<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());
          }

        }

      }

     



    版權(quán)所有 羅明
    posted on 2005-07-10 10:35 羅明 閱讀(745) 評論(0)  編輯  收藏 所屬分類: Eclipse
     
    主站蜘蛛池模板: 性生大片视频免费观看一级| 好吊妞在线成人免费| 亚在线观看免费视频入口| 最近2019中文字幕免费直播| 热久久精品免费视频| 久久精品亚洲乱码伦伦中文| 久久精品国产亚洲香蕉| 亚洲色大成网站www永久男同| 一级A毛片免费观看久久精品| 久久国产精品免费看| 波多野结衣久久高清免费| 相泽亚洲一区中文字幕| 亚洲嫩草影院在线观看| 一区二区三区AV高清免费波多| 久久免费福利视频| 国产一级做a爱免费视频| 91在线精品亚洲一区二区| 精品视频免费在线| 91大神免费观看| 亚洲人成国产精品无码| 亚洲三级视频在线| 中国内地毛片免费高清| 日本免费电影一区| 久久久久久久亚洲Av无码| 深夜A级毛片视频免费| 男人进去女人爽免费视频国产| 成人免费视频国产| 亚洲人成电影在线观看青青| 一区二区三区免费视频网站| 青苹果乐园免费高清在线| 亚洲成人午夜在线| 黄床大片免费30分钟国产精品 | 亚洲精品福利网站| 永久免费无码网站在线观看个| 免费观看无遮挡www的视频| 亚洲精品无码成人片久久| 黄色网址免费在线| 香蕉高清免费永久在线视频| 亚洲欧洲日产v特级毛片| 中文字幕无码免费久久| 浮力影院亚洲国产第一页|