]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Switch to new Model Browser apros-i4-rc3
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 17 May 2010 13:57:01 +0000 (13:57 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 17 May 2010 13:57:01 +0000 (13:57 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15751 ac1ea38d-2e2b-0410-8846-a27921b304fc

32 files changed:
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiment.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiments.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Model.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModulesLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/OperatingInterfaces.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/OperatingInterfacesLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Variable.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ConfigurationNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentsFolder.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModulesNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/OperatingInterfacesFolder.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java
sysdyn_ontologies/sysdyn.graph

index e92213e6cebb36c99ca1da03093ed3174dd8be2a..fda0571f19321cc846fd43a2b0b875d4c17b2900 100644 (file)
@@ -16,7 +16,7 @@
                <resource\r
                        uri="http://www.simantics.org/Sysdyn-1.0/SysdynProject"\r
                        class="org.simantics.sysdyn.ui.project.SysdynProject" />\r
-       </target>\r
+       </target>\r      \r
        <target\r
                interface="org.simantics.scenegraph.adapters.ISceneGraphProvider">\r
                <type\r
@@ -25,5 +25,5 @@
                        <graph />\r
                        <this />\r
                </type>\r
-       </target>\r
+       </target>\r      \r       <target\r                interface="org.simantics.sysdyn.ui.browser.nodes.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               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Variable"\r                     class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r                    <this />\r               </type>\r        </target>\r      \r
 </adapters>
\ No newline at end of file
index 366f6029a02e8b4096ffc25ef81e30a80c8085e0..39699954ddadd63931ea701b31f29529c01e3528 100644 (file)
             <visibleWhen checkEnabled="true">\r
             </visibleWhen>\r
          </command>\r
+         <menu\r
+               label="New">\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newModel"\r
+                  id="org.simantics.sysdyn.ui.browser.newModel"\r
+                  label="Model"\r
+                  style="push">\r
+            </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newModuleNode"\r
+                  id="org.simantics.sysdyn.ui.browser.newModule"\r
+                  label="Module"\r
+                  style="push">\r
+            </command>\r
+         </menu>\r
       </menuContribution>\r
       <menuContribution\r
             locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
                id="org.simantics.sysdyn.ui.simulate.state">\r
          </state>\r
       </command>\r
+      <command\r
+            id="org.simantics.sysdyn.ui.newModuleNode"\r
+            name="New Module">\r
+      </command>\r
+      <command\r
+            id="org.simantics.sysdyn.ui.newModel"\r
+            name="New Model">\r
+      </command>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.handlers">\r
             </with>\r
          </activeWhen>\r
       </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.handlers.NewModuleNodeHandler"\r
+            commandId="org.simantics.sysdyn.ui.newModuleNode">\r
+      </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.handlers.NewModelHandler"\r
+            commandId="org.simantics.sysdyn.ui.newModel">\r
+      </handler>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.cheatsheets.cheatSheetContent">\r
             Simple System Dynamics Tutorials\r
          </description>\r
       </cheatsheet>\r
+   </extension>\r
+   <extension\r
+         point="org.simantics.browsing.ui.common.viewpointContributionBinding">\r
+      <binding\r
+            browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Variable"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Experiments"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Model"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.OperatingInterfaces"\r
+               preference="1.0">\r
+         </implementation>\r
+      </binding>\r
+   </extension>\r
+   <extension\r
+         point="org.simantics.browsing.ui.common.labelerBinding">\r
+      <binding\r
+            browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ConfigurationLabeler"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.VariableLabeler"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ExperimentsLabeler"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ModelLabeler"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ModulesLabeler"\r
+               preference="1.0">\r
+         </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.OperatingInterfacesLabeler"\r
+               preference="1.0">\r
+         </implementation>\r
+      </binding>\r
    </extension>
 </plugin>\r
index 96be2b87c84504b8c4ec872399a5006d4bceb9b1..aa546cde92c92888163b0645a616ff66e05123cb 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.browser;\r
 \r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
 import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
-import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.common.EvaluatorData;\r
-import org.simantics.browsing.ui.common.EvaluatorDataImpl;\r
-import org.simantics.browsing.ui.common.EvaluatorImpl;\r
-import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.content.Labeler;\r
-import org.simantics.browsing.ui.content.LabelerFactory;\r
-import org.simantics.browsing.ui.graph.impl.GraphViewpointFactory;\r
-import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
-import org.simantics.browsing.ui.graph.impl.LazyGraphLabeler;\r
+import java.util.Set;\r
 import org.simantics.browsing.ui.swt.ContextMenuInitializer;\r
 import org.simantics.browsing.ui.swt.GraphExplorerView;\r
 import org.simantics.browsing.ui.swt.IContextMenuInitializer;\r
-import org.simantics.db.Builtins;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.datastructures.hints.HintContext;\r
 \r
 \r
 public class SysdynBrowser extends GraphExplorerView {\r
-\r
+    \r
+    private static final Set<String> browseContexts  = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser");\r
+    \r
     @Override\r
     protected IContextMenuInitializer getContextMenuInitializer() {\r
         return new ContextMenuInitializer("#SysdynBrowserPopup");\r
     }\r
-\r
+    \r
     @Override\r
-    protected EvaluatorData createEvaluatorData(Session session) {\r
-        HintContext factoryHints = new HintContext();\r
-        //if (sessionContext != null)\r
-        //factoryHints.setHint(IGraphExplorerHints.KEY_SESSION_CONTEXT, sessionContext);\r
-\r
-        EvaluatorData data = new EvaluatorDataImpl();\r
-        data.addEvaluator(Resource.class, createResourceEvaluator(session, factoryHints));\r
-        return data;\r
+    protected Set<String> getBrowseContexts() {\r
+        return browseContexts;\r
     }\r
-\r
-    private Evaluator createResourceEvaluator(Session session, HintContext factoryHints) {\r
-        Evaluator evaluator = new EvaluatorImpl();\r
-        evaluator.addViewpoint(new GraphViewpointFactory() {\r
-            @Override\r
-            protected Collection<?> getChildren(ReadGraph g, Resource r)\r
-            throws DatabaseException {\r
-                Builtins b = g.getBuiltins();\r
-                SysdynResource sr = SysdynResource.getInstance(g);\r
-                ArrayList<Resource> result = new ArrayList<Resource>();\r
-                for(Resource c : g.getObjects(r, b.ConsistsOf)) {\r
-                    if(  g.isInstanceOf(c, sr.Configuration)\r
-                            || (g.isInstanceOf(c, sr.Variable) &&\r
-                                    !g.isInstanceOf(c, sr.Cloud)\r
-                            )\r
-                    )\r
-                        result.add(c);\r
-                }\r
-                return result;\r
-            }\r
-        }, 1.0);\r
-        evaluator.addLabeler(new LabelerFactory() {\r
-            @Override\r
-            public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) {\r
-                return new LazyGraphLabeler(updater, context, key) {\r
-\r
-                    Resource nameResource;\r
-\r
-                    @Override\r
-                    public Map<String, String> labels(ReadGraph g)\r
-                    throws DatabaseException {\r
-                        Builtins b = g.getBuiltins();\r
-                        nameResource = b.HasName;\r
-                        Resource el = (Resource) context.getConstant(BuiltinKeys.INPUT);\r
-                        StringBuilder sb = new StringBuilder();\r
-                        for(Resource r : g.getObjects(el, b.HasName))\r
-                            sb.append(g.getValue(r));\r
-                        sb.append(" : ");\r
-                        for(Resource t : g.getObjects(el, b.InstanceOf))\r
-                            for(Resource r : g.getObjects(t, b.HasName))\r
-                                sb.append(g.getValue(r));\r
-                        return Collections.singletonMap(ColumnKeys.SINGLE, sb.toString());\r
-                    }\r
-\r
-                    @Override\r
-                    public Modifier getModifier(String key) {\r
-                        LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), (Resource) context.getConstant(BuiltinKeys.INPUT), nameResource) {\r
-                            @Override\r
-                            public String isValid(String label) {\r
-                                if (label.isEmpty())\r
-                                    return "Empty label not allowed";\r
-                                if (label.contains(" "))\r
-                                    return "Spaces are not allowed";\r
-                                return null;\r
-                            }\r
-                        };\r
-                        return modifier;\r
-                    }\r
-                };\r
-            }\r
-\r
-        }, 1.0);\r
-        /*evaluator.addImager(new ImagerFactory() {\r
-            @Override\r
-            public Imager create(PrimitiveQueryUpdater updater, INodeContext context) {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-        });*/\r
-        return evaluator;\r
-    }\r
-\r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java
new file mode 100644 (file)
index 0000000..f055782
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.ui.icons.ImageDescriptorProvider;\r
+\r
+public class AbstractNodeImager extends ImagerContributor<AbstractNode> {\r
+\r
+    @Override\r
+    public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode node) throws DatabaseException {\r
+        if (!graph.hasStatement(node.resource))\r
+            return null;\r
+        ImageDescriptorProvider provider = graph.adapt(node.resource, ImageDescriptorProvider.class);\r
+        return provider != null ? provider.get() : null;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeLabeler.java
new file mode 100644 (file)
index 0000000..813365c
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+\r
+public class AbstractNodeLabeler extends LabelerContributor<AbstractNode> {\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, AbstractNode node) throws DatabaseException {\r
+        if (!graph.hasStatement(node.resource))\r
+            return "";\r
+        return graph.adapt(node.resource, String.class);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java
new file mode 100644 (file)
index 0000000..171280e
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class Configuration extends ViewpointContributor<ModelNode> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, ModelNode model)\r
+    throws DatabaseException {\r
+        return new DataContainer<AbstractNode>(new ConfigurationNode(\r
+                graph.getSingleObject(\r
+                        model.resource, \r
+                        graph.getBuiltins().HasConfiguration))\r
+        );\r
+\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationLabeler.java
new file mode 100644 (file)
index 0000000..56f4e97
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class ConfigurationLabeler extends LabelerContributor<ConfigurationNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, ConfigurationNode conf) throws DatabaseException {\r
+        String name = graph.getPossibleRelatedValue(conf.resource, graph.getBuiltins().HasName);\r
+        return name == null ? "Project (no name)" : name;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiment.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiment.java
new file mode 100644 (file)
index 0000000..d80b031
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+\r
+public class Experiment extends ViewpointContributor<ExperimentsFolder> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, ExperimentsFolder input) throws DatabaseException {\r
+        // hasExperiment or something\r
+        return null;\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentLabeler.java
new file mode 100644 (file)
index 0000000..f78e77e
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************\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
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+\r
+public class ExperimentLabeler extends LabelerContributor<ExperimentNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, ExperimentNode input) throws DatabaseException {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiments.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiments.java
new file mode 100644 (file)
index 0000000..1efed43
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************\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
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class Experiments extends ViewpointContributor<ModelNode> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+        return new DataContainer<AbstractNode>(new ExperimentsFolder(model.resource));\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsLabeler.java
new file mode 100644 (file)
index 0000000..f301ce2
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************\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
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+\r
+public class ExperimentsLabeler extends LabelerContributor<ExperimentsFolder> {\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, ExperimentsFolder experiments) throws DatabaseException {\r
+        return "Experiments";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java
new file mode 100644 (file)
index 0000000..50ab222
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ *\r
+ * @param <T> input library node type\r
+ */\r
+public abstract class LibraryViewpointContributor<T extends AbstractNode> extends ViewpointContributor<T> {\r
+\r
+    protected abstract Read<Collection<Resource>> getChildRequest(ReadGraph graph, T lib) throws DatabaseException;\r
+\r
+    @Override\r
+    public final Collection<?> getContribution(ReadGraph graph, T lib) throws DatabaseException {\r
+        ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+        for (Resource r : graph.syncRequest(getChildRequest(graph, lib))) {\r
+            try {\r
+                AbstractNode n = graph.adapt(r, AbstractNode.class);\r
+                result.add(n);\r
+            } catch (DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Model.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Model.java
new file mode 100644 (file)
index 0000000..9f5c18b
--- /dev/null
@@ -0,0 +1,42 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class Model extends ViewpointContributor<Resource> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, Resource project)\r
+    throws DatabaseException {\r
+\r
+        ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+        Builtins b = graph.getBuiltins();\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        for(Resource r : graph.syncRequest(new ObjectsWithType(project, b.ConsistsOf, sr.SysdynModel))) {\r
+            try {\r
+                result.add(graph.adapt(r, AbstractNode.class));\r
+            } catch(DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        result.add(new ModulesNode(project));\r
+        return result;\r
+\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+    \r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java
new file mode 100644 (file)
index 0000000..64dc485
--- /dev/null
@@ -0,0 +1,15 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+\r
+public class ModelLabeler extends LabelerContributor<ModelNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+        String name = graph.getPossibleRelatedValue(model.resource, graph.getBuiltins().HasName);\r
+        return name == null ? "Model (no name)" : name;\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModulesLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModulesLabeler.java
new file mode 100644 (file)
index 0000000..9bc154c
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************\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
+\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
+\r
+public class ModulesLabeler extends LabelerContributor<ModulesNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, ModulesNode input) throws DatabaseException {\r
+        return "Modules";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/OperatingInterfaces.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/OperatingInterfaces.java
new file mode 100644 (file)
index 0000000..a0394ae
--- /dev/null
@@ -0,0 +1,25 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class OperatingInterfaces extends ViewpointContributor<ModelNode> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, ModelNode model) throws DatabaseException {\r
+        return new DataContainer<AbstractNode>(new OperatingInterfacesFolder(model.resource));\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/OperatingInterfacesLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/OperatingInterfacesLabeler.java
new file mode 100644 (file)
index 0000000..13cc2d3
--- /dev/null
@@ -0,0 +1,15 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder;\r
+\r
+public class OperatingInterfacesLabeler extends LabelerContributor<OperatingInterfacesFolder> {\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, OperatingInterfacesFolder input) throws DatabaseException {\r
+        return "Operating interfaces";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Variable.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Variable.java
new file mode 100644 (file)
index 0000000..333f1c2
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class Variable  extends ViewpointContributor<ConfigurationNode> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
+        ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+        Builtins b = graph.getBuiltins();\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
+            try {\r
+                result.add(graph.adapt(r, AbstractNode.class));\r
+            } catch(DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableLabeler.java
new file mode 100644 (file)
index 0000000..14b675a
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************\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.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class VariableLabeler  extends LabelerContributor<VariableNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, VariableNode var) throws DatabaseException {\r
+        Builtins b = graph.getBuiltins();\r
+        Resource varres = var.resource;\r
+        StringBuilder sb = new StringBuilder();\r
+        for(Resource r : graph.getObjects(varres, b.HasName))\r
+            sb.append(graph.getValue(r));\r
+        sb.append(" : ");\r
+        for(Resource t : graph.getObjects(varres, b.InstanceOf))\r
+            for(Resource r : graph.getObjects(t, b.HasName))\r
+                sb.append(graph.getValue(r));\r
+        return sb.toString();\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractNode.java
new file mode 100644 (file)
index 0000000..bf56020
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************\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.browser.nodes;\r
+\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.simantics.db.Resource;\r
+\r
+public abstract class AbstractNode implements IAdaptable {\r
+    public final Resource resource;\r
+\r
+    public AbstractNode(Resource resource) {\r
+        assert(resource != null);\r
+        this.resource = resource;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        return resource.hashCode() + getClass().hashCode();\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (obj == null)\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        AbstractNode other = (AbstractNode) obj;\r
+        return resource.equals(other.resource);\r
+    }\r
+\r
+    @SuppressWarnings("unchecked")\r
+    @Override\r
+    public Object getAdapter(Class adapter) {\r
+        if(adapter.equals(Resource.class))\r
+            return resource;\r
+        return null;\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ConfigurationNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ConfigurationNode.java
new file mode 100644 (file)
index 0000000..1bde861
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************\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.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ConfigurationNode  extends AbstractNode implements IDeletable, IModifiableNode {\r
+\r
+    public ConfigurationNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+    \r
+    @Override\r
+    public Modifier getModifier(String columnId) {\r
+        LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), resource) {\r
+            @Override\r
+            public String isValid(String label) {\r
+                if (label.isEmpty())\r
+                    return "Empty label not allowed";\r
+                if (label.contains(" "))\r
+                    return "Spaces are not allowed";\r
+                return null;\r
+            }\r
+        };\r
+        return modifier;\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentNode.java
new file mode 100644 (file)
index 0000000..adea16c
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************\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.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class ExperimentNode extends AbstractNode {\r
+\r
+    public ExperimentNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentsFolder.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentsFolder.java
new file mode 100644 (file)
index 0000000..b68b539
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************\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.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class ExperimentsFolder extends AbstractNode {\r
+\r
+    public ExperimentsFolder(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java
new file mode 100644 (file)
index 0000000..b79582c
--- /dev/null
@@ -0,0 +1,31 @@
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ModelNode extends AbstractNode implements IDeletable, IModifiableNode {\r
+\r
+    public ModelNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+    @Override\r
+    public Modifier getModifier(String columnId) {\r
+        LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), resource) {\r
+            @Override\r
+            public String isValid(String label) {\r
+                if (label.isEmpty())\r
+                    return "Empty label not allowed";\r
+                if (label.contains(" "))\r
+                    return "Spaces are not allowed";\r
+                return null;\r
+            }\r
+        };\r
+        return modifier;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModulesNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModulesNode.java
new file mode 100644 (file)
index 0000000..1536a4c
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************\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.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class ModulesNode extends AbstractNode {\r
+    \r
+    public ModulesNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/OperatingInterfacesFolder.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/OperatingInterfacesFolder.java
new file mode 100644 (file)
index 0000000..94ecb3f
--- /dev/null
@@ -0,0 +1,11 @@
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class OperatingInterfacesFolder extends AbstractNode {\r
+\r
+    public OperatingInterfacesFolder(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java
new file mode 100644 (file)
index 0000000..1480bb6
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************\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.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class VariableNode extends AbstractNode {\r
+\r
+    public VariableNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java
new file mode 100644 (file)
index 0000000..232e673
--- /dev/null
@@ -0,0 +1,43 @@
+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.simantics.db.Builtins;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class NewModelHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+            \r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+                // Same as in SysdynProject.java. Should use the same code, not copy.\r
+                Builtins b = graph.getBuiltins();\r
+                SysdynResource sr = SysdynResource.getInstance(graph);\r
+                Resource model = graph.newResource();\r
+                graph.claimValue(model, b.HasName, "Model1");\r
+                graph.claim(model, b.InstanceOf, sr.SysdynModel);\r
+                graph.claim(model, b.PartOf, SimanticsUI.getProject().get());\r
+                \r
+                Resource conf = graph.newResource();\r
+                graph.claimValue(conf, b.HasName, "Configuration");\r
+                graph.claim(conf, b.InstanceOf, sr.Configuration);\r
+                graph.claim(model, b.HasConfiguration, conf);\r
+                graph.claimValue(conf, sr.HasStartTime, 0.0);\r
+                graph.claimValue(conf, sr.HasStopTime, 10.0);\r
+            }\r
+        });\r
+        return null;\r
+    }\r
+\r
+\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java
new file mode 100644 (file)
index 0000000..54d75f8
--- /dev/null
@@ -0,0 +1,16 @@
+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
+\r
+public class NewModuleNodeHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        System.out.println("New module!");\r
+        return null;\r
+    }\r
+\r
+\r
+}\r
index 073dffdf5c20ae1ea27440b346c008405128a9e0..59fa382df9a15216da0d03aad5be96a5870a7151 100644 (file)
@@ -72,11 +72,16 @@ public class SysdynProject extends AbstractProjectFeature {
                 Builtins b = g.getBuiltins();\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
                 Resource model = g.newResource();\r
-                g.claimValue(model, b.HasName, "Configuration");\r
-                g.claim(model, b.InstanceOf, null, sr.Configuration);\r
+                g.claimValue(model, b.HasName, "Model1");\r
+                g.claim(model, b.InstanceOf, sr.SysdynModel);\r
                 g.claim(model, b.PartOf, library);\r
-                g.claimValue(model, sr.HasStartTime, 0.0);\r
-                g.claimValue(model, sr.HasStopTime, 10.0);\r
+                \r
+                Resource conf = g.newResource();\r
+                g.claimValue(conf, b.HasName, "Configuration");\r
+                g.claim(conf, b.InstanceOf, sr.Configuration);\r
+                g.claim(model, b.HasConfiguration, conf);\r
+                g.claimValue(conf, sr.HasStartTime, 0.0);\r
+                g.claimValue(conf, sr.HasStopTime, 10.0);\r
 \r
             } catch(Exception e) {\r
                 errorCallback.run(e);\r
index f108d491be253de6303dbe804c04cceeffd6830a..87165c9e0178f2cdf31889334c363b6523d9f591 100644 (file)
@@ -52,6 +52,7 @@ public class SysdynResource {
     public final Resource RefersTo;\r
     public final Resource Stock;\r
     public final Resource StockExpression;\r
+    public final Resource SysdynModel;\r
     public final Resource SysdynProject;\r
     public final Resource Terminal;\r
     public final Resource Valve;\r
@@ -91,6 +92,7 @@ public class SysdynResource {
         public static final String RefersTo = "http://www.simantics.org/Sysdyn-1.0/RefersTo";\r
         public static final String Stock = "http://www.simantics.org/Sysdyn-1.0/Stock";\r
         public static final String StockExpression = "http://www.simantics.org/Sysdyn-1.0/StockExpression";\r
+        public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.0/SysdynModel";\r
         public static final String SysdynProject = "http://www.simantics.org/Sysdyn-1.0/SysdynProject";\r
         public static final String Terminal = "http://www.simantics.org/Sysdyn-1.0/Terminal";\r
         public static final String Valve = "http://www.simantics.org/Sysdyn-1.0/Valve";\r
@@ -140,6 +142,7 @@ public class SysdynResource {
         RefersTo = getResourceOrNull(graph, URIs.RefersTo);\r
         Stock = getResourceOrNull(graph, URIs.Stock);\r
         StockExpression = getResourceOrNull(graph, URIs.StockExpression);\r
+        SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
         SysdynProject = getResourceOrNull(graph, URIs.SysdynProject);\r
         Terminal = getResourceOrNull(graph, URIs.Terminal);\r
         Valve = getResourceOrNull(graph, URIs.Valve);\r
index 42d4611f6bbd35535cf0427c8cc11907e4dd8b3e..a615777ec815049cc0624b69d0dd27d00307c2fa 100644 (file)
@@ -1,6 +1,7 @@
 %import "layer0.graph" L0\r
 %import "structural2.graph" ST\r
 %import "project.graph" PROJ\r
+%import "simulation.graph" SIMU\r
 \r
 %deflib L0.Type Sysdyn\r
 %deflib L0.Relation Sysdyn\r
@@ -20,10 +21,13 @@ SysdynProject : PROJ.Feature
     L0.HasDescription """System dynamics modelling project. Create system dynamics models and simulate them with OpenModelica.""" : L0.String\r
     L0.PartOf Sysdyn\r
     L0.PartOf PROJ.PublishedProjectFeatures\r
+    \r
+######################################################################\r
+# Model\r
+######################################################################    \r
 \r
-#SysdynTest : PROJ.Project2\r
-#    PROJ.HasFeature SysdynProject\r
-#    L0.PartOf L0.Projects\r
+SysdynModel <T SIMU.Model\r
+    [SIMU.HasConfiguration all Configuration]\r
 \r
 ######################################################################\r
 # Configuration\r
@@ -47,10 +51,11 @@ HasStopTime <R L0.HasProperty
 Variable <T ST.Component    \r
     [HasX card "1"]\r
     [HasY card "1"]\r
+    \r
 HasX <R L0.HasProperty : L0.FunctionalRelation\r
     L0.HasRange L0.Double\r
 HasY <R L0.HasProperty : L0.FunctionalRelation\r
-    L0.HasRange L0.Double        \r
+    L0.HasRange L0.Double\r
 HasExpression <R L0.IsRelatedTo : L0.FunctionalRelation\r
     L0.HasRange Expression\r
     \r
@@ -77,16 +82,12 @@ Cloud <T Variable
 Module <T Variable\r
     [HasTerminal]\r
     \r
-HasTerminal <R L0.IsRelatedTo\r
-    L0.HasRange [Terminal]\r
 Terminal <T Variable\r
     [RefersTo card "0..1"]\r
-RefersTo <R L0.IsRelatedTo\r
-    L0.HasDomain [Terminal]\r
-    L0.HasRange [IndependentVariable]\r
+\r
 \r
 ######################################################################\r
-# Connections\r
+# Connections and Relations\r
 ######################################################################\r
 \r
 HasAngle <R L0.HasProperty\r
@@ -107,6 +108,14 @@ Dependency <T ST.Connection
 Flow <T ST.Connection\r
     [HasHead card "1"]\r
     [HasTail card "1"]\r
+    \r
+RefersTo <R L0.IsRelatedTo\r
+    L0.HasDomain [Terminal]\r
+    L0.HasRange [IndependentVariable]\r
+    \r
+HasTerminal <R L0.IsRelatedTo\r
+    L0.HasRange [Terminal]\r
+    \r
 \r
 ######################################################################\r
 # Expression\r
@@ -143,13 +152,4 @@ LookupExpression <T Expression
     \r
 WithLookupExpression <T Expression\r
     [HasLookup card "1"]  \r
-    [HasEquation card "1"]    \r
-\r
-######################################################################\r
-# Test configuration\r
-######################################################################\r
-\r
-#TestConfiguration @ "TestConfiguration" : Configuration\r
-#    L0.PartOf SysdynTest\r
-#    HasStartTime "0.0" : L0.Double\r
-#    HasStopTime "10.0" : L0.Double\r
+    [HasEquation card "1"]    
\ No newline at end of file