Search in sources :

Example 1 with MetaInfoFormController

use of org.olat.core.commons.modules.bc.meta.MetaInfoFormController in project OpenOLAT by OpenOLAT.

the class CmdEditMeta method execute.

/**
 * Checks if the file/folder name is not null and valid,
 * checks if the FolderComponent is ok,
 * checks if the item exists and is not locked.
 *
 * @see org.olat.core.commons.modules.bc.commands.FolderCommand#execute(org.olat.core.commons.modules.bc.components.FolderComponent, org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl, org.olat.core.gui.translator.Translator)
 */
@Override
public Controller execute(FolderComponent fComponent, UserRequest ureq, WindowControl wControl, Translator trans) {
    this.translator = trans;
    this.folderComponent = fComponent;
    String pos = ureq.getParameter(ListRenderer.PARAM_EDTID);
    if (!StringHelper.containsNonWhitespace(pos)) {
        // somehow parameter did not make it to us
        status = FolderCommandStatus.STATUS_FAILED;
        getWindowControl().setError(translator.translate("failed"));
        return null;
    }
    status = FolderCommandHelper.sanityCheck(wControl, fComponent);
    if (status == FolderCommandStatus.STATUS_SUCCESS) {
        currentItem = fComponent.getCurrentContainerChildren().get(Integer.parseInt(pos));
    }
    if (status == FolderCommandStatus.STATUS_FAILED) {
        return null;
    }
    removeAsListenerAndDispose(metaCtr);
    removeAsListenerAndDispose(metaInfoCtr);
    if (vfsLockManager.isLockedForMe(currentItem, getIdentity(), ureq.getUserSession().getRoles())) {
        // readonly
        String resourceUrl = getResourceURL(wControl);
        metaCtr = new MetaInfoController(ureq, wControl, currentItem, resourceUrl);
        listenTo(metaCtr);
        putInitialPanel(metaCtr.getInitialComponent());
    } else {
        String resourceUrl = getResourceURL(wControl);
        metaInfoCtr = new MetaInfoFormController(ureq, wControl, currentItem, resourceUrl);
        listenTo(metaInfoCtr);
        putInitialPanel(metaInfoCtr.getInitialComponent());
    }
    return this;
}
Also used : MetaInfoController(org.olat.core.commons.modules.bc.meta.MetaInfoController) MetaInfoFormController(org.olat.core.commons.modules.bc.meta.MetaInfoFormController)

Example 2 with MetaInfoFormController

use of org.olat.core.commons.modules.bc.meta.MetaInfoFormController in project openolat by klemens.

the class FileUploadController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Trigger fieldset and title
    if (showTitle) {
        setFormTitle("ul.header");
    }
    flc.contextPut("showMetadata", showMetadata);
    // Add file element
    FormItemContainer fileUpload;
    // shown, align the file upload element
    if (showMetadata) {
        fileUpload = FormLayoutContainer.createDefaultFormLayout("file_upload", getTranslator());
    } else {
        fileUpload = FormLayoutContainer.createVerticalFormLayout("file_upload", getTranslator());
    }
    formLayout.add(fileUpload);
    flc.contextPut("resizeImg", resizeImg);
    // Add path element
    if (showTargetPath) {
        String path = "/ " + StringHelper.escapeHtml(uploadVFSContainer.getName());
        VFSContainer container = uploadVFSContainer.getParentContainer();
        while (container != null) {
            path = "/ " + StringHelper.escapeHtml(container.getName()) + " " + path;
            container = container.getParentContainer();
        }
        pathEl = uifactory.addStaticTextElement("ul.target", path, fileUpload);
        if (subfolderPath != null) {
            targetSubPath = uifactory.addInlineTextElement("ul.target.child", subfolderPath, fileUpload, this);
            targetSubPath.setLabel("ul.target.child", null);
        }
    }
    fileEl = uifactory.addFileElement(getWindowControl(), "fileEl", "ul.file", fileUpload);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    setMaxUploadSizeKB((uploadLimitKB < remainingQuotKB ? uploadLimitKB : remainingQuotKB));
    fileEl.setMandatory(true, "NoFileChoosen");
    if (mimeTypes != null && mimeTypes.size() > 0) {
        fileEl.limitToMimeType(mimeTypes, "WrongMimeType", new String[] { mimeTypes.toString() });
    }
    if (resizeImg) {
        FormLayoutContainer resizeCont;
        if (showMetadata) {
            resizeCont = FormLayoutContainer.createDefaultFormLayout("resize_image_wrapper", getTranslator());
        } else {
            resizeCont = FormLayoutContainer.createVerticalFormLayout("resize_image_wrapper", getTranslator());
        }
        formLayout.add(resizeCont);
        String[] values = new String[] { translate("resize_image") };
        resizeEl = uifactory.addCheckboxesHorizontal("resize_image", resizeCont, resizeKeys, values);
        resizeEl.setLabel(null, null);
        resizeEl.select(resizeKeys[0], true);
        resizeEl.setVisible(false);
    }
    // Check remaining quota
    if (remainingQuotKB == 0) {
        fileEl.setEnabled(false);
        getWindowControl().setError(translate("QuotaExceeded"));
    }
    if (showMetadata) {
        metaDataCtr = new MetaInfoFormController(ureq, getWindowControl(), mainForm);
        formLayout.add("metadata", metaDataCtr.getFormItem());
        listenTo(metaDataCtr);
    }
    // Add cancel and submit in button group layout
    FormItemContainer buttons;
    if (showMetadata) {
        buttons = FormLayoutContainer.createDefaultFormLayout("buttons", getTranslator());
    } else {
        buttons = FormLayoutContainer.createVerticalFormLayout("buttons", getTranslator());
    }
    formLayout.add(buttons);
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    buttons.add(buttonGroupLayout);
    buttonGroupLayout.setElementCssClass("o_sel_upload_buttons");
    uifactory.addFormSubmitButton("ul.upload", buttonGroupLayout);
    if (showCancel) {
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) MetaInfoFormController(org.olat.core.commons.modules.bc.meta.MetaInfoFormController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Example 3 with MetaInfoFormController

use of org.olat.core.commons.modules.bc.meta.MetaInfoFormController in project OpenOLAT by OpenOLAT.

the class FileUploadController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Trigger fieldset and title
    if (showTitle) {
        setFormTitle("ul.header");
    }
    flc.contextPut("showMetadata", showMetadata);
    // Add file element
    FormItemContainer fileUpload;
    // shown, align the file upload element
    if (showMetadata) {
        fileUpload = FormLayoutContainer.createDefaultFormLayout("file_upload", getTranslator());
    } else {
        fileUpload = FormLayoutContainer.createVerticalFormLayout("file_upload", getTranslator());
    }
    formLayout.add(fileUpload);
    flc.contextPut("resizeImg", resizeImg);
    // Add path element
    if (showTargetPath) {
        String path = "/ " + StringHelper.escapeHtml(uploadVFSContainer.getName());
        VFSContainer container = uploadVFSContainer.getParentContainer();
        while (container != null) {
            path = "/ " + StringHelper.escapeHtml(container.getName()) + " " + path;
            container = container.getParentContainer();
        }
        pathEl = uifactory.addStaticTextElement("ul.target", path, fileUpload);
        if (subfolderPath != null) {
            targetSubPath = uifactory.addInlineTextElement("ul.target.child", subfolderPath, fileUpload, this);
            targetSubPath.setLabel("ul.target.child", null);
        }
    }
    fileEl = uifactory.addFileElement(getWindowControl(), "fileEl", "ul.file", fileUpload);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    setMaxUploadSizeKB((uploadLimitKB < remainingQuotKB ? uploadLimitKB : remainingQuotKB));
    fileEl.setMandatory(true, "NoFileChoosen");
    if (mimeTypes != null && mimeTypes.size() > 0) {
        fileEl.limitToMimeType(mimeTypes, "WrongMimeType", new String[] { mimeTypes.toString() });
    }
    if (resizeImg) {
        FormLayoutContainer resizeCont;
        if (showMetadata) {
            resizeCont = FormLayoutContainer.createDefaultFormLayout("resize_image_wrapper", getTranslator());
        } else {
            resizeCont = FormLayoutContainer.createVerticalFormLayout("resize_image_wrapper", getTranslator());
        }
        formLayout.add(resizeCont);
        String[] values = new String[] { translate("resize_image") };
        resizeEl = uifactory.addCheckboxesHorizontal("resize_image", resizeCont, resizeKeys, values);
        resizeEl.setLabel(null, null);
        resizeEl.select(resizeKeys[0], true);
        resizeEl.setVisible(false);
    }
    // Check remaining quota
    if (remainingQuotKB == 0) {
        fileEl.setEnabled(false);
        getWindowControl().setError(translate("QuotaExceeded"));
    }
    if (showMetadata) {
        metaDataCtr = new MetaInfoFormController(ureq, getWindowControl(), mainForm);
        formLayout.add("metadata", metaDataCtr.getFormItem());
        listenTo(metaDataCtr);
    }
    // Add cancel and submit in button group layout
    FormItemContainer buttons;
    if (showMetadata) {
        buttons = FormLayoutContainer.createDefaultFormLayout("buttons", getTranslator());
    } else {
        buttons = FormLayoutContainer.createVerticalFormLayout("buttons", getTranslator());
    }
    formLayout.add(buttons);
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    buttons.add(buttonGroupLayout);
    buttonGroupLayout.setElementCssClass("o_sel_upload_buttons");
    uifactory.addFormSubmitButton("ul.upload", buttonGroupLayout);
    if (showCancel) {
        uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) MetaInfoFormController(org.olat.core.commons.modules.bc.meta.MetaInfoFormController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer)

Example 4 with MetaInfoFormController

use of org.olat.core.commons.modules.bc.meta.MetaInfoFormController in project openolat by klemens.

the class CmdEditMeta method execute.

/**
 * Checks if the file/folder name is not null and valid,
 * checks if the FolderComponent is ok,
 * checks if the item exists and is not locked.
 *
 * @see org.olat.core.commons.modules.bc.commands.FolderCommand#execute(org.olat.core.commons.modules.bc.components.FolderComponent, org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl, org.olat.core.gui.translator.Translator)
 */
@Override
public Controller execute(FolderComponent fComponent, UserRequest ureq, WindowControl wControl, Translator trans) {
    this.translator = trans;
    this.folderComponent = fComponent;
    String pos = ureq.getParameter(ListRenderer.PARAM_EDTID);
    if (!StringHelper.containsNonWhitespace(pos)) {
        // somehow parameter did not make it to us
        status = FolderCommandStatus.STATUS_FAILED;
        getWindowControl().setError(translator.translate("failed"));
        return null;
    }
    status = FolderCommandHelper.sanityCheck(wControl, fComponent);
    if (status == FolderCommandStatus.STATUS_SUCCESS) {
        currentItem = fComponent.getCurrentContainerChildren().get(Integer.parseInt(pos));
    }
    if (status == FolderCommandStatus.STATUS_FAILED) {
        return null;
    }
    removeAsListenerAndDispose(metaCtr);
    removeAsListenerAndDispose(metaInfoCtr);
    if (vfsLockManager.isLockedForMe(currentItem, getIdentity(), ureq.getUserSession().getRoles())) {
        // readonly
        String resourceUrl = getResourceURL(wControl);
        metaCtr = new MetaInfoController(ureq, wControl, currentItem, resourceUrl);
        listenTo(metaCtr);
        putInitialPanel(metaCtr.getInitialComponent());
    } else {
        String resourceUrl = getResourceURL(wControl);
        metaInfoCtr = new MetaInfoFormController(ureq, wControl, currentItem, resourceUrl);
        listenTo(metaInfoCtr);
        putInitialPanel(metaInfoCtr.getInitialComponent());
    }
    return this;
}
Also used : MetaInfoController(org.olat.core.commons.modules.bc.meta.MetaInfoController) MetaInfoFormController(org.olat.core.commons.modules.bc.meta.MetaInfoFormController)

Aggregations

MetaInfoFormController (org.olat.core.commons.modules.bc.meta.MetaInfoFormController)4 MetaInfoController (org.olat.core.commons.modules.bc.meta.MetaInfoController)2 FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2