use of org.eclipse.jface.viewers.TreePath in project hale by halestudio.
the class PropertyDefinitionDialog method getObjectFromSelection.
@Override
protected EntityDefinition getObjectFromSelection(ISelection selection) {
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof EntityDefinition) {
return (EntityDefinition) element;
}
}
if (!selection.isEmpty() && selection instanceof ITreeSelection) {
// create property definition w/ default contexts
TreePath path = ((ITreeSelection) selection).getPaths()[0];
// get parent type
TypeDefinition type = ((ChildDefinition<?>) path.getFirstSegment()).getParentType();
// determine definition path
List<ChildContext> defPath = new ArrayList<ChildContext>();
for (int i = 0; i < path.getSegmentCount(); i++) {
defPath.add(new ChildContext((ChildDefinition<?>) path.getSegment(i)));
}
// TODO check if property entity definition is applicable?
return new PropertyEntityDefinition(type, defPath, ssid, null);
}
return null;
}
use of org.eclipse.jface.viewers.TreePath in project hale by halestudio.
the class SchemaPatternFilter method isElementVisible.
/**
* @see eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter#isElementVisible(org.eclipse.jface.viewers.Viewer,
* java.lang.Object)
*/
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
TreePath elementPath = (TreePath) element;
Object segment = elementPath.getLastSegment();
if (segment instanceof EntityDefinition) {
segment = ((EntityDefinition) segment).getDefinition();
}
if (memoryAccepted.contains(segment))
return true;
if (memoryRejected.contains(segment))
return false;
boolean match = isLeafMatch(viewer, element);
if (!match) {
match = isParentMatch(viewer, element);
if (!match) {
memoryRejected.add(segment);
}
}
if (match) {
memoryAccepted.add(segment);
}
return match;
}
use of org.eclipse.jface.viewers.TreePath in project hale by halestudio.
the class SchemaPatternFilter method isLeafMatch.
/**
* @see eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter#isLeafMatch(org.eclipse.jface.viewers.Viewer,
* java.lang.Object)
*/
@Override
protected boolean isLeafMatch(Viewer viewer, Object element) {
boolean leaf = matches(viewer, element);
if (leaf) {
return true;
}
// return true, if this element' definition was classified as visible
TreePath elementPath = (TreePath) element;
Object segment = elementPath.getLastSegment();
if (segment instanceof EntityDefinition) {
segment = ((EntityDefinition) segment).getDefinition();
}
return memoryAccepted.contains(segment);
}
use of org.eclipse.jface.viewers.TreePath in project hale by halestudio.
the class TreePathFilteredTree method getPathsForElements.
/**
* Get the tree paths for the given objects with the given parent path.
*
* @param parentPath the parent path for each object
* @param elements the objects
* @return the list of tree paths
*/
public static List<TreePath> getPathsForElements(TreePath parentPath, Object[] elements) {
List<TreePath> paths = new ArrayList<TreePath>();
// create tree paths from elements
List<Object> parentSegments = new ArrayList<Object>();
if (parentPath != null) {
for (int i = 0; i < parentPath.getSegmentCount(); i++) {
parentSegments.add(parentPath.getSegment(i));
}
}
for (Object element : elements) {
TreePath path;
if (parentPath == null) {
path = new TreePath(new Object[] { element });
} else {
parentSegments.add(element);
path = new TreePath(parentSegments.toArray());
parentSegments.remove(parentSegments.size() - 1);
}
paths.add(path);
}
return paths;
}
use of org.eclipse.jface.viewers.TreePath in project hale by halestudio.
the class ClassificationFilter method select.
/**
* @see ViewerFilter#select(Viewer, Object, Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof TreePath) {
element = ((TreePath) element).getLastSegment();
}
if (element instanceof EntityDefinition) {
element = ((EntityDefinition) element).getDefinition();
}
if (hidden.isEmpty() || !(element instanceof Definition<?>)) {
// fast exit
return true;
}
Definition<?> def = (Definition<?>) element;
Classification clazz = Classification.getClassification(def);
return !hidden.contains(clazz);
}
Aggregations