]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Variable browser (copied from Apros, doesn't seem to work yet, though)
authorjplaine <jplaine@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 12:11:23 +0000 (12:11 +0000)
committerjplaine <jplaine@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 12:11:23 +0000 (12:11 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17510 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynOperationBrowser.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelContributor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelLabels.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationProjectContributor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableContributor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableImager.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java [new file with mode: 0644]

index 544b4155a79f769255bedf1289f3635c6e394f57..dbcacb59576b493870de7a33fe20e8d888fa5f35 100644 (file)
             name="Dependencies"\r
             restorable="true">\r
       </view>\r
+      <view\r
+            category="org.simantics.sysdyn.ui.category"\r
+            class="org.simantics.sysdyn.ui.browser.SysdynOperationBrowser"\r
+            icon="icons/chart_organisation.png"\r
+            id="org.simantics.sysdyn.ui.operationBrowser"\r
+            name="Operation Browser"\r
+            restorable="true">\r
+         <description>\r
+            Operation view browser for Sysdyn.\r
+         </description>\r
+      </view>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.perspectives">\r
                preference="2.0">\r
          </implementation>\r
       </binding>\r
+      <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
+        <implementation class="org.simantics.sysdyn.ui.property.OperationProjectContributor" preference="1.0"/>\r
+        <implementation class="org.simantics.sysdyn.ui.property.OperationModelContributor" preference="1.0"/>\r
+        <implementation class="org.simantics.sysdyn.ui.property.OperationVariableContributor" preference="1.0"/>\r
+      </binding>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.labelerBinding">\r
                class="org.simantics.sysdyn.ui.browser.contributions.ModulesLabeler"\r
                preference="2.0">\r
          </implementation>\r
-<!--         <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.OperatingInterfacesLabeler"\r
-               preference="2.0">\r
-         </implementation>-->\r
          <implementation\r
                class="org.simantics.sysdyn.ui.browser.contributions.ExperimentLabeler"\r
                preference="2.0">\r
                preference="2.0">\r
          </implementation>\r
       </binding>\r
+      <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
+        <implementation class="org.simantics.sysdyn.ui.property.OperationModelLabels" preference="1.0"/>\r
+        <implementation class="org.simantics.sysdyn.ui.property.OperationVariableLabels" preference="1.0"/>\r
+      </binding>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.imagerBinding">\r
                preference="2.0">\r
          </implementation>\r
       </binding>\r
+      <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
+<!--        <implementation class="org.simantics.sysdyn.ui.property.LibraryVariableImager" preference="2.0"/> -->\r
+        <implementation class="org.simantics.sysdyn.ui.property.OperationVariableImager" preference="1.0"/>\r
+      </binding>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.labelDecoratorBinding">\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynOperationBrowser.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynOperationBrowser.java
new file mode 100644 (file)
index 0000000..45f98c0
--- /dev/null
@@ -0,0 +1,17 @@
+package org.simantics.sysdyn.ui.browser;\r
+\r
+import java.util.Collections;\r
+import java.util.Set;\r
+\r
+import org.simantics.browsing.ui.swt.GraphExplorerView;\r
+\r
+public class SysdynOperationBrowser extends GraphExplorerView {\r
+\r
+    final private Set<String> browseContexts = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser");\r
+\r
+    @Override\r
+    protected Set<String> getBrowseContexts() {\r
+        return browseContexts;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelContributor.java
new file mode 100644 (file)
index 0000000..d1fd23f
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.sysdyn.ui.property;\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.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class OperationModelContributor extends ViewpointContributor<OperationModelNode> {\r
+\r
+       @Override\r
+       public Collection<?> getContribution(ReadGraph graph, OperationModelNode model) throws DatabaseException {\r
+               \r
+               Variable modelVariable = model.data;\r
+               Variable config = modelVariable.getChild(graph, "BaseRealization");\r
+               ArrayList<Variable> result = new ArrayList<Variable>();\r
+               result.addAll(config.browseChildren(graph));\r
+               return result;\r
+               \r
+       }\r
+\r
+       @Override\r
+       public String getViewpointId() {\r
+               return "Standard";\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelLabels.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelLabels.java
new file mode 100644 (file)
index 0000000..55fef5e
--- /dev/null
@@ -0,0 +1,23 @@
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor;\r
+import org.simantics.databoard.binding.java.StringBindingDefault;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class OperationModelLabels extends ColumnLabelerContributor<OperationModelNode> {\r
+\r
+    @Override\r
+    public Map<String, String> getLabel(ReadGraph graph, OperationModelNode model) throws DatabaseException {\r
+\r
+        String label = model.data.getPropertyValue(graph, "Name", StringBindingDefault.INSTANCE);\r
+\r
+        return new ArrayMap<String, String>(new String[] { ColumnKeys.SINGLE } , new String[] { label });\r
+\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelNode.java
new file mode 100644 (file)
index 0000000..f6e249a
--- /dev/null
@@ -0,0 +1,21 @@
+package org.simantics.sysdyn.ui.property;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.common.imagers.ImageURLs;\r
+import org.simantics.browsing.ui.common.imagers.SingleImageURLs;\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.sysdyn.ui.Activator;\r
+\r
+public class OperationModelNode extends AbstractNode<Variable> {\r
+\r
+       public OperationModelNode(Variable data) {\r
+               super(data);\r
+       }\r
+\r
+       @Override\r
+       protected ImageURLs getImageURLs() {\r
+               return new SingleImageURLs(ColumnKeys.SINGLE, Activator.getDefaultResource("icons/chart_organisation.png"));\r
+       }\r
+       \r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationProjectContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationProjectContributor.java
new file mode 100644 (file)
index 0000000..af6e5e6
--- /dev/null
@@ -0,0 +1,42 @@
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.Tester;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.browsing.ui.graph.tester.GraphTesters;\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.db.layer0.variable.Variable;\r
+import org.simantics.project.ontology.ProjectResource;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+\r
+public class OperationProjectContributor extends ViewpointContributor<Resource> {\r
+\r
+       @Override\r
+       public Collection<?> getContribution(ReadGraph graph, Resource project) throws DatabaseException {\r
+\r
+               ArrayList<OperationModelNode> result = new ArrayList<OperationModelNode>();\r
+               for(Resource model : graph.syncRequest(new ObjectsWithType(project, b.ConsistsOf, SimulationResource.getInstance(graph).Model))) {\r
+                       result.add(new OperationModelNode(graph.adapt(model, Variable.class)));\r
+               }\r
+               return result;\r
+               \r
+       }\r
+       \r
+       @Override\r
+       public Tester getNodeContextTester() {\r
+               \r
+               return GraphTesters.type(ProjectResource.URIs.Project);\r
+       }\r
+\r
+       @Override\r
+       public String getViewpointId() {\r
+               return "Standard";\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableContributor.java
new file mode 100644 (file)
index 0000000..a87a467
--- /dev/null
@@ -0,0 +1,26 @@
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+public class OperationVariableContributor extends ViewpointContributorImpl<Variable> {\r
+\r
+       @Override\r
+       public Collection<?> getContribution(ReadGraph graph, Variable input) throws DatabaseException {\r
+               ArrayList<Variable> result = new ArrayList<Variable>();\r
+               result.addAll(input.browseProperties(graph));\r
+               result.addAll(input.browseChildren(graph));\r
+               return result;\r
+       }\r
+       \r
+       @Override\r
+       public String getViewpointId() {\r
+               return "Properties";\r
+       }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableImager.java
new file mode 100644 (file)
index 0000000..dbad90e
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.property;\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.db.layer0.variable.Variable;\r
+import org.simantics.modeling.ui.Activator;\r
+\r
+public class OperationVariableImager extends ImagerContributor<Variable> {\r
+\r
+    @Override\r
+    public ImageDescriptor getDescriptor(ReadGraph graph, Variable var) throws DatabaseException {\r
+        return Activator.BULLET_ICON;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java
new file mode 100644 (file)
index 0000000..52162ba
--- /dev/null
@@ -0,0 +1,24 @@
+package org.simantics.sysdyn.ui.property;\r
+\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor;\r
+import org.simantics.databoard.binding.java.StringBindingDefault;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+\r
+public class OperationVariableLabels extends ColumnLabelerContributor<Variable> {\r
+\r
+    @Override\r
+    public Map<String, String> getLabel(ReadGraph graph, Variable variable) throws DatabaseException {\r
+\r
+        String label = variable.getPropertyValue(graph, "Name", StringBindingDefault.INSTANCE);\r
+\r
+        return new ArrayMap<String, String>(new String[] { ColumnKeys.SINGLE } , new String[] { label });\r
+\r
+    }\r
+\r
+}\r