public void run(IMarker marker) {
   PreferencesUtil.createPropertyDialogOn(
           JavaPlugin.getActiveWorkbenchShell(),
           fProject,
           BuildPathsPropertyPage.PROP_ID,
           null,
           null)
       .open();
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker)
   */
  public IMarkerResolution[] getResolutions(IMarker marker) {
    final Shell shell = JavaPlugin.getActiveWorkbenchShell();
    if (!hasResolutions(marker) || shell == null) {
      return NO_RESOLUTION;
    }

    ArrayList<IMarkerResolution2> resolutions = new ArrayList<IMarkerResolution2>();

    final IJavaProject project = getJavaProject(marker);

    int id = marker.getAttribute(IJavaModelMarker.ID, -1);
    if (id == IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND) {
      String[] arguments = CorrectionEngine.getProblemArguments(marker);
      final IPath path = new Path(arguments[0]);

      if (path.segment(0).equals(JavaCore.USER_LIBRARY_CONTAINER_ID)) {
        String label = NewWizardMessages.UserLibraryMarkerResolutionGenerator_changetouserlib_label;
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        resolutions.add(
            new UserLibraryMarkerResolution(label, image) {
              public void run(IMarker m) {
                changeToExistingLibrary(shell, path, false, project);
              }
            });
        if (path.segmentCount() == 2) {
          String label2 =
              Messages.format(
                  NewWizardMessages.UserLibraryMarkerResolutionGenerator_createuserlib_label,
                  path.segment(1));
          Image image2 = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_LIBRARY);
          resolutions.add(
              new UserLibraryMarkerResolution(label2, image2) {
                public void run(IMarker m) {
                  createUserLibrary(shell, path);
                }
              });
        }
      }
      String label = NewWizardMessages.UserLibraryMarkerResolutionGenerator_changetoother;
      Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
      resolutions.add(
          new UserLibraryMarkerResolution(label, image) {
            public void run(IMarker m) {
              changeToExistingLibrary(shell, path, true, project);
            }
          });
    }

    if (project != null) {
      resolutions.add(new OpenBuildPathMarkerResolution(project));
    }

    return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
   */
  public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
    if (stateMask == SWT.CONTROL && fCleanUp != null) {
      CleanUpRefactoring refactoring = new CleanUpRefactoring();
      refactoring.addCompilationUnit(getCompilationUnit());
      refactoring.addCleanUp(fCleanUp);
      refactoring.setLeaveFilesDirty(true);

      int stopSeverity = RefactoringCore.getConditionCheckingFailedSeverity();
      Shell shell = JavaPlugin.getActiveWorkbenchShell();
      IRunnableContext context = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      RefactoringExecutionHelper executer =
          new RefactoringExecutionHelper(
              refactoring, stopSeverity, RefactoringSaveHelper.SAVE_NOTHING, shell, context);
      try {
        executer.perform(true, true);
      } catch (InterruptedException e) {
      } catch (InvocationTargetException e) {
        JavaPlugin.log(e);
      }
      return;
    }
    apply(viewer.getDocument());
  }
  /*
   * @see ICompletionProposal#getAdditionalProposalInfo()
   */
  @Override
  public String getAdditionalProposalInfo() {
    try {
      fContext.setReadOnly(true);
      TemplateBuffer templateBuffer;
      try {
        templateBuffer = fContext.evaluate(fTemplate);
      } catch (TemplateException e) {
        return null;
      }

      IDocument document = new Document(templateBuffer.getString());
      IndentUtil.indentLines(document, new LineRange(0, document.getNumberOfLines()), null, null);
      return document.get();

    } catch (BadLocationException e) {
      handleException(
          JavaPlugin.getActiveWorkbenchShell(),
          new CoreException(
              new Status(
                  IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "", e))); // $NON-NLS-1$
      return null;
    }
  }
  /** {@inheritDoc} */
  @Override
  public void run() {
    final IJavaProject project = (IJavaProject) getSelectedElements().get(0);

    Shell shell = getShell();
    if (shell == null) {
      shell = JavaPlugin.getActiveWorkbenchShell();
    }

    IClasspathEntry[] classpath;
    try {
      classpath = project.getRawClasspath();
    } catch (JavaModelException e1) {
      showExceptionDialog(e1, NewWizardMessages.AddLibraryToBuildpathAction_ErrorTitle);
      return;
    }

    ClasspathContainerWizard wizard =
        new ClasspathContainerWizard((IClasspathEntry) null, project, classpath) {

          /** {@inheritDoc} */
          @Override
          public boolean performFinish() {
            if (super.performFinish()) {
              IWorkspaceRunnable op =
                  new IWorkspaceRunnable() {
                    public void run(IProgressMonitor monitor)
                        throws CoreException, OperationCanceledException {
                      try {
                        finishPage(monitor);
                      } catch (InterruptedException e) {
                        throw new OperationCanceledException(e.getMessage());
                      }
                    }
                  };
              try {
                ISchedulingRule rule = null;
                Job job = Job.getJobManager().currentJob();
                if (job != null) rule = job.getRule();
                IRunnableWithProgress runnable = null;
                if (rule != null) runnable = new WorkbenchRunnableAdapter(op, rule, true);
                else
                  runnable =
                      new WorkbenchRunnableAdapter(op, ResourcesPlugin.getWorkspace().getRoot());
                getContainer().run(false, true, runnable);
              } catch (InvocationTargetException e) {
                JavaPlugin.log(e);
                return false;
              } catch (InterruptedException e) {
                return false;
              }
              return true;
            }
            return false;
          }

          private void finishPage(IProgressMonitor pm) throws InterruptedException {
            IClasspathEntry[] selected = getNewEntries();
            if (selected != null) {
              try {
                pm.beginTask(NewWizardMessages.ClasspathModifier_Monitor_AddToBuildpath, 4);

                List<CPListElement> addedEntries = new ArrayList<CPListElement>();
                for (int i = 0; i < selected.length; i++) {
                  addedEntries.add(CPListElement.create(selected[i], true, project));
                }

                pm.worked(1);
                if (pm.isCanceled()) throw new InterruptedException();

                List<CPListElement> existingEntries = ClasspathModifier.getExistingEntries(project);
                ClasspathModifier.setNewEntry(
                    existingEntries, addedEntries, project, new SubProgressMonitor(pm, 1));
                if (pm.isCanceled()) throw new InterruptedException();

                ClasspathModifier.commitClassPath(
                    existingEntries, project, new SubProgressMonitor(pm, 1));

                BuildpathDelta delta = new BuildpathDelta(getToolTipText());
                delta.setNewEntries(
                    existingEntries.toArray(new CPListElement[existingEntries.size()]));
                informListeners(delta);

                List<ClassPathContainer> result =
                    new ArrayList<ClassPathContainer>(addedEntries.size());
                for (int i = 0; i < addedEntries.size(); i++) {
                  result.add(new ClassPathContainer(project, selected[i]));
                }
                selectAndReveal(new StructuredSelection(result));

                pm.worked(1);
              } catch (CoreException e) {
                showExceptionDialog(e, NewWizardMessages.AddLibraryToBuildpathAction_ErrorTitle);
              } finally {
                pm.done();
              }
            }
          }
        };
    wizard.setNeedsProgressMonitor(true);

    WizardDialog dialog = new WizardDialog(shell, wizard);
    PixelConverter converter = new PixelConverter(shell);
    dialog.setMinimumPageSize(
        converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
    dialog.create();
    dialog.open();
  }
  /**
   * Informs the user about the fact that there are no enabled categories in the default content
   * assist set and shows a link to the preferences.
   *
   * @return <code>true</code> if the default should be restored
   * @since 3.3
   */
  private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
      final Shell shell = JavaPlugin.getActiveWorkbenchShell();
      String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title;
      String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message;
      // see PreferencePage#createControl for the 'defaults' label
      final String restoreButtonLabel = JFaceResources.getString("defaults"); // $NON-NLS-1$
      final String linkMessage =
          Messages.format(
              JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link,
              LegacyActionTools.removeMnemonics(restoreButtonLabel));
      final int restoreId = IDialogConstants.CLIENT_ID + 10;
      final int settingsId = IDialogConstants.CLIENT_ID + 11;
      final OptionalMessageDialog dialog =
          new OptionalMessageDialog(
              PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
              shell,
              title,
              null /* default image */,
              message,
              MessageDialog.WARNING,
              new String[] {restoreButtonLabel, IDialogConstants.CLOSE_LABEL},
              1) {
            /*
             * @see org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected Control createCustomArea(Composite composite) {
              // wrap link and checkbox in one composite without space
              Composite parent = new Composite(composite, SWT.NONE);
              GridLayout layout = new GridLayout();
              layout.marginHeight = 0;
              layout.marginWidth = 0;
              layout.verticalSpacing = 0;
              parent.setLayout(layout);

              Composite linkComposite = new Composite(parent, SWT.NONE);
              layout = new GridLayout();
              layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
              layout.marginWidth =
                  convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
              layout.horizontalSpacing =
                  convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
              linkComposite.setLayout(layout);

              Link link = new Link(linkComposite, SWT.NONE);
              link.setText(linkMessage);
              link.addSelectionListener(
                  new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                      setReturnCode(settingsId);
                      close();
                    }
                  });
              GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
              gridData.widthHint = this.getMinimumMessageWidth();
              link.setLayoutData(gridData);

              // create checkbox and "don't show this message" prompt
              super.createCustomArea(parent);

              return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected void createButtonsForButtonBar(Composite parent) {
              Button[] buttons = new Button[2];
              buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
              buttons[1] =
                  createButton(
                      parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
              setButtons(buttons);
            }
          };
      int returnValue = dialog.open();
      if (restoreId == returnValue || settingsId == returnValue) {
        if (restoreId == returnValue) {
          IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
          store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
          store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
        }
        if (settingsId == returnValue)
          PreferencesUtil.createPreferenceDialogOn(
                  shell, "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null)
              .open(); //$NON-NLS-1$
        fComputerRegistry.reload();
        return true;
      }
    }
    return false;
  }
 /**
  * Returns the configured shell. If no shell has been configured using {@link #setShell(Shell)},
  * the shell of the currently active workbench is returned.
  *
  * @return the configured shell
  */
 protected Shell getShell() {
   if (fShell == null) {
     return JavaPlugin.getActiveWorkbenchShell();
   }
   return fShell;
 }
 private Shell getShell() {
   Assert.isTrue(fWizard == null || fShell == null);
   if (fWizard != null) return fWizard.getContainer().getShell();
   else if (fShell != null) return fShell;
   else return JavaPlugin.getActiveWorkbenchShell();
 }