]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/viewpoint/VariableChildRule.java
Externalize strings
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / viewpoint / VariableChildRule.java
1 package org.simantics.modeling.ui.viewpoint;
2
3 import java.util.Collection;
4 import java.util.Collections;
5
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;
11
12 public class VariableChildRule implements ChildRule {
13
14     @Override
15     public boolean isCompatible(Class<?> contentType) {
16         return contentType.equals(Variable.class);
17     }
18
19     @Override
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);
24     }
25
26     @Override
27     public Collection<?> getParents(ReadGraph graph, Object child)
28             throws DatabaseException {
29         Variable parent = ((Variable)child).getParent(graph);
30         if(parent == null)
31             return Collections.emptyList();
32         else
33             return Collections.singleton(parent);
34     }
35
36
37 }