public MembersManagementMainController(
      UserRequest ureq, WindowControl wControl, RepositoryEntry re) {
    super(ureq, wControl);
    this.repoEntry = re;
    acModule = CoreSpringFactory.getImpl(AccessControlModule.class);
    acService = CoreSpringFactory.getImpl(ACService.class);

    // logging
    getUserActivityLogger().setStickyActionType(ActionType.admin);
    ICourse course = CourseFactory.loadCourse(re.getOlatResource());
    addLoggingResourceable(LoggingResourceable.wrap(course));

    // ui stuff
    menuTree = new MenuTree("menuTree");
    menuTree.setTreeModel(buildTreeModel());
    menuTree.setRootVisible(false);
    menuTree.addListener(this);

    mainVC = createVelocityContainer("main_members");

    columnLayoutCtr =
        new LayoutMain3ColsController(
            ureq, getWindowControl(), menuTree, null, mainVC, "members-" + repoEntry.getKey());
    listenTo(columnLayoutCtr);
    putInitialPanel(columnLayoutCtr.getInitialComponent());

    selectMenuItem(ureq, CMD_MEMBERS);
  }
 @Override
 public void event(UserRequest ureq, Component source, Event event) {
   if (source == cancelButton) {
     fireEvent(ureq, Event.CANCELLED_EVENT);
   } else if (source == selectButton) {
     TreePosition tp = insertTree.getInsertionPosition();
     if (tp != null) {
       doInsert(ureq, tp);
     }
   } else if (event instanceof InsertEvent) {
     boolean canSelect = insertTree.getInsertionPoint() != null;
     selectButton.setEnabled(canSelect);
   }
 }
  private Controller selectMenuItem(UserRequest ureq, String cmd) {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(cmd, 0l);
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(
        LoggingResourceable.wrapBusinessPath(ores));
    WindowControl bwControl =
        BusinessControlFactory.getInstance()
            .createBusinessWindowControl(ores, null, getWindowControl());
    addToHistory(ureq, bwControl);

    Controller selectedCtrl = null;
    if (CMD_MEMBERS.equals(cmd)) {
      if (membersOverviewCtrl == null) {
        membersOverviewCtrl = new MembersOverviewController(ureq, bwControl, repoEntry);
        listenTo(membersOverviewCtrl);
      }
      mainVC.put("content", membersOverviewCtrl.getInitialComponent());
      selectedCtrl = membersOverviewCtrl;
    } else if (CMD_GROUPS.equals(cmd)) {
      if (groupsCtrl == null) {
        groupsCtrl = new CourseBusinessGroupListController(ureq, bwControl, repoEntry);
        listenTo(groupsCtrl);
      }
      groupsCtrl.reloadModel();
      mainVC.put("content", groupsCtrl.getInitialComponent());
      selectedCtrl = groupsCtrl;
    } else if (CMD_BOOKING.equals(cmd)) {
      if (ordersController == null) {
        ordersController = new OrdersAdminController(ureq, bwControl, repoEntry.getOlatResource());
        listenTo(ordersController);
      }
      mainVC.put("content", ordersController.getInitialComponent());
      selectedCtrl = ordersController;
    } else if (CMD_RIGHTS.equals(cmd)) {
      if (rightsController == null) {
        rightsController =
            new GroupsAndRightsController(ureq, bwControl, repoEntry.getOlatResource());
        listenTo(rightsController);
      }
      mainVC.put("content", rightsController.getInitialComponent());
      selectedCtrl = rightsController;
    }

    TreeNode selTreeNode =
        TreeHelper.findNodeByUserObject(cmd, menuTree.getTreeModel().getRootNode());
    if (selTreeNode != null && !selTreeNode.getIdent().equals(menuTree.getSelectedNodeId())) {
      menuTree.setSelectedNodeId(selTreeNode.getIdent());
    }
    return selectedCtrl;
  }
  public MoveCopySubtreeController(
      UserRequest ureq,
      WindowControl wControl,
      OLATResourceable ores,
      CourseEditorTreeNode moveCopyFrom,
      boolean copy) {
    super(ureq, wControl);
    this.ores = ores;
    this.moveCopyFrom = moveCopyFrom;
    this.copy = copy;

    ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
    addLoggingResourceable(LoggingResourceable.wrap(course));
    addLoggingResourceable(LoggingResourceable.wrap(moveCopyFrom.getCourseNode()));

    insertTree = new MenuTree(null, "copy_node_selection", this);
    insertTree.enableInsertTool(true);
    insertModel = new InsertTreeModel(course.getEditorTreeModel().getRootNode(), moveCopyFrom);
    insertTree.setTreeModel(insertModel);

    VelocityContainer mainVC = createVelocityContainer("moveCopyNode");

    selectButton = LinkFactory.createButton("insertAtSelectedTreepos", mainVC, this);
    selectButton.setCustomEnabledLinkCSS("btn btn-primary");
    selectButton.setCustomDisabledLinkCSS("btn btn-default");
    selectButton.setEnabled(false);
    cancelButton = LinkFactory.createButton("cancel", mainVC, this);

    int numOfNodes = TreeHelper.totalNodeCount(insertModel.getRootNode());
    if (numOfNodes > CourseModule.getCourseNodeLimit()) {
      String msg =
          getTranslator()
              .translate(
                  "warning.containsXXXormore.nodes",
                  new String[] {
                    String.valueOf(numOfNodes),
                    String.valueOf(CourseModule.getCourseNodeLimit() + 1)
                  });
      Controller tmp = MessageUIFactory.createWarnMessage(ureq, wControl, null, msg);
      listenTo(tmp);
      mainVC.put("nodelimitexceededwarning", tmp.getInitialComponent());
    }

    mainVC.put("selection", insertTree);
    putInitialPanel(mainVC);
  }
 @Override
 protected void event(UserRequest ureq, Component source, Event event) {
   if (source == menuTree) {
     if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
       TreeNode selTreeNode = menuTree.getSelectedNode();
       String cmd = (String) selTreeNode.getUserObject();
       selectMenuItem(ureq, cmd);
     }
   }
 }