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));
}
}
}
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);
}
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations