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

The following examples show how to use org.eclipse.ui.dialogs.ContainerCheckedTreeViewer#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: 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: 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 5
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);
}