use of org.olat.core.util.vfs.filters.VFSItemFilter in project OpenOLAT by OpenOLAT.
the class LinkFileCombiCalloutController method doOpenFileChanger.
public void doOpenFileChanger(UserRequest ureq, String tool) {
// close callout and open appropriate file changer controller
calloutCtr.deactivate();
Controller toolCtr = null;
if (tool.equals("chooseLink")) {
VFSItemFilter filter = new SystemItemFilter();
FileChooserController fileChooserCtr = FileChooserUIFactory.createFileChooserController(ureq, getWindowControl(), baseContainer, filter, true);
fileChooserCtr.setShowTitle(true);
fileChooserCtr.selectPath(relFilePath);
toolCtr = fileChooserCtr;
}
if (tool.equals("createLink")) {
String folderPath = null;
if (StringHelper.containsNonWhitespace(relFilePath)) {
// remove file name from relFilePath to represent directory path
folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
}
toolCtr = new FileCreatorController(ureq, getWindowControl(), baseContainer, folderPath);
}
if (tool.equals("uploadLink")) {
long quotaLeftKB = VFSManager.getQuotaLeftKB(baseContainer);
String folderPath = null;
if (StringHelper.containsNonWhitespace(relFilePath)) {
// remove file name from relFilePath to represent directory path
folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
}
toolCtr = new FileUploadController(getWindowControl(), baseContainer, ureq, quotaLeftKB, quotaLeftKB, null, false, true, false, false, true, true, folderPath);
}
displayModal(toolCtr);
}
use of org.olat.core.util.vfs.filters.VFSItemFilter in project OpenOLAT by OpenOLAT.
the class CPFile method deleteIfEmpty.
/**
* Deletes the container if it is empty (excluding files with '.' prefix).
*
* @param parentContainer
*/
private void deleteIfEmpty(VFSContainer container) {
String[] unwantedPrefixes = { "." };
VFSItemFilter filter = new VFSItemExcludePrefixFilter(unwantedPrefixes);
if (container != null) {
List<VFSItem> items = container.getItems(filter);
if (items == null || items.size() == 0) {
container.delete();
}
}
}
use of org.olat.core.util.vfs.filters.VFSItemFilter in project openolat by klemens.
the class LinkFileCombiCalloutController method doOpenFileChanger.
public void doOpenFileChanger(UserRequest ureq, String tool) {
// close callout and open appropriate file changer controller
calloutCtr.deactivate();
Controller toolCtr = null;
if (tool.equals("chooseLink")) {
VFSItemFilter filter = new SystemItemFilter();
FileChooserController fileChooserCtr = FileChooserUIFactory.createFileChooserController(ureq, getWindowControl(), baseContainer, filter, true);
fileChooserCtr.setShowTitle(true);
fileChooserCtr.selectPath(relFilePath);
toolCtr = fileChooserCtr;
}
if (tool.equals("createLink")) {
String folderPath = null;
if (StringHelper.containsNonWhitespace(relFilePath)) {
// remove file name from relFilePath to represent directory path
folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
}
toolCtr = new FileCreatorController(ureq, getWindowControl(), baseContainer, folderPath);
}
if (tool.equals("uploadLink")) {
long quotaLeftKB = VFSManager.getQuotaLeftKB(baseContainer);
String folderPath = null;
if (StringHelper.containsNonWhitespace(relFilePath)) {
// remove file name from relFilePath to represent directory path
folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
}
toolCtr = new FileUploadController(getWindowControl(), baseContainer, ureq, quotaLeftKB, quotaLeftKB, null, false, true, false, false, true, true, folderPath);
}
displayModal(toolCtr);
}
use of org.olat.core.util.vfs.filters.VFSItemFilter in project openolat by klemens.
the class CPFile method deleteIfEmpty.
/**
* Deletes the container if it is empty (excluding files with '.' prefix).
*
* @param parentContainer
*/
private void deleteIfEmpty(VFSContainer container) {
String[] unwantedPrefixes = { "." };
VFSItemFilter filter = new VFSItemExcludePrefixFilter(unwantedPrefixes);
if (container != null) {
List<VFSItem> items = container.getItems(filter);
if (items == null || items.size() == 0) {
container.delete();
}
}
}
Aggregations