Search in sources :

Example 81 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class AccessRightsEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (member != null && formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        Controller portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), member, true, true);
        layoutCont.getFormItemComponent().put("portrait", portraitCtr.getInitialComponent());
        listenTo(portraitCtr);
        Controller userShortDescrCtr = new UserShortDescription(ureq, getWindowControl(), member);
        layoutCont.getFormItemComponent().put("userShortDescription", userShortDescrCtr.getInitialComponent());
        listenTo(userShortDescrCtr);
    }
    selectAll = uifactory.addFormLink("form.checkall", "form.checkall", null, formLayout, Link.LINK);
    selectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_on");
    deselectAll = uifactory.addFormLink("form.uncheckall", "form.uncheckall", null, formLayout, Link.LINK);
    deselectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_off");
    // binder
    MultipleSelectionElement coachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
    coachEl.addActionListener(FormEvent.ONCHANGE);
    coachEl.setVisible(grading);
    MultipleSelectionElement reviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
    reviewerEl.addActionListener(FormEvent.ONCHANGE);
    binderRow = new BinderAccessRightsRow(coachEl, reviewerEl, binder);
    coachEl.setUserObject(binderRow);
    reviewerEl.setUserObject(binderRow);
    // sections
    List<Section> sections = portfolioService.getSections(binder);
    Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
    for (Section section : sections) {
        MultipleSelectionElement sectionCoachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        sectionCoachEl.addActionListener(FormEvent.ONCHANGE);
        sectionCoachEl.setVisible(grading);
        MultipleSelectionElement sectionReviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        sectionReviewerEl.addActionListener(FormEvent.ONCHANGE);
        SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionCoachEl, sectionReviewerEl, section, binderRow);
        binderRow.getSections().add(sectionRow);
        sectionMap.put(section.getKey(), sectionRow);
        sectionCoachEl.setUserObject(sectionRow);
        sectionReviewerEl.setUserObject(sectionRow);
    }
    // pages
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
        MultipleSelectionElement pageCoachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        pageCoachEl.addActionListener(FormEvent.ONCHANGE);
        pageCoachEl.setVisible(grading);
        MultipleSelectionElement pageReviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        pageReviewerEl.addActionListener(FormEvent.ONCHANGE);
        PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageCoachEl, pageReviewerEl, page, sectionRow);
        sectionRow.getPages().add(pageRow);
        pageCoachEl.setUserObject(pageRow);
        pageReviewerEl.setUserObject(pageRow);
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("binderRow", binderRow);
        layoutCont.contextPut("grading", new Boolean(grading));
    }
    if (hasButtons) {
        FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
        formLayout.add(buttonsCont);
        buttonsCont.setRootForm(mainForm);
        formLayout.add("buttons", buttonsCont);
        uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
        removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
        if (canEdit) {
            uifactory.addFormSubmitButton("save", buttonsCont);
        }
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) UserShortDescription(org.olat.admin.user.UserShortDescription) HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Page(org.olat.modules.portfolio.Page) DisplayPortraitController(org.olat.user.DisplayPortraitController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) Section(org.olat.modules.portfolio.Section) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 82 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class SelectMembersController method makeSelection.

private MultipleSelectionElement makeSelection(String name, List<Member> members, FormItemContainer formLayout) {
    String[] keys = new String[members.size()];
    String[] values = new String[members.size()];
    List<String> preSelectedOptions = new ArrayList<>();
    for (int i = members.size(); i-- > 0; ) {
        Member member = members.get(i);
        String optionKey = member.getKey().toString();
        keys[i] = optionKey;
        values[i] = member.getFullName();
        if (preSelectedMembers.contains(member)) {
            preSelectedOptions.add(optionKey);
        }
    }
    MultipleSelectionElement selectionEl = uifactory.addCheckboxesVertical(name, name, formLayout, keys, values, 2);
    for (String preSelectedOption : preSelectedOptions) {
        selectionEl.select(preSelectedOption, true);
    }
    return selectionEl;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) Member(org.olat.course.nodes.members.Member)

Example 83 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class LicenseAdminConfigController method createActivationCheckBoxes.

private List<MultipleSelectionElement> createActivationCheckBoxes(LicenseType licenseType, List<LicenseHandler> handlers) {
    List<MultipleSelectionElement> formItems = new ArrayList<>();
    for (LicenseHandler handler : handlers) {
        boolean handlerEnabled = licenseModule.isEnabled(handler);
        if (handlerEnabled) {
            String toggleName = "toggle-" + licenseType.getKey() + handler.getType();
            MultipleSelectionElement toggle = uifactory.addCheckboxesHorizontal(toggleName, null, flc, keys, values);
            toggle.setUserObject(new HandlerLicenseType(licenseType, handler));
            toggle.addActionListener(FormEvent.ONCHANGE);
            toggle.setAjaxOnly(true);
            toggle.select(keys[0], licenseService.isActive(handler, licenseType));
            formItems.add(toggle);
        }
    }
    return formItems;
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) ArrayList(java.util.ArrayList)

Example 84 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class LicenseAdminConfigController method loadModel.

private void loadModel() {
    List<LicenseType> licenseTypes = licenseService.loadLicenseTypes();
    Collections.sort(licenseTypes);
    List<LicenseTypeRow> rows = new ArrayList<>();
    for (LicenseType licenseType : licenseTypes) {
        List<MultipleSelectionElement> formItems = createActivationCheckBoxes(licenseType, licenseHandlers);
        LicenseTypeRow licenseTypeRow = new LicenseTypeRow(licenseType, formItems);
        rows.add(licenseTypeRow);
    }
    dataModel.setObjects(rows);
    tableEl.reset();
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) ArrayList(java.util.ArrayList) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 85 with MultipleSelectionElement

use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project OpenOLAT by OpenOLAT.

the class SysinfoController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    Formatter format = Formatter.getInstance(getLocale());
    // runtime informations
    FormLayoutContainer runtimeCont = FormLayoutContainer.createDefaultFormLayout("runtime", getTranslator());
    formLayout.add(runtimeCont);
    formLayout.add("runtime", runtimeCont);
    String startup = format.formatDateAndTime(new Date(WebappHelper.getTimeOfServerStartup()));
    uifactory.addStaticTextElement("runtime.startup", "runtime.startup", startup, runtimeCont);
    String time = format.formatDateAndTime(new Date()) + " (" + Calendar.getInstance().getTimeZone().getDisplayName(false, TimeZone.SHORT, ureq.getLocale()) + ")";
    uifactory.addStaticTextElement("runtime.time", "runtime.time", time, runtimeCont);
    // memory
    uifactory.addMemoryView("memoryHeap", "runtime.memory", MemoryType.HEAP, runtimeCont);
    uifactory.addMemoryView("memoryNonHeap", "runtime.memory.permGen", MemoryType.NON_HEAP, runtimeCont);
    // controllers
    int controllerCnt = DefaultController.getControllerCount();
    uifactory.addStaticTextElement("controllercount", "runtime.controllercount", Integer.toString(controllerCnt), runtimeCont);
    int numOfDispatchingThreads = sessionStatsManager.getConcurrentCounter();
    uifactory.addStaticTextElement("dispatchingthreads", "runtime.dispatchingthreads", Integer.toString(numOfDispatchingThreads), runtimeCont);
    // sessions and clicks
    String sessionAndClicksPage = velocity_root + "/session_clicks.html";
    FormLayoutContainer sessionAndClicksCont = FormLayoutContainer.createCustomFormLayout("session_clicks", getTranslator(), sessionAndClicksPage);
    runtimeCont.add(sessionAndClicksCont);
    sessionAndClicksCont.setLabel("sess.and.clicks", null);
    Calendar lastLoginMonthlyLimit = Calendar.getInstance();
    // users monthly
    lastLoginMonthlyLimit.add(Calendar.MONTH, -1);
    Long userLastMonth = securityManager.countUniqueUserLoginsSince(lastLoginMonthlyLimit.getTime());
    // -1 -5 = -6 for half a year
    lastLoginMonthlyLimit.add(Calendar.MONTH, -5);
    Long userLastSixMonths = securityManager.countUniqueUserLoginsSince(lastLoginMonthlyLimit.getTime());
    // -1 -11 = -12 for one year
    lastLoginMonthlyLimit.add(Calendar.MONTH, -11);
    Long userLastYear = securityManager.countUniqueUserLoginsSince(lastLoginMonthlyLimit.getTime());
    sessionAndClicksCont.contextPut("users1month", userLastMonth.toString());
    sessionAndClicksCont.contextPut("users6month", userLastSixMonths.toString());
    sessionAndClicksCont.contextPut("usersyear", userLastYear.toString());
    // users daily
    Calendar lastLoginDailyLimit = Calendar.getInstance();
    lastLoginDailyLimit.add(Calendar.DAY_OF_YEAR, -1);
    Long userLastDay = securityManager.countUniqueUserLoginsSince(lastLoginDailyLimit.getTime());
    // -1 - 6 = -7 for last week
    lastLoginDailyLimit.add(Calendar.DAY_OF_YEAR, -6);
    Long userLast6Days = securityManager.countUniqueUserLoginsSince(lastLoginDailyLimit.getTime());
    sessionAndClicksCont.contextPut("userslastday", userLastDay.toString());
    sessionAndClicksCont.contextPut("userslastweek", userLast6Days.toString());
    // last 5 minutes
    long activeSessions = sessionStatsManager.getActiveSessions(300);
    sessionAndClicksCont.contextPut("count5Minutes", String.valueOf(activeSessions));
    SessionsStats stats = sessionStatsManager.getSessionsStatsLast(300);
    sessionAndClicksCont.contextPut("click5Minutes", String.valueOf(stats.getAuthenticatedClickCalls()));
    sessionAndClicksCont.contextPut("poll5Minutes", String.valueOf(stats.getAuthenticatedPollerCalls()));
    sessionAndClicksCont.contextPut("request5Minutes", String.valueOf(stats.getRequests()));
    sessionAndClicksCont.contextPut("minutes", String.valueOf(5));
    // last minute
    activeSessions = sessionStatsManager.getActiveSessions(60);
    sessionAndClicksCont.contextPut("count1Minute", String.valueOf(activeSessions));
    stats = sessionStatsManager.getSessionsStatsLast(60);
    sessionAndClicksCont.contextPut("click1Minute", String.valueOf(stats.getAuthenticatedClickCalls()));
    sessionAndClicksCont.contextPut("poll1Minute", String.valueOf(stats.getAuthenticatedPollerCalls()));
    sessionAndClicksCont.contextPut("request1Minute", String.valueOf(stats.getRequests()));
    sessionAndClicksCont.contextPut("oneMinute", "1");
    // server informations
    FormLayoutContainer serverCont = FormLayoutContainer.createDefaultFormLayout("server", getTranslator());
    formLayout.add(serverCont);
    formLayout.add("server", serverCont);
    // version
    uifactory.addStaticTextElement("version", "sysinfo.version", Settings.getFullVersionInfo(), serverCont);
    uifactory.addStaticTextElement("version.hg", "sysinfo.version.hg", WebappHelper.getChangeSet(), serverCont);
    String buildDate = format.formatDateAndTime(Settings.getBuildDate());
    uifactory.addStaticTextElement("version.date", "sysinfo.version.date", buildDate, serverCont);
    // cluster
    boolean clusterMode = "Cluster".equals(Settings.getClusterMode());
    MultipleSelectionElement clusterEl = uifactory.addCheckboxesHorizontal("cluster", "sysinfo.cluster", serverCont, new String[] { "xx" }, new String[] { "" });
    clusterEl.setEnabled(false);
    clusterEl.select("xx", clusterMode);
    String nodeId = StringHelper.containsNonWhitespace(Settings.getNodeInfo()) ? Settings.getNodeInfo() : "N1";
    uifactory.addStaticTextElement("node", "sysinfo.node", nodeId, serverCont);
    File baseDir = new File(WebappHelper.getContextRoot());
    String baseDirPath = null;
    try {
        baseDirPath = baseDir.getCanonicalPath();
    } catch (IOException e1) {
        baseDirPath = baseDir.getAbsolutePath();
    }
    uifactory.addStaticTextElement("sysinfo.basedir", "sysinfo.basedir", baseDirPath, serverCont);
    uifactory.addStaticTextElement("sysinfo.olatdata", "sysinfo.olatdata", WebappHelper.getUserDataRoot(), serverCont);
}
Also used : Formatter(org.olat.core.util.Formatter) Calendar(java.util.Calendar) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) IOException(java.io.IOException) Date(java.util.Date) SessionsStats(org.olat.admin.sysinfo.model.SessionsStats) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) File(java.io.File)

Aggregations

MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)136 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)22 ArrayList (java.util.ArrayList)20 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)16 MultipleSelectionElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.MultipleSelectionElementImpl)16 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)10 FormItem (org.olat.core.gui.components.form.flexible.FormItem)8 Identity (org.olat.core.id.Identity)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)6 ICourse (org.olat.course.ICourse)6 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)5 VFSItem (org.olat.core.util.vfs.VFSItem)5 Section (org.olat.modules.portfolio.Section)5 File (java.io.File)4 UserShortDescription (org.olat.admin.user.UserShortDescription)4