Search in sources :

Example 1 with PageImageAlign

use of org.olat.modules.portfolio.PageImageAlign in project OpenOLAT by OpenOLAT.

the class PageMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (page == null) {
        String title = titleEl.getValue();
        String summary = summaryEl.getValue();
        SectionRef selectSection = getSelectedSection();
        String imagePath = null;
        if (imageUpload.getUploadFile() != null) {
            imagePath = portfolioService.addPosterImageForPage(imageUpload.getUploadFile(), imageUpload.getUploadFileName());
        }
        PageImageAlign align = null;
        if (imageAlignEl.isOneSelected()) {
            align = PageImageAlign.valueOf(imageAlignEl.getSelectedKey());
        }
        page = portfolioService.appendNewPage(getIdentity(), title, summary, imagePath, align, selectSection);
    } else {
        page.setTitle(titleEl.getValue());
        page.setSummary(summaryEl.getValue());
        if (imageUpload.getUploadFile() != null) {
            String imagePath = portfolioService.addPosterImageForPage(imageUpload.getUploadFile(), imageUpload.getUploadFileName());
            page.setImagePath(imagePath);
        } else if (imageUpload.getInitialFile() == null) {
            page.setImagePath(null);
            portfolioService.removePosterImage(page);
        }
        SectionRef selectSection = getSelectedSection();
        SectionRef newParent = null;
        if ((page.getSection() == null && selectSection != null) || (page.getSection() != null && selectSection != null && !page.getSection().getKey().equals(selectSection.getKey()))) {
            newParent = selectSection;
        }
        if (imageAlignEl.isOneSelected()) {
            page.setImageAlignment(PageImageAlign.valueOf(imageAlignEl.getSelectedKey()));
        }
        page = portfolioService.updatePage(page, newParent);
    }
    List<String> updatedCategories = categoriesEl.getValueList();
    portfolioService.updateCategories(page, updatedCategories);
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : PageImageAlign(org.olat.modules.portfolio.PageImageAlign) SectionRef(org.olat.modules.portfolio.SectionRef)

Example 2 with PageImageAlign

use of org.olat.modules.portfolio.PageImageAlign in project openolat by klemens.

the class PageMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (page == null) {
        String title = titleEl.getValue();
        String summary = summaryEl.getValue();
        SectionRef selectSection = getSelectedSection();
        String imagePath = null;
        if (imageUpload.getUploadFile() != null) {
            imagePath = portfolioService.addPosterImageForPage(imageUpload.getUploadFile(), imageUpload.getUploadFileName());
        }
        PageImageAlign align = null;
        if (imageAlignEl.isOneSelected()) {
            align = PageImageAlign.valueOf(imageAlignEl.getSelectedKey());
        }
        page = portfolioService.appendNewPage(getIdentity(), title, summary, imagePath, align, selectSection);
    } else {
        page.setTitle(titleEl.getValue());
        page.setSummary(summaryEl.getValue());
        if (imageUpload.getUploadFile() != null) {
            String imagePath = portfolioService.addPosterImageForPage(imageUpload.getUploadFile(), imageUpload.getUploadFileName());
            page.setImagePath(imagePath);
        } else if (imageUpload.getInitialFile() == null) {
            page.setImagePath(null);
            portfolioService.removePosterImage(page);
        }
        SectionRef selectSection = getSelectedSection();
        SectionRef newParent = null;
        if ((page.getSection() == null && selectSection != null) || (page.getSection() != null && selectSection != null && !page.getSection().getKey().equals(selectSection.getKey()))) {
            newParent = selectSection;
        }
        if (imageAlignEl.isOneSelected()) {
            page.setImageAlignment(PageImageAlign.valueOf(imageAlignEl.getSelectedKey()));
        }
        page = portfolioService.updatePage(page, newParent);
    }
    List<String> updatedCategories = categoriesEl.getValueList();
    portfolioService.updateCategories(page, updatedCategories);
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : PageImageAlign(org.olat.modules.portfolio.PageImageAlign) SectionRef(org.olat.modules.portfolio.SectionRef)

Example 3 with PageImageAlign

use of org.olat.modules.portfolio.PageImageAlign in project OpenOLAT by OpenOLAT.

the class PageMetadataEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_edit_entry_form");
    String title = page == null ? null : page.getTitle();
    titleEl = uifactory.addTextElement("title", "page.title", 255, title, formLayout);
    titleEl.setElementCssClass("o_sel_pf_edit_entry_title");
    titleEl.setEnabled(editTitleAndSummary);
    titleEl.setMandatory(true);
    String summary = page == null ? null : page.getSummary();
    summaryEl = uifactory.addRichTextElementForStringDataMinimalistic("summary", "page.summary", summary, 8, 60, formLayout, getWindowControl());
    summaryEl.setPlaceholderKey("summary.placeholder", null);
    summaryEl.setEnabled(editTitleAndSummary);
    summaryEl.getEditorConfiguration().setPathInStatusBar(false);
    imageUpload = uifactory.addFileElement(getWindowControl(), "file", "fileupload", formLayout);
    imageUpload.setPreview(ureq.getUserSession(), true);
    imageUpload.addActionListener(FormEvent.ONCHANGE);
    imageUpload.setDeleteEnabled(true);
    imageUpload.limitToMimeType(imageMimeTypes, null, null);
    imageUpload.setMaxUploadSizeKB(picUploadlimitKB, null, null);
    if (page != null) {
        File posterImg = portfolioService.getPosterImage(page);
        if (posterImg != null) {
            imageUpload.setInitialFile(posterImg);
        }
    }
    String[] alignValues = new String[] { translate("image.align.background"), translate("image.align.right"), translate("image.align.right.large"), translate("image.align.left"), translate("image.align.left.large") };
    imageAlignEl = uifactory.addDropdownSingleselect("image.align", null, formLayout, alignKeys, alignValues, null);
    PageImageAlign alignment = page == null ? null : page.getImageAlignment();
    if (alignment == null) {
        imageAlignEl.select(alignKeys[0], true);
    } else {
        for (int i = alignKeys.length; i-- > 0; ) {
            if (alignKeys[i].equals(alignment.name())) {
                imageAlignEl.select(alignKeys[i], true);
            }
        }
    }
    categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categories, formLayout, getTranslator());
    categoriesEl.setHelpText(translate("categories.hint"));
    categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
    categoriesEl.setAllowDuplicates(false);
    bindersEl = uifactory.addDropdownSingleselect("binders", "page.binders", formLayout, new String[] { "" }, new String[] { "" }, null);
    sectionsEl = uifactory.addDropdownSingleselect("sections", "page.sections", formLayout, new String[] { "" }, new String[] { "" }, null);
    sectionsEl.setElementCssClass("o_sel_pf_edit_entry_section");
    sectionsEl.setVisible(false);
    initBinderSelection();
    updateSections();
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsCont.setRootForm(mainForm);
    formLayout.add(buttonsCont);
    if (page != null && page.getKey() != null) {
        uifactory.addFormSubmitButton("save", buttonsCont);
    } else {
        uifactory.addFormSubmitButton("create.page", buttonsCont);
    }
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : PageImageAlign(org.olat.modules.portfolio.PageImageAlign) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) File(java.io.File)

Example 4 with PageImageAlign

use of org.olat.modules.portfolio.PageImageAlign in project openolat by klemens.

the class PageMetadataEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_edit_entry_form");
    String title = page == null ? null : page.getTitle();
    titleEl = uifactory.addTextElement("title", "page.title", 255, title, formLayout);
    titleEl.setElementCssClass("o_sel_pf_edit_entry_title");
    titleEl.setEnabled(editTitleAndSummary);
    titleEl.setMandatory(true);
    String summary = page == null ? null : page.getSummary();
    summaryEl = uifactory.addRichTextElementForStringDataMinimalistic("summary", "page.summary", summary, 8, 60, formLayout, getWindowControl());
    summaryEl.setPlaceholderKey("summary.placeholder", null);
    summaryEl.setEnabled(editTitleAndSummary);
    summaryEl.getEditorConfiguration().setPathInStatusBar(false);
    imageUpload = uifactory.addFileElement(getWindowControl(), "file", "fileupload", formLayout);
    imageUpload.setPreview(ureq.getUserSession(), true);
    imageUpload.addActionListener(FormEvent.ONCHANGE);
    imageUpload.setDeleteEnabled(true);
    imageUpload.limitToMimeType(imageMimeTypes, null, null);
    imageUpload.setMaxUploadSizeKB(picUploadlimitKB, null, null);
    if (page != null) {
        File posterImg = portfolioService.getPosterImage(page);
        if (posterImg != null) {
            imageUpload.setInitialFile(posterImg);
        }
    }
    String[] alignValues = new String[] { translate("image.align.background"), translate("image.align.right"), translate("image.align.right.large"), translate("image.align.left"), translate("image.align.left.large") };
    imageAlignEl = uifactory.addDropdownSingleselect("image.align", null, formLayout, alignKeys, alignValues, null);
    PageImageAlign alignment = page == null ? null : page.getImageAlignment();
    if (alignment == null) {
        imageAlignEl.select(alignKeys[0], true);
    } else {
        for (int i = alignKeys.length; i-- > 0; ) {
            if (alignKeys[i].equals(alignment.name())) {
                imageAlignEl.select(alignKeys[i], true);
            }
        }
    }
    categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categories, formLayout, getTranslator());
    categoriesEl.setHelpText(translate("categories.hint"));
    categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
    categoriesEl.setAllowDuplicates(false);
    bindersEl = uifactory.addDropdownSingleselect("binders", "page.binders", formLayout, new String[] { "" }, new String[] { "" }, null);
    sectionsEl = uifactory.addDropdownSingleselect("sections", "page.sections", formLayout, new String[] { "" }, new String[] { "" }, null);
    sectionsEl.setElementCssClass("o_sel_pf_edit_entry_section");
    sectionsEl.setVisible(false);
    initBinderSelection();
    updateSections();
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsCont.setRootForm(mainForm);
    formLayout.add(buttonsCont);
    if (page != null && page.getKey() != null) {
        uifactory.addFormSubmitButton("save", buttonsCont);
    } else {
        uifactory.addFormSubmitButton("create.page", buttonsCont);
    }
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : PageImageAlign(org.olat.modules.portfolio.PageImageAlign) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) File(java.io.File)

Aggregations

PageImageAlign (org.olat.modules.portfolio.PageImageAlign)4 File (java.io.File)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 SectionRef (org.olat.modules.portfolio.SectionRef)2