@Override protected String process(final String directive, final Map<String, Object> attrs, final String theRest) { for (final String k : attrs.keySet()) { assignAttribute(k == null ? "name" : k, attrs.get(k)); } moduleService.addModule(info()); // TODO how to handle duplicate names? return ""; }
@Override protected String process(final String directive, final Map<String, Object> attrs, final String theRest) { for (final String k : attrs.keySet()) { assignAttribute(k == null ? "name" : k, attrs.get(k)); } moduleService.addModule(info()); // TODO how to handle duplicate names? return ""; }
@Override public void add(final String path) { final boolean present = recentModules.containsKey(path); // add path to recent files list if (present) recentFiles.remove(path); recentFiles.add(path); // persist the updated list saveList(); if (present) { // path already present; update linked module info final ModuleInfo info = recentModules.get(path); // TODO - update module weights info.update(eventService); } else { // new path; create linked module info final ModuleInfo info = createInfo(path); recentModules.put(path, info); // register the module with the module service moduleService.addModule(info); } }
@Override public void add(final String path) { final boolean present = recentModules.containsKey(path); // add path to recent files list if (present) recentFiles.remove(path); recentFiles.add(path); // persist the updated list saveList(); if (present) { // path already present; update linked module info final ModuleInfo info = recentModules.get(path); // TODO - update module weights info.update(eventService); } else { // new path; create linked module info final ModuleInfo info = createInfo(path); recentModules.put(path, info); // register the module with the module service moduleService.addModule(info); } }
/** Creates a {@link ModuleInfo} to reopen data at the given path. */ private ModuleInfo createInfo(final String displayName) { final CommandInfo info = new CommandInfo(SelectWindow.class.getName()); // hard code path to open as a preset final HashMap<String, Object> presets = new HashMap<>(); presets.put("displayToSelect", displayName); info.setPresets(presets); // set menu path final MenuPath menuPath = new MenuPath(); menuPath.add(new MenuEntry(MenuConstants.WINDOW_LABEL)); final MenuEntry leaf = new MenuEntry(shortPath(displayName)); menuPath.add(leaf); info.setMenuPath(menuPath); // set menu position leaf.setWeight(order++); // TODO - do this properly // register the module with the module service moduleService.addModule(info); return info; }
@Before public void setUp() { context = new Context(ModuleService.class); context.service(ModuleService.class).addModule(new AlphabetModuleInfo()); runner = new ModuleCodeRunner(); context.inject(runner); }