public void execute() {
   IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   if (window != null) {
     WorkbenchPreferenceDialog dialog =
         WorkbenchPreferenceDialog.createDialogOn(window.getShell(), preferenceNode.getId());
     dialog.open();
   }
 }
Ejemplo n.º 2
0
  /** @return either Window.OK or Window.CANCEL */
  private int showPreferenceDialog() {
    FilteredPreferenceDialog dialog =
        WorkbenchPreferenceDialog.createDialogOn(window.getShell(), DebugPreferencePage.PAGE_ID);

    dialog.showOnly(new String[] {DebugPreferencePage.PAGE_ID});

    return dialog.open();
  }
  /**
   * Creates a workbench preference dialog and selects particular preference page. If there is
   * already a preference dialog open this dialog is used and its selection is set to the page with
   * id preferencePageId. Show the other pages as filtered results using whatever filtering criteria
   * the search uses. It is the responsibility of the caller to then call <code>open()</code>. The
   * call to <code>open()</code> will not return until the dialog closes, so this is the last chance
   * to manipulate the dialog.
   *
   * @param shell The Shell to parent the dialog off of if it is not already created. May be <code>
   *     null</code> in which case the active workbench window will be used if available.
   * @param preferencePageId The identifier of the preference page to open; may be <code>null</code>
   *     . If it is <code>null</code>, then the preference page is not selected or modified in any
   *     way.
   * @param displayedIds The ids of the other pages to be displayed using the same filtering
   *     criterea as search. If this is <code>null</code>, then the all preference pages are shown.
   * @param data Data that will be passed to all of the preference pages to be applied as specified
   *     within the page as they are created. If the data is <code>null</code> nothing will be
   *     called.
   * @return a preference dialog.
   * @since 3.1
   * @see PreferenceDialog#PreferenceDialog(Shell, PreferenceManager)
   */
  public static final PreferenceDialog createPreferenceDialogOn(
      Shell shell, String preferencePageId, String[] displayedIds, Object data) {
    FilteredPreferenceDialog dialog =
        WorkbenchPreferenceDialog.createDialogOn(shell, preferencePageId);

    applyOptions(data, displayedIds, dialog);

    return dialog;
  }