X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.swt.core%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fswt%2Fcore%2Fbase%2FPostEventCommand.java;h=2537f9de946a0714b3ce866083aa0bf14d622f0f;hb=refs%2Fheads%2Fprivate%2Fantin_tyomaa;hp=25f5c8b6a18e1921d10ced5de6e6c7e65425bd9a;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PostEventCommand.java b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PostEventCommand.java index 25f5c8b6a..2537f9de9 100644 --- a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PostEventCommand.java +++ b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PostEventCommand.java @@ -1,45 +1,42 @@ -package org.simantics.document.swt.core.base; - -import java.util.Map; - -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.swt.core.SWTDocument; - -public class PostEventCommand extends AbstractEventCommand { - - private AbstractEventHandler handler; - private CommandContextImpl parameters; - - public PostEventCommand(SWTDocument document, AbstractEventHandler handler, Map parameters) { - this(document, handler, parameters, null); - } - - public PostEventCommand(SWTDocument document, AbstractEventHandler handler, Map parameters, PostEventCommand next) { - super(document); - this.handler = handler; - this.parameters = new CommandContextImpl(); - for(Map.Entry entry : parameters.entrySet()) { - this.parameters.putString(entry.getKey(), entry.getValue()); - } - this.next = next; - } - - @Override - public void handleCommand() { - document.post(handler, parameters); - } - - @Override - public void commandSuccess() { - if(next != null) - next.handleCommand(); - } - - @Override - public void commandError(String errorMessage) { - System.err.println(this + " failed: " + errorMessage); - } - -} +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); + } + +}