예제 #1
0
  public void init() throws ConfigException {
    if (initialized) return;

    //        String spaces = "";
    //        for(int i = 0; i < nestingInit; i++)
    //            spaces += "  ";
    //        System.out.println(spaces + name);

    nestingInit++;

    super.init();

    if (inheritedMenuName != null) {
      if (inheritedMenu == null) {
        inheritedMenu = config.getDesignMenuManager().findDesignMenu(inheritedMenuName);

        if (inheritedMenu == null)
          throw new ConfigException(
              "Base design menu '" + inheritedMenuName + "' of menu '" + name + "' is not found");

        checkParentInheritance();

        Checks.checkCyclicInheritance(this, "design menu");

        if (inheritedMenu != null) inheritedMenu.init();

        inheritMenu();
      } else {
        if (!updated)
          throw new ConfigException(
              "Internal error: menu element '"
                  + name
                  + (parentMenu != null ? "' of design menu '" + parentMenu.getName() : "")
                  + "' is neigher initialized nor updated, but has already inherited menu '"
                  + inheritedMenuName
                  + "'");
      }
    }

    String commonMessagePart =
        " of menu '"
            + name
            + (parentMenu != null ? "' in menu '" + parentMenu.getName() : "'")
            + " is absent";

    if (label == null) throw new ConfigException("Label" + commonMessagePart);
    else if (parentMenu == null && description == null)
      throw new ConfigException("Description" + commonMessagePart);

    initItemsList();

    nestingInit--;

    initialized = true;
  }
예제 #2
0
  private void initItemsList() throws ConfigException {
    if (items.isEmpty())
      throw new ConfigException(
          "Menu '"
              + name
              + "'"
              + (parentMenu != null ? " in menu '" + parentMenu.getName() : "'")
              + " doesn't contain any items");

    Checks.checkDuplicatedNames(items, "menu '" + name + "'");

    for (Iterator<DesignMenuItem> i = items.iterator(); i.hasNext(); )
      ((DesignMenuItem) i.next()).init();
  }