+
+ }
+
+ private static CommandMappingImpl commandMapping = null;
+
+ public static CommandMapping getCommandMapping() {
+
+ if(commandMapping == null) {
+ commandMapping = new CommandMappingImpl();
+ commandMapping.register("Button", new ButtonWidget.ButtonCommandManager());
+ commandMapping.register("Explorer", new Explorer.ExplorerCommandManager());
+ }
+
+ return commandMapping;
+
+ }
+
+ public static List<Pair<WidgetData, ICommand>> getTriggeredCommands(Document document, Collection<ICommand> commands, String trigger) {
+ // Nulls should not get this far
+ assert(commands != null);
+ List<Pair<WidgetData, ICommand>> data = new ArrayList<>();
+ for(ICommand c : commands) {
+ if(c.getCommand() == null || c.getTargetId() == null || c.getTrigger() == null)
+ continue;
+ if(trigger.equals(c.getTrigger())) {
+ WidgetData wd = document.getWidgetData().get(c.getTargetId());
+ if(wd != null)
+ data.add(new Pair<WidgetData, ICommand>(wd, c));
+ }
+ }
+ return data;