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); } }