]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.issues.ui/src/org/simantics/issues/ui/DynamicIssueSourceHierarchyRule.java
Preliminary support for purely Variable based dynamic issue sources
[simantics/platform.git] / bundles / org.simantics.issues.ui / src / org / simantics / issues / ui / DynamicIssueSourceHierarchyRule.java
1 package org.simantics.issues.ui;
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
11 /**
12  * @author Tuukka Lehtonen
13  * @since 1.27
14  */
15 public class DynamicIssueSourceHierarchyRule implements ChildRule {
16
17     @Override
18     public boolean isCompatible(Class<?> contentType) {
19         return contentType.equals(Variable.class);
20     }
21
22     @Override
23     public Collection<?> getChildren(ReadGraph graph, Object parent) throws DatabaseException {
24         Variable v = (Variable) parent;
25         return v.getChildren(graph);
26     }
27
28     @Override
29     public Collection<?> getParents(ReadGraph graph, Object child) throws DatabaseException {
30         Variable parent = ((Variable)child).getParent(graph);
31         return parent != null ? Collections.singleton(parent) : Collections.emptyList();
32     }
33
34 }