]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/AbstractEventCommand.java
Improvements to modelled SWT documents
[simantics/platform.git] / bundles / org.simantics.document.swt.core / src / org / simantics / document / swt / core / base / AbstractEventCommand.java
1 package org.simantics.document.swt.core.base;
2
3 import org.simantics.document.server.IEventCommand;
4 import org.simantics.document.server.io.CommandContext;
5 import org.simantics.document.server.io.CommandContextMutable;
6 import org.simantics.document.swt.core.SWTDocument;
7
8 public abstract class AbstractEventCommand implements IEventCommand {
9     
10     protected IEventCommand next;
11     protected SWTDocument document;
12     
13     public AbstractEventCommand(SWTDocument document) {
14         this.document = document;
15     }
16
17     @Override
18     public void setNext(IEventCommand next) {
19         this.next = next;
20     }
21     
22     @Override
23     public IEventCommand getNext() {
24         return this.next;
25     }
26     
27     @Override
28     public CommandContext commandSuccess(CommandContextMutable context) {
29         if(next != null)
30             return next.handleCommand(context);
31         return context;
32     }
33
34     @Override
35     public void commandError(String errorMessage) {
36         System.err.println(this + " failed: " + errorMessage);
37     }
38
39 }