]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PostEventCommand.java
Improvements to modelled SWT documents
[simantics/platform.git] / bundles / org.simantics.document.swt.core / src / org / simantics / document / swt / core / base / PostEventCommand.java
index ff6d4fd13d5aa6d20e0894339c02bee95fc68569..7214bdd1f1691057c25a304621b4112339c9ada9 100644 (file)
@@ -1,40 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
 package org.simantics.document.swt.core.base;
 
-import java.util.Map;
-
-import org.simantics.document.server.handler.AbstractEventHandler;
+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;
 
 public class PostEventCommand extends AbstractEventCommand {
     
     private AbstractEventHandler handler;
-    private CommandContextImpl parameters;
+    private CommandContextMutable context;
     
-    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, Map<String, String> parameters) {
-        this(document, handler, parameters, null);
+    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context) {
+        this(document, handler, context, null);
     }
     
-    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, Map<String, String> parameters, PostEventCommand next) {
+    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context, PostEventCommand next) {
         super(document);
         this.handler = handler;
-        this.parameters = new CommandContextImpl();
-        for(Map.Entry<String, String> entry : parameters.entrySet()) {
-               this.parameters.putString(entry.getKey(), entry.getValue());
-        }
+        this.context = context;
         this.next = next;
     }
 
     @Override
-    public void handleCommand() {
-        document.post(handler, parameters);
+    public CommandContext handleCommand(CommandContextMutable context) {
+        document.post(handler, context);
+        return context;
     }
 
     @Override
-    public void commandSuccess() {
+    public CommandContext commandSuccess(CommandContextMutable context) {
         if(next != null)
-            next.handleCommand();
+            return next.handleCommand(context);
+        return context;
     }
 
     @Override