/** * 删除子项 * * @param label */ public void deleteItem(MenuItemLabel label) { MenuItem item = (MenuItem) label.getEditableObj(); MenuItem currentMenuItem = menuObj.getMenuItem(); if (currentMenuItem.getChildList().contains(item)) { currentMenuItem.getChildList().remove(item); // 删除相关连接 MenubarEditor editor = MenubarEditor.getActiveMenubarEditor(); MenubarConnector connector = editor.getConnector(item.getId()); if (null != connector) { editor.removeConnector(item.getId()); connector.disConnect(); } } getContentFigure().remove(label); this.height -= LINE_HEIGHT; resizeHeight(); }
/** * 创建新的MenuItem * * @param item * @param paramPanels * @param packageName * @param classPrefix */ private void createNewMenuItems( MenuItem item, Map<DefaultItem, MenuItemParamPanel> paramPanels, String sourceFolder, String packageName, String classPrefix) { for (DefaultItem defaultItem : paramPanels.keySet()) { MenuItem menuItem = defaultItem.generateMenuItem(); // 设置ID String id = ""; if (null != item) { // id = item.getId() + menuItem.getId(); id = menuItem.getId(); item.addMenuItem(menuItem); } else { // id = menuObj.getMenuItem().getId() + menuItem.getId(); id = menuItem.getId(); } // menuItem.setId(id); String listenerId = "menu_item_" + id + "_listener"; String genClazz = classPrefix + defaultItem .getSuperClazz() .substring(defaultItem.getSuperClazz().lastIndexOf('.') + 1); JsListenerConf listener = paramPanels .get(defaultItem) .generateListener(sourceFolder, packageName, genClazz, defaultItem, listenerId); menuItem.addListener(listener); addItem(menuItem); } }