]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Model browser cleanup
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 30 Jul 2010 13:14:58 +0000 (13:14 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 30 Jul 2010 13:14:58 +0000 (13:14 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16883 ac1ea38d-2e2b-0410-8846-a27921b304fc

15 files changed:
org.simantics.sysdyn.ui/icons/palette.png [new file with mode: 0644]
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleTypeLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Modules.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java

diff --git a/org.simantics.sysdyn.ui/icons/palette.png b/org.simantics.sysdyn.ui/icons/palette.png
new file mode 100644 (file)
index 0000000..73c5b3f
Binary files /dev/null and b/org.simantics.sysdyn.ui/icons/palette.png differ
index 4ae354c98bd4df26d21bf60385bd86f5d14d75b1..6988c69088d4d8dcd55c2bb5b94bbdf1a457a0ac 100644 (file)
@@ -74,6 +74,7 @@
             restorable="true">\r
       </view>\r
       <view\r
+            category="org.simantics.sysdyn.ui.category"\r
             class="org.simantics.sysdyn.ui.browser.SysdynBrowser"\r
             id="org.simantics.sysdyn.ui.browser"\r
             name="Sysdyn Model Browser"\r
          </menu>\r
          <command\r
                commandId="org.simantics.sysdyn.ui.showModule"\r
-               icon="icons/silk/palette.png"\r
+               icon="icons/palette.png"\r
                label="Show Module"\r
                style="push">\r
             <visibleWhen>\r
                class="org.simantics.sysdyn.ui.browser.contributions.Module"\r
                preference="1.0">\r
          </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.ModuleType"\r
-               preference="1.0">\r
-         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
                class="org.simantics.sysdyn.ui.browser.contributions.AbstractNodeImager"\r
                preference="2.0">\r
          </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.ModelImager"\r
-               preference="2.0">\r
-         </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.ConfigurationImager"\r
-               preference="2.0">\r
-         </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.VariableImager"\r
-               preference="2.0">\r
-         </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.ExperimentImager"\r
-               preference="2.0">\r
-         </implementation>\r
          <implementation\r
                class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultImager"\r
                preference="2.0">\r
          </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.ModuleImager"\r
-               preference="2.0">\r
-         </implementation>\r
-         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.InputImager"\r
-               preference="2.0">\r
-         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
                class="org.simantics.sysdyn.ui.properties.ResourceSelectionProcessor">\r
          </implementation>\r
       </binding>\r
-   </extension>\r
-   <extension\r
-         point="org.eclipse.ui.propertyPages">\r
-      <page\r
-            class="org.simantics.sysdyn.ui.WorkbenchPropertyPage1"\r
-            id="org.simantics.sysdyn.ui.page1"\r
-            name="name">\r
-      </page>\r
    </extension>
 </plugin>\r
index 977d54e8f4be77888a6ee676503d09dec3f043dd..21ae321a7783a55586d27038adbef44efbc3dfe1 100644 (file)
@@ -17,20 +17,40 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.ui.Activator;\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.ExperimentNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\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.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> {\r
 \r
     @Override\r
     public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode node) throws DatabaseException {\r
         \r
+        String image = null;\r
         if (node instanceof ExperimentsFolder || \r
                 node instanceof OperatingInterfacesFolder || \r
                 node instanceof ModulesNode)\r
-            return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/folder.png"));\r
-            \r
+            image = "icons/folder.png";\r
+        else if (node instanceof ModuleTypeNode || node instanceof ModuleNode || node instanceof ConfigurationNode)\r
+            image = "icons/bricks.png";\r
+        else if (node instanceof ExperimentNode)\r
+            image = "icons/time.png";\r
+        else if (node instanceof InputNode)\r
+            image = "icons/brick_link.png";\r
+        else if (node instanceof ModelNode)\r
+            image = "icons/chart_organisation.png";\r
+        else if (node instanceof VariableNode)\r
+            image =  "icons/brick.png";\r
+        \r
+        if (image != null)\r
+            return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource(image));\r
         return null;\r
     }\r
 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java
deleted file mode 100644 (file)
index e8f1f91..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-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.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
-\r
-public class ConfigurationImager extends ImagerContributor<ConfigurationNode> {\r
-\r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, ConfigurationNode node) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/bricks.png"));\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java
deleted file mode 100644 (file)
index 0f607d5..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-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.project.IProject;\r
-import org.simantics.simulation.project.IExperimentManager;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class ExperimentImager extends ImagerContributor<ExperimentNode> {\r
-    \r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, ExperimentNode experiment) throws DatabaseException {\r
-        IProject project = SimanticsUI.getProject();\r
-        IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
-        System.out.println(experimentManager.getActiveExperiment());\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/time.png"));\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java
deleted file mode 100644 (file)
index beb1e80..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-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.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
-\r
-public class ExperimentsImager extends ImagerContributor<ExperimentsFolder> {\r
-\r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, ExperimentsFolder node) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/folder.png"));\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java
deleted file mode 100644 (file)
index c70b366..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-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.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
-\r
-public class InputImager extends ImagerContributor<InputNode> {\r
-\r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, InputNode node) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/brick_link.png"));\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java
deleted file mode 100644 (file)
index 00e386b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-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.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
-\r
-public class ModelImager extends ImagerContributor<ModelNode> {\r
-\r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, ModelNode node) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_organisation.png"));\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java
deleted file mode 100644 (file)
index b6ecea3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-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.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
-\r
-public class ModuleImager extends ImagerContributor<ModuleNode> {\r
-\r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, ModuleNode node) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/bricks.png"));\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
deleted file mode 100644 (file)
index 5e79acd..0000000
+++ /dev/null
@@ -1,30 +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.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.modeling.ModelingResources;\r
-import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
-import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
-\r
-public class ModuleType  extends ViewpointContributor<ModuleTypeNode> {\r
-\r
-    @Override\r
-    public Collection<?> getContribution(ReadGraph graph, ModuleTypeNode module) throws DatabaseException {\r
-        ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
-        ModelingResources mr = ModelingResources.getInstance(graph);\r
-        Resource symbol = graph.getPossibleObject(module.resource, mr.ComponentTypeToSymbol);\r
-        result.add(graph.adapt(symbol, AbstractNode.class));\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public String getViewpointId() {\r
-        return "Standard";\r
-    }\r
-\r
-}\r
index 4390dcdf670a3540bac489d8f857f520a760b082..74adf5911be27ef885c66962d69df5b76adcf7ea 100644 (file)
@@ -2,14 +2,18 @@ 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.modeling.ModelingResources;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
 \r
 public class ModuleTypeLabeler extends LabelerContributor<ModuleTypeNode>{\r
 \r
     @Override\r
     public String getLabel(ReadGraph graph, ModuleTypeNode moduleType) throws DatabaseException {\r
-        String label = graph.getPossibleRelatedValue(moduleType.resource, graph.getBuiltins().HasLabel);\r
+        ModelingResources mr = ModelingResources.getInstance(graph);\r
+        Resource typeResource =  graph.getPossibleObject(moduleType.resource, mr.SymbolToComponentType);\r
+        String label = graph.getPossibleRelatedValue(typeResource, graph.getBuiltins().HasName);\r
         return label == null ? "ModuleType (no name)" : label;\r
     }\r
 \r
index 5281330f5404e580451672b54f4b927cadf81c79..4399de9b7a3f0861a64e250a6367f3d54e3be86c 100644 (file)
@@ -9,6 +9,7 @@ import org.simantics.db.ReadGraph;
 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.ui.browser.nodes.AbstractNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode;\r
@@ -24,7 +25,8 @@ public class Modules extends ViewpointContributor<ModulesNode> {
         Builtins b = graph.getBuiltins();\r
         StructuralResource2 st = StructuralResource2.getInstance(graph);\r
         for(Resource r : graph.syncRequest(new ObjectsWithType(model.resource, b.ConsistsOf, st.ComponentType))) {\r
-            result.add(new ModuleTypeNode(r));\r
+            Resource symbol = graph.getPossibleObject(r,ModelingResources.getInstance(graph).ComponentTypeToSymbol);\r
+            result.add(new ModuleTypeNode(symbol));\r
         }\r
         return result;\r
 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java
deleted file mode 100644 (file)
index 3dc6c4c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-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.Activator;\r
-import org.simantics.sysdyn.ui.browser.nodes.VariableNode;\r
-\r
-public class VariableImager extends ImagerContributor<VariableNode> {\r
-\r
-    @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, VariableNode node) throws DatabaseException {\r
-        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/brick.png"));\r
-    }\r
-}\r
index 1e9fdc0f17a6eb63db86d00c3ffd65e0ed9ee4c6..cd1484ed4d75fc4267db7badce56321ea8f0a4d9 100644 (file)
@@ -41,7 +41,6 @@ public class NewModuleNodeHandler extends AbstractHandler {
                 \r
                 Resource moduleType = g.newResource();\r
                 g.claimValue(moduleType, mu.b.HasName, "New Module Type");\r
-                g.claimValue(moduleType, mu.b.HasLabel, "New Module Type");\r
                 g.claim(moduleType, mu.b.Inherits, sr.Module);\r
                 g.claim(moduleType, mu.b.PartOf, model);\r
                 \r
index cf6fd21679784eb5937d0a411b94d1da7077d098..8dcc4316f4827d5b7c851ff0bb32640f8d9c69ae 100644 (file)
@@ -128,13 +128,16 @@ public class ResourceSelectionProcessor implements SelectionProcessor<ISelection
                                     0,\r
                                     r,\r
                             "Dependency Properties"));\r
-            if (backend.isInheritedFrom(r, sr.Module))\r
-                return Collections.singleton(\r
+            if (backend.isInheritedFrom(r, sr.ModuleSymbol)) {\r
+                r =  backend.getPossibleObject(r, mr.SymbolToComponentType);\r
+                if(r != null)\r
+                    return Collections.singleton(\r
                         new ComparableTabContributor(\r
                                 new ModuleTypeTab(),\r
                                 0,\r
                                 r,\r
                         "Module Type Properties"));\r
+            }\r
         } catch (ServiceException e) {\r
             e.printStackTrace();\r
         } catch (ManyObjectsForFunctionalRelationException e) {\r