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

The following examples show how to use org.eclipse.jface.viewers.CheckboxTreeViewer#addFilter() . 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: AddGetterSetterAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
	CheckboxTreeViewer treeViewer= super.createTreeViewer(parent);
	if (!fAllowSettersForFinals) {
		treeViewer.addFilter(fSettersForFinalFieldsFilter);
	}
	return treeViewer;
}
 
Example 3
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 4
Source File: ModelSelectionPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createViewer(Composite composite) {
	viewer = new CheckboxTreeViewer(composite, SWT.VIRTUAL | SWT.MULTI
			| SWT.BORDER);
	viewer.setUseHashlookup(true);
	viewer.getTree().setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new NavigationContentProvider());
	viewer.setLabelProvider(new NavigationLabelProvider(false));
	viewer.setComparator(new NavigationComparator());
	viewer.addFilter(new ModelTypeFilter(types));
	viewer.addCheckStateListener(new ModelSelectionState(this, viewer));
	registerInputHandler(composite);
	ColumnViewerToolTipSupport.enableFor(viewer);
}
 
Example 5
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 6
Source File: CreateContractInputFromBusinessObjectWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createProcessDataMappingTreeViewer(Composite composite, EMFDataBindingContext dbc) {
    final Composite viewerComposite = new Composite(composite, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 15).create());
    createButtonComposite(viewerComposite);
    treeViewer = new CheckboxTreeViewer(viewerComposite,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    treeViewer.getTree()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.addFilter(hidePersistenceIdMapping());
    final FieldToContractInputMappingViewerCheckStateManager manager = new FieldToContractInputMappingViewerCheckStateManager();
    treeViewer.addCheckStateListener(manager);
    treeViewer.setCheckStateProvider(manager);
    final ObservableListTreeContentProvider provider = new ObservableListTreeContentProvider(
            new FieldToContractInputMappingObservableFactory(),
            new FieldToContractInputMappingTreeStructureAdvisor());
    treeViewer.setContentProvider(provider);

    final TreeViewerColumn nameTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    nameTreeViewerColumn.getColumn().setText(Messages.attributeName);
    nameTreeViewerColumn.getColumn().setWidth(250);
    lazyFieldStatusProvider = new UnselectLazyReferencesInMultipleContainer();
    nameTreeViewerColumn.setLabelProvider(new FieldNameColumnLabelProvider(lazyFieldStatusProvider));

    final TreeViewerColumn typeTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    typeTreeViewerColumn.getColumn().setText(Messages.attributetype);
    typeTreeViewerColumn.getColumn().setWidth(150);
    typeTreeViewerColumn.setLabelProvider(new FieldTypeColumnLabelProvider());

    final TreeViewerColumn inputTypeTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    inputTypeTreeViewerColumn.getColumn().setText(Messages.inputType);
    inputTypeTreeViewerColumn.getColumn().setWidth(150);
    inputTypeTreeViewerColumn.setLabelProvider(new InputTypeColumnLabelProvider(contract));
    inputTypeTreeViewerColumn.setEditingSupport(new ContractInputTypeEditingSupport(treeViewer, contract));

    final TreeViewerColumn mandatoryTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    mandatoryTreeViewerColumn.getColumn().setText(Messages.mandatory);
    mandatoryTreeViewerColumn.getColumn().setWidth(80);
    mandatoryTreeViewerColumn.setLabelProvider(new MandatoryColumnLabelProvider());

    IViewerObservableSet checkedElements = ViewersObservables.observeCheckedElements(treeViewer,
            FieldToContractInputMapping.class);

    final IObservableValue<FieldToContractInputMapping> observeInput = ViewersObservables.observeInput(treeViewer);
    dbc.bindValue(observeInput,
            selectedDataObservable,
            null,
            UpdateStrategyFactory.updateValueStrategy().withConverter(selectedDataToFieldMappings()).create());

    generationOptions.getEditModeObservable().addValueChangeListener(event -> {
        if (selectedDataObservable.getValue() instanceof BusinessObjectData) {
            createMapping(selectedDataObservable.getValue());
            treeViewer.setInput(mappings);
        }
    });

    createButtonListeners(checkedElements);

    multiValidator = new EmptySelectionMultivalidator(selectedDataObservable, checkedElements, mappings,
            contract.eContainer(), generationOptions.getEditModeObservable());
    dbc.addValidationStatusProvider(multiValidator);

    new Label(viewerComposite, SWT.NONE); //FILLER

    Link formGenerationDocLink = new Link(viewerComposite, SWT.NONE);
    formGenerationDocLink.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    formGenerationDocLink.setText(Messages.moreInfoFormGenerationLink);
    formGenerationDocLink.addListener(SWT.Selection, event -> openBrowser(FORM_GENERATION_REDIRECT_ID));

    ColumnViewerToolTipSupport.enableFor(treeViewer);
}