void windowMenu_menuSelected(MenuEvent e) { // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes // the Window // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon // Aquino] if (windowMenu.getItemCount() > 0 && windowMenu.getItem(0) != null && windowMenu .getItem(0) .getText() .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) { JMenuItem newWindowMenuItem = windowMenu.getItem(0); windowMenu.removeAll(); windowMenu.add(newWindowMenuItem); windowMenu.addSeparator(); } else { // ezLink doesn't have a Clone Window menu [Jon Aquino] windowMenu.removeAll(); } // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames(); final JInternalFrame[] frames = desktopPane.getAllFrames(); for (int i = 0; i < frames.length; i++) { JMenuItem menuItem = new JMenuItem(); // Increase truncation threshold from 20 to 40, for eziLink [Jon // Aquino] menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40)); associate(menuItem, frames[i]); windowMenu.add(menuItem); } if (windowMenu.getItemCount() == 0) { // For ezLink [Jon Aquino] windowMenu.add(new JMenuItem("(No Windows)")); } }
private void loadPlugIns(WorkbenchProperties props) { PlugInContext pc = context.createPlugInContext(); // List<String> classNames = props.getPlugInClassNames(); Map<String, Map<String, String>> pluginSettings = props.getSettings(new String[] {WorkbenchProperties.KEY_PLUGIN}); int i = 0; for (String className : pluginSettings.keySet()) { // System.out.println(i++ + "/"+ className); String initSetting = pluginSettings.get(className).get(WorkbenchProperties.ATTR_INITIALIZE); if (initSetting instanceof String && initSetting.equals(WorkbenchProperties.ATTR_VALUE_FALSE)) continue; monitor.report(LOADING + " " + className); Class plugInClass = null; try { long start = secondsSince(0); plugInClass = Class.forName(className); PlugIn plugIn = (PlugIn) plugInClass.newInstance(); plugIn.initialize(pc); // get plugin's menu settings Map<String, Map> menuSettings = props.getSettings( new String[] { WorkbenchProperties.KEY_PLUGIN, className, WorkbenchProperties.KEY_MENUS }); // interpret menu settings for (Map.Entry<String, Map> entry : menuSettings.entrySet()) { String menuKey = entry.getKey(); if (pc.getFeatureInstaller().fetchMenuForKey(menuKey) == null) continue; // install me to menu? String installSetting = props.getSetting( new String[] { WorkbenchProperties.KEY_PLUGIN, className, WorkbenchProperties.KEY_MENUS, menuKey, WorkbenchProperties.ATTR_INSTALL }); // String orderSetting = props.getSetting(new String[] { // WorkbenchProperties.KEY_PLUGIN, className, // WorkbenchProperties.KEY_MENUS, // menuKey, // WorkbenchProperties.ATTR_ORDERID}); // log (order) info // context // .getWorkbench() // .getFrame() // .log( // "install " + className + " to " + menuKey + " = " // + installSetting + " with orderid = " + orderSetting); // install, or not if (installSetting.equals(WorkbenchProperties.ATTR_VALUE_TRUE)) pc.getFeatureInstaller().addMenuPlugin(menuKey, plugIn); } // register shortcuts of plugins AbstractPlugIn.registerShortcuts(plugIn); context .getWorkbench() .getFrame() .log("Loading " + className + " took " + secondsSinceString(start) + "s"); } catch (Throwable e) { context.getErrorHandler().handleThrowable(e); context.getWorkbench().getFrame().log(className + " " + NOT_INITIALIZED, this.getClass()); } } }