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=7214bdd1f1691057c25a304621b4112339c9ada9;hb=e4ffdffae875e518a4eb070b8bda6ead1a9843d3;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..7214bdd1f 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,53 @@ -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); - } - -} +/******************************************************************************* + * 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); + } + +}