Esempio n. 1
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.IWizard#addPages()
   */
  public void addPages() {
    if (addingPages) return;

    try {
      addingPages = true;
      pages = new ArrayList<IWizardPage>();
      Iterator<WizardFragment> iterator = getAllWizardFragments().iterator();
      while (iterator.hasNext()) {
        WizardFragment fragment = (WizardFragment) iterator.next();
        FragmentedWizardPage page = getFragmentData(fragment);
        if (fragment.hasComposite()) {
          if (page != null) {
            addPage(page);
          } else {
            page = new FragmentedWizardPage(fragment);
            fragmentData.put(fragment, page);
            addPage(page);
          }
        }
      }
    } catch (Exception e) {
      PHPUiPlugin.log(
          new Status(
              IStatus.ERROR,
              PHPUiPlugin.ID,
              0,
              "Error adding fragments to wizard",
              e)); //$NON-NLS-1$
    } finally {
      addingPages = false;
    }
  }
Esempio n. 2
0
  /**
   * Cancel the client selection.
   *
   * @return boolean
   */
  public boolean performCancel() {
    final List<WizardFragment> list = getAllWizardFragments();
    IRunnableWithProgress runnable =
        new IRunnableWithProgress() {
          public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
              Iterator<WizardFragment> iterator = list.iterator();
              while (iterator.hasNext())
                executeTask((WizardFragment) iterator.next(), CANCEL, monitor);
            } catch (CoreException ce) {
              throw new InvocationTargetException(ce);
            }
          }
        };

    Throwable t = null;
    try {
      if (getContainer() != null) getContainer().run(true, true, runnable);
      else runnable.run(new NullProgressMonitor());
      return true;
    } catch (InvocationTargetException te) {
      t = te.getCause();
    } catch (Exception e) {
      t = e;
    }
    PHPUiPlugin.log(
        new Status(
            IStatus.ERROR, PHPUiPlugin.ID, 0, "Error cancelling task wizard", t)); // $NON-NLS-1$

    if (t instanceof CoreException) {
      openError(t.getLocalizedMessage(), ((CoreException) t).getStatus());
    } else openError(t.getLocalizedMessage());

    return false;
  }
Esempio n. 3
0
  private FragmentedWizardPage getFragmentData(WizardFragment fragment) {
    try {
      FragmentedWizardPage page = (FragmentedWizardPage) fragmentData.get(fragment);
      if (page != null) return page;
    } catch (Exception e) {
      PHPUiPlugin.log(
          new Status(
              IStatus.ERROR, PHPUiPlugin.ID, 0, "Error getting fragment data", e)); // $NON-NLS-1$
    }

    return null;
  }
  /**
   * Performs the reconcile and returns the AST if it was computed.
   *
   * @param unit the compilation unit
   * @param initialReconcile <code>true</code> if this is the initial reconcile
   * @return the AST or <code>null</code> if none
   * @throws JavaModelException if the original Java element does not exist
   * @since 3.4
   */
  private Program reconcile(ISourceModule unit, boolean initialReconcile) throws ModelException {
    /* fix for missing cancel flag communication */
    IProblemRequestorExtension extension = getProblemRequestorExtension();
    if (extension != null) {
      extension.setProgressMonitor(fProgressMonitor);
      extension.setIsActive(true);
    }

    try {
      final ASTProvider astProvider = PHPUiPlugin.getDefault().getASTProvider();

      synchronized (unit) {
        unit.reconcile(true, null, fProgressMonitor);
      }

      // read DOM AST from provider if avaiable
      Program createdAST = astProvider.getAST(unit, SharedASTProvider.WAIT_NO, fProgressMonitor);
      if (astProvider.isActive(unit) && createdAST != null) {
        return createdAST;
      }

      if (initialReconcile || astProvider.isActive(unit)) {
        PHPVersion phpVersion = ProjectOptions.getPhpVersion(unit.getScriptProject().getProject());
        ASTParser newParser = ASTParser.newParser(phpVersion, unit);
        createdAST = newParser.createAST(null);
        if (createdAST != null && document != null) {
          createdAST.setSourceModule(unit);
          createdAST.setSourceRange(0, document.getLength());
          createdAST.setLineEndTable(Util.lineEndTable(document));
        }
        return createdAST;
      }

    } catch (OperationCanceledException ex) {
      Assert.isTrue(fProgressMonitor == null || fProgressMonitor.isCanceled());

    } catch (Exception e) {
      throw new ModelException(e, IStatus.ERROR);

    } finally {
      /* fix for missing cancel flag communication */
      if (extension != null) {
        extension.setProgressMonitor(null);
        extension.setIsActive(false);
      }
    }

    return null;
  }
Esempio n. 5
0
    public JavaScriptSupportGroup(Composite composite, WizardPage projectWizardFirstPage) {
      final int numColumns = 3;
      fGroup = new Group(composite, SWT.NONE);
      fGroup.setFont(composite.getFont());

      fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fGroup.setLayout(initGridLayout(new GridLayout(numColumns, false), true));
      fGroup.setText(PHPUIMessages.JavaScriptSupportGroup_OptionBlockTitle); // $NON-NLS-1$

      fEnableJavaScriptSupport = new Button(fGroup, SWT.CHECK | SWT.RIGHT);
      fEnableJavaScriptSupport.setText(
          PHPUIMessages.JavaScriptSupportGroup_EnableSupport); // $NON-NLS-1$
      fEnableJavaScriptSupport.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
      fEnableJavaScriptSupport.addSelectionListener(this);
      fEnableJavaScriptSupport.setSelection(
          PHPUiPlugin.getDefault()
              .getPreferenceStore()
              .getBoolean((PreferenceConstants.JavaScriptSupportEnable)));
    }
Esempio n. 6
0
 private void registerInWorkspaceIfNeeded() {
   IPath jarPath = fJarPackage.getAbsolutePharLocation();
   IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
   for (int i = 0; i < projects.length; i++) {
     IProject project = projects[i];
     // The Jar is always put into the local file system. So it can only be
     // part of a project if the project is local as well. So using getLocation
     // is currently save here.
     IPath projectLocation = project.getLocation();
     if (projectLocation != null && projectLocation.isPrefixOf(jarPath)) {
       try {
         jarPath = jarPath.removeFirstSegments(projectLocation.segmentCount());
         jarPath = jarPath.removeLastSegments(1);
         IResource containingFolder = project.findMember(jarPath);
         if (containingFolder != null && containingFolder.isAccessible())
           containingFolder.refreshLocal(IResource.DEPTH_ONE, null);
       } catch (CoreException ex) {
         // don't refresh the folder but log the problem
         PHPUiPlugin.log(ex);
       }
     }
   }
 }
Esempio n. 7
0
  public boolean performFinish() {
    if (currentFragment != null) currentFragment.exit();

    final WizardFragment cFragment = currentFragment;

    status = Status.OK_STATUS;

    final List<WizardFragment> list = getAllWizardFragments();
    IRunnableWithProgress runnable =
        new IRunnableWithProgress() {
          public void run(IProgressMonitor monitor) {
            // enter & exit the remaining pages
            int index = list.indexOf(cFragment);
            while (index > 0 && index < list.size() - 1) {
              final WizardFragment fragment = (WizardFragment) list.get(++index);
              try {
                Display.getDefault()
                    .syncExec(
                        new Runnable() {
                          public void run() {
                            FragmentedWizardPage page = getFragmentData(fragment);
                            if (page.getControl() == null && pageContainerHook != null) {
                              page.createControl(pageContainerHook);
                            }
                            fragment.enter();
                            fragment.exit();
                          }
                        });
              } catch (Exception e) {
                PHPUiPlugin.log(
                    new Status(
                        IStatus.ERROR,
                        PHPUiPlugin.ID,
                        0,
                        "Could not enter/exit page",
                        e)); //$NON-NLS-1$
              }
            }

            if (useJob()) {
              class FinishWizardJob extends Job {
                public FinishWizardJob() {
                  super(getJobTitle());
                }

                public boolean belongsTo(Object family) {
                  return "org.eclipse.wst.server.ui.family".equals(family); // $NON-NLS-1$
                }

                public IStatus run(IProgressMonitor monitor2) {
                  try {
                    Iterator<WizardFragment> iterator = list.iterator();
                    while (iterator.hasNext()) executeTask(iterator.next(), FINISH, monitor2);
                  } catch (CoreException ce) {
                    Status status =
                        new Status(
                            IStatus.ERROR, PHPUiPlugin.ID, 0, ce.getLocalizedMessage(), null);
                    PHPUiPlugin.log(status);
                    return status;
                  }
                  return Status.OK_STATUS;
                }
              }

              FinishWizardJob job = new FinishWizardJob();
              job.setUser(true);
              job.schedule();
            } else {
              Iterator<WizardFragment> iterator = list.iterator();
              while (iterator.hasNext())
                try {
                  WizardFragment fragment = (WizardFragment) iterator.next();
                  if (!executeTask(fragment, FINISH, monitor)) {
                    status =
                        new Status(
                            IStatus.ERROR,
                            PHPUiPlugin.ID,
                            "Error during wizard page execution."); //$NON-NLS-1$
                  }
                } catch (CoreException e) {
                  PHPUiPlugin.log(e);
                }
            }
          }
        };

    Throwable t = null;
    try {
      if (getContainer() != null) getContainer().run(true, true, runnable);
      else runnable.run(new NullProgressMonitor());
      if (status.getSeverity() != IStatus.OK) {
        return false;
      }
      return true;
    } catch (InvocationTargetException te) {
      PHPUiPlugin.log(
          new Status(
              IStatus.ERROR, PHPUiPlugin.ID, 0, "Error finishing task wizard", te)); // $NON-NLS-1$
      t = te.getCause();
    } catch (Exception e) {
      PHPUiPlugin.log(
          new Status(
              IStatus.ERROR, PHPUiPlugin.ID, 0, "Error finishing task wizard 2", e)); // $NON-NLS-1$
      t = e;
    }
    if (t instanceof CoreException) {
      openError(t.getLocalizedMessage(), ((CoreException) t).getStatus());
    } else if (t instanceof NullPointerException) openError(PHPUIMessages.FragmentedWizard_7);
    else openError(t.getLocalizedMessage());

    return false;
  }
Esempio n. 8
0
 public boolean shouldSupportJavaScript() {
   return PHPUiPlugin.getDefault()
       .getPreferenceStore()
       .getBoolean((PreferenceConstants.JavaScriptSupportEnable));
 }