Java Code Examples for org.eclipse.jface.viewers.CheckboxTreeViewer#addCheckStateListener()
The following examples show how to use
org.eclipse.jface.viewers.CheckboxTreeViewer#addCheckStateListener() .
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: CheckNodeTreeView.java From depan with Apache License 2.0 | 6 votes |
@Override protected CheckboxTreeViewer createTreeViewer(Composite parent) { int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL; CheckboxTreeViewer result = new CheckboxTreeViewer(parent, style); result.setLabelProvider(new WorkbenchLabelProvider()); result.setContentProvider(new BaseWorkbenchContentProvider()); result.setComparator(new NodeWrapperTreeSorter()); result.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { if (recursiveTreeSelect) { tree.setSubtreeChecked(event.getElement(), event.getChecked()); } } }); tree = result; return result; }
Example 2
Source File: CheckboxTreeAndListGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Creates this group's tree viewer. * @param parent parent composite * @param width the width * @param height the height */ protected void createTreeViewer(Composite parent, int width, int height) { Tree tree= new Tree(parent, SWT.CHECK | SWT.BORDER); GridData data= new GridData(GridData.FILL_BOTH); data.widthHint= width; data.heightHint= height; tree.setLayoutData(data); fTreeViewer= new CheckboxTreeViewer(tree); fTreeViewer.setUseHashlookup(true); fTreeViewer.setContentProvider(fTreeContentProvider); fTreeViewer.setLabelProvider(fTreeLabelProvider); fTreeViewer.addTreeListener(this); fTreeViewer.addCheckStateListener(this); fTreeViewer.addSelectionChangedListener(this); }
Example 3
Source File: MultipleFolderSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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 4
Source File: PackageFilterEditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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 5
Source File: FilteredCheckboxTree.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected TreeViewer doCreateTreeViewer(Composite parentComposite, int style) { fCheckboxTreeViewer = new CheckboxTreeViewer(parentComposite, style); fCheckboxTreeViewer.setUseHashlookup(true); fCheckboxTreeViewer.addCheckStateListener(event -> { if (event.getChecked()) { fCheckedObjects.add(event.getElement()); } else { fCheckedObjects.remove(event.getElement()); } }); return fCheckboxTreeViewer; }
Example 6
Source File: TriStateFilteredCheckboxTree.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected TreeViewer doCreateTreeViewer(Composite parentComposite, int style) { TreeViewer tree = super.doCreateTreeViewer(parentComposite, style); if (tree instanceof CheckboxTreeViewer) { CheckboxTreeViewer checkboxTree = (CheckboxTreeViewer) tree; checkboxTree.addCheckStateListener(event -> setSubtreeChecked(event.getElement(), event.getChecked())); } return tree; }
Example 7
Source File: AddContextDialog.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@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 8
Source File: SGenWizardPage2.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private void createObjectTree(Composite container) { lblNewLabel = new Label(container, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); lblNewLabel.setText("Choose: " + getSelectedGenerator().getContentType()); resourceTree = new CheckboxTreeViewer(container, SWT.BORDER); resourceTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); resourceTree.setContentProvider(new WorkspaceTreeContentProvider()); resourceTree.setLabelProvider(new SGenWorkspaceLabelProvider()); TreePropagatingCheckStateListener checkStateListener = new TreePropagatingCheckStateListener(resourceTree) { @Override public void checkStateChanged(CheckStateChangedEvent event) { super.checkStateChanged(event); } }; resourceTree.addCheckStateListener(checkStateListener); resourceTree.addDoubleClickListener(new TreeExpandingDoubleClickListener(resourceTree, checkStateListener)); resourceTree.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); resourceTree.setFilters(new ViewerFilter[] { new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { // TODO: Filter by common navigator filter instead of supressing // '.' prefixed folder if (element instanceof IFolder) { return !((IFolder) element).getName().startsWith("."); } return true; } } }); }
Example 9
Source File: LevelViewDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
private void createLevelViewer( Composite parent ) { levelViewer = new CheckboxTreeViewer( parent, SWT.SINGLE | SWT.BORDER ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.widthHint = 340; gd.heightHint = 250; levelViewer.getTree( ).setLayoutData( gd ); levelViewer.setContentProvider( new CubeContentProvider( ) ); levelViewer.setLabelProvider( new CubeLabelProvider( ) ); levelViewer.addCheckStateListener( new ICheckStateListener( ) { public void checkStateChanged( CheckStateChangedEvent event ) { LevelHandle item = (LevelHandle) event.getElement( ); if ( event.getChecked( ) ) { if ( !showLevels.contains( item ) ) showLevels.add( item ); } else { if ( showLevels.contains( item ) ) showLevels.remove( item ); } checkOKButtonStatus( ); } } ); }
Example 10
Source File: MOOSETreeCompositeView.java From ice with Eclipse Public License 1.0 | 5 votes |
/** * Overrides the default viewer to add an additional feature: When a parent * node is unchecked, all of its child nodes are unchecked. */ @Override protected TreeViewer createViewer(Composite parent) { TreeViewer treeViewer = null; if (parent != null) { // Initialize the TreeViewer. Note: We create a CheckboxTreeViewer! final CheckboxTreeViewer checkboxTreeViewer = new CheckboxTreeViewer( parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); treeViewer = checkboxTreeViewer; // Set and configure the content and label providers treeViewer.setContentProvider(new TreeCompositeContentProvider( this, parentMap)); treeViewer.setLabelProvider(new TreeCompositeLabelProvider()); // Add a provider to tell the viewer when elements should be // checked. This is NOT default behavior. MOOSETreeCheckStateManager checkManager; checkManager = new MOOSETreeCheckStateManager(); checkboxTreeViewer.setCheckStateProvider(checkManager); checkboxTreeViewer.addCheckStateListener(checkManager); } return treeViewer; }
Example 11
Source File: ExportWizardPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
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 12
Source File: CommitDiffViewer.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected TreeViewer createViewer(Composite parent) { CheckboxTreeViewer viewer = new CheckboxTreeViewer(parent, SWT.BORDER); configureViewer(viewer, true); viewer.addCheckStateListener((e) -> setChecked(viewer, (DiffNode) e.getElement(), e.getChecked(), false)); UI.gridData(viewer.getTree(), true, true); return viewer; }
Example 13
Source File: RepositoryImportWizard.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override public void createControl(Composite parent) { Composite container = UI.formComposite(parent); setControl(container); viewer = new CheckboxTreeViewer(container, SWT.BORDER); viewer.setLabelProvider(new Label()); viewer.setContentProvider(new ContentProvider()); viewer.setUseHashlookup(true); viewer.addCheckStateListener(new SelectionState(this)); UI.gridData(viewer.getTree(), true, true); }
Example 14
Source File: ModelSelectionPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
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 15
Source File: ModelCheckBoxTree.java From olca-app with Mozilla Public License 2.0 | 5 votes |
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 16
Source File: CreateContractInputFromBusinessObjectWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
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); }