use of com.haulmont.cuba.core.entity.Folder in project cuba by cuba-platform.
the class AppFolderEditWindow method commit.
@Override
protected void commit() {
AppFolder folder = (AppFolder) AppFolderEditWindow.this.folder;
if (StringUtils.trimToNull(nameField.getValue()) == null) {
String msg = messages.getMessage(messagesPack, "folders.folderEditWindow.emptyName");
App.getInstance().getWindowManager().showNotification(msg, Frame.NotificationType.TRAY);
return;
}
folder.setName(nameField.getValue());
folder.setTabName(tabNameField.getValue());
if (sortOrderField.getValue() == null || "".equals(sortOrderField.getValue())) {
folder.setSortOrder(null);
} else {
Object value = sortOrderField.getValue();
int sortOrder;
try {
sortOrder = Integer.parseInt((String) value);
} catch (NumberFormatException e) {
String msg = messages.getMessage(messagesPack, "folders.folderEditWindow.invalidSortOrder");
App.getInstance().getWindowManager().showNotification(msg, Frame.NotificationType.TRAY);
return;
}
folder.setSortOrder(sortOrder);
}
Object parent = parentSelect.getValue();
if (parent instanceof Folder) {
folder.setParent((Folder) parent);
} else {
folder.setParent(null);
}
if (visibilityScriptField != null) {
String scriptText = visibilityScriptField.getValue();
folder.setVisibilityScript(scriptText);
}
if (quantityScriptField != null) {
String scriptText = quantityScriptField.getValue();
folder.setQuantityScript(scriptText);
}
folder.setApplyDefault(Boolean.valueOf(applyDefaultCb.getValue().toString()));
AppFolderEditWindow.this.commitHandler.run();
close();
}
use of com.haulmont.cuba.core.entity.Folder in project cuba by cuba-platform.
the class CubaFoldersPane method fillTree.
protected void fillTree(Tree tree, List<? extends Folder> folders, Object rootItemId) {
if (rootItemId != null) {
tree.addItem(rootItemId);
}
for (Folder folder : folders) {
tree.addItem(folder);
setFolderTreeItemCaption(tree, folder);
if (webConfig.getShowFolderIcons()) {
if (folder instanceof SearchFolder) {
if (BooleanUtils.isTrue(((SearchFolder) folder).getIsSet())) {
tree.setItemIcon(folder, WebComponentsHelper.getIcon("icons/set-small.png"));
} else {
tree.setItemIcon(folder, WebComponentsHelper.getIcon("icons/search-folder-small.png"));
}
} else if (folder instanceof AppFolder) {
tree.setItemIcon(folder, WebComponentsHelper.getIcon("icons/app-folder-small.png"));
}
}
}
for (Folder folder : folders) {
if (folder.getParent() == null) {
tree.setParent(folder, rootItemId);
} else {
if (tree.getItem(folder.getParent()) != null)
tree.setParent(folder, folder.getParent());
else
tree.setParent(folder, rootItemId);
}
}
for (Folder folder : folders) {
if (!tree.hasChildren(folder)) {
tree.setChildrenAllowed(folder, false);
}
}
}
Aggregations