コード例 #1
0
 /**
  * 增加子项
  *
  * @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();
 }
コード例 #2
0
  /**
   * 创建新的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);
    }
  }