/*
   * Implementation of method defined on <code>IAction</code>.
   */
  @Override
  public void run() {
    IResourceNavigator navigator = getNavigator();
    ResourcePatternFilter filter = navigator.getPatternFilter();
    FiltersContentProvider contentProvider = new FiltersContentProvider(filter);

    ListSelectionDialog dialog =
        new ListSelectionDialog(
            getShell(),
            getViewer(),
            contentProvider,
            new LabelProvider(),
            FILTER_SELECTION_MESSAGE);

    dialog.setTitle(FILTER_TITLE_MESSAGE);
    dialog.setInitialSelections(contentProvider.getInitialSelections());
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {
      Object[] results = dialog.getResult();
      String[] selectedPatterns = new String[results.length];
      System.arraycopy(results, 0, selectedPatterns, 0, results.length);
      filter.setPatterns(selectedPatterns);
      navigator.setFiltersPreference(selectedPatterns);
      Viewer viewer = getViewer();
      viewer.getControl().setRedraw(false);
      viewer.refresh();
      viewer.getControl().setRedraw(true);
    }
  }
Exemplo n.º 2
0
  /*
   * Implementation of method defined on <code>IAction</code>.
   */
  public void run() {
    FiltersContentProvider contentProvider = new FiltersContentProvider();

    ListSelectionDialog dialog =
        new ListSelectionDialog(
            explorer.getSite().getShell(),
            explorer.getTreeViewer(),
            contentProvider,
            new LabelProvider(),
            FILTER_SELECTION_MESSAGE);
    dialog.setTitle(FILTER_TITLE_MESSAGE);
    dialog.setInitialSelections(contentProvider.getInitialSelections());
    dialog.open();
    if (dialog.getReturnCode() == Dialog.OK) {
      Object[] results = dialog.getResult();
      String[] selectedPatterns = new String[results.length];
      System.arraycopy(results, 0, selectedPatterns, 0, results.length);
      contentProvider.setSelections(selectedPatterns);
      Viewer viewer = explorer.getTreeViewer();
      viewer.getControl().setRedraw(false);
      explorer.updateFilters(selectedPatterns);
      viewer.refresh();
      viewer.getControl().setRedraw(true);
    }
  }
  protected EnvironmentVariable[] addExisted() {

    // get Environment Variables from the Environment
    Map envVariables = getNativeEnvironment();
    if (envVariables.size() == 0) {
      MessageBox box = new MessageBox(fDialog.getShell(), SWT.ICON_ERROR);
      box.setMessage(
          MessageFormat.format(
              InterpretersMessages
                  .AbstractInterpreterEnvironmentVariablesBlock_couldNotRetrieveEnvironmentVariablesFrom,
              new Object[] {fDialog.getEnvironment().getName()}));
      box.setText(
          InterpretersMessages
              .AbstractInterpreterEnvironmentVariablesBlock_failedToRetrieveEnvironment);
      box.open();
      return null;
    }

    // get Environment Variables from the table
    EnvironmentVariable[] items = fEnvironmentVariablesContentProvider.getVariables();
    for (int i = 0; i < items.length; i++) {
      EnvironmentVariable var = (EnvironmentVariable) items[i];
      envVariables.remove(var.getName());
    }

    ListSelectionDialog dialog =
        new ListSelectionDialog(
            fDialog.getShell(),
            envVariables,
            createSelectionDialogContentProvider(),
            createSelectionDialogLabelProvider(),
            LaunchConfigurationsMessages.EnvironmentTab_19);
    dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20);

    int button = dialog.open();
    if (button == Window.OK) {
      Object[] selected = dialog.getResult();
      EnvironmentVariable[] vars = new EnvironmentVariable[selected.length];
      for (int i = 0; i < vars.length; i++) {
        vars[i] = (EnvironmentVariable) selected[i];
      }
      return vars;
    }
    return null;
  }
  private CPListElement[] openProjectDialog(CPListElement elem) {

    try {
      ArrayList selectable = new ArrayList();
      selectable.addAll(Arrays.asList(fCurrJProject.getJavaScriptModel().getJavaScriptProjects()));
      selectable.remove(fCurrJProject);

      List elements = fProjectsList.getElements();
      for (int i = 0; i < elements.size(); i++) {
        CPListElement curr = (CPListElement) elements.get(0);
        IJavaScriptProject proj = (IJavaScriptProject) JavaScriptCore.create(curr.getResource());
        selectable.remove(proj);
      }
      Object[] selectArr = selectable.toArray();
      new JavaScriptElementComparator().sort(null, selectArr);

      ListSelectionDialog dialog =
          new ListSelectionDialog(
              getShell(),
              Arrays.asList(selectArr),
              new ArrayContentProvider(),
              new JavaUILabelProvider(),
              NewWizardMessages.ProjectsWorkbookPage_chooseProjects_message);
      dialog.setTitle(NewWizardMessages.ProjectsWorkbookPage_chooseProjects_title);
      dialog.setHelpAvailable(false);
      if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        CPListElement[] cpElements = new CPListElement[result.length];
        for (int i = 0; i < result.length; i++) {
          IJavaScriptProject curr = (IJavaScriptProject) result[i];
          cpElements[i] =
              new CPListElement(
                  fCurrJProject, IIncludePathEntry.CPE_PROJECT, curr.getPath(), curr.getResource());
        }
        return cpElements;
      }
    } catch (JavaScriptModelException e) {
      return null;
    }
    return null;
  }
  private void handleCustomizePressed() {
    List input = SearchPlugin.getDefault().getSearchPageDescriptors();
    input = filterByActivities(input);

    final ArrayList createdImages = new ArrayList(input.size());
    ILabelProvider labelProvider =
        new LabelProvider() {
          public String getText(Object element) {
            if (element instanceof SearchPageDescriptor)
              return LegacyActionTools.removeMnemonics(((SearchPageDescriptor) element).getLabel());
            return null;
          }

          public Image getImage(Object element) {
            if (element instanceof SearchPageDescriptor) {
              ImageDescriptor imageDesc = ((SearchPageDescriptor) element).getImage();
              if (imageDesc == null) return null;
              Image image = imageDesc.createImage();
              if (image != null) createdImages.add(image);
              return image;
            }
            return null;
          }
        };

    String message = SearchMessages.SearchPageSelectionDialog_message;

    ListSelectionDialog dialog =
        new ListSelectionDialog(
            getShell(), input, new ArrayContentProvider(), labelProvider, message) {
          Button fLastUsedPageButton;

          public void create() {
            super.create();
            final CheckboxTableViewer viewer = getViewer();
            final Button okButton = this.getOkButton();
            viewer.addCheckStateListener(
                new ICheckStateListener() {
                  public void checkStateChanged(CheckStateChangedEvent event) {
                    okButton.setEnabled(viewer.getCheckedElements().length > 0);
                  }
                });
            SelectionListener listener =
                new SelectionAdapter() {
                  public void widgetSelected(SelectionEvent e) {
                    okButton.setEnabled(viewer.getCheckedElements().length > 0);
                  }
                };
            this.getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(listener);
            this.getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(listener);
          }

          protected Control createDialogArea(Composite parent) {
            Composite control = (Composite) super.createDialogArea(parent);
            fLastUsedPageButton = new Button(control, SWT.CHECK);
            fLastUsedPageButton.setText(
                SearchMessages.SearchPageSelectionDialog_rememberLastUsedPage_message);
            fLastUsedPageButton.setSelection(
                fDialogSettings.getBoolean(STORE_IS_OPEN_PREVIOUS_PAGE));
            return control;
          }

          protected void okPressed() {
            fDialogSettings.put(STORE_IS_OPEN_PREVIOUS_PAGE, fLastUsedPageButton.getSelection());
            super.okPressed();
          }
        };
    dialog.setTitle(SearchMessages.SearchPageSelectionDialog_title);
    dialog.setInitialSelections(
        SearchPlugin.getDefault().getEnabledSearchPageDescriptors(fInitialPageId).toArray());
    if (dialog.open() == Window.OK) {
      SearchPageDescriptor.setEnabled(dialog.getResult());
      Display display = getShell().getDisplay();
      close();
      if (display != null && !display.isDisposed()) {
        display.asyncExec(
            new Runnable() {
              public void run() {
                new OpenSearchDialogAction().run();
              }
            });
      }
    }
    destroyImages(createdImages);
  }