<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The wizard in this code is a standard wizard that displays pages, then generates code in the doFinish method. What is most interesting about this class is that in performFinish, it demonstrates how to interact with Eclipse's process monitor for tasks that take a long time.

    /**
       * This method is called when 'Finish' button is pressed 
       * in the wizard. We will create an operation and run it
       * using wizard as execution context.
       
    */

      
    public boolean performFinish() {
        final String containerName 
    = page.getContainerName();
        final String fileName 
    = page.getFileName();
        IRunnableWithProgress op 
    = new IRunnableWithProgress() 
        
    {
          
    public void run(IProgressMonitor monitor) 
              throws InvocationTargetException 
          
    {
            
    try {
              doFinish(containerName, fileName, monitor);
            }
     catch (CoreException e) {
              
    throw new InvocationTargetException(e);
            }
     finally {
              monitor.done();
            }

          }

        }
    ;
        
    try {
          getContainer().run(
    truefalse, op);
        }
     catch (InterruptedException e) {
          
    return false;
        }
     catch (InvocationTargetException e) {
          Throwable realException 
    = e.getTargetException();
          MessageDialog.openError(
              getShell(), 
              
    "Error", realException.getMessage());
          
    return false;
        }

        
    return true;
      }


    /*  */
    /**
       * The worker method. It will find the container, create
       * the file if missing or just replace its contents, and 
       * open the editor on the newly created file.
       
    */


      
    private void doFinish(
          String containerName,
          String fileName,
          IProgressMonitor monitor)
          throws CoreException 
      
    {
        
    // create a sample file
        monitor.beginTask("Creating " + fileName, 2);
        IWorkspaceRoot root 
    = 
            ResourcesPlugin.getWorkspace().getRoot();
        IResource resource 
    = root.findMember(
            
    new Path(containerName));
        
    if (!resource.exists() || 
            
    !(resource instanceof IContainer)) 
        
    {
          throwCoreException(
    "Container \"" + 
              containerName + "\" does not exist.");
        }

        IContainer container 
    = (IContainer) resource;
        final IFile file 
    = 
            container.getFile(
    new Path(fileName));
        
    try {
          InputStream stream 
    = openContentStream();
          
    if (file.exists()) {
            file.setContents(stream, 
    truetrue, monitor);
          }
     else {
            file.create(stream, 
    true, monitor);
          }

          stream.close();
        }
     catch (IOException e) {
        }

        monitor.worked(
    1);
        monitor.setTaskName(
    "Opening file for editing");
        getShell().getDisplay().asyncExec(
    new Runnable() {
            
    public void run() {
              IWorkbenchPage page 
    =
                  PlatformUI.getWorkbench().
                  getActiveWorkbenchWindow().getActivePage();
              
    try {
                IDE.openEditor(page, file, 
    true);
              }
     catch (PartInitException e) {
              }

            }

          }
    );
        monitor.worked(
    1);
      }


    This code is a simple SWT wizard page. The most interesting characteristic of this class is in the handleBrowse method. This method uses Eclipse's ContainerSelectionDialog for displaying the folders in the workspace.

    /**
       * Uses the standard container selection dialog to
       * choose the new value for the container field.
       
    */

      
    private void handleBrowse() {
        ContainerSelectionDialog dialog 
    =
            
    new ContainerSelectionDialog(
                getShell(),
                ResourcesPlugin.getWorkspace().getRoot(),
                
    false,
                
    "Select new file container");
        
    if (dialog.open() == ContainerSelectionDialog.OK) {
          Object[] result 
    = dialog.getResult();
          
    if (result.length == 1{
            containerText.setText(
                ((Path)result[
    0]).toOSString());
          }

        }

      }

     



    版權所有 羅明
    posted on 2005-07-10 10:35 羅明 閱讀(746) 評論(0)  編輯  收藏 所屬分類: Eclipse
     
    主站蜘蛛池模板: 曰批免费视频播放免费| 国产精品免费视频网站| 九九久久国产精品免费热6| 亚洲一区二区三区高清不卡| 亚洲国产婷婷六月丁香| 免费午夜爽爽爽WWW视频十八禁| 中文字幕免费视频一| 免费国产污网站在线观看| 国产亚洲精品欧洲在线观看| 亚洲人成电影网站久久| 久久亚洲精品国产精品| 亚洲无线观看国产精品| 亚洲国产精品狼友中文久久久| 在线a人片天堂免费观看高清| 222www在线观看免费| 四虎影视在线影院在线观看免费视频 | 成人午夜18免费看| 亚洲视频在线免费看| 久久99精品国产免费观看| 成在人线av无码免费高潮水| 日日摸夜夜添夜夜免费视频 | 国产成人精品免费直播| 在线A级毛片无码免费真人| 无码永久免费AV网站| 0588影视手机免费看片| 1000部夫妻午夜免费| 99xxoo视频在线永久免费观看| 永久免费不卡在线观看黄网站| 少妇性饥渴无码A区免费| 成人影片一区免费观看| 中文字幕av免费专区| 中文字幕高清免费不卡视频| 国产V片在线播放免费无码| 国产区在线免费观看| 一区二区三区免费视频播放器| 九九久久国产精品免费热6| a一级爱做片免费| a级毛片免费观看视频| 污污网站免费观看| 成人免费视频69| 毛片免费全部播放一级|