@Override public Position[] getInsertionPosition(TreeNode node) { Position[] positions; if (source == node) { positions = new Position[0]; } else if (getRootNode() == node) { positions = new Position[] {Position.under}; } else if (TreeHelper.isInParentLine(node, source)) { positions = new Position[0]; } else { positions = new Position[] {Position.up, Position.down, Position.under}; } return positions; }
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); }