<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
     
    主站蜘蛛池模板: 亚洲成aⅴ人片在线影院八| 区久久AAA片69亚洲| 亚洲国产精品免费视频| 国产亚洲一区二区在线观看| 国产永久免费高清在线| 亚洲AV无码专区在线播放中文| 日本免费一区二区三区四区五六区 | 91av在线免费视频| 亚洲黄色高清视频| 国产VA免费精品高清在线| jlzzjlzz亚洲乱熟在线播放| 男人天堂免费视频| 亚洲经典在线观看| 亚洲欧洲免费无码| 美女被爆羞羞网站在免费观看| 国产亚洲成归v人片在线观看 | 国产国产成年年人免费看片| 日韩精品亚洲专区在线影视| 亚洲国产天堂久久综合| 久久国产精品成人免费| 亚洲性色高清完整版在线观看| 国内外成人免费视频| 一级看片免费视频| 亚洲日本中文字幕区| 午夜dj免费在线观看| 国产福利在线观看永久免费| 久久亚洲精品成人AV| 日韩中文字幕免费| a级黄色毛片免费播放视频| 亚洲精品国产手机| 免费人成无码大片在线观看| A级毛片高清免费视频在线播放| 亚洲免费福利视频| 免费专区丝袜脚调教视频| 久久亚洲精品无码网站| 日韩精品视频免费网址| 黄色网址免费在线观看| 国产AV旡码专区亚洲AV苍井空| 亚洲男人在线无码视频| 99在线热视频只有精品免费| 色欲aⅴ亚洲情无码AV|