]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Initial version of SVG tab contribution 60/160/3
authorAntti Villberg <antti.villberg@semantum.fi>
Tue, 22 Nov 2016 11:47:55 +0000 (13:47 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Wed, 23 Nov 2016 09:06:41 +0000 (11:06 +0200)
refs #6825

Change-Id: I412379dcd53e307962b807b087cf6e243fe37b03

bundles/org.simantics.modeling.ontology/graph.tg
bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph
bundles/org.simantics.modeling.ontology/src/org/simantics/modeling/ModelingResources.java
bundles/org.simantics.modeling.ui/scl/Simantics/SelectionView/TabContribution/SVG.scl [new file with mode: 0644]
bundles/org.simantics.modeling.ui/scl/Simantics/UI.scl [moved from bundles/org.simantics.modeling/scl/Simantics/UI.scl with 83% similarity]
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGElementComposite.java
bundles/org.simantics.platform.ui.ontology/graph.tg
bundles/org.simantics.platform.ui.ontology/graph/PlatformUI.pgraph
bundles/org.simantics.selectionview/adapters.xml

index 9bfebc390959640226a8ee71108d4441f53e4bca..c76a05c83ecfdf879c26150166f1952a21a90b25 100644 (file)
Binary files a/bundles/org.simantics.modeling.ontology/graph.tg and b/bundles/org.simantics.modeling.ontology/graph.tg differ
index a94c64f2df0c3f95b1e7d133e3f2a021af5bce3e..d026eb2b5a3982f6bf561f49056fe94268d165ad 100644 (file)
@@ -501,5 +501,9 @@ MOD.editorContribution : L0.Template
                 L0.SCLValue.expression %canHandle\r
                 L0.HasValueType "Resource -> <ReadGraph> Boolean"\r
                 \r
+MOD.SVGTabContribution : SEL.SCLTabContribution\r
+  @MOD.scl SEL.SCLTabContribution.instantiate\r
+    "svgTabContribution"\r
+    "() -> <Proc> TabContribution"\r
 \r
       
\ No newline at end of file
index 0c4febf8458bd799aa6421d11bc562253601e232..0bcb5ecdf2e0bf67c1d1e39f78668ba6ecc47abd 100644 (file)
@@ -366,6 +366,7 @@ public class ModelingResources {
     public final Resource SCLTest_test;\r
     public final Resource SCLTest_test_Inverse;\r
     public final Resource SCLValue;\r
+    public final Resource SVGTabContribution;\r
     public final Resource SharedOntology;\r
     public final Resource SourceInformation;\r
     public final Resource SourceInformation_copiedAtRevision;\r
@@ -790,6 +791,7 @@ public class ModelingResources {
         public static final String SCLTest_test = "http://www.simantics.org/Modeling-1.2/SCLTest/test";\r
         public static final String SCLTest_test_Inverse = "http://www.simantics.org/Modeling-1.2/SCLTest/test/Inverse";\r
         public static final String SCLValue = "http://www.simantics.org/Modeling-1.2/SCLValue";\r
+        public static final String SVGTabContribution = "http://www.simantics.org/Modeling-1.2/SVGTabContribution";\r
         public static final String SharedOntology = "http://www.simantics.org/Modeling-1.2/SharedOntology";\r
         public static final String SourceInformation = "http://www.simantics.org/Modeling-1.2/SourceInformation";\r
         public static final String SourceInformation_copiedAtRevision = "http://www.simantics.org/Modeling-1.2/SourceInformation/copiedAtRevision";\r
@@ -1224,6 +1226,7 @@ public class ModelingResources {
         SCLTest_test = getResourceOrNull(graph, URIs.SCLTest_test);\r
         SCLTest_test_Inverse = getResourceOrNull(graph, URIs.SCLTest_test_Inverse);\r
         SCLValue = getResourceOrNull(graph, URIs.SCLValue);\r
+        SVGTabContribution = getResourceOrNull(graph, URIs.SVGTabContribution);\r
         SharedOntology = getResourceOrNull(graph, URIs.SharedOntology);\r
         SourceInformation = getResourceOrNull(graph, URIs.SourceInformation);\r
         SourceInformation_copiedAtRevision = getResourceOrNull(graph, URIs.SourceInformation_copiedAtRevision);\r
diff --git a/bundles/org.simantics.modeling.ui/scl/Simantics/SelectionView/TabContribution/SVG.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/SelectionView/TabContribution/SVG.scl
new file mode 100644 (file)
index 0000000..e41da3c
--- /dev/null
@@ -0,0 +1,5 @@
+include "File"\r
+include "Simantics/SelectionView"\r
+\r
+importJava "org.simantics.modeling.ui.property.svg.SVGElementComposite" where\r
+    svgTabContribution :: () -> <Proc> TabContribution    
\ No newline at end of file
similarity index 83%
rename from bundles/org.simantics.modeling/scl/Simantics/UI.scl
rename to bundles/org.simantics.modeling.ui/scl/Simantics/UI.scl
index 59772c97b2724a2cedddd950a2bf2f1425cb8f25..50bcb305a53993d2460310de1e5fcf0992df30de 100644 (file)
@@ -1,6 +1,6 @@
 include "File"\r
+include "Simantics/SelectionView"\r
 \r
 importJava "org.simantics.modeling.ModelingUtils" where\r
     """Queries for a file using a common file dialog."""\r
     fileDialog :: String -> [(String,String)] -> <Proc> Maybe File\r
-    
\ No newline at end of file
index 58dbf16dafc70a8dea3b15ffc5178d73399b5782..084569f0293870bde66d3469cffe869344b177cf 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/\r
 package org.simantics.modeling.ui.property.svg;\r
 \r
+import java.util.Collection;\r
+\r
 import org.eclipse.jface.dialogs.IInputValidator;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.resource.ColorDescriptor;\r
@@ -24,16 +26,44 @@ import org.simantics.browsing.ui.swt.widgets.DefaultColorProvider;
 import org.simantics.browsing.ui.swt.widgets.Label;\r
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
 import org.simantics.selectionview.ComparableTabContributor;\r
 import org.simantics.selectionview.ConfigurationComposite;\r
+import org.simantics.selectionview.TabContribution;\r
+import org.simantics.ui.selection.WorkbenchSelectionUtils;\r
 \r
 /**\r
  * @author Tuukka Lehtonen\r
  */\r
 public class SVGElementComposite extends ConfigurationComposite {\r
 \r
+       public static TabContribution<Object> svgTabContribution() {\r
+               return new TabContribution<Object>() {\r
+\r
+                       @Override\r
+                       public boolean accept(ReadGraph graph, Object input) throws DatabaseException {\r
+                               Resource res = WorkbenchSelectionUtils.getPossibleResource(input);\r
+                               if(res == null) return false;\r
+                               return graph.isInstanceOf(res, DiagramResource.getInstance(graph).SVGElement);\r
+                       }\r
+\r
+                       @Override\r
+                       public void contribute(ReadGraph graph, Object selection, Collection<ComparableTabContributor> result)\r
+                                       throws DatabaseException {\r
+                               Resource res = WorkbenchSelectionUtils.getPossibleResource(selection);\r
+                               if(res != null) {\r
+                                       if(graph.isInstanceOf(res, DiagramResource.getInstance(graph).SVGElement)) {\r
+                                               result.add(make(res, 100.0, "SVG"));\r
+                                       }\r
+                               }\r
+                       }\r
+               };\r
+       }\r
+       \r
     public static ComparableTabContributor make(Resource input, double priority, String tabLabel) {\r
         return make(new SVGInput(input), priority, tabLabel);\r
     }\r
index 45c711d9cf908a0312c80be0e3585ef25befe1e0..eafb6ec76ba847404f9b0cc19d1c6a9714fa9d4e 100644 (file)
Binary files a/bundles/org.simantics.platform.ui.ontology/graph.tg and b/bundles/org.simantics.platform.ui.ontology/graph.tg differ
index 093fb87e2c5d1272b7e60f3cdac43fdadeff0164..3d3dc3c8aea221cc4c60d1343619207ca35c5743 100644 (file)
@@ -13,6 +13,7 @@ PlatformUI = <http://www.simantics.org/PlatformUI-1.0> : L0.Ontology
     L0.IsLinkedTo SEL
     L0.IsLinkedTo ANNO
     L0.IsLinkedTo TEMPLATE
+    L0.IsLinkedTo MOD
     
 PlatformUI.SCLMain : L0.SCLModule
     L0.SCLModule.definition _ : L0.String
index 4ac4dab26cf0c41d5ae191362bb60f76794a75f6..f1b084282aeaeceae7267df0d5fbbc0f7d264031 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.selectionview.TabContribution">\r               <type uri="http://www.simantics.org/SelectionView-0.0/TypedVariableTabContribution"\r                    class="org.simantics.selectionview.TypedVariableTabContribution">\r                      <graph/>\r                       <this/>\r                </type>\r                <type uri="http://www.simantics.org/SelectionView-0.0/VariableTabContribution"\r                 class="org.simantics.selectionview.VariableTabContribution">\r                   <graph/>\r                       <this/>\r                </type>\r        </target>\r\r\r    <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <type uri="http://www.simantics.org/SelectionViewUI-0.0/VariablePropertyCategoryRule"\r             class="org.simantics.selectionview.VariablePropertyCategoryRule">\r             <graph/>\r             <this/>\r        </type>\r    </target>\r\r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/CategoryNodeLabelRule"\r                  class="org.simantics.selectionview.CategoryNodeLabelRule"/>\r        <type uri="http://www.simantics.org/SelectionViewUI-0.0/StandardPropertySorterRuleType"\r                  class="org.simantics.selectionview.StandardPropertySorterRule">\r                  <this/>\r        </type>\r                  \r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/VariablePropertyLabelRule"\r                  class="org.simantics.selectionview.VariablePropertyLabelRule"/>\r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/VariablePropertyModifierRule"\r                  class="org.simantics.selectionview.VariablePropertyModifierRule"/>\r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/VariableColoringDecorationRule"\r                  class="org.simantics.selectionview.VariableColoringDecorationRule"/>\r    </target>\r\r  <target interface="org.simantics.db.layer0.variable.Variable">\r         <!--<adapter uri="http://www.simantics.org/SelectionView-0.0/StandardPropertyInfo"\r                     contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.PropertyInfoVariableAdapter" />-->\r           <adapter uri="http://www.simantics.org/SelectionView-0.0/DisplayProperty"\r                      contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.DisplayPropertyVariableAdapter" />\r           <adapter uri="http://www.simantics.org/SelectionView-0.0/DisplayValue"\r                 contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.DisplayValueVariableAdapter" />\r              <adapter uri="http://www.simantics.org/SelectionView-0.0/DisplayUnit"\r                  contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.DisplayUnitVariableAdapter" />\r       </target>\r\r
+<adapters>\r\r   <target interface="org.simantics.selectionview.TabContribution">\r               <type uri="http://www.simantics.org/SelectionView-0.0/SCLTabContribution"\r                      class="org.simantics.selectionview.SCLTabContribution">\r                        <graph/>\r                       <this/>\r                </type>\r                <type uri="http://www.simantics.org/SelectionView-0.0/TypedVariableTabContribution"\r                    class="org.simantics.selectionview.TypedVariableTabContribution">\r                      <graph/>\r                       <this/>\r                </type>\r                <type uri="http://www.simantics.org/SelectionView-0.0/VariableTabContribution"\r                 class="org.simantics.selectionview.VariableTabContribution">\r                   <graph/>\r                       <this/>\r                </type>\r        </target>\r\r\r    <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <type uri="http://www.simantics.org/SelectionViewUI-0.0/VariablePropertyCategoryRule"\r             class="org.simantics.selectionview.VariablePropertyCategoryRule">\r             <graph/>\r             <this/>\r        </type>\r    </target>\r\r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/CategoryNodeLabelRule"\r                  class="org.simantics.selectionview.CategoryNodeLabelRule"/>\r        <type uri="http://www.simantics.org/SelectionViewUI-0.0/StandardPropertySorterRuleType"\r                  class="org.simantics.selectionview.StandardPropertySorterRule">\r                  <this/>\r        </type>\r                  \r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/VariablePropertyLabelRule"\r                  class="org.simantics.selectionview.VariablePropertyLabelRule"/>\r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/VariablePropertyModifierRule"\r                  class="org.simantics.selectionview.VariablePropertyModifierRule"/>\r        <resource uri="http://www.simantics.org/SelectionViewUI-0.0/VariableColoringDecorationRule"\r                  class="org.simantics.selectionview.VariableColoringDecorationRule"/>\r    </target>\r\r  <target interface="org.simantics.db.layer0.variable.Variable">\r         <!--<adapter uri="http://www.simantics.org/SelectionView-0.0/StandardPropertyInfo"\r                     contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.PropertyInfoVariableAdapter" />-->\r           <adapter uri="http://www.simantics.org/SelectionView-0.0/DisplayProperty"\r                      contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.DisplayPropertyVariableAdapter" />\r           <adapter uri="http://www.simantics.org/SelectionView-0.0/DisplayValue"\r                 contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.DisplayValueVariableAdapter" />\r              <adapter uri="http://www.simantics.org/SelectionView-0.0/DisplayUnit"\r                  contextClass="org.simantics.db.layer0.variable.ModelledVariablePropertyDescriptor"\r                     adapterClass="org.simantics.selectionview.DisplayUnitVariableAdapter" />\r       </target>\r\r
 </adapters>\r