import org.eclipse.ui.IEditorPart;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ReadRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.request.PossibleModel;\r
import org.simantics.db.layer0.variable.RVI;\r
import org.simantics.modeling.actions.NavigateToTarget;\r
import org.simantics.modeling.ui.Activator;\r
import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;\r
import org.simantics.utils.datastructures.Callback;\r
-import org.simantics.utils.threads.SWTThread;\r
import org.simantics.utils.threads.ThreadUtils;\r
import org.simantics.utils.ui.AdaptionUtils;\r
\r
\r
private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
\r
+ private static Collection<Runnable> rs;\r
+ \r
public OpenDiagramFromComponentAdapter() {\r
super("Diagram Editor", Activator.COMPOSITE_ICON);\r
}\r
if (r == null)\r
return false;\r
Variable v = AdaptionUtils.adaptToSingle(input, Variable.class);\r
- Collection<Runnable> rs = tryFindDiagram(graph, r, v);\r
+ rs = tryFindDiagram(graph, r, v);\r
return !rs.isEmpty();\r
}\r
\r
if (d == null)\r
return;\r
\r
- SimanticsUI.getSession().syncRequest(new ReadRequest() {\r
- @Override\r
- public void run(ReadGraph graph) throws DatabaseException {\r
- Resource r = tryGetResource(graph, input);\r
- if (r == null)\r
- return;\r
-\r
- Variable v = AdaptionUtils.adaptToSingle(input, Variable.class);\r
-\r
- final Collection<Runnable> rs = tryFindDiagram(graph, r, v);\r
- if (rs.isEmpty())\r
- return;\r
-\r
- SWTThread.getThreadAccess(d).asyncExec(new Runnable() {\r
- @Override\r
- public void run() {\r
- for (Runnable runnable : rs) {\r
- runnable.run();\r
- }\r
- }\r
- });\r
- }\r
- });\r
+ for (Runnable runnable : rs) {\r
+ runnable.run();\r
+ }\r
}\r
\r
private Collection<Runnable> tryFindDiagram(ReadGraph g, Resource module, Variable variable) throws DatabaseException {\r