Search in sources :

Example 11 with Window

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

the class DesktopWindowManager method moveFocus.

protected void moveFocus(java.awt.Component tab) {
    Window window = tabs.get(tab).getCurrentWindow();
    if (window != null) {
        String focusComponentId = window.getFocusComponent();
        boolean focused = false;
        if (focusComponentId != null) {
            com.haulmont.cuba.gui.components.Component focusComponent = window.getComponent(focusComponentId);
            if (focusComponent != null) {
                if (focusComponent.isEnabled() && focusComponent.isVisible()) {
                    focusComponent.requestFocus();
                    focused = true;
                }
            }
        }
        if (!focused && window instanceof Window.Wrapper) {
            Window.Wrapper wrapper = (Window.Wrapper) window;
            focused = ((DesktopWindow) wrapper.getWrappedWindow()).findAndFocusChildComponent();
            if (!focused) {
                tabsPane.requestFocus();
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Component(com.haulmont.cuba.gui.components.Component)

Example 12 with Window

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

the class DesktopWindowManager method isCloseWithCloseButtonPrevented.

protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
    DesktopWindow desktopWindow = (DesktopWindow) ComponentsHelper.getWindowImplementation(currentWindow);
    if (desktopWindow != null) {
        Window.BeforeCloseWithCloseButtonEvent event = new Window.BeforeCloseWithCloseButtonEvent(desktopWindow);
        desktopWindow.fireBeforeCloseWithCloseButton(event);
        return event.isClosePrevented();
    }
    return false;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow)

Example 13 with Window

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

the class WindowBreadCrumbs method update.

public void update() {
    removeAll();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
        Window window = it.next();
        JButton button = new JXHyperlink();
        button.setFocusable(false);
        button.setText(StringUtils.trimToEmpty(window.getCaption()));
        button.addActionListener(new ValidationAwareActionListener() {

            @Override
            public void actionPerformedAfterValidation(ActionEvent e) {
                JButton btn = (JButton) e.getSource();
                Window win = btn2win.get(btn);
                if (win != null) {
                    fireListeners(win);
                }
            }
        });
        btn2win.put(button, window);
        if (it.hasNext()) {
            add(button);
            JLabel separatorLab = new JLabel(">");
            add(separatorLab);
        } else {
            add(new JLabel(window.getCaption()));
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) ValidationAwareActionListener(com.haulmont.cuba.desktop.sys.validation.ValidationAwareActionListener) ActionEvent(java.awt.event.ActionEvent) JXHyperlink(org.jdesktop.swingx.JXHyperlink)

Example 14 with Window

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

the class AddAction method actionPerform.

/**
 * This method is invoked by action owner component. Don't override it, there are special methods to
 * customize behaviour below.
 * @param component component invoking action
 */
@Override
public void actionPerform(Component component) {
    if (beforeActionPerformedHandler != null) {
        if (!beforeActionPerformedHandler.beforeActionPerformed())
            return;
    }
    Map<String, Object> params = prepareWindowParams();
    Window.Lookup.Handler handler = getHandler();
    Window.Lookup.Handler itemsHandler = handler != null ? handler : new DefaultHandler();
    Window lookupWindow = target.getFrame().openLookup(getWindowId(), itemsHandler, getOpenType(), params);
    lookupWindow.addCloseListener(actionId -> {
        // move focus to owner
        target.requestFocus();
    });
}
Also used : Window(com.haulmont.cuba.gui.components.Window)

Example 15 with Window

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

the class DesktopTabSheet method initLazyTab.

protected void initLazyTab(JComponent tab) {
    LazyTabInfo lti = null;
    for (LazyTabInfo lazyTabInfo : lazyTabs) {
        if (lazyTabInfo.getTabComponent() == tab) {
            lti = lazyTabInfo;
            break;
        }
    }
    if (lti == null) {
        // already initialized
        return;
    }
    if (!lti.getTab().isEnabled()) {
        return;
    }
    lazyTabs.remove(lti);
    lti.loader.createComponent();
    Component lazyContent = lti.loader.getResultComponent();
    lazyContent.setWidth("100%");
    lti.tabContent.add(lazyContent);
    lti.tabContent.expand(lazyContent, "", "");
    lazyContent.setParent(this);
    lti.loader.loadComponent();
    if (lazyContent instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
        ((DesktopAbstractComponent) lazyContent).setParentEnabled(false);
    }
    final Window window = ComponentsHelper.getWindow(DesktopTabSheet.this);
    if (window != null) {
        ComponentsHelper.walkComponents(lti.tabContent, (component, name) -> {
            if (component instanceof HasSettings) {
                Settings settings = window.getSettings();
                if (settings != null) {
                    Element e = settings.get(name);
                    ((HasSettings) component).applySettings(e);
                }
            }
        });
        lti.getTab().setLazyInitialized(true);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) Element(org.dom4j.Element) ButtonTabComponent(com.haulmont.cuba.desktop.sys.ButtonTabComponent) Component(com.haulmont.cuba.gui.components.Component) Settings(com.haulmont.cuba.gui.settings.Settings)

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