Java Code Examples for org.eclipse.jface.viewers.TreePath#getSegment()

The following examples show how to use org.eclipse.jface.viewers.TreePath#getSegment() . 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 vote down vote up
@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 2
Source File: RenameSelectionState.java    From typescript.java with MIT License 5 votes vote down vote up
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 3
Source File: RenameSelectionState.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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: WorkingSetDropAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 5
Source File: SelectPathDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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 vote down vote up
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 vote down vote up
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 vote down vote up
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();
}