Search in sources :

Example 6 with FolderEvent

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

the class VideoPosterSelectionForm method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link button = (Link) source;
        VFSItem posterFile = tmpContainer.resolve((String) button.getUserObject());
        if (posterFile instanceof VFSLeaf) {
            fireEvent(ureq, new FolderEvent(FolderEvent.UPLOAD_EVENT, posterFile));
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSItem(org.olat.core.util.vfs.VFSItem) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) Link(org.olat.core.gui.components.link.Link)

Example 7 with FolderEvent

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

the class CmdDelete method event.

public void event(UserRequest ureq, Controller source, Event event) {
    if (source == dialogCtr) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            // do delete
            VFSContainer currentContainer = folderComponent.getCurrentContainer();
            List<String> files = fileSelection.getFiles();
            if (files.size() == 0) {
                // sometimes, browser sends empty form data...
                getWindowControl().setError(translator.translate("failed"));
                status = FolderCommandStatus.STATUS_FAILED;
                fireEvent(ureq, FOLDERCOMMAND_FINISHED);
            }
            for (String file : files) {
                VFSItem item = currentContainer.resolve(file);
                if (item != null && (item.canDelete() == VFSConstants.YES)) {
                    if (item instanceof MetaTagged) {
                        // delete all meta info
                        MetaInfo meta = ((MetaTagged) item).getMetaInfo();
                        if (meta != null) {
                            meta.deleteAll();
                        }
                    }
                    // delete the item itself
                    item.delete();
                } else {
                    getWindowControl().setWarning(translator.translate("del.partial"));
                }
            }
            String confirmationText = fileSelection.renderAsHtml();
            fireEvent(ureq, new FolderEvent(FolderEvent.DELETE_EVENT, confirmationText));
            fireEvent(ureq, FOLDERCOMMAND_FINISHED);
        } else {
            // abort
            status = FolderCommandStatus.STATUS_CANCELED;
            fireEvent(ureq, FOLDERCOMMAND_FINISHED);
        }
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent)

Example 8 with FolderEvent

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

the class CmdZip method formOK.

/**
 * Creates a zipFile by using ZipUtil and fires Event.DONE_EVENT if successful.
 *
 * @see org.olat.core.commons.modules.bc.commands.AbstractCreateItemForm#formOK(org.olat.core.gui.UserRequest)
 */
@Override
protected void formOK(UserRequest ureq) {
    String name = textElement.getValue();
    if (!name.toLowerCase().endsWith(".zip")) {
        name += ".zip";
    }
    VFSItem zipFile = currentContainer.createChildLeaf(name);
    if (zipFile == null) {
        fireEvent(ureq, Event.FAILED_EVENT);
        return;
    }
    List<VFSItem> vfsFiles = new ArrayList<VFSItem>();
    for (String fileName : selection.getFiles()) {
        VFSItem item = currentContainer.resolve(fileName);
        if (item != null) {
            vfsFiles.add(item);
        }
    }
    if (!ZipUtil.zip(vfsFiles, (VFSLeaf) zipFile, true)) {
        // cleanup zip file
        zipFile.delete();
        status = FolderCommandStatus.STATUS_FAILED;
        fireEvent(ureq, FOLDERCOMMAND_FINISHED);
    } else {
        if (zipFile instanceof MetaTagged) {
            MetaInfo info = ((MetaTagged) zipFile).getMetaInfo();
            if (info != null) {
                info.setAuthor(ureq.getIdentity());
                info.write();
            }
        }
        fireEvent(ureq, new FolderEvent(FolderEvent.ZIP_EVENT, selection.renderAsHtml()));
        fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent)

Example 9 with FolderEvent

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

the class CmdCreateFolder method formOK.

@Override
protected void formOK(UserRequest ureq) {
    // create the folder
    String name = textElement.getValue();
    VFSContainer currentContainer = folderComponent.getCurrentContainer();
    VFSItem item = currentContainer.createChildContainer(name);
    if (item instanceof OlatRelPathImpl) {
        // update meta data
        MetaInfo meta = metaInfoFactory.createMetaInfoFor((OlatRelPathImpl) item);
        meta.setAuthor(ureq.getIdentity());
        meta.write();
        status = FolderCommandStatus.STATUS_FAILED;
        fireEvent(ureq, new FolderEvent(FolderEvent.NEW_FOLDER_EVENT, folderName));
        fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
    } else {
        status = FolderCommandStatus.STATUS_FAILED;
        fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
    }
}
Also used : OlatRelPathImpl(org.olat.core.util.vfs.OlatRelPathImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent)

Example 10 with FolderEvent

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

the class CmdEditMeta method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == metaInfoCtr && event == Event.DONE_EVENT) {
        MetaInfo meta = metaInfoCtr.getMetaInfo();
        String fileName = metaInfoCtr.getFilename();
        if (meta != null) {
            meta.write();
            if (metaInfoCtr.isFileRenamed()) {
                // IMPORTANT: First rename the meta data because underlying file
                // has to exist in order to work properly on it's meta data.
                VFSContainer container = currentItem.getParentContainer();
                if (container.resolve(fileName) != null) {
                    getWindowControl().setError(translator.translate("TargetNameAlreadyUsed"));
                    status = FolderCommandStatus.STATUS_FAILED;
                } else {
                    meta.rename(fileName);
                    if (VFSConstants.NO.equals(currentItem.rename(fileName))) {
                        getWindowControl().setError(translator.translate("FileRenameFailed", new String[] { fileName }));
                        status = FolderCommandStatus.STATUS_FAILED;
                    }
                }
            }
        }
        fireEvent(ureq, new FolderEvent(FolderEvent.EDIT_EVENT, fileName));
        notifyFinished(ureq);
    } else if (event == Event.CANCELLED_EVENT) {
        fireEvent(ureq, FOLDERCOMMAND_FINISHED);
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent)

Aggregations

FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)28 VFSItem (org.olat.core.util.vfs.VFSItem)14 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)6 ArrayList (java.util.ArrayList)4 Link (org.olat.core.gui.components.link.Link)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 OlatRelPathImpl (org.olat.core.util.vfs.OlatRelPathImpl)4 FileChoosenEvent (org.olat.core.commons.controllers.filechooser.FileChoosenEvent)2 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)2 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 Size (org.olat.core.commons.services.image.Size)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2