Search in sources :

Example 6 with AbstractSearchFolder

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

the class FoldersBean method openFolder.

@Override
public void openFolder(AbstractSearchFolder folder) {
    if (StringUtils.isBlank(folder.getFilterComponentId())) {
        log.warn("Unable to open folder: componentId is blank");
        return;
    }
    String[] strings = ValuePathHelper.parse(folder.getFilterComponentId());
    String screenId = strings[0];
    WindowInfo windowInfo = windowConfig.getWindowInfo(screenId);
    Map<String, Object> params = new HashMap<>();
    WindowParams.DISABLE_AUTO_REFRESH.set(params, true);
    WindowParams.DISABLE_RESUME_SUSPENDED.set(params, true);
    if (!StringUtils.isBlank(folder.getTabName())) {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getTabName()));
    } else {
        WindowParams.DESCRIPTION.set(params, messages.getMainMessage(folder.getName()));
    }
    WindowParams.FOLDER_ID.set(params, folder.getId());
    WindowManager wm = App.getInstance().getWindowManager();
    Window window = wm.openWindow(windowInfo, OpenType.NEW_TAB, params);
    Filter filterComponent = null;
    if (strings.length > 1) {
        String filterComponentId = StringUtils.join(Arrays.copyOfRange(strings, 1, strings.length), '.');
        filterComponent = (Filter) window.getComponentNN(filterComponentId);
        FilterEntity filterEntity = metadata.create(FilterEntity.class);
        filterEntity.setFolder(folder);
        filterEntity.setComponentId(folder.getFilterComponentId());
        filterEntity.setName(folder.getLocName());
        filterEntity.setXml(folder.getFilterXml());
        filterEntity.setApplyDefault(BooleanUtils.isNotFalse(folder.getApplyDefault()));
        if (folder instanceof SearchFolder) {
            filterEntity.setIsSet(((SearchFolder) folder).getIsSet());
        }
        filterComponent.setFilterEntity(filterEntity);
        filterComponent.switchFilterMode(FilterDelegate.FilterMode.GENERIC_MODE);
    }
    if (filterComponent != null && folder instanceof SearchFolder) {
        SearchFolder searchFolder = (SearchFolder) folder;
        if (searchFolder.getPresentation() != null) {
            ((HasPresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentation().getId());
        }
    }
    if (window.getFrameOwner() instanceof LegacyFrame) {
        DsContext dsContext = ((LegacyFrame) window.getFrameOwner()).getDsContext();
        if (dsContext != null) {
            ((DsContextImplementation) dsContext).resumeSuspended();
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) HasPresentations(com.haulmont.cuba.gui.components.HasPresentations) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) DsContext(com.haulmont.cuba.gui.data.DsContext) HashMap(java.util.HashMap) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WindowManager(com.haulmont.cuba.gui.WindowManager) Filter(com.haulmont.cuba.gui.components.Filter)

Example 7 with AbstractSearchFolder

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

the class FilterDelegateImpl method saveFilterEntity.

protected void saveFilterEntity() {
    Boolean isDefault = filterEntity.getIsDefault();
    Boolean applyDefault = filterEntity.getApplyDefault();
    if (filterEntity.getFolder() == null) {
        CommitContext ctx = new CommitContext(Collections.singletonList(filterEntity));
        Set<Entity> result = dataService.commit(ctx);
        FilterEntity savedFilterEntity = (FilterEntity) result.iterator().next();
        filterEntities.remove(filterEntity);
        filterEntity = savedFilterEntity;
        filterEntities.add(filterEntity);
        filterEntity.setApplyDefault(applyDefault);
        filterEntity.setIsDefault(isDefault);
    } else {
        filterEntity.getFolder().setName(filterEntity.getName());
        filterEntity.getFolder().setFilterXml(filterEntity.getXml());
        AbstractSearchFolder folder = saveFolder(filterEntity.getFolder());
        filterEntity.setFolder(folder);
    }
    saveInitialFilterState();
    setFilterActionsEnabled();
    updateFilterModifiedIndicator();
}
Also used : FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Entity(com.haulmont.cuba.core.entity.Entity) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity)

Example 8 with AbstractSearchFolder

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

the class WebFilterHelper method saveFolder.

@Override
@Nullable
public AbstractSearchFolder saveFolder(AbstractSearchFolder folder) {
    FoldersPane foldersPane = getUiFoldersPane();
    if (foldersPane == null)
        return null;
    CubaFoldersPane foldersPaneImpl = foldersPane.unwrapOrNull(CubaFoldersPane.class);
    if (foldersPaneImpl == null) {
        return null;
    }
    AbstractSearchFolder savedFolder = (AbstractSearchFolder) foldersPaneImpl.saveFolder(folder);
    foldersPaneImpl.refreshFolders();
    return savedFolder;
}
Also used : FoldersPane(com.haulmont.cuba.gui.components.mainwindow.FoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane) CubaFoldersPane(com.haulmont.cuba.web.app.folders.CubaFoldersPane) AbstractSearchFolder(com.haulmont.cuba.core.entity.AbstractSearchFolder) Nullable(javax.annotation.Nullable)

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