1 package org.simantics.document.swt.core.base;
3 import java.awt.Component;
4 import java.util.Collection;
8 import org.simantics.document.server.IEventCommand;
9 import org.simantics.document.server.JSONObject;
10 import org.simantics.document.server.client.Document;
11 import org.simantics.document.server.client.WidgetData;
12 import org.simantics.document.server.client.WidgetManager;
13 import org.simantics.document.server.io.CommandContext;
14 import org.simantics.document.server.io.CommandContextImpl;
15 import org.simantics.document.server.io.CommandContextMutable;
16 import org.simantics.document.server.io.ICommand;
17 import org.simantics.document.server.io.JSONObjectUtils;
18 import org.simantics.document.swt.core.SWTDocument;
19 import org.simantics.document.swt.core.SWTViews;
20 import org.simantics.utils.datastructures.Pair;
22 public abstract class PropertyWidgetManager<W> implements WidgetManager<SWTDocument, W> {
25 public String getProperty(SWTDocument document, JSONObject object, W widget, String property) {
30 public IEventCommand eventCommand(SWTDocument document, JSONObject object, W widget, ICommand command, CommandContext context) {
34 // public static CommandContext sendEvent(SWTDocument document, Object source, String event, Object target, CommandContextMutable context) {
35 // return sendEvent(document, document.find(source), event, target, context);
38 public static CommandContext sendEvent(SWTDocument document, WidgetData wd, String event, Object target, CommandContextMutable context) {
39 Collection<ICommand> commands = JSONObjectUtils.getCommands(wd.object);
41 if(context == null) context = new CommandContextImpl();
42 context.putValue("event", event);
44 List<Pair<WidgetData, ICommand>> data = SWTViews.getTriggeredCommands(document, commands, "eventOut");
46 return document.handleCommands(data, context, wd.widget);