X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.swt.core%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fswt%2Fcore%2Fbase%2FPropertyWidgetManager.java;h=c8593c604e3a5f50daee13c8f718c72a116812c3;hb=refs%2Fheads%2Fprivate%2Fantin_tyomaa;hp=dfb73e879b916099890e0b7b9ae5a1c10eca3905;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PropertyWidgetManager.java b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PropertyWidgetManager.java index dfb73e879..c8593c604 100644 --- a/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PropertyWidgetManager.java +++ b/bundles/org.simantics.document.swt.core/src/org/simantics/document/swt/core/base/PropertyWidgetManager.java @@ -1,20 +1,50 @@ -package org.simantics.document.swt.core.base; - -import org.simantics.document.server.IEventCommand; -import org.simantics.document.server.JSONObject; -import org.simantics.document.server.client.WidgetManager; -import org.simantics.document.swt.core.SWTDocument; - -public abstract class PropertyWidgetManager implements WidgetManager { - - @Override - public String getProperty(SWTDocument document, JSONObject object, W widget, String property) { - return null; - } - - @Override - public IEventCommand eventCommand(SWTDocument document, JSONObject object, W widget, String command) { - return null; - } - -} +package org.simantics.document.swt.core.base; + +import java.awt.Component; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.simantics.document.server.IEventCommand; +import org.simantics.document.server.JSONObject; +import org.simantics.document.server.client.Document; +import org.simantics.document.server.client.WidgetData; +import org.simantics.document.server.client.WidgetManager; +import org.simantics.document.server.io.CommandContext; +import org.simantics.document.server.io.CommandContextImpl; +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.SWTDocument; +import org.simantics.document.swt.core.SWTViews; +import org.simantics.utils.datastructures.Pair; + +public abstract class PropertyWidgetManager implements WidgetManager { + + @Override + public String getProperty(SWTDocument document, JSONObject object, W widget, String property) { + return null; + } + + @Override + public IEventCommand eventCommand(SWTDocument document, JSONObject object, W widget, ICommand command, CommandContext context) { + return null; + } + +// public static CommandContext sendEvent(SWTDocument document, Object source, String event, Object target, CommandContextMutable context) { +// return sendEvent(document, document.find(source), event, target, context); +// } + + public static CommandContext sendEvent(SWTDocument document, WidgetData wd, String event, Object target, CommandContextMutable context) { + Collection commands = JSONObjectUtils.getCommands(wd.object); + + if(context == null) context = new CommandContextImpl(); + context.putValue("event", event); + + List> data = SWTViews.getTriggeredCommands(document, commands, "eventOut"); + + return document.handleCommands(data, context, wd.widget); + + } + +}