1 package org.simantics.modeling.ui.viewpoint;
3 import java.util.Collection;
4 import java.util.Collections;
6 import org.simantics.browsing.ui.model.children.ChildRule;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.variable.Variable;
10 import org.simantics.structural.stubs.StructuralResource2;
12 public class VariableChildRule implements ChildRule {
15 public boolean isCompatible(Class<?> contentType) {
16 return contentType.equals(Variable.class);
20 public Collection<?> getChildren(ReadGraph graph, Object parent)
21 throws DatabaseException {
22 Collection<Variable> children = ((Variable)parent).getChildren(graph);
23 return VariableChildren.filterByClassification(graph, children, StructuralResource2.URIs.Component);
27 public Collection<?> getParents(ReadGraph graph, Object child)
28 throws DatabaseException {
29 Variable parent = ((Variable)child).getParent(graph);
31 return Collections.emptyList();
33 return Collections.singleton(parent);