<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
     
    主站蜘蛛池模板: 久久九九亚洲精品| 黄人成a动漫片免费网站| 亚洲日韩一区二区三区| 黄色网站软件app在线观看免费| 好吊妞在线新免费视频| 久久久国产精品亚洲一区| h视频在线免费观看| 国产美女做a免费视频软件| 亚洲三级视频在线| 精品无码无人网站免费视频| 亚洲av无码一区二区三区不卡| 中文字幕免费观看视频| 国产aⅴ无码专区亚洲av麻豆| 精品女同一区二区三区免费播放| 成年女人色毛片免费看| 亚洲最大福利视频| 中国在线观看免费高清完整版| 亚洲av永久无码精品天堂久久| 亚洲精品成人网久久久久久| 亚洲另类无码一区二区三区| 精品国产亚洲一区二区三区 | 香蕉国产在线观看免费| 亚洲国产一区视频| 性短视频在线观看免费不卡流畅| 亚洲一卡一卡二新区无人区| 午夜视频免费成人| 日韩人妻一区二区三区免费| 亚洲国产片在线观看| 日韩欧美一区二区三区免费观看| 亚洲AV日韩综合一区尤物| 免费黄色一级毛片| 日韩毛片在线免费观看| 亚洲精品国产高清嫩草影院| 国产在线国偷精品产拍免费| 8888四色奇米在线观看免费看| 亚洲免费日韩无码系列| 国产亚洲欧美在线观看| 免费精品国产自产拍观看| 岛国精品一区免费视频在线观看| 日本亚洲中午字幕乱码| 成人亚洲国产va天堂|