ACTIONS.NewFunction : ACT.Action\r
ACTIONS.NewFunctionLibrary : ACT.Action\r
ACTIONS.NewSharedFunctionLibrary : ACT.Action\r
+ACTIONS.OpenWorkbook : ACT.Action\r
\r
\r
-MAC \r
+MAC\r
@VP.actionContribution "Module" SBC.ModulesFolder MBC.Images.Composite VP.NewActionCategory ACTIONS.NewModuleType\r
+ VP.BrowseContext.HasActionContribution _ : VP.ActionContribution\r
+ L0.HasLabel "Open Workbook"\r
+ VP.ActionContribution.HasImage MBC.Images.Component\r
+ VP.ActionContribution.HasNodeType MBC.Configuration\r
+ VP.ActionContribution.HasAction ACTIONS.OpenWorkbook\r
+ \r
@VP.actionContribution "Enumeration" MBC.Configuration MBC.Images.Component VP.NewActionCategory ACTIONS.NewEnumeration\r
+ //@VP.actionContribution "Open Workbook" MBC.Configuration MBC.Images.Component VP.NewActionCategory ACTIONS.OpenWorkbook\r
@VP.actionContribution "Enumeration" SBC.ModuleSymbol MBC.Images.Component VP.NewActionCategory ACTIONS.NewEnumeration\r
@VP.actionContribution "Function" SBC.FunctionsFolder MBC.Images.Component VP.NewActionCategory ACTIONS.NewFunction\r
@VP.actionContribution "Function" SYSDYN.SysdynModelicaFunctionLibrary MBC.Images.Component VP.NewActionCategory ACTIONS.NewFunction\r
public final Resource ProjectActionContext_Actions_NewFunctionLibrary;\r
public final Resource ProjectActionContext_Actions_NewModuleType;\r
public final Resource ProjectActionContext_Actions_NewSharedFunctionLibrary;\r
+ public final Resource ProjectActionContext_Actions_OpenWorkbook;\r
public final Resource ProjectBrowseContext;\r
public final Resource ProjectBrowseContext_BuiltinFunctions;\r
public final Resource ProjectBrowseContext_FunctionsFolder;\r
public static final String ProjectActionContext_Actions_NewFunctionLibrary = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunctionLibrary";\r
public static final String ProjectActionContext_Actions_NewModuleType = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewModuleType";\r
public static final String ProjectActionContext_Actions_NewSharedFunctionLibrary = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewSharedFunctionLibrary";\r
+ public static final String ProjectActionContext_Actions_OpenWorkbook = "http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/OpenWorkbook";\r
public static final String ProjectBrowseContext = "http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext";\r
public static final String ProjectBrowseContext_BuiltinFunctions = "http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/BuiltinFunctions";\r
public static final String ProjectBrowseContext_FunctionsFolder = "http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/FunctionsFolder";\r
ProjectActionContext_Actions_NewFunctionLibrary = getResourceOrNull(graph, URIs.ProjectActionContext_Actions_NewFunctionLibrary);\r
ProjectActionContext_Actions_NewModuleType = getResourceOrNull(graph, URIs.ProjectActionContext_Actions_NewModuleType);\r
ProjectActionContext_Actions_NewSharedFunctionLibrary = getResourceOrNull(graph, URIs.ProjectActionContext_Actions_NewSharedFunctionLibrary);\r
+ ProjectActionContext_Actions_OpenWorkbook = getResourceOrNull(graph, URIs.ProjectActionContext_Actions_OpenWorkbook);\r
ProjectBrowseContext = getResourceOrNull(graph, URIs.ProjectBrowseContext);\r
ProjectBrowseContext_BuiltinFunctions = getResourceOrNull(graph, URIs.ProjectBrowseContext_BuiltinFunctions);\r
ProjectBrowseContext_FunctionsFolder = getResourceOrNull(graph, URIs.ProjectBrowseContext_FunctionsFolder);\r
org.simantics.graph;bundle-version="1.0.2",
org.simantics.graph.db;bundle-version="1.0.0",
org.simantics.structural.ui;bundle-version="1.1.1",
- org.simantics.browsing.ui.model;bundle-version="1.0.0"
+ org.simantics.browsing.ui.model;bundle-version="1.0.0",
+ org.simantics.spreadsheet.ui;bundle-version="1.1.0"
Bundle-Activator: org.simantics.sysdyn.ui.Activator
Bundle-ActivationPolicy: lazy
Export-Package: org.simantics.sysdyn.ui.browser.nodes
VTT Technical Research Centre of Finland - initial API and implementation\r
-->\r
-<adapters>\r\r <target interface="org.simantics.db.layer0.adapter.Realization">\r <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r class="org.simantics.structural2.realization.StructuralRealization">\r <this />\r </type>\r </target>\r\r<!-- \r <target interface="org.simantics.db.layer0.variable.Variable">\r <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r <this />\r </type>\r <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r <this />\r </type>\r </target>\r -->\r\r <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r <graph/>\r <this />\r </type>\r </target>\r \r <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r <this />\r </type>\r </target> \r \r\r <target\r interface="org.simantics.browsing.ui.common.node.AbstractNode">\r <type\r uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r <this />\r </type>\r\r <resource\r uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r <this />\r </resource>\r\r <type\r uri="http://www.simantics.org/Simulation-1.0/Experiment"\r class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/Result"\r class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r <this />\r </type>\r \r </target>\r\r <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r <target interface="org.simantics.g2d.diagram.DiagramClass">\r <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r </target>\r\r <!-- Sysdyn symbols -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" /> \r </target>\r \r <!-- Sysdyn connections -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <!-- Edges -->\r <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r <!-- : SYSDYN.Connection-->\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r </target>\r \r <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>none 0</string>\r </resource>\r <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>fill 1</string>\r </resource>\r </target>\r \r <!-- ModelBrowser2 -->\r \r <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeChildRule"\r class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleContentChildRule"\r class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/> \r </target>\r \r <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeLabelRule"\r class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r </target> \r \r <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewModuleType"\r class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewEnumeration"\r class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunction"\r class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunctionLibrary"\r class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" /> \r </target> \r \r \r
+<adapters>\r\r <target interface="org.simantics.db.layer0.adapter.Realization">\r <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r class="org.simantics.structural2.realization.StructuralRealization">\r <this />\r </type>\r </target>\r\r<!-- \r <target interface="org.simantics.db.layer0.variable.Variable">\r <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r <this />\r </type>\r <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r <this />\r </type>\r </target>\r -->\r\r <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r <graph/>\r <this />\r </type>\r </target>\r \r <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r <this />\r </type>\r </target> \r \r\r <target\r interface="org.simantics.browsing.ui.common.node.AbstractNode">\r <type\r uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r <this />\r </type>\r\r <resource\r uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r <this />\r </resource>\r\r <type\r uri="http://www.simantics.org/Simulation-1.0/Experiment"\r class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/Result"\r class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r <this />\r </type>\r \r </target>\r\r <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r <target interface="org.simantics.g2d.diagram.DiagramClass">\r <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r </target>\r\r <!-- Sysdyn symbols -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" /> \r </target>\r \r <!-- Sysdyn connections -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <!-- Edges -->\r <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r <!-- : SYSDYN.Connection-->\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r </target>\r \r <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>none 0</string>\r </resource>\r <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>fill 1</string>\r </resource>\r </target>\r \r <!-- ModelBrowser2 -->\r \r <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeChildRule"\r class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleContentChildRule"\r class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/> \r </target>\r \r <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeLabelRule"\r class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r </target> \r \r <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewModuleType"\r class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewEnumeration"\r class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/OpenWorkbook"\r class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunction"\r class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewFunctionLibrary"\r class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" /> \r </target> \r \r \r
</adapters>
\ No newline at end of file
--- /dev/null
+package org.simantics.sysdyn.ui.browser.actions;\r
+\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.ActionFactory;\r
+import org.simantics.db.layer0.util.Simantics;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ui.diagramEditor.OpenSheetAdapter;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+public class OpenWorkbookAction implements ActionFactory{\r
+\r
+ @Override\r
+ public Runnable create(Object target) {\r
+ \r
+ if(!(target instanceof Resource))\r
+ return null;\r
+ \r
+ final Resource resource = (Resource)target;\r
+ \r
+ return new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ \r
+ try {\r
+ \r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);\r
+ \r
+ Resource book = graph.syncRequest(new PossibleObjectWithType(resource, L0.ConsistsOf, sr.Book));\r
+ final Resource sheet = graph.syncRequest(new PossibleObjectWithType(book, L0.ConsistsOf, sr.Spreadsheet));\r
+ \r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ Variable variable = graph.adapt(sheet, Variable.class);\r
+ Resource model = Variables.getModel(graph, variable);\r
+ final String modelURI = graph.getURI(model);\r
+ final String RVI = Variables.getRVI(graph, variable);\r
+\r
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+ \r
+ private static final String EDITOR_ID = "org.simantics.spreadsheet.ui.editor2";\r
+ \r
+ @Override\r
+ public void run() {\r
+ try {\r
+ System.out.println("Activating sheet: model=" + modelURI + " rvi=" + RVI);\r
+ WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, sheet, modelURI, RVI));\r
+ } catch (PartInitException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ });\r
+ }\r
+ });\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+ \r
+ };\r
+ \r
+ }\r
+\r
+}\r
\r
import java.io.File;\r
import java.util.HashMap;\r
+import java.util.UUID;\r
\r
import org.eclipse.core.runtime.Platform;\r
import org.eclipse.core.runtime.preferences.IEclipsePreferences;\r
import org.simantics.simulation.experiment.IExperiment;\r
import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.sysdyn.ui.editor.SysdynEditorNamingService;\r
}\r
\r
private final WriteRunnable CREATE_MODEL = new WriteRunnable() {\r
+ \r
+ Resource createSheet(WriteGraph graph, Resource book, String name, String[] colNames, int[] colWidths) throws DatabaseException {\r
+\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);\r
+\r
+ Resource result = graph.newResource();\r
+ graph.claim(result, L0.InstanceOf, null, sr.Spreadsheet);\r
+\r
+ if(name == null) {\r
+ name = NameUtils.findFreshEscapedName(graph, "Sheet", book, sr.HasSheet);\r
+ }\r
+ graph.claimLiteral(result, L0.HasName, L0.NameOf, L0.String, name, Bindings.STRING);\r
+ graph.claim(book, L0.ConsistsOf, L0.PartOf, result);\r
+\r
+ {\r
+ Resource newCell = graph.newResource();\r
+ graph.claim(newCell, L0.InstanceOf, null, sr.DimensionsCell);\r
+ graph.claimLiteral(newCell, L0.HasName, L0.NameOf, L0.String, "Dimensions", Bindings.STRING);\r
+ graph.addLiteral(newCell, sr.FitColumns, sr.FitColumnsOf, L0.Boolean, true, Bindings.BOOLEAN);\r
+ graph.addLiteral(newCell, sr.FitRows, sr.FitRowsOf, L0.Boolean, true, Bindings.BOOLEAN);\r
+ graph.claim(result, L0.ConsistsOf, L0.PartOf, newCell);\r
+ }\r
+\r
+ {\r
+ Resource newCell = graph.newResource();\r
+ graph.claimLiteral(newCell, L0.HasName, L0.NameOf, L0.String, "Headers", Bindings.STRING);\r
+ graph.claim(newCell, L0.InstanceOf, null, sr.HeadersCell);\r
+ graph.addLiteral(newCell, sr.ColumnLabels, sr.ColumnLabelsOf, L0.StringArray, colNames, Bindings.getBindingUnchecked(String[].class));\r
+ graph.addLiteral(newCell, sr.ColumnWidths, sr.ColumnWidthsOf, L0.IntegerArray, colWidths, Bindings.INT_ARRAY);\r
+ graph.claim(result, L0.ConsistsOf, L0.PartOf, newCell);\r
+ }\r
+\r
+ {\r
+ \r
+ double[] doubles = new double[10*10];\r
+ for(int i=0;i<10*10;i++) doubles[i] = i;\r
+ \r
+ Resource newCell = graph.newResource();\r
+ graph.claim(newCell, L0.InstanceOf, null, sr.DoubleArrayCell);\r
+ graph.addLiteral(newCell, sr.DoubleArrayCell_HasWidth, sr.DoubleArrayCell_HasWidth_Inverse, L0.Integer, 10, Bindings.INTEGER);\r
+ graph.addLiteral(newCell, sr.HasLocation, sr.HasLocation_Inverse, L0.String, "A1", Bindings.STRING);\r
+ graph.addLiteral(newCell, sr.DoubleArrayCell_HasDoubleArray, sr.DoubleArrayCell_HasDoubleArray_Inverse, L0.DoubleArray, doubles, Bindings.DOUBLE_ARRAY);\r
+ graph.claim(result, L0.HasChildVariables, L0.HasChildVariables_Inverse, newCell);\r
+ \r
+ }\r
+ \r
+ return result;\r
+\r
+ }\r
+ \r
@Override\r
public void run(WriteGraph g, Resource library, Callback<Resource> callback, Callback<Throwable> errorCallback) {\r
try {\r
Layer0 l0 = Layer0.getInstance(g);\r
SysdynResource sr = SysdynResource.getInstance(g);\r
+ SpreadsheetResource SHEET = SpreadsheetResource.getInstance(g);\r
ModelingUtils mu = new ModelingUtils(g);\r
\r
String modelName = NameUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), l0.ConsistsOf, "%s%d");\r
\r
g.claim(model, mu.SIMU.HasConfiguration, conf);\r
\r
+ Resource book = g.newResource();\r
+ g.claim(book, l0.InstanceOf, null, SHEET.Book);\r
+ g.addLiteral(book, l0.HasName, l0.NameOf, l0.String, "Book" + UUID.randomUUID().toString(), Bindings.STRING);\r
+ g.claim(conf, l0.ConsistsOf, l0.PartOf, book);\r
+ \r
+ createSheet(g, book, "Sheet1", new String[] { "ARG" }, new int[] { 50 });\r
+ \r
+ \r
+ \r
ModelingResources mr = ModelingResources.getInstance(g);\r
// Remove default mapping and add sysdyn mapping\r
for(Resource trigger : g.getObjects(diagram, l0.HasTrigger)) {\r
super(resource);\r
}\r
\r
- @Override\r
- public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
- Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(resource));\r
- Resource child = children.get(name);\r
- if(child == null) {\r
- return getPossibleSpecialChild(graph, name);\r
- }\r
- else return graph.adaptContextual(child, this, Variable.class, Variable.class);\r
- }\r
+// @Override\r
+// public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
+// Map<String, Resource> children = graph.syncRequest(new UnescapedChildMapOfResource(resource));\r
+// Resource child = children.get(name);\r
+// if(child == null) {\r
+// return getPossibleSpecialChild(graph, name);\r
+// }\r
+// else return graph.adaptContextual(child, this, Variable.class, Variable.class);\r
+// }\r
\r
\r
@Override\r