Search in sources :

Example 11 with FormLink

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

the class MembersMailController method doUploadAttachement.

private void doUploadAttachement() {
    if (attachementTempDir == null) {
        attachementTempDir = FileUtils.createTempDir("attachements", null, null);
    }
    long size = attachmentEl.getUploadSize();
    String filename = attachmentEl.getUploadFileName();
    if (size + attachmentSize > (contactAttachmentMaxSizeInMb * 1024 * 1024)) {
        showWarning("contact.attachment,maxsize", Integer.toString(contactAttachmentMaxSizeInMb));
        attachmentEl.reset();
    } else {
        File attachment = attachmentEl.moveUploadFileTo(attachementTempDir);
        attachmentEl.reset();
        if (attachment == null) {
            logError("Could not move contact-form attachment to " + attachementTempDir.getAbsolutePath(), null);
            setTranslator(Util.createPackageTranslator(FileUploadController.class, getLocale(), getTranslator()));
            showError("FileMoveCopyFailed", "");
        } else {
            attachmentSize += size;
            FormLink removeFile = uifactory.addFormLink("delete_" + (++counter), "delete", "delete", null, uploadCont, Link.LINK);
            removeFile.setIconLeftCSS("o_icon o_icon-fw o_icon_delete");
            String css = CSSHelper.createFiletypeIconCssClassFor(filename);
            Attachment wrapper = new Attachment(attachment, attachment.getName(), css, removeFile);
            removeFile.setUserObject(wrapper);
            attachments.add(wrapper);
            uploadCont.setVisible(true);
        }
    }
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) File(java.io.File) FileUploadController(org.olat.core.commons.modules.bc.FileUploadController)

Example 12 with FormLink

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

the class MembersTableController method forgeChatLink.

protected void forgeChatLink(MemberView row) {
    FormLink chatLink = uifactory.addFormLink("tools_" + counter.incrementAndGet(), "im", "", null, null, Link.NONTRANSLATED);
    chatLink.setIconLeftCSS("o_icon o_icon_status_unavailable");
    chatLink.setUserObject(row);
    row.setChatLink(chatLink);
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 13 with FormLink

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

the class InfoDisplayController method loadMessages.

/**
 * This is the main method which push the messages in the layout container,
 * and clean-up old links.
 */
protected void loadMessages() {
    // first clear the current message if any
    for (Long key : previousDisplayKeys) {
        flc.contextRemove("info.date." + key);
        if (flc.getComponent("info.delete." + key) != null) {
            flc.remove("info.delete." + key);
        }
        if (flc.getComponent("info.edit." + key) != null) {
            flc.remove("info.edit." + key);
        }
    }
    previousDisplayKeys.clear();
    deleteLinks.clear();
    List<InfoMessage> msgs = infoMessageManager.loadInfoMessageByResource(ores, resSubPath, businessPath, after, null, 0, maxResults);
    List<InfoMessageForDisplay> infoDisplays = new ArrayList<>(msgs.size());
    Map<Long, VFSLeaf> keyToDisplay = new HashMap<>();
    for (InfoMessage info : msgs) {
        previousDisplayKeys.add(info.getKey());
        InfoMessageForDisplay infoDisplay = createInfoMessageForDisplay(info);
        infoDisplays.add(infoDisplay);
        if (infoDisplay.getAttachment() != null) {
            keyToDisplay.put(info.getKey(), infoDisplay.getAttachment());
        }
        String dateCmpName = "info.date." + info.getKey();
        DateElement dateEl = DateComponentFactory.createDateElementWithYear(dateCmpName, info.getCreationDate());
        flc.add(dateCmpName, dateEl);
        if (secCallback.canEdit(info)) {
            String editName = "info.edit." + info.getKey();
            FormLink link = uifactory.addFormLink(editName, "edit", "edit", flc, Link.BUTTON_SMALL);
            link.setElementCssClass("o_sel_info_edit_msg");
            link.setUserObject(info);
            editLinks.add(link);
            flc.add(link);
        }
        if (secCallback.canDelete()) {
            String delName = "info.delete." + info.getKey();
            FormLink link = uifactory.addFormLink(delName, "delete", "delete", flc, Link.BUTTON_SMALL);
            link.setElementCssClass("o_sel_info_delete_msg");
            link.setUserObject(info);
            deleteLinks.add(link);
            flc.add(link);
        }
    }
    flc.contextPut("infos", infoDisplays);
    infoKeyToAttachment = keyToDisplay;
    int numOfInfos = infoMessageManager.countInfoMessageByResource(ores, resSubPath, businessPath, null, null);
    oldMsgsLink.setVisible((msgs.size() < numOfInfos));
    newMsgsLink.setVisible((msgs.size() == numOfInfos) && (numOfInfos > maxResultsConfig) && (maxResultsConfig > 0));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) HashMap(java.util.HashMap) DateElement(org.olat.core.gui.components.date.DateElement) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) InfoMessage(org.olat.commons.info.InfoMessage)

Example 14 with FormLink

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

the class ImpressumAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("menu.impressum");
    setFormDescription("config.hint");
    boolean enabled = impressumModule.isEnabled();
    String[] enableKeys = new String[] { "on" };
    enableEl = uifactory.addCheckboxesHorizontal("enable", "enable.impressum", formLayout, enableKeys, new String[] { translate("enable") });
    enableEl.addActionListener(FormEvent.ONCHANGE);
    enableEl.select(enableKeys[0], enabled);
    String[] positionValues = new String[] { translate("position.top"), translate("position.footer") };
    positionEl = uifactory.addDropdownSingleselect("position", "position", formLayout, positionKeys, positionValues, null);
    positionEl.addActionListener(FormEvent.ONCHANGE);
    if (impressumModule.getPosition() != null) {
        switch(impressumModule.getPosition()) {
            case top:
                positionEl.select(positionKeys[0], true);
                break;
            case footer:
                positionEl.select(positionKeys[1], true);
                break;
            default:
                {
                }
        }
    }
    impressumCont = FormLayoutContainer.createCustomFormLayout("impressums", getTranslator(), velocity_root + "/buttongroups.html");
    impressumCont.setLabel("impressum.file", null);
    impressumCont.setVisible(enabled);
    formLayout.add(impressumCont);
    List<ButtonGroup> impressumButtons = new ArrayList<>();
    impressumCont.contextPut("buttons", impressumButtons);
    for (String lang : i18nModule.getEnabledLanguageKeys()) {
        FormLink editLink = uifactory.addFormLink("impressum." + lang, "impressum", getTranslated(lang), "impressum.file", impressumCont, Link.BUTTON | Link.NONTRANSLATED);
        editLink.setLabel(null, null);
        String filePath = "index_" + lang + ".html";
        boolean hasImpressum = checkContent(impressumDir.resolve(filePath));
        if (hasImpressum) {
            editLink.setIconLeftCSS("o_icon o_icon_check");
        }
        FormLink deleteLink = uifactory.addFormLink("impressum.del." + lang, "delete-impressum", "", "impressum.file", impressumCont, Link.BUTTON | Link.NONTRANSLATED);
        deleteLink.setLabel(null, null);
        deleteLink.setIconLeftCSS("o_icon o_icon_delete_item");
        deleteLink.setVisible(hasImpressum);
        ButtonGroup group = new ButtonGroup(lang, editLink, deleteLink);
        editLink.setUserObject(group);
        deleteLink.setUserObject(group);
        impressumButtons.add(group);
    }
    termsCont = FormLayoutContainer.createCustomFormLayout("terms", getTranslator(), velocity_root + "/buttongroups.html");
    termsCont.setLabel("termofuse.file", null);
    termsCont.setVisible(enabled);
    formLayout.add(termsCont);
    List<ButtonGroup> termsOfUseButtons = new ArrayList<>();
    termsCont.contextPut("buttons", termsOfUseButtons);
    for (String lang : i18nModule.getEnabledLanguageKeys()) {
        FormLink editLink = uifactory.addFormLink("termofuser." + lang, "termsofuse", getTranslated(lang), "termofuse.file", termsCont, Link.BUTTON | Link.NONTRANSLATED);
        editLink.setLabel(null, null);
        String filePath = "index_" + lang + ".html";
        boolean hasTermsOfUse = checkContent(termsOfUseDir.resolve(filePath));
        if (hasTermsOfUse) {
            editLink.setIconLeftCSS("o_icon o_icon_check");
        }
        FormLink deleteLink = uifactory.addFormLink("impressum.del." + lang, "delete-termsofuse", "", "termofuse.file", termsCont, Link.BUTTON | Link.NONTRANSLATED);
        deleteLink.setLabel(null, null);
        deleteLink.setIconLeftCSS("o_icon o_icon_delete_item");
        deleteLink.setVisible(hasTermsOfUse);
        ButtonGroup group = new ButtonGroup(lang, editLink, deleteLink);
        editLink.setUserObject(group);
        deleteLink.setUserObject(group);
        termsOfUseButtons.add(group);
    }
}
Also used : ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 15 with FormLink

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

the class ImpressumAdminController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (enableEl == source) {
        boolean enabled = enableEl.isAtLeastSelected(1);
        impressumModule.setEnabled(enabled);
        positionEl.setEnabled(enabled);
        termsCont.setVisible(enabled);
        impressumCont.setVisible(enabled);
        getWindowControl().getWindowBackOffice().getWindow().setDirty(true);
        getWindowControl().getWindowBackOffice().getChiefController().wishReload(ureq, true);
    } else if (positionEl == source) {
        if (positionEl.isOneSelected()) {
            String key = positionEl.getSelectedKey();
            impressumModule.setPosition(key);
            getWindowControl().getWindowBackOffice().getWindow().setDirty(true);
            getWindowControl().getWindowBackOffice().getChiefController().wishReload(ureq, true);
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        ButtonGroup group = (ButtonGroup) source.getUserObject();
        String lang = group.getLang();
        if ("impressum".equals(cmd)) {
            doEdit(ureq, link, impressumDir, lang);
        } else if ("termsofuse".equals(cmd)) {
            doEdit(ureq, link, termsOfUseDir, lang);
        } else if ("delete-impressum".equals(cmd)) {
            doDelete(impressumDir, lang);
            group.getEditButton().setIconLeftCSS(null);
            group.getDeleteButton().setVisible(false);
        } else if ("delete-termsofuse".equals(cmd)) {
            doDelete(termsOfUseDir, lang);
            group.getEditButton().setIconLeftCSS(null);
            group.getDeleteButton().setVisible(false);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)376 ArrayList (java.util.ArrayList)108 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)64 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)36 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)34 List (java.util.List)30 FormItem (org.olat.core.gui.components.form.flexible.FormItem)28 HashMap (java.util.HashMap)26 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)24 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 Date (java.util.Date)18 Map (java.util.Map)18 Link (org.olat.core.gui.components.link.Link)18 Identity (org.olat.core.id.Identity)18 Component (org.olat.core.gui.components.Component)16 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)16 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)16 Controller (org.olat.core.gui.control.Controller)16 Event (org.olat.core.gui.control.Event)16