示例#1
0
 /** @return the cachd LoginSettings for this user. */
 public LoginSettings getLoginSettings() {
   try {
     return getCache().getLoginSettings();
   } catch (DataSourceException e) {
     e.printStackTrace();
   }
   return null;
 }
示例#2
0
  /**
   * @return the currently selected menu. If there is no valid current selection then the main menu
   *     is returned.
   */
  public MenuAction getCurrentMenu() {
    assert _user != null;

    if (_currentMenu == null) {
      if (_rootMenu == null) {
        // no mainmenu yet, construct the main menu object and then load
        // base menu items for group (s)
        _rootMenu = new Submenu("Main Menu", "Main Menu", null, null);

        try {
          // find the groups the user is a member of
          boolean isFirst = true;
          Vector gmems = _user.getGroupMemberships();
          for (int i = 0; gmems != null && i < gmems.size(); i++) {
            GroupMembership gm = (GroupMembership) gmems.elementAt(i);
            if (gm != null) {
              // add a spaced between multiple group menus
              if (isFirst) isFirst = false;
              else ; // _rootMenu.addChildAtEnd (new TextAction ());

              // get the group menu
              Vector v = getCache().getGroupMenus(new Integer(gm.getGroupId()));

              // add the group menu items to main menu
              for (int j = 0; v != null && j < v.size(); j++)
                _rootMenu.addChildAtEnd((MenuAction) v.get(j));
            }
          }
        } catch (DataSourceException e) {
          Log.error("UserState.getMenu: " + e.toString());
        }

        // add the logout entry
        _rootMenu.addChildAtEnd(new LogoutAction());
      }

      _currentMenu = _rootMenu;
    }

    return _currentMenu;
  }