package org.simantics.issues.ui; import java.util.Collection; import java.util.Collections; import org.simantics.browsing.ui.model.children.ChildRule; import org.simantics.db.ReadGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; /** * @author Tuukka Lehtonen * @since 1.27 */ public class DynamicIssueSourceHierarchyRule implements ChildRule { @Override public boolean isCompatible(Class contentType) { return contentType.equals(Variable.class); } @Override public Collection getChildren(ReadGraph graph, Object parent) throws DatabaseException { Variable v = (Variable) parent; return v.getChildren(graph); } @Override public Collection getParents(ReadGraph graph, Object child) throws DatabaseException { Variable parent = ((Variable)child).getParent(graph); return parent != null ? Collections.singleton(parent) : Collections.emptyList(); } }