Exemple #1
0
  public void testSetGrayedElements() {
    CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;

    TestElement[] children = fRootElement.getChildren();

    List toGray = new ArrayList((children.length + 1) / 2);

    for (int i = 0; i < children.length; i += 2) {
      toGray.add(children[i]);
    }

    ctv.setGrayedElements(toGray.toArray());

    for (int i = 0; i < children.length; i++) {
      if (i % 2 == 0) {
        assertTrue(
            "an element passed through setGrayedElements should be grayed",
            ctv.getGrayed(children[i]));
      } else {
        assertFalse(
            "an element not passed through setGrayedElements should not be grayed",
            ctv.getGrayed(children[i]));
      }
    }
  }
Exemple #2
0
  @Override
  protected Control createDialogArea(Composite top) {
    top.getShell().setText(Messages.EventTreeDialog_PapiEventSelection);
    final Composite parent = (Composite) super.createDialogArea(top);
    final GridLayout gl = new GridLayout();
    parent.setLayout(gl);

    final GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 500;
    gd.widthHint = 350;

    treeV = new CheckboxTreeViewer(parent, SWT.BORDER);

    ColumnViewerToolTipSupport.enableFor(treeV);

    // et=new EventTree();

    cSelect = new PapiCSelect(toolPath, utilBlob); // "E:\\PAPIProject\\ptest2.xml");//
    et = cSelect.getEventTree();

    treeV.setContentProvider(et);

    // tree=treeV.getTree();

    treeV.getTree().setLayoutData(gd);
    // tree.setLayoutData(gd);
    treeV.setLabelProvider(new ETreeCellLabelProvider());

    treeV.setInput(et);
    treeV.setGrayedElements(new Object[0]);
    treeV.expandToLevel(3);
    treeV.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            final Object element = event.getElement();

            if (treeV.getGrayed(element)) {
              treeV.setChecked(element, true);
              return;
            }

            if (element instanceof ETItem) {
              doCheck((ETItem) element, event.getChecked());
            }
          }
        });

    return parent;
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
   * .Composite)
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    createMessageArea(composite);
    CheckboxTreeViewer treeViewer = createTreeViewer(composite);

    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = convertWidthInCharsToPixels(60);
    data.heightHint = convertHeightInCharsToPixels(18);

    Tree treeWidget = treeViewer.getTree();
    treeWidget.setLayoutData(data);
    treeWidget.setFont(composite.getFont());

    if (hasNewFolderButton) {
      Button button = new Button(composite, SWT.PUSH);
      button.setText(TernUIMessages.Button_newFolder);
      button.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent event) {
              newFolderButtonPressed();
            }
          });
      button.setFont(composite.getFont());

      fNewFolderButton = button;
    }

    treeViewer.addSelectionChangedListener(this);
    if (fExisting != null) {
      Object[] existing = fExisting.toArray();
      treeViewer.setGrayedElements(existing);
      setInitialSelections(existing);
    }
    if (fFocusElement != null) {
      treeViewer.setSelection(new StructuredSelection(fFocusElement), true);
    }
    treeViewer.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            forceExistingChecked(event);
          }
        });

    applyDialogFont(composite);
    return composite;
  }