]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
modelbrowser2 enabled
authorakallio <akallio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 29 Jun 2011 15:31:50 +0000 (15:31 +0000)
committerakallio <akallio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 29 Jun 2011 15:31:50 +0000 (15:31 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@21406 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/graph/Sysdyn_ModelBrowser_Viewpoint.pgraph [new file with mode: 0644]
org.simantics.sysdyn.ui/META-INF/MANIFEST.MF
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/ModuleTypeChildRule.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java

index 3428e820e48f36b9932dba151d31216130310e73..7f8b35c652fe121f36b9ce812fc2c34f48ddc277 100644 (file)
@@ -27,7 +27,7 @@ SYSDYN.SharedModuleOntolofgy <T L0.Ontology
 // Model
 //#####################################################################    
 
-SYSDYN.SysdynModel <T SIMU.Model
+SYSDYN.SysdynModel <T MOD.StructuralModel
     // TODO [SIMU.HasConfiguration all SYSDYN.Configuration]
     @L0.assert SYSDYN.HasStartTime 0.0
     @L0.assert SYSDYN.HasStopTime 10.0
diff --git a/org.simantics.sysdyn.ontology/graph/Sysdyn_ModelBrowser_Viewpoint.pgraph b/org.simantics.sysdyn.ontology/graph/Sysdyn_ModelBrowser_Viewpoint.pgraph
new file mode 100644 (file)
index 0000000..bc1dedb
--- /dev/null
@@ -0,0 +1,27 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+VP = <http://www.simantics.org/Viewpoint-1.0>\r
+SIMU = <http://www.simantics.org/Simulation-1.0>\r
+PROJECT = <http://www.simantics.org/Project-1.0>\r
+IMAGE = <http://www.simantics.org/Image-2.0>\r
+ACT = <http://www.simantics.org/Action-1.0>\r
+MOD = <http://www.simantics.org/Modeling-1.0>\r
+STR = <http://www.simantics.org/Structural-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+\r
+SBC = SYSDYN.ProjectBrowseContext : VP.BrowseContext\r
+SAC = SYSDYN.ProjectActionContext : VP.BrowseContext\r
+\r
+MBC = MOD.ModelingBrowseContext : VP.BrowseContext\r
+    VP.BrowseContext.IsIncludedIn PROJECT.ProjectBrowseContext\r
+MAC = MOD.ModelingActionContext : VP.BrowseContext\r
+    VP.BrowseContext.IsIncludedIn PROJECT.ProjectActionContext\r
+\r
+//dymmy moduleslibrary to make this easier\r
+SYSDYN.ModulesLibrary <T L0.Library\r
+\r
+MBC\r
+    @VP.relationChildRule      MOD.StructuralModel      L0.ConsistsOf      SYSDYN.ModulesLibrary\r
+    VP.BrowseContext.HasChildContribution _ : VP.ChildContribution\r
+        VP.ChildContribution.HasParentNodeType SYSDYN.ModulesLibrary\r
+        VP.ChildContribution.HasChildNodeType L0.Entity\r
+        VP.ChildContribution.HasRule SBC.ModuleTypeChildRule : VP.ChildRule
\ No newline at end of file
index 70727806b3a3459087f8297f8be2bf24d968ed26..ed95e0589697864d6724a3a00c5f4c1e32a66fc7 100644 (file)
@@ -39,7 +39,8 @@ Require-Bundle: org.simantics.layer0.utils;bundle-version="0.6.2",
  org.simantics.diagram.ontology;bundle-version="1.0.0",
  org.simantics.graph;bundle-version="1.0.2",
  org.simantics.graph.db;bundle-version="1.0.0",
- org.simantics.structural.ui;bundle-version="1.1.1"
+ org.simantics.structural.ui;bundle-version="1.1.1",
+ org.simantics.browsing.ui.model;bundle-version="1.0.0"
 Bundle-Activator: org.simantics.sysdyn.ui.Activator
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.sysdyn.ui.browser.nodes
index b3e7e6065e6ad7b885e1e7347bae379ad168e394..6db4046b416830a5c1e1ac4896a95041b1f4ae6e 100644 (file)
@@ -10,5 +10,5 @@
         VTT Technical Research Centre of Finland - initial API and implementation\r
  -->\r
 
-<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r<!-- \r       <target interface="org.simantics.db.layer0.variable.Variable">\r         <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r                     class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r                      <this />\r               </type>\r                <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r                     class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r                      <this />\r               </type>\r        </target>\r -->\r\r        <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->\r         <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                     class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <!-- : SYSDYN.Connection-->\r            <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r
+<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r<!-- \r       <target interface="org.simantics.db.layer0.variable.Variable">\r         <type uri="http://www.simantics.org/Sysdyn-1.0/HistoryRealization"\r                     class="org.simantics.sysdyn.ui.project.HistoryVariable" >\r                      <this />\r               </type>\r                <type uri="http://www.simantics.org/Sysdyn-1.0/DefaultRealization"\r                     class="org.simantics.sysdyn.ui.project.DefaultVariable" >\r                      <this />\r               </type>\r        </target>\r -->\r\r        <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->\r         <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                     class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowEdgeFactory" />\r               <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <!-- : SYSDYN.Connection-->\r            <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.connections.FlowConnectionFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-1.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r    </target>\r        \r
 </adapters>
\ No newline at end of file
index cf30c2d7d0ae81f984f070e57dc878a12e8ca031..f8db234d644c91e0329826fb97316d0b277d991f 100644 (file)
                relationship="left"\r
                relative="org.eclipse.ui.editorss">\r
          </view>\r
+         <view\r
+               id="org.simantics.structural.ui.modelBrowser2"\r
+               minimized="false"\r
+               relationship="stack"\r
+               relative="org.simantics.sysdyn.ui.browser">\r
+         </view>\r
          <view\r
                id="org.simantics.diagram.symbollibrary"\r
                minimized="false"\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/ModuleTypeChildRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/childrules/ModuleTypeChildRule.java
new file mode 100644 (file)
index 0000000..7b5d764
--- /dev/null
@@ -0,0 +1,57 @@
+package org.simantics.sysdyn.ui.browser.childrules;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.model.children.ChildRule;\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.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+\r
+public class ModuleTypeChildRule implements ChildRule {\r
+\r
+       @Override\r
+       public boolean isCompatible(Class<?> contentType) {\r
+               return contentType.equals(Resource.class);\r
+       }\r
+\r
+       @Override\r
+       public Collection<?> getChildren(ReadGraph graph, Object parent)\r
+                       throws DatabaseException {\r
+\r
+       ArrayList<Resource> children = new ArrayList<Resource>();\r
+       \r
+               if(!(parent instanceof Resource)) {\r
+                       return children;\r
+               }\r
+               \r
+               Layer0 l0 = Layer0.getInstance(graph);\r
+               StructuralResource2 st = StructuralResource2.getInstance(graph);\r
+\r
+               Resource modulelibrary = (Resource)parent;\r
+               \r
+               Resource model = graph.getSingleObject(modulelibrary, l0.PartOf);\r
+               \r
+        for(Resource r : graph.syncRequest(new ObjectsWithType(model, l0.ConsistsOf, st.ComponentType))) {\r
+               if(graph.isInheritedFrom(r, SysdynResource.getInstance(graph).Module)) {\r
+                       Resource symbol = graph.getPossibleObject(r,ModelingResources.getInstance(graph).ComponentTypeToSymbol);\r
+                       children.add(symbol);\r
+               }\r
+        }\r
+               \r
+               return children;\r
+       }\r
+\r
+       @Override\r
+       public Collection<?> getParents(ReadGraph graph, Object child)\r
+                       throws DatabaseException {\r
+               return new ArrayList<Resource>();\r
+       }\r
+\r
+}
\ No newline at end of file
index 657a8ff1b88a138b630531cd5b013d262309baab..3f6cde47d90ed05bb2913bb3c21edc9ab6fcb0ea 100644 (file)
@@ -153,6 +153,11 @@ public class SysdynProject extends AbstractProjectFeature {
                         l0.HasLabel, "Experiment",\r
                         l0.HasReportFactory, report,\r
                         l0.PartOf, model);\r
+                \r
+                //model browser2\r
+                Resource moduleslibrary = g.newResource();\r
+                g.claim(moduleslibrary, l0.InstanceOf, sr.ModulesLibrary);\r
+                g.claim(model, l0.ConsistsOf, moduleslibrary);\r
 \r
                 ProjectResource PROJ = ProjectResource.getInstance(g);\r
                 for(Resource dep : g.getObjects(library, l0.IsLinkedTo)) {\r