Search in sources :

Example 1 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class CourseRemindersController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == segmentView) {
        if (event instanceof SegmentViewEvent) {
            SegmentViewEvent sve = (SegmentViewEvent) event;
            String segmentCName = sve.getComponentName();
            Component clickedLink = mainVC.getComponent(segmentCName);
            if (clickedLink == remindersLink) {
                doOpenRemindersConfiguration(ureq);
            } else if (clickedLink == logsLink) {
                doOpenReminderLogs(ureq);
            }
        }
    }
}
Also used : SegmentViewEvent(org.olat.core.gui.components.segmentedview.SegmentViewEvent) Component(org.olat.core.gui.components.Component) SegmentViewComponent(org.olat.core.gui.components.segmentedview.SegmentViewComponent)

Example 2 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class PreviewRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == luTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent tev = (TreeEvent) event;
            // goto node:
            // after a click in the tree, evaluate the model anew, set the tree
            // model anew, and set the selection of the tree again
            NodeClickedRef nclr = navHandler.evaluateJumpToTreeNode(ureq, getWindowControl(), treeModel, tev, this, null, currentNodeController);
            if (!nclr.isVisible()) {
                getWindowControl().setWarning(translate("warn.notvisible"));
                return;
            }
            if (nclr.isHandledBySubTreeModelListener()) {
                // not used:
                return;
            }
            // set the new treemodel
            treeModel = nclr.getTreeModel();
            luTree.setTreeModel(treeModel);
            // set the new tree selection
            luTree.setSelectedNodeId(nclr.getSelectedNodeId());
            luTree.setOpenNodeIds(nclr.getOpenNodeIds());
            // get the controller (in this case it is a preview controller). Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
            if (nclr.getRunController() != null) {
                if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
                    currentNodeController.dispose();
                }
                currentNodeController = nclr.getRunController();
            }
            CourseNode cn = nclr.getCalledCourseNode();
            if (cn != null) {
                Condition c = cn.getPreConditionVisibility();
                String visibilityExpr = (c.getConditionExpression() == null ? translate("details.visibility.none") : c.getConditionExpression());
                detail.contextPut("visibilityExpr", visibilityExpr);
                detail.contextPut("coursenode", cn);
                currentCourseNode = cn;
            }
            Component nodeComp = currentNodeController.getInitialComponent();
            content.setContent(nodeComp);
        }
    } else if (source == configButton) {
        fireEvent(ureq, new Event("command.config"));
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Condition(org.olat.course.condition.Condition) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Event(org.olat.core.gui.control.Event) OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) CourseNode(org.olat.course.nodes.CourseNode) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) Component(org.olat.core.gui.components.Component)

Example 3 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class AbstractPageListController method getComponents.

@Override
public final Iterable<Component> getComponents(int row, Object rowObject) {
    PortfolioElementRow elRow = model.getObject(row);
    List<Component> components = new ArrayList<>(4);
    if (elRow.getNewEntryLink() != null) {
        components.add(elRow.getNewEntryLink().getComponent());
    }
    if (elRow.getNewFloatingEntryLink() != null) {
        components.add(elRow.getNewFloatingEntryLink().getComponent());
    }
    if (elRow.getNewAssignmentLink() != null) {
        components.add(elRow.getNewAssignmentLink().getComponent());
    }
    if (elRow.getOpenFormItem() != null) {
        components.add(elRow.getOpenFormItem().getComponent());
    }
    if (elRow.getReopenSectionLink() != null) {
        components.add(elRow.getReopenSectionLink().getComponent());
    }
    if (elRow.getCloseSectionLink() != null) {
        components.add(elRow.getCloseSectionLink().getComponent());
    }
    if (elRow.getEditAssignmentLink() != null) {
        components.add(elRow.getEditAssignmentLink().getComponent());
    }
    if (elRow.getDeleteAssignmentLink() != null) {
        components.add(elRow.getDeleteAssignmentLink().getComponent());
    }
    if (elRow.getUpAssignmentLink() != null) {
        components.add(elRow.getUpAssignmentLink().getComponent());
    }
    if (elRow.getDownAssignmentLink() != null) {
        components.add(elRow.getDownAssignmentLink().getComponent());
    }
    if (elRow.getMoveAssignmentLink() != null) {
        components.add(elRow.getMoveAssignmentLink().getComponent());
    }
    if (elRow.getInstantiateAssignmentLink() != null) {
        components.add(elRow.getInstantiateAssignmentLink().getComponent());
    }
    if (elRow.getCommentFormLink() != null) {
        components.add(elRow.getCommentFormLink().getComponent());
    }
    if (elRow.getPoster() != null) {
        components.add(elRow.getPoster());
    }
    if (elRow.getStartSelection() != null) {
        components.add(elRow.getStartSelection().getComponent());
    }
    return components;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) ArrayList(java.util.ArrayList) Component(org.olat.core.gui.components.Component) ImageComponent(org.olat.core.gui.components.image.ImageComponent)

Example 4 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class HighScoreRunController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    VelocityContainer mainVC = this.flc.getFormItemComponent();
    mainVC.put("loadd3js", new StatisticsComponent("d3loader"));
    if (viewHistogram) {
        VelocityContainer scoreHistogramVC = createVelocityContainer("histogram_score");
        // transfer all scores to velocity container as base data for histogram
        HighScoreRankingResults modifiedData = highScoreManager.processHistogramData(allScores, lowerBorder, upperBorder);
        allScores = modifiedData.getModifiedScores();
        scoreHistogramVC.contextPut("datas", BarSeries.datasToString(allScores));
        // histogram marker for own position
        scoreHistogramVC.contextPut("cutValue", ownIdIndices.size() > 0 ? highScoreManager.calculateHistogramCutvalue(allMembers.get(ownIdIndices.get(0)).getScore(), modifiedData.getClasswidth(), modifiedData.getMin()) : -1000);
        // classwidth to correctly display the histogram
        long classwidth = modifiedData.getClasswidth();
        scoreHistogramVC.contextPut("step", classwidth);
        // find path for ownID image to display in histogram
        UserAvatarMapper mapper = new UserAvatarMapper(false);
        String mapperPath = registerMapper(ureq, mapper);
        String identityMapperPath = mapper.createPathFor(mapperPath, ownIdentity);
        scoreHistogramVC.contextPut("mapperUrl", identityMapperPath);
        mainVC.put("scoreHistogram", scoreHistogramVC);
    }
    if (viewPodium) {
        String[] localizer = { "first", "second", "third" };
        // for clarity and space reasons do not show any portraits if one position has more than 6 persons
        int maxPerson = 6;
        boolean showPortraits = !anonymous && allPodium.get(0).size() <= maxPerson && allPodium.get(1).size() <= maxPerson && allPodium.get(2).size() <= maxPerson;
        for (int i = 0; i < localizer.length; i++) {
            int sizePerPos = allPodium.get(i).size();
            StringBuilder sb = new StringBuilder();
            if (sizePerPos > 2) {
                int reduce = 0;
                // create link if podium has more than 2 entries per rank, entries can be displayed as anonymous
                if (allPodium.get(i).get(0).getIdentity().equals(ownIdentity)) {
                    sb.append(userManager.getUserDisplayName(ownIdentity));
                    ++reduce;
                }
                if (sizePerPos > 6 || anonymous) {
                    mainVC.contextPut("further" + (i + 1), (sizePerPos - reduce) + " " + (reduce == 1 ? translate("highscore.further") : translate("highscore.total")));
                } else {
                    links[i] = LinkFactory.createLink(null, "link" + (i + 1), "cmd", (sizePerPos - reduce) + " " + (reduce == 1 ? translate("highscore.further") : translate("highscore.total")), getTranslator(), mainVC, this, 16);
                }
            } else {
                for (HighScoreTableEntry te : allPodium.get(i)) {
                    if (!anonymous || te.getIdentity().equals(ownIdentity)) {
                        sb.append(userManager.getUserDisplayName(te.getIdentity()));
                        sb.append("<br/>");
                    }
                }
            }
            mainVC.contextPut(localizer[i], sizePerPos > 0 ? sb.toString() : translate("highscore.unavail"));
            mainVC.contextPut("score" + (i + 1), sizePerPos > 0 ? allPodium.get(i).get(0).getScore() : null);
            if (sizePerPos > 0 && showPortraits) {
                // decide whether or not to display id portrait
                mainVC.contextPut("number" + (i + 1), sizePerPos);
                for (int j = 0; j < sizePerPos; j++) {
                    Identity currentID = allPodium.get(i).get(j).getIdentity();
                    boolean choosePortrait = !anonymous || ownIdentity.equals(currentID);
                    DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), currentID, false, choosePortrait, !choosePortrait);
                    listenTo(portrait);
                    Component portraitComponent = portrait.getInitialComponent();
                    mainVC.put("portrait" + (i + 1) + "-" + (j + 1), portraitComponent);
                }
            } else {
                // if amount of people per rank is too large, own id portrait can still be displayed
                for (int j = 0; j < sizePerPos; j++) {
                    Identity currentID = allPodium.get(i).get(j).getIdentity();
                    if (ownIdentity.equals(currentID)) {
                        DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), currentID, true, true, false);
                        listenTo(portrait);
                        mainVC.put("portrait" + (i + 1), portrait.getInitialComponent());
                    }
                }
            }
        }
    }
    if (viewTable) {
        FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header1", HighScoreTableEntry.RANK));
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header2", HighScoreTableEntry.SCORE));
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("highscore.table.header3", HighScoreTableEntry.NAME));
        // trim to tableSize
        if (tableSize < allMembers.size()) {
            allMembers.subList(tableSize, allMembers.size()).clear();
        }
        tableDataModel = new FlexiTableDataModelImpl<HighScoreTableEntry>(new HighScoreFlexiTableModel(allMembers, anonymous, translate("highscore.anonymous"), ownIdentity), tableColumnModel);
        FlexiTableElement topTenTable = uifactory.addTableElement(getWindowControl(), "table", tableDataModel, getTranslator(), formLayout);
        topTenTable.setNumOfRowsEnabled(false);
        topTenTable.setCustomizeColumns(false);
        topTenTable.setCssDelegate(new MarkedMemberCssDelegate(false));
        // establish a 2nd table if ownID position is greater than first table's size setting
        if (!ownIdMembers.isEmpty()) {
            tableDataModel2 = new FlexiTableDataModelImpl<HighScoreTableEntry>(new HighScoreFlexiTableModel(ownIdMembers, anonymous, translate("highscore.anonymous"), ownIdentity), tableColumnModel);
            FlexiTableElement tableElement = uifactory.addTableElement(getWindowControl(), "table2", tableDataModel2, getTranslator(), formLayout);
            tableElement.setNumOfRowsEnabled(false);
            tableElement.setCustomizeColumns(false);
            tableElement.setCssDelegate(new MarkedMemberCssDelegate(true));
        }
    }
    if (viewPosition && ownIdIndices.size() > 0) {
        int amountWorse = allScores.length - ownIdIndices.get(0) - 1;
        if (amountWorse > 0) {
            mainVC.contextPut("relposition", translate("highscore.position.inrelation", new String[] { String.valueOf(amountWorse) }));
        }
        int ownRank = highscoreDataModel.getOwnTableEntry().getRank();
        mainVC.contextPut("position", translate("highscore.position.yourposition", new String[] { String.valueOf(ownRank) }));
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) StatisticsComponent(org.olat.core.gui.components.chart.StatisticsComponent) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) UserAvatarMapper(org.olat.user.UserAvatarMapper) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) HighScoreRankingResults(org.olat.course.highscore.model.HighScoreRankingResults) Identity(org.olat.core.id.Identity) StatisticsComponent(org.olat.core.gui.components.chart.StatisticsComponent) Component(org.olat.core.gui.components.Component) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Example 5 with Component

use of org.olat.core.gui.components.Component in project OpenOLAT by OpenOLAT.

the class LectureRepositoryAdminController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == segmentView) {
        if (event instanceof SegmentViewEvent) {
            SegmentViewEvent sve = (SegmentViewEvent) event;
            String segmentCName = sve.getComponentName();
            Component clickedLink = mainVC.getComponent(segmentCName);
            if (clickedLink == lecturesLink) {
                doOpenLectures(ureq);
            } else if (clickedLink == settingsLink) {
                doOpenSettings(ureq);
            } else if (clickedLink == participantsLink) {
                doOpenParticipants(ureq);
            }
        }
    } else if (archiveLink == source) {
        doExportArchive(ureq);
    } else if (logLink == source) {
        doExportLog(ureq);
    }
}
Also used : SegmentViewEvent(org.olat.core.gui.components.segmentedview.SegmentViewEvent) Component(org.olat.core.gui.components.Component) SegmentViewComponent(org.olat.core.gui.components.segmentedview.SegmentViewComponent)

Aggregations

Component (org.olat.core.gui.components.Component)300 SegmentViewComponent (org.olat.core.gui.components.segmentedview.SegmentViewComponent)90 SegmentViewEvent (org.olat.core.gui.components.segmentedview.SegmentViewEvent)90 ArrayList (java.util.ArrayList)36 Controller (org.olat.core.gui.control.Controller)28 Link (org.olat.core.gui.components.link.Link)22 BasicController (org.olat.core.gui.control.controller.BasicController)22 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)18 Panel (org.olat.core.gui.components.panel.Panel)12 HighScoreRunController (org.olat.course.highscore.ui.HighScoreRunController)12 Date (java.util.Date)10 UserRequest (org.olat.core.gui.UserRequest)10 ComponentRenderer (org.olat.core.gui.components.ComponentRenderer)10 TreeNode (org.olat.core.gui.components.tree.TreeNode)10 RenderResult (org.olat.core.gui.render.RenderResult)10 StringOutput (org.olat.core.gui.render.StringOutput)10 Translator (org.olat.core.gui.translator.Translator)10 AbstractComponent (org.olat.core.gui.components.AbstractComponent)8 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)8