package org.simantics.document.swt.core;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbenchSite;
import org.simantics.db.common.utils.Logger;
+import org.simantics.document.server.IEventCommand;
import org.simantics.document.server.JSONObject;
import org.simantics.document.server.client.DocumentClient;
import org.simantics.document.server.client.WidgetData;
import org.simantics.document.server.client.WidgetMapping;
-import org.simantics.document.server.handler.AbstractEventHandler;
+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.server.io.ICommand;
+import org.simantics.document.server.io.JSONObjectUtils;
import org.simantics.document.swt.core.base.WidgetContainer;
import org.simantics.document.swt.core.widget.FillComposite;
import org.simantics.ui.colors.Colors;
import org.simantics.ui.fonts.Fonts;
+import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.threads.IThreadWorkQueue;
import org.simantics.utils.threads.SWTThread;
}
@Override
- public void post(final AbstractEventHandler handler, CommandContext parameters) {
+ public void post(AbstractEventHandler handler, CommandContextMutable parameters) {
handler.handle(parameters);
}
+
@Override
protected void updateDocument(Collection<JSONObject> objects) {
}
+ @Override
+ public CommandContext handleCommands(List<Pair<WidgetData, ICommand>> data, CommandContextMutable context, Object component) {
+
+ // Build a linked list of commands
+
+ ArrayList<IEventCommand> commands = new ArrayList<IEventCommand>();
+ for(Pair<WidgetData, ICommand> pair : data) {
+ WidgetData d = pair.first;
+
+ ICommand c = pair.second;
+ IEventCommand p = d.eventCommand(c, null);
+// if(component != null && p != null)
+// p.setTrigger(component);
+ if(p != null) {
+ if(!commands.isEmpty())
+ commands.get(commands.size()-1).setNext(p);
+ commands.add(p);
+ }
+ }
+
+ // Execute the first command, the linked list handles the rest of them
+ if(!commands.isEmpty()) {
+ try {
+ commands.get(0).handleCommand(context);
+ } finally {
+ }
+ }
+ return context;
+ }
+
@Override
public void layout() {
requireLayout = true;