private IWorkingSet[] getWorkingSets(IStructuredSelection selection) {
    IWorkingSet[] selected = WorkingSetConfigurationBlock.getSelectedWorkingSet(selection);
    if (selected != null && selected.length > 0) {
      for (int i = 0; i < selected.length; i++) {
        if (!isValidWorkingSet(selected[i])) return null;
      }
      return selected;
    }

    PackageExplorerPart explorerPart = getActivePackageExplorer();
    if (explorerPart == null) return null;

    if (explorerPart.getRootMode() == ViewActionGroup.SHOW_PROJECTS) {
      // Get active filter
      IWorkingSet filterWorkingSet = explorerPart.getFilterWorkingSet();
      if (filterWorkingSet == null) return null;

      if (!isValidWorkingSet(filterWorkingSet)) return null;

      return new IWorkingSet[] {filterWorkingSet};
    } else if (explorerPart.getRootMode() == ViewActionGroup.SHOW_WORKING_SETS) {
      // If we have been gone into a working set return the working set
      Object input = explorerPart.getViewPartInput();
      if (!(input instanceof IWorkingSet)) return null;

      IWorkingSet workingSet = (IWorkingSet) input;
      if (!isValidWorkingSet(workingSet)) return null;

      return new IWorkingSet[] {workingSet};
    }

    return null;
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.wizard.IWizard#performFinish()
   */
  public boolean performFinish() {
    boolean res = super.performFinish();
    if (res) {
      final IJavaScriptElement newElement = getCreatedElement();

      IWorkingSet[] workingSets = fFirstPage.getWorkingSets();
      WorkingSetConfigurationBlock.addToWorkingSets(newElement, workingSets);

      BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
      selectAndReveal(fSecondPage.getJavaProject().getProject());

      Display.getDefault()
          .asyncExec(
              new Runnable() {
                public void run() {
                  PackageExplorerPart activePackageExplorer = getActivePackageExplorer();
                  if (activePackageExplorer != null) {
                    activePackageExplorer.tryToReveal(newElement);
                  }
                }
              });
    }
    return res;
  }