Search in sources :

Example 1 with HasTablePresentations

use of io.jmix.ui.component.HasTablePresentations in project jmix by jmix-framework.

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 = windowManagerProvider.get();
    Window window = wm.openWindow(windowInfo, WindowManager.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.getPresentationId() != null) {
            ((HasTablePresentations) filterComponent.getApplyTo()).applyPresentation(searchFolder.getPresentationId());
        }
    }
    if (window.getFrameOwner() instanceof LegacyFrame) {
        DsContext dsContext = ((LegacyFrame) window.getFrameOwner()).getDsContext();
        if (dsContext != null) {
            ((DsContextImplementation) dsContext).resumeSuspended();
        }
    }
}
Also used : Window(io.jmix.ui.component.Window) 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(io.jmix.ui.WindowInfo) WindowManager(com.haulmont.cuba.gui.WindowManager) Filter(com.haulmont.cuba.gui.components.Filter) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Example 2 with HasTablePresentations

use of io.jmix.ui.component.HasTablePresentations in project jmix by jmix-framework.

the class PresentationsFacetProvider method loadFromXml.

@Override
public void loadFromXml(PresentationsFacet facet, Element element, ComponentLoader.ComponentContext context) {
    loadId(element).ifPresent(facet::setId);
    loadAuto(element).ifPresent(facet::setAuto);
    if (!facet.isAuto()) {
        List<String> ids = loadComponentIds(context, element);
        facet.addComponentIds(ids.toArray(new String[0]));
    }
    if (isPresentationsAvailable()) {
        context.addPostInitTask((context1, window) -> {
            Collection<Component> components = facet.getComponents();
            for (Component component : components) {
                if (component instanceof HasTablePresentations) {
                    ((HasTablePresentations) component).loadPresentations();
                }
            }
        });
    }
}
Also used : Component(io.jmix.ui.component.Component) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Example 3 with HasTablePresentations

use of io.jmix.ui.component.HasTablePresentations in project jmix by jmix-framework.

the class PresentationsManagerImpl method setupDefaultSettings.

@Override
public void setupDefaultSettings(Collection<Component> components) {
    for (Component component : components) {
        if (Strings.isNullOrEmpty(component.getId()) || !settingsRegistry.isSettingsRegisteredFor(component.getClass()) || !(component instanceof HasTablePresentations)) {
            continue;
        }
        ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
        ComponentSettings defaultSettings = binder.getSettings(component);
        ((HasTablePresentations) component).setDefaultSettings(new SettingsWrapperImpl(defaultSettings));
    }
}
Also used : ComponentSettings(io.jmix.ui.settings.component.ComponentSettings) SettingsWrapperImpl(io.jmix.ui.settings.component.SettingsWrapperImpl) Component(io.jmix.ui.component.Component) HasTablePresentations(io.jmix.ui.component.HasTablePresentations) ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder)

Example 4 with HasTablePresentations

use of io.jmix.ui.component.HasTablePresentations in project jmix by jmix-framework.

the class ScreenSettings method applySettings.

/**
 * Apply settings for screen.
 *
 * @param screen   screen
 * @param settings settings
 */
public void applySettings(Screen screen, Settings settings) {
    checkNotNullArgument(screen);
    checkNotNullArgument(settings);
    walkComponents(screen.getWindow(), (component, name) -> {
        if (component.getId() != null && component instanceof HasSettings) {
            log.trace("Applying settings for {} : {} ", name, component);
            Element e = settings.get(name);
            ((HasSettings) component).applySettings(e);
            if (component instanceof HasTablePresentations && e.attributeValue("presentation") != null) {
                String def = e.attributeValue("presentation");
                if (!StringUtils.isEmpty(def)) {
                    UUID defaultId = UUID.fromString(def);
                    ((HasTablePresentations) component).applyPresentationAsDefault(defaultId);
                }
            }
        }
    });
}
Also used : Element(org.dom4j.Element) HasSettings(com.haulmont.cuba.gui.components.HasSettings) UUID(java.util.UUID) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Example 5 with HasTablePresentations

use of io.jmix.ui.component.HasTablePresentations in project jmix by jmix-framework.

the class LegacySettingsDelegate method applySettings.

@Override
public void applySettings(Element element) {
    if (!isSettingsEnabled()) {
        return;
    }
    if (defaultSettings == null && component instanceof HasTablePresentations) {
        // save default view before apply custom
        defaultSettings = DocumentHelper.createDocument();
        defaultSettings.setRootElement(defaultSettings.addElement("presentation"));
        saveSettings(defaultSettings.getRootElement());
        ComponentSettings settings = settingsConverter.convertToComponentSettings(defaultSettings.getRootElement());
        ((HasTablePresentations) component).setDefaultSettings(new SettingsWrapperImpl(settings));
    }
    ComponentSettings settings = settingsConverter.convertToComponentSettings(element);
    settingsBinder.applySettings(component, new SettingsWrapperImpl(settings));
}
Also used : ComponentSettings(io.jmix.ui.settings.component.ComponentSettings) SettingsWrapperImpl(io.jmix.ui.settings.component.SettingsWrapperImpl) HasTablePresentations(io.jmix.ui.component.HasTablePresentations)

Aggregations

HasTablePresentations (io.jmix.ui.component.HasTablePresentations)5 Component (io.jmix.ui.component.Component)2 ComponentSettings (io.jmix.ui.settings.component.ComponentSettings)2 SettingsWrapperImpl (io.jmix.ui.settings.component.SettingsWrapperImpl)2 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 Filter (com.haulmont.cuba.gui.components.Filter)1 HasSettings (com.haulmont.cuba.gui.components.HasSettings)1 DsContext (com.haulmont.cuba.gui.data.DsContext)1 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)1 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)1 WindowInfo (io.jmix.ui.WindowInfo)1 Window (io.jmix.ui.component.Window)1 ComponentSettingsBinder (io.jmix.ui.settings.component.binder.ComponentSettingsBinder)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 Element (org.dom4j.Element)1