]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Improvements to modelled SWT documents (fixed)"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Sun, 25 Aug 2019 21:29:46 +0000 (21:29 +0000)
committerGerrit Code Review <gerrit2@simantics>
Sun, 25 Aug 2019 21:29:46 +0000 (21:29 +0000)
bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PostEventCommand.java
bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/ButtonWidget.java
bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/CommandEventWidget.java
bundles/org.simantics.document.swt.ontology/graph/Components.pgraph

index 7214bdd1f1691057c25a304621b4112339c9ada9..24b6e6111c41774337c9aec5934decaf7c3da8d7 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.document.swt.core.base;
 
 import org.simantics.document.server.io.AbstractEventHandler;
 import org.simantics.document.server.io.CommandContext;
+import org.simantics.document.server.io.CommandContextImpl;
 import org.simantics.document.server.io.CommandContextMutable;
 import org.simantics.document.swt.core.SWTDocument;
 
@@ -27,6 +28,7 @@ public class PostEventCommand extends AbstractEventCommand {
     
     public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context, PostEventCommand next) {
         super(document);
+        assert(handler != null);
         this.handler = handler;
         this.context = context;
         this.next = next;
@@ -34,7 +36,9 @@ public class PostEventCommand extends AbstractEventCommand {
 
     @Override
     public CommandContext handleCommand(CommandContextMutable context) {
-        document.post(handler, context);
+        CommandContextMutable mergedContext = new CommandContextImpl().merge(context)
+                .merge(this.context);
+        document.post(handler, mergedContext);
         return context;
     }
 
index 72c7c360b0566529d0941f58557ed9cd93d4c4eb..88afe7b2ab802bcc235952bdaa6d42766f2cf68a 100644 (file)
@@ -75,6 +75,7 @@ public class ButtonWidget extends LeafWidgetManager<Button> {
             List<ICommand> commands = object.getJSONField("commands");
             HashSet<Object> listeners = new HashSet<Object>();
             List<Pair<WidgetData, ICommand>> data = new ArrayList<>();
+            data.addAll(SWTViews.getTriggeredCommands(document, commands, "click"));
             data.addAll(SWTViews.getTriggeredCommands(document, commands, "eventOut"));
             data.add(new Pair<WidgetData, ICommand>(wd, new Command("onPress")));
             SelectionListener listener = new ButtonSelectionListener(wd, data);
@@ -102,6 +103,7 @@ public class ButtonWidget extends LeafWidgetManager<Button> {
         if("onPress".equals(command.getCommand())) {
             CommandContextMutable context = new CommandContextImpl().merge(p);
             AbstractEventHandler onPress = object.getJSONField("onPress");
+            if(onPress == null) return null;
             return new PostEventCommand(document, onPress, context);
         }
         return null;
index efded8810e0bb738e4e6ed93d7b18490bf882f93..ca6c31ddffdf8e5a565bf3d71f49d41edb7a267f 100644 (file)
@@ -52,6 +52,7 @@ public class CommandEventWidget  extends PropertyWidgetManager<Object> {
             List<DataDefinition> dataDefinitions = object.getJSONField("dataDefinitions");
             CommandContextMutable context = new CommandContextImpl();
             context.merge(p);
+            context.merge(command.getConstants());
             for(DataDefinition dd : dataDefinitions) {
                 WidgetData wd = document.getWidgetData().get(dd.getElementId());
                 if(wd != null && wd.object != null) {
index e577e6c5dadda5e00469d9acdf757ad6b10e2af8..b255c4f2b4bd53863bd6e6471e3e5014d33c3cea 100644 (file)
@@ -47,6 +47,8 @@ COMPONENTS.Component <T DOC.Components.PrimitiveComponent
     @SWT.defAttribute L0.Value "Boolean"
   >-- COMPONENTS.Component.NoScroll
     @SWT.defAttribute L0.Value "Boolean"
+  >-- COMPONENTS.Component.Check
+    @SWT.defAttribute L0.Value "Boolean"
   >-- COMPONENTS.Component.alignment
     @SWT.defAttribute L0.Value "String"
         
@@ -190,6 +192,8 @@ COMPONENTS.Explorer <T COMPONENTS.Component
     @SWT.defAttribute L0.Value "String"
   >-- COMPONENTS.Explorer.dragSourceListenerFactory
     @SWT.defAttribute L0.Value "DragSourceListenerFactory"
+  >-- COMPONENTS.Explorer.onCheck
+    @SWT.defAttribute L0.Value "AbstractEventHandler"
 
   @attribute COMPONENTS.Explorer.browseContext
     ""