Java Code Examples for org.eclipse.jface.viewers.TreePath#getSegmentCount()
The following examples show how to use
org.eclipse.jface.viewers.TreePath#getSegmentCount() .
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: 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 3
Source File: RenameSelectionState.java From typescript.java with MIT License | 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 4
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 5
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 6
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 7
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 8
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(); }
Example 9
Source File: RenameSelectionState.java From typescript.java with MIT License | 4 votes |
public void restore(Object newElement) { if (fDisplay == null) return; for (int i = 0; i < fParts.size(); i++) { IStructuredSelection currentSelection = (IStructuredSelection) fSelections.get(i); boolean changed = false; final ISetSelectionTarget target = (ISetSelectionTarget) fParts.get(i); final IStructuredSelection[] newSelection = new IStructuredSelection[1]; newSelection[0] = currentSelection; if (currentSelection instanceof TreeSelection) { TreeSelection treeSelection = (TreeSelection) currentSelection; TreePath[] paths = treeSelection.getPaths(); for (int p = 0; p < paths.length; p++) { TreePath path = paths[p]; if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) { paths[p] = createTreePath(path, newElement); changed = true; } } if (changed) { newSelection[0] = new TreeSelection(paths, treeSelection.getElementComparer()); } } else { Object[] elements = currentSelection.toArray(); for (int e = 0; e < elements.length; e++) { if (elements[e].equals(fElement)) { elements[e] = newElement; changed = true; } } if (changed) { newSelection[0] = new StructuredSelection(elements); } } if (changed) { fDisplay.asyncExec(new Runnable() { public void run() { target.selectReveal(newSelection[0]); } }); } } }
Example 10
Source File: RenameSelectionState.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void restore(Object newElement) { if (fDisplay == null) return; for (int i= 0; i < fParts.size(); i++) { IStructuredSelection currentSelection= fSelections.get(i); boolean changed= false; final ISetSelectionTarget target= (ISetSelectionTarget)fParts.get(i); final IStructuredSelection[] newSelection= new IStructuredSelection[1]; newSelection[0]= currentSelection; if (currentSelection instanceof TreeSelection) { TreeSelection treeSelection= (TreeSelection)currentSelection; TreePath[] paths= treeSelection.getPaths(); for (int p= 0; p < paths.length; p++) { TreePath path= paths[p]; if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) { paths[p]= createTreePath(path, newElement); changed= true; } } if (changed) { newSelection[0]= new TreeSelection(paths, treeSelection.getElementComparer()); } } else { Object[] elements= currentSelection.toArray(); for (int e= 0; e < elements.length; e++) { if (elements[e].equals(fElement)) { elements[e]= newElement; changed= true; } } if (changed) { newSelection[0]= new StructuredSelection(elements); } } if (changed) { fDisplay.asyncExec(new Runnable() { public void run() { target.selectReveal(newSelection[0]); } }); } } }