]> 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 25f5c8b6a18e1921d10ced5de6e6c7e65425bd9a..7214bdd1f1691057c25a304621b4112339c9ada9 100644 (file)
@@ -1,45 +1,53 @@
-package org.simantics.document.swt.core.base;\r
-\r
-import java.util.Map;\r
-\r
-import org.simantics.document.server.handler.AbstractEventHandler;\r
-import org.simantics.document.server.io.CommandContext;\r
-import org.simantics.document.server.io.CommandContextImpl;\r
-import org.simantics.document.swt.core.SWTDocument;\r
-\r
-public class PostEventCommand extends AbstractEventCommand {\r
-    \r
-    private AbstractEventHandler handler;\r
-    private CommandContextImpl parameters;\r
-    \r
-    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, Map<String, String> parameters) {\r
-        this(document, handler, parameters, null);\r
-    }\r
-    \r
-    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, Map<String, String> parameters, PostEventCommand next) {\r
-        super(document);\r
-        this.handler = handler;\r
-        this.parameters = new CommandContextImpl();\r
-        for(Map.Entry<String, String> entry : parameters.entrySet()) {\r
-               this.parameters.putString(entry.getKey(), entry.getValue());\r
-        }\r
-        this.next = next;\r
-    }\r
-\r
-    @Override\r
-    public void handleCommand() {\r
-        document.post(handler, parameters);\r
-    }\r
-\r
-    @Override\r
-    public void commandSuccess() {\r
-        if(next != null)\r
-            next.handleCommand();\r
-    }\r
-\r
-    @Override\r
-    public void commandError(String errorMessage) {\r
-        System.err.println(this + " failed: " + errorMessage);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * 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 org.simantics.document.server.io.AbstractEventHandler;
+import org.simantics.document.server.io.CommandContext;
+import org.simantics.document.server.io.CommandContextMutable;
+import org.simantics.document.swt.core.SWTDocument;
+
+public class PostEventCommand extends AbstractEventCommand {
+    
+    private AbstractEventHandler handler;
+    private CommandContextMutable context;
+    
+    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context) {
+        this(document, handler, context, null);
+    }
+    
+    public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context, PostEventCommand next) {
+        super(document);
+        this.handler = handler;
+        this.context = context;
+        this.next = next;
+    }
+
+    @Override
+    public CommandContext handleCommand(CommandContextMutable context) {
+        document.post(handler, context);
+        return context;
+    }
+
+    @Override
+    public CommandContext commandSuccess(CommandContextMutable context) {
+        if(next != null)
+            return next.handleCommand(context);
+        return context;
+    }
+
+    @Override
+    public void commandError(String errorMessage) {
+        System.err.println(this + " failed: " + errorMessage);
+    }
+
+}