コード例 #1
0
  /**
   * Handles the button pressed event on the filter criteria. Move the items between the lists based
   * on the selection and but button pressed.
   */
  private void buttonPressed(int buttonId) {
    String[] items = {};
    switch (buttonId) {
      case ADD_TO_ID:
        items = filterList.getSelection();
        for (int i = 0; i < items.length; i++) {
          filters.add(items[i]);
          filterList.remove(items[i]);
        }
        addTo.setEnabled(false);
        break;
      case REMOVE_FROM_ID:
        items = filters.getSelection();
        for (int i = 0; i < items.length; i++) {
          filterList.add(items[i]);
          filters.remove(items[i]);
        }
        removeFrom.setEnabled(false);
        break;
      case ADD_ALL_TO_ID:
        items = filterList.getItems();
        for (int i = 0; i < items.length; i++) {
          filters.add(items[i]);
          filterList.remove(items[i]);
        }
        break;
      case REMOVE_ALL_FROM_ID:
        items = filters.getItems();
        for (int i = 0; i < items.length; i++) {
          filters.remove(items[i]);
          filterList.add(items[i]);
        }
        break;
    }
    updateFilteringKeysFromControls();
    if (pageType == CHILD_PAGE) {
      refreshList();
    } else if (pageType == ROOT_PAGE) {
      PreferenceManager preferenceManager =
          ((SortFilterDialog) getContainer()).getPreferenceManager();
      Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator();
      while (nodes.hasNext()) {
        PreferenceNode node = (PreferenceNode) nodes.next();
        SortFilterPage page = (SortFilterPage) node.getPage();
        if (page == this) {
          continue;
        }

        if (Arrays.equals(filterStrings, page.getFilterList())) {
          page._filteringKeys = new ArrayList(_filteringKeys.size());
          page._filteringKeys.addAll(_filteringKeys);
          page._filtering = _filtering;
          page.populateFilterLists();
          page.refreshList();
          page.updateApplyButton();
        }
      }
    }
    updateApplyButton();
  }
コード例 #2
0
  /**
   * Create Network group
   *
   * @param parent parent composite
   */
  @SuppressWarnings("unchecked")
  private void createNetworkGroup(Composite parent) {

    // Makes the network preferences dialog manager
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();

    IPreferenceNode networkNode = null;

    for (IPreferenceNode node :
        (List<IPreferenceNode>) manager.getElements(PreferenceManager.PRE_ORDER)) {
      if (node.getId().equals(PROXY_PREFERENCE_PAGE_ID)) {
        networkNode = node;
        break;
      }
    }
    prefMan = new PreferenceManager();
    if (networkNode != null) {
      prefMan.addToRoot(networkNode);
    }

    Link downloadText = new Link(parent, SWT.WRAP);
    downloadText.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {
            // Do nothing
          }

          public void widgetSelected(SelectionEvent e) {
            openNetworkPreferencesPage();
          }
        });

    String linkText =
        Messages.bind(Messages.NetworkLinkText, Messages.NetworkLinkText, Messages.NetworkLinkLink);

    downloadText.setText(linkText);
    downloadText.update();
    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    downloadText.setLayoutData(gridData);
  }