Search in sources :

Example 56 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project OpenOLAT by OpenOLAT.

the class GTACoachSelectionController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    String type = entries.get(0).getOLATResourceable().getResourceableTypeName();
    Long key = entries.get(0).getOLATResourceable().getResourceableId();
    if ("Identity".equalsIgnoreCase(type)) {
        if (participantListCtrl != null && participantListCtrl.hasIdentityKey(key)) {
            Identity selectedIdentity = securityManager.loadIdentityByKey(key);
            List<ContextEntry> subEntries = entries.subList(1, entries.size());
            doSelectParticipant(ureq, selectedIdentity).activate(ureq, subEntries, entries.get(0).getTransientState());
        }
    } else if ("BusinessGroup".equalsIgnoreCase(type)) {
        if (groupListCtrl != null) {
            BusinessGroup group = groupListCtrl.getBusinessGroup(key);
            if (group != null) {
                List<ContextEntry> subEntries = entries.subList(1, entries.size());
                doSelectBusinessGroup(ureq, group).activate(ureq, subEntries, entries.get(0).getTransientState());
            }
        }
    } else if ("Solution".equals(type) && entries.size() > 1) {
        String path = BusinessControlFactory.getInstance().getPath(entries.get(1));
        String url = solutionMapperUri + "/" + path;
        solutionDownloadCmp.triggerFileDownload(url);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) List(java.util.List) Identity(org.olat.core.id.Identity) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 57 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project OpenOLAT by OpenOLAT.

the class BusinessGroupFormController method initForm.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
 */
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Create the business group name input text element
    if (bulkMode) {
        businessGroupName = uifactory.addTextElement("create.form.title.bgnames", "create.form.title.bgnames", 10 * BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout);
        businessGroupName.setExampleKey("create.form.message.example.group", null);
    } else {
        businessGroupName = uifactory.addTextElement("create.form.title.bgname", "create.form.title.bgname", BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout);
        businessGroupName.setNotLongerThanCheck(BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong");
        businessGroupName.setRegexMatchCheck(BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName");
    }
    businessGroupName.setElementCssClass("o_sel_group_edit_title");
    businessGroupName.setMandatory(true);
    businessGroupName.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title));
    formLayout.setElementCssClass("o_sel_group_edit_group_form");
    // Create the business group description input rich text element
    businessGroupDescription = uifactory.addRichTextElementForStringDataMinimalistic("create.form.title.description", "create.form.title.description", "", 10, -1, formLayout, getWindowControl());
    businessGroupDescription.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description));
    if (businessGroup != null && !bulkMode) {
        // link to group direct jump in business path
        BusinessControlFactory bcf = BusinessControlFactory.getInstance();
        List<ContextEntry> entries = bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]");
        String url = bcf.getAsURIString(entries, true);
        url = "<span class='o_copy_code o_nowrap'><input type='text' value='" + url + "' onclick='this.select()'/></span>";
        StaticTextElement urlEl = uifactory.addStaticTextElement("create.form.businesspath", url, formLayout);
        urlEl.setElementCssClass("o_sel_group_url");
        // link to group visiting card
        bcf = BusinessControlFactory.getInstance();
        entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]");
        url = "<span class='o_copy_code o_nowrap'><input type='text' value='" + bcf.getAsURIString(entries, true) + "' onclick='this.select()'/></span>";
        StaticTextElement cardEl = uifactory.addStaticTextElement("create.form.groupcard", url, formLayout);
        cardEl.setElementCssClass("o_sel_group_card_url");
    }
    uifactory.addSpacerElement("myspacer", formLayout, true);
    // Minimum members input
    businessGroupMinimumMembers = uifactory.addTextElement("create.form.title.min", "create.form.title.min", 5, "", formLayout);
    businessGroupMinimumMembers.setDisplaySize(6);
    // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setVisible(false);
    businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members");
    // Maximum members input
    businessGroupMaximumMembers = uifactory.addTextElement("create.form.title.max", "create.form.title.max", 5, "", formLayout);
    businessGroupMaximumMembers.setDisplaySize(6);
    businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members");
    // Checkboxes
    enableWaitingList = uifactory.addCheckboxesHorizontal("create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues);
    enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list");
    enableAutoCloseRanks = uifactory.addCheckboxesHorizontal("create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues);
    enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks");
    // Enable only if specification of min and max members is possible
    // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setVisible(false);
    businessGroupMaximumMembers.setVisible(true);
    enableWaitingList.setVisible(true);
    enableAutoCloseRanks.setVisible(true);
    boolean managedSettings = BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings);
    businessGroupMinimumMembers.setEnabled(!managedSettings);
    businessGroupMaximumMembers.setEnabled(!managedSettings);
    enableWaitingList.setEnabled(!managedSettings);
    enableAutoCloseRanks.setEnabled(!managedSettings);
    if ((businessGroup != null) && (!bulkMode)) {
        businessGroupName.setValue(businessGroup.getName());
        businessGroupDescription.setValue(businessGroup.getDescription());
        Integer minimumMembers = businessGroup.getMinParticipants();
        Integer maximumMembers = businessGroup.getMaxParticipants();
        businessGroupMinimumMembers.setValue(minimumMembers == null || minimumMembers.intValue() <= 0 ? "" : minimumMembers.toString());
        businessGroupMaximumMembers.setValue(maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString());
        if (businessGroup.getWaitingListEnabled() != null) {
            enableWaitingList.select("create.form.enableWaitinglist", businessGroup.getWaitingListEnabled());
        }
        if (businessGroup.getAutoCloseRanksEnabled() != null) {
            enableAutoCloseRanks.select("create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled());
        }
    }
    if (!embbeded) {
        // Create submit and cancel buttons
        final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
        formLayout.add(buttonLayout);
        FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout);
        submit.setEnabled(!BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details));
        uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }
    if ((businessGroup != null) && (!bulkMode)) {
        // managed group information
        boolean managed = StringHelper.containsNonWhitespace(businessGroup.getExternalId()) || businessGroup.getManagedFlags().length > 0;
        if (managed) {
            uifactory.addSpacerElement("managedspacer", formLayout, false);
            String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId();
            StaticTextElement externalIdEl = uifactory.addStaticTextElement("create.form.externalid", extId, formLayout);
            externalIdEl.setElementCssClass("o_sel_group_external_id");
            FormLayoutContainer flagsFlc = FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator());
            flagsFlc.setLabel("create.form.managedflags", null);
            formLayout.add(flagsFlc);
            String flags = businessGroup.getManagedFlagsString() == null ? "" : businessGroup.getManagedFlagsString().trim();
            String flagsFormatted = null;
            if (flags.length() > 0) {
                // use translator from REST admin package to import managed flags context help strings
                Translator managedTrans = Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale());
                StringBuffer flagList = new StringBuffer();
                flagList.append("<p class=\"o_important\">");
                flagList.append(translate("create.form.managedflags.intro"));
                flagList.append("</div>");
                flagList.append("<ul>");
                for (String flag : flags.split(",")) {
                    flagList.append("<li>");
                    flagList.append(managedTrans.translate("managed.flags.group." + flag));
                    flagList.append("</li>");
                }
                flagsFormatted = flagList.toString();
            } else {
                flagsFormatted = flags;
            }
            StaticTextElement flagsEl = uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc);
            flagsEl.showLabel(false);
            flagsEl.setElementCssClass("o_sel_group_managed_flags");
        }
    }
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) Translator(org.olat.core.gui.translator.Translator) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 58 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project OpenOLAT by OpenOLAT.

the class GroupInfoMainController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        addToHistory(ureq);
        return;
    }
    ContextEntry entry = entries.get(0);
    String menuItem = entry.getOLATResourceable().getResourceableTypeName();
    Object nodeUserObject = null;
    Controller selectedController = null;
    if ("Infos".equals(menuItem)) {
        selectedController = getInfosController(ureq);
        nodeUserObject = COMMAND_MENU_GROUPINFO;
    } else if ("Contact".equals(menuItem)) {
        selectedController = getContactController(ureq);
        nodeUserObject = COMMAND_MENU_GROUPCONTACT;
    } else if ("Members".equals(menuItem)) {
        selectedController = getMembersController(ureq);
        nodeUserObject = COMMAND_MENU_GROUPMEMBERS;
    }
    if (selectedController != null) {
        TreeNode node = TreeHelper.findNodeByUserObject(nodeUserObject, menuTree.getTreeModel().getRootNode());
        if (node != null) {
            menuTree.setSelectedNode(node);
        }
        addToHistory(ureq, selectedController);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 59 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project OpenOLAT by OpenOLAT.

the class BusinessGroupArchiver method appendIdentity.

private void appendIdentity(StringBuffer buf, Identity owner, Date addedTo, Translator translator) {
    Locale loc = translator.getLocale();
    // add the identities user name
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(owner);
    String uname = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
    buf.append(uname);
    buf.append(DELIMITER);
    // add all user properties
    for (UserPropertyHandler propertyHandler : getUserPropertyHandlers()) {
        String value = propertyHandler.getUserProperty(owner.getUser(), loc);
        if (StringHelper.containsNonWhitespace(value)) {
            buf.append(value);
        }
        buf.append(DELIMITER);
    }
    // add the added-to date
    buf.append(addedTo.toString());
    buf.append(EOL);
}
Also used : Locale(java.util.Locale) ContextEntry(org.olat.core.id.context.ContextEntry) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 60 with ContextEntry

use of org.olat.core.id.context.ContextEntry in project OpenOLAT by OpenOLAT.

the class BGControllerFactory method createRunControllerFor.

// 
// 2) Group run controllers
// 
/**
 * Factory method to create a configured group run controller
 *
 * @param ureq
 * @param wControl
 * @param businessGroup
 * @param isGMAdmin true if user is group management administrator
 * @param initialViewIdentifier
 * @return a run controller for this business group
 */
public BusinessGroupMainRunController createRunControllerFor(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup) {
    // build up the context path
    WindowControl bwControl;
    OLATResourceable businessOres = businessGroup;
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(businessOres);
    // OLAT-5944: check if the current context entry is not already the group entry to avoid duplicate in the business path
    if (ce.equals(wControl.getBusinessControl().getCurrentContextEntry())) {
        bwControl = wControl;
    } else {
        bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
    }
    return new BusinessGroupMainRunController(ureq, bwControl, businessGroup);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) BusinessGroupMainRunController(org.olat.group.ui.run.BusinessGroupMainRunController)

Aggregations

ContextEntry (org.olat.core.id.context.ContextEntry)270 OLATResourceable (org.olat.core.id.OLATResourceable)78 WindowControl (org.olat.core.gui.control.WindowControl)58 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)44 ArrayList (java.util.ArrayList)42 TreeNode (org.olat.core.gui.components.tree.TreeNode)30 Controller (org.olat.core.gui.control.Controller)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 List (java.util.List)22 Identity (org.olat.core.id.Identity)22 BusinessControl (org.olat.core.id.context.BusinessControl)22 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)20 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)18 HistoryPoint (org.olat.core.id.context.HistoryPoint)18 CollaborationTools (org.olat.collaboration.CollaborationTools)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)14 UserSession (org.olat.core.util.UserSession)14 CourseNode (org.olat.course.nodes.CourseNode)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)12 Translator (org.olat.core.gui.translator.Translator)12