+ public static class ExplorerCommandManager implements CommandManager<SWTDocument, WidgetContainer<ModelBrowser>> {
+
+ @Override
+ public Collection<Object> updateCommandListeners(final SWTDocument document, final JSONObject object,
+ WidgetContainer<ModelBrowser> container) {
+
+ WidgetData wd = document.getWidget(JSONObjectUtils.getId(object));
+ List<ICommand> commands = object.getJSONField("commands");
+ HashSet<Object> listeners = new HashSet<Object>();
+ List<Pair<WidgetData, ICommand>> data = new ArrayList<>();
+ data.addAll(SWTViews.getTriggeredCommands(document, commands, "eventOut"));
+ data.add(new Pair<WidgetData, ICommand>(wd, new Command("onCheck")));
+ Listener listener = new ExplorerListener(wd, data);
+ ModelBrowser browser = container.getControl();
+ if(!browser.isDisposed()) {
+ browser.addListenerToControl(SWT.Selection, listener);
+ listeners.add(listener);
+ }
+
+ return listeners;
+
+ }
+
+ @Override
+ public void removeListener(WidgetContainer<ModelBrowser> container, Object listener) {
+ if(container.getControl().isDisposed()) return;
+ if(listener instanceof ExplorerListener)
+ container.getControl().removeListenerFromControl(SWT.Selection, (Listener)listener);
+ }
+
+ }
+
+ @Override
+ public IEventCommand eventCommand(SWTDocument document, JSONObject object, WidgetContainer widget, ICommand command, CommandContext p) {
+ if("onCheck".equals(command.getCommand())) {
+ CommandContextMutable context = new CommandContextImpl().merge(p);
+ AbstractEventHandler onCheck = object.getJSONField("onCheck");
+ return new PostEventCommand(document, onCheck, context);
+ }
+ return null;
+ }
+