Search in sources :

Example 1 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class AddConditionHelper method _addCondition.

protected void _addCondition(AbstractConditionDescriptor descriptor, ConditionsTree conditionsTree) {
    final AbstractCondition condition = descriptor.createCondition();
    if (descriptor instanceof CustomConditionCreator) {
        WindowInfo windowInfo = windowConfig.getWindowInfo("customConditionEditor");
        Map<String, Object> params = new HashMap<>();
        params.put("condition", condition);
        params.put("conditionsTree", conditionsTree);
        final CustomConditionEditor window = (CustomConditionEditor) windowManager.openWindow(windowInfo, WindowManager.OpenType.DIALOG, params);
        window.addCloseListener(actionId -> {
            if (Window.COMMIT_ACTION_ID.equals(actionId)) {
                handler.handle(condition);
            }
        });
    } else if (descriptor instanceof DynamicAttributesConditionCreator) {
        WindowInfo windowInfo = windowConfig.getWindowInfo("dynamicAttributesConditionEditor");
        Map<String, Object> params = new HashMap<>();
        params.put("condition", condition);
        final DynamicAttributesConditionEditor window = (DynamicAttributesConditionEditor) windowManager.openWindow(windowInfo, WindowManager.OpenType.DIALOG, params);
        window.addCloseListener(actionId -> {
            if (Window.COMMIT_ACTION_ID.equals(actionId)) {
                handler.handle(condition);
            }
        });
    } else {
        handler.handle(condition);
    }
}
Also used : CustomConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator) WindowManager(com.haulmont.cuba.gui.WindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) Collection(java.util.Collection) AddConditionWindow(com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow) HashMap(java.util.HashMap) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) AppBeans(com.haulmont.cuba.core.global.AppBeans) CustomConditionEditor(com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor) ConditionDescriptorsTreeBuilderAPI(com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI) AbstractConditionDescriptor(com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor) Window(com.haulmont.cuba.gui.components.Window) DynamicAttributesConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) DynamicAttributesConditionEditor(com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor) Tree(com.haulmont.bali.datastruct.Tree) Map(java.util.Map) WindowManagerProvider(com.haulmont.cuba.gui.WindowManagerProvider) Filter(com.haulmont.cuba.gui.components.Filter) CustomConditionEditor(com.haulmont.cuba.gui.components.filter.edit.CustomConditionEditor) CustomConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.CustomConditionCreator) HashMap(java.util.HashMap) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) DynamicAttributesConditionEditor(com.haulmont.cuba.gui.components.filter.edit.DynamicAttributesConditionEditor) DynamicAttributesConditionCreator(com.haulmont.cuba.gui.components.filter.descriptor.DynamicAttributesConditionCreator) AbstractCondition(com.haulmont.cuba.gui.components.filter.condition.AbstractCondition) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class TreeLoader method loadButtonsPanel.

protected void loadButtonsPanel(Tree component) {
    if (buttonsPanelLoader != null) {
        // noinspection unchecked
        buttonsPanelLoader.loadComponent();
        ButtonsPanel panel = (ButtonsPanel) buttonsPanelLoader.getResultComponent();
        Window window = ComponentsHelper.getWindowImplementation(component);
        String alwaysVisible = buttonsPanelElement.attributeValue("alwaysVisible");
        panel.setVisible(!(window instanceof Window.Lookup) || "true".equals(alwaysVisible));
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) ButtonsPanel(com.haulmont.cuba.gui.components.ButtonsPanel)

Example 3 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class WidgetsTreeLoader method loadButtonsPanel.

protected void loadButtonsPanel(Tree component) {
    if (buttonsPanelLoader != null) {
        // noinspection unchecked
        buttonsPanelLoader.loadComponent();
        ButtonsPanel panel = (ButtonsPanel) buttonsPanelLoader.getResultComponent();
        Window window = ComponentsHelper.getWindowImplementation(component);
        String alwaysVisible = buttonsPanelElement.attributeValue("alwaysVisible");
        panel.setVisible(!(window instanceof Window.Lookup) || "true".equals(alwaysVisible));
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) ButtonsPanel(com.haulmont.cuba.gui.components.ButtonsPanel)

Example 4 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class ScreenHistorySupport method saveScreenHistory.

public void saveScreenHistory(Window window, WindowManager.OpenMode openMode) {
    Security security = AppBeans.get(Security.NAME);
    if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && window.getFrame() != null && (window.getFrame() instanceof Window.Editor) && openMode != WindowManager.OpenMode.DIALOG && (screenIds == null || screenIds.contains(window.getId()))) {
        String caption = window.getCaption();
        UUID entityId = null;
        Frame frame = window.getFrame();
        Entity entity = null;
        if (frame instanceof Window.Editor) {
            entity = ((Window.Editor) frame).getItem();
            if (entity != null) {
                if (PersistenceHelper.isNew(entity)) {
                    return;
                }
                if (StringUtils.isBlank(caption))
                    caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " " + entity.getInstanceName();
                entityId = (UUID) entity.getId();
            }
        }
        ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class);
        screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255));
        screenHistoryEntity.setUrl(makeLink(window));
        screenHistoryEntity.setEntityId(entityId);
        addAdditionalFields(screenHistoryEntity, entity);
        CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity));
        DataService dataService = AppBeans.get(DataService.NAME);
        dataService.commit(cc);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) ScreenHistoryEntity(com.haulmont.cuba.security.entity.ScreenHistoryEntity) Entity(com.haulmont.cuba.core.entity.Entity) Frame(com.haulmont.cuba.gui.components.Frame) ScreenHistoryEntity(com.haulmont.cuba.security.entity.ScreenHistoryEntity) DataService(com.haulmont.cuba.core.app.DataService)

Example 5 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class DesktopWindowManager method showWindowThisTab.

protected JComponent showWindowThisTab(Window window, String caption, String description) {
    getDialogParams().reset();
    window.setWidth("100%");
    window.setHeight("100%");
    JComponent layout;
    if (isMainWindowManager) {
        layout = (JComponent) tabsPane.getSelectedComponent();
    } else {
        layout = (JComponent) frame.getContentPane().getComponent(0);
    }
    WindowBreadCrumbs breadCrumbs = tabs.get(layout);
    if (breadCrumbs == null)
        throw new IllegalStateException("BreadCrumbs not found");
    Window currentWindow = breadCrumbs.getCurrentWindow();
    Window currentWindowFrame = (Window) currentWindow.getFrame();
    windowOpenMode.get(currentWindowFrame).setFocusOwner(frame.getFocusOwner());
    Set<Map.Entry<Window, Integer>> set = windows.entrySet();
    boolean pushed = false;
    for (Map.Entry<Window, Integer> entry : set) {
        if (entry.getKey().equals(currentWindow)) {
            windows.remove(currentWindow);
            stacks.get(breadCrumbs).push(entry);
            pushed = true;
            break;
        }
    }
    if (!pushed) {
        stacks.get(breadCrumbs).push(new AbstractMap.SimpleEntry<>(currentWindow, null));
    }
    windows.remove(window);
    layout.remove(DesktopComponentsHelper.getComposition(currentWindow));
    JComponent component = DesktopComponentsHelper.getComposition(window);
    layout.add(component);
    breadCrumbs.addWindow(window);
    if (isMainWindowManager) {
        setActiveWindowCaption(caption, description, tabsPane.getSelectedIndex());
    } else {
        setTopLevelWindowCaption(caption);
        component.revalidate();
        component.repaint();
    }
    return layout;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) ParamsMap(com.haulmont.bali.util.ParamsMap)

Aggregations

Window (com.haulmont.cuba.gui.components.Window)54 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)15 WebWindow (com.haulmont.cuba.web.gui.WebWindow)13 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)10 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)6 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)6 ParamsMap (com.haulmont.bali.util.ParamsMap)5 Component (com.haulmont.cuba.gui.components.Component)5 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)5 Component (com.vaadin.ui.Component)5 Entity (com.haulmont.cuba.core.entity.Entity)4 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)4 CssLayout (com.vaadin.ui.CssLayout)4 Pair (com.haulmont.bali.datastruct.Pair)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3 Action (com.haulmont.cuba.gui.components.Action)3 ButtonsPanel (com.haulmont.cuba.gui.components.ButtonsPanel)3 Frame (com.haulmont.cuba.gui.components.Frame)3 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)3