]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge remote-tracking branch 'origin/svn' 22/22/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 16 Aug 2016 09:33:20 +0000 (12:33 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 16 Aug 2016 09:35:23 +0000 (12:35 +0300)
Change-Id: Iacf80b151f71a6fcfa294fe48d3ed57e6ce72b10

108 files changed:
bundles/org.simantics.datatypes/scl/Simantics/GUID.scl
bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/GraphDebugger.java
bundles/org.simantics.desktop.product/.classpath [new file with mode: 0644]
bundles/org.simantics.desktop.product/.project [new file with mode: 0644]
bundles/org.simantics.desktop.product/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.desktop.product/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.desktop.product/build.properties [new file with mode: 0644]
bundles/org.simantics.desktop.product/plugin.xml [new file with mode: 0644]
bundles/org.simantics.desktop.product/simantics-desktop.product [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/.classpath [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/.project [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/build.properties [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/graph.tg [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/graph/DesktopUI.pgraph [new file with mode: 0644]
bundles/org.simantics.desktop.ui.ontology/graph/scl/SCLMain.scl [new file with mode: 0644]
bundles/org.simantics.desktop.ui/.classpath [new file with mode: 0644]
bundles/org.simantics.desktop.ui/.project [new file with mode: 0644]
bundles/org.simantics.desktop.ui/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.desktop.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.desktop.ui/build.properties [new file with mode: 0644]
bundles/org.simantics.desktop.ui/fragment.e4xmi [new file with mode: 0644]
bundles/org.simantics.desktop.ui/icons/appicon.png [new file with mode: 0644]
bundles/org.simantics.desktop.ui/icons/simantics256.png [new file with mode: 0644]
bundles/org.simantics.desktop.ui/icons/simantics32.png [new file with mode: 0644]
bundles/org.simantics.desktop.ui/plugin.xml [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/Activator.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/DesktopProjectFeature.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportModel.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ImportModel.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ImportSharedLibrary.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/NewModel.java [new file with mode: 0644]
bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/StandardModelledView.java [new file with mode: 0644]
bundles/org.simantics.diagram.svg/.classpath [new file with mode: 0644]
bundles/org.simantics.diagram.svg/.project [new file with mode: 0644]
bundles/org.simantics.diagram.svg/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.diagram.svg/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.diagram.svg/build.properties [new file with mode: 0644]
bundles/org.simantics.diagram.svg/scl/Diagram/svg.scl [new file with mode: 0644]
bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/Activator.java [new file with mode: 0644]
bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/DiagramToSVG.java [new file with mode: 0644]
bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/SVGBuilder.java [new file with mode: 0644]
bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/UniqueIDGenerator.java [new file with mode: 0644]
bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java [new file with mode: 0644]
bundles/org.simantics.document.server/scl/Document/All.scl
bundles/org.simantics.help.base/.classpath [new file with mode: 0644]
bundles/org.simantics.help.base/.project [new file with mode: 0644]
bundles/org.simantics.help.base/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.help.base/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.help.base/build.properties [new file with mode: 0644]
bundles/org.simantics.help.base/fontbox-1.8.10.jar [new file with mode: 0644]
bundles/org.simantics.help.base/jempbox-1.8.10.jar [new file with mode: 0644]
bundles/org.simantics.help.base/pdfbox-1.8.10-src.zip [new file with mode: 0644]
bundles/org.simantics.help.base/pdfbox-1.8.10.jar [new file with mode: 0644]
bundles/org.simantics.help.base/plugin.xml [new file with mode: 0644]
bundles/org.simantics.help.base/src/org/simantics/help/base/internal/Activator.java [new file with mode: 0644]
bundles/org.simantics.help.base/src/org/simantics/help/base/internal/PDFSearchParticipant.java [new file with mode: 0644]
bundles/org.simantics.help.base/src/org/simantics/help/base/internal/PDFUtil.java [new file with mode: 0644]
bundles/org.simantics.help.base/xmpbox-1.8.10.jar [new file with mode: 0644]
bundles/org.simantics.help.core/.classpath [new file with mode: 0644]
bundles/org.simantics.help.core/.project [new file with mode: 0644]
bundles/org.simantics.help.core/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.help.core/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.help.core/build.properties [new file with mode: 0644]
bundles/org.simantics.help.core/css/style.css [new file with mode: 0644]
bundles/org.simantics.help.core/plugin.xml [new file with mode: 0644]
bundles/org.simantics.help.core/scl/Simantics/Help.scl [new file with mode: 0644]
bundles/org.simantics.help.core/src/org/simantics/help/core/Activator.java [new file with mode: 0644]
bundles/org.simantics.help.core/src/org/simantics/help/core/HelpUtils.java [new file with mode: 0644]
bundles/org.simantics.help.core/src/org/simantics/help/core/SimanticsTocProvider.java [new file with mode: 0644]
bundles/org.simantics.help.feature/.project [new file with mode: 0644]
bundles/org.simantics.help.feature/build.properties [new file with mode: 0644]
bundles/org.simantics.help.feature/feature.xml [new file with mode: 0644]
bundles/org.simantics.help.files/.project [new file with mode: 0644]
bundles/org.simantics.help.files/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.help.files/build.properties [new file with mode: 0644]
bundles/org.simantics.help.files/html/style.css [new file with mode: 0644]
bundles/org.simantics.help.ontology/.classpath [new file with mode: 0644]
bundles/org.simantics.help.ontology/.project [new file with mode: 0644]
bundles/org.simantics.help.ontology/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.help.ontology/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.help.ontology/build.properties [new file with mode: 0644]
bundles/org.simantics.help.ontology/graph.tg [new file with mode: 0644]
bundles/org.simantics.help.ontology/graph/Help.pgraph [new file with mode: 0644]
bundles/org.simantics.help.ontology/graph/scl/SCLMain.scl [new file with mode: 0644]
bundles/org.simantics.help.ontology/src/org/simantics/help/HelpResources.java [new file with mode: 0644]
bundles/org.simantics.help.ui/.classpath [new file with mode: 0644]
bundles/org.simantics.help.ui/.project [new file with mode: 0644]
bundles/org.simantics.help.ui/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.help.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.help.ui/build.properties [new file with mode: 0644]
bundles/org.simantics.help.ui/plugin.xml [new file with mode: 0644]
bundles/org.simantics.help.ui/src/org/simantics/help/ui/Activator.java [new file with mode: 0644]
bundles/org.simantics.help.ui/src/org/simantics/help/ui/HelpFileDocumentProvider.java [new file with mode: 0644]
bundles/org.simantics.help.ui/src/org/simantics/help/ui/HelpFileEditor.java [new file with mode: 0644]
bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java [new file with mode: 0644]
bundles/org.simantics.scl.db/scl/Simantics/DB.scl
bundles/org.simantics.scl.db/scl/Simantics/Variables.scl
bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java [new file with mode: 0644]
bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl
features/org.simantics.desktop.feature/.project [new file with mode: 0644]
features/org.simantics.desktop.feature/build.properties [new file with mode: 0644]
features/org.simantics.desktop.feature/feature.xml [new file with mode: 0644]
features/org.simantics.desktop.product.feature/.project [new file with mode: 0644]
features/org.simantics.desktop.product.feature/build.properties [new file with mode: 0644]
features/org.simantics.desktop.product.feature/feature.xml [new file with mode: 0644]

index 99fd4f4a0b9df15cd9e94df6778aa20f65c7fdd2..b6e3ede7922f832e1574bcfd9ba5f8d9e3a71347 100644 (file)
@@ -4,7 +4,11 @@ import "Simantics/Ontologies"
 importJava "org.simantics.datatypes.literal.GUID" where\r
     \r
     data GUID\r
-    \r
+\r
+instance Show GUID where\r
+    show guid = guidIndexString guid\r
+\r
+importJava "org.simantics.datatypes.literal.GUID" where\r
     @JavaName "BINDING"\r
     guidBinding :: Binding a\r
     @JavaName random\r
index ca2fa2190c97a99ef6c029cb63a6b97c9a194fc2..4d2a19dfee2aee2a23f995036fd527aeeb39c902 100644 (file)
@@ -963,8 +963,10 @@ public class GraphDebugger extends Composite {
             Layer0 L0 = Layer0.getInstance(graph);\r
             if (graph.isInstanceOf(r, L0.Assertion)) {\r
                 Resource pred = graph.getSingleObject(r, L0.HasPredicate);\r
-                Resource obj = graph.getSingleObject(r, L0.HasObject);\r
-                String tmp = htmlEscape( getResourceName(graph, pred) + " -> " + getResourceName(graph, obj) + " (Assertion)" );\r
+                // Don't know how I encountered this but it seems to be possible in some cases..\r
+                // Resource obj = graph.getSingleObject(r, L0.HasObject);\r
+                Resource obj = graph.getPossibleObject(r, L0.HasObject);\r
+                String tmp = htmlEscape( getResourceName(graph, pred) + " -> " + (obj == null ? "No object ?" : getResourceName(graph, obj)) + " (Assertion)" );\r
                 name = tmp.substring(0, Math.min(80, tmp.length()));\r
             } else {\r
                 String resourceName = getResourceName(graph, r);\r
diff --git a/bundles/org.simantics.desktop.product/.classpath b/bundles/org.simantics.desktop.product/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.desktop.product/.project b/bundles/org.simantics.desktop.product/.project
new file mode 100644 (file)
index 0000000..9cf5722
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.desktop.product</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.desktop.product/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.desktop.product/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.desktop.product/META-INF/MANIFEST.MF b/bundles/org.simantics.desktop.product/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..030200c
--- /dev/null
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Desktop Product
+Bundle-SymbolicName: org.simantics.desktop.product;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Semantum Oy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/bundles/org.simantics.desktop.product/build.properties b/bundles/org.simantics.desktop.product/build.properties
new file mode 100644 (file)
index 0000000..6f20375
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               plugin.xml\r
diff --git a/bundles/org.simantics.desktop.product/plugin.xml b/bundles/org.simantics.desktop.product/plugin.xml
new file mode 100644 (file)
index 0000000..683c16d
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.4"?>\r
+<plugin>\r
+\r
+   <extension id="desktopProduct"\r
+         point="org.eclipse.core.runtime.products">\r
+      <product\r
+            application="org.simantics.workbench.application"\r
+            description="Simantics Desktop Environment"\r
+            name="Simantics Desktop">\r
+         <property\r
+               name="appName"\r
+               value="Simantics Desktop"/>\r
+         <property\r
+               name="aboutImage"\r
+               value="platform:/plugin/org.simantics.desktop.ui/icons/simantics256.png">\r
+         </property>\r
+         <property\r
+               name="aboutText"\r
+               value="The desktop environment for Simantics products.">\r
+         </property>\r
+         <property\r
+               name="windowImages"\r
+               value="platform:/plugin/org.simantics.desktop.ui/icons/simantics32.png">\r
+         </property>\r
+      </product>   \r
+   </extension>\r
+\r
+</plugin>\r
diff --git a/bundles/org.simantics.desktop.product/simantics-desktop.product b/bundles/org.simantics.desktop.product/simantics-desktop.product
new file mode 100644 (file)
index 0000000..af09f04
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?pde version="3.5"?>\r
+\r
+<product name="Simantics Desktop" uid="org.simantics.desktop.product.desktopProduct" id="org.simantics.desktop.product.desktopProduct" application="org.simantics.workbench.application" version="1.21.0" useFeatures="true" includeLaunchers="true">\r
+\r
+   <aboutInfo>\r
+      <image path="/org.simantics.desktop.ui/icons/simantics256.png"/>\r
+      <text>\r
+         The desktop environment for Simantics products.\r
+      </text>\r
+   </aboutInfo>\r
+\r
+   <configIni use="">\r
+   </configIni>\r
+\r
+   <launcherArgs>\r
+      <programArgs>--launcher.XXMaxPermSize\r
+192m\r
+-fixerrors\r
+-data\r
+@noDefault\r
+-cssTheme\r
+org.eclipse.e4.ui.css.theme.e4_classic\r
+      </programArgs>\r
+      <vmArgs>-ea\r
+-Xmx500M\r
+-Xshare:off\r
+-XX:MaxPermSize=192m\r
+-Djava.net.preferIPv4Stack=true\r
+-Dorg.simantics.workbench.application.showFastViewBars=false\r
+-Dorg.simantics.workbench.application.showPerspectiveBar=false\r
+-Dorg.simantics.workbench.application.excludePerspectiveFromTitle=true\r
+-Declipse.workaround.bug467000=true\r
+      </vmArgs>\r
+      <vmArgsWin>-Dorg.osgi.framework.os.name=win32\r
+      </vmArgsWin>\r
+   </launcherArgs>\r
+\r
+   <windowImages i32="/org.simantics.desktop.ui/icons/simantics32.png"/>\r
+\r
+   <launcher name="Simantics-Desktop">\r
+      <solaris/>\r
+      <win useIco="false">\r
+         <bmp/>\r
+      </win>\r
+   </launcher>\r
+\r
+   <vm>\r
+      <windows include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8</windows>\r
+   </vm>\r
+\r
+   <license>\r
+        <url>http://www.eclipse.org/legal/epl-v10.html</url>\r
+   </license>\r
+\r
+   <plugins>\r
+   </plugins>\r
+\r
+   <features>\r
+      <feature id="org.simantics.desktop.product" version="1.0.0.qualifier"/>\r
+   </features>\r
+\r
+   <preferencesInfo>\r
+      <targetfile overwrite="false"/>\r
+   </preferencesInfo>\r
+\r
+   <cssInfo>\r
+   </cssInfo>\r
+\r
+</product>\r
diff --git a/bundles/org.simantics.desktop.ui.ontology/.classpath b/bundles/org.simantics.desktop.ui.ontology/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.desktop.ui.ontology/.project b/bundles/org.simantics.desktop.ui.ontology/.project
new file mode 100644 (file)
index 0000000..6e56266
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.desktop.ui.ontology</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.simantics.graph.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.simantics.graph.nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.desktop.ui.ontology/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.desktop.ui.ontology/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.desktop.ui.ontology/META-INF/MANIFEST.MF b/bundles/org.simantics.desktop.ui.ontology/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..8790e69
--- /dev/null
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: http://www.simantics.org/DesktopUI
+Bundle-SymbolicName: org.simantics.desktop.ui.ontology
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Semantum Oy
+Require-Bundle: org.simantics.layer0,
+ org.simantics.project.ontology;bundle-version="1.2.0",
+ org.simantics.silk.ontology;bundle-version="1.1.0",
+ org.simantics.viewpoint.ontology;bundle-version="1.2.0",
+ org.simantics.modeling.ontology;bundle-version="1.2.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/bundles/org.simantics.desktop.ui.ontology/build.properties b/bundles/org.simantics.desktop.ui.ontology/build.properties
new file mode 100644 (file)
index 0000000..022de17
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               graph.tg\r
diff --git a/bundles/org.simantics.desktop.ui.ontology/graph.tg b/bundles/org.simantics.desktop.ui.ontology/graph.tg
new file mode 100644 (file)
index 0000000..02d354a
Binary files /dev/null and b/bundles/org.simantics.desktop.ui.ontology/graph.tg differ
diff --git a/bundles/org.simantics.desktop.ui.ontology/graph/DesktopUI.pgraph b/bundles/org.simantics.desktop.ui.ontology/graph/DesktopUI.pgraph
new file mode 100644 (file)
index 0000000..c583c4d
--- /dev/null
@@ -0,0 +1,31 @@
+L0 = <http://www.simantics.org/Layer0-1.1>
+PROJECT = <http://www.simantics.org/Project-1.2>
+SILK = <http://www.simantics.org/Silk-1.1>
+VP = <http://www.simantics.org/Viewpoint-1.2>
+MOD = <http://www.simantics.org/Modeling-1.2>
+
+DesktopUI = <http://www.simantics.org/DesktopUI-1.0> : L0.Ontology
+    @L0.new
+
+DesktopUI.SCLMain : L0.SCLModule
+  L0.SCLModule.definition _ : L0.String
+      @L0.loadString "scl/SCLMain.scl"
+
+DesktopUI.BrowseContext : VP.BrowseContext
+    VP.BrowseContext.Includes PROJECT.ProjectBrowseContext
+    VP.BrowseContext.HasChildContribution MOD.Contributions.ModelLibraries
+
+DesktopUI.FileMenuNewActionContext : VP.BrowseContext
+    VP.BrowseContext.IsIncludedIn PROJECT.ProjectFileMenuNewActionContext
+    VP.BrowseContext.HasActionContribution _ : VP.ActionContribution
+        L0.HasLabel "Shared Library"
+        VP.ActionContribution.HasImage SILK.folder
+        VP.ActionContribution.HasCategory VP.EditActionCategory
+        VP.ActionContribution.HasNodeType PROJECT.Project
+        VP.ActionContribution.HasAction ACTIONS.NewSharedLibrary
+
+ACTIONS = DesktopUI.Actions : L0.Library
+
+ACTIONS.NewSharedLibrary
+  @MOD.sclAction "newSharedLibraryAction"
+        
\ No newline at end of file
diff --git a/bundles/org.simantics.desktop.ui.ontology/graph/scl/SCLMain.scl b/bundles/org.simantics.desktop.ui.ontology/graph/scl/SCLMain.scl
new file mode 100644 (file)
index 0000000..f48a765
--- /dev/null
@@ -0,0 +1,6 @@
+include "Simantics/All"\r
+\r
+newSharedLibraryAction :: Resource -> <Proc> ()\r
+newSharedLibraryAction res = do\r
+  syncWrite (\() -> createSharedOntologyWithUI L0.SharedOntology)\r
+  ()\r
diff --git a/bundles/org.simantics.desktop.ui/.classpath b/bundles/org.simantics.desktop.ui/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.desktop.ui/.project b/bundles/org.simantics.desktop.ui/.project
new file mode 100644 (file)
index 0000000..69ab42f
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.desktop.ui</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.desktop.ui/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.desktop.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.desktop.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.desktop.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..28c6e20
--- /dev/null
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Desktop UI
+Bundle-SymbolicName: org.simantics.desktop.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.desktop.ui.internal.Activator
+Bundle-Vendor: Semantum Oy
+Require-Bundle: org.simantics.workbench;bundle-version="1.5.1",
+ org.eclipse.epp.mpc.core;bundle-version="1.1.1",
+ org.eclipse.epp.mpc.help.ui;bundle-version="1.1.1",
+ org.eclipse.epp.mpc.ui;bundle-version="1.1.1",
+ org.eclipse.ui.browser;bundle-version="3.3.100",
+ org.simantics.platform.ui.ontology;bundle-version="1.0.0",
+ org.simantics.spreadsheet.ontology;bundle-version="1.2.0",
+ org.simantics.spreadsheet.common;bundle-version="1.1.0",
+ org.simantics.selectionview;bundle-version="1.0.0",
+ org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100.v20150407-1430",
+ org.simantics.spreadsheet.graph,
+ org.simantics.spreadsheet;bundle-version="1.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
diff --git a/bundles/org.simantics.desktop.ui/build.properties b/bundles/org.simantics.desktop.ui/build.properties
new file mode 100644 (file)
index 0000000..5de1261
--- /dev/null
@@ -0,0 +1,9 @@
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               plugin.xml,\\r
+               icons/appicon.png,\\r
+               icons/simantics256.png,\\r
+               icons/simantics32.png,\\r
+               fragment.e4xmi\r
+source.. = src/\r
diff --git a/bundles/org.simantics.desktop.ui/fragment.e4xmi b/bundles/org.simantics.desktop.ui/fragment.e4xmi
new file mode 100644 (file)
index 0000000..64c4315
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="ASCII"?>\r
+<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_2RrQgMTrEeWlteepFBDbRQ">\r
+  <imports xsi:type="basic:TrimBar" xmi:id="_UrNgIMT_EeWlteepFBDbRQ" elementId="org.eclipse.ui.main.toolbar"/>\r
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_fZeBUMT5EeWlteepFBDbRQ" featurename="trimContributions" parentElementId="xpath:/">\r
+    <elements xsi:type="menu:TrimContribution" xmi:id="_f8QlUMT5EeWlteepFBDbRQ" elementId="org.simantics.desktop.ui.trim.modeledToolbar" parentId="org.eclipse.ui.main.toolbar" positionInParent="after=additions">\r
+      <children xsi:type="menu:ToolBar" xmi:id="_gP22wMT5EeWlteepFBDbRQ" elementId="org.simantics.desktop.ui.toolbar.modeled">\r
+        <children xsi:type="menu:ToolControl" xmi:id="_gnD10MT5EeWlteepFBDbRQ" elementId="org.simantics.desktop.ui.toolcontrol.modeled" contributionURI="bundleclass://org.simantics.modeling.ui/org.simantics.modeling.ui.actions.e4.GlobalModeledToolbarActions">\r
+          <tags>http://www.simantics.org/Project-1.2/MainToolbarActionContext</tags>\r
+        </children>\r
+      </children>\r
+    </elements>\r
+  </fragments>\r
+</fragment:ModelFragments>\r
diff --git a/bundles/org.simantics.desktop.ui/icons/appicon.png b/bundles/org.simantics.desktop.ui/icons/appicon.png
new file mode 100644 (file)
index 0000000..1dee9e3
Binary files /dev/null and b/bundles/org.simantics.desktop.ui/icons/appicon.png differ
diff --git a/bundles/org.simantics.desktop.ui/icons/simantics256.png b/bundles/org.simantics.desktop.ui/icons/simantics256.png
new file mode 100644 (file)
index 0000000..17e9f21
Binary files /dev/null and b/bundles/org.simantics.desktop.ui/icons/simantics256.png differ
diff --git a/bundles/org.simantics.desktop.ui/icons/simantics32.png b/bundles/org.simantics.desktop.ui/icons/simantics32.png
new file mode 100644 (file)
index 0000000..04738fd
Binary files /dev/null and b/bundles/org.simantics.desktop.ui/icons/simantics32.png differ
diff --git a/bundles/org.simantics.desktop.ui/plugin.xml b/bundles/org.simantics.desktop.ui/plugin.xml
new file mode 100644 (file)
index 0000000..a3df92f
--- /dev/null
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<plugin>\r
+\r
+   <extension\r
+         point="org.eclipse.ui.perspectives">\r
+      <perspective\r
+            name="Modelling"\r
+            fixed="false"\r
+            class="org.simantics.workbench.Perspective"\r
+            id="org.simantics.desktop.modelling.perspective">\r
+      </perspective>\r
+   </extension>\r
+   <extension\r
+         point="org.simantics.project.feature">\r
+      <feature\r
+            label="Desktop"\r
+            description="Desktop product project feature."\r
+            class="org.simantics.desktop.ui.internal.DesktopProjectFeature"\r
+            published="true"\r
+            id="org.simantics.desktop.ui">\r
+         <installGroup\r
+               version="[1.0.0,2.0.0)"\r
+               id="omnipresent">\r
+         </installGroup>\r
+      </feature>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.perspectiveExtensions">\r
+      <perspectiveExtension\r
+            targetID="org.simantics.desktop.modelling.perspective">\r
+         <view\r
+               minimized="true"\r
+               ratio="0.20"\r
+               relative="org.eclipse.ui.editorss"\r
+               closeable="true"\r
+               visible="true"\r
+               id="org.simantics.modeling.ui.browser"\r
+               relationship="left">\r
+         </view>\r
+         <view\r
+               minimized="false"\r
+               ratio="0.5"\r
+               relative="org.simantics.modeling.ui.browser"\r
+               closeable="true"\r
+               visible="true"\r
+               id="org.simantics.browsing.ui.graph.propertyView"\r
+               relationship="bottom">\r
+         </view>\r
+      </perspectiveExtension>\r
+   </extension>\r
+   <!--\r
+   <extension\r
+         point="org.eclipse.epp.mpc.ui.catalog">\r
+      <catalog\r
+            label="Simantics Marketplace"\r
+            url="http://dev.simantics.org:8070/marketplace/"\r
+            icon="icons/simantics32.png"\r
+            description="Marketplace for installing simulation components for Simantics.">\r
+      </catalog>\r
+   </extension>\r
+   -->\r
+   <extension\r
+         point="org.eclipse.ui.views">\r
+      <category\r
+            name="Modeling"\r
+            id="org.simantics.modeling.ui.category">\r
+      </category>\r
+      <view\r
+            name="Model Browser"\r
+            icon="platform:/plugin/com.famfamfam.silk/icons/chart_organisation.png"\r
+            category="org.simantics.modeling.category"\r
+            class="org.simantics.desktop.ui.internal.StandardModelledView:configurationURI=http://www.simantics.org/Modeling-1.2/PlainModelBrowser"\r
+            restorable="true"\r
+            id="org.simantics.modeling.ui.browser">\r
+      </view>\r
+   </extension>\r
+   <extension\r
+         point="org.simantics.ui.doubleClick">\r
+      <doubleClickAction\r
+            name="Modeled Double Click"\r
+            priority="1.0"\r
+            class="org.simantics.modeling.ui.actions.ModeledDoubleClickActions">\r
+      </doubleClickAction>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.menus">\r
+      <menuContribution\r
+            locationURI="menu:sFile?after=import.ext">\r
+         <command\r
+               commandId="org.eclipse.ui.file.import">\r
+         </command>\r
+         <command\r
+               commandId="org.eclipse.ui.file.export">\r
+         </command>\r
+      </menuContribution>\r
+      <menuContribution\r
+            allPopups="false"\r
+            locationURI="menu:#FileNewMenu">\r
+         <dynamic\r
+               class="org.simantics.modeling.ui.actions.GlobalModeledActions:context=http://www.simantics.org/Project-1.2/ProjectFileMenuNewActionContext"\r
+               id="org.simantics.desktop.ui.fileMenuNew.modeledActions">\r
+         </dynamic>\r
+      </menuContribution>\r
+      <menuContribution\r
+            allPopups="false"\r
+            locationURI="menu:sFile">\r
+         <dynamic\r
+               class="org.simantics.modeling.ui.actions.GlobalModeledActions:context=http://www.simantics.org/Project-1.2/ProjectFileMenuActionContext"\r
+               id="org.simantics.desktop.ui.fileMenu.modeledActions">\r
+         </dynamic>\r
+      </menuContribution>\r
+      <menuContribution\r
+            locationURI="popup:#ModelBrowserPopup">\r
+         <separator\r
+               name="new.begin"\r
+               visible="false">\r
+         </separator>\r
+         <separator\r
+               name="new.ext"\r
+               visible="false">\r
+         </separator>\r
+         <separator\r
+               name="new.end"\r
+               visible="true">\r
+         </separator>\r
+         <dynamic\r
+               class="org.simantics.modeling.ui.actions.ModeledActions"\r
+               id="org.simantics.desktop.ui.modeledActions">\r
+         </dynamic>\r
+         <dynamic\r
+               class="org.simantics.ui.contribution.OpenWithMenuContribution"\r
+               id="openWith">\r
+         </dynamic>\r
+         <command\r
+               commandId="org.simantics.browsing.ui.common.collapseAll"\r
+               label="Collapse All"\r
+               icon="platform:/plugin/org.simantics.browsing.ui.common/icons/collapseall.png"\r
+               style="push"\r
+               tooltip="Collapse All">\r
+         </command>\r
+         <command\r
+               commandId="org.simantics.browsing.ui.common.collapseSelected"\r
+               label="Collapse Selected"\r
+               icon="platform:/plugin/org.simantics.browsing.ui.common/icons/collapse.png"\r
+               style="push"\r
+               tooltip="Collapse Selected">\r
+            <visibleWhen\r
+                  checkEnabled="false">\r
+               <with\r
+                     variable="selection">\r
+                   <count\r
+                         value="(0-">\r
+                   </count>\r
+               </with>\r
+            </visibleWhen>\r
+         </command>\r
+      </menuContribution>\r
+   </extension>\r
+   <extension\r
+         id="org.simantics.desktop.ui.fragment"\r
+         point="org.eclipse.e4.workbench.model">\r
+      <fragment\r
+            uri="fragment.e4xmi">\r
+      </fragment>\r
+   </extension>\r
+\r
+</plugin>\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/Activator.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/Activator.java
new file mode 100644 (file)
index 0000000..ed2301f
--- /dev/null
@@ -0,0 +1,50 @@
+package org.simantics.desktop.ui.internal;\r
+\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+\r
+/**\r
+ * The activator class controls the plug-in life cycle\r
+ */\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+       // The plug-in ID\r
+       public static final String PLUGIN_ID = "org.simantics.desktop.ui"; //$NON-NLS-1$\r
+\r
+       // The shared instance\r
+       private static Activator plugin;\r
+       \r
+       /**\r
+        * The constructor\r
+        */\r
+       public Activator() {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext context) throws Exception {\r
+               super.start(context);\r
+               plugin = this;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext context) throws Exception {\r
+               plugin = null;\r
+               super.stop(context);\r
+       }\r
+\r
+       /**\r
+        * Returns the shared instance\r
+        *\r
+        * @return the shared instance\r
+        */\r
+       public static Activator getDefault() {\r
+               return plugin;\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/DesktopProjectFeature.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/DesktopProjectFeature.java
new file mode 100644 (file)
index 0000000..ca638ce
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\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.desktop.ui.internal;\r
+\r
+import org.simantics.project.ProjectKeys;\r
+import org.simantics.project.exception.ProjectException;\r
+import org.simantics.project.features.AbstractProjectFeature;\r
+\r
+public class DesktopProjectFeature extends AbstractProjectFeature {\r
+\r
+    private static final String DEFAULT_PERSPECTIVE = "org.simantics.desktop.modelling.perspective";\r
+\r
+    @Override\r
+    public void configure() throws ProjectException {\r
+       \r
+       Object existing = getProjectElement().getHint(ProjectKeys.DEFAULT_PERSPECTIVE);\r
+       if(existing == null)\r
+               getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
+\r
+    }\r
+\r
+    @Override\r
+    public void deconfigure() throws ProjectException {\r
+       \r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportModel.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportModel.java
new file mode 100644 (file)
index 0000000..3cb96a6
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * 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.desktop.ui.internal;\r
+\r
+import java.util.Collection;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.simantics.Simantics;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.db.layer0.request.ProjectModels;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+\r
+public class ExportModel extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        \r
+       try {\r
+               \r
+                       Resource lib = Simantics.sync(new UniqueRead<Resource>() {\r
+\r
+                               @Override\r
+                               public Resource perform(ReadGraph graph) throws DatabaseException {\r
+                                       Collection<Resource> models = graph.sync(new ProjectModels(Simantics.getProjectResource()));\r
+                                       if(models.size() == 1) return models.iterator().next();\r
+                                       return null;\r
+                               }\r
+                               \r
+                       });\r
+                       if(lib == null) return null;\r
+                       \r
+            IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+            context.setHint(SelectionHints.KEY_MAIN, lib);\r
+\r
+                       IStructuredSelection sel = new StructuredSelection(context);\r
+               ModelingUtils.openWizard(Display.getCurrent(), sel, "org.simantics.modeling.ui.modelExportWizard");\r
+               } catch (DatabaseException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
+               }\r
+       \r
+       return null;\r
+        \r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ExportSharedLibrary.java
new file mode 100644 (file)
index 0000000..cbc6d06
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * 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.desktop.ui.internal;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.simantics.Simantics;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.SelectionHints;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.scl.runtime.tuple.Tuple0;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+\r
+public class ExportSharedLibrary extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        \r
+       try {\r
+                       Resource lib = Simantics.sync(new UniqueRead<Resource>() {\r
+\r
+                               @Override\r
+                               public Resource perform(ReadGraph graph) throws DatabaseException {\r
+                                       List<Resource> ontologies =  Simantics.applySCL("Simantics/SharedOntologies", "getSharedOntologies", graph, Tuple0.INSTANCE);\r
+                                       if(ontologies.size() == 1) return ontologies.iterator().next();\r
+                                       return null;\r
+                               }\r
+                               \r
+                       });\r
+                       if(lib == null) return null;\r
+                       \r
+            IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+            context.setHint(SelectionHints.KEY_MAIN, lib);\r
+\r
+                       IStructuredSelection sel = new StructuredSelection(context);\r
+               ModelingUtils.openWizard(Display.getCurrent(), sel, "org.simantics.modeling.ui.sharedOntologyExportWizard");\r
+               } catch (DatabaseException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
+               }\r
+       \r
+       return null;\r
+        \r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ImportModel.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ImportModel.java
new file mode 100644 (file)
index 0000000..42a21d7
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * 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.desktop.ui.internal;\r
+\r
+import java.io.File;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.core.runtime.jobs.Job;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.DatabaseJob;\r
+import org.simantics.modeling.ModelingUtils;\r
+\r
+public class ImportModel extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        \r
+        // Get imported transferable graph file using FileDialog\r
+        Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+        FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+        fd.setText("Import Model");\r
+\r
+        String path = Activator.getDefault().getPreferenceStore().getString("IMPORT_MODEL_PATH");\r
+        if(path.isEmpty() || !(new File(path).exists())){\r
+               path = System.getProperty("user.dir");\r
+        }\r
+        \r
+        fd.setFilterPath(path);\r
+        String[] filterExt = {"*.tg", "*.*"};\r
+        fd.setFilterExtensions(filterExt);\r
+        final String selected = fd.open();\r
+        if(selected == null) return null;\r
+\r
+        Job job = new DatabaseJob("Import model") {\r
+\r
+            @Override\r
+            protected IStatus run(IProgressMonitor monitor) {\r
+                ModelingUtils.importModel(selected);\r
+                return Status.OK_STATUS;\r
+            }\r
+        };\r
+        \r
+        job.setUser(true);\r
+        job.schedule();\r
+\r
+        return null;\r
+        \r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ImportSharedLibrary.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/ImportSharedLibrary.java
new file mode 100644 (file)
index 0000000..f9015e8
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * 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.desktop.ui.internal;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.simantics.modeling.ModelingUtils;\r
+\r
+public class ImportSharedLibrary extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        \r
+               IStructuredSelection sel = new StructuredSelection();\r
+       ModelingUtils.openWizard(Display.getCurrent(), sel, "org.simantics.modeling.ui.sharedOntologyImportWizard");\r
+       return null;\r
+        \r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/NewModel.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/NewModel.java
new file mode 100644 (file)
index 0000000..d6236ec
--- /dev/null
@@ -0,0 +1,78 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * 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.desktop.ui.internal;\r
+\r
+ import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.core.runtime.jobs.Job;\r
+import org.simantics.DatabaseJob;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.request.Configuration;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.platform.ui.PlatformUIResource;\r
+import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils;\r
+import org.simantics.spreadsheet.util.SpreadsheetUtils;\r
+\r
+public class NewModel extends AbstractHandler {\r
+\r
+    public static Resource execute(WriteGraph graph) throws DatabaseException {\r
+        PlatformUIResource PLATFORM = PlatformUIResource.getInstance(graph);\r
+        return execute(graph, PLATFORM.Model, null);\r
+    }\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        Job job = new DatabaseJob("Creating Model") {\r
+            @Override\r
+            protected IStatus run(IProgressMonitor monitor) {\r
+                try {\r
+                    Simantics.sync(new WriteRequest() {\r
+                        @Override\r
+                        public void perform(WriteGraph graph) throws DatabaseException {\r
+                            execute(graph);\r
+                        }\r
+                    });\r
+                    return Status.OK_STATUS;\r
+                } catch (DatabaseException e) {\r
+                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, getName() + " failed.", e);\r
+                }\r
+            }\r
+        };\r
+        job.setUser(true);\r
+        job.schedule();\r
+        return null;\r
+    }\r
+\r
+    public static Resource execute(WriteGraph graph, Resource type, String name) throws DatabaseException {\r
+        Resource model = ModelingUtils.createModel(graph, type, name);\r
+        Resource conf = graph.syncRequest(new Configuration(model));\r
+\r
+        ModelingUtils.addSCLMainToModel(graph, model, "SCLMain", "");\r
+        ModelingUtils.createLocalLibrary(graph, model, "Library");\r
+\r
+        Resource book = SpreadsheetGraphUtils.createBook(graph, conf, "Book1");\r
+        SpreadsheetUtils.createSheet(graph, book, "Sheet1", new String[] { }, new int[] { 50 });\r
+        SpreadsheetUtils.createSheet(graph, book, "Sheet2", new String[] { }, new int[] { 50 });\r
+        SpreadsheetUtils.createSheet(graph, book, "Sheet3", new String[] { }, new int[] { 50 });\r
+\r
+        return model;\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/StandardModelledView.java b/bundles/org.simantics.desktop.ui/src/org/simantics/desktop/ui/internal/StandardModelledView.java
new file mode 100644 (file)
index 0000000..3b70673
--- /dev/null
@@ -0,0 +1,14 @@
+package org.simantics.desktop.ui.internal;\r
+\r
+import org.simantics.selectionview.StandardPropertyPage;\r
+import org.simantics.ui.workbench.IPropertyPage;\r
+import org.simantics.views.swt.ModelledView;\r
+\r
+public class StandardModelledView extends ModelledView {\r
+\r
+    @Override\r
+    protected IPropertyPage getPropertyPage() {\r
+        return new StandardPropertyPage(getSite());\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.diagram.svg/.classpath b/bundles/org.simantics.diagram.svg/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.diagram.svg/.project b/bundles/org.simantics.diagram.svg/.project
new file mode 100644 (file)
index 0000000..30169e2
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.diagram.svg</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.diagram.svg/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.diagram.svg/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.diagram.svg/META-INF/MANIFEST.MF b/bundles/org.simantics.diagram.svg/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..13a372c
--- /dev/null
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Svg
+Bundle-SymbolicName: org.simantics.diagram.svg
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.diagram.svg.Activator
+Bundle-Vendor: VTT
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.simantics;bundle-version="1.0.0",
+ org.simantics.diagram;bundle-version="1.1.1",
+ org.simantics.diagram.ontology;bundle-version="2.2.0",
+ org.simantics.db.management;bundle-version="1.1.0",
+ org.simantics.structural.ontology;bundle-version="1.2.0",
+ org.simantics.structural2;bundle-version="1.1.1",
+ org.apache.batik;bundle-version="1.8.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.diagram.svg.export
diff --git a/bundles/org.simantics.diagram.svg/build.properties b/bundles/org.simantics.diagram.svg/build.properties
new file mode 100644 (file)
index 0000000..6092d89
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               scl/\r
diff --git a/bundles/org.simantics.diagram.svg/scl/Diagram/svg.scl b/bundles/org.simantics.diagram.svg/scl/Diagram/svg.scl
new file mode 100644 (file)
index 0000000..1f68516
--- /dev/null
@@ -0,0 +1,8 @@
+import "Simantics/DB"\r
+\r
+importJava "org.simantics.diagram.svg.export.DiagramToSVG" where\r
+   diagramToSVG :: Resource -> <Proc> String\r
+   @JavaName diagramToSVG\r
+   diagramToSVGdpi :: Resource -> Double -> <Proc> String\r
+   @JavaName diagramToSVG\r
+   diagramToSVGsize :: Resource -> Integer -> Integer -> <Proc> String
\ No newline at end of file
diff --git a/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/Activator.java b/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/Activator.java
new file mode 100644 (file)
index 0000000..b2607e8
--- /dev/null
@@ -0,0 +1,50 @@
+package org.simantics.diagram.svg;\r
+\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+\r
+/**\r
+ * The activator class controls the plug-in life cycle\r
+ */\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+       // The plug-in ID\r
+       public static final String PLUGIN_ID = "org.simantics.diagram.svg"; //$NON-NLS-1$\r
+\r
+       // The shared instance\r
+       private static Activator plugin;\r
+       \r
+       /**\r
+        * The constructor\r
+        */\r
+       public Activator() {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext context) throws Exception {\r
+               super.start(context);\r
+               plugin = this;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext context) throws Exception {\r
+               plugin = null;\r
+               super.stop(context);\r
+       }\r
+\r
+       /**\r
+        * Returns the shared instance\r
+        *\r
+        * @return the shared instance\r
+        */\r
+       public static Activator getDefault() {\r
+               return plugin;\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/DiagramToSVG.java b/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/DiagramToSVG.java
new file mode 100644 (file)
index 0000000..636a246
--- /dev/null
@@ -0,0 +1,216 @@
+package org.simantics.diagram.svg.export;\r
+\r
+\r
+import java.awt.Point;\r
+import java.util.concurrent.Semaphore;\r
+import java.util.concurrent.atomic.AtomicReference;\r
+\r
+import org.apache.batik.svggen.SVGGraphics2D;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.ResourceArray;\r
+import org.simantics.db.common.request.PossibleIndexRoot;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.diagram.elements.DiagramNodeUtil;\r
+import org.simantics.diagram.export.ImagePrinter;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.g2d.canvas.impl.CanvasContext;\r
+import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.StructuralVariables;\r
+import org.simantics.utils.DataContainer;\r
+import org.simantics.utils.datastructures.Pair;\r
+import org.simantics.utils.page.MarginUtils.Margins;\r
+import org.simantics.utils.threads.ThreadUtils;\r
+import org.simantics.utils.threads.WorkerThread;\r
+\r
+\r
+public class DiagramToSVG {\r
+       \r
+       \r
+       public static String diagramToSVG(Resource diagram) {\r
+\r
+               try {\r
+                       ImagePrinter.ImageExportPlan exportPlan = new ImagePrinter.ImageExportPlan();\r
+                       exportPlan.margin = 0.05;\r
+                       exportPlan.dpi = 96.0;\r
+                       exportPlan.diagram = diagram;\r
+                       return render(diagram,exportPlan);\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+                       return "<b>error</b> "+ e.getMessage();\r
+               }\r
\r
+               \r
+       }\r
+       \r
+       public static String diagramToSVG(Resource diagram, int width, int height) {\r
+\r
+               try {\r
+                       ImagePrinter.ImageExportPlan exportPlan = new ImagePrinter.ImageExportPlan();\r
+                       exportPlan.margin = 0.05;\r
+                       exportPlan.size = new Point(width, height);\r
+                       exportPlan.diagram = diagram;\r
+                       return render(diagram,exportPlan);\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+                       return "<b>error</b> "+ e.getMessage();\r
+               }\r
\r
+               \r
+       }\r
+       \r
+       public static String diagramToSVG(Resource diagram, double dpi) {\r
+\r
+               try {\r
+                       ImagePrinter.ImageExportPlan exportPlan = new ImagePrinter.ImageExportPlan();\r
+                       exportPlan.margin = 0.05;\r
+                       exportPlan.dpi = dpi;\r
+                       exportPlan.diagram = diagram;\r
+                       return render(diagram,exportPlan);\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+                       return "<b>error</b> "+ e.getMessage();\r
+               }\r
\r
+               \r
+       }\r
+       \r
+       public static String diagramToSVG(Resource diagram, ImagePrinter.ImageExportPlan exportPlan, Margins margins, SVGGraphics2D svgGenerator) {\r
+\r
+               try {\r
+                       return render(diagram,exportPlan,margins,svgGenerator);\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+                       return "<b>error</b> "+ e.getMessage();\r
+               }\r
+               \r
+       }\r
+       \r
+       private static String render(final Resource input, final ImagePrinter.ImageExportPlan exportPlan) throws Exception {\r
+               return render(input, exportPlan, null, SVGBuilder.defaultSVGGenerator()); \r
+       }\r
+       \r
+       private static String render(final Resource input, final ImagePrinter.ImageExportPlan exportPlan, Margins margins, SVGGraphics2D svgExporter) throws Exception {\r
+               Resource diagram = Simantics.getSession().syncRequest(new Read<Resource>() {\r
+                       @Override\r
+                       public Resource perform(ReadGraph graph) throws DatabaseException {\r
+                               DiagramResource DIA = DiagramResource.getInstance(graph);\r
+                               if (graph.isInstanceOf(input, DIA.Diagram))\r
+                                       return input;\r
+                               StructuralResource2 SR = StructuralResource2.getInstance(graph);\r
+                               ModelingResources MOD = ModelingResources.getInstance(graph);\r
+                               Layer0 L0 = Layer0.getInstance(graph);\r
+                               if (graph.isInstanceOf(input, SR.Composite)) {\r
+                                       Resource possibleDiagram = graph.getPossibleObject(input, MOD.CompositeToDiagram);\r
+                                       if (possibleDiagram != null)\r
+                                               return possibleDiagram;\r
+                                       for (Resource r : graph.getObjects(input, L0.ConsistsOf)) {\r
+                                               if (graph.isInstanceOf(r, SR.Composite)) {\r
+                                                       possibleDiagram = graph.getPossibleObject(input, MOD.CompositeToDiagram);\r
+                                                       if (possibleDiagram != null)\r
+                                                               return possibleDiagram;\r
+                                               }\r
+                                       }\r
+                               }\r
+                               return null;\r
+                       }\r
+               });\r
+               if (diagram == null)\r
+                       throw new DatabaseException("Input " + input + " cannot be resolved as diagram");\r
+               \r
+               \r
+       \r
+               \r
+               final WorkerThread thread = new WorkerThread("Diagram Image Painter");\r
+               thread.start();\r
+               \r
+        final CanvasContext ctx = new CanvasContext(thread);\r
+        final AtomicReference<ICanvasSceneGraphProvider> sgProvider = new AtomicReference<ICanvasSceneGraphProvider>();\r
+               final ISessionContext sessionContext = Simantics.getSessionContext();\r
+               final DataContainer<String> result = new DataContainer<String>(null);\r
+               final DataContainer<Exception> exception = new DataContainer<Exception>(null);\r
+        try {\r
+            final Semaphore done = new Semaphore(0);\r
+            // IMPORTANT: Load diagram in a different thread than the canvas context thread!\r
+            ThreadUtils.getBlockingWorkExecutor().execute(new Runnable() {\r
+                @Override\r
+                public void run() {\r
+                    try {\r
+                        Pair<Resource, String> modelAndRVI = sessionContext.getSession().syncRequest(new UniqueRead<Pair<Resource, String>>() {\r
+                            @Override\r
+                            public Pair<Resource, String> perform(ReadGraph graph) throws DatabaseException {\r
+                                return new Pair<Resource, String>( resolveModel(graph, exportPlan.diagram ), resolveRVI(graph, exportPlan.diagram) );\r
+                            }\r
+                        });\r
+\r
+                        ICanvasSceneGraphProvider provider = DiagramNodeUtil.loadSceneGraphProvider(ctx, modelAndRVI.first, exportPlan.diagram, modelAndRVI.second);\r
+                        sgProvider.set( provider );\r
+                        \r
+                        ThreadUtils.asyncExec(thread, new Runnable() {\r
+                            @Override\r
+                            public void run() {\r
+                                try {\r
+                                    SVGBuilder chassis = margins != null ?\r
+                                               new SVGBuilder(exportPlan.dpi,exportPlan.size,margins) :\r
+                                               new SVGBuilder(exportPlan.dpi,exportPlan.size,exportPlan.margin);\r
+                                    \r
+                                    result.set(chassis.paint(ctx, svgExporter));\r
+                                } catch (Exception e) {\r
+                                       exception.set(e);\r
+                                } finally {\r
+                                    done.release();\r
+                                }\r
+                            }\r
+                        });\r
+                    } catch (DatabaseException e) {\r
+                       exception.set(e);\r
+                        done.release();\r
+                    } catch (Throwable e) {\r
+                       exception.set(new DatabaseException(e));\r
+                        done.release();\r
+                    } finally {\r
+                        done.release();\r
+                    }\r
+                }\r
+            });\r
+\r
+            done.acquire(2);\r
+            if (exception.get() != null)\r
+                throw exception.get();\r
+            return result.get();\r
+        } finally {\r
+            if (sgProvider.get() != null)\r
+                sgProvider.get().dispose();\r
+            ctx.dispose();\r
+        }\r
+       }\r
+       \r
+       private static Resource resolveModel(ReadGraph graph, Resource diagram) throws DatabaseException {\r
+       ModelingResources mod = ModelingResources.getInstance(graph);\r
+        Resource composite = graph.getSingleObject(diagram, mod.DiagramToComposite);\r
+        Resource model = graph.syncRequest(new PossibleIndexRoot(composite));\r
+        if (model == null)\r
+            throw new ValidationException("no model found for composite " + NameUtils.getSafeName(graph, composite));\r
+        return model;\r
+    }\r
+\r
+\r
+\r
+    private static String resolveRVI(ReadGraph graph, Resource diagram) throws DatabaseException {\r
+       ModelingResources mod = ModelingResources.getInstance(graph);\r
+        Resource composite = graph.getSingleObject(diagram, mod.DiagramToComposite);\r
+        final ResourceArray compositePath = StructuralVariables.getCompositeArray(graph, composite);\r
+        final ResourceArray variablePath = compositePath.removeFromBeginning(1);\r
+        return StructuralVariables.getRVI(graph, variablePath);\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/SVGBuilder.java b/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/SVGBuilder.java
new file mode 100644 (file)
index 0000000..4f2d79b
--- /dev/null
@@ -0,0 +1,189 @@
+package org.simantics.diagram.svg.export;\r
+\r
+import java.awt.Graphics2D;\r
+import java.awt.Point;\r
+import java.awt.RenderingHints;\r
+import java.awt.geom.AffineTransform;\r
+import java.awt.geom.Rectangle2D;\r
+import java.io.StringWriter;\r
+import java.util.UUID;\r
+\r
+import org.apache.batik.dom.GenericDOMImplementation;\r
+import org.apache.batik.svggen.SVGGraphics2D;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.diagram.DiagramHints;\r
+import org.simantics.g2d.diagram.DiagramUtils;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.participant.TransformUtil;\r
+import org.simantics.scenegraph.g2d.G2DRenderingHints;\r
+import org.simantics.scenegraph.utils.QualityHints;\r
+import org.simantics.utils.page.MarginUtils;\r
+import org.simantics.utils.page.MarginUtils.Margin;\r
+import org.simantics.utils.page.MarginUtils.Margins;\r
+import org.w3c.dom.DOMImplementation;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+\r
+\r
+/**\r
+ * org.simantics.diagram.export.ImageBuilder with SVG support \r
+ * \r
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
+ *\r
+ */\r
+public class SVGBuilder {\r
+       Double dpi;\r
+       Point size;\r
+       double margin;\r
+       Margins margins;\r
+       \r
+       /**\r
+        * \r
+        * @param file File to write the image (optional)\r
+        * @param dpi Dots Per Inch\r
+        * @param size Image size in pixels\r
+        * @param margin percentage of image width for margins. 0.05 is 5%.\r
+        */\r
+       public SVGBuilder(Double dpi, Point size, double margin) {\r
+               this.dpi = dpi;\r
+               this.size = size;\r
+               this.margin = Math.max(margin,0.0);\r
+               this.margins = null;\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @param file File to write the image (optional)\r
+        * @param dpi Dots Per Inch\r
+        * @param size Image size in pixels\r
+        * @param margins Margins\r
+        */\r
+       public SVGBuilder(Double dpi, Point size, Margins margins) {\r
+               this.dpi = dpi;\r
+               this.size = size;\r
+               this.margin = 0.0;\r
+               this.margins = margins;\r
+       }\r
+       \r
+       public static SVGGraphics2D defaultSVGGenerator() {\r
+               DOMImplementation domImpl =  GenericDOMImplementation.getDOMImplementation();\r
+               \r
+               // Create an instance of org.w3c.dom.Document.\r
+           String svgNS = "http://www.w3.org/2000/svg";\r
+           Document document = domImpl.createDocument(svgNS, "svg", null);\r
+       \r
+           // Create an instance of the SVG Generator.\r
+           SVGGraphics2D svgGenerator = new SVGGraphics2D(document);\r
+           svgGenerator.getGeneratorContext().setIDGenerator(new UniqueIDGenerator(UUID.randomUUID().toString()));\r
+           return svgGenerator;\r
+       }\r
+\r
+       /**\r
+        * @param canvasContext\r
+        *            the canvas context to paint\r
+        * @param writeResults\r
+        *            <code>true</code> to actually write the resulting Image to the file.\r
+        */\r
+       public String paint(ICanvasContext canvasContext) throws Exception {\r
+               return paint(canvasContext, defaultSVGGenerator());\r
+       }\r
+       \r
+       /**\r
+        * @param canvasContext\r
+        *            the canvas context to paint\r
+        *        svgGenerator \r
+        *            the svg generator to use\r
+        * @param writeResults\r
+        *            <code>true</code> to actually write the resulting Image to the file.\r
+        */\r
+       public String paint(ICanvasContext canvasContext, SVGGraphics2D svgGenerator) throws Exception {\r
+               \r
+               Graphics2D g2 = svgGenerator;\r
+               \r
+               IDiagram diagram = canvasContext.getDefaultHintContext().getHint(DiagramHints.KEY_DIAGRAM);\r
+               Rectangle2D diagramRect = DiagramUtils.getContentRect(diagram);\r
+\r
+               if (diagramRect == null)\r
+                       diagramRect = new Rectangle2D.Double(0, 0, 100, 100);\r
+\r
+               // add margins to content.\r
+               double off = Math.max(diagramRect.getWidth(), diagramRect.getHeight()) * margin*0.5;\r
+               diagramRect = new Rectangle2D.Double(diagramRect.getX() - off, diagramRect.getY() - off, diagramRect.getWidth() + off * 2.0, diagramRect.getHeight() + off * 2.0);\r
+\r
+               if (margins != null) {\r
+                       diagramRect = org.simantics.scenegraph.utils.GeometryUtils.expandRectangle(diagramRect,\r
+                                       margins.top.diagramAbsolute,\r
+                                       margins.bottom.diagramAbsolute,\r
+                                       margins.left.diagramAbsolute,\r
+                                       margins.right.diagramAbsolute\r
+                                       );\r
+               }\r
+               \r
+               // Make sure the transformation is reset.\r
+               AffineTransform tr = new AffineTransform();\r
+\r
+               Rectangle2D controlArea;\r
+               if (dpi != null) {\r
+                       double mmToInch = 1.0 / 25.4;\r
+                       controlArea = new Rectangle2D.Double(0, 0, diagramRect.getWidth() * mmToInch * dpi, diagramRect.getHeight() * mmToInch * dpi);\r
+\r
+                       if (margins != null) {\r
+                               double w = controlArea.getWidth();\r
+                               double h = controlArea.getHeight();\r
+                               controlArea = org.simantics.scenegraph.utils.GeometryUtils.expandRectangle(controlArea,\r
+                                               margins.top.controlAbsolute + margins.top.controlRelative * h,\r
+                                               margins.bottom.controlAbsolute + margins.bottom.controlRelative * h,\r
+                                               margins.left.controlAbsolute + margins.left.controlRelative * w,\r
+                                               margins.right.controlAbsolute + margins.right.controlRelative * w\r
+                                               );\r
+                       }\r
+               } else {\r
+                       controlArea = new Rectangle2D.Double(0, 0, size.getX(), size.getY());\r
+                       if (margins != null) {\r
+                               double w = controlArea.getWidth();\r
+                               double h = controlArea.getHeight();\r
+                               controlArea = org.simantics.scenegraph.utils.GeometryUtils.expandRectangle(controlArea,\r
+                                               -(margins.top.controlAbsolute + margins.top.controlRelative * h),\r
+                                               -(margins.bottom.controlAbsolute + margins.bottom.controlRelative * h),\r
+                                               -(margins.left.controlAbsolute + margins.left.controlRelative * w),\r
+                                               -(margins.right.controlAbsolute + margins.right.controlRelative * w)\r
+                                               );\r
+                       }\r
+               }\r
+\r
+               canvasContext.getSingleItem(TransformUtil.class).fitArea(controlArea, diagramRect, MarginUtils.NO_MARGINS);\r
+               \r
+               float width = (float)controlArea.getWidth();\r
+               float height = (float)controlArea.getHeight();\r
+               \r
+\r
+               QualityHints.HIGH_QUALITY_HINTS.setQuality(g2);\r
+               g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);\r
+\r
+\r
+               g2.setTransform(tr);\r
+               g2.setClip(new Rectangle2D.Double(0, 0, controlArea.getWidth(), controlArea.getHeight()));\r
+\r
+               g2.setRenderingHint(G2DRenderingHints.KEY_CONTROL_BOUNDS, new Rectangle2D.Double(0, 0, controlArea.getWidth(), controlArea.getHeight()));\r
+\r
+               if (canvasContext.isLocked())\r
+                       throw new IllegalStateException("cannot render image, canvas context is locked: " + canvasContext);\r
+\r
+               canvasContext.getSceneGraph().render(g2);\r
+                       \r
+\r
+               \r
+               Element root = svgGenerator.getRoot();\r
+               root.setAttributeNS(null, "viewBox", "0 0 " + width + " " + height); \r
+               root.setAttributeNS(null, "height", Float.toString(height));\r
+               root.setAttributeNS(null, "width", Float.toString(width));\r
+               \r
+               // Finally, stream out SVG to the standard output using\r
+           // UTF-8 encoding.\r
+           boolean useCSS = false; // we want to use CSS style attributes\r
+           StringWriter writer = new StringWriter();\r
+           //svgGenerator.stream(writer, useCSS);\r
+           svgGenerator.stream(root,writer, useCSS, false);\r
+           return writer.toString();\r
+       }\r
+}\r
diff --git a/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/UniqueIDGenerator.java b/bundles/org.simantics.diagram.svg/src/org/simantics/diagram/svg/export/UniqueIDGenerator.java
new file mode 100644 (file)
index 0000000..9bfb8c0
--- /dev/null
@@ -0,0 +1,18 @@
+package org.simantics.diagram.svg.export;\r
+\r
+import org.apache.batik.svggen.SVGIDGenerator;\r
+\r
+public class UniqueIDGenerator extends SVGIDGenerator{\r
+       \r
+       String overallId;\r
+       public UniqueIDGenerator(String overallId) {\r
+               super();\r
+               this.overallId = overallId;\r
+       }\r
+       \r
+       @Override\r
+       public String generateID(String prefix) {\r
+               return super.generateID(overallId+prefix);\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java b/bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java
new file mode 100644 (file)
index 0000000..085f38b
--- /dev/null
@@ -0,0 +1,6 @@
+package org.simantics.document.server.io;\r
+\r
+public interface ITreeTableCell extends ITableCell {\r
+    \r
+       int getParent();\r
+}\r
index 35ab38a80ffc403db6ed5e829523c02f13040be5..53124fb464194fcbbf53eab3cfc04c3d1e6fab8c 100644 (file)
@@ -14,6 +14,9 @@ importJava "org.simantics.document.server.io.IDocument" where
 importJava "org.simantics.document.server.io.ITableCell" where\r
     data ITableCell\r
 \r
+importJava "org.simantics.document.server.io.ITreeTableCell" where\r
+    data ITreeTableCell\r
+\r
 importJava "org.simantics.document.server.io.IFont" where\r
     data IFont\r
 \r
@@ -56,9 +59,9 @@ importJava "org.simantics.document.server.io.CommandContextMutable" where
     data CommandContextMutable\r
 \r
     @JavaName putString\r
-    putString :: CommandContextMutable -> String -> String -> CommandContextMutable\r
+    putString :: CommandContextMutable -> String -> String -> <Proc> CommandContextMutable\r
     \r
-    putValue :: CommandContextMutable -> String -> a -> CommandContextMutable\r
+    putValue :: CommandContextMutable -> String -> a -> <Proc> CommandContextMutable\r
 \r
 importJava "org.simantics.document.server.io.CommandContextImpl" where\r
 \r
diff --git a/bundles/org.simantics.help.base/.classpath b/bundles/org.simantics.help.base/.classpath
new file mode 100644 (file)
index 0000000..6cf33fb
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry exported="true" kind="lib" path="fontbox-1.8.10.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="jempbox-1.8.10.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="xmpbox-1.8.10.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="pdfbox-1.8.10.jar" sourcepath="pdfbox-1.8.10-src.zip"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.help.base/.project b/bundles/org.simantics.help.base/.project
new file mode 100644 (file)
index 0000000..c27404d
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.help.base</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.help.base/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.help.base/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..11f6e46
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7\r
+org.eclipse.jdt.core.compiler.compliance=1.7\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.7\r
diff --git a/bundles/org.simantics.help.base/META-INF/MANIFEST.MF b/bundles/org.simantics.help.base/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..d9c6d45
--- /dev/null
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Contributions for Eclipse Help System
+Bundle-SymbolicName: org.simantics.help.base;singleton:=true
+Bundle-Version: 1.18.3.qualifier
+Bundle-Activator: org.simantics.help.base.internal.Activator
+Bundle-Vendor: Semantum Oy
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.help.base,
+ org.apache.commons.logging;bundle-version="1.0.4",
+ org.bouncycastle;bundle-version="1.47.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,
+ xmpbox-1.8.10.jar,
+ jempbox-1.8.10.jar,
+ fontbox-1.8.10.jar,
+ pdfbox-1.8.10.jar
diff --git a/bundles/org.simantics.help.base/build.properties b/bundles/org.simantics.help.base/build.properties
new file mode 100644 (file)
index 0000000..7904aba
--- /dev/null
@@ -0,0 +1,10 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               plugin.xml,\\r
+               pdfbox-1.8.10.jar,\\r
+               fontbox-1.8.10.jar,\\r
+               jempbox-1.8.10.jar,\\r
+               xmpbox-1.8.10.jar\r
+source.. = src/\r
diff --git a/bundles/org.simantics.help.base/fontbox-1.8.10.jar b/bundles/org.simantics.help.base/fontbox-1.8.10.jar
new file mode 100644 (file)
index 0000000..3284950
Binary files /dev/null and b/bundles/org.simantics.help.base/fontbox-1.8.10.jar differ
diff --git a/bundles/org.simantics.help.base/jempbox-1.8.10.jar b/bundles/org.simantics.help.base/jempbox-1.8.10.jar
new file mode 100644 (file)
index 0000000..48cc633
Binary files /dev/null and b/bundles/org.simantics.help.base/jempbox-1.8.10.jar differ
diff --git a/bundles/org.simantics.help.base/pdfbox-1.8.10-src.zip b/bundles/org.simantics.help.base/pdfbox-1.8.10-src.zip
new file mode 100644 (file)
index 0000000..e05aa63
Binary files /dev/null and b/bundles/org.simantics.help.base/pdfbox-1.8.10-src.zip differ
diff --git a/bundles/org.simantics.help.base/pdfbox-1.8.10.jar b/bundles/org.simantics.help.base/pdfbox-1.8.10.jar
new file mode 100644 (file)
index 0000000..87bb9a7
Binary files /dev/null and b/bundles/org.simantics.help.base/pdfbox-1.8.10.jar differ
diff --git a/bundles/org.simantics.help.base/plugin.xml b/bundles/org.simantics.help.base/plugin.xml
new file mode 100644 (file)
index 0000000..2a8ba7c
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.4"?>\r
+<plugin>\r
+\r
+   <extension\r
+         point="org.eclipse.help.base.searchParticipant">\r
+      <searchParticipant\r
+            extensions="pdf"\r
+            id="org.simantics.help.base.pdf"\r
+            participant="org.simantics.help.base.internal.PDFSearchParticipant"\r
+            headless="true"/>\r
+   </extension>\r
+\r
+</plugin>\r
diff --git a/bundles/org.simantics.help.base/src/org/simantics/help/base/internal/Activator.java b/bundles/org.simantics.help.base/src/org/simantics/help/base/internal/Activator.java
new file mode 100644 (file)
index 0000000..a53e7ce
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.help.base.internal;\r
+\r
+import org.osgi.framework.BundleActivator;\r
+import org.osgi.framework.BundleContext;\r
+\r
+public class Activator implements BundleActivator {\r
+\r
+       private static BundleContext context;\r
+\r
+       static BundleContext getContext() {\r
+               return context;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext bundleContext) throws Exception {\r
+               Activator.context = bundleContext;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext bundleContext) throws Exception {\r
+               Activator.context = null;\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.help.base/src/org/simantics/help/base/internal/PDFSearchParticipant.java b/bundles/org.simantics.help.base/src/org/simantics/help/base/internal/PDFSearchParticipant.java
new file mode 100644 (file)
index 0000000..d630e11
--- /dev/null
@@ -0,0 +1,54 @@
+package org.simantics.help.base.internal;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.net.URL;\r
+import java.net.URLDecoder;\r
+\r
+import org.eclipse.core.runtime.FileLocator;\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Path;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.core.runtime.Status;\r
+import org.eclipse.help.search.IHelpSearchIndex;\r
+import org.eclipse.help.search.ISearchDocument;\r
+import org.eclipse.help.search.SearchParticipant;\r
+import org.osgi.framework.Bundle;\r
+\r
+/**\r
+ * An abstract search participants for adding XML documents to the search index. Subclass it\r
+ * and implement or override protected methods to handle parsing of the document.\r
+ *\r
+ * @since 1.20.0\r
+ */\r
+public class PDFSearchParticipant extends SearchParticipant {\r
+\r
+    @Override\r
+    public IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id, ISearchDocument doc) {\r
+        try {\r
+            //System.out.println("PDFSearchParticipant.addDocument(" + index + ", " + pluginId + ", " + name + ", " + url + ", " + id + ", " + doc + ")");\r
+            Bundle bundle = Platform.getBundle(pluginId);\r
+            if (bundle == null)\r
+                return new Status(IStatus.ERROR, pluginId, "Failed to find bundle " + bundle + " from the platform.");\r
+\r
+            // Need to decode path because it will fail to resolve if it contains %20 (=' ').\r
+            IPath path = new Path(URLDecoder.decode(name, "UTF-8"));\r
+            path = path.removeFirstSegments(1);\r
+            URL bundleUrl = FileLocator.find(bundle, path, null);\r
+            if (bundleUrl == null)\r
+                return new Status(IStatus.ERROR, pluginId, "Failed to find file " + name + " from bundle " + pluginId + ".");\r
+\r
+            URL fileUrl = FileLocator.toFileURL(bundleUrl);\r
+            if (!fileUrl.getProtocol().equals("file"))\r
+                return new Status(IStatus.ERROR, pluginId, "Failed to make " + url + " available as a file");\r
+\r
+            File f = new File(URLDecoder.decode(fileUrl.getPath(), "UTF-8")).getCanonicalFile();\r
+            PDFUtil.stripText(f, doc);\r
+            return Status.OK_STATUS;\r
+        } catch (IOException e) {\r
+            return new Status(IStatus.ERROR, pluginId, "Failed to strip text from PDF document " + url + ".", e);\r
+        }\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.help.base/src/org/simantics/help/base/internal/PDFUtil.java b/bundles/org.simantics.help.base/src/org/simantics/help/base/internal/PDFUtil.java
new file mode 100644 (file)
index 0000000..c12e56b
--- /dev/null
@@ -0,0 +1,42 @@
+package org.simantics.help.base.internal;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.IOException;\r
+\r
+import org.apache.pdfbox.cos.COSDocument;\r
+import org.apache.pdfbox.pdfparser.PDFParser;\r
+import org.apache.pdfbox.pdmodel.PDDocument;\r
+import org.apache.pdfbox.pdmodel.PDDocumentInformation;\r
+import org.apache.pdfbox.util.PDFTextStripper;\r
+import org.eclipse.help.search.ISearchDocument;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class PDFUtil {\r
+\r
+    public static void stripText(File fromPdf, ISearchDocument doc) throws IOException {\r
+        PDFParser parser = new PDFParser(new FileInputStream(fromPdf));\r
+        parser.parse();\r
+\r
+        try (COSDocument cosDoc = parser.getDocument()) {\r
+            try (PDDocument pdDoc = new PDDocument(cosDoc)) {\r
+                int numPages = pdDoc.getNumberOfPages();\r
+                PDFTextStripper stripper = new PDFTextStripper();\r
+                stripper.setStartPage(1);\r
+                stripper.setEndPage(numPages);\r
+                String text = stripper.getText(pdDoc);\r
+                PDDocumentInformation docInfo = pdDoc.getDocumentInformation();\r
+                String title = docInfo.getTitle();\r
+                String subject = docInfo.getSubject();\r
+                if (title != null)\r
+                    doc.setTitle(title);\r
+                if (subject != null)\r
+                    doc.setSummary(subject);\r
+                doc.addContents(text);\r
+            }\r
+        }\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/bundles/org.simantics.help.base/xmpbox-1.8.10.jar b/bundles/org.simantics.help.base/xmpbox-1.8.10.jar
new file mode 100644 (file)
index 0000000..7a8a465
Binary files /dev/null and b/bundles/org.simantics.help.base/xmpbox-1.8.10.jar differ
diff --git a/bundles/org.simantics.help.core/.classpath b/bundles/org.simantics.help.core/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.help.core/.project b/bundles/org.simantics.help.core/.project
new file mode 100644 (file)
index 0000000..e627b6c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.help.core</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.help.core/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.help.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.help.core/META-INF/MANIFEST.MF b/bundles/org.simantics.help.core/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..dacb90f
--- /dev/null
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Help Core
+Bundle-SymbolicName: org.simantics.help.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.help.core.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.simantics.help.ontology;bundle-version="1.0.0",
+ org.simantics.db,
+ org.simantics.modeling.ontology,
+ org.simantics.layer0;bundle-version="1.1.0",
+ org.eclipse.help,
+ org.simantics.modeling;bundle-version="1.1.1",
+ winterwell.markdown,
+ org.simantics,
+ org.simantics.document.base.ontology,
+ org.eclipse.mylyn.wikitext.core,
+ org.eclipse.mylyn.wikitext.mediawiki.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Export-Package: org.simantics.help.core
diff --git a/bundles/org.simantics.help.core/build.properties b/bundles/org.simantics.help.core/build.properties
new file mode 100644 (file)
index 0000000..4e3c13e
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               scl/,\\r
+               plugin.xml\r
diff --git a/bundles/org.simantics.help.core/css/style.css b/bundles/org.simantics.help.core/css/style.css
new file mode 100644 (file)
index 0000000..6d0f994
--- /dev/null
@@ -0,0 +1,107 @@
+body { \r
+       font-family: "Lucida Grande", "Lucida Grande", Verdana; \r
+       font-size:12px; \r
+       font-weight:normal;\r
+       color:#000000;\r
+       border-left: 2em solid #2b476f;\r
+       border-rigth: 2em hidden #2b476f;\r
+       padding-left: 1em;\r
+       padding-right: 1em;}\r
+       scrollbar-face-color:#006600;\r
+       scrollbar-highlight-color:#C0C0C0;\r
+       scrollbar-3dlight-color:#C0C0C0;\r
+       scrollbar-darkshadow-color:#000000;\r
+       scrollbar-shadow-color:#0F4966;\r
+       scrollbar-arrow-color:#FFFFFF;\r
+       scrollbar-track-color:#C0C0C0;\r
+       background-color: white;\r
+}\r
+\r
+table {\r
+       border-collapse: collapse;\r
+       text-align: left;\r
+       vertical-align: center;\r
+}\r
+\r
+caption {\r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px; \r
+       text-align: left;\r
+       font-style: italic;\r
+}\r
+\r
+th {           \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px; \r
+       background-color: silver;\r
+       padding-left: 5px;\r
+       padding-right: 5px;\r
+}\r
+\r
+td {   \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px;        \r
+       padding-left: 5px;\r
+       padding-right: 5px;\r
+}\r
+\r
+figure {\r
+       margin: 0;\r
+}\r
+\r
+figcaption {\r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px; \r
+       text-align: left;\r
+       font-style: italic;\r
+}\r
+\r
+h1 { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size:35px; \r
+       color:#2b476f; \r
+}\r
+\r
+h2 { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size:20px; \r
+       color:#000000;\r
+}\r
+\r
+h3 { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size:16px;\r
+}\r
+\r
+A:link, A:visited, A:active { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: inherit; \r
+       text-decoration: none;\r
+       font-weight:bold; \r
+       color:#2b476f; \r
+}\r
+\r
+A:hover {  \r
+       font-family: "Lucida Grande", Verdana; \r
+       text-decoration: none; \r
+       font-weight:bold; \r
+       color:#222299; \r
+       background-color:#C0C0C0\r
+}\r
+\r
+A[name]:hover {  \r
+       font-family: "Lucida Grande", Verdana; \r
+       text-decoration: inherit; \r
+       font-weight: inherit; \r
+       color: inherit; \r
+       background-color: inherit \r
+}\r
+\r
+.wikitable {\r
+       text-align: left;\r
+       border-collapse: collapse;\r
+}\r
+\r
+.wikitable, .wikitable th, .wikitable td {\r
+       border: 1px solid black;\r
+}\r
diff --git a/bundles/org.simantics.help.core/plugin.xml b/bundles/org.simantics.help.core/plugin.xml
new file mode 100644 (file)
index 0000000..af0a286
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.4"?>\r
+<plugin>\r
+   <extension\r
+         point="org.eclipse.help.toc">\r
+      <tocProvider\r
+            class="org.simantics.help.core.SimanticsTocProvider">\r
+      </tocProvider>\r
+   </extension>\r
+\r
+</plugin>\r
diff --git a/bundles/org.simantics.help.core/scl/Simantics/Help.scl b/bundles/org.simantics.help.core/scl/Simantics/Help.scl
new file mode 100644 (file)
index 0000000..d104a50
--- /dev/null
@@ -0,0 +1,27 @@
+import "URL"\r
+import "Simantics/DB"\r
+import "http://www.simantics.org/Help-1.0" as HELP\r
+\r
+importJava "org.simantics.help.core.HelpUtils" where\r
+    createHelpLibrary :: Resource -> <WriteGraph, Proc> Resource\r
+    createHelpTutorial :: Resource -> String -> <WriteGraph, Proc> Resource\r
+    clearHelpTocCache :: () -> <Proc> ()\r
+    saveHelpFileContents :: Resource -> String -> <WriteGraph, Proc> ()\r
+    readHelpFileContents :: Resource -> <ReadGraph, Proc> String\r
+    markdownToHtml :: Resource -> <ReadGraph, Proc> String\r
+    getHelpBrowserUrl :: () -> URL\r
+\r
+createHelpLibraryAction :: Resource -> <Proc> ()\r
+createHelpLibraryAction parent = do\r
+    syncWrite (\() -> createHelpLibrary parent)\r
+    ()\r
+\r
+createHelpTutorialAction :: Resource -> <Proc> ()\r
+createHelpTutorialAction parent = do\r
+    tutorialFiles = syncRead (\x -> objectsWithType parent L0.ConsistsOf HELP.TutorialFile)\r
+    fileName = if length tutorialFiles == 0\r
+    then "Tutorial"\r
+    else do\r
+        "Tutorial " + (show (length tutorialFiles))\r
+    syncWrite (\() -> createHelpTutorial parent fileName)\r
+    ()
\ No newline at end of file
diff --git a/bundles/org.simantics.help.core/src/org/simantics/help/core/Activator.java b/bundles/org.simantics.help.core/src/org/simantics/help/core/Activator.java
new file mode 100644 (file)
index 0000000..8a4f199
--- /dev/null
@@ -0,0 +1,80 @@
+package org.simantics.help.core;\r
+\r
+import java.net.URL;\r
+import java.nio.file.Files;\r
+import java.nio.file.Path;\r
+import java.nio.file.Paths;\r
+import java.nio.file.StandardCopyOption;\r
+\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.Bundle;\r
+import org.osgi.framework.BundleContext;\r
+\r
+/**\r
+ * The activator class controls the plug-in life cycle\r
+ */\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+       // The plug-in ID\r
+       public static final String PLUGIN_ID = "org.simantics.help.core"; //$NON-NLS-1$\r
+\r
+       public static final String HTML_FOLDER = "html";\r
+       \r
+       // The shared instance\r
+       private static Activator plugin;\r
+       private static Path directory;\r
+       \r
+       /**\r
+        * The constructor\r
+        */\r
+       public Activator() {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext context) throws Exception {\r
+               super.start(context);\r
+               plugin = this;\r
+        Bundle bundle = context.getBundle();\r
+        IPath path = Platform.getStateLocation(bundle);\r
+        Path p = Paths.get(path.toOSString());\r
+        directory = p.resolve(HTML_FOLDER);\r
+        if (!Files.exists(directory))\r
+            Files.createDirectories(directory);\r
+        \r
+        // Ensure that style.css is inside the html directory\r
+        Path css = directory.resolve("style.css");\r
+        if (!Files.exists(css)) {\r
+            Files.createFile(css);\r
+            URL url = bundle.getEntry("css/style.css");\r
+            Files.copy(url.openStream(), css, StandardCopyOption.REPLACE_EXISTING);\r
+        }\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext context) throws Exception {\r
+               plugin = null;\r
+               super.stop(context);\r
+       }\r
+\r
+       /**\r
+        * Returns the shared instance\r
+        *\r
+        * @return the shared instance\r
+        */\r
+       public static Activator getDefault() {\r
+               return plugin;\r
+       }\r
+       \r
+    public static Path getHtmlDirectory() {\r
+        return directory;\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.help.core/src/org/simantics/help/core/HelpUtils.java b/bundles/org.simantics.help.core/src/org/simantics/help/core/HelpUtils.java
new file mode 100644 (file)
index 0000000..730fd42
--- /dev/null
@@ -0,0 +1,337 @@
+package org.simantics.help.core;\r
+\r
+import java.io.IOException;\r
+import java.io.StringWriter;\r
+import java.net.URL;\r
+import java.net.URLDecoder;\r
+import java.nio.charset.StandardCharsets;\r
+import java.nio.file.Files;\r
+import java.nio.file.Path;\r
+import java.nio.file.StandardOpenOption;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+import java.util.TreeMap;\r
+\r
+import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;\r
+import org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder;\r
+import org.eclipse.mylyn.wikitext.mediawiki.core.MediaWikiLanguage;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.help.IWorkbenchHelpSystem;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.BindingException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.document.base.ontology.DocumentationResource;\r
+import org.simantics.help.HelpResources;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingUtils;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+\r
+import winterwell.markdown.pagemodel.MarkdownPage;\r
+\r
+public class HelpUtils {\r
+\r
+    public static Resource createHelpLibrary(WriteGraph graph, Resource parent) throws DatabaseException {\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        HelpResources HELP = HelpResources.getInstance(graph);\r
+        Resource library = graph.newResource();\r
+        graph.claim(library, L0.InstanceOf, null, HELP.HelpLibrary);\r
+        graph.addLiteral(library, L0.HasName, L0.NameOf, "Help Library", Bindings.STRING);\r
+        graph.claim(parent, L0.ConsistsOf, L0.PartOf, library);\r
+        return library;\r
+    }\r
+    \r
+    public static Resource createHelpTutorial(WriteGraph graph, Resource parent, String name) throws DatabaseException {\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        HelpResources HELP = HelpResources.getInstance(graph);\r
+        Resource tutorialFile = graph.newResource();\r
+        graph.claim(tutorialFile, L0.InstanceOf, null, HELP.TutorialFile);\r
+        graph.addLiteral(tutorialFile, L0.HasName, L0.NameOf, name, Bindings.STRING);\r
+        graph.claim(parent, L0.ConsistsOf, L0.PartOf, tutorialFile);\r
+        return tutorialFile;\r
+    }\r
+\r
+    public static List<Path> collectHelps(ReadGraph graph, Resource indexRoot) throws DatabaseException {\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        HelpResources HELP = HelpResources.getInstance(graph);\r
+        List<Resource> tutorialFiles = ModelingUtils.searchByType(graph, indexRoot, HELP.TutorialFile);\r
+        if (tutorialFiles.isEmpty())\r
+            return Collections.emptyList();\r
+        List<Path> result = new ArrayList<>(tutorialFiles.size());\r
+        for (Resource tutorialFile : tutorialFiles) {\r
+            StringBuilder sb = new StringBuilder();\r
+            \r
+            htmlHead(sb, graph.getRelatedValue2(tutorialFile, L0.HasName, Bindings.STRING));\r
+            sb.append(HelpUtils.markdownToHtml(graph, tutorialFile));\r
+            htmlHeadClose(sb);\r
+            \r
+            String indexRootURI = graph.getURI(indexRoot);\r
+            String indexRootName = graph.getRelatedValue2(indexRoot, L0.HasName, Bindings.STRING);\r
+            String tutorialFileURI = graph.getURI(tutorialFile);\r
+            String suffix = tutorialFileURI.substring(indexRootURI.length());\r
+            try {\r
+                if (suffix.startsWith("/"))\r
+                    suffix = suffix.substring(1);\r
+                suffix = URLDecoder.decode(suffix, StandardCharsets.UTF_8.name());\r
+                Path outputPath = Activator.getHtmlDirectory().resolve(indexRootName).resolve(suffix + ".html");\r
+                createDirsRec(outputPath.getParent());\r
+                if (!Files.exists(outputPath))\r
+                    Files.createFile(outputPath);\r
+                Files.write(outputPath, sb.toString().getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);\r
+                result.add(outputPath);\r
+            } catch (IOException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    private static void createDirsRec(Path path) throws IOException {\r
+        Path parent = path.getParent();\r
+        if (!Files.exists(parent)) {\r
+            createDirsRec(parent);\r
+        }\r
+        if (!Files.exists(path))\r
+            Files.createDirectory(path);\r
+    }\r
+\r
+    public static Map<String, List<Path>> collectHelpsFromSharedLibraries(ReadGraph graph) throws DatabaseException {\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        Collection<Resource> sharedLibraries = graph.syncRequest(new ObjectsWithType(graph.getRootLibrary(), L0.ConsistsOf, L0.SharedOntology));\r
+        if (sharedLibraries.isEmpty())\r
+            return Collections.emptyMap();\r
+        Map<String, List<Path>> result = new HashMap<>(sharedLibraries.size());\r
+        for (Resource library : sharedLibraries) {\r
+            String libraryName = graph.getRelatedValue2(library, L0.HasName, Bindings.STRING);\r
+            List<Path> paths = collectHelps(graph, library);\r
+            result.put(libraryName, paths);\r
+        }\r
+        return result;\r
+    }\r
+    \r
+    public static Map<String, Path> collectWidgetReferencesFromSharedLibraries(ReadGraph graph) throws DatabaseException {\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        Collection<Resource> sharedLibraries = graph.syncRequest(new ObjectsWithType(graph.getRootLibrary(), L0.ConsistsOf, L0.SharedOntology));\r
+        if (sharedLibraries.isEmpty())\r
+            return Collections.emptyMap();\r
+        Map<String, Path> result = new HashMap<>(sharedLibraries.size());\r
+        for (Resource library : sharedLibraries) {\r
+            String html = createWidgetReference(graph, library, "Widget Reference");\r
+            String indexRootName = graph.getRelatedValue2(library, L0.HasName, Bindings.STRING);\r
+            try {\r
+                Path outputPath = Activator.getHtmlDirectory().resolve(indexRootName).resolve("widgetReference.html");\r
+                createDirsRec(outputPath.getParent());\r
+                if (!Files.exists(outputPath))\r
+                    Files.createFile(outputPath);\r
+                Files.write(outputPath, html.getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);\r
+                result.put(indexRootName, outputPath);\r
+            } catch (IOException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+    \r
+    private static void htmlHead(StringBuilder sb, String title) {\r
+        sb.append("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML//EN\">\n");\r
+        sb.append("<html><head><title>" + title + " Tutorial</title>\n");\r
+        sb.append("<link rel=\"Stylesheet\" type=\"text/css\" media=\"all\" href=\"../style.css\">\n");\r
+        sb.append("</head>\n");\r
+        sb.append("<body style=\"background-color: white;\">\n");\r
+        sb.append("<h1 align=\"center\">" + title + "</h1>\n");\r
+        sb.append("<hr>\n");\r
+    }\r
+    \r
+    private static void htmlHeadClose(StringBuilder sb) {\r
+        sb.append("</body></html>\n");\r
+    }\r
+\r
+    public static String createWidgetReference(ReadGraph graph, Resource indexRoot, String title) throws DatabaseException {\r
+\r
+        String ontologyDesc = NameUtils.getSafeLabel(graph, indexRoot);\r
+        \r
+        StringBuilder sb = new StringBuilder();\r
+        \r
+        sb.append("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML//EN\">\n");\r
+        sb.append("<html><head><title>" + ontologyDesc+ " Widget Reference</title>\n");\r
+        sb.append("<link rel=\"Stylesheet\" type=\"text/css\" media=\"all\" href=\"../style.css\">\n");\r
+        sb.append("</head>\n");\r
+        sb.append("<body style=\"background-color: white;\">\n");\r
+        sb.append("<h1 align=\"center\">" + ontologyDesc+ "</h1>\n");\r
+        sb.append("<h2 align=\"center\">Widget Reference</h2>\n");\r
+        sb.append("<hr>\n");\r
+        sb.append("<h1 align=\"center\">" + title + "</h1>\n");\r
+        \r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
+        DocumentationResource DOC = DocumentationResource.getInstance(graph);\r
+        \r
+        List<Resource> types = ModelingUtils.searchByType(graph, indexRoot, DOC.DocumentComponentType);\r
+        for(Resource type : types) {\r
+\r
+            \r
+            String label = NameUtils.getSafeLabel(graph, type);\r
+\r
+            sb.append("<h2><a name=\"" + label + "\"></a>" + label + "</h2>\n");\r
+            sb.append("<h3>Description</h3>\n");\r
+\r
+            String desc = graph.getPossibleRelatedValue(type, L0.HasDescription);\r
+            if(desc == null) desc = "";\r
+            \r
+            sb.append("<p>" + WikiParser.parseToHtml(desc, false) + "</p>\n");\r
+            \r
+            sb.append("<h3>Base Types</h3>\n");\r
+            \r
+            Map<String,String> names = new HashMap<String,String>();\r
+\r
+            for(Resource r : graph.getSupertypes(type)) {\r
+\r
+                if(graph.isInheritedFrom(r, STR.Component)) {\r
+                    \r
+                    String label2 = NameUtils.getSafeLabel(graph, r);\r
+                    String name = graph.getRelatedValue(r, L0.HasName);\r
+                    //if("Component".equals(name)) continue;\r
+                    if("Element".equals(name)) continue;\r
+                    if("DefinedElement".equals(name)) continue;\r
+                    if("PrimitiveComponent".equals(name)) continue;\r
+                    if("DocumentComponent".equals(name)) continue;\r
+                    \r
+                    names.put(name, label2);\r
+\r
+                }\r
+                \r
+            }\r
+\r
+            for(Map.Entry<String, String> entry : names.entrySet()) {\r
+                String stuff = "predefined/baseWidgets.html#";\r
+                sb.append("<a href=\"" + stuff + entry.getKey() + "\">" + entry.getValue() + "</a>\n");\r
+                //sb.append("<a href=\"baseWidgets.html#" + entry.getKey() + "\">" + entry.getValue() + "</a>\n");\r
+            }\r
+\r
+            sb.append("<h3>Properties</h3>\n");\r
+            sb.append("<table style=\"width: 100%;\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n");\r
+            sb.append("<tbody>\n");\r
+            sb.append("  <tr style=\"background-color: silver;\">\n");\r
+            sb.append("  <td valign=\"top\"><br><strong>Property Name</strong></td>\n");\r
+            sb.append("  <td valign=\"top\"><br><strong>Type</strong></td>\n");\r
+            sb.append("  <td valign=\"top\"><br><strong>Default Value</strong></td>\n");\r
+            sb.append("  <td valign=\"top\"><br><strong>Description</strong></td>\n");\r
+            sb.append("  </tr>\n");\r
+            \r
+            Map<String, Resource> propertyMap = new TreeMap<String, Resource>();\r
+            \r
+            for(Resource ass : graph.getObjects(type, L0.Asserts)) {\r
+                \r
+                Resource object = graph.getSingleObject(ass, L0.HasObject);\r
+                \r
+                if(graph.isInstanceOf(object, L0.SCLValue)) continue;\r
+                if(graph.isInstanceOf(object, L0.Function)) continue;\r
+                if(graph.isInstanceOf(object, L0.ExternalValue)) continue;\r
+\r
+                Resource pred = graph.getSingleObject(ass, L0.HasPredicate);\r
+                String pName = NameUtils.getSafeLabel(graph, pred);\r
+                propertyMap.put(pName, ass);\r
+            }\r
+            \r
+            for (Entry<String, Resource> entry : propertyMap.entrySet()) {\r
+                Resource ass = entry.getValue();\r
+                Resource object = graph.getSingleObject(ass, L0.HasObject);\r
+                \r
+                Resource pred = graph.getSingleObject(ass, L0.HasPredicate);\r
+                String pName = NameUtils.getSafeLabel(graph, pred);\r
+                String valueType = graph.getPossibleRelatedValue(pred, L0.RequiresValueType);\r
+\r
+                Object jObject = graph.getValue(object);\r
+                String objectName = jObject.toString();\r
+                if(jObject.getClass().isArray()) {\r
+                    Class<?> c1 = jObject.getClass().getComponentType();\r
+                    boolean p1 = c1.isPrimitive();\r
+                    if (!p1)\r
+                        objectName = Arrays.toString((Object[])jObject);\r
+                    if (boolean.class.equals(c1))\r
+                        objectName = Arrays.toString((boolean[])jObject);\r
+                    else if (byte.class.equals(c1))\r
+                        objectName = Arrays.toString((byte[])jObject);\r
+                    else if (int.class.equals(c1))\r
+                        objectName = Arrays.toString((int[])jObject);\r
+                    else if (long.class.equals(c1))\r
+                        objectName = Arrays.toString((long[])jObject);\r
+                    else if (float.class.equals(c1))\r
+                        objectName = Arrays.toString((float[])jObject);\r
+                    else if (double.class.equals(c1))\r
+                        objectName = Arrays.toString((double[])jObject);\r
+                }\r
+\r
+                String pDesc = graph.getPossibleRelatedValue(pred, L0.HasDescription);\r
+                if(pDesc == null) pDesc = "";\r
+                \r
+                sb.append("  <tr>\n");\r
+                sb.append("  <td valign=\"top\">" + pName + "</td>\n");\r
+                sb.append("  <td valign=\"top\">" + valueType + "</td>\n");\r
+                sb.append("  <td valign=\"top\">" + objectName + "</td>\n");\r
+                sb.append("  <td valign=\"top\">" + WikiParser.parseToHtml(pDesc, false) + "</td>\n");\r
+                sb.append("  </tr>\n");\r
+            }\r
+\r
+            sb.append("  </tbody></table><br>\n");\r
+        }\r
+\r
+        sb.append("</body></html>\n");\r
+        return sb.toString();\r
+    }\r
+    \r
+    public static void clearHelpTocCache() {\r
+        SimanticsTocProvider.clearTocCache();\r
+    }\r
+    \r
+    public static void saveHelpFileContents(WriteGraph graph, Resource helpFile, String currentText) throws BindingException, ManyObjectsForFunctionalRelationException, ServiceException {\r
+        HelpResources HELP = HelpResources.getInstance(graph);\r
+        graph.claimLiteral(helpFile, HELP.HelpFile_contents, currentText, Bindings.STRING);\r
+    }\r
+    \r
+    public static String readHelpFileContents(ReadGraph graph, Resource helpFile) throws DatabaseException {\r
+        HelpResources HELP = HelpResources.getInstance(graph);\r
+        String content = graph.getPossibleRelatedValue2(helpFile, HELP.HelpFile_contents, Bindings.STRING);\r
+        return content != null ? content : "";\r
+    }\r
+    \r
+    public static String markdownToHtml(ReadGraph graph, Resource tutorialFile) throws DatabaseException {\r
+        HelpResources HELP = HelpResources.getInstance(graph);\r
+        String markdown = graph.getRelatedValue2(tutorialFile, HELP.HelpFile_contents, Bindings.STRING);\r
+        MarkdownPage page = new MarkdownPage(markdown);\r
+        return page.html();\r
+    }\r
+    \r
+    public static URL getHelpBrowserUrl() {\r
+        IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();\r
+        URL url = helpSystem.resolve("", false);\r
+        return url;\r
+    }\r
+\r
+    private static class WikiParser {\r
+        \r
+        private static MarkupParser markupParser = new MarkupParser(new MediaWikiLanguage());\r
+        \r
+        private WikiParser() {}\r
+        \r
+        public static String parseToHtml(String wiki, boolean asDocument) {\r
+            StringWriter writer = new StringWriter();\r
+            HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);\r
+            markupParser.setBuilder(builder);\r
+            markupParser.parse(wiki, asDocument);\r
+            return writer.toString();\r
+        }\r
+    }\r
+}\r
diff --git a/bundles/org.simantics.help.core/src/org/simantics/help/core/SimanticsTocProvider.java b/bundles/org.simantics.help.core/src/org/simantics/help/core/SimanticsTocProvider.java
new file mode 100644 (file)
index 0000000..559ef55
--- /dev/null
@@ -0,0 +1,168 @@
+package org.simantics.help.core;\r
+\r
+import java.nio.file.Path;\r
+import java.nio.file.Paths;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+import javax.xml.parsers.ParserConfigurationException;\r
+\r
+import org.eclipse.help.AbstractTocProvider;\r
+import org.eclipse.help.ITocContribution;\r
+import org.eclipse.help.internal.HelpPlugin;\r
+import org.eclipse.help.internal.Topic;\r
+import org.eclipse.help.internal.entityresolver.LocalEntityResolver;\r
+import org.eclipse.help.internal.toc.Toc;\r
+import org.eclipse.help.internal.toc.TocContribution;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+\r
+@SuppressWarnings("restriction")\r
+public class SimanticsTocProvider extends AbstractTocProvider {\r
+\r
+    private static DocumentBuilder builder;\r
+    private static Document document;\r
+    \r
+    private static Map<String, Path> widgetReferences; \r
+    private static Map<String, List<Path>> tutorials;\r
+    \r
+    @Override\r
+    public ITocContribution[] getTocContributions(String locale) {\r
+        List<ITocContribution> contributions = new ArrayList<>();\r
+        \r
+        if (widgetReferences == null || tutorials == null) {\r
+            try {\r
+                Simantics.getSession().syncRequest(new ReadRequest() {\r
+                    @Override\r
+                    public void run(ReadGraph graph) throws DatabaseException {\r
+                        widgetReferences = HelpUtils.collectWidgetReferencesFromSharedLibraries(graph);\r
+                        tutorials = HelpUtils.collectHelpsFromSharedLibraries(graph);\r
+                        \r
+                    }\r
+                });\r
+            } catch (DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+\r
+        Map<String, Toc> tocs = new HashMap<>();\r
+        \r
+        if (widgetReferences != null) {\r
+            for (Map.Entry<String, Path> widgetReference : widgetReferences.entrySet()) {\r
+                String libName = widgetReference.getKey();\r
+                Path htmlFile = widgetReference.getValue();\r
+                Toc toc = tocs.get(libName);\r
+                if (toc == null) {\r
+                    Element element = getDocument().createElement("toc");\r
+                    toc = new Toc(element); \r
+                    toc.setLabel(libName);\r
+//                    toc.setTopic(libName);\r
+//                    toc.setHref(libName);\r
+                    tocs.put(libName, toc);\r
+                }\r
+                \r
+                Topic topic = new Topic();\r
+                //topic.setLabel(htmlFile.getFileName().toString());\r
+                topic.setLabel("Widget Reference");\r
+//                String href = htmlFile.toUri().toString();\r
+                String href = htmlFile.toString().split(Activator.PLUGIN_ID)[1].substring(1);\r
+                href = "PLUGINS_ROOT/platform:/meta/" + Activator.PLUGIN_ID + "/" + href;\r
+                topic.setHref(href.replace("\\", "/").replace(" ", "%20"));\r
+                \r
+                toc.appendChild(topic);\r
+            }\r
+        }\r
+\r
+        if (tutorials != null) {\r
+            for (Map.Entry<String, List<Path>> tutorial : tutorials.entrySet()) {\r
+                String libName = tutorial.getKey();\r
+                Toc toc = tocs.get(libName);\r
+                if (toc == null) {\r
+                    Element element = getDocument().createElement("toc");\r
+                    toc = new Toc(element); \r
+                    toc.setLabel(libName);\r
+                    toc.setTopic(libName);\r
+                    toc.setHref(libName);\r
+                    tocs.put(libName, toc);\r
+                }\r
+                \r
+                Map<String, Topic> topics = new HashMap<>();\r
+                \r
+                for (Path htmlFile : tutorial.getValue()) {\r
+                    Path path = Paths.get(htmlFile.toString().split(libName)[1]);\r
+                    Topic topic = getOrCreateTopic(topics, toc, path);\r
+                    String href = htmlFile.toString().split(Activator.PLUGIN_ID)[1].substring(1);\r
+                    href = "PLUGINS_ROOT/platform:/meta/" + Activator.PLUGIN_ID + "/" + href;\r
+//                    String href = htmlFile.toUri().toString();\r
+                    topic.setHref(href.replace("\\", "/").replace(" ", "%20"));\r
+                }\r
+            }\r
+        }\r
+        \r
+        for (Toc toc : tocs.values()) {\r
+            TocContribution contribution = new TocContribution();\r
+            contribution.setLocale(locale);\r
+            contribution.setId(toc.getLabel());\r
+            contribution.setCategoryId("category_" + toc.getLabel());\r
+            contribution.setPrimary(true);\r
+            contribution.setContributorId(Activator.PLUGIN_ID);\r
+            \r
+            contribution.setToc(toc);\r
+            contributions.add(contribution);\r
+        }\r
+\r
+        \r
+        return (ITocContribution[])contributions.toArray(new ITocContribution[contributions.size()]);\r
+    }\r
+    \r
+    private static Topic getOrCreateTopic(Map<String, Topic> topics, Toc toc, Path topicPath) {\r
+        String topicName = topicPath.getFileName().toString();\r
+        Topic topic = topics.get(topicName);\r
+        if (topic == null) {\r
+            topic = new Topic();\r
+            topic.setLabel(topicName);\r
+            Path parentPath = topicPath.getParent();\r
+            if (parentPath != null && parentPath.getFileName() != null) {\r
+                Topic parentTopic = getOrCreateTopic(topics, toc, parentPath);\r
+                parentTopic.appendChild(topic);\r
+            } else {\r
+                toc.appendChild(topic);\r
+            }\r
+            topics.put(topicName, topic);\r
+        }\r
+        return topic;\r
+    }\r
+    \r
+    private static Document getDocument() {\r
+        if (document == null) {\r
+            if (builder == null) {\r
+                try {\r
+                    builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();\r
+                    builder.setEntityResolver(new LocalEntityResolver());\r
+                }\r
+                catch (ParserConfigurationException e) {\r
+                    String msg = "Error creating document builder"; //$NON-NLS-1$\r
+                    HelpPlugin.logError(msg, e);\r
+                }\r
+            }\r
+            document = builder.newDocument();\r
+        }\r
+        return document;\r
+    }\r
+    \r
+    public static void clearTocCache() {\r
+        widgetReferences.clear();\r
+        widgetReferences = null;\r
+        tutorials.clear();\r
+        tutorials = null;\r
+        HelpPlugin.getTocManager().clearCache();\r
+    }\r
+}\r
diff --git a/bundles/org.simantics.help.feature/.project b/bundles/org.simantics.help.feature/.project
new file mode 100644 (file)
index 0000000..5f32fab
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.help.feature</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.FeatureBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.FeatureNature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.help.feature/build.properties b/bundles/org.simantics.help.feature/build.properties
new file mode 100644 (file)
index 0000000..0c85ae7
--- /dev/null
@@ -0,0 +1,12 @@
+###############################################################################\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
+bin.includes = feature.xml\r
diff --git a/bundles/org.simantics.help.feature/feature.xml b/bundles/org.simantics.help.feature/feature.xml
new file mode 100644 (file)
index 0000000..24eaf09
--- /dev/null
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--
+    Copyright (c) 2007, 2010 Association for Decentralized Information Management
+    in Industry THTH ry.
+    All rights reserved. This program and the accompanying materials
+    are made available under the terms of the Eclipse Public License v1.0
+    which accompanies this distribution, and is available at
+    http://www.eclipse.org/legal/epl-v10.html
+   
+    Contributors:
+        VTT Technical Research Centre of Finland - initial API and implementation
+ -->\r
+<feature\r
+      id="org.simantics.help"\r
+      label="Simantics Help"\r
+      version="1.1.1.qualifier"\r
+      provider-name="VTT Technical Research Centre of Finland">\r
+\r
+   <description>\r
+      This feature gather together the parts of Eclipse SDK that are needed to use the Eclipse help system and cheat sheets.\r
+   </description>\r
+\r
+   <license url="http://www.eclipse.org/legal/epl-v10.html">\r
+      Licensed under Eclipse Public License (EPL) 1.0.\r
+   </license>\r
+\r
+   <plugin\r
+         id="org.eclipse.help"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.help.base"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.help.ui"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.apache.lucene.analysis"\r
+         download-size="887"\r
+         install-size="1772"\r
+         version="3.5.0.v20120725-1805"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.apache.lucene.core"\r
+         download-size="1513"\r
+         install-size="3048"\r
+         version="3.5.0.v20120725-1805"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.help.webapp"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.equinox.http.registry"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="javax.servlet"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="javax.servlet.jsp"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.equinox.jsp.jasper"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.equinox.jsp.jasper.registry"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.equinox.http.jetty"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.equinox.http.servlet"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.ui.cheatsheets"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="javax.el"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="com.sun.el"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.apache.commons.logging"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.apache.jasper.glassfish"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.continuation"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.http"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.io"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.security"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.server"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.servlet"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jetty.util"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="winterwell.markdown"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+</feature>\r
diff --git a/bundles/org.simantics.help.files/.project b/bundles/org.simantics.help.files/.project
new file mode 100644 (file)
index 0000000..9b03029
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.help.files</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.help.files/META-INF/MANIFEST.MF b/bundles/org.simantics.help.files/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..61896e1
--- /dev/null
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Help Files Location
+Bundle-SymbolicName: org.simantics.help.files
+Bundle-Version: 1.0.0.qualifier
diff --git a/bundles/org.simantics.help.files/build.properties b/bundles/org.simantics.help.files/build.properties
new file mode 100644 (file)
index 0000000..5e37285
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = META-INF/\r
diff --git a/bundles/org.simantics.help.files/html/style.css b/bundles/org.simantics.help.files/html/style.css
new file mode 100644 (file)
index 0000000..6d0f994
--- /dev/null
@@ -0,0 +1,107 @@
+body { \r
+       font-family: "Lucida Grande", "Lucida Grande", Verdana; \r
+       font-size:12px; \r
+       font-weight:normal;\r
+       color:#000000;\r
+       border-left: 2em solid #2b476f;\r
+       border-rigth: 2em hidden #2b476f;\r
+       padding-left: 1em;\r
+       padding-right: 1em;}\r
+       scrollbar-face-color:#006600;\r
+       scrollbar-highlight-color:#C0C0C0;\r
+       scrollbar-3dlight-color:#C0C0C0;\r
+       scrollbar-darkshadow-color:#000000;\r
+       scrollbar-shadow-color:#0F4966;\r
+       scrollbar-arrow-color:#FFFFFF;\r
+       scrollbar-track-color:#C0C0C0;\r
+       background-color: white;\r
+}\r
+\r
+table {\r
+       border-collapse: collapse;\r
+       text-align: left;\r
+       vertical-align: center;\r
+}\r
+\r
+caption {\r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px; \r
+       text-align: left;\r
+       font-style: italic;\r
+}\r
+\r
+th {           \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px; \r
+       background-color: silver;\r
+       padding-left: 5px;\r
+       padding-right: 5px;\r
+}\r
+\r
+td {   \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px;        \r
+       padding-left: 5px;\r
+       padding-right: 5px;\r
+}\r
+\r
+figure {\r
+       margin: 0;\r
+}\r
+\r
+figcaption {\r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: 12px; \r
+       text-align: left;\r
+       font-style: italic;\r
+}\r
+\r
+h1 { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size:35px; \r
+       color:#2b476f; \r
+}\r
+\r
+h2 { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size:20px; \r
+       color:#000000;\r
+}\r
+\r
+h3 { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size:16px;\r
+}\r
+\r
+A:link, A:visited, A:active { \r
+       font-family: "Lucida Grande", Verdana; \r
+       font-size: inherit; \r
+       text-decoration: none;\r
+       font-weight:bold; \r
+       color:#2b476f; \r
+}\r
+\r
+A:hover {  \r
+       font-family: "Lucida Grande", Verdana; \r
+       text-decoration: none; \r
+       font-weight:bold; \r
+       color:#222299; \r
+       background-color:#C0C0C0\r
+}\r
+\r
+A[name]:hover {  \r
+       font-family: "Lucida Grande", Verdana; \r
+       text-decoration: inherit; \r
+       font-weight: inherit; \r
+       color: inherit; \r
+       background-color: inherit \r
+}\r
+\r
+.wikitable {\r
+       text-align: left;\r
+       border-collapse: collapse;\r
+}\r
+\r
+.wikitable, .wikitable th, .wikitable td {\r
+       border: 1px solid black;\r
+}\r
diff --git a/bundles/org.simantics.help.ontology/.classpath b/bundles/org.simantics.help.ontology/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.help.ontology/.project b/bundles/org.simantics.help.ontology/.project
new file mode 100644 (file)
index 0000000..1ddcb8d
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.help.ontology</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.simantics.graph.builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.simantics.graph.nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.help.ontology/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.help.ontology/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.help.ontology/META-INF/MANIFEST.MF b/bundles/org.simantics.help.ontology/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..c2a6f1c
--- /dev/null
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Help Ontology
+Bundle-SymbolicName: org.simantics.help.ontology
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.simantics.layer0,
+ org.simantics.viewpoint.ontology;bundle-version="1.2.0",
+ org.simantics.modeling.ontology;bundle-version="1.2.0",
+ org.simantics.silk.ontology;bundle-version="1.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Export-Package: org.simantics.help
diff --git a/bundles/org.simantics.help.ontology/build.properties b/bundles/org.simantics.help.ontology/build.properties
new file mode 100644 (file)
index 0000000..022de17
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .,\\r
+               graph.tg\r
diff --git a/bundles/org.simantics.help.ontology/graph.tg b/bundles/org.simantics.help.ontology/graph.tg
new file mode 100644 (file)
index 0000000..4cb13d0
Binary files /dev/null and b/bundles/org.simantics.help.ontology/graph.tg differ
diff --git a/bundles/org.simantics.help.ontology/graph/Help.pgraph b/bundles/org.simantics.help.ontology/graph/Help.pgraph
new file mode 100644 (file)
index 0000000..ac5a9a4
--- /dev/null
@@ -0,0 +1,57 @@
+L0 = <http://www.simantics.org/Layer0-1.1>
+VP = <http://www.simantics.org/Viewpoint-1.2>
+MOD = <http://www.simantics.org/Modeling-1.2>
+SILK = <http://www.simantics.org/Silk-1.1>
+
+HELP = <http://www.simantics.org/Help-1.0> : L0.Ontology
+    @L0.new
+    L0.HasResourceClass "org.simantics.help.HelpResources"
+
+HELP.SCLMain : L0.SCLModule
+    L0.SCLModule.definition _ : L0.String
+      @L0.loadString "scl/SCLMain.scl"
+
+HELP.HelpLibrary <T L0.Library
+
+HELP.HelpFile <T L0.Entity : MOD.TypeWithChangeInformation : L0.TypeWithIdentifier
+    >-- HELP.HelpFile.contents --> L0.String <R L0.HasProperty : L0.TotalFunction
+    @L0.assert HELP.HelpFile.contents ""
+
+HELP.TutorialFile <T HELP.HelpFile
+
+MAC = MOD.ModelingActionContext
+MBC = MOD.ModelingBrowseContext
+
+ACTIONS = HELP.Actions : L0.Library
+
+ACTIONS.NewHelpLibrary
+    @MOD.sclAction "createHelpLibraryAction"
+ACTIONS.NewHelpTutorial
+    @MOD.sclAction "createHelpTutorialAction"
+
+CONTRIBUTIONS = HELP.Contributions : L0.Library
+
+TESTS = MAC.Tests
+
+MAC
+    VP.BrowseContext.HasActionContribution CONTRIBUTIONS.NewHelpLibrary : VP.ActionContribution
+        L0.HasLabel "Help Library"
+        VP.ActionContribution.HasImage SILK.book
+        VP.ActionContribution.HasCategory VP.NewActionCategory
+        VP.ActionContribution.HasNodeType
+            L0.Library
+        VP.ActionContribution.HasAction ACTIONS.NewHelpLibrary
+        VP.ActionContribution.IsVisibleIf TESTS.IsContainerNotPublished
+    VP.BrowseContext.HasActionContribution CONTRIBUTIONS.NewHelpTutorial : VP.ActionContribution
+        L0.HasLabel "Help Tutorial"
+        VP.ActionContribution.HasImage SILK.page_white_text
+        VP.ActionContribution.HasCategory VP.NewActionCategory
+        VP.ActionContribution.HasNodeType
+            HELP.HelpLibrary
+        VP.ActionContribution.HasAction ACTIONS.NewHelpTutorial
+        VP.ActionContribution.IsVisibleIf TESTS.IsContainerNotPublished
+
+MBC
+    @VP.namedRelationChildRule    CONTRIBUTIONS.HelpFiles           L0.Entity    L0.ConsistsOf    HELP.HelpFile
+    @VP.namedConstantImageRule    CONTRIBUTIONS.HelpFileImage       HELP.HelpFile       SILK.page_white_text
+    @VP.namedConstantImageRule    CONTRIBUTIONS.HelpLibraryImage    HELP.HelpLibrary    SILK.book
diff --git a/bundles/org.simantics.help.ontology/graph/scl/SCLMain.scl b/bundles/org.simantics.help.ontology/graph/scl/SCLMain.scl
new file mode 100644 (file)
index 0000000..f786f15
--- /dev/null
@@ -0,0 +1,2 @@
+include "Simantics/All"\r
+include "Simantics/Help"
\ No newline at end of file
diff --git a/bundles/org.simantics.help.ontology/src/org/simantics/help/HelpResources.java b/bundles/org.simantics.help.ontology/src/org/simantics/help/HelpResources.java
new file mode 100644 (file)
index 0000000..57b2f54
--- /dev/null
@@ -0,0 +1,100 @@
+package org.simantics.help;\r
+\r
+import org.simantics.db.RequestProcessor;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.service.QueryControl;\r
+\r
+public class HelpResources {\r
+    \r
+    public final Resource Actions;\r
+    public final Resource Actions_NewHelpLibrary;\r
+    public final Resource Actions_NewHelpTutorial;\r
+    public final Resource Contributions;\r
+    public final Resource Contributions_HelpFileImage;\r
+    public final Resource Contributions_HelpFiles;\r
+    public final Resource Contributions_HelpLibraryImage;\r
+    public final Resource Contributions_NewHelpLibrary;\r
+    public final Resource Contributions_NewHelpTutorial;\r
+    public final Resource HelpFile;\r
+    public final Resource HelpFile_contents;\r
+    public final Resource HelpFile_contents_Inverse;\r
+    public final Resource HelpLibrary;\r
+    public final Resource SCLMain;\r
+    public final Resource TutorialFile;\r
+        \r
+    public static class URIs {\r
+        public static final String Actions = "http://www.simantics.org/Help-1.0/Actions";\r
+        public static final String Actions_NewHelpLibrary = "http://www.simantics.org/Help-1.0/Actions/NewHelpLibrary";\r
+        public static final String Actions_NewHelpTutorial = "http://www.simantics.org/Help-1.0/Actions/NewHelpTutorial";\r
+        public static final String Contributions = "http://www.simantics.org/Help-1.0/Contributions";\r
+        public static final String Contributions_HelpFileImage = "http://www.simantics.org/Help-1.0/Contributions/HelpFileImage";\r
+        public static final String Contributions_HelpFiles = "http://www.simantics.org/Help-1.0/Contributions/HelpFiles";\r
+        public static final String Contributions_HelpLibraryImage = "http://www.simantics.org/Help-1.0/Contributions/HelpLibraryImage";\r
+        public static final String Contributions_NewHelpLibrary = "http://www.simantics.org/Help-1.0/Contributions/NewHelpLibrary";\r
+        public static final String Contributions_NewHelpTutorial = "http://www.simantics.org/Help-1.0/Contributions/NewHelpTutorial";\r
+        public static final String HelpFile = "http://www.simantics.org/Help-1.0/HelpFile";\r
+        public static final String HelpFile_contents = "http://www.simantics.org/Help-1.0/HelpFile/contents";\r
+        public static final String HelpFile_contents_Inverse = "http://www.simantics.org/Help-1.0/HelpFile/contents/Inverse";\r
+        public static final String HelpLibrary = "http://www.simantics.org/Help-1.0/HelpLibrary";\r
+        public static final String SCLMain = "http://www.simantics.org/Help-1.0/SCLMain";\r
+        public static final String TutorialFile = "http://www.simantics.org/Help-1.0/TutorialFile";\r
+    }\r
+    \r
+    public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
+        try {\r
+            return graph.getResource(uri);\r
+        } catch(DatabaseException e) {\r
+            System.err.println(e.getMessage());\r
+            return null;\r
+        }\r
+    }\r
+    \r
+    public HelpResources(ReadGraph graph) {\r
+        Actions = getResourceOrNull(graph, URIs.Actions);\r
+        Actions_NewHelpLibrary = getResourceOrNull(graph, URIs.Actions_NewHelpLibrary);\r
+        Actions_NewHelpTutorial = getResourceOrNull(graph, URIs.Actions_NewHelpTutorial);\r
+        Contributions = getResourceOrNull(graph, URIs.Contributions);\r
+        Contributions_HelpFileImage = getResourceOrNull(graph, URIs.Contributions_HelpFileImage);\r
+        Contributions_HelpFiles = getResourceOrNull(graph, URIs.Contributions_HelpFiles);\r
+        Contributions_HelpLibraryImage = getResourceOrNull(graph, URIs.Contributions_HelpLibraryImage);\r
+        Contributions_NewHelpLibrary = getResourceOrNull(graph, URIs.Contributions_NewHelpLibrary);\r
+        Contributions_NewHelpTutorial = getResourceOrNull(graph, URIs.Contributions_NewHelpTutorial);\r
+        HelpFile = getResourceOrNull(graph, URIs.HelpFile);\r
+        HelpFile_contents = getResourceOrNull(graph, URIs.HelpFile_contents);\r
+        HelpFile_contents_Inverse = getResourceOrNull(graph, URIs.HelpFile_contents_Inverse);\r
+        HelpLibrary = getResourceOrNull(graph, URIs.HelpLibrary);\r
+        SCLMain = getResourceOrNull(graph, URIs.SCLMain);\r
+        TutorialFile = getResourceOrNull(graph, URIs.TutorialFile);\r
+    }\r
+    \r
+    public static HelpResources getInstance(ReadGraph graph) {\r
+        Session session = graph.getSession();\r
+        HelpResources ret = session.peekService(HelpResources.class);\r
+        if(ret == null) {\r
+            QueryControl qc = graph.getService(QueryControl.class);\r
+            ret = new HelpResources(qc.getIndependentGraph(graph));\r
+            session.registerService(HelpResources.class, ret);\r
+        }\r
+        return ret;\r
+    }\r
+    \r
+    public static HelpResources getInstance(RequestProcessor session) throws DatabaseException {\r
+        HelpResources ret = session.peekService(HelpResources.class);\r
+        if(ret == null) {\r
+            ret = session.syncRequest(new Read<HelpResources>() {\r
+                public HelpResources perform(ReadGraph graph) throws DatabaseException {\r
+                    QueryControl qc = graph.getService(QueryControl.class);\r
+                    return new HelpResources(qc.getIndependentGraph(graph));\r
+                }\r
+            });\r
+            session.registerService(HelpResources.class, ret);\r
+        }\r
+        return ret;\r
+    }\r
+    \r
+}\r
+\r
diff --git a/bundles/org.simantics.help.ui/.classpath b/bundles/org.simantics.help.ui/.classpath
new file mode 100644 (file)
index 0000000..b862a29
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/bundles/org.simantics.help.ui/.project b/bundles/org.simantics.help.ui/.project
new file mode 100644 (file)
index 0000000..25dbe7a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.help.ui</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/bundles/org.simantics.help.ui/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.help.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..295926d
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8\r
+org.eclipse.jdt.core.compiler.compliance=1.8\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.8\r
diff --git a/bundles/org.simantics.help.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.help.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..e9f8ba1
--- /dev/null
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simantics Help UI
+Bundle-SymbolicName: org.simantics.help.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.simantics.help.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.simantics.ui,
+ org.simantics.help.ontology,
+ winterwell.markdown;bundle-version="1.2.0",
+ org.eclipse.ui.editors;bundle-version="3.9.0",
+ org.eclipse.jface.text;bundle-version="3.10.0",
+ org.eclipse.core.resources;bundle-version="3.10.1",
+ org.simantics.help.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
diff --git a/bundles/org.simantics.help.ui/build.properties b/bundles/org.simantics.help.ui/build.properties
new file mode 100644 (file)
index 0000000..6f20375
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               plugin.xml\r
diff --git a/bundles/org.simantics.help.ui/plugin.xml b/bundles/org.simantics.help.ui/plugin.xml
new file mode 100644 (file)
index 0000000..d5ffa05
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.4"?>\r
+<plugin>\r
+   <extension\r
+         point="org.simantics.ui.resourceEditorAdapter">\r
+      <adapterClass\r
+            class="org.simantics.help.ui.OpenHelpFileAdapter"\r
+            priority="0">\r
+      </adapterClass>\r
+   </extension>\r
+   <extension\r
+         point="org.eclipse.ui.editors">\r
+      <editor\r
+            class="org.simantics.help.ui.HelpFileEditor"\r
+            contributorClass="winterwell.markdown.editors.ActionBarContributor"\r
+            default="false"\r
+            id="org.simantics.help.ui.HelpFileEditor"\r
+            name="Simantics Help File Editor">\r
+      </editor>\r
+   </extension>\r
+\r
+</plugin>\r
diff --git a/bundles/org.simantics.help.ui/src/org/simantics/help/ui/Activator.java b/bundles/org.simantics.help.ui/src/org/simantics/help/ui/Activator.java
new file mode 100644 (file)
index 0000000..2a38479
--- /dev/null
@@ -0,0 +1,50 @@
+package org.simantics.help.ui;\r
+\r
+import org.eclipse.ui.plugin.AbstractUIPlugin;\r
+import org.osgi.framework.BundleContext;\r
+\r
+/**\r
+ * The activator class controls the plug-in life cycle\r
+ */\r
+public class Activator extends AbstractUIPlugin {\r
+\r
+       // The plug-in ID\r
+       public static final String PLUGIN_ID = "org.simantics.help.ui"; //$NON-NLS-1$\r
+\r
+       // The shared instance\r
+       private static Activator plugin;\r
+       \r
+       /**\r
+        * The constructor\r
+        */\r
+       public Activator() {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)\r
+        */\r
+       public void start(BundleContext context) throws Exception {\r
+               super.start(context);\r
+               plugin = this;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)\r
+        */\r
+       public void stop(BundleContext context) throws Exception {\r
+               plugin = null;\r
+               super.stop(context);\r
+       }\r
+\r
+       /**\r
+        * Returns the shared instance\r
+        *\r
+        * @return the shared instance\r
+        */\r
+       public static Activator getDefault() {\r
+               return plugin;\r
+       }\r
+\r
+}\r
diff --git a/bundles/org.simantics.help.ui/src/org/simantics/help/ui/HelpFileDocumentProvider.java b/bundles/org.simantics.help.ui/src/org/simantics/help/ui/HelpFileDocumentProvider.java
new file mode 100644 (file)
index 0000000..d199490
--- /dev/null
@@ -0,0 +1,94 @@
+package org.simantics.help.ui;\r
+\r
+import java.io.PrintWriter;\r
+import java.io.StringWriter;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.jface.operation.IRunnableContext;\r
+import org.eclipse.jface.text.Document;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.source.IAnnotationModel;\r
+import org.eclipse.ui.texteditor.AbstractDocumentProvider;\r
+import org.simantics.Simantics;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
+import org.simantics.help.core.HelpUtils;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.ui.workbench.IResourceEditorInput;\r
+import org.simantics.utils.logging.TimeLogger;\r
+\r
+public class HelpFileDocumentProvider extends AbstractDocumentProvider {\r
+\r
+    private Resource resource;\r
+    private String currentText;\r
+    private boolean errorHappened;\r
+\r
+    @Override\r
+    protected IDocument createDocument(Object element) throws CoreException {\r
+        IResourceEditorInput input = (IResourceEditorInput) element;\r
+        resource = input.getResource();\r
+        try {\r
+            return Simantics.getSession().syncRequest(new UniqueRead<Document>() {\r
+                @Override\r
+                public Document perform(ReadGraph graph) throws DatabaseException {\r
+                    currentText = HelpUtils.readHelpFileContents(graph, resource);\r
+                    errorHappened = false;\r
+                    return new Document(currentText != null ? currentText : "");\r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            StringWriter sw = new StringWriter();\r
+            PrintWriter pw = new PrintWriter(sw);\r
+            e.printStackTrace(pw);\r
+            errorHappened = true;\r
+            return new Document(sw.toString());\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {\r
+        return null;\r
+    }\r
+\r
+    @Override\r
+    protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {\r
+        TimeLogger.resetTimeAndLog("HelpFileDocumentProvider.doSaveDocument");\r
+        currentText = document.get();\r
+        Simantics.getSession().asyncRequest(new WriteRequest() {\r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+                graph.markUndoPoint();\r
+                HelpUtils.saveHelpFileContents(graph, resource, currentText);\r
+                Layer0Utils.addCommentMetadata(graph, "Saved SCL Module " + graph.getRelatedValue2(resource, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
+            }\r
+        });\r
+    }\r
+\r
+    @Override\r
+    protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {\r
+        return null;\r
+    }\r
+    \r
+    @Override\r
+    public boolean isModifiable(Object element) {\r
+        return !errorHappened;\r
+    }\r
+    \r
+    @Override\r
+    public boolean isReadOnly(Object element) {\r
+        return errorHappened;\r
+    }\r
+\r
+    @Override\r
+    public boolean canSaveDocument(Object element) {\r
+        return !errorHappened && !getDocument(element).get().equals(currentText);\r
+    }\r
+\r
+}\r
diff --git a/bundles/org.simantics.help.ui/src/org/simantics/help/ui/HelpFileEditor.java b/bundles/org.simantics.help.ui/src/org/simantics/help/ui/HelpFileEditor.java
new file mode 100644 (file)
index 0000000..2b5eaca
--- /dev/null
@@ -0,0 +1,93 @@
+package org.simantics.help.ui;\r
+\r
+import java.util.function.Supplier;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorSite;\r
+import org.eclipse.ui.PartInitException;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.common.request.ParametrizedRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.request.combinations.Combinators;\r
+import org.simantics.ui.workbench.IResourceEditorInput;\r
+import org.simantics.ui.workbench.ResourceEditorSupport;\r
+import org.simantics.ui.workbench.TitleUpdater;\r
+import org.simantics.ui.workbench.TitleWithParentNameRequest;\r
+import org.simantics.ui.workbench.ToolTipRequest;\r
+import org.simantics.ui.workbench.editor.input.InputValidationCombinators;\r
+\r
+import winterwell.markdown.editors.MarkdownEditor;\r
+\r
+public class HelpFileEditor extends MarkdownEditor {\r
+\r
+    private static final String EDITOR_ID = "org.simantics.help.ui.HelpFileEditor";\r
+\r
+    private boolean disposed;\r
+\r
+    private static final ParametrizedRead<IResourceEditorInput, Boolean> INPUT_VALIDATOR = \r
+            Combinators.compose(InputValidationCombinators.hasURI(), InputValidationCombinators.extractInputResource());\r
+\r
+    private ResourceEditorSupport support;\r
+\r
+    public HelpFileEditor() {\r
+        super();\r
+        setDocumentProvider(new HelpFileDocumentProvider());\r
+    }\r
+\r
+    @Override\r
+    public void init(IEditorSite site, IEditorInput input) throws PartInitException {\r
+        super.init(site, input);\r
+\r
+        support = new ResourceEditorSupport(this, INPUT_VALIDATOR);\r
+        support.activateValidation();\r
+        try {\r
+            getResourceInput().init(null);\r
+        } catch (DatabaseException e) {\r
+            throw new PartInitException("Failed to initialize " + input, e);\r
+        }\r
+\r
+    }\r
+\r
+    protected IResourceEditorInput getResourceInput() {\r
+        return (IResourceEditorInput) getEditorInput();\r
+    }\r
+\r
+    @Override\r
+    public void createPartControl(Composite parent) {\r
+        super.createPartControl(parent);\r
+        updatePartName();\r
+    }\r
+\r
+    protected void updatePartName() {\r
+        setPartName(getEditorInput().getName());\r
+\r
+        Session session = Simantics.peekSession();\r
+        if (session != null) {\r
+            Supplier<Boolean> disposedCallback = this::isDisposed;\r
+            session.asyncRequest(new TitleWithParentNameRequest(getResourceInput()),\r
+                    new TitleUpdater(getSite().getShell().getDisplay(), this::setPartName, disposedCallback));\r
+            session.asyncRequest(new ToolTipRequest(getSite().getId(), getResourceInput()),\r
+                    new TitleUpdater(getSite().getShell().getDisplay(), this::setTitleToolTip, disposedCallback));\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        disposed = true;\r
+        if (support != null) {\r
+            support.dispose();\r
+            support = null;\r
+        }\r
+        super.dispose();\r
+    }\r
+\r
+    public boolean isDisposed() {\r
+        return disposed;\r
+    }\r
+\r
+    public static String getEditorId() {\r
+        return EDITOR_ID;\r
+    }\r
+}\r
diff --git a/bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java b/bundles/org.simantics.help.ui/src/org/simantics/help/ui/OpenHelpFileAdapter.java
new file mode 100644 (file)
index 0000000..c5847ce
--- /dev/null
@@ -0,0 +1,60 @@
+package org.simantics.help.ui;\r
+\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.simantics.Logger;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.PossibleIndexRoot;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.RVI;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.help.HelpResources;\r
+import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;\r
+import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
+\r
+public class OpenHelpFileAdapter extends AbstractResourceEditorAdapter {\r
+\r
+    public OpenHelpFileAdapter() {\r
+        super("Help File Editor");\r
+    }\r
+\r
+    protected String getEditorId() {\r
+        return HelpFileEditor.getEditorId();\r
+    }\r
+    \r
+    @Override\r
+    protected boolean canHandle(ReadGraph g, Resource input) throws DatabaseException {\r
+        return g.isInstanceOf(input, HelpResources.getInstance(g).HelpFile);\r
+    }\r
+    \r
+    @Override\r
+    protected void openEditor(Resource input) throws Exception {\r
+        Simantics.getSession().asyncRequest(new ReadRequest() {\r
+            @Override\r
+            public void run(ReadGraph g) throws DatabaseException {\r
+\r
+                Variable variable = Variables.getVariable(g, input);\r
+                final Resource model = g.syncRequest(new PossibleIndexRoot(input));\r
+                final RVI rvi = variable.getPossibleRVI(g);\r
+                \r
+                PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
+                    @Override\r
+                    public void run() {\r
+                        try {\r
+                            String editorId = getEditorId();\r
+                            WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, input, model, rvi));\r
+                        } catch (PartInitException e) {\r
+                            Logger.defaultLogError(e);\r
+                        }\r
+                    }\r
+                });\r
+            }\r
+        });\r
+    }\r
+\r
+}\r
index e91b7d78667a95a74da0f238ab37f7aca44c27b2..ac50e3e73525dab3bd2f5afb71c59a0ab97800ed 100644 (file)
@@ -86,6 +86,9 @@ importJava "org.simantics.db.ReadGraph" where
     \r
     getDataType :: Resource -> <ReadGraph> Datatype\r
 \r
+    @JavaName getSupertypes\r
+    superTypesOf :: Resource -> <ReadGraph> Set.T Resource\r
+    \r
     @private\r
     @JavaName getURI\r
     uriOfResource :: Resource -> <ReadGraph> String\r
index c54048a7387591409cd4eb543780f5d2a982709b..bcfd43a6400bbc06b0112d82846102c3dca25d22 100644 (file)
@@ -119,6 +119,10 @@ importJava "org.simantics.db.layer0.variable.Variable" where
     \r
     @JavaName getProperties\r
     properties_ :: Variable -> <ReadGraph> Collection Variable\r
+    \r
+    @JavaName getProperties\r
+    propertiesClassified_ :: Variable -> Resource -> <ReadGraph> Collection Variable\r
+    \r
     @JavaName getChildren\r
     children_ :: Variable -> <ReadGraph> Collection Variable\r
     \r
@@ -420,4 +424,8 @@ instance Browsable Variable where
     valueOf v = untypedValue v\r
     variantValueOf v = createVariant (datatype v) (untypedValue v :: Dynamic)\r
     child = child_\r
-    possibleChild = possibleChild_
\ No newline at end of file
+    possibleChild = possibleChild_\r
+\r
+propertiesClassified :: Variable -> Resource -> <ReadGraph> [Variable]\r
+propertiesClassified parent classified = do\r
+    collectionToList $ propertiesClassified_ parent classified
\ No newline at end of file
diff --git a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java
new file mode 100644 (file)
index 0000000..0ff973e
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013, 2014 Association for Decentralized \r
+ * Information Management in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the THTH Simantics \r
+ * Division Member Component License which accompanies this \r
+ * distribution, and is available at\r
+ * http://www.simantics.org/legal/sdmcl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.spreadsheet.common;\r
+\r
+import org.simantics.document.server.io.ITreeTableCell;\r
+\r
+public class TreeTableCell extends TableCell implements ITreeTableCell {       \r
+       \r
+       private int parent = -1;\r
+\r
+       public TreeTableCell() {\r
+       }\r
+       \r
+       public void setParent(int parent) {\r
+               this.parent = parent;\r
+       }\r
+       \r
+       @Override\r
+       public int getParent() {\r
+               return parent;\r
+       }\r
+\r
+}\r
index cb35884c7048e1ff572bd511ded9bdf436b841dd..4eeb308d295c394a9bfa397b7728631b46903487 100644 (file)
@@ -7,6 +7,9 @@ include "File"
 importJava "org.simantics.spreadsheet.common.TableCell" where\r
     data TableCell\r
 \r
+importJava "org.simantics.spreadsheet.common.TreeTableCell" where\r
+    data TreeTableCell\r
+\r
 importJava "org.simantics.spreadsheet.common.SpreadsheetCell" where\r
     data SpreadsheetCell\r
 \r
diff --git a/features/org.simantics.desktop.feature/.project b/features/org.simantics.desktop.feature/.project
new file mode 100644 (file)
index 0000000..89848f6
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.desktop.feature</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.FeatureBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.FeatureNature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/features/org.simantics.desktop.feature/build.properties b/features/org.simantics.desktop.feature/build.properties
new file mode 100644 (file)
index 0000000..82ab19c
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = feature.xml\r
diff --git a/features/org.simantics.desktop.feature/feature.xml b/features/org.simantics.desktop.feature/feature.xml
new file mode 100644 (file)
index 0000000..d29ccac
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<feature\r
+      id="org.simantics.desktop"\r
+      label="Simantics Desktop"\r
+      version="1.0.1.qualifier"\r
+      provider-name="Semantum Oy">\r
+\r
+   <description url="http://www.example.com/description">\r
+      [Enter Feature Description here.]\r
+   </description>\r
+\r
+   <copyright url="http://www.example.com/copyright">\r
+      [Enter Copyright Description here.]\r
+   </copyright>\r
+\r
+   <license url="http://www.example.com/license">\r
+      [Enter License Description here.]\r
+   </license>\r
+\r
+   <includes\r
+         id="org.eclipse.equinox.executable"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.simantics.help"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.simantics.issues"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.simantics.modeling"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.simantics.issues.ui"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.simantics.workbench"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.simantics.eclipsec.launcher"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.eclipse.epp.mpc"\r
+         version="0.0.0"/>\r
+\r
+   <includes\r
+         id="org.eclipse.equinox.p2.discovery.feature"\r
+         version="0.0.0"/>\r
+\r
+   <plugin\r
+         id="org.simantics.desktop.ui"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.simantics.desktop.ui.ontology"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+</feature>\r
diff --git a/features/org.simantics.desktop.product.feature/.project b/features/org.simantics.desktop.product.feature/.project
new file mode 100644 (file)
index 0000000..2931342
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.simantics.desktop.product.feature</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.FeatureBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.FeatureNature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/features/org.simantics.desktop.product.feature/build.properties b/features/org.simantics.desktop.product.feature/build.properties
new file mode 100644 (file)
index 0000000..82ab19c
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = feature.xml\r
diff --git a/features/org.simantics.desktop.product.feature/feature.xml b/features/org.simantics.desktop.product.feature/feature.xml
new file mode 100644 (file)
index 0000000..a7292c7
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<feature\r
+      id="org.simantics.desktop.product"\r
+      label="Simantics Desktop Product Feature"\r
+      version="1.0.0.qualifier"\r
+      provider-name="Semantum Oy">\r
+\r
+   <description url="http://www.example.com/description">\r
+      [Enter Feature Description here.]\r
+   </description>\r
+\r
+   <copyright url="http://www.example.com/copyright">\r
+      [Enter Copyright Description here.]\r
+   </copyright>\r
+\r
+   <license url="http://www.example.com/license">\r
+      [Enter License Description here.]\r
+   </license>\r
+\r
+   <includes\r
+         id="org.simantics.desktop"\r
+         version="0.0.0"/>\r
+\r
+   <plugin\r
+         id="org.simantics.desktop.product"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+</feature>\r