1 package org.simantics.document.swt.core.widget;
5 import org.eclipse.swt.SWT;
6 import org.eclipse.swt.widgets.Event;
7 import org.eclipse.swt.widgets.Listener;
8 import org.eclipse.swt.widgets.TreeItem;
9 import org.simantics.browsing.ui.BuiltinKeys;
10 import org.simantics.browsing.ui.NodeContext;
11 import org.simantics.document.server.client.WidgetData;
12 import org.simantics.document.server.io.CommandContext;
13 import org.simantics.document.server.io.CommandContextImpl;
14 import org.simantics.document.server.io.CommandContextMutable;
15 import org.simantics.document.server.io.ICommand;
16 import org.simantics.document.swt.core.SWTDocument;
17 import org.simantics.document.swt.core.base.PropertyWidgetManager;
18 import org.simantics.utils.datastructures.Pair;
20 public class ExplorerListener implements Listener {
22 private WidgetData wd;
23 private List<Pair<WidgetData, ICommand>> data;
25 public ExplorerListener(WidgetData wd, List<Pair<WidgetData, ICommand>> data) {
31 public void handleEvent(Event event) {
35 if (event.detail == SWT.CHECK && event.item != null) {
37 TreeItem item = (TreeItem) event.item;
38 NodeContext ctx = (NodeContext)item.getData();
39 Object value = ctx.getConstant(BuiltinKeys.INPUT);
41 boolean checked = item.getChecked();
43 CommandContextMutable context = new CommandContextImpl();
44 context.putValue("event", "onCheck");
45 context.putValue("checked", checked);
46 context.putValue("item", value);
49 ((SWTDocument)wd.document).handleCommands(data, context, event.widget);
52 CommandContext ret = PropertyWidgetManager.sendEvent((SWTDocument)wd.document, wd, "onCheck", event.widget, context);