Search in sources :

Example 6 with DisplayPortraitController

use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.

the class MemberInfoController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), identity, true, false);
        // auto dispose
        listenTo(dpc);
        layoutCont.put("image", dpc.getInitialComponent());
        layoutCont.contextPut("fullname", StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
    }
    // user properties
    FormLayoutContainer userPropertiesContainer = FormLayoutContainer.createDefaultFormLayout_6_6("userProperties", getTranslator());
    formLayout.add("userProperties", userPropertiesContainer);
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(getClass().getCanonicalName(), false);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        String value = userPropertyHandler.getUserProperty(identity.getUser(), getLocale());
        String key = userPropertyHandler.i18nFormElementLabelKey();
        if (value == null) {
            value = "";
        }
        uifactory.addStaticTextElement("up_" + propName, key, value, userPropertiesContainer);
    }
    // course informations
    FormLayoutContainer courseInfosContainer = FormLayoutContainer.createDefaultFormLayout_9_3("courseInfos", getTranslator());
    formLayout.add("courseInfos", courseInfosContainer);
    membershipCreationEl = uifactory.addStaticTextElement("firstTime", "course.membership.creation", "", courseInfosContainer);
    if (securityModule.isUserLastVisitVisible(ureq.getUserSession().getRoles())) {
        Formatter formatter = Formatter.getInstance(getLocale());
        String lastVisit = "";
        String numOfVisits = "0";
        if (courseInfos != null) {
            if (courseInfos.getRecentLaunch() != null) {
                lastVisit = formatter.formatDate(courseInfos.getRecentLaunch());
            }
            if (courseInfos.getVisit() >= 0) {
                numOfVisits = Integer.toString(courseInfos.getVisit());
            }
        }
        uifactory.addStaticTextElement("lastTime", "course.lastTime", lastVisit, courseInfosContainer);
        uifactory.addStaticTextElement("numOfVisits", "course.numOfVisits", numOfVisits, courseInfosContainer);
    }
    // links
    if (withLinks) {
        homeLink = uifactory.addFormLink("home", formLayout, Link.BUTTON);
        homeLink.setIconLeftCSS("o_icon o_icon_home");
        formLayout.add("home", homeLink);
        contactLink = uifactory.addFormLink("contact", formLayout, Link.BUTTON);
        contactLink.setIconLeftCSS("o_icon o_icon_mail");
        formLayout.add("contact", contactLink);
        if (repoEntryKey != null) {
            assessmentLink = uifactory.addFormLink("assessment", formLayout, Link.BUTTON);
            assessmentLink.setIconLeftCSS("o_icon o_icon_certificate");
            formLayout.add("assessment", assessmentLink);
        }
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) DisplayPortraitController(org.olat.user.DisplayPortraitController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 7 with DisplayPortraitController

use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.

the class OlatTopNavController method getPortraitCmp.

private Component getPortraitCmp(UserRequest ureq) {
    Controller ctr = new DisplayPortraitController(ureq, getWindowControl(), getIdentity(), false, false, false, true);
    listenTo(ctr);
    return ctr.getInitialComponent();
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) DisplayPortraitController(org.olat.user.DisplayPortraitController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) LockableController(org.olat.core.commons.fullWebApp.LockableController)

Example 8 with DisplayPortraitController

use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.

the class EPMapViewController method initForm.

protected void initForm(UserRequest ureq) {
    Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
    if (ownerIdentity != null) {
        DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
        mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
    }
    mainVc.contextPut("map", map);
    mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
    mainVc.remove(mainVc.getComponent("map.editButton"));
    if (secCallback.canEditStructure()) {
        editButton = LinkFactory.createButton("map.editButton", mainVc, this);
        editButton.setElementCssClass("o_sel_ep_edit_map");
        editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
        if (editMode == EditMode.view) {
            editButton.setCustomDisplayText(translate("map.editButton.on"));
        } else {
            editButton.setCustomDisplayText(translate("map.editButton.off"));
        }
    }
    if (back) {
        backLink = LinkFactory.createLinkBack(mainVc, this);
    }
    mainVc.remove(mainVc.getComponent("map.submit.assess"));
    if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
    }
    if (map instanceof EPStructuredMap) {
        EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
        RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
        if (repoEntry != null) {
            mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
            String url = Settings.getServerContextPathURI();
            url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
            mainVc.contextPut("courseLink", url);
        }
    }
    mainVc.remove(mainVc.getComponent("addButton"));
    if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
        if (secCallback.canAddPage()) {
            addButton.setShowLink(EPAddElementsController.ADD_PAGE);
        }
        mainVc.put("addButton", addButton.getInitialComponent());
        listenTo(addButton);
    }
    mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
    List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
    if (pageList != null && pageList.size() != 0) {
        // prepare to paint pages also
        removeAsListenerAndDispose(pageCtrl);
        pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
        mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
        listenTo(pageCtrl);
    } else if (mainVc.getComponent("pagesCtrl") != null) {
        mainVc.remove(mainVc.getComponent("pagesCtrl"));
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 9 with DisplayPortraitController

use of org.olat.user.DisplayPortraitController in project openolat by klemens.

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 10 with DisplayPortraitController

use of org.olat.user.DisplayPortraitController in project openolat by klemens.

the class EPMapViewController method initForm.

protected void initForm(UserRequest ureq) {
    Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
    if (ownerIdentity != null) {
        DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
        mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
    }
    mainVc.contextPut("map", map);
    mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
    mainVc.remove(mainVc.getComponent("map.editButton"));
    if (secCallback.canEditStructure()) {
        editButton = LinkFactory.createButton("map.editButton", mainVc, this);
        editButton.setElementCssClass("o_sel_ep_edit_map");
        editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
        if (editMode == EditMode.view) {
            editButton.setCustomDisplayText(translate("map.editButton.on"));
        } else {
            editButton.setCustomDisplayText(translate("map.editButton.off"));
        }
    }
    if (back) {
        backLink = LinkFactory.createLinkBack(mainVc, this);
    }
    mainVc.remove(mainVc.getComponent("map.submit.assess"));
    if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
    }
    if (map instanceof EPStructuredMap) {
        EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
        RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
        if (repoEntry != null) {
            mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
            String url = Settings.getServerContextPathURI();
            url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
            mainVc.contextPut("courseLink", url);
        }
    }
    mainVc.remove(mainVc.getComponent("addButton"));
    if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
        if (secCallback.canAddPage()) {
            addButton.setShowLink(EPAddElementsController.ADD_PAGE);
        }
        mainVc.put("addButton", addButton.getInitialComponent());
        listenTo(addButton);
    }
    mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
    List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
    if (pageList != null && pageList.size() != 0) {
        // prepare to paint pages also
        removeAsListenerAndDispose(pageCtrl);
        pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
        mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
        listenTo(pageCtrl);
    } else if (mainVc.getComponent("pagesCtrl") != null) {
        mainVc.remove(mainVc.getComponent("pagesCtrl"));
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Aggregations

DisplayPortraitController (org.olat.user.DisplayPortraitController)20 Controller (org.olat.core.gui.control.Controller)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 Identity (org.olat.core.id.Identity)8 UserShortDescription (org.olat.admin.user.UserShortDescription)4 Component (org.olat.core.gui.components.Component)4 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)4 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)4 BasicController (org.olat.core.gui.control.controller.BasicController)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LockableController (org.olat.core.commons.fullWebApp.LockableController)2 Mark (org.olat.core.commons.services.mark.Mark)2 MarkResourceStat (org.olat.core.commons.services.mark.MarkResourceStat)2 StatisticsComponent (org.olat.core.gui.components.chart.StatisticsComponent)2 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2