示例#1
0
 public IStructuredSelection adaptedSelection(IStructuredSelection selection) {
   return delegate.adaptedSelection(selection);
 }
示例#2
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.wizard.IWizardNode#getWizard()
   */
  public IWizard getWizard() {
    if (wizard != null) {
      return wizard; // we've already created it
    }

    final IWorkbenchWizard[] workbenchWizard = new IWorkbenchWizard[1];
    final IStatus statuses[] = new IStatus[1];
    // Start busy indicator.
    BusyIndicator.showWhile(
        parentWizardPage.getShell().getDisplay(),
        new Runnable() {
          public void run() {
            SafeRunner.run(
                new SafeRunnable() {
                  /** Add the exception details to status is one happens. */
                  public void handleException(Throwable e) {
                    IPluginContribution contribution =
                        (IPluginContribution)
                            Util.getAdapter(wizardElement, IPluginContribution.class);
                    statuses[0] =
                        new Status(
                            IStatus.ERROR,
                            contribution != null
                                ? contribution.getPluginId()
                                : WorkbenchPlugin.PI_WORKBENCH,
                            IStatus.OK,
                            WorkbenchMessages.get().WorkbenchWizard_errorMessage,
                            e);
                  }

                  public void run() {
                    try {
                      workbenchWizard[0] = createWizard();
                      // create instance of target wizard
                    } catch (CoreException e) {
                      IPluginContribution contribution =
                          (IPluginContribution)
                              Util.getAdapter(wizardElement, IPluginContribution.class);
                      statuses[0] =
                          new Status(
                              IStatus.ERROR,
                              contribution != null
                                  ? contribution.getPluginId()
                                  : WorkbenchPlugin.PI_WORKBENCH,
                              IStatus.OK,
                              WorkbenchMessages.get().WorkbenchWizard_errorMessage,
                              e);
                    }
                  }
                });
          }
        });

    if (statuses[0] != null) {
      parentWizardPage.setErrorMessage(WorkbenchMessages.get().WorkbenchWizard_errorMessage);
      StatusAdapter statusAdapter = new StatusAdapter(statuses[0]);
      statusAdapter.addAdapter(Shell.class, parentWizardPage.getShell());
      statusAdapter.setProperty(
          StatusAdapter.TITLE_PROPERTY, WorkbenchMessages.get().WorkbenchWizard_errorTitle);
      StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);
      return null;
    }

    IStructuredSelection currentSelection = getCurrentResourceSelection();

    // Get the adapted version of the selection that works for the
    // wizard node
    currentSelection = wizardElement.adaptedSelection(currentSelection);

    workbenchWizard[0].init(getWorkbench(), currentSelection);

    wizard = workbenchWizard[0];
    return wizard;
  }