style="push">\r
</command>\r
</menu>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.showModule"\r
+ icon="icons/silk/palette.png"\r
+ label="Show Module"\r
+ style="push">\r
+ <visibleWhen>\r
+ <and>\r
+ <with\r
+ variable="selection">\r
+ <and>\r
+ <test\r
+ args="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r
+ property="org.simantics.graph.resourceType">\r
+ </test>\r
+ </and>\r
+ </with>\r
+ </and>\r
+ </visibleWhen>\r
+ </command>\r
<command\r
commandId="org.simantics.sysdyn.ui.rename"\r
icon="icons/textfield_rename.png"\r
id="org.simantics.sysdyn.ui.trend.view.pin.state">\r
</state>\r
</command>\r
+ <command\r
+ id="org.simantics.sysdyn.ui.showModule"\r
+ name="Show Module">\r
+ </command>\r
<command\r
defaultHandler="org.simantics.sysdyn.ui.handlers.CreateAuxiliaryHandler"\r
id="org.simantics.sysdyn.ui.createAuxiliary"\r
</with>\r
</activeWhen>\r
</handler>\r
+ <handler\r
+ class="org.simantics.sysdyn.ui.handlers.ShowModuleHandler"\r
+ commandId="org.simantics.sysdyn.ui.showModule">\r
+ <enabledWhen>\r
+ <and>\r
+ <with\r
+ variable="selection">\r
+ <and>\r
+ <test\r
+ args="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r
+ property="org.simantics.graph.resourceType">\r
+ </test>\r
+ </and>\r
+ </with>\r
+ </and>\r
+ </enabledWhen>\r
+ </handler>\r
<handler\r
class="org.simantics.sysdyn.ui.handlers.RenameHandler"\r
commandId="org.simantics.sysdyn.ui.rename">\r
*/\r
public class DiagramViewer extends org.simantics.modeling.ui.diagramEditor.DiagramViewer {\r
\r
- @Override\r
+ protected String getPopupId() {\r
+ return "#SysdynDiagramPopup";\r
+ }\r
+\r
+ @Override\r
protected Set<String> getPropertyPageContexts() {\r
return Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser");\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.binding.java.StringBindingDefault;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.ResourceArray;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.modeling.ComponentUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.StructuralVariables;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.editor.DiagramViewer;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+/**\r
+ * Style Edit\r
+ * \r
+ * TODO : should we have extension point for expanding styles?\r
+ * TODO : default ColorChooser is not suitable for this task\r
+ * TODO : how to store MetricsFormat template list\r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public class ShowModuleHandler extends AbstractHandler {\r
+\r
+ private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ \r
+ ISelection s = HandlerUtil.getCurrentSelectionChecked(event);\r
+ final Resource resources[] = ResourceAdaptionUtils.toResources(s);\r
+ final DiagramViewer viewer = (DiagramViewer)HandlerUtil.getActiveEditor(event);\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+\r
+ DiagramResource dr = DiagramResource.getInstance(graph);\r
+ Resource runtime = viewer.getRuntime();\r
+ String uri = graph.getPossibleRelatedValue(runtime, dr.HasVariable, StringBindingDefault.INSTANCE);\r
+ String currentRVI = graph.getPossibleRelatedValue(runtime, dr.HasRVI, StringBindingDefault.INSTANCE);\r
+ Variable variable = Variables.getVariable(graph, uri);\r
+ Resource model = Variables.getModel(graph, variable);\r
+ final String modelURI = graph.getURI(model);\r
+ \r
+ for(Resource element : resources) {\r
+\r
+ Builtins b = graph.getBuiltins();\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 st = StructuralResource2.getInstance(graph);\r
+ \r
+ final Resource component = graph.getPossibleObject(element, mr.ElementToComponent);\r
+ final Resource componentType = graph.getPossibleType(component, sr.Module);\r
+ final Resource configuration = graph.getPossibleObject(componentType, st.IsDefinedBy);\r
+ final Resource diagram = ComponentUtils.getPossibleCompositeDiagram(graph, configuration);\r
+ \r
+ if(diagram == null) return;\r
+ \r
+ final String rvi = currentRVI + "/" + graph.getPossibleRelatedValue(component, b.HasName, StringBindingDefault.INSTANCE);\r
+ if(rvi == null) return;\r
+\r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ // for (Triple<Resource, String, String> in : ins) {\r
+ try {\r
+ String editorId = EDITOR_ID;\r
+ System.out.println("Activating diagram: model=" + modelURI + " rvi='" + rvi + "'");\r
+ WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, diagram, modelURI, rvi));\r
+ } catch (PartInitException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ // }\r
+ }\r
+ });\r
+ \r
+ }\r
+ \r
+ }\r
+ });\r
+ \r
+ return null;\r
+ }\r
+ \r
+\r
+}\r
Resource tail = graph.getPossibleObject(r, sr.HasTail);\r
if(tail != null) {\r
Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
- if (name != null) {\r
- System.out.println("STOCK += " + name);\r
+ if (name != null) \r
builder.append(" + " + name);\r
- }\r
+ \r
}\r
}\r
}\r
import org.simantics.db.Session;\r
import org.simantics.db.common.request.ReadRequest;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.modeling.ModelingResources;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.manager.SysdynDataSet;\r
return;\r
if(selection instanceof IStructuredSelection) {\r
Set<Resource> ress = ISelectionUtils.filterSetSelection(selection, Resource.class);\r
+ Resource runtime = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_VARIABLE_RESOURCE, Resource.class);\r
// Object[] els = ((IStructuredSelection) selection).toArray();\r
// Resource[] resources = new Resource[els.length];\r
// for(int i=0;i<els.length;++i) {\r
// else\r
// return;\r
// }\r
- setSelection(ress.toArray(Resource.NONE));\r
+ setSelection(ress.toArray(Resource.NONE), runtime);\r
} \r
}\r
});\r
}\r
\r
Resource[] resources;\r
+ Resource runtime;\r
\r
- protected void setSelection(Resource[] resources) {\r
+ protected void setSelection(Resource[] resources, Resource runtime) {\r
this.resources = resources;\r
+ this.runtime = runtime;\r
updateView();\r
}\r
\r
public void updateView() {\r
+ \r
Session session = SimanticsUI.peekSession();\r
if (session == null)\r
return;\r
\r
final ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
for(Resource resource : resources) {\r
- Collection<SysdynDataSet> set = load(g, resource);\r
+ Collection<SysdynDataSet> set = load(g, resource, runtime);\r
if(set == null) return;\r
- datasets.addAll(load(g, resource));\r
+ datasets.addAll(load(g, resource, runtime));\r
}
\r
SwingUtilities.invokeLater(new Runnable() {\r
}\r
}\r
\r
- protected Collection<SysdynDataSet> load(ReadGraph g, Resource resource) throws DatabaseException {\r
+ protected Collection<SysdynDataSet> load(ReadGraph g, Resource resource, Resource runtime) throws DatabaseException {\r
Builtins b = g.getBuiltins();\r
SysdynResource sr = SysdynResource.getInstance(g);\r
\r
+ DiagramResource dr = DiagramResource.getInstance(g);\r
+ \r
+// String rvi = g.getPossibleRelatedValue(runtime, dr.HasRVI);\r
+// System.out.println("load results rvi='" + rvi + "'");\r
+ String prefix = "";\r
+ \r
ModelingResources mr = ModelingResources.getInstance(g);\r
Resource map = g.getPossibleObject(resource, mr.ElementToComponent);\r
if(map != null) resource = map;\r
\r
if(g.isInstanceOf(resource, sr.Variable)) {\r
Resource module = g.getPossibleObject(resource, b.PartOf);\r
- while(!g.isInstanceOf(module, sr.Configuration)) {\r
- module = g.getPossibleObject(module, b.PartOf);\r
- }\r
+// while(!g.isInstanceOf(module, sr.Configuration)) {\r
+// module = g.getPossibleObject(module, b.PartOf);\r
+// }\r
if(g.isInstanceOf(module, sr.Configuration)) {\r
SysdynModel model = getModel(g, module);\r
if(model == null)\r
Collection<SysdynResult> activeResults = model.getActiveResults(g);\r
ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
for(SysdynResult r : activeResults) {\r
- SysdynDataSet sdds = r.getDataSet(var.getName());\r
+ SysdynDataSet sdds = r.getDataSet(prefix + var.getName());\r
if(sdds != null) datasets.add(sdds);\r
}\r
return datasets;\r
}\r
\r
public SysdynResult(String result, String path) {\r
+ System.out.println("sysdynresult " + result + " " + path);\r
this.resultName = result;\r
File file = new File(path);\r
try {\r
[L0.HasLabel card "1"]\r
\r
ModuleSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
- defSymbol("Stock", Module)\r
+ defSymbol("ModuleSymbol", Module)\r
ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
_ : SysdynTerminal\r
terminal(ModuleSymbol, IsHeadOfTerminal)\r
#tag(IsInput)\r
\r
### Dependencies \r
- _ : Flow\r
+ Flow3 : Flow\r
HasHead Investment\r
HasTail DummyCloud2 \r
- _ : Flow\r
+ Flow4 : Flow\r
HasHead CapacityStock\r
HasTail Investment \r
- _ : Flow\r
+ Flow5 : Flow\r
HasHead Reductions\r
HasTail CapacityStock\r
- _ : Flow\r
+ Flow6 : Flow\r
HasHead DummyCloud3\r
HasTail Reductions \r
_ : Dependency\r
HasHead Investment\r
HasTail CapacityAdjustment \r
\r
+CapacityModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext\r
+ MOD.DiagramToComposite CapacityModuleConfiguration\r
+ DIA.HasLayer _ @ "Admin" : DIA.Layer\r
+ DIA.IsActive "true" : L0.Boolean\r
+ DIA.HasFocusableTag AdminIsFocusable\r
+ DIA.HasVisibleTag AdminIsVisible\r
+ #L0.HasTrigger _ : DiagramToCompositeMapping\r
+ %list_elements\r
+ DummyCloud2Element : CloudSymbol\r
+ MOD.ElementToComponent DummyCloud2\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 85.0, 90.0" : G2D.Transform\r
+ InvestmentElement : ValveSymbol\r
+ MOD.ElementToComponent Investment\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 90.0" : G2D.Transform\r
+ CapacityStockElement : StockSymbol\r
+ MOD.ElementToComponent CapacityStock\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 115.0, 90.0" : G2D.Transform\r
+ ReductionsElement : ValveSymbol\r
+ MOD.ElementToComponent Reductions\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 90.0" : G2D.Transform\r
+ DummyCloud3Element : CloudSymbol\r
+ MOD.ElementToComponent DummyCloud3\r
+ DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 145.0, 90.0" : G2D.Transform\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow3\r
+ flow(DummyCloud2Element, InvestmentElement)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow4\r
+ flow(InvestmentElement, CapacityStockElement)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow5\r
+ flow(CapacityStockElement, ReductionsElement)\r
+ _ : FlowConnection\r
+ MOD.DiagramConnectionToConnection Flow6\r
+ flow(ReductionsElement, DummyCloud3Element)\r
+\r
+\r
CustomerModule @ "Asiakasmoduuli" <T Module\r
ST.IsDefinedBy CustomerModuleConfiguration\r
\r