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.CommandContextMutable;
17 import org.simantics.document.swt.core.SWTDocument;
19 public class PostEventCommand extends AbstractEventCommand {
21 private AbstractEventHandler handler;
22 private CommandContextMutable context;
24 public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context) {
25 this(document, handler, context, null);
28 public PostEventCommand(SWTDocument document, AbstractEventHandler handler, CommandContextMutable context, PostEventCommand next) {
30 this.handler = handler;
31 this.context = context;
36 public CommandContext handleCommand(CommandContextMutable context) {
37 document.post(handler, context);
42 public CommandContext commandSuccess(CommandContextMutable context) {
44 return next.handleCommand(context);
49 public void commandError(String errorMessage) {
50 System.err.println(this + " failed: " + errorMessage);