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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations