/** * 删除子项 * * @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(); }
/** * 增加子项Label的事件 * * @param label */ private void addItemLabelListener(MenuItemLabel label) { label.addMouseListener( new MouseListener.Stub() { public void mouseDoubleClicked(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mousePressed(MouseEvent e) { MenuItemLabel currentLabel = (MenuItemLabel) e.getSource(); // 取消所有其它子项选中状态 LFWBaseEditor.getActiveEditor().getGraph().unSelectAllLabels(); // 选中该子项 selectLabel(currentLabel); // 显示属性 MenuItem currentItem = (MenuItem) ((MenuItemLabel) currentLabel).getEditableObj(); menuObj.setCurrentItem(currentItem); // 新版显示事件 LFWBaseEditor.getActiveEditor().getViewPage().setWebElement(currentItem); LFWBaseEditor.getActiveEditor() .getViewPage() .addEventPropertiesView( currentItem.getEventConfs(), LFWAMCPersTool.getCurrentWidget().getControllerClazz()); // 重新显示属性内容 reloadPropertySheet(menuObj); // 菜单管理器中的menuItem if (MenubarEditor.getActiveMenubarEditor() != null) { // 重新显示Listener内容 ((MenubarGraph) MenubarEditor.getActiveMenubarEditor().getGraph()) .reloadListenerFigure((MenuItem) currentLabel.getEditableObj()); } // 右键菜单中的menuitem else if (ContextMenuEditor.getActiveMenubarEditor() != null) { ((ContextMenuGrahp) ContextMenuEditor.getActiveMenubarEditor().getGraph()) .reloadListenerFigure((MenuItem) currentLabel.getEditableObj()); } } }); }