1 /*******************************************************************************
2 * Copyright (c) 2019 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.document.swt.core.base;
14 import org.simantics.document.server.io.AbstractEventHandler;
15 import org.simantics.document.server.io.CommandContext;
16 import org.simantics.document.server.io.CommandContextImpl;
17 import org.simantics.document.server.io.CommandContextMutable;
18 import org.simantics.document.swt.core.SWTDocument;
20 public class PostEventCommand extends AbstractEventCommand {
22 private AbstractEventHandler handler;
23 private CommandContextMutable context;
25 public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context) {
26 this(document, handler, context, null);
29 public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context, PostEventCommand next) {
31 assert(handler != null);
32 this.handler = handler;
33 this.context = context;
38 public CommandContext handleCommand(CommandContextMutable context) {
39 CommandContextMutable mergedContext = new CommandContextImpl().merge(context)
41 document.post(handler, mergedContext);
46 public CommandContext commandSuccess(CommandContextMutable context) {
48 return next.handleCommand(context);
53 public void commandError(String errorMessage) {
54 System.err.println(this + " failed: " + errorMessage);