Search in sources :

Example 21 with IMainContainer

use of com.servoy.j2db.IMainContainer in project servoy-client by Servoy.

the class SwingFormManager method getOrCreateMainContainer.

@Override
public IMainContainer getOrCreateMainContainer(String name) {
    IMainContainer container = getMainContainer(name);
    if (container == null) {
        container = new MainPanel(getApplication(), name);
        containers.put(name, container);
    }
    return container;
}
Also used : IMainContainer(com.servoy.j2db.IMainContainer)

Example 22 with IMainContainer

use of com.servoy.j2db.IMainContainer in project servoy-client by Servoy.

the class SwingRuntimeWindow method doOldShowInDialog.

private void doOldShowInDialog(String formName, boolean closeAll, boolean legacyV3Behavior) {
    FormManager fm = ((FormManager) getApplication().getFormManager());
    IMainContainer currentModalDialogContainer = fm.getModalDialogContainer();
    JSWindow parentJSWindow = getParent();
    RuntimeWindow parentRuntimeWindow = null;
    if (parentJSWindow != null && parentJSWindow.getImpl().isVisible())
        parentRuntimeWindow = parentJSWindow.getImpl();
    else {
        Window dialogWindowOwner = getWindowFromMainContainer(currentModalDialogContainer);
        if (dialogWindowOwner != null) {
            IMainContainer currentContainer = fm.getCurrentContainer();
            Window currentContainerWindow = getWindowFromMainContainer(currentContainer);
            while (currentContainerWindow != null) {
                if (dialogWindowOwner == currentContainerWindow) {
                    break;
                }
                currentContainerWindow = currentContainerWindow.getOwner();
            }
            if (currentContainerWindow == null) {
                // if it never really was the owner (in the own chain of the dialog) then do just use the currentContainer.
                currentModalDialogContainer = currentContainer;
            }
        }
        parentRuntimeWindow = getApplication().getRuntimeWindowManager().getWindow(currentModalDialogContainer.getContainerName());
    }
    boolean windowModal = ((legacyV3Behavior && wrappedWindow == null) || getType() == JSWindow.MODAL_DIALOG);
    Pair<Boolean, IMainContainer> p = createAndReparentDialogIfNeeded(fm, parentRuntimeWindow, windowModal);
    boolean bringToFrontNeeded = p.getLeft().booleanValue();
    IMainContainer previousModalContainer = p.getRight();
    FormDialog sfd = (FormDialog) wrappedWindow;
    IMainContainer container = sfd.getMainContainer();
    // For none legacy the dialog must always be really closed
    sfd.setCloseAll(closeAll || !legacyV3Behavior);
    if (sfd.isVisible()) {
        sfd.storeBounds();
    }
    final FormController fp = fm.showFormInMainPanel(formName, container, title, closeAll && legacyV3Behavior, windowName);
    if (fp != null && fp.getName().equals(formName)) {
        sfd.setModal(windowModal);
        if (!sfd.isDisplayable() && isUndecorated()) {
            sfd.setUndecorated(true);
            sfd.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
            // $NON-NLS-1$
            if (Utils.isAppleMacOS())
                sfd.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
        }
        applyOpacityAndTransparency(sfd, container, sfd.getContentPane(), sfd.isUndecorated());
        if (windowModal) {
            testAndSetJava6Modality(sfd);
            // When a modal window is closed, the old modal window state will have to be restored...
            // For example, when inside JS for an event you close a modal window and open another one,
            // the new modal window must have as owner not the closed window, but the last opened modal window
            // before the window just closed.
            // This has to happen when setVisible(false) is called on the modal dialog. We cannot simply rely
            // on executing this after sfd.setVisible(true) is unblocked, because then it will be executed
            // after the new dialog is opened by java script. (because that execution continues as the next event on the EventThread)
            sfd.setPreviousMainContainer(previousModalContainer, currentModalDialogContainer);
        } else {
            // If it is a none modal dialog, make sure the current container is reset to the currentMainContainer (== previous his parent)
            // else it is switched a bit to early (if a developer shows 2 dialogs at once from a main container)
            // the focus event of the FormDialog will set it correctly.
            fm.setCurrentContainer(currentModalDialogContainer, currentModalDialogContainer.getName());
        }
    }
    finalizeShowWindow(fp, formName, container, true, legacyV3Behavior, bringToFrontNeeded);
}
Also used : ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) Window(java.awt.Window) JSWindow(com.servoy.j2db.scripting.JSWindow) FormWindow(com.servoy.j2db.FormWindow) FormController(com.servoy.j2db.FormController) FormDialog(com.servoy.j2db.gui.FormDialog) ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) FormManager(com.servoy.j2db.FormManager) JSWindow(com.servoy.j2db.scripting.JSWindow) IMainContainer(com.servoy.j2db.IMainContainer)

Example 23 with IMainContainer

use of com.servoy.j2db.IMainContainer in project servoy-client by Servoy.

the class SwingRuntimeWindow method getWindowFromMainContainer.

/**
 * @param currentModalDialogContainer
 * @return
 */
public Window getWindowFromMainContainer(IMainContainer currentModalDialogContainer) {
    Window dialogWindowOwner = null;
    Container component = (Container) currentModalDialogContainer;
    while (component != null) {
        if (component instanceof Window) {
            dialogWindowOwner = (Window) component;
            break;
        }
        component = component.getParent();
    }
    return dialogWindowOwner;
}
Also used : ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) Window(java.awt.Window) JSWindow(com.servoy.j2db.scripting.JSWindow) FormWindow(com.servoy.j2db.FormWindow) IMainContainer(com.servoy.j2db.IMainContainer) Container(java.awt.Container) RootPaneContainer(javax.swing.RootPaneContainer)

Example 24 with IMainContainer

use of com.servoy.j2db.IMainContainer in project servoy-client by Servoy.

the class SwingRuntimeWindow method createFrameIfNeeded.

private boolean createFrameIfNeeded(FormManager fm) {
    IMainContainer container = fm.getOrCreateMainContainer(windowName);
    boolean bringToFrontNeeded = false;
    FormFrame frame = (FormFrame) wrappedWindow;
    if (frame == null) {
        wrappedWindow = frame = createFormFrame(windowName);
        frame.setResizable(resizable);
        frame.setMainContainer(container);
        // need to call 'pack' as the 'container' may have been used before & removed from a frame, causing
        // it to be unbinded from its peer, but we need it binded for calculations before showing it; see
        // MainPanel.show, all 'tableFormPanel' components would be inivisible, because 'tableFormPanel' is unbinded from its peer,
        // causing the frame focus to not work;
        frame.pack();
        createdNewWindow = true;
    } else if (frame.isVisible()) {
        bringToFrontNeeded = true;
    }
    return bringToFrontNeeded;
}
Also used : IMainContainer(com.servoy.j2db.IMainContainer)

Example 25 with IMainContainer

use of com.servoy.j2db.IMainContainer in project servoy-client by Servoy.

the class SwingRuntimeWindow method createAndReparentDialogIfNeeded.

private Pair<Boolean, IMainContainer> createAndReparentDialogIfNeeded(FormManager fm, RuntimeWindow parentJSWindow, boolean windowModal) {
    IMainContainer container = fm.getOrCreateMainContainer(windowName);
    IMainContainer previousModalContainer = null;
    FormDialog sfd = (FormDialog) wrappedWindow;
    boolean reparented = false;
    Object[] savedStatusForRecreate = null;
    // make sure the dialog has the correct owner
    if (sfd != null) {
        Window formDialogOwner = sfd.getOwner();
        Window owner = null;
        if (parentJSWindow == null || parentJSWindow.getWrappedObject() == null) {
            owner = getApplication().getMainApplicationFrame();
        } else {
            owner = (Window) parentJSWindow.getWrappedObject();
        }
        if ((owner != sfd) && !owner.equals(formDialogOwner)) {
            // wrong owner... will create a new window and close/dispose old one
            savedStatusForRecreate = saveWrappedWindowStatusForRecreate();
            hide(true);
            sfd.dispose();
            sfd = null;
            wrappedWindow = null;
            reparented = true;
        }
    }
    if (windowModal) {
        previousModalContainer = fm.setModalDialogContainer(container);
    }
    boolean bringToFrontNeeded = false;
    if (sfd == null) {
        wrappedWindow = sfd = createFormDialog(parentJSWindow != null ? (Window) parentJSWindow.getWrappedObject() : null, windowModal, windowName);
        createdNewWindow = true;
        sfd.setResizable(resizable);
        sfd.setMainContainer(container);
        if (reparented) {
            restoreWrappedWindowStatusAfterRecreate(savedStatusForRecreate);
        }
    } else if (sfd.isVisible()) {
        bringToFrontNeeded = true;
    }
    return new Pair<Boolean, IMainContainer>(Boolean.valueOf(bringToFrontNeeded), previousModalContainer);
}
Also used : ISmartRuntimeWindow(com.servoy.j2db.plugins.ISmartRuntimeWindow) RuntimeWindow(com.servoy.j2db.scripting.RuntimeWindow) Window(java.awt.Window) JSWindow(com.servoy.j2db.scripting.JSWindow) FormWindow(com.servoy.j2db.FormWindow) FormDialog(com.servoy.j2db.gui.FormDialog) IMainContainer(com.servoy.j2db.IMainContainer) Pair(com.servoy.j2db.util.Pair)

Aggregations

IMainContainer (com.servoy.j2db.IMainContainer)25 FormManager (com.servoy.j2db.FormManager)20 MainPage (com.servoy.j2db.server.headlessclient.MainPage)13 FormController (com.servoy.j2db.FormController)3 FormWindow (com.servoy.j2db.FormWindow)3 FormDialog (com.servoy.j2db.gui.FormDialog)3 ISmartRuntimeWindow (com.servoy.j2db.plugins.ISmartRuntimeWindow)3 JSWindow (com.servoy.j2db.scripting.JSWindow)3 RuntimeWindow (com.servoy.j2db.scripting.RuntimeWindow)3 Window (java.awt.Window)3 IBasicFormManager (com.servoy.j2db.IBasicFormManager)2 IComponent (com.servoy.j2db.ui.IComponent)2 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 ISupportOnRenderCallback (com.servoy.j2db.ui.ISupportOnRenderCallback)2 Container (java.awt.Container)2 Component (org.apache.wicket.Component)2 IApplication (com.servoy.j2db.IApplication)1 IBasicMainContainer (com.servoy.j2db.IBasicMainContainer)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1