1 package org.simantics.sysdyn.ui.browser.childrules;
\r
3 import java.util.ArrayList;
\r
4 import java.util.Collection;
\r
6 import org.simantics.browsing.ui.model.children.ChildRule;
\r
7 import org.simantics.db.ReadGraph;
\r
8 import org.simantics.db.Resource;
\r
9 import org.simantics.db.common.request.ObjectsWithType;
\r
10 import org.simantics.db.exception.DatabaseException;
\r
11 import org.simantics.layer0.Layer0;
\r
12 import org.simantics.modeling.ModelingResources;
\r
13 import org.simantics.structural.stubs.StructuralResource2;
\r
14 import org.simantics.sysdyn.SysdynResource;
\r
17 public class ModuleTypeChildRule implements ChildRule {
\r
20 public boolean isCompatible(Class<?> contentType) {
\r
21 return contentType.equals(Resource.class);
\r
25 public Collection<?> getChildren(ReadGraph graph, Object parent)
\r
26 throws DatabaseException {
\r
28 ArrayList<Resource> children = new ArrayList<Resource>();
\r
30 if(!(parent instanceof Resource)) {
\r
34 Layer0 l0 = Layer0.getInstance(graph);
\r
35 StructuralResource2 st = StructuralResource2.getInstance(graph);
\r
37 Resource model = (Resource)parent;
\r
38 if(!graph.isInstanceOf(model, SysdynResource.getInstance(graph).SysdynModel))
\r
41 for(Resource r : graph.syncRequest(new ObjectsWithType(model, l0.ConsistsOf, st.ComponentType))) {
\r
42 if(graph.isInheritedFrom(r, SysdynResource.getInstance(graph).Module)) {
\r
43 Resource symbol = graph.getPossibleObject(r,ModelingResources.getInstance(graph).ComponentTypeToSymbol);
\r
44 children.add(symbol);
\r
52 public Collection<?> getParents(ReadGraph graph, Object child)
\r
53 throws DatabaseException {
\r
54 return new ArrayList<Resource>();
\r