From: Antti Villberg Date: Tue, 22 Nov 2016 11:47:55 +0000 (+0200) Subject: Initial version of SVG tab contribution X-Git-Tag: v1.25.0~37 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=3363d703decd994069d66740681a72c03ce6acf4;p=simantics%2Fplatform.git Initial version of SVG tab contribution refs #6825 Change-Id: I412379dcd53e307962b807b087cf6e243fe37b03 --- diff --git a/bundles/org.simantics.modeling.ontology/graph.tg b/bundles/org.simantics.modeling.ontology/graph.tg index 9bfebc390..c76a05c83 100644 Binary files a/bundles/org.simantics.modeling.ontology/graph.tg and b/bundles/org.simantics.modeling.ontology/graph.tg differ diff --git a/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph b/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph index a94c64f2d..d026eb2b5 100644 --- a/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph +++ b/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph @@ -501,5 +501,9 @@ MOD.editorContribution : L0.Template L0.SCLValue.expression %canHandle L0.HasValueType "Resource -> Boolean" +MOD.SVGTabContribution : SEL.SCLTabContribution + @MOD.scl SEL.SCLTabContribution.instantiate + "svgTabContribution" + "() -> TabContribution" \ No newline at end of file diff --git a/bundles/org.simantics.modeling.ontology/src/org/simantics/modeling/ModelingResources.java b/bundles/org.simantics.modeling.ontology/src/org/simantics/modeling/ModelingResources.java index 0c4febf84..0bcb5ecdf 100644 --- a/bundles/org.simantics.modeling.ontology/src/org/simantics/modeling/ModelingResources.java +++ b/bundles/org.simantics.modeling.ontology/src/org/simantics/modeling/ModelingResources.java @@ -366,6 +366,7 @@ public class ModelingResources { public final Resource SCLTest_test; public final Resource SCLTest_test_Inverse; public final Resource SCLValue; + public final Resource SVGTabContribution; public final Resource SharedOntology; public final Resource SourceInformation; public final Resource SourceInformation_copiedAtRevision; @@ -790,6 +791,7 @@ public class ModelingResources { public static final String SCLTest_test = "http://www.simantics.org/Modeling-1.2/SCLTest/test"; public static final String SCLTest_test_Inverse = "http://www.simantics.org/Modeling-1.2/SCLTest/test/Inverse"; public static final String SCLValue = "http://www.simantics.org/Modeling-1.2/SCLValue"; + public static final String SVGTabContribution = "http://www.simantics.org/Modeling-1.2/SVGTabContribution"; public static final String SharedOntology = "http://www.simantics.org/Modeling-1.2/SharedOntology"; public static final String SourceInformation = "http://www.simantics.org/Modeling-1.2/SourceInformation"; public static final String SourceInformation_copiedAtRevision = "http://www.simantics.org/Modeling-1.2/SourceInformation/copiedAtRevision"; @@ -1224,6 +1226,7 @@ public class ModelingResources { SCLTest_test = getResourceOrNull(graph, URIs.SCLTest_test); SCLTest_test_Inverse = getResourceOrNull(graph, URIs.SCLTest_test_Inverse); SCLValue = getResourceOrNull(graph, URIs.SCLValue); + SVGTabContribution = getResourceOrNull(graph, URIs.SVGTabContribution); SharedOntology = getResourceOrNull(graph, URIs.SharedOntology); SourceInformation = getResourceOrNull(graph, URIs.SourceInformation); SourceInformation_copiedAtRevision = getResourceOrNull(graph, URIs.SourceInformation_copiedAtRevision); 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 index 000000000..e41da3cea --- /dev/null +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/SelectionView/TabContribution/SVG.scl @@ -0,0 +1,5 @@ +include "File" +include "Simantics/SelectionView" + +importJava "org.simantics.modeling.ui.property.svg.SVGElementComposite" where + svgTabContribution :: () -> TabContribution \ No newline at end of file diff --git a/bundles/org.simantics.modeling/scl/Simantics/UI.scl b/bundles/org.simantics.modeling.ui/scl/Simantics/UI.scl 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 59772c97b..50bcb305a 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/UI.scl +++ b/bundles/org.simantics.modeling.ui/scl/Simantics/UI.scl @@ -1,6 +1,6 @@ include "File" +include "Simantics/SelectionView" importJava "org.simantics.modeling.ModelingUtils" where """Queries for a file using a common file dialog.""" fileDialog :: String -> [(String,String)] -> Maybe File - \ No newline at end of file diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGElementComposite.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGElementComposite.java index 58dbf16da..084569f02 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGElementComposite.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/property/svg/SVGElementComposite.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.simantics.modeling.ui.property.svg; +import java.util.Collection; + import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.resource.ColorDescriptor; @@ -24,16 +26,44 @@ import org.simantics.browsing.ui.swt.widgets.DefaultColorProvider; import org.simantics.browsing.ui.swt.widgets.Label; import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; import org.simantics.db.management.ISessionContext; +import org.simantics.diagram.stubs.DiagramResource; import org.simantics.selectionview.ComparableTabContributor; import org.simantics.selectionview.ConfigurationComposite; +import org.simantics.selectionview.TabContribution; +import org.simantics.ui.selection.WorkbenchSelectionUtils; /** * @author Tuukka Lehtonen */ public class SVGElementComposite extends ConfigurationComposite { + public static TabContribution svgTabContribution() { + return new TabContribution() { + + @Override + public boolean accept(ReadGraph graph, Object input) throws DatabaseException { + Resource res = WorkbenchSelectionUtils.getPossibleResource(input); + if(res == null) return false; + return graph.isInstanceOf(res, DiagramResource.getInstance(graph).SVGElement); + } + + @Override + public void contribute(ReadGraph graph, Object selection, Collection result) + throws DatabaseException { + Resource res = WorkbenchSelectionUtils.getPossibleResource(selection); + if(res != null) { + if(graph.isInstanceOf(res, DiagramResource.getInstance(graph).SVGElement)) { + result.add(make(res, 100.0, "SVG")); + } + } + } + }; + } + public static ComparableTabContributor make(Resource input, double priority, String tabLabel) { return make(new SVGInput(input), priority, tabLabel); } diff --git a/bundles/org.simantics.platform.ui.ontology/graph.tg b/bundles/org.simantics.platform.ui.ontology/graph.tg index 45c711d9c..eafb6ec76 100644 Binary files a/bundles/org.simantics.platform.ui.ontology/graph.tg and b/bundles/org.simantics.platform.ui.ontology/graph.tg differ diff --git a/bundles/org.simantics.platform.ui.ontology/graph/PlatformUI.pgraph b/bundles/org.simantics.platform.ui.ontology/graph/PlatformUI.pgraph index 093fb87e2..3d3dc3c8a 100644 --- a/bundles/org.simantics.platform.ui.ontology/graph/PlatformUI.pgraph +++ b/bundles/org.simantics.platform.ui.ontology/graph/PlatformUI.pgraph @@ -13,6 +13,7 @@ PlatformUI = : L0.Ontology L0.IsLinkedTo SEL L0.IsLinkedTo ANNO L0.IsLinkedTo TEMPLATE + L0.IsLinkedTo MOD PlatformUI.SCLMain : L0.SCLModule L0.SCLModule.definition _ : L0.String diff --git a/bundles/org.simantics.selectionview/adapters.xml b/bundles/org.simantics.selectionview/adapters.xml index 4ac4dab26..f1b084282 100644 --- a/bundles/org.simantics.selectionview/adapters.xml +++ b/bundles/org.simantics.selectionview/adapters.xml @@ -10,5 +10,5 @@ VTT Technical Research Centre of Finland - initial API and implementation --> - +