org.eclipse.jface.viewers.TreeViewer Java Examples
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer.
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: ActorMappingConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void createMappingTree(final Composite listComposite) { mappingTree = new TreeViewer(listComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.V_SCROLL); mappingTree.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mappingTree.setContentProvider(new AdapterFactoryContentProvider(adapterFactory) { @Override public Object[] getElements(final Object object) { if (object instanceof Collection) { return ((Collection) object).toArray(); } return super.getElements(object); } }); mappingTree.setLabelProvider(new ActorMappingStyledTreeLabelProvider(adapterFactory, deployedOrganization)); mappingTree.addSelectionChangedListener(this); mappingTree.addDoubleClickListener(this); mappingTree.addFilter(new ViewerFilter() { @Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { return (element instanceof String || element instanceof MembershipType) || ((ITreeContentProvider) mappingTree.getContentProvider()).hasChildren(element); } }); }
Example #2
Source File: ItemListContentProvider.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public void performRemoved ( final ListEntry[] entries ) { if ( this.viewer.getControl ().isDisposed () ) { return; } if ( this.viewer instanceof TreeViewer ) { ( (TreeViewer)this.viewer ).remove ( entries ); } else if ( this.viewer != null ) { this.viewer.refresh (); } }
Example #3
Source File: BusinessObjectList.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 #4
Source File: LeveAttributelNodeProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates the context menu for the given object. Gets the action from the * actionRegistry and adds the action to the menu. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { super.createContextMenu( sourceViewer, object, menu ); menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$ new ShowPropertyAction( object ) ); menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$ IAction action = new RefreshAction( sourceViewer ); if (action.isEnabled( )) { menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$ } }
Example #5
Source File: ItemListContentProvider.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void performAdded ( final ListEntry[] entries ) { if ( this.viewer.getControl ().isDisposed () ) { return; } if ( this.viewer instanceof TreeViewer ) { ( (TreeViewer)this.viewer ).add ( this.data, entries ); } else if ( this.viewer != null ) { this.viewer.refresh (); } }
Example #6
Source File: DataSetBasePage.java From birt with Eclipse Public License 1.0 | 6 votes |
public boolean isElementVisible( Viewer viewer, Object element ) { if ( isLeafMatch( viewer, element ) ) { return true; } if ( element instanceof DataSourceType ) { ITreeContentProvider contentProvider = (ITreeContentProvider) ( (TreeViewer) viewer ).getContentProvider( ); DataSourceType node = (DataSourceType) element; Object[] children = contentProvider.getChildren( node ); // Will return true if any subnode of the element matches the search if ( filter( viewer, element, children ).length > 0 ) { return true; } } return false; }
Example #7
Source File: Trees.java From olca-app with Mozilla Public License 2.0 | 6 votes |
public static void addDropSupport(TreeViewer tree, Consumer<List<Descriptor>> handler) { Transfer transfer = ModelTransfer.getInstance(); DropTarget dropTarget = new DropTarget(tree.getTree(), DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT); dropTarget.setTransfer(new Transfer[] { transfer }); dropTarget.addDropListener(new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { if (!transfer.isSupportedType(event.currentDataType)) return; var list = ModelTransfer.getDescriptors(event.data); handler.accept(list); } }); }
Example #8
Source File: ItemListContentProvider.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public void performUpdated ( final ListEntry[] entries ) { if ( this.viewer.getControl ().isDisposed () ) { return; } if ( this.viewer instanceof TreeViewer ) { for ( final ListEntry entry : entries ) { ( (TreeViewer)this.viewer ).refresh ( entry ); } ( (TreeViewer)this.viewer ).update ( entries, null ); } else if ( this.viewer != null ) { this.viewer.refresh (); } }
Example #9
Source File: AbstractInformationControl.java From typescript.java with MIT License | 6 votes |
/** * 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 #10
Source File: FileStagingModeUtil.java From ADT_Frontend with MIT License | 6 votes |
public static void unstageObjects(TreeViewer stagedTreeViewer, IStructuredSelection selection, IAbapGitStaging model, List<Object> expandedNodes) { IAbapGitObject abapObject; IAbapGitFile file; movedObjects.clear(); for (Object object : selection.toList()) { abapObject = null; file = null; if (object instanceof IAbapGitObject) { abapObject = (IAbapGitObject) object; if (stagedTreeViewer.getExpandedState(abapObject)) { expandedNodes.add(abapObject); } unstageObject(model, abapObject); } else if (object instanceof IAbapGitFile) { abapObject = (IAbapGitObject) ((IAbapGitFile) object).eContainer(); file = (IAbapGitFile) object; if (movedObjects.contains(abapObject)) { continue; } expandedNodes.add(abapObject); unstageFile(model, abapObject, file); } } }
Example #11
Source File: SVNWizardPage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
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 #12
Source File: GroupsWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void addButtonSelected() { final org.bonitasoft.studio.actors.model.organization.Group parentGoup = (org.bonitasoft.studio.actors.model.organization.Group) ((IStructuredSelection) getViewer() .getSelection()).getFirstElement(); final org.bonitasoft.studio.actors.model.organization.Group group = OrganizationFactory.eINSTANCE.createGroup(); group.setName(generateGroupname()); group.setDisplayName(group.getName()); if (parentGoup != null) { if (parentGoup.getParentPath() == null) { group.setParentPath(GroupContentProvider.GROUP_SEPARATOR + parentGoup.getName()); } else { group.setParentPath(parentGoup.getParentPath() + GroupContentProvider.GROUP_SEPARATOR + parentGoup.getName()); } } groupList.add(group); getViewer().setInput(groupList); ((TreeViewer) getViewer()).expandAll(); getViewer().setSelection(new StructuredSelection(group)); }
Example #13
Source File: GroupsWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void configureViewer(final StructuredViewer viewer) { viewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final String displayName = ((org.bonitasoft.studio.actors.model.organization.Group) element).getDisplayName(); if (displayName == null || displayName.isEmpty()) { return ((org.bonitasoft.studio.actors.model.organization.Group) element).getName(); } return displayName; } }); if (groupList != null && getViewer() != null) { getViewer().setInput(groupList); ((TreeViewer) getViewer()).expandAll(); } }
Example #14
Source File: IQuickOutlineContribution.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void register(QuickOutlinePopup quickOutline, IMenuManager dialogMenu) { for (IQuickOutlineContribution contribution : contributions) contribution.register(quickOutline, dialogMenu); TreeViewer treeViewer = quickOutline.getTreeViewer(); if (!treeViewer.getTree().isDisposed()) treeViewer.refresh(); }
Example #15
Source File: PyOpenPythonFileAction.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public synchronized void run() { // clear them fillSelections(); if (filesSelected.size() > 0) { openFiles(filesSelected); } else if (nodesSelected.size() > 0) { PythonNode node = nodesSelected.iterator().next(); ParsedItem actualObject = node.getActualObject(); ASTEntryWithChildren astThis = actualObject.getAstThis(); if (astThis != null) { new PyOpenAction().run(new ItemPointer(node.getPythonFile().getActualObject(), NodeUtils .getNameTokFromNode(astThis.node))); } } else if (pythonPathZipFilesSelected.size() > 0) { openFiles(pythonPathZipFilesSelected.toArray(new PythonpathZipChildTreeNode[pythonPathZipFilesSelected .size()])); } else if (pythonPathFilesSelected.size() > 0) { openFiles(pythonPathFilesSelected.toArray(new PythonpathTreeNode[pythonPathFilesSelected.size()])); } else if (containersSelected.size() > 0) { if (this.provider instanceof TreeViewer) { TreeViewer viewer = (TreeViewer) this.provider; for (Object container : containersSelected) { if (viewer.isExpandable(container)) { viewer.setExpandedState(container, !viewer.getExpandedState(container)); } } } else { Log.log("Expecting the provider to be a TreeViewer -- it is:" + this.provider.getClass()); } } }
Example #16
Source File: SelectExamplePage.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void createTreeViewer(Composite container) { viewer = new TreeViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); viewer.setContentProvider(new ExampleContentProvider()); viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExampleLabelProvider())); viewer.addSelectionChangedListener(this); }
Example #17
Source File: OutlinePage.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.8 */ protected void showBusyStatus() { TreeViewer treeViewer = getTreeViewer(); treeViewer.setLabelProvider(busyLabelProvider); treeViewer.setContentProvider(new TreeNodeContentProvider()); treeViewer.setInput(new TreeNode[] { new TreeNode("Loading...") }); }
Example #18
Source File: ReorgMoveWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void doNewButtonPressed() { Object newElement= fCreateTargetQuery.getCreatedTarget(fDestination); if (newElement != null) { TreeViewer viewer= getTreeViewer(); ITreeContentProvider contentProvider= (ITreeContentProvider) viewer.getContentProvider(); viewer.refresh(contentProvider.getParent(newElement)); viewer.setSelection(new StructuredSelection(newElement), true); viewer.getTree().setFocus(); } }
Example #19
Source File: JavaOutlineInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private LexicalSortingAction(TreeViewer outlineViewer) { super(TextMessages.JavaOutlineInformationControl_LexicalSortingAction_label, IAction.AS_CHECK_BOX); setToolTipText(TextMessages.JavaOutlineInformationControl_LexicalSortingAction_tooltip); setDescription(TextMessages.JavaOutlineInformationControl_LexicalSortingAction_description); JavaPluginImages.setLocalImageDescriptors(this, "alphab_sort_co.gif"); //$NON-NLS-1$ fOutlineViewer= outlineViewer; boolean checked=getDialogSettings().getBoolean(STORE_LEXICAL_SORTING_CHECKED); setChecked(checked); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LEXICAL_SORTING_BROWSING_ACTION); }
Example #20
Source File: LogContent.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Reveal all children in the model that require attention. */ private void revealChildrenThatNeedAttention(TreeViewer viewer, LogEntry<T> entry) { Data logData = entry.getLogData(); if (logData != null && logData.getNeedsAttention()) { viewer.reveal(entry); } List<LogEntry<T>> disclosedChildren = entry.getDisclosedChildren(); for (LogEntry<T> logEntry : disclosedChildren) { revealChildrenThatNeedAttention(viewer, logEntry); } }
Example #21
Source File: AbstractInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean hasUnfilteredChild(TreeViewer viewer, Object element) { if (element instanceof IParent) { Object[] children= ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element); for (int i= 0; i < children.length; i++) if (select(viewer, element, children[i])) return true; } return false; }
Example #22
Source File: GraphEditorNodeViewProvider.java From depan with Apache License 2.0 | 5 votes |
@Override public void updateExpandState(TreeViewer viewer) { TreePath[] expandState = graphData.getExpandState(); if (expandState.length > 0) { viewer.setExpandedTreePaths(expandState); return; } if (graphData.countTreeNodes() < NodeViewerProvider.AUTO_EXPAND_LIMIT) { viewer.expandAll(); } else { viewer.expandToLevel(1); } graphData.saveExpandState(viewer.getExpandedTreePaths()); }
Example #23
Source File: TermDbManagerDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Create a new <code>TreeViewer</code>. * @param parent * the parent <code>Composite</code>. * @return the <code>TreeViewer</code>. */ protected TreeViewer createTreeViewer(Composite parent) { final TreeViewer viewer = new TreeViewer(parent, SWT.NONE); addListeners(viewer); viewer.setLabelProvider(new TreeLableProvider()); viewer.setContentProvider(new TreeContentProvider()); return viewer; }
Example #24
Source File: InvasiveThemeHijacker.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void hijackCallHierarchy(final IViewPart view, final boolean revertToDefaults) { try { Field f = view.getClass().getDeclaredField("fPagebook"); //$NON-NLS-1$ f.setAccessible(true); PageBook pageBook = (PageBook) f.get(view); f = pageBook.getClass().getDeclaredField("currentPage"); //$NON-NLS-1$ f.setAccessible(true); Control control = (Control) f.get(pageBook); if (control instanceof Label) { hookTheme(control, revertToDefaults); return; } Method m = view.getClass().getMethod("getViewer"); //$NON-NLS-1$ TreeViewer treeViewer = (TreeViewer) m.invoke(view); hookTheme(treeViewer, revertToDefaults); m = view.getClass().getDeclaredMethod("getLocationViewer"); //$NON-NLS-1$ if (m != null) { m.setAccessible(true); Viewer viewer = (Viewer) m.invoke(view); hookTheme(viewer, revertToDefaults); } } catch (Exception e) { // ignore } }
Example #25
Source File: FileSearchPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@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 #26
Source File: CreateESBAction.java From tesb-studio-se with Apache License 2.0 | 5 votes |
@Override public void init(TreeViewer viewer, IStructuredSelection selection) { boolean canWork = !selection.isEmpty() && selection.size() == 1; IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); if (factory.isUserReadOnlyOnCurrentProject()) { canWork = false; } if (canWork) { Object o = selection.getFirstElement(); RepositoryNode node = (RepositoryNode) o; switch (node.getType()) { case SIMPLE_FOLDER: case SYSTEM_FOLDER: ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE); if (nodeType != ESBRepositoryNodeType.SERVICES) { canWork = false; } if (node.getObject() != null && node.getObject().isDeleted()) { canWork = false; } break; default: canWork = false; } if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) { canWork = false; } } setEnabled(canWork); }
Example #27
Source File: LanguageCodesPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private int compareColumn(final Viewer viewer, final Object a, final Object b, final int columnNumber) { IBaseLabelProvider baseLabel = ((TreeViewer) viewer).getLabelProvider(); if (baseLabel instanceof ITableLabelProvider) { ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel; String e1p = tableProvider.getColumnText(a, columnNumber); String e2p = tableProvider.getColumnText(b, columnNumber); if (e1p != null && e2p != null) { return getComparator().compare(e1p, e2p); } } return 0; }
Example #28
Source File: AbstractOutlineWorkbenchTest.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
protected void awaitForTreeViewer(TreeViewer treeViewer) { long waitTime = 0; while (treeViewer.getInput() == null && waitTime < EXPECTED_TIMEOUT) { waitTime += 10; if (Display.getCurrent() != null) Display.getCurrent().readAndDispatch(); } }
Example #29
Source File: ExternalLibraryTreeContentProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { if (viewer instanceof TreeViewer) { this.treeViewerRef = Optional.of((TreeViewer) viewer); } else { this.treeViewerRef = Optional.absent(); } // clear projects cache when input changes this.locationProjectsCache.clear(); }
Example #30
Source File: AbstractSegmentsStatisticsViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Constructor * * @param parent * the parent composite * @param dataProviderId * the data provider extension point ID. * @since 3.0 */ public AbstractSegmentsStatisticsViewer(Composite parent, @Nullable String dataProviderId) { super(parent, false); setLabelProvider(new SegmentStoreStatisticsLabelProvider()); fTablePopupMenuManager = new MenuManager(); fTablePopupMenuManager.setRemoveAllWhenShown(true); fTablePopupMenuManager.addMenuListener(manager -> { TreeViewer viewer = getTreeViewer(); ISelection selection = viewer.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; if (manager != null) { appendToTablePopupMenu(manager, sel); } } }); Menu tablePopup = fTablePopupMenuManager.createContextMenu(getTreeViewer().getTree()); Tree tree = getTreeViewer().getTree(); tree.setMenu(tablePopup); tree.addDisposeListener(e -> { if (fModule != null) { fModule.dispose(); } }); fProviderId = dataProviderId; }