Search in sources :

Example 1 with BusinessControlFactory

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

the class EPCollectStepForm00 method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    title = uifactory.addTextElement("title", "artefact.title", 500, artefact.getTitle(), formLayout);
    title.setElementCssClass("o_sel_ep_artefact_metadata_title");
    title.setMandatory(true);
    title.setNotEmptyCheck("artefact.title.not.empty");
    title.setNotLongerThanCheck(512, "artefact.title.too.long");
    title.setVisible(!simpleMode);
    descript = uifactory.addRichTextElementForStringDataMinimalistic("description", "artefact.description", artefact.getDescription(), 7, -1, formLayout, getWindowControl());
    descript.setMaxLength(4000);
    descript.setNotLongerThanCheck(4000, "artefact.description.too.long");
    String artSource = artefact.getSource();
    if (StringHelper.containsNonWhitespace(artSource) && !simpleMode) {
        uifactory.addStaticTextElement("artefact.source", artSource, formLayout);
    }
    Date artDate = artefact.getCreationDate();
    if (artDate == null)
        artDate = new Date();
    StaticTextElement date = uifactory.addStaticTextElement("artefact.date", Formatter.getInstance(getLocale()).formatDateAndTime(artDate), formLayout);
    date.setVisible(!simpleMode);
    String busPath = artefact.getBusinessPath();
    if (StringHelper.containsNonWhitespace(busPath) && !simpleMode) {
        BusinessControlFactory bCF = BusinessControlFactory.getInstance();
        List<ContextEntry> ceList = bCF.createCEListFromString(busPath);
        String busLink = bCF.getAsURIString(ceList, true);
        if (StringHelper.containsNonWhitespace(busLink)) {
            String finalPath = "<a href=\"" + busLink + "\">" + busLink + "</a>";
            uifactory.addStaticTextElement("artefact.link", finalPath, formLayout);
        }
    }
    if (!isUsedInStepWizzard()) {
        // add form buttons
        uifactory.addFormSubmitButton("stepform.submit", formLayout);
    }
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) Date(java.util.Date) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 2 with BusinessControlFactory

use of org.olat.core.id.context.BusinessControlFactory 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 3 with BusinessControlFactory

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

the class SendInfoMailFormatter method getBody.

@Override
public String getBody(InfoMessage msg) {
    BusinessControlFactory bCF = BusinessControlFactory.getInstance();
    List<ContextEntry> ceList = bCF.createCEListFromString(businessPath);
    String busPath = BusinessControlFactory.getInstance().getBusinessPathAsURIFromCEList(ceList);
    String author = msg.getAuthor().getUser().getProperty(UserConstants.FIRSTNAME, null) + " " + msg.getAuthor().getUser().getProperty(UserConstants.LASTNAME, null);
    String date = DateFormat.getDateInstance(DateFormat.MEDIUM, translator.getLocale()).format(msg.getCreationDate());
    String link = Settings.getServerContextPathURI() + "/url/" + busPath;
    StringBuilder sb = new StringBuilder();
    sb.append("<div style='background: #FAFAFA; border: 1px solid #eee; border-radius: 5px; padding: 0 0.5em 0.5em 0.5em; margin: 1em 0 1em 0;' class='o_m_h'>");
    sb.append("<h3>").append(translator.translate("mail.body.title", new String[] { title })).append("</h3>");
    sb.append("<div style='font-size: 90%; color: #888' class='o_m_a'>").append(translator.translate("mail.body.from", new String[] { author, date })).append("</div>");
    sb.append("</div>");
    sb.append("<div style='background: #FAFAFA; padding: 5px 5px; margin: 10px 0;' class='o_m_c'>");
    sb.append(msg.getMessage());
    sb.append("<div style='margin: 2em 0 1em 0;' class='o_m_m'>").append("<a href='").append(link).append("'>");
    sb.append(translator.translate("mail.body.more"));
    sb.append(" &raquo;</a></div>");
    sb.append("</div>");
    return sb.toString();
}
Also used : BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 4 with BusinessControlFactory

use of org.olat.core.id.context.BusinessControlFactory in project openolat by klemens.

the class FeedViewHelper method getJumpInLink.

/**
 * @param feed
 *            the target feed for the jumpInLink
 * @param item
 *            the target item for the jumpInLink or null if not want to
 *            refer to a specific item
 * @return the jump in link
 */
public String getJumpInLink(Feed feed, Item item) {
    String jumpInLink = null;
    RepositoryManager resMgr = RepositoryManager.getInstance();
    if (courseId != null && nodeId != null) {
        OLATResourceable oresCourse = OLATResourceManager.getInstance().findResourceable(courseId, CourseModule.getCourseTypeName());
        OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("CourseNode", Long.valueOf(nodeId));
        RepositoryEntry repositoryEntry = resMgr.lookupRepositoryEntry(oresCourse, false);
        List<ContextEntry> ces = new ArrayList<>();
        ces.add(BusinessControlFactory.getInstance().createContextEntry(repositoryEntry));
        ces.add(BusinessControlFactory.getInstance().createContextEntry(oresNode));
        jumpInLink = BusinessControlFactory.getInstance().getAsURIString(ces, false);
    } else {
        RepositoryEntry repositoryEntry = resMgr.lookupRepositoryEntry(feed, false);
        if (repositoryEntry != null) {
            ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(repositoryEntry);
            jumpInLink = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
        } else {
            // its a liveblog-helperFeed
            final BusinessControlFactory bCF = BusinessControlFactory.getInstance();
            String feedBP = LiveBlogArtefactHandler.LIVEBLOG + feed.getResourceableId() + "]";
            final List<ContextEntry> ceList = bCF.createCEListFromString(feedBP);
            jumpInLink = bCF.getAsURIString(ceList, true);
        }
    }
    if (item != null && jumpInLink != null) {
        jumpInLink += "/item=" + item.getKey() + "/0";
    }
    return jumpInLink;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) RepositoryManager(org.olat.repository.RepositoryManager) BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) RepositoryEntry(org.olat.repository.RepositoryEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 5 with BusinessControlFactory

use of org.olat.core.id.context.BusinessControlFactory in project openolat by klemens.

the class EPArtefactViewController method createLinkToArtefactSource.

private String createLinkToArtefactSource(UserRequest ureq, String businessPath) {
    BusinessControlFactory bCF = BusinessControlFactory.getInstance();
    List<ContextEntry> ceList = bCF.createCEListFromString(businessPath);
    boolean valid = (ceList.size() > 0) && NewControllerFactory.getInstance().validateCEWithContextControllerCreator(ureq, getWindowControl(), ceList.get(0));
    String busLink = bCF.getAsURIString(ceList, true);
    if (valid && StringHelper.containsNonWhitespace(busLink)) {
        return "<a href=\"" + busLink + "\">" + translate("artefact.open.source") + "</a>";
    } else
        return translate("artefact.no.source");
}
Also used : BusinessControlFactory(org.olat.core.id.context.BusinessControlFactory) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)20 ContextEntry (org.olat.core.id.context.ContextEntry)16 ArrayList (java.util.ArrayList)4 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)4 Translator (org.olat.core.gui.translator.Translator)4 Roles (org.olat.core.id.Roles)4 BusinessControl (org.olat.core.id.context.BusinessControl)4 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)4 Date (java.util.Date)2 Invitation (org.olat.basesecurity.Invitation)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 FormSubmit (org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit)2 Controller (org.olat.core.gui.control.Controller)2 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)2 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 ContactList (org.olat.core.util.mail.ContactList)2 MailBundle (org.olat.core.util.mail.MailBundle)2