Java Code Examples for org.eclipse.ui.dialogs.ContainerCheckedTreeViewer#addCheckStateListener()

The following examples show how to use org.eclipse.ui.dialogs.ContainerCheckedTreeViewer#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: OverrideMethodsPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void createTreeViewer(Composite treeComp) {
    treeViewer = new ContainerCheckedTreeViewer(treeComp);
    treeViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            processSelectionChange();
        }
    });

    treeViewer.setContentProvider(classProvider);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setAutoExpandLevel(2);
    // treeViewer.addFilter(new MethodViewerFilter());
    treeViewer.setUseHashlookup(true);
    treeViewer.setInput("");
    treeViewer.setSelection(new StructuredSelection(treeViewer.getExpandedElements()[0]));
}
 
Example 2
Source File: GeneratePropertiesPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void createTreeViewer(Composite treeComp) {
    treeViewer = new ContainerCheckedTreeViewer(treeComp);
    treeViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            getRequestProcsseor().setCheckedElements(treeViewer.getCheckedElements());
            GeneratePropertiesPage.this.getWizard().getContainer().updateButtons();
        }
    });

    treeViewer.setContentProvider(classProvider);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setAutoExpandLevel(2);
    treeViewer.setInput("");
    treeViewer.setSelection(new StructuredSelection(treeViewer.getExpandedElements()[0]));
}
 
Example 3
Source File: ConstructorFieldPage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void createTreeViewer(Composite treeComp) {
    treeViewer = new ContainerCheckedTreeViewer(treeComp);
    treeViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            getRequestProcessor().setCheckedElements(treeViewer.getCheckedElements());
            ConstructorFieldPage.this.getWizard().getContainer().updateButtons();
        }
    });

    treeViewer.setContentProvider(classProvider);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setAutoExpandLevel(2);
    treeViewer.setInput("");
    treeViewer.setSelection(new StructuredSelection(treeViewer.getExpandedElements()[0]));
}
 
Example 4
Source File: CompositeFactory.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public static ContainerCheckedTreeViewer createCheckedTreeViewer(final AbstractDialog dialog, final Composite parent, final int height, final int span) {
    final GridData gridData = new GridData();
    gridData.heightHint = height;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = span;

    final ContainerCheckedTreeViewer viewer = new ContainerCheckedTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    final Tree tree = viewer.getTree();
    tree.setLayoutData(gridData);

    viewer.setContentProvider(new TreeNodeContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());

    if (dialog != null) {
        viewer.addCheckStateListener(new ICheckStateListener() {

            @Override
            public void checkStateChanged(final CheckStateChangedEvent event) {
                dialog.validate();
            }

        });
    }

    return viewer;
}
 
Example 5
Source File: FilterBugsDialog.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ContainerCheckedTreeViewer createTree(Composite parent, int style) {
    final ContainerCheckedTreeViewer viewer = new ContainerCheckedTreeViewer(parent, style | SWT.SINGLE | SWT.BORDER
            | SWT.V_SCROLL | SWT.H_SCROLL | SWT.RESIZE) {
        /**
         * Overriden to re-set checked state of elements after filter change
         */
        @Override
        public void refresh(boolean updateLabels) {
            super.refresh(updateLabels);
            setCheckedElements(checkedElements);
        }
    };

    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(labelProvider);
    viewer.setInput(allowedTypes);
    Object[] preselected = getPreselected();
    viewer.setCheckedElements(preselected);
    viewer.addPostSelectionChangedListener(new TreeSelectionChangedListener());
    viewer.getTree().addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            updateDescription((IStructuredSelection) viewer.getSelection());
        }
    });
    viewer.addCheckStateListener(new TreeCheckStateListener());
    return viewer;
}
 
Example 6
Source File: CheckedTreeEditor.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Returns this field editor's list control.
 * 
 * @param parent
 *            the parent control
 * @return the list control
 */
public Tree createListControl(Composite parent) {
	Tree table = (Tree) getTreeControl();
	if (table == null) {
		listParent = parent;
		treeViewer = new ContainerCheckedTreeViewer(parent, SWT.BORDER | SWT.MULTI
				| SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
		table = treeViewer.getTree();
		table.setFont(parent.getFont());
		treeViewer.addCheckStateListener(this);
	} else {
		checkParent(table, parent);
	}
	return table;
}
 
Example 7
Source File: TaxonomyCheckboxListView.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.
 */
@Override
public void createPartControl(Composite parent) {
	Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy();
	contentProvider = new TermContentProvider(viewer);
	viewer = new ContainerCheckedTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(contentProvider);
	DecoratingLabelProvider p = new DecoratingLabelProvider(new DefaultEObjectLabelProvider(), new TaxonomyLabelDecorator());
	viewer.setLabelProvider(p);
	viewer.addCheckStateListener(this);
	viewer.setSorter(null);

	cellEditor = new MyTextCellEditor(viewer.getTree());

	TreeViewerEditor.create(
			viewer,
			new ColumnViewerEditorActivationStrategy(viewer){
				protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
					return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION ||
							(event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.F2);
				}
			},
			TreeViewerEditor.DEFAULT
	);
	enableEditing();

	if(m.isPresent()){
		viewer.setInput(m.get());
	}
	viewer.expandAll();

	//Create right-click menu
       MenuManager menuManager = new MenuManager();
       Menu menu = menuManager.createContextMenu(viewer.getTree());
       viewer.getTree().setMenu(menu);
       getSite().registerContextMenu(menuManager, viewer);
	getSite().setSelectionProvider(viewer);
	// Create the help context id for the viewer's control
	PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "de.tudresden.slr.model.taxonomy.ui.viewer");
	getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
}