<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 羅明 閱讀(751) 評論(0)  編輯  收藏 所屬分類: Eclipse
     
    主站蜘蛛池模板: 亚洲五月午夜免费在线视频| 亚洲校园春色另类激情| 国产一级一片免费播放i| 成人免费无码精品国产电影| 亚洲国产成人精品无码久久久久久综合 | 国产亚洲精品国产| 久久精品九九亚洲精品| 亚洲国产系列一区二区三区 | 一个人免费观看视频在线中文| 精品久久久久久无码免费| 中文在线免费不卡视频| 四虎最新永久免费视频| 国产极品美女高潮抽搐免费网站| 久久精品国产亚洲综合色| 亚洲日本中文字幕天天更新| 91av免费在线视频| 最近中文字幕免费mv视频8| 亚洲免费视频一区二区三区| 亚洲jjzzjjzz在线观看| 一区二区三区免费视频网站| 国产精品亚洲二区在线观看| 中文字幕成人免费高清在线视频| 亚洲αv在线精品糸列| 日韩亚洲人成在线综合| 久久一本岛在免费线观看2020| 日韩午夜免费视频| 免费在线观看亚洲| 最近高清国语中文在线观看免费| 亚洲国产精品ⅴa在线观看| 色欲国产麻豆一精品一AV一免费 | 亚洲乱码无码永久不卡在线| 91人人区免费区人人| 亚洲人成77777在线播放网站| 亚洲a∨国产av综合av下载| 免费在线看v网址| 久久精品国产亚洲综合色| 美女视频黄免费亚洲| 特级毛片全部免费播放a一级| 免费观看的毛片手机视频| 亚洲国产精品成人精品软件 | 国产99视频精品免费观看7|