]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/widget/CommandEventWidget.java
Playground for Antti.
[simantics/platform.git] / bundles / org.simantics.document.swt.core / src / org / simantics / document / swt / core / widget / CommandEventWidget.java
index 23311d93c18a00757af97dfea980ea379c513fcc..6eb69541860798def6fd472443cc8595a9cbece6 100644 (file)
@@ -1,6 +1,5 @@
 package org.simantics.document.swt.core.widget;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.TreeMap;
 
@@ -10,6 +9,10 @@ import org.simantics.document.server.bean.DataDefinition;
 import org.simantics.document.server.client.WidgetData;
 import org.simantics.document.server.client.WidgetManager;
 import org.simantics.document.server.handler.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.server.io.ICommand;
 import org.simantics.document.swt.core.SWTDocument;
 import org.simantics.document.swt.core.base.PostEventCommand;
 import org.simantics.document.swt.core.base.PropertyWidgetManager;
@@ -33,10 +36,11 @@ public class CommandEventWidget  extends PropertyWidgetManager<Object> {
     }
 
     @Override
-    public IEventCommand eventCommand(SWTDocument document, JSONObject object, Object component, String command) {
-        if("event".equals(command)) {
+    public IEventCommand eventCommand(SWTDocument document, JSONObject object, Object component, ICommand command, CommandContext p) {
+        if("event".equals(command.getCommand())) {
             List<DataDefinition> dataDefinitions = object.getJSONField("dataDefinitions");
-            HashMap<String, String> data = new HashMap<String, String>();
+            CommandContextMutable context = new CommandContextImpl();
+            context.merge(p);
             for(DataDefinition dd : dataDefinitions) {
                 WidgetData wd = document.getWidgetData().get(dd.getElementId());
                 if(wd != null && wd.object != null) {
@@ -45,12 +49,12 @@ public class CommandEventWidget  extends PropertyWidgetManager<Object> {
                     if(manager != null) {
                         @SuppressWarnings("unchecked")
                         String result = manager.getProperty(document, wd.object, wd.widget, dd.getProperty());
-                        data.put(dd.getTarget(), result);
+                        context.putValue(dd.getTarget(), result);
                     }
                 }
             }
             AbstractEventHandler handler = object.getJSONField("SCLFunction");
-            return new PostEventCommand(document, handler, data);
+            return new PostEventCommand(document, handler, context);
         } else {
             return null;
         }