]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/utils/Monitors.java
Find SCL references in SCLModuleEditor with Ctrl+Shift+G
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / utils / Monitors.java
1 package org.simantics.modeling.utils;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.exception.DatabaseException;
6 import org.simantics.diagram.stubs.DiagramResource;
7 import org.simantics.modeling.ModelingResources;
8
9 /**
10  * Utilities for dealing with diagram monitors.
11  * 
12  * @author Tuukka Lehtonen
13  */
14 public final class Monitors {
15
16     public static Resource getMonitoredComponent(ReadGraph graph, Resource monitor) throws DatabaseException {
17         DiagramResource DIA = DiagramResource.getInstance(graph);
18         Resource component = graph.getPossibleObject(monitor, DIA.HasMonitorComponent);
19         return component;
20     }
21
22     public static Resource getMonitoredElement(ReadGraph graph, Resource monitor) throws DatabaseException {
23         Resource component = getMonitoredComponent(graph, monitor);
24         if (component == null)
25             return null;
26         ModelingResources MOD = ModelingResources.getInstance(graph);
27         Resource element = graph.getPossibleObject(component, MOD.ComponentToElement);
28         return element;
29     }
30
31 }