use of org.olat.core.commons.controllers.filechooser.FileChoosenEvent in project OpenOLAT by OpenOLAT.
the class GuiDemoFileChooserController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == chooserCtr) {
// catch the events from the file chooser controller here
if (event instanceof FileChoosenEvent) {
// User pressed select button, get selected item from controller
VFSItem selectedItem = FileChooserUIFactory.getSelectedItem((FileChoosenEvent) event);
// for this demo just get file path and display an info message
LocalImpl localFile = (LocalImpl) selectedItem;
String absPath = localFile.getBasefile().getAbsolutePath();
String relPath = absPath.substring(webappRootFile.getAbsolutePath().length());
getWindowControl().setInfo("user selected /static" + relPath);
} else if (event == Event.CANCELLED_EVENT) {
// user pressed cancel
getWindowControl().setInfo("user cancelled");
} else if (event == Event.FAILED_EVENT) {
// selection failed for unknown reason
getWindowControl().setError("Ups, an error occured");
}
}
}
use of org.olat.core.commons.controllers.filechooser.FileChoosenEvent in project openolat by klemens.
the class GuiDemoFileChooserController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == chooserCtr) {
// catch the events from the file chooser controller here
if (event instanceof FileChoosenEvent) {
// User pressed select button, get selected item from controller
VFSItem selectedItem = FileChooserUIFactory.getSelectedItem((FileChoosenEvent) event);
// for this demo just get file path and display an info message
LocalImpl localFile = (LocalImpl) selectedItem;
String absPath = localFile.getBasefile().getAbsolutePath();
String relPath = absPath.substring(webappRootFile.getAbsolutePath().length());
getWindowControl().setInfo("user selected /static" + relPath);
} else if (event == Event.CANCELLED_EVENT) {
// user pressed cancel
getWindowControl().setInfo("user cancelled");
} else if (event == Event.FAILED_EVENT) {
// selection failed for unknown reason
getWindowControl().setError("Ups, an error occured");
}
}
}
use of org.olat.core.commons.controllers.filechooser.FileChoosenEvent in project OpenOLAT by OpenOLAT.
the class FileLinkChooserController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == uploadCtr) {
if (event instanceof FolderEvent) {
FolderEvent folderEvent = (FolderEvent) event;
if (isFileSuffixOk(folderEvent.getFilename())) {
Size size = null;
VFSItem item = folderEvent.getItem();
String relPath;
if (item != null) {
size = getSize(item, item.getName());
relPath = FileChooserUIFactory.getSelectedRelativeItemPath(folderEvent, rootDir, fileName);
} else {
relPath = folderEvent.getFilename();
}
if (StringHelper.containsNonWhitespace(absolutePath)) {
relPath = absolutePath + relPath;
}
if (size != null) {
fireEvent(ureq, new URLChoosenEvent(relPath, null, null, null, size.getWidth(), size.getHeight()));
} else {
fireEvent(ureq, new URLChoosenEvent(relPath));
}
} else {
setErrorMessage(folderEvent.getFilename());
}
}
if (event == Event.DONE_EVENT) {
if (uploadCtr.getStatus() == FolderCommandStatus.STATUS_CANCELED) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
} else if (event == Event.CANCELLED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
} else if (event == Event.FAILED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
} else if (source == fileChooserController) {
if (event instanceof FileChoosenEvent) {
FileChoosenEvent fileEvent = (FileChoosenEvent) event;
VFSItem item = fileEvent.getSelectedItem();
Size size = getSize(item, item.getName());
String relPath = FileChooserUIFactory.getSelectedRelativeItemPath(fileEvent, rootDir, fileName);
// notify parent controller
if (StringHelper.containsNonWhitespace(absolutePath)) {
relPath = absolutePath + relPath;
}
if (size != null) {
fireEvent(ureq, new URLChoosenEvent(relPath, null, null, null, size.getWidth(), size.getHeight()));
} else {
fireEvent(ureq, new URLChoosenEvent(relPath));
}
} else if (event == Event.CANCELLED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
} else if (event == Event.FAILED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
}
use of org.olat.core.commons.controllers.filechooser.FileChoosenEvent in project openolat by klemens.
the class FileLinkChooserController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == uploadCtr) {
if (event instanceof FolderEvent) {
FolderEvent folderEvent = (FolderEvent) event;
if (isFileSuffixOk(folderEvent.getFilename())) {
Size size = null;
VFSItem item = folderEvent.getItem();
String relPath;
if (item != null) {
size = getSize(item, item.getName());
relPath = FileChooserUIFactory.getSelectedRelativeItemPath(folderEvent, rootDir, fileName);
} else {
relPath = folderEvent.getFilename();
}
if (StringHelper.containsNonWhitespace(absolutePath)) {
relPath = absolutePath + relPath;
}
if (size != null) {
fireEvent(ureq, new URLChoosenEvent(relPath, null, null, null, size.getWidth(), size.getHeight()));
} else {
fireEvent(ureq, new URLChoosenEvent(relPath));
}
} else {
setErrorMessage(folderEvent.getFilename());
}
}
if (event == Event.DONE_EVENT) {
if (uploadCtr.getStatus() == FolderCommandStatus.STATUS_CANCELED) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
} else if (event == Event.CANCELLED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
} else if (event == Event.FAILED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
} else if (source == fileChooserController) {
if (event instanceof FileChoosenEvent) {
FileChoosenEvent fileEvent = (FileChoosenEvent) event;
VFSItem item = fileEvent.getSelectedItem();
Size size = getSize(item, item.getName());
String relPath = FileChooserUIFactory.getSelectedRelativeItemPath(fileEvent, rootDir, fileName);
// notify parent controller
if (StringHelper.containsNonWhitespace(absolutePath)) {
relPath = absolutePath + relPath;
}
if (size != null) {
fireEvent(ureq, new URLChoosenEvent(relPath, null, null, null, size.getWidth(), size.getHeight()));
} else {
fireEvent(ureq, new URLChoosenEvent(relPath));
}
} else if (event == Event.CANCELLED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
} else if (event == Event.FAILED_EVENT) {
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
}
Aggregations