]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Several Wiki documentation view improvements.
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 29 Aug 2016 09:17:11 +0000 (12:17 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 29 Aug 2016 09:17:11 +0000 (12:17 +0300)
* Pin Selection toggle button added to Documentation view toolbar
* Added support for linking to internal documents within the Simantics database in wiki documentation: [[Media:root://Documents/Document.pdf|This is the anchor text for the created link]]
** DocumentDialect will transform links like this into external links that look like this: [http://simantics-internal/http://Projects/Development%20Project/Project/Documents/Document.pdf This is the anchor text for the created link]
** Obviously external browsers and viewers do not understand these links but when these links are clicked in the Workbench Documentation view, the Browser component location changes are intercepted by the function returned by org.simantics.document.ui.function.All.locationChanging and the workbench's default action is performed for the database resource/variable that the URI in the link resolves to in the Simantics database.
* DiagramViewerSelectionProvider.SelectionElement will now return a the variable of the diagram composite when element selection is the diagram resource itself. This helps the Documentation view show the wiki page of the diagram composite when nothing is selected on the diagram editor.
* Fixed a couple of typos from org.simantics.scl.reflection.internal.registry.Namespace
* org.simantics.views.ontology now supports defining SWT RowLayout/RowData for modelled composites. This is used in the Documentation view to flow all the action buttons above the text editor to separate rows even when the view is not wide enough to fit all buttons on a single row.

refs #6449

21 files changed:
bundles/org.simantics.document.ui.ontology/graph.tg
bundles/org.simantics.document.ui.ontology/graph/DocumentUI.pgraph
bundles/org.simantics.document.ui.ontology/src/org/simantics/document/ui/DocumentUIResource.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/DocumentView.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/All.java
bundles/org.simantics.document/src/org/simantics/document/DocumentDialect.java
bundles/org.simantics.document/src/org/simantics/document/function/All.java
bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/registry/Namespace.java
bundles/org.simantics.views.ontology/graph.tg
bundles/org.simantics.views.ontology/graph/Views.pgraph
bundles/org.simantics.views.ontology/src/org/simantics/views/ontology/ViewsResources.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/base/SWTViewUtils.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/base/SingleSWTViewNode.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTBrowser.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTComposite.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTExplorer.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTSashForm.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTScrolledComposite.java
bundles/org.simantics.views.swt.client/src/org/simantics/views/swt/client/impl/SWTTabFolder.java
bundles/org.simantics.views/src/org/simantics/views/All.java
bundles/org.simantics.views/src/org/simantics/views/ViewUtils.java

index 0501da80502987c0dafd4f487d754a5686c2a3cf..a32cf12e7b099dd425525150c5fb82651e506854 100644 (file)
Binary files a/bundles/org.simantics.document.ui.ontology/graph.tg and b/bundles/org.simantics.document.ui.ontology/graph.tg differ
index 914bdca44c3ec39c24bf7760ab8b1df83691614a..cb7cd6498d3139072b14268adac3cff8d40ccbcc 100644 (file)
@@ -38,8 +38,12 @@ UI.WikitextContribution.View : VIEWS.Composite
   SG.Node.children _ : L0.List
     @L0.list
       _ : VIEWS.Composite
-        VIEWS.Composite.layout _ : VIEWS.GridLayout
-          VIEWS.GridLayout.columnCount 19
+        VIEWS.Composite.layout _ : VIEWS.RowLayout
+          //VIEWS.RowLayout.type VIEWS.Control.Style.Constant.Horizontal
+          //VIEWS.RowLayout.spacing 0
+          //VIEWS.RowLayout.justify true
+          //VIEWS.RowLayout.pack true
+          //VIEWS.RowLayout.wrap true
         VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
           VIEWS.GridLayout.GridData.horizontalGrab true
         SG.Node.children _ : L0.List
@@ -49,135 +53,102 @@ UI.WikitextContribution.View : VIEWS.Composite
               VIEWS.Button.tooltip "Makes selection bold or inserts some bold text at cursor"
               VIEWS.Button.modifier UI.Functions.boldModifier : L0.Function
               VIEWS.Button.image SILK.text_bold
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Makes selection italic or inserts some italic text at cursor"
               VIEWS.Button.modifier UI.Functions.italicModifier : L0.Function
               VIEWS.Button.image SILK.text_italic
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Makes selection strikethrough or inserts some strikethrough text at cursor"
               VIEWS.Button.modifier UI.Functions.strikethroughModifier : L0.Function
               VIEWS.Button.image SILK.text_strikethrough
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Makes selection underlined or inserts some underlined text at cursor"
               VIEWS.Button.modifier UI.Functions.underlineModifier : L0.Function
               VIEWS.Button.image SILK.text_underline
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a horizontal ruler at cursor"
               VIEWS.Button.modifier UI.Functions.horizontalRulerModifier : L0.Function
               VIEWS.Button.image SILK.text_horizontalrule
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Indents text"
               VIEWS.Button.modifier UI.Functions.indentModifier : L0.Function
               VIEWS.Button.image SILK.text_indent
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Modifies selection font or inserts text with font settings"
               VIEWS.Button.modifier UI.Functions.fontModifier : L0.Function
               VIEWS.Button.image SILK.font
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts an image"
               VIEWS.Button.modifier UI.Functions.imageModifier : L0.Function
               VIEWS.Button.image SILK.image
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
+            _ : VIEWS.Button
+              VIEWS.Button.tooltip "Inserts an internal model-specific document link"
+              VIEWS.Button.modifier UI.Functions.internalLinkModifier : L0.Function
+              VIEWS.Button.image SILK.database_link
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
+            _ : VIEWS.Button
+              VIEWS.Button.tooltip "Inserts an external website link"
+              VIEWS.Button.modifier UI.Functions.linkModifier : L0.Function
+              VIEWS.Button.image SILK.world_link
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a 1st level header"
               VIEWS.Button.modifier UI.Functions.header1Modifier : L0.Function
               VIEWS.Button.image SILK.text_heading_1
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a 2nd level header"
               VIEWS.Button.modifier UI.Functions.header2Modifier : L0.Function
               VIEWS.Button.image SILK.text_heading_2
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a 3rd level header"
               VIEWS.Button.modifier UI.Functions.header3Modifier : L0.Function
               VIEWS.Button.image SILK.text_heading_3
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a 4th level header"
               VIEWS.Button.modifier UI.Functions.header4Modifier : L0.Function
               VIEWS.Button.image SILK.text_heading_4
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a numbered list"
               VIEWS.Button.modifier UI.Functions.numberedListModifier : L0.Function
               VIEWS.Button.image SILK.text_list_numbers
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a bullet list"
               VIEWS.Button.modifier UI.Functions.bulletListModifier : L0.Function
               VIEWS.Button.image SILK.text_list_bullets
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.tooltip "Inserts a table"
               VIEWS.Button.modifier UI.Functions.tableModifier : L0.Function
               VIEWS.Button.image SILK.table
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
-            _ : VIEWS.Button
-              VIEWS.Button.tooltip "Inserts an external website link"
-              VIEWS.Button.modifier UI.Functions.linkModifier : L0.Function
-              VIEWS.Button.image SILK.link
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.text "&Styles"
               VIEWS.Button.tooltip "Edits document styles"
               VIEWS.Button.modifier UI.Functions.styleModifier : L0.Function
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.text "&Apply changes"
               VIEWS.Button.tooltip "Applies any changes in the wiki markup into the document"
               VIEWS.Button.modifier UI.Functions.wikitextModifier : L0.Function
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
             _ : VIEWS.Button
               VIEWS.Button.text "Delete document"
               VIEWS.Button.tooltip "Deletes the document"
               VIEWS.Button.modifier UI.Functions.onDeleteDocumentButton : L0.Function
-              VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
-                VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
-                VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+              VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
 
       UI.WikitextContribution.View.TextContainer : VIEWS.Composite
         VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
@@ -242,6 +213,8 @@ UI.Sash : VIEWS.SashForm
             VIEWS.GridLayout.GridData.verticalGrab true
         VIEWS.Browser.variable DOC.Functions.documentationRootVariable
         VIEWS.Browser.document DOC.Functions.documentationText
+        VIEWS.Browser.locationChanging UI.Functions.locationChanging : L0.Function
+            L0.HasValueType "a -> Boolean"
       UI.WikitextContribution.View
 
 UI.NoDocument : VIEWS.Composite
index 7c5b0f4559e520d83077c26b75f32b053f35f2a4..82375ae2a99d9615d457247acc404e568a538a7f 100644 (file)
@@ -34,9 +34,11 @@ public class DocumentUIResource {
     public final Resource Functions_horizontalRulerModifier;\r
     public final Resource Functions_imageModifier;\r
     public final Resource Functions_indentModifier;\r
+    public final Resource Functions_internalLinkModifier;\r
     public final Resource Functions_isWikitext;\r
     public final Resource Functions_italicModifier;\r
     public final Resource Functions_linkModifier;\r
+    public final Resource Functions_locationChanging;\r
     public final Resource Functions_noDocumentText;\r
     public final Resource Functions_numberedListModifier;\r
     public final Resource Functions_onCreateDocumentButton;\r
@@ -83,9 +85,11 @@ public class DocumentUIResource {
         public static final String Functions_horizontalRulerModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/horizontalRulerModifier";\r
         public static final String Functions_imageModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/imageModifier";\r
         public static final String Functions_indentModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/indentModifier";\r
+        public static final String Functions_internalLinkModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/internalLinkModifier";\r
         public static final String Functions_isWikitext = "http://www.simantics.org/DocumentUI-1.1/Functions/isWikitext";\r
         public static final String Functions_italicModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/italicModifier";\r
         public static final String Functions_linkModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/linkModifier";\r
+        public static final String Functions_locationChanging = "http://www.simantics.org/DocumentUI-1.1/Functions/locationChanging";\r
         public static final String Functions_noDocumentText = "http://www.simantics.org/DocumentUI-1.1/Functions/noDocumentText";\r
         public static final String Functions_numberedListModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/numberedListModifier";\r
         public static final String Functions_onCreateDocumentButton = "http://www.simantics.org/DocumentUI-1.1/Functions/onCreateDocumentButton";\r
@@ -142,9 +146,11 @@ public class DocumentUIResource {
         Functions_horizontalRulerModifier = getResourceOrNull(graph, URIs.Functions_horizontalRulerModifier);\r
         Functions_imageModifier = getResourceOrNull(graph, URIs.Functions_imageModifier);\r
         Functions_indentModifier = getResourceOrNull(graph, URIs.Functions_indentModifier);\r
+        Functions_internalLinkModifier = getResourceOrNull(graph, URIs.Functions_internalLinkModifier);\r
         Functions_isWikitext = getResourceOrNull(graph, URIs.Functions_isWikitext);\r
         Functions_italicModifier = getResourceOrNull(graph, URIs.Functions_italicModifier);\r
         Functions_linkModifier = getResourceOrNull(graph, URIs.Functions_linkModifier);\r
+        Functions_locationChanging = getResourceOrNull(graph, URIs.Functions_locationChanging);\r
         Functions_noDocumentText = getResourceOrNull(graph, URIs.Functions_noDocumentText);\r
         Functions_numberedListModifier = getResourceOrNull(graph, URIs.Functions_numberedListModifier);\r
         Functions_onCreateDocumentButton = getResourceOrNull(graph, URIs.Functions_onCreateDocumentButton);\r
index ccbfbd5083fe415a6b570274ddeaee431934d0bd..025b88b0808348357691bbb9c0f169f3eb65c7f6 100644 (file)
  *******************************************************************************/\r
 package org.simantics.document.ui;\r
 \r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.action.IAction;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchPart;\r
 import org.simantics.ui.workbench.IPropertyPage;\r
+import org.simantics.utils.ui.BundleUtils;\r
 import org.simantics.views.swt.ModelledView;\r
 \r
 /**\r
@@ -19,6 +24,8 @@ import org.simantics.views.swt.ModelledView;
  */\r
 public class DocumentView extends ModelledView {\r
 \r
+    private boolean pinSelection = false;\r
+\r
     @Override\r
     protected String configurationURI() {\r
         return DocumentUIResource.URIs.View;\r
@@ -29,4 +36,32 @@ public class DocumentView extends ModelledView {
         return null;\r
     }\r
 \r
+    @Override\r
+    protected void inputChanged(IWorkbenchPart provider, Object input) {\r
+        if (pinSelection)\r
+            return;\r
+        super.inputChanged(provider, input);\r
+    }\r
+\r
+    @Override\r
+    public void createPartControl(Composite parent) {\r
+        super.createPartControl(parent);\r
+        getViewSite().getActionBars().getToolBarManager().add(new PinSelection());\r
+    }\r
+\r
+    private class PinSelection extends Action {\r
+        public PinSelection() {\r
+            super("Pin Selection", IAction.AS_CHECK_BOX);\r
+            setImageDescriptor(\r
+                    BundleUtils.getImageDescriptorFromPlugin(\r
+                            "org.eclipse.ui",\r
+                            "icons/full/etool16/pin_editor.png"));\r
+        }\r
+\r
+        @Override\r
+        public void run() {\r
+            pinSelection = isChecked();\r
+        }\r
+    }\r
+\r
 }\r
index 20b8d3d0e66cb050670b0d701330300b670d9ded..e5f8b439238c9b1709a2f4d13e6d3df38527e831 100644 (file)
@@ -13,8 +13,11 @@ package org.simantics.document.ui.function;
 \r
 import java.util.TreeMap;\r
 \r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
 import org.eclipse.jface.viewers.ISelectionProvider;\r
 import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.browser.LocationEvent;\r
 import org.eclipse.swt.graphics.FontData;\r
 import org.eclipse.swt.graphics.Point;\r
 import org.eclipse.swt.graphics.RGB;\r
@@ -30,19 +33,26 @@ import org.simantics.browsing.ui.NodeContext;
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.UnaryRead;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.RequestUtil;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.adapter.Instances;\r
 import org.simantics.db.layer0.request.PossibleModel;\r
+import org.simantics.db.layer0.request.PossibleResource;\r
 import org.simantics.db.layer0.util.RemoverUtil;\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.document.DocumentDialect;\r
 import org.simantics.document.DocumentResource;\r
 import org.simantics.document.DocumentUtils;\r
+import org.simantics.document.ui.Activator;\r
 import org.simantics.document.ui.CSSEditor;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.scenegraph.INode;\r
@@ -50,9 +60,12 @@ import org.simantics.scenegraph.loader.ScenegraphLoaderProcess;
 import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;\r
 import org.simantics.scenegraph.loader.ScenegraphLoaderUtils.ScenegraphPropertyReference;\r
 import org.simantics.scl.reflection.annotations.SCLValue;\r
+import org.simantics.scl.runtime.function.Function1;\r
 import org.simantics.scl.runtime.function.FunctionImpl1;\r
 import org.simantics.scl.runtime.function.FunctionImpl3;\r
+import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.ui.workbench.action.DefaultActions;\r
 import org.simantics.utils.threads.SWTThread;\r
 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
 \r
@@ -546,7 +559,7 @@ public class All {
                        @Override\r
                        void perform(String before, String selected, String after, Point selection) {\r
 \r
-                               textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + selected + after);\r
+                               textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + "\r\n" + selected + after);\r
                                \r
                        }\r
                        \r
@@ -683,6 +696,18 @@ public class All {
         \r
     }\r
 \r
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")\r
+    public static Object internalLinkModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {\r
+        return new WikiButtonModifier(graph, context) {\r
+            @Override\r
+            void perform(String before, String selected, String after, Point selection) {\r
+                textReference.setValue(before +\r
+                        "[[Media:root://Documents/Document.pdf|Link to a file within the model]]\r\n" + selected + after);\r
+                \r
+            }\r
+        };\r
+    }\r
+    \r
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")\r
     public static Object linkModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {\r
 \r
@@ -691,8 +716,8 @@ public class All {
                        @Override\r
                        void perform(String before, String selected, String after, Point selection) {\r
 \r
-                               textReference.setValue(before + "\r\n" +\r
-                                               "[http://www.simantics.org External Website Link]\r\n"  + selected + after);\r
+                               textReference.setValue(before +\r
+                                               "[http://www.simantics.org External Website Link]\r\n" + selected + after);\r
                                \r
                        }\r
                        \r
@@ -815,5 +840,51 @@ public class All {
        return true;\r
        \r
     }\r
-    \r
+\r
+    private static class ResolveURI extends UnaryRead<String, Object> {\r
+        public ResolveURI(String uri) {\r
+            super(uri);\r
+        }\r
+        @Override\r
+        public Object perform(ReadGraph graph) throws DatabaseException {\r
+            Object result = graph.syncRequest(new PossibleResource(parameter));\r
+            if (result == null)\r
+                result = Variables.getPossibleVariable(graph, parameter);\r
+            return result;\r
+        }\r
+    }\r
+\r
+    private static final Function1<Object, Boolean> PERFORM_DEFAULT_ACTION_FOR_URI_RESOURCE = new Function1<Object, Boolean>() {\r
+        @Override\r
+        public Boolean apply(Object p0) {\r
+            LocationEvent le = (LocationEvent) p0;\r
+            if (le.location.startsWith(DocumentDialect.SIMANTICS_INTERNAL_URI_PREFIX)) {\r
+                // This is not a valid URL anyway so deny relocation.\r
+                le.doit = false;\r
+\r
+                // Try to execute default action for the resource or variable\r
+                // that the URI represents.\r
+                String uri = le.location.substring(DocumentDialect.SIMANTICS_INTERNAL_URI_PREFIX.length());\r
+                try {\r
+                    Session s = Simantics.getSession();\r
+                    Object input = RequestUtil.trySyncRequest(s,\r
+                            SimanticsUI.UI_THREAD_REQUEST_START_TIMEOUT,\r
+                            SimanticsUI.UI_THREAD_REQUEST_EXECUTION_TIMEOUT,\r
+                            new ResolveURI(uri));\r
+                    if (input != null) {\r
+                        DefaultActions.asyncPerformDefaultAction(s, input, false, false, false);\r
+                    }\r
+                } catch (DatabaseException | InterruptedException e) {\r
+                    Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to resolve URI to a database resource or variable: " + uri, e));\r
+                }\r
+            }\r
+            return true;\r
+        }\r
+    };\r
+\r
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")\r
+    public static Function1<Object, Boolean> locationChanging(ReadGraph graph, Resource variable, Variable context) throws DatabaseException {\r
+        return PERFORM_DEFAULT_ACTION_FOR_URI_RESOURCE;\r
+    }\r
+\r
 }\r
index 9fc8e98a7ebb85927f2e76b13dcf8fc9b0094959..7cb6bbee0f669a1f7d2b65536edf87b014a0a475 100644 (file)
  *******************************************************************************/\r
 package org.simantics.document;\r
 \r
-import java.io.File;\r
 import java.io.IOException;\r
 import java.math.BigInteger;\r
+import java.nio.file.Files;\r
+import java.nio.file.Path;\r
 import java.security.MessageDigest;\r
 import java.security.NoSuchAlgorithmException;\r
 import java.util.regex.Matcher;\r
@@ -26,78 +27,109 @@ import org.simantics.db.Resource;
 import org.simantics.db.common.request.PossibleIndexRoot;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.image2.ontology.ImageResource;\r
-import org.simantics.utils.FileUtils;\r
-\r
 \r
 public class DocumentDialect {\r
-    \r
-    final Pattern imagePattern = Pattern.compile("\\[\\[Image(?::([^\\]]+))?\\]\\]");\r
 \r
        final static public DocumentDialect INSTANCE = new DocumentDialect();\r
 \r
-       public String transform(ReadGraph graph, Resource res, String options) {\r
-               \r
+       public static final String SIMANTICS_INTERNAL_URI_PREFIX = "http://simantics-internal/";\r
+\r
+       private static final String HTTP = "http://";\r
+       private static final String ROOT = "root:/";\r
+       private static final String IMAGE = "image";\r
+       private static final String MEDIA = "media";\r
+\r
+       final Pattern imageOrMediaPattern = Pattern.compile("\\[\\[([Ii]mage|[Mm]edia)(?::([^\\]]+))?\\]\\]");\r
+\r
+       private static String digest(byte[] bytes) throws NoSuchAlgorithmException {\r
+               MessageDigest md = MessageDigest.getInstance("MD5");\r
+               md.update(bytes);\r
+               BigInteger number = new BigInteger(1, md.digest());\r
+               return number.toString(16);\r
+       }\r
+\r
+       private static String imageExtension(ReadGraph graph, Resource image) throws DatabaseException {\r
+                  ImageResource IMAGE = ImageResource.getInstance(graph);\r
+               if (graph.isInstanceOf(image, IMAGE.PngImage))\r
+                       return ".png";\r
+               else if (graph.isInstanceOf(image, IMAGE.JpegImage))\r
+                       return ".jpg";\r
+               return null;\r
+       }\r
+\r
+       public String transform(ReadGraph graph, Resource res, String type, String options) {\r
                try {\r
-                       \r
                        String[] parts = options.split("\\|");\r
-                       if(parts.length > 0) {\r
-                               \r
+                       if (parts.length > 0) {\r
                                String uri = parts[0];\r
+\r
                                Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(res));\r
-                               if(indexRoot == null) return null;\r
+                               if (indexRoot == null) return null;\r
                                String rootURI = graph.getURI(indexRoot);\r
-                               uri = uri.replace("root:/", rootURI);\r
-                               // (Apros #12268) For easier image linking, allow users to\r
-                               // write white space as ' ' in the wiki-style image links.\r
+\r
+                               uri = uri.replace(ROOT, rootURI);\r
+\r
+                               // (Apros #12268) For more user-friendly linking, allow users to\r
+                               // write white space as ' ' in the wiki-style image links instead\r
+                               // of having to write %20.\r
                                uri = uri.replace(" ", "%20");\r
-                               Resource image = graph.getPossibleResource(uri);\r
-                               if(image == null) return null;\r
-                               byte[] bytes = graph.getValue(image, Bindings.BYTE_ARRAY);\r
-                               MessageDigest md;\r
-                               md = MessageDigest.getInstance("MD5");\r
-                               md.update(bytes);\r
-                               BigInteger number = new BigInteger(1, md.digest());\r
-                               String digest = number.toString(16);\r
-                               File dir = Simantics.getTemporaryDirectory("documentImages");\r
-                               dir.mkdirs();\r
-                               \r
-                               ImageResource IMAGE = ImageResource.getInstance(graph);\r
-                               \r
-                               String extension;\r
-                               if(graph.isInstanceOf(image, IMAGE.PngImage)) extension = ".png";\r
-                               else if(graph.isInstanceOf(image, IMAGE.JpegImage)) extension = ".jpg";\r
-                               else return null;\r
-                               \r
-                               File f = new File(dir, digest + extension);\r
-                               if(!f.exists())\r
-                                       FileUtils.writeFile(f, bytes);\r
-                               StringBuilder sb = new StringBuilder();\r
-                               sb.append("[[File: " + f.toURI());\r
-                               for(int i=1;i<parts.length;i++) {\r
-                                       sb.append("|");\r
-                                       sb.append(parts[i]);\r
+\r
+                               if (IMAGE.equals(type)) {\r
+                                       Resource image = graph.getPossibleResource(uri);\r
+                                       if (image == null)\r
+                                               return null;\r
+\r
+                                       String extension = imageExtension(graph, image);\r
+                                       if (extension == null)\r
+                                               return null;\r
+\r
+                                       byte[] bytes = graph.getValue(image, Bindings.BYTE_ARRAY);\r
+                                       String digest = digest(bytes);\r
+\r
+                                       Path dir = Simantics.getTemporaryDirectory("documentImages").toPath();\r
+                                       Files.createDirectories(dir);\r
+\r
+                                       Path f = dir.resolve(digest + extension);\r
+                                       if (!Files.exists(f))\r
+                                               Files.write(f, bytes);\r
+\r
+                                       StringBuilder sb = new StringBuilder(128);\r
+                                       sb.append("[[File: ").append(f.toUri());\r
+                                       for (int i = 1; i < parts.length; i++)\r
+                                               sb.append("|").append(parts[i]);\r
+                                       sb.append("]]");\r
+                                       return sb.toString();\r
+                               } else if (MEDIA.equals(type)) {\r
+                                       Resource image = graph.getPossibleResource(uri);\r
+                                       if (image == null)\r
+                                               return null;\r
+\r
+                                       StringBuilder sb = new StringBuilder();\r
+                                       sb.append("[").append(SIMANTICS_INTERNAL_URI_PREFIX).append(uri);\r
+                                       for (int i = 1; i < parts.length; i++)\r
+                                               sb.append(" ").append(parts[i]);\r
+                                       sb.append("]");\r
+                                       return sb.toString();\r
                                }\r
-                               sb.append("]]");\r
-                               return sb.toString();\r
+\r
                        }\r
-                       \r
                } catch (DatabaseException e) {\r
                } catch (NoSuchAlgorithmException e) {\r
                } catch (IOException e) {\r
                }\r
                \r
                return null;\r
-               \r
        }\r
 \r
        public String apply(ReadGraph graph, Resource res, String markup) throws DatabaseException {\r
 \r
                StringBuffer sb = new StringBuffer();\r
-               Matcher matcher = imagePattern.matcher(markup);\r
+               Matcher matcher = imageOrMediaPattern.matcher(markup);\r
                while(matcher.find()) {\r
                        matcher.appendReplacement(sb, "");\r
-                       String options = matcher.group(1);\r
-                       String match = transform(graph, res, options);\r
+                       String type = matcher.group(1);\r
+                       String options = matcher.group(2);\r
+                       String match = transform(graph, res, type.toLowerCase(), options);\r
                        if(match != null) sb.append(match);\r
                        else sb.append("[[Image:" + options + "]]");\r
                }\r
index 3a71cafb7d76a26d26058d9c2b445f02e147d9ce..37f8e0481f7eff1ade2636fb6e855b930e130fe7 100644 (file)
@@ -70,5 +70,4 @@ public class All {
        return result.toString();\r
     }\r
 \r
-    \r
 }\r
index 73be05f6ccb45a58fca0a8276df6420ac522c372..45db1307027f5551039897b741ee1c87f74a532b 100755 (executable)
@@ -181,7 +181,7 @@ public class Namespace {
                 }\r
                 else {\r
                     Activator.logError("Method " + method.getName() + " in class " + \r
-                            clazz.getCanonicalName() + " has incompantible SCL type in the SCLValue annotation."\r
+                            clazz.getCanonicalName() + " has incompatible SCL type in the SCLValue annotation."\r
                             );\r
                     ReflectionUtils.isCompatible(scheme, type, method);\r
                 }\r
@@ -215,7 +215,7 @@ public class Namespace {
                 }\r
                 else {\r
                     Activator.logError("Constructor of " + \r
-                            clazz.getCanonicalName() + " has incompantible SCL type in the SCLValue annotation."\r
+                            clazz.getCanonicalName() + " has incompatible SCL type in the SCLValue annotation."\r
                             );\r
                 }\r
             } catch (TypeNotFoundException e) {\r
@@ -264,7 +264,7 @@ public class Namespace {
                 }\r
                 else {\r
                     Activator.logError("Field " + field.getName() + " in class " + \r
-                            clazz.getCanonicalName() + " has incompantible SCL type in the SCLValue annotation."\r
+                            clazz.getCanonicalName() + " has incompatible SCL type in the SCLValue annotation."\r
                             );\r
                 }\r
             } catch (TypeNotFoundException e) {\r
index ea5e89791c2f201c66c2376e5bb5cf03148cb2f2..a2ec73d89334f9a5a1ca4662daae6a2fc46acf23 100644 (file)
Binary files a/bundles/org.simantics.views.ontology/graph.tg and b/bundles/org.simantics.views.ontology/graph.tg differ
index c91515096fb6bc15d53440f4aa6fab826c882a84..65f9a4cbb2613aced2342deecc6c650690c607cb 100644 (file)
@@ -86,6 +86,8 @@ Views.Control.Style.Constant.Check = 32 : L0.Integer
 Views.Control.Style.Constant.Wrap = 64 : L0.Integer
 Views.Control.Style.Constant.HScroll = 256 : L0.Integer
 Views.Control.Style.Constant.VScroll = 512 : L0.Integer
+Views.Control.Style.Constant.Horizontal = 256 : L0.Integer
+Views.Control.Style.Constant.Vertical = 512 : L0.Integer
 Views.Control.Style.Constant.Border = 2048 : L0.Integer
 Views.Control.Style.Constant.FullSelection = 65536 : L0.Integer
 Views.Control.Style.Constant.NoFocus = 524288 : L0.Integer
@@ -220,6 +222,7 @@ Views.Button <T Views.TextContainer
 Views.Browser <T Views.Control
   >-- Views.Browser.document ==> "String" <R SG.Node.HasProperty : L0.FunctionalRelation
   >-- Views.Browser.variable ==> "Variable" <R SG.Node.HasProperty : L0.FunctionalRelation
+  >-- Views.Browser.locationChanging ==> "a -> Boolean" <R SG.Node.HasProperty : L0.FunctionalRelation
 
 Views.WikiBrowser <T Views.Control
   >-- Views.WikiBrowser.document ==> "String" <R SG.Node.HasProperty : L0.FunctionalRelation
@@ -312,6 +315,42 @@ Views.GridLayout.GridData.CENTER = 2 : L0.Integer
 Views.GridLayout.GridData.END = 3 : L0.Integer
 Views.GridLayout.GridData.FILL = 4 : L0.Integer
 
+Views.RowLayout <T Views.Layout
+  @L0.assert L0.HasValueType "RowLayout"
+  @L0.assert
+    L0.ConvertsToValueWith
+    Views.Functions.rowLayout : L0.ExternalValue
+  >-- Views.RowLayout.type ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.spacing ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.center ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.fill ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.justify ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.pack ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.wrap ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.extendedMargins ==> "a" <R L0.HasProperty : L0.FunctionalRelation
+  @L0.assert Views.RowLayout.type Views.Control.Style.Constant.Horizontal
+  @L0.assert Views.RowLayout.spacing 3
+  @L0.assert Views.RowLayout.center false
+  @L0.assert Views.RowLayout.fill false
+  @L0.assert Views.RowLayout.justify false
+  @L0.assert Views.RowLayout.pack true
+  @L0.assert Views.RowLayout.wrap true
+  @L0.assert Views.RowLayout.extendedMargins 
+    (3,3,3,3) : Views.RowLayout.ExtendedMargins
+
+Views.RowLayout.ExtendedMargins <T L0.Literal
+    @L0.assert L0.HasDataType $(Integer,Integer,Integer,Integer)
+
+Views.RowLayout.RowData <T L0.Value
+  @L0.assert L0.HasValueType "RowData"
+  @L0.assert
+    L0.ConvertsToValueWith
+    Views.Functions.rowData : L0.ExternalValue
+  >-- Views.RowLayout.RowData.width ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+  >-- Views.RowLayout.RowData.height ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+  @L0.assert Views.RowLayout.RowData.width -1
+  @L0.assert Views.RowLayout.RowData.height -1
+
 Views.SingleColumn 
   @Views.Explorer.Column.full "single" "Entries" "LEFT" 150 "Entries" true 1
 
index 1414c21161005dc532a9bb1060f54f2ac3aa9113..21a552b218ad1a1bdab3c292b9bb702972a89e80 100644 (file)
@@ -17,6 +17,8 @@ public class ViewsResources {
     public final Resource Browser;\r
     public final Resource Browser_document;\r
     public final Resource Browser_document_Inverse;\r
+    public final Resource Browser_locationChanging;\r
+    public final Resource Browser_locationChanging_Inverse;\r
     public final Resource Browser_variable;\r
     public final Resource Browser_variable_Inverse;\r
     public final Resource BundleImage;\r
@@ -53,12 +55,14 @@ public class ViewsResources {
     public final Resource Control_Style_Constant_Check;\r
     public final Resource Control_Style_Constant_FullSelection;\r
     public final Resource Control_Style_Constant_HScroll;\r
+    public final Resource Control_Style_Constant_Horizontal;\r
     public final Resource Control_Style_Constant_Multi;\r
     public final Resource Control_Style_Constant_NoFocus;\r
     public final Resource Control_Style_Constant_None;\r
     public final Resource Control_Style_Constant_Push;\r
     public final Resource Control_Style_Constant_ReadOnly;\r
     public final Resource Control_Style_Constant_VScroll;\r
+    public final Resource Control_Style_Constant_Vertical;\r
     public final Resource Control_Style_Constant_Wrap;\r
     public final Resource Control_Style_HasConstant;\r
     public final Resource Control_Style_HasConstant_Inverse;\r
@@ -130,6 +134,8 @@ public class ViewsResources {
     public final Resource Functions_gridLayout;\r
     public final Resource Functions_parameterValue;\r
     public final Resource Functions_resourceURI;\r
+    public final Resource Functions_rowData;\r
+    public final Resource Functions_rowLayout;\r
     public final Resource Functions_singleResourceSelection;\r
     public final Resource Functions_style;\r
     public final Resource Functions_tabChildNames;\r
@@ -193,6 +199,29 @@ public class ViewsResources {
     public final Resource ResourceURI;\r
     public final Resource ResourceURI_HasResource;\r
     public final Resource ResourceURI_HasResource_Inverse;\r
+    public final Resource RowLayout;\r
+    public final Resource RowLayout_ExtendedMargins;\r
+    public final Resource RowLayout_RowData;\r
+    public final Resource RowLayout_RowData_height;\r
+    public final Resource RowLayout_RowData_height_Inverse;\r
+    public final Resource RowLayout_RowData_width;\r
+    public final Resource RowLayout_RowData_width_Inverse;\r
+    public final Resource RowLayout_center;\r
+    public final Resource RowLayout_center_Inverse;\r
+    public final Resource RowLayout_extendedMargins;\r
+    public final Resource RowLayout_extendedMargins_Inverse;\r
+    public final Resource RowLayout_fill;\r
+    public final Resource RowLayout_fill_Inverse;\r
+    public final Resource RowLayout_justify;\r
+    public final Resource RowLayout_justify_Inverse;\r
+    public final Resource RowLayout_pack;\r
+    public final Resource RowLayout_pack_Inverse;\r
+    public final Resource RowLayout_spacing;\r
+    public final Resource RowLayout_spacing_Inverse;\r
+    public final Resource RowLayout_type;\r
+    public final Resource RowLayout_type_Inverse;\r
+    public final Resource RowLayout_wrap;\r
+    public final Resource RowLayout_wrap_Inverse;\r
     public final Resource SashForm;\r
     public final Resource SashForm_Horizontal;\r
     public final Resource SashForm_Vertical;\r
@@ -259,6 +288,8 @@ public class ViewsResources {
         public static final String Browser = "http://www.simantics.org/Views-1.2/Browser";\r
         public static final String Browser_document = "http://www.simantics.org/Views-1.2/Browser/document";\r
         public static final String Browser_document_Inverse = "http://www.simantics.org/Views-1.2/Browser/document/Inverse";\r
+        public static final String Browser_locationChanging = "http://www.simantics.org/Views-1.2/Browser/locationChanging";\r
+        public static final String Browser_locationChanging_Inverse = "http://www.simantics.org/Views-1.2/Browser/locationChanging/Inverse";\r
         public static final String Browser_variable = "http://www.simantics.org/Views-1.2/Browser/variable";\r
         public static final String Browser_variable_Inverse = "http://www.simantics.org/Views-1.2/Browser/variable/Inverse";\r
         public static final String BundleImage = "http://www.simantics.org/Views-1.2/BundleImage";\r
@@ -295,12 +326,14 @@ public class ViewsResources {
         public static final String Control_Style_Constant_Check = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Check";\r
         public static final String Control_Style_Constant_FullSelection = "http://www.simantics.org/Views-1.2/Control/Style/Constant/FullSelection";\r
         public static final String Control_Style_Constant_HScroll = "http://www.simantics.org/Views-1.2/Control/Style/Constant/HScroll";\r
+        public static final String Control_Style_Constant_Horizontal = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Horizontal";\r
         public static final String Control_Style_Constant_Multi = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Multi";\r
         public static final String Control_Style_Constant_NoFocus = "http://www.simantics.org/Views-1.2/Control/Style/Constant/NoFocus";\r
         public static final String Control_Style_Constant_None = "http://www.simantics.org/Views-1.2/Control/Style/Constant/None";\r
         public static final String Control_Style_Constant_Push = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Push";\r
         public static final String Control_Style_Constant_ReadOnly = "http://www.simantics.org/Views-1.2/Control/Style/Constant/ReadOnly";\r
         public static final String Control_Style_Constant_VScroll = "http://www.simantics.org/Views-1.2/Control/Style/Constant/VScroll";\r
+        public static final String Control_Style_Constant_Vertical = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Vertical";\r
         public static final String Control_Style_Constant_Wrap = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Wrap";\r
         public static final String Control_Style_HasConstant = "http://www.simantics.org/Views-1.2/Control/Style/HasConstant";\r
         public static final String Control_Style_HasConstant_Inverse = "http://www.simantics.org/Views-1.2/Control/Style/HasConstant/Inverse";\r
@@ -372,6 +405,8 @@ public class ViewsResources {
         public static final String Functions_gridLayout = "http://www.simantics.org/Views-1.2/Functions/gridLayout";\r
         public static final String Functions_parameterValue = "http://www.simantics.org/Views-1.2/Functions/parameterValue";\r
         public static final String Functions_resourceURI = "http://www.simantics.org/Views-1.2/Functions/resourceURI";\r
+        public static final String Functions_rowData = "http://www.simantics.org/Views-1.2/Functions/rowData";\r
+        public static final String Functions_rowLayout = "http://www.simantics.org/Views-1.2/Functions/rowLayout";\r
         public static final String Functions_singleResourceSelection = "http://www.simantics.org/Views-1.2/Functions/singleResourceSelection";\r
         public static final String Functions_style = "http://www.simantics.org/Views-1.2/Functions/style";\r
         public static final String Functions_tabChildNames = "http://www.simantics.org/Views-1.2/Functions/tabChildNames";\r
@@ -435,6 +470,29 @@ public class ViewsResources {
         public static final String ResourceURI = "http://www.simantics.org/Views-1.2/ResourceURI";\r
         public static final String ResourceURI_HasResource = "http://www.simantics.org/Views-1.2/ResourceURI/HasResource";\r
         public static final String ResourceURI_HasResource_Inverse = "http://www.simantics.org/Views-1.2/ResourceURI/HasResource/Inverse";\r
+        public static final String RowLayout = "http://www.simantics.org/Views-1.2/RowLayout";\r
+        public static final String RowLayout_ExtendedMargins = "http://www.simantics.org/Views-1.2/RowLayout/ExtendedMargins";\r
+        public static final String RowLayout_RowData = "http://www.simantics.org/Views-1.2/RowLayout/RowData";\r
+        public static final String RowLayout_RowData_height = "http://www.simantics.org/Views-1.2/RowLayout/RowData/height";\r
+        public static final String RowLayout_RowData_height_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/RowData/height/Inverse";\r
+        public static final String RowLayout_RowData_width = "http://www.simantics.org/Views-1.2/RowLayout/RowData/width";\r
+        public static final String RowLayout_RowData_width_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/RowData/width/Inverse";\r
+        public static final String RowLayout_center = "http://www.simantics.org/Views-1.2/RowLayout/center";\r
+        public static final String RowLayout_center_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/center/Inverse";\r
+        public static final String RowLayout_extendedMargins = "http://www.simantics.org/Views-1.2/RowLayout/extendedMargins";\r
+        public static final String RowLayout_extendedMargins_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/extendedMargins/Inverse";\r
+        public static final String RowLayout_fill = "http://www.simantics.org/Views-1.2/RowLayout/fill";\r
+        public static final String RowLayout_fill_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/fill/Inverse";\r
+        public static final String RowLayout_justify = "http://www.simantics.org/Views-1.2/RowLayout/justify";\r
+        public static final String RowLayout_justify_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/justify/Inverse";\r
+        public static final String RowLayout_pack = "http://www.simantics.org/Views-1.2/RowLayout/pack";\r
+        public static final String RowLayout_pack_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/pack/Inverse";\r
+        public static final String RowLayout_spacing = "http://www.simantics.org/Views-1.2/RowLayout/spacing";\r
+        public static final String RowLayout_spacing_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/spacing/Inverse";\r
+        public static final String RowLayout_type = "http://www.simantics.org/Views-1.2/RowLayout/type";\r
+        public static final String RowLayout_type_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/type/Inverse";\r
+        public static final String RowLayout_wrap = "http://www.simantics.org/Views-1.2/RowLayout/wrap";\r
+        public static final String RowLayout_wrap_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/wrap/Inverse";\r
         public static final String SashForm = "http://www.simantics.org/Views-1.2/SashForm";\r
         public static final String SashForm_Horizontal = "http://www.simantics.org/Views-1.2/SashForm/Horizontal";\r
         public static final String SashForm_Vertical = "http://www.simantics.org/Views-1.2/SashForm/Vertical";\r
@@ -511,6 +569,8 @@ public class ViewsResources {
         Browser = getResourceOrNull(graph, URIs.Browser);\r
         Browser_document = getResourceOrNull(graph, URIs.Browser_document);\r
         Browser_document_Inverse = getResourceOrNull(graph, URIs.Browser_document_Inverse);\r
+        Browser_locationChanging = getResourceOrNull(graph, URIs.Browser_locationChanging);\r
+        Browser_locationChanging_Inverse = getResourceOrNull(graph, URIs.Browser_locationChanging_Inverse);\r
         Browser_variable = getResourceOrNull(graph, URIs.Browser_variable);\r
         Browser_variable_Inverse = getResourceOrNull(graph, URIs.Browser_variable_Inverse);\r
         BundleImage = getResourceOrNull(graph, URIs.BundleImage);\r
@@ -547,12 +607,14 @@ public class ViewsResources {
         Control_Style_Constant_Check = getResourceOrNull(graph, URIs.Control_Style_Constant_Check);\r
         Control_Style_Constant_FullSelection = getResourceOrNull(graph, URIs.Control_Style_Constant_FullSelection);\r
         Control_Style_Constant_HScroll = getResourceOrNull(graph, URIs.Control_Style_Constant_HScroll);\r
+        Control_Style_Constant_Horizontal = getResourceOrNull(graph, URIs.Control_Style_Constant_Horizontal);\r
         Control_Style_Constant_Multi = getResourceOrNull(graph, URIs.Control_Style_Constant_Multi);\r
         Control_Style_Constant_NoFocus = getResourceOrNull(graph, URIs.Control_Style_Constant_NoFocus);\r
         Control_Style_Constant_None = getResourceOrNull(graph, URIs.Control_Style_Constant_None);\r
         Control_Style_Constant_Push = getResourceOrNull(graph, URIs.Control_Style_Constant_Push);\r
         Control_Style_Constant_ReadOnly = getResourceOrNull(graph, URIs.Control_Style_Constant_ReadOnly);\r
         Control_Style_Constant_VScroll = getResourceOrNull(graph, URIs.Control_Style_Constant_VScroll);\r
+        Control_Style_Constant_Vertical = getResourceOrNull(graph, URIs.Control_Style_Constant_Vertical);\r
         Control_Style_Constant_Wrap = getResourceOrNull(graph, URIs.Control_Style_Constant_Wrap);\r
         Control_Style_HasConstant = getResourceOrNull(graph, URIs.Control_Style_HasConstant);\r
         Control_Style_HasConstant_Inverse = getResourceOrNull(graph, URIs.Control_Style_HasConstant_Inverse);\r
@@ -624,6 +686,8 @@ public class ViewsResources {
         Functions_gridLayout = getResourceOrNull(graph, URIs.Functions_gridLayout);\r
         Functions_parameterValue = getResourceOrNull(graph, URIs.Functions_parameterValue);\r
         Functions_resourceURI = getResourceOrNull(graph, URIs.Functions_resourceURI);\r
+        Functions_rowData = getResourceOrNull(graph, URIs.Functions_rowData);\r
+        Functions_rowLayout = getResourceOrNull(graph, URIs.Functions_rowLayout);\r
         Functions_singleResourceSelection = getResourceOrNull(graph, URIs.Functions_singleResourceSelection);\r
         Functions_style = getResourceOrNull(graph, URIs.Functions_style);\r
         Functions_tabChildNames = getResourceOrNull(graph, URIs.Functions_tabChildNames);\r
@@ -687,6 +751,29 @@ public class ViewsResources {
         ResourceURI = getResourceOrNull(graph, URIs.ResourceURI);\r
         ResourceURI_HasResource = getResourceOrNull(graph, URIs.ResourceURI_HasResource);\r
         ResourceURI_HasResource_Inverse = getResourceOrNull(graph, URIs.ResourceURI_HasResource_Inverse);\r
+        RowLayout = getResourceOrNull(graph, URIs.RowLayout);\r
+        RowLayout_ExtendedMargins = getResourceOrNull(graph, URIs.RowLayout_ExtendedMargins);\r
+        RowLayout_RowData = getResourceOrNull(graph, URIs.RowLayout_RowData);\r
+        RowLayout_RowData_height = getResourceOrNull(graph, URIs.RowLayout_RowData_height);\r
+        RowLayout_RowData_height_Inverse = getResourceOrNull(graph, URIs.RowLayout_RowData_height_Inverse);\r
+        RowLayout_RowData_width = getResourceOrNull(graph, URIs.RowLayout_RowData_width);\r
+        RowLayout_RowData_width_Inverse = getResourceOrNull(graph, URIs.RowLayout_RowData_width_Inverse);\r
+        RowLayout_center = getResourceOrNull(graph, URIs.RowLayout_center);\r
+        RowLayout_center_Inverse = getResourceOrNull(graph, URIs.RowLayout_center_Inverse);\r
+        RowLayout_extendedMargins = getResourceOrNull(graph, URIs.RowLayout_extendedMargins);\r
+        RowLayout_extendedMargins_Inverse = getResourceOrNull(graph, URIs.RowLayout_extendedMargins_Inverse);\r
+        RowLayout_fill = getResourceOrNull(graph, URIs.RowLayout_fill);\r
+        RowLayout_fill_Inverse = getResourceOrNull(graph, URIs.RowLayout_fill_Inverse);\r
+        RowLayout_justify = getResourceOrNull(graph, URIs.RowLayout_justify);\r
+        RowLayout_justify_Inverse = getResourceOrNull(graph, URIs.RowLayout_justify_Inverse);\r
+        RowLayout_pack = getResourceOrNull(graph, URIs.RowLayout_pack);\r
+        RowLayout_pack_Inverse = getResourceOrNull(graph, URIs.RowLayout_pack_Inverse);\r
+        RowLayout_spacing = getResourceOrNull(graph, URIs.RowLayout_spacing);\r
+        RowLayout_spacing_Inverse = getResourceOrNull(graph, URIs.RowLayout_spacing_Inverse);\r
+        RowLayout_type = getResourceOrNull(graph, URIs.RowLayout_type);\r
+        RowLayout_type_Inverse = getResourceOrNull(graph, URIs.RowLayout_type_Inverse);\r
+        RowLayout_wrap = getResourceOrNull(graph, URIs.RowLayout_wrap);\r
+        RowLayout_wrap_Inverse = getResourceOrNull(graph, URIs.RowLayout_wrap_Inverse);\r
         SashForm = getResourceOrNull(graph, URIs.SashForm);\r
         SashForm_Horizontal = getResourceOrNull(graph, URIs.SashForm_Horizontal);\r
         SashForm_Vertical = getResourceOrNull(graph, URIs.SashForm_Vertical);\r
index 6fc3491a1a69c4255a97a97aa52b7ffc45119be3..91cc7f7a1381bf81a9f3671c5455f46365521867 100644 (file)
@@ -1,15 +1,22 @@
 package org.simantics.views.swt.client.base;\r
 \r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.layout.RowLayoutFactory;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.layout.RowData;\r
+import org.eclipse.swt.layout.RowLayout;\r
 import org.eclipse.swt.widgets.Layout;\r
 import org.simantics.browsing.ui.Column;\r
 import org.simantics.browsing.ui.Column.Align;\r
 import org.simantics.views.ViewUtils.ColumnBean;\r
 import org.simantics.views.ViewUtils.GridDataBean;\r
 import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutDataBean;\r
+import org.simantics.views.ViewUtils.RowDataBean;\r
+import org.simantics.views.ViewUtils.RowLayoutBean;\r
 \r
 public class SWTViewUtils {\r
 \r
@@ -24,10 +31,25 @@ public class SWTViewUtils {
                result.marginBottom = bean.marginBottom;\r
                return result;\r
        }\r
-       \r
-       \r
+\r
+       public static Layout toLayout(RowLayoutBean bean) {\r
+               RowLayout result = RowLayoutFactory.fillDefaults().create();\r
+               result.type = bean.type;\r
+               result.spacing = bean.spacing;\r
+               result.center = bean.center;\r
+               result.fill = bean.fill;\r
+               result.justify = bean.justify;\r
+               result.pack = bean.pack;\r
+               result.wrap = bean.wrap;\r
+               result.marginLeft = bean.marginLeft;\r
+               result.marginRight = bean.marginRight;\r
+               result.marginTop = bean.marginTop;\r
+               result.marginBottom = bean.marginBottom;\r
+               return result;\r
+       }\r
+\r
        public static GridData toGridData(GridDataBean bean) {\r
-               GridData result = new GridData(SWT.FILL, SWT.FILL, true, false);           \r
+               GridData result = new GridData(SWT.FILL, SWT.FILL, true, false);\r
                result.horizontalSpan = bean.horizontalSpan;\r
                result.grabExcessHorizontalSpace = bean.grabExcessHorizontalSpace;\r
                result.grabExcessVerticalSpace = bean.grabExcessVerticalSpace;\r
@@ -39,6 +61,27 @@ public class SWTViewUtils {
                \r
        }\r
 \r
+       public static RowData toRowData(RowDataBean bean) {\r
+               return new RowData(bean.width, bean.height);\r
+       }\r
+\r
+       public static Layout toLayout(LayoutBean layout) {\r
+               if (layout instanceof GridLayoutBean)\r
+                       return toLayout((GridLayoutBean) layout);\r
+               if (layout instanceof RowLayoutBean)\r
+                       return toLayout((RowLayoutBean) layout);\r
+               throw new IllegalArgumentException("unrecognized layout: " + layout);\r
+       }\r
+\r
+\r
+       public static Object toLayoutData(LayoutDataBean layoutData) {\r
+               if (layoutData instanceof GridDataBean)\r
+                       return toGridData((GridDataBean) layoutData);\r
+               if (layoutData instanceof RowDataBean)\r
+                       return toRowData((RowDataBean) layoutData);\r
+               throw new IllegalArgumentException("unrecognized layout data: " + layoutData);\r
+       }\r
+\r
        private static Align getAlign(String alignment) {\r
                if("LEFT".equals(alignment)) return Align.LEFT;\r
                else if("CENTER".equals(alignment)) return Align.CENTER;\r
index 182aee594f3c5e1af6a7ec538787586354a383cf..55ac799d3ba9509630e54c64c9c36f7ec4d1ef2f 100644 (file)
@@ -27,7 +27,7 @@ import org.simantics.ui.colors.Colors;
 import org.simantics.ui.fonts.Fonts;\r
 import org.simantics.utils.threads.IThreadWorkQueue;\r
 import org.simantics.utils.threads.SWTThread;\r
-import org.simantics.views.ViewUtils.GridDataBean;\r
+import org.simantics.views.ViewUtils.LayoutDataBean;\r
 \r
 abstract public class SingleSWTViewNode<T extends Control> extends SWTParentNode implements LoaderNode {\r
        \r
@@ -36,7 +36,7 @@ abstract public class SingleSWTViewNode<T extends Control> extends SWTParentNode
        private Map<String, Object> genericProperties = new HashMap<String, Object>();\r
        \r
        public Function2<String, Object, Boolean> propertyCallback;\r
-       public GridDataBean layoutData;\r
+       public LayoutDataBean layoutData;\r
        public int style;\r
        public String text;\r
        public RGB.Integer background;\r
@@ -292,8 +292,8 @@ abstract public class SingleSWTViewNode<T extends Control> extends SWTParentNode
        final public void synchronizeStyle(int style) {\r
        }\r
 \r
-       final public void synchronizeLayoutData(GridDataBean layoutData) {\r
-               if(layoutData != null) control.setLayoutData(SWTViewUtils.toGridData(layoutData));\r
+       final public void synchronizeLayoutData(LayoutDataBean layoutData) {\r
+               if(layoutData != null) control.setLayoutData(SWTViewUtils.toLayoutData(layoutData));\r
        }\r
        \r
 }\r
index 6df6bdaad3e14cdb419fc7c0697aaf215897d211..5c4d212691151c92813a1aea9a501cacbb67119b 100644 (file)
@@ -3,8 +3,11 @@ package org.simantics.views.swt.client.impl;
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.swt.browser.Browser;\r
+import org.eclipse.swt.browser.LocationEvent;\r
+import org.eclipse.swt.browser.LocationListener;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.scl.runtime.function.Function1;\r
 import org.simantics.utils.datastructures.map.Tuple;\r
 import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
 \r
@@ -12,10 +15,11 @@ public class SWTBrowser extends SingleSWTViewNode<Browser> {
        \r
        private static final long serialVersionUID = -2704760050046054447L;\r
        \r
-       public String                   document;\r
-       public Variable                                 variable;\r
+       public String                     document;\r
+       public Variable                   variable;\r
+       public Function1<Object, Boolean> locationChanging;\r
 \r
-       private Tuple                    lastAppliedParametrization;\r
+       private Tuple                     lastAppliedParametrization;\r
 \r
        @Override\r
        public void reset() {\r
@@ -32,6 +36,18 @@ public class SWTBrowser extends SingleSWTViewNode<Browser> {
                control = new Browser(parent, style);\r
                GridDataFactory.fillDefaults().grab(true, true).applyTo(control);\r
 \r
+               control.addLocationListener(new LocationListener() {\r
+                       @Override\r
+                       public void changing(LocationEvent event) {\r
+                               Function1<Object, Boolean> lc = locationChanging;\r
+                               if (lc != null)\r
+                                       lc.apply(event);\r
+                       }\r
+                       @Override\r
+                       public void changed(LocationEvent event) {\r
+                       }\r
+               });\r
+\r
                setProperties();\r
 \r
        }\r
index 5fe825a96e982462245c21baee2578aa408a5e23..a67d0abf950753d063419c08de52c0c3c350d410 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.views.swt.client.impl;\r
 \r
 import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
 import org.simantics.views.swt.client.base.SWTViewUtils;\r
 import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
 \r
@@ -9,7 +9,7 @@ public class SWTComposite extends SingleSWTViewNode<Composite> {
        \r
        private static final long serialVersionUID = 7932335224632082902L;\r
        \r
-       public GridLayoutBean layout;\r
+       public LayoutBean layout;\r
        \r
        @Override\r
        public void createControls(org.eclipse.swt.widgets.Composite parent) {\r
@@ -22,7 +22,7 @@ public class SWTComposite extends SingleSWTViewNode<Composite> {
        \r
        }\r
 \r
-       final public void synchronizeLayout(GridLayoutBean layout) {\r
+       final public void synchronizeLayout(LayoutBean layout) {\r
                if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
        }\r
        \r
index f448ebde49e50552266f57bda813cdafccd58783..3c0ce5a1f0504273960714cb0d470ff2159893e8 100644 (file)
@@ -23,7 +23,7 @@ import org.simantics.browsing.ui.swt.widgets.ModelBrowser;
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
 import org.simantics.scl.runtime.function.Function1;\r
 import org.simantics.views.ViewUtils.ColumnBean;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
 import org.simantics.views.swt.client.base.SWTViewUtils;\r
 import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
 \r
@@ -31,7 +31,7 @@ public class SWTExplorer extends SingleSWTViewNode<ModelBrowser> {
        \r
        private static final long serialVersionUID = 7932335224632082902L;\r
        \r
-       public GridLayoutBean layout;\r
+       public LayoutBean layout;\r
        public String browseContext;\r
        public String contextMenuId;\r
        public String uiContext;\r
@@ -189,7 +189,7 @@ public class SWTExplorer extends SingleSWTViewNode<ModelBrowser> {
                }\r
        }\r
 \r
-       final public void synchronizeLayout(GridLayoutBean layout) {\r
+       final public void synchronizeLayout(LayoutBean layout) {\r
        }\r
        \r
 }\r
index 5bc8b2366e632d2ede8ee974940a019970eca8b0..af79bdc8d04aa389b93cf1891b95b57eee6b9231 100644 (file)
@@ -3,7 +3,7 @@ package org.simantics.views.swt.client.impl;
 import org.eclipse.swt.custom.SashForm;\r
 import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Sash;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
 import org.simantics.views.swt.client.base.SWTViewUtils;\r
 import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
 \r
@@ -11,7 +11,7 @@ public class SWTSashForm extends SingleSWTViewNode<SashForm> {
        \r
        private static final long serialVersionUID = 7932335224632082902L;\r
        \r
-       public GridLayoutBean layout;\r
+       public LayoutBean layout;\r
        public int[] weights;\r
        public Integer orientation;\r
        \r
@@ -26,7 +26,7 @@ public class SWTSashForm extends SingleSWTViewNode<SashForm> {
        \r
        }\r
 \r
-       final public void synchronizeLayout(GridLayoutBean layout) {\r
+       final public void synchronizeLayout(LayoutBean layout) {\r
                if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
        }\r
 \r
index 421315f892a6eae25d1b5a3f1a7e916298b6b934..1bf86ca124d26f8e5e6ca0da68a202b894d402b7 100644 (file)
@@ -13,7 +13,7 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;\r
 import org.eclipse.swt.widgets.Event;\r
 import org.eclipse.swt.widgets.Listener;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
 import org.simantics.views.swt.client.base.SWTViewUtils;\r
 import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
 \r
@@ -23,7 +23,7 @@ public class SWTScrolledComposite extends SingleSWTViewNode<ScrolledComposite> {
 \r
        private static final long serialVersionUID = 7932335224632082902L;\r
        \r
-       public GridLayoutBean layout;\r
+       public LayoutBean layout;\r
        \r
        private int minSize = 100;\r
        \r
@@ -124,7 +124,7 @@ public class SWTScrolledComposite extends SingleSWTViewNode<ScrolledComposite> {
        \r
        }\r
 \r
-       final public void synchronizeLayout(GridLayoutBean layout) {\r
+       final public void synchronizeLayout(LayoutBean layout) {\r
                if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
        }\r
        \r
index b8aebe5375923e6b1239aa91cf7ab481941eed94..629f28285f1b0d4998a131528b03ba53e1e89b5d 100644 (file)
@@ -14,7 +14,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;\r
 import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
 import org.simantics.utils.ui.jface.BasePostSelectionProvider;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
 import org.simantics.views.swt.client.base.ISWTViewNode;\r
 import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
 \r
@@ -24,7 +24,7 @@ public class SWTTabFolder extends SingleSWTViewNode<CTabFolder> {
 \r
        public List<String> childNames;\r
 \r
-       public GridLayoutBean layout;\r
+       public LayoutBean layout;\r
        \r
        final BasePostSelectionProvider selectionProvider = new BasePostSelectionProvider();\r
 \r
@@ -119,7 +119,7 @@ public class SWTTabFolder extends SingleSWTViewNode<CTabFolder> {
                \r
        }\r
        \r
-       final public void synchronizeLayout(GridLayoutBean layout) {\r
+       final public void synchronizeLayout(LayoutBean layout) {\r
        }\r
        \r
 }\r
index 941213f9c59c35f1dfa2a8e1c7f93ffb6787725d..6d26bb7f83540f680250f9c571666ec41c888e0d 100644 (file)
@@ -104,12 +104,22 @@ public class All {
 \r
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
     public static Object gridData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       return ViewUtils.getGridData(graph, converter);\r
+        return ViewUtils.getGridData(graph, converter);\r
     }\r
 \r
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
     public static Object gridLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       return ViewUtils.getLayout(graph, converter);\r
+        return ViewUtils.getLayout(graph, converter);\r
+    }\r
+\r
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
+    public static Object rowData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
+        return ViewUtils.getRowData(graph, converter);\r
+    }\r
+\r
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
+    public static Object rowLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
+        return ViewUtils.getRowLayout(graph, converter);\r
     }\r
 \r
     @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
index f22e5ad836bc53e5f463b722bd83802789827703..749c2856e3b7d38a7721349174641f5293bf4c96 100644 (file)
@@ -32,20 +32,35 @@ public class ViewUtils {
     }\r
 \r
     public static final Binding EXTENDED_MARGINS_BINDING = Bindings.getBindingUnchecked(ExtendedMargins.class);\r
-       \r
-       public static class GridLayoutBean extends Bean {\r
-               \r
-               public int numColumns;\r
-               public int horizontalSpacing;\r
-               public int verticalSpacing;\r
+\r
+       public static class LayoutBean extends Bean {\r
                public int marginLeft;\r
                public int marginRight;\r
                public int marginTop;\r
                public int marginBottom;\r
+       }\r
+\r
+       public static class GridLayoutBean extends LayoutBean {\r
+               \r
+               public int numColumns;\r
+               public int horizontalSpacing;\r
+               public int verticalSpacing;\r
                \r
        }\r
-       \r
-       public static class GridDataBean extends Bean {\r
+\r
+       public static class RowLayoutBean extends LayoutBean {\r
+               public int type;\r
+               public int spacing;\r
+               public boolean center;\r
+               public boolean fill;\r
+               public boolean justify;\r
+               public boolean pack;\r
+               public boolean wrap;\r
+       }\r
+\r
+       public static class LayoutDataBean extends Bean {}\r
+\r
+       public static class GridDataBean extends LayoutDataBean {\r
                \r
                public int horizontalSpan;\r
                public boolean grabExcessHorizontalSpace;\r
@@ -56,7 +71,12 @@ public class ViewUtils {
                public int heightHint;\r
                \r
        }\r
-       \r
+\r
+       public static class RowDataBean extends LayoutDataBean {\r
+               public int width;\r
+               public int height;\r
+       }\r
+\r
        public static class ColumnBean extends Bean {\r
                \r
                public String key;\r
@@ -128,6 +148,50 @@ public class ViewUtils {
     \r
        }\r
 \r
+       public static RowLayoutBean getRowLayout(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
+           return processor.sync(new ResourceRead<RowLayoutBean>(configuration) {\r
+               @Override\r
+               public RowLayoutBean perform(ReadGraph graph) throws DatabaseException {\r
+                   ViewsResources VIEW = ViewsResources.getInstance(graph);\r
+                   Integer type = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_type, Bindings.INTEGER);\r
+                   Integer spacing = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_spacing, Bindings.INTEGER);\r
+                   Boolean center = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_center, Bindings.BOOLEAN);\r
+                Boolean fill = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_fill, Bindings.BOOLEAN);\r
+                Boolean justify = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_justify, Bindings.BOOLEAN);\r
+                   Boolean pack = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_pack, Bindings.BOOLEAN);\r
+                   Boolean wrap = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_wrap, Bindings.BOOLEAN);\r
+                   ExtendedMargins extendedMargins = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_extendedMargins, EXTENDED_MARGINS_BINDING);\r
+\r
+                   RowLayoutBean layout = new RowLayoutBean();\r
+                   layout.type = type;\r
+                   layout.spacing = spacing;\r
+                layout.center = center;\r
+                layout.fill = fill;\r
+                layout.justify = justify;\r
+                   layout.pack = pack;\r
+                   layout.wrap = wrap;\r
+                   layout.marginLeft = extendedMargins.left;\r
+                   layout.marginRight = extendedMargins.right;\r
+                   layout.marginTop = extendedMargins.top;\r
+                   layout.marginBottom = extendedMargins.bottom;\r
+                   return layout;\r
+               }\r
+           });\r
+       }\r
+\r
+       public static RowDataBean getRowData(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
+           return processor.sync(new ResourceRead<RowDataBean>(configuration) {\r
+               @Override\r
+               public RowDataBean perform(ReadGraph graph) throws DatabaseException {\r
+                   ViewsResources VIEW = ViewsResources.getInstance(graph);\r
+                   RowDataBean data = new RowDataBean();\r
+                   data.width = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredWidth, Bindings.INTEGER);\r
+                   data.height = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredHeight, Bindings.INTEGER);\r
+                   return data;\r
+               }\r
+           });\r
+       }\r
+\r
        public static int getStyle(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
                \r
                return processor.sync(new ResourceRead<Integer>(configuration) {\r
@@ -188,6 +252,7 @@ public class ViewUtils {
 \r
                Simantics.getSession().async(new TernaryRead<Resource, Variable, String, T> (configuration, context, relationURI) {\r
 \r
+                       @SuppressWarnings("unchecked")\r
                        @Override\r
                        public T perform(ReadGraph graph) throws DatabaseException {\r
                                Object value = graph.getRelatedValue2(parameter, graph.getResource(parameter3), parameter2);\r