Java Code Examples for org.eclipse.jface.viewers.TreeViewer#setUseHashlookup()

The following examples show how to use org.eclipse.jface.viewers.TreeViewer#setUseHashlookup() . 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: OutlinePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void configureTree() {
	TreeViewer treeViewer = getTreeViewer();
	contentProvider.setFilterAndSorter(filterAndSorter);
	treeViewer.setUseHashlookup(true);
	// access EMF's image registry now, since it needs a UI-thread.
	ExtendedImageRegistry.getInstance();
	if (treeProvider instanceof IOutlineTreeProvider.Background) {
		showBusyStatus();
		new Job("Initializing Outline") {
			@Override
			protected IStatus run(IProgressMonitor monitor) {
				try {
					initializeTreeContent();
					return Status.OK_STATUS;
				} catch (Throwable e) {
					LOG.error("Error initializing outline", e);
					return Status.OK_STATUS; 
				}
			}
			
		}.schedule();
	} else {
		initializeTreeContent();
	}
}
 
Example 2
Source File: QueryEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private TreeViewer createQueryViewer(Composite parent) {
    TreeViewer queryViewer = new TreeViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    queryViewer.getTree()
            .setLayoutData(GridDataFactory.fillDefaults().grab(false, true).hint(300, SWT.DEFAULT).create());
    queryViewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, QUERY_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(queryViewer.getTree());
    ColumnViewerToolTipSupport.enableFor(queryViewer);
    queryViewer.setUseHashlookup(true);
    queryViewer.addFilter(createSearchFilter());
    queryViewer.addDoubleClickListener(e -> {
        queryViewer.setExpandedState(querySelectedObservable.getValue(),
                !viewer.getExpandedState(querySelectedObservable.getValue()));
    });

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    queryViewer.getTree().setLayout(layout);

    createQueryNameColumn(queryViewer);

    provider = new QueryContentProvider();
    queryViewer.setContentProvider(provider);
    return queryViewer;
}
 
Example 3
Source File: SVNWizardPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected TreeViewer createResourceSelectionTree(Composite composite, int types, int span) {
	TreeViewer tree = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
	tree.setUseHashlookup(true);
	tree.setContentProvider(getResourceProvider(types));
	tree.setLabelProvider(
		new DecoratingLabelProvider(
			new WorkbenchLabelProvider(), 
			SVNUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getLabelDecorator()));
	tree.setSorter(new ResourceSorter(ResourceSorter.NAME));
	
	GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
	data.heightHint = LIST_HEIGHT_HINT;
	data.horizontalSpan = span;
	tree.getControl().setLayoutData(data);
	return tree;
}
 
Example 4
Source File: BusinessObjectList.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createViewer(Composite parent, AbstractBdmFormPage formPage) {
    viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create());
    formPage.getToolkit().adapt(viewer.getTree());
    viewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, BUSINESS_OBJECT_LIST_VIEWER_ID);
    viewer.addFilter(createSearchFilter());
    viewer.addDoubleClickListener(e -> {
        viewer.setExpandedState(selectionObservable.getValue(),
                !viewer.getExpandedState(selectionObservable.getValue()));
    });

    ColumnViewerToolTipSupport.enableFor(viewer);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    viewer.getTree().setLayout(layout);
    viewer.setUseHashlookup(true);
    createBusinessObjectColumn(viewer, formPage);
    viewer.setContentProvider(new BusinessObjectTreeContentProvider());
    viewer.setComparator(new BusinessObjectViewerComparator());
    viewer.setInput(input);
    addDNDSupport(formPage);
    selectionObservable = ViewerProperties.singleSelection(Object.class).observe(viewer);
}
 
Example 5
Source File: AbstractInformationControl.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * Creates tree viewer to manage content
 * 
 * @param parent
 *            parent control
 */
private void createTreeViewer(Composite parent) {
	int style = SWT.H_SCROLL | SWT.V_SCROLL;
	// Create the tree
	Tree widget = new Tree(parent, style);
	// Configure the layout
	GridData data = new GridData(GridData.FILL_BOTH);
	data.heightHint = widget.getItemHeight() * 12;
	widget.setLayoutData(data);

	treeViewer = new TreeViewer(widget);
	namePatternFilter = new QuickOutlineNamePatternFilter();
	treeViewer.addFilter(namePatternFilter);
	treeContentProvider = getContentProvider();
	treeViewer.setContentProvider(treeContentProvider);
	treeLabelProvider = getLabelProvider();
	treeViewer.setLabelProvider(treeLabelProvider);
	treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
	treeViewer.setUseHashlookup(true);
	treeViewer.setInput(getInitialInput());
}
 
Example 6
Source File: TypeScriptSearchResultPage.java    From typescript.java with MIT License 5 votes vote down vote up
protected void configureTreeViewer(TreeViewer viewer) {
	viewer.setUseHashlookup(true);
	TypeScriptSearchLabelProvider innerLabelProvider= new TypeScriptSearchLabelProvider(this, TypeScriptSearchLabelProvider.SHOW_LABEL);
	viewer.setLabelProvider(new DecoratingTypeScriptSearchLabelProvider(innerLabelProvider));
	viewer.setContentProvider(new TypeScriptSearchTreeContentProvider(this, viewer));
	viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider));
	fContentProvider= (ITypeScriptSearchContentProvider) viewer.getContentProvider();
	addDragAdapters(viewer);
}
 
Example 7
Source File: Navigator.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void initListeners(TreeViewer viewer) {
	super.initListeners(viewer);
	viewer.setUseHashlookup(true);
	ColumnViewerToolTipSupport.enableFor(viewer);
	viewer.addDoubleClickListener(evt -> {
		var elem = Viewers.getFirst(evt.getSelection());
		if (elem instanceof ModelElement) {
			var model = ((ModelElement) elem).getContent();
			App.openEditor(model);
		} else if (elem instanceof DatabaseElement) {
			var config = ((DatabaseElement) elem).getContent();
			if (config != null && !Database.isActive(config)) {
				new DbActivateAction(config).run();
			}
		} else if (elem instanceof ScriptElement) {
			var file = ((ScriptElement) elem).getContent();
			if (file.isDirectory())
				return;
			if (file.getName().endsWith(".py")) {
				PythonEditor.open(file);
			}
		} else if (elem instanceof LibraryElement) {
			var library = ((LibraryElement) elem).getContent();
			LibraryInfoPage.show(library);
		}
	});
}
 
Example 8
Source File: JsonContentOutlinePage.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    super.createControl(parent);

    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(new OutlineContentProvider());
    viewer.setLabelProvider(new OutlineStyledLabelProvider());
    viewer.addSelectionChangedListener(this);
    viewer.setAutoExpandLevel(2);
    viewer.setUseHashlookup(true);

    if (currentInput != null) {
        setInput(currentInput);
    }
}
 
Example 9
Source File: AbstractCallHierarchyViewPart.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected TreeViewer createCallHierarchyViewer(Composite parent) {
	TreeViewer treeViewer = new TreeViewer(parent);
	treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
	treeViewer.setUseHashlookup(true);
	treeViewer.setAutoExpandLevel(2);
	treeViewer.setLabelProvider(createHierarchyLabelProvider());
	treeViewer.setContentProvider(createHierarchyContentProvider());
	return treeViewer;
}
 
Example 10
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureTreeViewer(TreeViewer viewer) {
	PostfixLabelProvider postfixLabelProvider= new PostfixLabelProvider(this);
	viewer.setUseHashlookup(true);
	viewer.setComparator(new DecoratorIgnoringViewerSorter(postfixLabelProvider));
	viewer.setLabelProvider(new DecoratingJavaLabelProvider(postfixLabelProvider, false));
	fContentProvider= new LevelTreeContentProvider(this, fCurrentGrouping);
	viewer.setContentProvider(fContentProvider);
	addDragAdapters(viewer);
}
 
Example 11
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureTreeViewer(TreeViewer viewer) {
    viewer.setUseHashlookup(true);
    SearchIndexLabelProvider innerLabelProvider = createSearchIndexLabelProvider();
    viewer.setLabelProvider(new DecoratingFileSearchLabelProvider(innerLabelProvider));
    viewer.setContentProvider(createTreeContentProvider(viewer));
    viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider));
    fContentProvider = (ISearchIndexContentProvider) viewer.getContentProvider();
    addDragAdapters(viewer);

    updateGroupWith(viewer);
}
 
Example 12
Source File: FileSearchPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void configureTreeViewer(TreeViewer viewer) {
    viewer.setUseHashlookup(true);
    FileLabelProvider innerLabelProvider = new FileLabelProvider(this, FileLabelProvider.SHOW_LABEL);
    viewer.setLabelProvider(innerLabelProvider);
    viewer.setContentProvider(new FileTreeContentProvider(this, viewer));
    viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider));
    fContentProvider = (IFileSearchContentProvider) viewer.getContentProvider();
    addDragAdapters(viewer);
}
 
Example 13
Source File: XMPPSessionDisplayComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(TreeViewer viewer) {
  viewer.setContentProvider(new SessionContentProvider(new RosterContentProvider()));

  viewer.setLabelProvider(new TreeLabelProvider());
  viewer.setComparator(new SessionComparator(new RosterComparator()));
  viewer.setUseHashlookup(true);
}
 
Example 14
Source File: AbstractContentOutlinePage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected TreeViewer createTreeViewer(Composite parent) {
	treeViewer = new TreeViewer(parent, SWT.MULTI);
	
	treeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
	// TODO: allow certain StructureElements to not be initially expanded
	treeViewer.setUseHashlookup(true);
	
	setupTreeViewerListeners();
	createTreeViewerMenu();
	
	return treeViewer;
}
 
Example 15
Source File: SmartImportBdmPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Composite createMergeViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    composite.setLayout(GridLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing().x, 1).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    viewer = new TreeViewer(composite,
            SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.setUseHashlookup(true);
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    viewer.setContentProvider(new SmartImportBdmTreeContentProvider());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(6, true));
    layout.addColumnData(new ColumnWeightData(2, true));
    viewer.getTree().setLayout(layout);

    createModelColumn();
    createActionColumn();

    IViewerObservableValue singleSelectionObservable = ViewerProperties.singleSelection().observe(viewer);
    viewer.addDoubleClickListener(e -> viewer.setExpandedState(singleSelectionObservable.getValue(),
            !viewer.getExpandedState(singleSelectionObservable.getValue())));
    return composite;
}
 
Example 16
Source File: ErrorTraceTreeViewer.java    From tlaplus with MIT License 4 votes vote down vote up
ErrorTraceTreeViewer(final Tree parent, final ModelEditor associatedModelEditor) {
	treeViewer = new TreeViewer(parent);
	treeViewer.setUseHashlookup(true);
	treeViewer.setContentProvider(new StateContentProvider());
	ColumnViewerToolTipSupport.enableFor(treeViewer);

	final TraceDisplayResizer resizer = new TraceDisplayResizer(parent);
	final StateLabelProvider labelProvider = new StateLabelProvider();
	for (int i = 0; i < COLUMN_TEXTS.length; i++) {
		final TreeViewerColumn column = new TreeViewerColumn(treeViewer, i);
		column.getColumn().setText(COLUMN_TEXTS[i]);
		column.getColumn().setWidth(COLUMN_WIDTH[i]);
		column.setLabelProvider(labelProvider);
		resizer.setColumnForIndex(column, i);
		column.getColumn().addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				// reverse the current trace
				final TLCError error = (TLCError) treeViewer.getInput();
				error.reverseTrace();
				// Reset the viewer's selection to the empty selection. With empty
				// selection, the subsequent refresh call does *not* invalidate the
				// StateContentProvider's lazy policy.
				// We know that the user clicked on the tree's column header
				// and the real selection is of little importance.
				treeViewer.setSelection(new ISelection() {
					public boolean isEmpty() {
						return true;
					}
				});
				treeViewer.refresh(false);
				
				// remember the order for next trace shown
				final IDialogSettings dialogSettings = Activator.getDefault().getDialogSettings();
				dialogSettings.put(TLCModelLaunchDataProvider.STATESORTORDER,
						!dialogSettings.getBoolean(TLCModelLaunchDataProvider.STATESORTORDER));
			}
		});
	}
	
       parent.addControlListener(resizer);
	
	errorTraceFontChangeListener = (event) -> {
		if ((event == null) || event.getProperty().equals(ITLCPreferenceConstants.I_TLC_ERROR_TRACE_FONT)) {
			final Font f = JFaceResources.getFont(ITLCPreferenceConstants.I_TLC_ERROR_TRACE_FONT);
			
			JFaceResources.getFontRegistry().put(TLCErrorView.JFACE_ERROR_TRACE_ID, f.getFontData());

			if (treeViewer != null) {
				treeViewer.refresh(true);
			}
		}
	};
	errorTraceFontChangeListener.propertyChange(null);
       JFaceResources.getFontRegistry().addListener(errorTraceFontChangeListener);
       
       createContextMenu();
       
       setModelEditor(associatedModelEditor);
}
 
Example 17
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private Composite createTree(Composite parent) {
    final Composite fileTreeGroup = new Composite(parent, SWT.NONE);
    fileTreeGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 5).create());
    fileTreeGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    viewer = new TreeViewer(fileTreeGroup,
            SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(600, SWT.DEFAULT).create());
    provider = new ArchiveTreeContentProvider(viewer);
    viewer.setContentProvider(provider);
    viewer.setUseHashlookup(true); // important for lazy behavior!
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(6, true));
    layout.addColumnData(new ColumnWeightData(2, true));
    viewer.getTree().setLayout(layout);
    ColumnViewerToolTipSupport.enableFor(viewer);

    final TreeViewerColumn archiveColumn = new TreeViewerColumn(viewer, SWT.NONE);
    archiveColumn.getColumn().setText(Messages.archiveColumn);
    archiveColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(new ImportModelLabelProvider(
            new ImportModelStyler())));

    final TreeViewerColumn actionColumn = new TreeViewerColumn(viewer, SWT.NONE);
    actionColumn.getColumn().setText(Messages.actionColumn);
    actionColumn.setLabelProvider(new LabelProviderBuilder<>()
            .withTextProvider(this::getActionText)
            .createColumnLabelProvider());
    actionColumn.setEditingSupport(new ImportActionEditingSupport(viewer));

    final Composite buttonsComposite = new Composite(fileTreeGroup, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(5, 2).create());
    buttonsComposite.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).create());

    importActionSelector = new ImportActionSelector(viewer);
    overwriteButton = new ButtonWidget.Builder()
            .withLabel(Messages.overwriteAll)
            .alignLeft()
            .fill()
            .grabHorizontalSpace()
            .minimumWidth(BUTTON_WIDTH)
            .onClick(importActionSelector::selectOverwriteAll)
            .createIn(buttonsComposite);
    overwriteButton.disable();

    keepAllButton = new ButtonWidget.Builder()
            .withLabel(Messages.keepAll)
            .alignLeft()
            .fill()
            .minimumWidth(BUTTON_WIDTH)
            .grabHorizontalSpace()
            .onClick(importActionSelector::selectKeepAll)
            .createIn(buttonsComposite);
    keepAllButton.disable();

    return fileTreeGroup;
}
 
Example 18
Source File: TreeConflictsView.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void createPartControl(Composite parent) {
	GridLayout layout = new GridLayout();
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.numColumns = 1;
	parent.setLayout(layout);		

	treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
	treeViewer.setLabelProvider(new ConflictsLabelProvider());
	treeViewer.setContentProvider(new ConflictsContentProvider());
	treeViewer.setUseHashlookup(true);
	GridData layoutData = new GridData();
	layoutData.grabExcessHorizontalSpace = true;
	layoutData.grabExcessVerticalSpace = true;
	layoutData.horizontalAlignment = GridData.FILL;
	layoutData.verticalAlignment = GridData.FILL;
	treeViewer.getControl().setLayoutData(layoutData);
	TableLayout tableLayout = new TableLayout();
	treeViewer.getTree().setLayout(tableLayout);

	DisposeListener disposeListener = new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			TreeColumn col = (TreeColumn)e.getSource();
			if (col.getWidth() > 0) settings.put("TreeConflictsView.col." + col.getText(), col.getWidth()); //$NON-NLS-1$
		}			
	};
	for (int i = 0; i < columnHeaders.length; i++) {
		TreeColumn tc = new TreeColumn(treeViewer.getTree(), SWT.NONE,i);
		tc.setResizable(columnLayouts[i].resizable);
		tc.setText(columnHeaders[i]);
		setColumnWidth(tableLayout, disposeListener, tc, i);
	}
	
	treeViewer.getTree().setHeaderVisible(true);
	treeViewer.getTree().setLinesVisible(false);
	
	treeViewer.setInput(this);

	treeViewer.addOpenListener(new IOpenListener() {
		public void open(OpenEvent evt) {
			openAction.run();
		}	
	});
	
	createMenus();
	createToolbar();
	
	String path = settings.get("TreeConflictsView.resource"); //$NON-NLS-1$
	if (path != null) {
		boolean container = settings.getBoolean("TreeConflictsView.container"); //$NON-NLS-1$
		if (container) resource = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(path));
		else resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(path));
	}
	if (resource == null)
		setContentDescription(Policy.bind("TreeConflictsView.noResource")); //$NON-NLS-1$
	else
		setContentDescription(resource.getFullPath().toString());
}
 
Example 19
Source File: AbstractWorkingSetWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void createTree(Composite parent) {

		Label label= new Label(parent, SWT.NONE);
		label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
		label.setText(WorkingSetMessages.JavaWorkingSetPage_workspace_content);

		fTree= new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
		fTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		fTree.addFilter(new AddedElementsFilter());
		fTree.setUseHashlookup(true);

		configureTree(fTree);

		fTreeContentProvider= (ITreeContentProvider) fTree.getContentProvider();
	}
 
Example 20
Source File: AbapGitStagingView.java    From ADT_Frontend with MIT License 4 votes vote down vote up
private TreeViewer createTree(Composite composite) {
	Tree tree = this.toolkit.createTree(composite, SWT.FULL_SELECTION | SWT.MULTI);
	TreeViewer treeViewer = new TreeViewer(tree);
	treeViewer.setUseHashlookup(true);
	return treeViewer;
}