/** * 增加子项 * * @param signal */ public void addItem(MenuItem menuItem) { MenuItem currentMenuItem = menuObj.getMenuItem(); int index = 0; if (null != currentMenuItem.getChildList()) index = currentMenuItem.getChildList().size(); currentMenuItem.addMenuItem(menuItem); MenuItemLabel label = new MenuItemLabel(menuItem); addToContent(label, index); addItemLabelListener(label); this.height += LINE_HEIGHT; resizeHeight(); }
/** * 删除子项 * * @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(); }
/** 显示所有子项 */ private void addItems() { MenuItem menuItem = menuObj.getMenuItem(); List<MenuItem> itemList = menuItem.getChildList(); if (itemList != null) { Iterator<MenuItem> it = itemList.iterator(); while (it.hasNext()) { MenuItem item = it.next(); MenuItemLabel label = new MenuItemLabel(item); addToContent(label); this.height += LINE_HEIGHT; addItemLabelListener(label); } } }