]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Model browser's configuration is based on realization. Each variable know their path...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 07:53:30 +0000 (07:53 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 07:53:30 +0000 (07:53 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17492 ac1ea38d-2e2b-0410-8846-a27921b304fc

23 files changed:
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/BrowserSelection.java [new file with mode: 0644]
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
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Experiment.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Model.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Project.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResult.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ConfigurationNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/InputNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/VariableNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java

index 93d76d28e037d29033e3823c9d9bd4cfb61cc7db..ea0799dcd50da1a7f7f021f0344792c3097ef8f2 100644 (file)
@@ -16,5 +16,5 @@
                <resource\r
                        uri="http://www.simantics.org/Sysdyn-1.0/SysdynProject"\r
                        class="org.simantics.sysdyn.ui.project.SysdynProject" />\r
-               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/SysdynModelManager"\r                   class="org.simantics.sysdyn.ui.project.SysdynProject" />\r       </target>\r      \r       <target interface="org.simantics.project.IProjectLifecycle">\r           <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/SysdynProject"\r                        class="org.simantics.sysdyn.ui.project.SysdynProjectLifeCycle" />\r      </target>\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               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/IndependentVariable"\r                  class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r                    <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Input"\r                        class="org.simantics.sysdyn.ui.browser.nodes.InputNode">\r                       <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ModuleNode">\r                      <this />\r               </type>\r                \r               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode">\r                  <this />\r               </resource>\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
+               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/SysdynModelManager"\r                   class="org.simantics.sysdyn.ui.project.SysdynProject" />\r       </target>\r      \r       <target interface="org.simantics.project.IProjectLifecycle">\r           <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/SysdynProject"\r                        class="org.simantics.sysdyn.ui.project.SysdynProjectLifeCycle" />\r      </target>\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
 </adapters>
\ No newline at end of file
index 5992bf10d5f98c6728348bc8d2e36c6c970b33bc..544b4155a79f769255bedf1289f3635c6e394f57 100644 (file)
       <binding\r
             browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
          <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ModuleType"\r
                preference="1.0">\r
          </implementation>\r
          <implementation\r
                preference="2.0">\r
          </implementation>\r
          <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.Module"\r
-               preference="1.0">\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
+               preference="2.0">\r
          </implementation>\r
       </binding>\r
    </extension>\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/BrowserSelection.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/BrowserSelection.java
new file mode 100644 (file)
index 0000000..f30b800
--- /dev/null
@@ -0,0 +1,32 @@
+package org.simantics.sysdyn.ui.browser;\r
+\r
+import org.eclipse.core.runtime.IAdaptable;\r
+import org.simantics.db.Resource;\r
+\r
+public class BrowserSelection implements IAdaptable {\r
+       private Resource resource;\r
+       private Resource model;\r
+       private String URI;\r
+\r
+       public BrowserSelection(Resource resource, String URI, Resource model) {\r
+               this.resource = resource;\r
+               this.URI = URI;\r
+               this.model = model;\r
+       }\r
+\r
+       @Override\r
+       public Object getAdapter(Class adapter) {\r
+               if (adapter == Resource.class)\r
+                       return resource;\r
+               return null;\r
+       }\r
+       \r
+       public Resource getModel() {\r
+               return this.model;\r
+       }\r
+       \r
+       public String getURI() {\r
+               return this.URI;\r
+       }\r
+       \r
+}\r
index 181d0505e2449b06c4f35f01b60a00a66fa5e9fe..032328a8d027015102e16cf7dd23ee6e6096daf5 100644 (file)
@@ -17,12 +17,22 @@ import java.util.HashSet;
 import java.util.Set;\r
 \r
 import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.GraphExplorer;\r
+import org.simantics.browsing.ui.NodeContext;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
 import org.simantics.browsing.ui.swt.ContextMenuInitializer;\r
+import org.simantics.browsing.ui.swt.DefaultSelectionDataResolver;\r
+import org.simantics.browsing.ui.swt.GraphExplorerFactory;\r
 import org.simantics.browsing.ui.swt.GraphExplorerView;\r
 import org.simantics.browsing.ui.swt.IContextMenuInitializer;\r
 import org.simantics.browsing.ui.swt.IPropertyPage;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.layer0.SelectionHints;\r
 import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
 import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
+import org.simantics.utils.datastructures.BinaryFunction;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
 \r
 \r
 public class SysdynBrowser extends GraphExplorerView {\r
@@ -30,6 +40,37 @@ public class SysdynBrowser extends GraphExplorerView {
 //  private static final Set<String> browseContexts  = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/Browser");\r
     private static final Set<String> browseContexts  = new HashSet<String>(Arrays.asList("http://www.simantics.org/Sysdyn-1.0/Browser", "http://www.simantics.org/Operating-1.0/Browser"));    \r
 \r
+    private BinaryFunction<Object[], GraphExplorer, Object[]> selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {\r
+\r
+               @Override\r
+               public Object[] call(GraphExplorer explorer, Object[] objects) {\r
+               Object[] result = new Object[objects.length];\r
+               for (int i = 0; i < objects.length; i++) {\r
+                       \r
+                       NodeContext ctx = (NodeContext)objects[i];        \r
+                   @SuppressWarnings("unchecked")\r
+                               VariableNode<Resource> vn = (VariableNode<Resource>) ctx.getAdapter(VariableNode.class);\r
+                   IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+                   if(vn != null) {\r
+                       Resource resource = vn.getResource() == null ? vn.data : vn.getResource();\r
+                       context.setHint(SelectionHints.KEY_MAIN, new BrowserSelection(resource, vn.getURI(), vn.getModel()));\r
+                   } else {\r
+                       context.setHint(SelectionHints.KEY_MAIN, objects[i]);\r
+                   }\r
+                   result[i] = context;\r
+               }\r
+               return result;\r
+               }\r
+       \r
+    };\r
+    \r
+    protected GraphExplorer createExplorerControl(Composite parent) {\r
+        return GraphExplorerFactory.getInstance()\r
+        .selectionDataResolver(new DefaultSelectionDataResolver())\r
+        .selectionTransformation(selectionTransformation)\r
+        .create(parent, getStyle());\r
+    }\r
+    \r
     @Override\r
     protected IContextMenuInitializer getContextMenuInitializer() {\r
         return new ContextMenuInitializer("#SysdynBrowserPopup");\r
@@ -51,7 +92,6 @@ public class SysdynBrowser extends GraphExplorerView {
         //toolBar.add(new HomeAction());\r
     }\r
     \r
-    @SuppressWarnings("unchecked")\r
     @Override\r
     public Object getAdapter(Class adapter) {\r
         if (adapter == IPropertyPage.class)\r
index 650709b2b21e320556176179fe449cfdb677a1e1..ce9230e32fcddb3b63a94e747092f7907cbfea72 100644 (file)
@@ -26,7 +26,6 @@ import org.simantics.sysdyn.ui.browser.nodes.ModelNode;
 import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
-import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder;\r
 import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
 \r
 public class AbstractNodeImager extends ImagerContributor<AbstractNode<Resource>> {\r
@@ -36,7 +35,6 @@ public class AbstractNodeImager extends ImagerContributor<AbstractNode<Resource>
         \r
         String image = null;\r
         if (node instanceof ExperimentsFolder || \r
-//                node instanceof OperatingInterfacesFolder || \r
                 node instanceof ModulesNode)\r
             image = "icons/folder.png";\r
         else if (node instanceof ModuleTypeNode || node instanceof ModuleNode || node instanceof ConfigurationNode)\r
index 9f1c4dcf4c8b080a75af00d0f06fcd1b9af911e8..3016f8e842bff969c8e51fff2330cd5d466f5a9d 100644 (file)
@@ -8,44 +8,49 @@ import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributo
 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.ConfigurationNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
 \r
-public class Configuration extends ViewpointContributor<ConfigurationNode> {\r
+public class Configuration extends ViewpointContributor<ConfigurationNode<Resource>> {\r
 \r
-        @Override\r
-        public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
-            ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
-            Builtins b = graph.getBuiltins();\r
-            SysdynResource sr = SysdynResource.getInstance(graph);\r
-            for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.data, b.ConsistsOf, sr.IndependentVariable))) {\r
-                try {\r
-                    result.add(graph.adapt(r, AbstractNode.class));\r
-                } catch(DatabaseException e) {\r
-                    e.printStackTrace();\r
-                }\r
-            }\r
-            for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.data, b.ConsistsOf, sr.Input))) {\r
-                try {\r
-                    result.add(graph.adapt(r, AbstractNode.class));\r
-                } catch(DatabaseException e) {\r
-                    e.printStackTrace();\r
-                }\r
-            }\r
-            for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.data, b.ConsistsOf, sr.Module))) {\r
-                try {\r
-                    result.add(graph.adapt(r, AbstractNode.class));\r
-                } catch(DatabaseException e) {\r
-                    e.printStackTrace();\r
-                }\r
-            }\r
-            return result;\r
-        }\r
+       @Override\r
+       public Collection<?> getContribution(ReadGraph graph, ConfigurationNode<Resource> configuration) throws DatabaseException {\r
+               Builtins b = graph.getBuiltins();\r
+               ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+               if (!graph.isInheritedFrom(graph.getSingleObject(configuration.data, b.InstanceOf), b.Realization))\r
+                       return result;\r
+               \r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               ArrayList<Resource> variables = new ArrayList<Resource>();\r
+               ArrayList<Resource> inputs = new ArrayList<Resource>();\r
+               ArrayList<Resource> modules = new ArrayList<Resource>();\r
+               \r
+               for(Resource r : graph.getObjects(configuration.data, b.ConsistsOf)) {\r
+                       Resource represents  = graph.getSingleObject(r, b.Represents);\r
+                       if(graph.isInstanceOf(represents, sr.IndependentVariable)) {\r
+                               variables.add(r);\r
+                       } else if (graph.isInstanceOf(represents, sr.Input)) {\r
+                               inputs.add(r);\r
+                       } else if (graph.isInstanceOf(represents, sr.Module)) {\r
+                               modules.add(r);\r
+                       }\r
+               }\r
+               \r
+               for (Resource r : variables)\r
+                       result.add(new VariableNode<Resource>(r));\r
+               for (Resource r : inputs)\r
+                       result.add(new InputNode(r));\r
+               for (Resource r : modules) \r
+                       result.add(new ModuleNode(r));\r
+               return result;\r
+       }\r
 \r
-        @Override\r
-        public String getViewpointId() {\r
-            return "Standard";\r
-        }\r
+       @Override\r
+       public String getViewpointId() {\r
+               return "Standard";\r
+       }\r
 }\r
index 2161aaee512f41c2f8fea454ca5ea1e09133e0c6..53700ade3d52bbd192d1d4928d38be00177469d8 100644 (file)
@@ -13,13 +13,14 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\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.ConfigurationNode;\r
 \r
-public class ConfigurationLabeler extends LabelerContributor<ConfigurationNode>{\r
+public class ConfigurationLabeler extends LabelerContributor<ConfigurationNode<Resource>>{\r
 \r
     @Override\r
-    public String getLabel(ReadGraph graph, ConfigurationNode conf) throws DatabaseException {\r
+    public String getLabel(ReadGraph graph, ConfigurationNode<Resource> conf) throws DatabaseException {\r
         return "Configuration";\r
     }\r
 \r
index cf9d84a8862644d02a4a2fc21a4dd405ae96cd12..307b3eb74d872eea852fb0ca6fecc01f10c82d00 100644 (file)
@@ -26,7 +26,8 @@ import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;
 \r
 public class Experiment extends ViewpointContributor<ExperimentsFolder> {\r
 \r
-    @Override\r
+    @SuppressWarnings("unchecked")\r
+       @Override\r
     public Collection<?> getContribution(ReadGraph graph, ExperimentsFolder experimentsFolder) throws DatabaseException {\r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
         Builtins b = graph.getBuiltins();\r
index 8c946d1f1226aa1c7326bf44f76dc0dc850a6ea0..76d98d4e07f694413a7d3a7acee4f364539ba62e 100644 (file)
@@ -7,8 +7,9 @@ import org.simantics.browsing.ui.common.node.AbstractNode;
 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.common.request.PossibleObjectWithType;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
@@ -20,11 +21,11 @@ public class Model  extends ViewpointContributor<ModelNode> {
     public Collection<?> getContribution(ReadGraph graph, ModelNode model)\r
     throws DatabaseException {\r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
-        result.add(new ConfigurationNode(\r
-                graph.getSingleObject(\r
-                        model.data,\r
-                        SimulationResource.getInstance(graph).HasConfiguration))\r
-        );\r
+        \r
+        Resource baseRealization = graph.syncRequest(new PossibleObjectWithType(model.data, b.ConsistsOf, SysdynResource.getInstance(graph).DefaultRealization));\r
+        if (baseRealization != null) {\r
+            result.add(new ConfigurationNode<Resource>(baseRealization));\r
+        }\r
         result.add(new ExperimentsFolder(model.data));\r
         result.add(new ModulesNode(model.data));\r
         return result;\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java
deleted file mode 100644 (file)
index 9cbfbc6..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-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.common.node.AbstractNode;\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.modeling.ModelingResources;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
-\r
-public class Module extends ViewpointContributor<ModuleNode> {\r
-\r
-    @Override\r
-    public Collection<?> getContribution(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
-        ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
-        Builtins b = graph.getBuiltins();\r
-        SysdynResource sr = SysdynResource.getInstance(graph);\r
-        StructuralResource2 str = StructuralResource2.getInstance(graph);\r
-\r
-        // ModuleTypeNode extends ModuleNode, so we get the instance in two different ways\r
-        Resource instance = graph.getPossibleObject(module.data, b.InstanceOf);\r
-        if(graph.isInheritedFrom(module.data, sr.ModuleSymbol)) {\r
-            ModelingResources mr = ModelingResources.getInstance(graph);\r
-            instance =  graph.getPossibleObject(module.data, mr.SymbolToComponentType);\r
-        }\r
-\r
-        if(instance == null) return result;\r
-        Resource conf = graph.getSingleObject(instance, str.IsDefinedBy);\r
-        for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.IndependentVariable))) {\r
-            try {\r
-                result.add(graph.adapt(r, AbstractNode.class));\r
-            } catch(DatabaseException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-        for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.Input))) {\r
-            try {\r
-                result.add(graph.adapt(r, AbstractNode.class));\r
-            } catch(DatabaseException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-        for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.Module))) {\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/ModuleType.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java
new file mode 100644 (file)
index 0000000..b47e8d7
--- /dev/null
@@ -0,0 +1,52 @@
+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.common.node.AbstractNode;\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.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
+\r
+public class ModuleType extends ViewpointContributor<ModuleTypeNode> {\r
+\r
+       @Override\r
+       public Collection<?> getContribution(ReadGraph graph, ModuleTypeNode module) throws DatabaseException {\r
+               ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+               Builtins b = graph.getBuiltins();\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               StructuralResource2 str = StructuralResource2.getInstance(graph);\r
+               \r
+               ModelingResources mr = ModelingResources.getInstance(graph);\r
+               Resource instance =  graph.getPossibleObject(module.data, mr.SymbolToComponentType);\r
+\r
+               if(instance == null) return result;\r
+               Resource conf = graph.getSingleObject(instance, str.IsDefinedBy);\r
+               for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.IndependentVariable))) {\r
+                       result.add(new VariableNode<Resource>(r));\r
+               }\r
+               for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.Input))) {\r
+                       result.add(new InputNode(r));\r
+               }\r
+               for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.Module))) {\r
+                       result.add(new ModuleNode(r));\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public String getViewpointId() {\r
+               return "Standard";\r
+       }\r
+\r
+}\r
index 83acd782a7a8a1feb899f940be0601c243a6d948..cc763e6c340a13bee613246831f21b3a7bd86267 100644 (file)
@@ -14,7 +14,8 @@ import org.simantics.sysdyn.SysdynResource;
 \r
 public class Project extends ViewpointContributor<Resource> {\r
 \r
-    @Override\r
+    @SuppressWarnings("unchecked")\r
+       @Override\r
     public Collection<?> getContribution(ReadGraph graph, Resource project)\r
     throws DatabaseException {\r
 \r
index ecd79d25ae935219edd6cb6e1e105f2d7edbb9d1..a06e64a5a050ae5c9d9afee581b3a84ab9310838 100644 (file)
@@ -17,7 +17,8 @@ import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;
 \r
 public class SimulationResult  extends ViewpointContributor<ExperimentNode> {\r
 \r
-    @Override\r
+    @SuppressWarnings("unchecked")\r
+       @Override\r
     public Collection<?> getContribution(ReadGraph graph, ExperimentNode experiment) throws DatabaseException {\r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
index 24d13e76aecb8e13c21e5b1fcf307eb7162db6f0..7243a5390e902b9c372826e0122a589fe098f2b6 100644 (file)
@@ -18,10 +18,10 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
 \r
-public class VariableLabeler  extends LabelerContributor<VariableNode>{\r
+public class VariableLabeler  extends LabelerContributor<VariableNode<Resource>>{\r
 \r
     @Override\r
-    public String getLabel(ReadGraph graph, VariableNode var) throws DatabaseException {\r
+    public String getLabel(ReadGraph graph, VariableNode<Resource> var) throws DatabaseException {\r
         Builtins b = graph.getBuiltins();\r
         Resource varres = var.data;\r
         StringBuilder sb = new StringBuilder();\r
index cd1a43359513db1b397d660ab0c18e6329120c7b..0499ec618914dd6d38fee68bce6e9f374654f4a5 100644 (file)
@@ -15,10 +15,10 @@ import org.simantics.browsing.ui.common.node.AbstractNode;
 import org.simantics.browsing.ui.common.node.IDeletable;\r
 import org.simantics.db.Resource;\r
 \r
-public class ConfigurationNode  extends AbstractNode<Resource> implements IDeletable {\r
-\r
-    public ConfigurationNode(Resource resource) {\r
-        super(resource);\r
+public class ConfigurationNode<T> extends AbstractNode<Resource> implements IDeletable {\r
+       \r
+    public ConfigurationNode(final Resource resource) {\r
+       super(resource);\r
     }\r
     \r
 }\r
index 82aa5cae2732c9e1d94e2e6c614095698178823b..7575c02d055ff30f9877f2385028c08337b1d346 100644 (file)
@@ -1,9 +1,8 @@
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
-import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.db.Resource;\r
 \r
-public class InputNode  extends AbstractNode<Resource> {\r
+public class InputNode  extends VariableNode<Resource> {\r
 \r
     public InputNode(Resource resource) {\r
         super(resource);\r
index 9801d563683f97445953c44a0de95ee14124cd2f..7ced9908fa9ca1745394f32867949ff5e679aab1 100644 (file)
@@ -18,6 +18,7 @@ import org.simantics.utils.ui.ExceptionUtils;
 \r
 public class ModelNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
 \r
+       \r
     public ModelNode(Resource resource) {\r
         super(resource);\r
     }\r
index 0a8044baf92af3162ec599c3c3adcfe48bdc4705..00117ddca9356bbe5fd1484da651784741d10388 100644 (file)
@@ -1,9 +1,8 @@
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
-import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.db.Resource;\r
 \r
-public class ModuleNode extends AbstractNode<Resource> {\r
+public class ModuleNode extends ConfigurationNode<Resource> {\r
 \r
     public ModuleNode(Resource resource) {\r
         super(resource);\r
index 6e680372455676b474cad9e1e87617c6fa075b76..0e024004e79acb501dcd0fb4c4fd9ac87c2d075d 100644 (file)
@@ -22,7 +22,7 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.ui.SimanticsUI;\r
-// FIXME: should extend ModuleNode\r
+\r
 public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
 \r
     public ModuleTypeNode(Resource resource) {\r
index 08ea8b9a56ee712c01ecbcdeff70104cc4d294c1..a4f399fea6a0ce55bf0d240ab5c833f64b21838b 100644 (file)
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
 import org.simantics.browsing.ui.common.node.AbstractNode;\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.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
 \r
-public class VariableNode extends AbstractNode<Resource> {\r
+public class VariableNode<T> extends AbstractNode<Resource> {\r
 \r
-    public VariableNode(Resource resource) {\r
-        super(resource);\r
-    }\r
+       Resource model = null;\r
+       String uri;\r
+       Resource resource;\r
 \r
+       public VariableNode(Resource resource) {\r
+               super(resource);\r
+\r
+               SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+\r
+                       @Override\r
+                       public void run(ReadGraph graph) throws DatabaseException {\r
+                               Builtins b = graph.getBuiltins();\r
+                               SysdynResource sr = SysdynResource.getInstance(graph);\r
+                               \r
+                               VariableNode.this.resource = graph.getPossibleObject(data, b.Represents);\r
+                               \r
+                               if(VariableNode.this.resource == null)\r
+                                       return;\r
+                               \r
+                               uri = getName(graph);\r
+                               \r
+                               // don't search for a parent if the resource is not part of a realization\r
+                               if(!graph.isInheritedFrom(graph.getSingleObject(data, b.InstanceOf), b.Realization))\r
+                                       return;\r
+                               \r
+                               // search for the model parent and build the uri\r
+                               Resource parent = graph.getSingleObject(data, b.PartOf);\r
+                               while (!graph.isInstanceOf(parent, sr.SysdynModel)) {\r
+                                       uri = graph.getRelatedValue(parent, b.HasName) + "/" + uri;\r
+                                       parent = graph.getSingleObject(parent, b.PartOf);\r
+                               }\r
+                               // cut out the realization name\r
+                               System.out.println(uri);\r
+                               uri = uri.substring(uri.indexOf("/") + 1);\r
+                               System.out.println(uri);\r
+                               model = parent;\r
+                       }\r
+               });\r
+       }\r
+\r
+       public String getURI() {\r
+               return uri;\r
+       }\r
+\r
+       public Resource getModel() {\r
+               return model;\r
+       }\r
+\r
+       public String getName(ReadGraph graph) throws DatabaseException {\r
+               return (String)graph.getRelatedValue(data, graph.getBuiltins().HasName);\r
+       }\r
+\r
+       public Resource getParent(ReadGraph graph) throws DatabaseException {\r
+               return graph.getSingleObject(data, graph.getBuiltins().PartOf);\r
+       }\r
+       \r
+       public Resource getResource() {\r
+               return resource;\r
+       }\r
 }\r
index 2c4c6e0931462d4eb552416eb23541c0dad2eebe..e425fe1a4f6d52f29697783dc96f9732ee312a83 100644 (file)
@@ -1,5 +1,6 @@
 package org.simantics.sysdyn.ui.editor;\r
 \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
@@ -13,55 +14,69 @@ import org.simantics.ui.SimanticsUI;
 \r
 public class OpenDiagramFromConfigurationAdapter extends org.simantics.modeling.ui.diagramEditor.OpenDiagramFromConfigurationAdapter {\r
 \r
-    private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
+       private static final String EDITOR_ID = "org.simantics.sysdyn.ui.diagramViewer";\r
 \r
-    public OpenDiagramFromConfigurationAdapter() {\r
-        super();\r
-    }\r
+       public OpenDiagramFromConfigurationAdapter() {\r
+               super();\r
+       }\r
 \r
-    @Override\r
-    protected String getEditorId() {\r
-        return EDITOR_ID;\r
-    }\r
+       @Override\r
+       protected String getEditorId() {\r
+               return EDITOR_ID;\r
+       }\r
 \r
-    @Override\r
-    public boolean canHandle(ReadGraph g, Resource r) throws DatabaseException {\r
-        if(g.isInheritedFrom(r, SysdynResource.getInstance(g).ModuleSymbol)) {\r
-            ModelingResources mr = ModelingResources.getInstance(g);\r
-            StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
-            Resource componentType = g.getSingleObject(r, mr.SymbolToComponentType);\r
-            r = g.getSingleObject(componentType, sr2.IsDefinedBy);\r
-        }\r
-        return ComponentUtils.compositeHasDiagram(g, r) /*|| ComponentUtils.componentHasDiagram(g, r)*/;\r
-    }\r
+       @Override\r
+       public boolean canHandle(ReadGraph g, Resource r) throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(g);\r
+               if(g.isInheritedFrom(r, sr.ModuleSymbol)) {\r
+                       ModelingResources mr = ModelingResources.getInstance(g);\r
+                       StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+                       Resource componentType = g.getSingleObject(r, mr.SymbolToComponentType);\r
+                       r = g.getSingleObject(componentType, sr2.IsDefinedBy);\r
+               }\r
+               Builtins b = g.getBuiltins();\r
+               Resource represents = g.getPossibleObject(r, b.Represents);\r
+               if(represents != null){\r
+                       if(g.isInstanceOf(represents, sr.Configuration)) {\r
+                               r = represents;\r
+                       }\r
+               }\r
+               return ComponentUtils.compositeHasDiagram(g, r) /*|| ComponentUtils.componentHasDiagram(g, r)*/;\r
+       }\r
 \r
-    @Override\r
-    public void openEditor(final Resource r) throws Exception {\r
-        Resource configuration = null;\r
-        try {\r
-            configuration = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+       @Override\r
+       public void openEditor(final Resource r) throws Exception {\r
+               Resource configuration = null;\r
+               try {\r
+                       configuration = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
 \r
-                @Override\r
-                public Resource perform(ReadGraph graph) throws DatabaseException {\r
-                    if(graph.isInheritedFrom(r, SysdynResource.getInstance(graph).ModuleSymbol)) {\r
-                        ModelingResources mr = ModelingResources.getInstance(graph);\r
-                        StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
-                        Resource componentType = graph.getSingleObject(r, mr.SymbolToComponentType);\r
-                        Resource configuration = graph.getSingleObject(componentType, sr2.IsDefinedBy);\r
-                        return configuration;\r
-                    }\r
-                    else {\r
-                        return null;\r
-                    }\r
-                }\r
-            });\r
-        } catch (DatabaseException e1) {\r
-            e1.printStackTrace();\r
-        }\r
-        if (configuration != null)\r
-            super.openEditor(configuration);\r
-        else\r
-            super.openEditor(r);\r
-    }\r
+                               @Override\r
+                               public Resource perform(ReadGraph graph) throws DatabaseException {\r
+                                       Builtins b = graph.getBuiltins();\r
+                                       if(graph.isInheritedFrom(r, SysdynResource.getInstance(graph).ModuleSymbol)) {\r
+                                               ModelingResources mr = ModelingResources.getInstance(graph);\r
+                                               StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+                                               Resource componentType = graph.getSingleObject(r, mr.SymbolToComponentType);\r
+                                               Resource configuration = graph.getSingleObject(componentType, sr2.IsDefinedBy);\r
+                                               return configuration;\r
+                                       } else {     \r
+                                               Resource represents = graph.getPossibleObject(r, b.Represents);\r
+                                               if(represents != null && graph.isInstanceOf(represents, SysdynResource.getInstance(graph).Configuration)){\r
+                                                       return represents;\r
+                                               }\r
+                                               else {\r
+                                                       return null;\r
+                                               }\r
+                                       }\r
+                               }\r
+                       });\r
+               } catch (DatabaseException e1) {\r
+                       e1.printStackTrace();\r
+               }\r
+               if (configuration != null)\r
+                       super.openEditor(configuration);\r
+               else\r
+                       super.openEditor(r);\r
+       }\r
 \r
 }\r
index b43486c5eb62850852df518ae244c793c6af3fea..d0142956cf1e5722b265c6a6b1423aed755fb55e 100644 (file)
@@ -66,6 +66,12 @@ public class ShortcutTabWidget implements Widget {
         item = new TableItem(functionTable, SWT.NONE);\r
         item.setText("if then else");\r
         item.setData("if then else");\r
+        item = new TableItem(functionTable, SWT.NONE);\r
+        item.setText("xidz()");\r
+        item.setData("xidz( number, divisor , x)");\r
+        item = new TableItem(functionTable, SWT.NONE);\r
+        item.setText("interpolate()");\r
+        item.setData("interpolate( x, table)");     \r
         functions.setControl(functionTable);\r
     }\r
 \r
index d292a61bd5e63702a5d77cc340d01485a6af32b1..6fd478ba51f2ca1a6e7e5b17798656d76ca15ba7 100644 (file)
@@ -50,229 +50,218 @@ import org.simantics.sysdyn.manager.SysdynDataSet;
 import org.simantics.sysdyn.manager.SysdynModel;\r
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.manager.SysdynResult;\r
+import org.simantics.sysdyn.ui.browser.BrowserSelection;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 import org.simantics.utils.ui.jface.ActiveSelectionProvider;\r
 \r
 public class TrendView extends ViewPart {\r
 \r
-    Frame frame;\r
-    ChartPanel panel;\r
-    SysdynDatasets sysdynDatasets = new SysdynDatasets();\r
-\r
-\r
-    @SuppressWarnings("serial")\r
-    class SysdynDatasets extends AbstractXYDataset {\r
-\r
-        SysdynDataSet[] sets = new SysdynDataSet[0];\r
-\r
-        public void setDatasets(SysdynDataSet[] sets) {\r
-            this.sets = sets;\r
-            fireDatasetChanged();\r
-        }\r
-\r
-        @Override\r
-        public Number getY(int series, int item) {\r
-            return sets[series].values[item];\r
-        }\r
-\r
-        @Override\r
-        public Number getX(int series, int item) {\r
-            return sets[series].times[item];\r
-        }\r
-\r
-        @Override\r
-        public int getItemCount(int series) {\r
-            return sets[series].times.length;\r
-        }\r
-\r
-        @Override\r
-        public Comparable<String> getSeriesKey(int series) {\r
-            SysdynDataSet sds = sets[series];\r
-            if(sds.result == null)\r
-                return sds.name;\r
-            else\r
-                return sds.name + " : " + sds.result;\r
-        }\r
-\r
-        @Override\r
-        public int getSeriesCount() {\r
-            return sets.length;\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        final ActiveSelectionProvider selectionProvider = new ActiveSelectionProvider();\r
-        getSite().setSelectionProvider(selectionProvider);\r
-\r
-        final Composite composite = new Composite(parent,\r
-                SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
-        frame = SWT_AWT.new_Frame(composite);\r
-\r
-        SwingUtilities.invokeLater(new Runnable() {\r
-\r
-            @Override\r
-            public void run() {\r
-                XYPlot plot = new XYPlot(\r
-                        sysdynDatasets,\r
-                        new NumberAxis("time"),\r
-                        new NumberAxis("x"),\r
-                        new XYLineAndShapeRenderer(true, false)\r
-                );\r
-\r
-                JFreeChart chart = new JFreeChart(plot);\r
-                panel = new ChartPanel(chart);\r
-                frame.add(panel);\r
-\r
-                panel.requestFocus();\r
-            }\r
-\r
-        });\r
-\r
-        getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(new ISelectionListener() {\r
-\r
-            @Override\r
-            public void selectionChanged(IWorkbenchPart part, ISelection selection) {\r
-                if(selection.isEmpty() || Boolean.TRUE.equals(PinTrend.getState()))\r
-                    return;\r
-                if(selection instanceof IStructuredSelection) {\r
-                    Set<Resource> ress = ISelectionUtils.filterSetSelection(selection, Resource.class);\r
-                    List<Resource> runtimes = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_VARIABLE_RESOURCE, Resource.class);\r
-                    if(runtimes.isEmpty())\r
-                        return;\r
-                    Resource runtime = runtimes.get(0);\r
-                    setSelection(ress.toArray(Resource.NONE), runtime);\r
-                }\r
-            }\r
-        });\r
-\r
-    }\r
-\r
-    Resource[] resources;\r
-    Resource runtime;\r
-\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
-        session.asyncRequest(new ReadRequest() {\r
-            @Override\r
-            public void run(ReadGraph g) throws DatabaseException {\r
-\r
-                final ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
-                for(Resource resource : resources) {\r
-//                    SysdynDataSet set = load(g, resource, runtime);\r
-//                    if(set == null) {\r
-//                        return;\r
-//                    }\r
-//                    datasets.add(set);\r
-                    Collection<SysdynDataSet> activeDataSets = loadAllActive(g, resource, runtime);\r
-                    if(activeDataSets != null && !activeDataSets.isEmpty())\r
-                        datasets.addAll(activeDataSets);\r
-                }
-\r
-                SwingUtilities.invokeLater(new Runnable() {\r
-\r
-                    @Override\r
-                    public void run() {\r
-                        sysdynDatasets.setDatasets(datasets.toArray(new SysdynDataSet[datasets.size()]));\r
-                    }\r
-\r
-                });\r
-\r
-            }\r
-        });\r
-    }\r
-\r
-    /*\r
-    protected SysdynDataSet load(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
-\r
-       Builtins b = g.getBuiltins();\r
-\r
-        SysdynResource sr = SysdynResource.getInstance(g);\r
-\r
-        DiagramResource dr = DiagramResource.getInstance(g);\r
-\r
-        if(runtime == null) return null;\r
-        Resource resource = ModelingUtils.getPossibleElementCorrespondendence(g, element);\r
-        if(resource == null || !g.isInstanceOf(resource, sr.Variable)) return null;\r
-\r
-        String variableURI = g.getPossibleRelatedValue(runtime, dr.HasVariable);\r
-\r
-        System.out.println("load dataset for '"+ g.getPossibleRelatedValue(resource, b.HasName) + "'in composite '" + variableURI + "'");\r
-        Variable compositeVariable = Variables.getVariable(g, variableURI);\r
-        Variable item = compositeVariable.browsePossible(g, resource);\r
-        if(item == null) return null;\r
-\r
-        System.out.println("load dataset for '" + item.getURI(g) + "'");\r
-\r
-        Accessor accessor = item.getInterface(g, Accessor.class);\r
-        if(accessor == null) return null;\r
-        try {\r
-                       return (SysdynDataSet)accessor.getValue(Bindings.getBindingUnchecked(SysdynDataSet.class));\r
-               } catch (RuntimeBindingConstructionException e) {\r
-                       e.printStackTrace();\r
-               } catch (AccessorException e) {\r
-                       e.printStackTrace();\r
-               }\r
-               return null;\r
+       Frame frame;\r
+       ChartPanel panel;\r
+       SysdynDatasets sysdynDatasets = new SysdynDatasets();\r
+\r
 \r
-    }\r
-     */\r
+       @SuppressWarnings("serial")\r
+       class SysdynDatasets extends AbstractXYDataset {\r
 \r
-    @Override\r
-    public void setFocus() {\r
-        if(panel != null)\r
-            panel.requestFocus();\r
-    }\r
+               SysdynDataSet[] sets = new SysdynDataSet[0];\r
 \r
-    protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
+               public void setDatasets(SysdynDataSet[] sets) {\r
+                       this.sets = sets;\r
+                       fireDatasetChanged();\r
+               }\r
+\r
+               @Override\r
+               public Number getY(int series, int item) {\r
+                       return sets[series].values[item];\r
+               }\r
 \r
-        ArrayList<SysdynDataSet> dataSets = new ArrayList<SysdynDataSet>();\r
-        Builtins b = g.getBuiltins();\r
+               @Override\r
+               public Number getX(int series, int item) {\r
+                       return sets[series].times[item];\r
+               }\r
 \r
-        SysdynResource sr = SysdynResource.getInstance(g);\r
+               @Override\r
+               public int getItemCount(int series) {\r
+                       return sets[series].times.length;\r
+               }\r
 \r
-        DiagramResource dr = DiagramResource.getInstance(g);\r
+               @Override\r
+               public Comparable<String> getSeriesKey(int series) {\r
+                       SysdynDataSet sds = sets[series];\r
+                       if(sds.result == null)\r
+                               return sds.name;\r
+                       else\r
+                               return sds.name + " : " + sds.result;\r
+               }\r
 \r
-        if(runtime == null) return null;\r
-        Resource resource = ModelingUtils.getPossibleElementCorrespondendence(g, element);\r
-        if(resource == null || !g.isInstanceOf(resource, sr.Variable)) return null;\r
+               @Override\r
+               public int getSeriesCount() {\r
+                       return sets.length;\r
+               }\r
 \r
-        String variableURI = g.getPossibleRelatedValue(runtime, dr.HasVariable);\r
+       }\r
+\r
+       @Override\r
+       public void createPartControl(Composite parent) {\r
+               final ActiveSelectionProvider selectionProvider = new ActiveSelectionProvider();\r
+               getSite().setSelectionProvider(selectionProvider);\r
+\r
+               final Composite composite = new Composite(parent,\r
+                               SWT.NO_BACKGROUND | SWT.EMBEDDED);\r
+               frame = SWT_AWT.new_Frame(composite);\r
+\r
+               SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                       @Override\r
+                       public void run() {\r
+                               XYPlot plot = new XYPlot(\r
+                                               sysdynDatasets,\r
+                                               new NumberAxis("time"),\r
+                                               new NumberAxis("x"),\r
+                                               new XYLineAndShapeRenderer(true, false)\r
+                               );\r
+\r
+                               JFreeChart chart = new JFreeChart(plot);\r
+                               panel = new ChartPanel(chart);\r
+                               frame.add(panel);\r
+\r
+                               panel.requestFocus();\r
+                       }\r
+\r
+               });\r
+\r
+               getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(new ISelectionListener() {\r
+\r
+                       @Override\r
+                       public void selectionChanged(IWorkbenchPart part, ISelection selection) {\r
+                               if(selection.isEmpty() || Boolean.TRUE.equals(PinTrend.getState()))\r
+                                       return;\r
+                               if(selection instanceof IStructuredSelection) {\r
+                                       Set<BrowserSelection> bs = ISelectionUtils.filterSetSelection(selection, BrowserSelection.class);\r
+                                       if(!bs.isEmpty()) {\r
+                                               updateDatasets(bs.toArray(new BrowserSelection[bs.size()]));\r
+                                       } else {\r
+                                               Set<Resource> ress = ISelectionUtils.filterSetSelection(selection, Resource.class);\r
+                                               List<Resource> runtimes = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_VARIABLE_RESOURCE, Resource.class);\r
+                                               if(runtimes.isEmpty())\r
+                                                       return;\r
+                                               Resource runtime = runtimes.get(0);\r
+                                               updateDatasets(ress.toArray(Resource.NONE), runtime);\r
+                                       }\r
+                               }\r
+                       }\r
+               });\r
 \r
-        System.out.println("load dataset for '"+ g.getPossibleRelatedValue(resource, b.HasName) + "'in composite '" + variableURI + "'");\r
-        Variable compositeVariable = Variables.getVariable(g, variableURI);\r
-        Variable item = compositeVariable.browsePossible(g, resource);\r
-        if(item == null) return null;\r
+       }\r
+\r
+       ArrayList<SysdynDataSet> datasets = new ArrayList<SysdynDataSet>();\r
+\r
+       private void updateDatasets(final Resource[] resources, final Resource runtime) {\r
+               Session session = SimanticsUI.peekSession();\r
+               if (session == null)\r
+                       return;\r
+\r
+               session.asyncRequest(new ReadRequest() {\r
+                       @Override\r
+                       public void run(ReadGraph g) throws DatabaseException {\r
+                               datasets.clear();\r
+                               for(Resource resource : resources) {\r
+                                       Collection<SysdynDataSet> activeDataSets = loadAllActive(g, resource, runtime);\r
+                                       if(activeDataSets != null && !activeDataSets.isEmpty())\r
+                                               datasets.addAll(activeDataSets);\r
+                               }\r
+                               updateView();\r
+                       }\r
+               });\r
+\r
+       }\r
+\r
+       private void updateDatasets(final BrowserSelection[] browserSelections) {\r
+               Session session = SimanticsUI.peekSession();\r
+               if (session == null)\r
+                       return;\r
+\r
+               session.asyncRequest(new ReadRequest() {\r
+                       @Override\r
+                       public void run(ReadGraph g) throws DatabaseException {\r
+                               datasets.clear();\r
+                               for(BrowserSelection bs : browserSelections) {\r
+                                       if(bs.getURI() != null && bs.getModel() != null) {\r
+                                               Collection<SysdynDataSet> activeDataSets = loadAllActive(g, bs.getURI(), bs.getModel());\r
+                                               if(activeDataSets != null && !activeDataSets.isEmpty()) \r
+                                                       datasets.addAll(activeDataSets);\r
+                                       }\r
+\r
+                               }\r
+                               updateView();\r
+                       }\r
+               });\r
+       }\r
+\r
+       private void updateView() {\r
+               SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                       @Override\r
+                       public void run() {\r
+                               sysdynDatasets.setDatasets(datasets.toArray(new SysdynDataSet[datasets.size()]));\r
+                       }\r
+\r
+               });\r
+       }\r
+\r
+\r
+       @Override\r
+       public void setFocus() {\r
+               if(panel != null)\r
+                       panel.requestFocus();\r
+       }\r
+\r
+       protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, Resource element, Resource runtime) throws DatabaseException {\r
+\r
+               Builtins b = g.getBuiltins();\r
+\r
+               SysdynResource sr = SysdynResource.getInstance(g);\r
+\r
+               DiagramResource dr = DiagramResource.getInstance(g);\r
+\r
+               if(runtime == null) return null;\r
+               Resource resource = ModelingUtils.getPossibleElementCorrespondendence(g, element);\r
+               if(resource == null || !g.isInstanceOf(resource, sr.Variable)) return null;\r
+\r
+               String variableURI = g.getPossibleRelatedValue(runtime, dr.HasVariable);\r
+\r
+               System.out.println("load dataset for '"+ g.getPossibleRelatedValue(resource, b.HasName) + "'in composite '" + variableURI + "'");\r
+               Variable compositeVariable = Variables.getVariable(g, variableURI);\r
+               Variable item = compositeVariable.browsePossible(g, resource);\r
+               if(item == null) return null;\r
+\r
+               String rvi = Variables.getRVI(g, item);\r
+               System.out.println("HistoryVariable rvi='" + rvi + "'");\r
+\r
+               System.out.println("load dataset for '" + item.getURI(g) + "'");\r
+\r
+               Resource model = Variables.getModel(g, item);\r
+\r
+               return loadAllActive(g, rvi.substring(1), model);\r
 \r
-        String rvi = Variables.getRVI(g, item);\r
-        System.out.println("HistoryVariable rvi='" + rvi + "'");\r
+       }\r
 \r
-        System.out.println("load dataset for '" + item.getURI(g) + "'");\r
+       protected Collection<SysdynDataSet> loadAllActive(ReadGraph g, String rvi, Resource model) throws DatabaseException {\r
+               ArrayList<SysdynDataSet> dataSets = new ArrayList<SysdynDataSet>();\r
 \r
-        Resource model = Variables.getModel(g, item);\r
-        Resource configuration = g.getPossibleObject(model, SimulationResource.getInstance(g).HasConfiguration);\r
-        SysdynModel sm = SysdynModelManager.getInstance(g.getSession()).getModel(g, configuration);\r
+               Resource configuration = g.getPossibleObject(model, SimulationResource.getInstance(g).HasConfiguration);\r
+               SysdynModel sm = SysdynModelManager.getInstance(g.getSession()).getModel(g, configuration);\r
 \r
-        Collection<SysdynResult> activeResults = sm.getActiveResults(g);\r
-        for(SysdynResult sysdynResult : activeResults) {\r
-            SysdynDataSet sds = sysdynResult.getDataSet(rvi.substring(1).replace("/", "."));\r
-            if(sds != null)\r
-                dataSets.add(sds);\r
-        }\r
-        return dataSets;\r
+               Collection<SysdynResult> activeResults = sm.getActiveResults(g);\r
+               for(SysdynResult sysdynResult : activeResults) {\r
+                       SysdynDataSet sds = sysdynResult.getDataSet(rvi.replace("/", "."));\r
+                       if(sds != null)\r
+                               dataSets.add(sds);\r
+               }\r
+               return dataSets;\r
 \r
-    }\r
+       }\r
 \r
 }\r