org.eclipse.jface.viewers.TreePath Java Examples
The following examples show how to use
org.eclipse.jface.viewers.TreePath.
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: JavaSynchronizationLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void updateLabel(ViewerLabel label, TreePath elementPath) { Object firstSegment = elementPath.getFirstSegment(); if (firstSegment instanceof IProject && elementPath.getSegmentCount() == 2) { IProject project = (IProject) firstSegment; Object lastSegment = elementPath.getLastSegment(); if (lastSegment instanceof IFolder) { IFolder folder = (IFolder) lastSegment; if (!folder.getParent().equals(project)) { // This means that a folder that is not a direct child of the project // is a child in the tree. Therefore, the resource content provider // must be active and in compress folder mode so we will leave // it to the resource provider to provide the proper label. // We need to do this because of bug 153912 return; } } } label.setImage(getImage(elementPath.getLastSegment())); label.setText(getText(elementPath.getLastSegment())); Font f = getFont(elementPath.getLastSegment()); if (f != null) label.setFont(f); }
Example #2
Source File: WorkingSetAwareContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private List<TreePath> getTreePaths(List<Object> modelParents, int index) { List<TreePath> result= new ArrayList<TreePath>(); Object input= getViewerInput(); Object element= modelParents.get(index); Object[] parents= fWorkingSetModel.getAllParents(element); for (int i= 0; i < parents.length; i++) { List<Object> chain= new ArrayList<Object>(); if (!parents[i].equals(input)) chain.add(parents[i]); for (int m= index; m < modelParents.size(); m++) { chain.add(modelParents.get(m)); } result.add(new TreePath(chain.toArray())); } return result; }
Example #3
Source File: LogContent.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private void copyTreeSelectionToClipboard() { ITreeSelection selection = (ITreeSelection) treeViewer.getSelection(); TreePath[] paths = selection.getPaths(); StringBuffer buf = new StringBuffer(); for (TreePath path : paths) { LogEntry<?> entry = (LogEntry<?>) path.getLastSegment(); buf.append(createTabString(path.getSegmentCount() - 1)); buf.append(entry.toString()); buf.append("\n"); } if (buf.length() > 0) { buf.deleteCharAt(buf.length() - 1); // take off last \n } copyToClipboard(buf.toString()); }
Example #4
Source File: GalleryTreeViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
public void editElement(Object element, int column) { if (element instanceof TreePath) { setSelection(new TreeSelection((TreePath) element)); GalleryItem[] items = gallery.getSelection(); if (items.length == 1) { ViewerRow row = getViewerRowFromItem(items[0]); if (row != null) { ViewerCell cell = row.getCell(column); if (cell != null) { getControl().setRedraw(false); triggerEditorActivationEvent( new ColumnViewerEditorActivationEvent(cell)); getControl().setRedraw(true); } } } } else { super.editElement(element, column); } }
Example #5
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.jface.viewers.AbstractTreeViewer#getParentElement(java.lang.Object) */ protected Object getParentElement(Object element) { boolean oldBusy = isBusy(); setBusy(true); try { if (contentProviderIsLazy && !contentProviderIsTreeBased && !(element instanceof TreePath)) { ILazyTreeContentProvider lazyTreeContentProvider = (ILazyTreeContentProvider) getContentProvider(); return lazyTreeContentProvider.getParent(element); } if (contentProviderIsLazy && contentProviderIsTreeBased && !(element instanceof TreePath)) { ILazyTreePathContentProvider lazyTreePathContentProvider = (ILazyTreePathContentProvider) getContentProvider(); TreePath[] parents = lazyTreePathContentProvider.getParents(element); if (parents != null && parents.length > 0) { return parents[0]; } } return super.getParentElement(element); } finally { setBusy(oldBusy); } }
Example #6
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Update the widget at index. * * @param widget * @param index */ private void virtualLazyUpdateWidget(Widget widget, int index) { boolean oldBusy = isBusy(); setBusy(false); try { if (contentProviderIsTreeBased) { TreePath treePath; if (widget instanceof Item) { if (widget.getData() == null) { return; } treePath = getTreePathFromItem((Item) widget); } else { treePath = TreePath.EMPTY; } ((ILazyTreePathContentProvider) getContentProvider()).updateElement(treePath, index); } else { ((ILazyTreeContentProvider) getContentProvider()).updateElement(widget.getData(), index); } } finally { setBusy(oldBusy); } }
Example #7
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Update the child count * * @param widget * @param currentChildCount */ private void virtualLazyUpdateChildCount(Widget widget, int currentChildCount) { boolean oldBusy = isBusy(); setBusy(false); try { if (contentProviderIsTreeBased) { TreePath treePath; if (widget instanceof Item) { treePath = getTreePathFromItem((Item) widget); } else { treePath = TreePath.EMPTY; } ((ILazyTreePathContentProvider) getContentProvider()).updateChildCount(treePath, currentChildCount); } else { ((ILazyTreeContentProvider) getContentProvider()).updateChildCount(widget.getData(), currentChildCount); } } finally { setBusy(oldBusy); } }
Example #8
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Update the item with the current child count. * * @param item * @param currentChildCount */ private void virtualLazyUpdateHasChildren(Item item, int currentChildCount) { boolean oldBusy = isBusy(); setBusy(false); try { if (contentProviderIsTreeBased) { TreePath treePath; treePath = getTreePathFromItem(item); if (currentChildCount == 0) { // item is not expanded (but may have a plus currently) ((ILazyTreePathContentProvider) getContentProvider()).updateHasChildren(treePath); } else { ((ILazyTreePathContentProvider) getContentProvider()).updateChildCount(treePath, currentChildCount); } } else { ((ILazyTreeContentProvider) getContentProvider()).updateChildCount(item.getData(), currentChildCount); } } finally { setBusy(oldBusy); } }
Example #9
Source File: CTreeComboViewer.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.jface.viewers.ColumnViewer#editElement(java.lang.Object, int) */ public void editElement(Object element, int column) { if (element instanceof TreePath) { try { getControl().setRedraw(false); setSelection(new TreeSelection((TreePath) element)); CTreeComboItem[] items = tree.getSelection(); if (items.length == 1) { ViewerRow row = getViewerRowFromItem(items[0]); if (row != null) { ViewerCell cell = row.getCell(column); if (cell != null) { triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell)); } } } } finally { getControl().setRedraw(true); } } else { super.editElement(element, column); } }
Example #10
Source File: TreeViewerBackup.java From birt with Eclipse Public License 1.0 | 6 votes |
public void updateStatus( TreeViewer treeViewer ) { TreePath[] treepaths = treeViewer.getExpandedTreePaths( ); List list = Arrays.asList( treepaths ); leafList.clear( ); leafList.addAll( list ); for ( int i = 0; i < leafList.size( ); i++ ) { TreePath path = ( (TreePath) leafList.get( i ) ).getParentPath( ); if ( path == null ) { leafList.remove( i ); i--; } if ( leafList.contains( path ) ) { leafList.remove( path ); i--; } } }
Example #11
Source File: PyPackageStateSaver.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Saves some selection in the memento object. */ private void save(TreePath treePath, String type) { if (treePath != null) { Object object = treePath.getLastSegment(); if (object instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) object; IResource resource = (IResource) adaptable.getAdapter(IResource.class); if (resource != null) { IPath path = resource.getLocation(); if (path != null) { memento.createChild(type, path.toPortableString()); } } } } }
Example #12
Source File: ActorMappingConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void doubleClick(final DoubleClickEvent event) { final TreePath treePath = ((ITreeSelection) event.getSelection()).getPaths()[0]; for (int i = treePath.getSegmentCount() - 1; i >= 0; i--) { final Object selection = treePath.getSegment(i); if (selection instanceof Users) { userAction(); } else if (selection instanceof Membership) { membershipAction(); } else if (selection instanceof Groups) { groupAction(); } else if (selection instanceof Roles) { roleAction(); } } }
Example #13
Source File: NavigatorContentProvider.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public TreePath[] getParents(final Object element) { final ArrayList segments = new ArrayList(); Object parent = element; do { parent = getParent(parent); if (parent != null && parent != getInstance()) segments.add(0, parent); } while (parent != null && parent != getInstance()); if (!segments.isEmpty()) { return new TreePath[] { new TreePath(segments.toArray()) }; } return new TreePath[0]; }
Example #14
Source File: WorkingSetAwareContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public TreePath[] getTreePaths(Object element) { if (element instanceof IWorkingSet) { TreePath path= new TreePath(new Object[] {element}); return new TreePath[] {path}; } List<Object> modelParents= getModelPath(element); List<TreePath> result= new ArrayList<TreePath>(); for (int i= 0; i < modelParents.size(); i++) { result.addAll(getTreePaths(modelParents, i)); } return result.toArray(new TreePath[result.size()]); }
Example #15
Source File: WorkingSetDropAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Map<IWorkingSet, List<Object>> groupByWorkingSets(TreePath[] paths) { Map<IWorkingSet, List<Object>> result= new HashMap<IWorkingSet, List<Object>>(); for (int i= 0; i < paths.length; i++) { TreePath path= paths[i]; IWorkingSet ws= (IWorkingSet)path.getSegment(0); List<Object> l= result.get(ws); if (l == null) { l= new ArrayList<Object>(); result.put(ws, l); } l.add(path.getSegment(1)); } return result; }
Example #16
Source File: PackageExplorerActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
void handleDoubleClick(DoubleClickEvent event) { TreeViewer viewer= fPart.getTreeViewer(); IStructuredSelection selection= (IStructuredSelection)event.getSelection(); Object element= selection.getFirstElement(); if (viewer.isExpandable(element)) { if (doubleClickGoesInto()) { // don't zoom into compilation units and class files if (element instanceof ICompilationUnit || element instanceof IClassFile) return; if (element instanceof IOpenable || element instanceof IContainer || element instanceof IWorkingSet) { fZoomInAction.run(); } } else { IAction openAction= fNavigateActionGroup.getOpenAction(); if (openAction != null && openAction.isEnabled() && OpenStrategy.getOpenMethod() == OpenStrategy.DOUBLE_CLICK) return; if (selection instanceof ITreeSelection) { TreePath[] paths= ((ITreeSelection)selection).getPathsFor(element); for (int i= 0; i < paths.length; i++) { viewer.setExpandedState(paths[i], !viewer.getExpandedState(paths[i])); } } else { viewer.setExpandedState(element, !viewer.getExpandedState(element)); } } } else if (element instanceof IProject && !((IProject) element).isOpen()) { OpenProjectAction openProjectAction= fProjectActionGroup.getOpenProjectAction(); if (openProjectAction.isEnabled()) { openProjectAction.run(); } } }
Example #17
Source File: RenameSelectionState.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private TreePath createTreePath(TreePath old, Object newElement) { int count= old.getSegmentCount(); Object[] newObjects= new Object[count]; for (int i= 0; i < count - 1; i++) { newObjects[i]= old.getSegment(i); } newObjects[count - 1]= newElement; return new TreePath(newObjects); }
Example #18
Source File: PydevPackageExplorer.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Returns the tree path for the given item. * * It's overridden because when using mylyn, the paths may be expanded but not shown, so segment is null * -- that's why we return null if a given segment is null (instead of the assert that it contains in the superclass) * @since 3.2 */ @Override protected TreePath getTreePathFromItem(Item item) { LinkedList<Object> segments = new LinkedListWarningOnSlowOperations<Object>(); while (item != null) { Object segment = item.getData(); if (segment == null) { return null; } segments.addFirst(segment); item = getParentItem(item); } return new TreePath(segments.toArray()); }
Example #19
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 #20
Source File: CrossflowNavigatorLabelProvider.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ public void updateLabel(ViewerLabel label, TreePath elementPath) { Object element = elementPath.getLastSegment(); if (element instanceof CrossflowNavigatorItem && !isOwnView(((CrossflowNavigatorItem) element).getView())) { return; } label.setText(getText(element)); label.setImage(getImage(element)); }
Example #21
Source File: UserLibraryPreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IPath getWorkbenchWindowSelection() { IWorkbenchWindow window= fWorkbench.getActiveWorkbenchWindow(); if (window != null) { ISelection selection= window.getSelectionService().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection= (IStructuredSelection) selection; Object element= structuredSelection.getFirstElement(); if (element != null) { Object resource= Platform.getAdapterManager().getAdapter(element, IResource.class); if (resource != null) { return ((IResource) resource).getFullPath(); } if (structuredSelection instanceof ITreeSelection) { TreePath treePath= ((ITreeSelection) structuredSelection).getPaths()[0]; while ((treePath = treePath.getParentPath()) != null) { element= treePath.getLastSegment(); resource= Platform.getAdapterManager().getAdapter(element, IResource.class); if (resource != null) { return ((IResource) resource).getFullPath(); } } } } } } return null; }
Example #22
Source File: NavigatorFilter.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { if (parentElement instanceof TreePath && ResourceManager.isFile(element)) { final TreePath p = (TreePath) parentElement; if (p.getLastSegment() instanceof WrappedFolder) { final IResource r = FileMetaDataProvider.shapeFileSupportedBy(ResourceManager.getFile(element)); if (r != null) { return false; } } } return true; }
Example #23
Source File: SelectPathDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param selection * @param useQualifiedName TODO * @return */ public static String computeXPath(ITreeSelection selection, boolean useQualifiedName) { if (selection.getPaths().length == 0) { return ""; } TreePath path = selection.getPaths()[0]; return computeXPath(path, useQualifiedName); }
Example #24
Source File: SelectPathDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param path * @param useQualifiedName TODO * @return */ public static String computeXPath(TreePath path, boolean useQualifiedName) { StringBuilder pathBuilder = new StringBuilder(); for (int i = 1; i < path.getSegmentCount(); i++) { if (path.getSegment(i) instanceof XSDContentProvider.Append) { continue; } pathBuilder.append('/'); XSDNamedComponent item = (XSDNamedComponent)path.getSegment(i); if (item instanceof XSDAttributeDeclaration) { pathBuilder.append('@'); } if(useQualifiedName){ pathBuilder.append(item.getQName()); } else { pathBuilder.append(item.getName()); } if (item instanceof XSDElementDeclaration) { XSDElementDeclaration element = (XSDElementDeclaration)item; if (element.getContainer() instanceof XSDParticle) { XSDParticle particle = (XSDParticle)element.getContainer(); if (particle.getMaxOccurs() < 0 || particle.getMinOccurs() > 1) { pathBuilder.append("[1]"); } } } } if (path.getLastSegment() instanceof XSDElementDeclaration && ((XSDElementDeclaration)path.getLastSegment()).getType().getSimpleType() != null) { pathBuilder.append("/text()"); } if (path.getLastSegment() instanceof XSDContentProvider.Append) { pathBuilder.append(BonitaConstants.XPATH_VAR_SEPARATOR + BonitaConstants.XPATH_APPEND_FLAG); } return pathBuilder.toString(); }
Example #25
Source File: XPathOperatorEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String computeXPath(ITreeSelection selection, boolean useQualifiedName) { if (selection.getPaths().length == 0) { return ""; } TreePath path = selection.getPaths()[0]; return computeXPath(path, useQualifiedName); }
Example #26
Source File: XPathOperatorEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String computeXPath(TreePath path, boolean useQualifiedName) { StringBuilder pathBuilder = new StringBuilder(); for (int i = 1; i < path.getSegmentCount(); i++) { if (path.getSegment(i) instanceof XSDContentProvider.Append) { continue; } pathBuilder.append('/'); XSDNamedComponent item = (XSDNamedComponent)path.getSegment(i); if (item instanceof XSDAttributeDeclaration) { pathBuilder.append('@'); } if(useQualifiedName){ pathBuilder.append(item.getQName()); } else { pathBuilder.append(item.getName()); } if (item instanceof XSDElementDeclaration) { XSDElementDeclaration element = (XSDElementDeclaration)item; if (element.getContainer() instanceof XSDParticle) { XSDParticle particle = (XSDParticle)element.getContainer(); if (particle.getMaxOccurs() < 0 || particle.getMinOccurs() > 1) { pathBuilder.append("[1]"); } } } } if (path.getLastSegment() instanceof XSDElementDeclaration && ((XSDElementDeclaration)path.getLastSegment()).getType().getSimpleType() != null) { pathBuilder.append("/text()"); } if (path.getLastSegment() instanceof XSDContentProvider.Append) { pathBuilder.append(BonitaConstants.XPATH_VAR_SEPARATOR + BonitaConstants.XPATH_APPEND_FLAG); } return pathBuilder.toString(); }
Example #27
Source File: XPathExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static String computeXPath(final ITreeSelection selection, final boolean useQualifiedName) { if (selection.getPaths().length == 0) { return ""; } final TreePath path = selection.getPaths()[0]; return computeXPath(path, useQualifiedName); }
Example #28
Source File: XPathExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static String computeXPath(final TreePath path, final boolean useQualifiedName) { final StringBuilder pathBuilder = new StringBuilder(); for (int i = 1; i < path.getSegmentCount(); i++) { if (path.getSegment(i) instanceof XSDContentProvider.Append) { continue; } pathBuilder.append('/'); final XSDNamedComponent item = (XSDNamedComponent) path.getSegment(i); if (item instanceof XSDAttributeDeclaration) { pathBuilder.append('@'); } if (useQualifiedName) { pathBuilder.append(item.getQName()); } else { pathBuilder.append(item.getName()); } if (item instanceof XSDElementDeclaration) { final XSDElementDeclaration element = (XSDElementDeclaration) item; if (element.getContainer() instanceof XSDParticle) { final XSDParticle particle = (XSDParticle) element.getContainer(); if (particle.getMaxOccurs() < 0 || particle.getMinOccurs() > 1) { pathBuilder.append("[1]"); } } } } if (path.getLastSegment() instanceof XSDElementDeclaration && ((XSDElementDeclaration) path.getLastSegment()).getType().getSimpleType() != null) { pathBuilder.append("/text()"); } if (path.getLastSegment() instanceof XSDContentProvider.Append) { pathBuilder.append(BonitaConstants.XPATH_VAR_SEPARATOR + BonitaConstants.XPATH_APPEND_FLAG); } return pathBuilder.toString(); }
Example #29
Source File: ProcessNavigatorLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ public void updateLabel(ViewerLabel label, TreePath elementPath) { Object element = elementPath.getLastSegment(); if (element instanceof ProcessNavigatorItem && !isOwnView(((ProcessNavigatorItem) element).getView())) { return; } label.setText(getText(element)); label.setImage(getImage(element)); }
Example #30
Source File: JavaSetterOperatorEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String generateJavaAdditionalPath(final ITreeSelection selection) { if (selection == null) { return ""; } final TreePath path = selection.getPaths()[0]; if (path.getSegmentCount() == 1) { return ""; } final StringBuilder res = new StringBuilder(); final Object item = path.getSegment(path.getSegmentCount() - 1); res.append(((IJavaElement) item).getElementName()); return res.toString(); }