Java Code Examples for org.eclipse.jface.viewers.CheckboxTreeViewer#setInput()

The following examples show how to use org.eclipse.jface.viewers.CheckboxTreeViewer#setInput() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleFolderSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the tree viewer.
 *
 * @param parent the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
	fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);

	fViewer.setContentProvider(fContentProvider);
	fViewer.setLabelProvider(fLabelProvider);
	fViewer.addCheckStateListener(new ICheckStateListener() {
		public void checkStateChanged(CheckStateChangedEvent event) {
			updateOKStatus();
		}
	});

	fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
	if (fFilters != null) {
		for (int i = 0; i != fFilters.size(); i++)
			fViewer.addFilter(fFilters.get(i));
	}

	fViewer.setInput(fInput);

	return fViewer;
}
 
Example 2
Source File: PackageFilterEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates the tree viewer.
 *
 * @param parent
 *          the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {

  mViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
  mViewer.setContentProvider(mContentProvider);
  mViewer.setLabelProvider(mLabelProvider);

  mViewer.addCheckStateListener(new ICheckStateListener() {
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {

      IContainer element = (IContainer) event.getElement();

      if (isRecursivelyExcludeSubTree() && !isGrayed(element)) {
        setSubElementsGrayedChecked(element, event.getChecked());
      } else if (isRecursivelyExcludeSubTree() && isGrayed(element)) {
        mViewer.setGrayChecked(element, true);
      }
    }
  });

  mViewer.setInput(mInput);
  mViewer.setCheckedElements(getInitialElementSelections().toArray());
  adaptRecurseBehaviour();
  if (mExpandedElements != null) {
    mViewer.setExpandedElements(mExpandedElements);
  }

  return mViewer;
}
 
Example 3
Source File: RemoteFetchLogWizardRemotePage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private boolean updateViewer() {
    Object elementViewerInput = createElementViewerInput();
    if (elementViewerInput == null) {
        return false;
    }

    CheckboxTreeViewer elementViewer = getElementViewer();
    elementViewer.setInput(elementViewerInput);
    elementViewer.expandToLevel(3);
    setAllChecked(elementViewer, false, true);
    updatePageCompletion();

    return true;
}
 
Example 4
Source File: ExportTracePackageWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Set the selected trace from the previous page to be displayed in the
 * element viewer
 *
 * @param selectedTraces
 *            the selected trace
 */
public void setSelectedTraces(List<TmfTraceElement> selectedTraces) {
    if (!fSelectedTraces.containsAll(selectedTraces) || !selectedTraces.containsAll(fSelectedTraces)) {
        fSelectedTraces = new ArrayList<>(selectedTraces);
        CheckboxTreeViewer elementViewer = getElementViewer();
        elementViewer.setInput(createElementViewerInput());
        elementViewer.expandToLevel(2);
        setAllChecked(elementViewer, false, true);
        updateApproximateSelectedSize();
    }
}
 
Example 5
Source File: AddContextDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {

    // Main dialog panel
    Composite dialogComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, true);
    dialogComposite.setLayout(layout);
    dialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Contexts list
    Group contextGroup = new Group(dialogComposite, SWT.SHADOW_NONE);
    contextGroup.setText(Messages.TraceControl_AddContextAvailableContextsLabel);
    layout = new GridLayout(1, true);
    contextGroup.setLayout(layout);
    contextGroup.setLayoutData(new GridData(GridData.FILL_BOTH));

    fContextsViewer = new CheckboxTreeViewer(contextGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    fContextsViewer.getTree().setToolTipText(Messages.TraceControl_AddContextAvailableContextsTooltip);

    fContextsViewer.setContentProvider(new ContextsContentProvider());
    fContextsViewer.setLabelProvider(new ContextsLabelProvider());
    fContextsViewer.addCheckStateListener(new ContextCheckListener());
    fContextsViewer.setInput(fContextModel);
    fContextsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));

    getShell().setMinimumSize(new Point(500, 450));

    return dialogComposite;
}
 
Example 6
Source File: FieldToContractInputMappingViewerCheckStateManagerTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private CheckboxTreeViewer aCheckBoxTreeViewer(List<FieldToContractInputMapping> input) {
    CheckboxTreeViewer viewer = new CheckboxTreeViewer(realmWithDisplay.createComposite());
    viewer.setFilters(hidePersistenceIdMapping());
    ObservableListTreeContentProvider provider = new ObservableListTreeContentProvider(
            new FieldToContractInputMappingObservableFactory(),
            new FieldToContractInputMappingTreeStructureAdvisor());
    viewer.setContentProvider(provider);
    viewer.setInput(input);
    return viewer;
}
 
Example 7
Source File: ExportWizardPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createProcessTree(Composite container) {
	Composite composite = new Composite(container, SWT.NONE);
	composite.setLayout(new FillLayout());
	UI.gridData(composite, true, true);
	viewer = new CheckboxTreeViewer(composite, SWT.MULTI | SWT.BORDER);
	viewer.setUseHashlookup(true);
	viewer.setContentProvider(new NavigationContentProvider());
	viewer.setLabelProvider(new NavigationLabelProvider(false));
	viewer.setInput(Navigator.getNavigationRoot());
	viewer.addCheckStateListener(new NavigationTreeCheck(viewer));
	viewer.addCheckStateListener(this);
	viewer.addFilter(new NavigationTreeFilter());
	viewer.setComparator(new NavigationComparator());
}
 
Example 8
Source File: ModelCheckBoxTree.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public void drawOn(Composite comp, FormToolkit tk) {
	tree = new CheckboxTreeViewer(comp,
			SWT.VIRTUAL | SWT.MULTI | SWT.BORDER);
	tree.setUseHashlookup(true);
	tree.setContentProvider(new NavigationContentProvider());
	tree.setLabelProvider(new NavigationLabelProvider(false));
	tree.setComparator(new NavigationComparator());
	tree.addFilter(new ModelTypeFilter(types));
	tree.addCheckStateListener(this);
	ColumnViewerToolTipSupport.enableFor(tree);
	if (tk != null) {
		tk.adapt(tree.getTree());
	}

	// compute a height hint
	GridData data = UI.gridData(tree.getTree(), true, true);
	data.minimumHeight = 120;
	Point p = comp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	data.heightHint = p.y < 120 ? 120 : p.y;

	if (types == null || types.length == 0)
		return;
	if (types.length == 1) {
		tree.setInput(Navigator.findElement(types[0]));
	} else {
		List<INavigationElement<?>> elems = Arrays.stream(types)
				.map(type -> Navigator.findElement(type))
				.filter(elem -> !elem.getChildren().isEmpty())
				.collect(Collectors.toList());
		tree.setInput(elems);
	}
	tree.expandToLevel(2);
}
 
Example 9
Source File: LTTngProfileViewer.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Creates a CheckboxTreeViewer for selection available LTTng profiles.
 * @param parent
 *                A parent composite
 * @param style
 *                The style bits
 * @return LTTng Profiles CheckboxTreeViewer
 */
public static CheckboxTreeViewer createLTTngProfileViewer(Composite parent, int style) {
    CheckboxTreeViewer fFolderViewer = new CheckboxTreeViewer(parent, style);
    fFolderViewer.setContentProvider(new ProfileContentProvider());
    fFolderViewer.setLabelProvider(new ProfileLabelProvider());
    fFolderViewer.setInput(getViewerInput());
    return fFolderViewer;
}