Search in sources :

Example 6 with Folder

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();
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) AppFolder(com.haulmont.cuba.core.entity.AppFolder) Folder(com.haulmont.cuba.core.entity.Folder)

Example 7 with Folder

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);
        }
    }
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AppFolder(com.haulmont.cuba.core.entity.AppFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) Folder(com.haulmont.cuba.core.entity.Folder)

Aggregations

Folder (com.haulmont.cuba.core.entity.Folder)7 AppFolder (com.haulmont.cuba.core.entity.AppFolder)5 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)5 Transaction (com.haulmont.cuba.core.Transaction)2 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)2 User (com.haulmont.cuba.security.entity.User)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 EntityManager (com.haulmont.cuba.core.EntityManager)1 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)1 UserSession (com.haulmont.cuba.security.global.UserSession)1 TestNotPersistentEntity (com.haulmont.cuba.testmodel.TestNotPersistentEntity)1 Binding (groovy.lang.Binding)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ZipArchiveEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry)1 ZipArchiveInputStream (org.apache.commons.compress.archivers.zip.ZipArchiveInputStream)1 Test (org.junit.Test)1 StopWatch (org.perf4j.StopWatch)1 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)1