Search in sources :

Example 1 with AbstractSearchFolder

use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.

the class CubaFoldersPane method collapseItemInTree.

protected void collapseItemInTree(Tree tree, final String foldersCollapse) {
    String s = userSettingService.loadSetting(foldersCollapse);
    List<UUID> idFolders = strToIds(s);
    // noinspection unchecked, RedundantCast
    for (AbstractSearchFolder folder : (Collection<AbstractSearchFolder>) tree.getItemIds()) {
        if (idFolders.contains(folder.getId())) {
            tree.collapseItem(folder);
        }
    }
    tree.addExpandListener(new Tree.ExpandListener() {

        @Override
        public void nodeExpand(Tree.ExpandEvent event) {
            if (event.getItemId() instanceof AbstractSearchFolder) {
                UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId();
                String str = userSettingService.loadSetting(foldersCollapse);
                userSettingService.saveSetting(foldersCollapse, removeIdInStr(str, uuid));
            }
        }
    });
    tree.addCollapseListener(new Tree.CollapseListener() {

        @Override
        public void nodeCollapse(Tree.CollapseEvent event) {
            if (event.getItemId() instanceof AbstractSearchFolder) {
                UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId();
                String str = userSettingService.loadSetting(foldersCollapse);
                userSettingService.saveSetting(foldersCollapse, addIdInStr(str, uuid));
            }
        }
    });
}
Also used : AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) CubaTree(com.haulmont.cuba.web.toolkit.ui.CubaTree)

Example 2 with AbstractSearchFolder

use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.

the class CubaFoldersPane method createSearchFoldersPane.

protected Component createSearchFoldersPane() {
    searchFoldersTree = new CubaTree();
    searchFoldersTree.setCubaId("searchFoldersTree");
    searchFoldersTree.setSelectable(true);
    searchFoldersTree.setItemStyleGenerator(new FolderTreeStyleProvider());
    searchFoldersTree.addShortcutListener(new ShortcutListener("applySearchFolder", ShortcutAction.KeyCode.ENTER, (int[]) null) {

        @Override
        public void handleAction(Object sender, Object target) {
            if (target == searchFoldersTree) {
                AbstractSearchFolder folder = (AbstractSearchFolder) searchFoldersTree.getValue();
                if (folder != null) {
                    openFolder(folder);
                }
            }
        }
    });
    List<SearchFolder> searchFolders = foldersService.loadSearchFolders();
    searchFoldersRoot = messages.getMainMessage("folders.searchFoldersRoot");
    searchFoldersTree.addItemClickListener(new FolderClickListener());
    searchFoldersTree.addActionHandler(new SearchFolderActionsHandler());
    if (!searchFolders.isEmpty()) {
        fillTree(searchFoldersTree, searchFolders, isNeedRootSearchFolder() ? searchFoldersRoot : null);
    }
    for (Object itemId : searchFoldersTree.rootItemIds()) {
        searchFoldersTree.expandItemsRecursively(itemId);
    }
    return searchFoldersTree;
}
Also used : ShortcutListener(com.vaadin.event.ShortcutListener) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) CubaTree(com.haulmont.cuba.web.toolkit.ui.CubaTree)

Example 3 with AbstractSearchFolder

use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.

the class FilterDelegateImpl method saveAsFolder.

protected void saveAsFolder(boolean isAppFolder) {
    final AbstractSearchFolder folder;
    if (isAppFolder)
        folder = (metadata.create(AppFolder.class));
    else
        folder = (metadata.create(SearchFolder.class));
    if (filterEntity.getCode() == null) {
        String folderName = filterEntity != adHocFilter ? filterEntity.getName() : "";
        folder.setName(folderName);
        folder.setTabName(folderName);
    } else {
        String name = messages.getMainMessage(filterEntity.getCode());
        folder.setName(name);
        folder.setTabName(name);
    }
    String newXml = filterParser.getXml(conditions, Param.ValueProperty.VALUE);
    folder.setFilterComponentId(filterEntity.getComponentId());
    folder.setFilterXml(newXml);
    if (!isAppFolder) {
        if (uerCanEditGlobalFilter())
            ((SearchFolder) folder).setUser(filterEntity.getUser());
        else
            ((SearchFolder) folder).setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
    }
    Presentations presentations;
    if (applyTo != null && applyTo instanceof HasPresentations) {
        final HasPresentations presentationsOwner = (HasPresentations) applyTo;
        presentations = presentationsOwner.isUsePresentations() ? presentationsOwner.getPresentations() : null;
    } else {
        presentations = null;
    }
    Runnable commitHandler;
    if (isAppFolder) {
        commitHandler = () -> {
            AbstractSearchFolder savedFolder = saveFolder(folder);
            filterEntity.setFolder(savedFolder);
        };
    } else {
        commitHandler = () -> {
            AbstractSearchFolder savedFolder = saveFolder(folder);
            filterEntity.setFolder(savedFolder);
        };
    }
    filterHelper.openFolderEditWindow(isAppFolder, folder, presentations, commitHandler);
}
Also used : AppFolder(com.haulmont.cuba.core.entity.AppFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) Presentations(com.haulmont.cuba.gui.presentations.Presentations)

Example 4 with AbstractSearchFolder

use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.

the class WebFoldersPane method setupIconGenerator.

protected void setupIconGenerator() {
    WebConfig webConfig = beanLocator.get(Configuration.class).getConfig(WebConfig.class);
    IconGenerator<AbstractSearchFolder> iconGenerator = !webConfig.getShowFolderIcons() ? NULL_ITEM_ICON_GENERATOR : iconProvider == null ? DEFAULT_ICON_GENERATOR : ICON_GENERATOR;
    component.setIconGenerator(iconGenerator);
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) WebConfig(com.haulmont.cuba.web.WebConfig)

Example 5 with AbstractSearchFolder

use of com.haulmont.cuba.core.entity.AbstractSearchFolder in project cuba by cuba-platform.

the class FoldersLinkHandlerProcessor method handle.

@Override
public void handle(ExternalLinkContext linkContext) {
    String folderId = linkContext.getRequestParams().get("folder");
    AbstractSearchFolder folder = loadFolder(UUID.fromString(folderId));
    if (folder != null) {
        folders.openFolder(folder);
    } else {
        log.warn("Folder not found: {}", folderId);
    }
}
Also used : AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder)

Aggregations

AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)8 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)3 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)2 CubaTree (com.haulmont.cuba.web.toolkit.ui.CubaTree)2 AppFolder (com.haulmont.cuba.core.entity.AppFolder)1 Entity (com.haulmont.cuba.core.entity.Entity)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 Filter (com.haulmont.cuba.gui.components.Filter)1 HasPresentations (com.haulmont.cuba.gui.components.HasPresentations)1 Window (com.haulmont.cuba.gui.components.Window)1 FoldersPane (com.haulmont.cuba.gui.components.mainwindow.FoldersPane)1 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 DsContext (com.haulmont.cuba.gui.data.DsContext)1 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)1 Presentations (com.haulmont.cuba.gui.presentations.Presentations)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1 WebConfig (com.haulmont.cuba.web.WebConfig)1 CubaFoldersPane (com.haulmont.cuba.web.app.folders.CubaFoldersPane)1 ShortcutListener (com.vaadin.event.ShortcutListener)1