use of com.servoy.j2db.gui.FormDialog in project servoy-client by Servoy.
the class SwingRuntimeWindowManager method getOrderedContainers.
@Override
protected List<String> getOrderedContainers() {
// here we have to close in reverse order of the opening
FormManager fm = ((FormManager) application.getFormManager());
List<String> orderedDialogs = new ArrayList<String>();
Map<FormDialog, String> dialogs = new HashMap<FormDialog, String>();
List<String> all = fm.getCreatedMainContainerKeys();
for (String key : all) {
if (key != null) {
IMainContainer mContainer = fm.getMainContainer(key);
if (fm.getMainContainer(null) != mContainer) {
Container parent = ((Component) mContainer).getParent();
while (parent != null && !(parent instanceof FormDialog)) {
parent = parent.getParent();
}
if (parent instanceof FormDialog) {
dialogs.put((FormDialog) parent, key);
continue;
}
}
}
}
for (FormDialog dialog : dialogs.keySet()) {
addDialogsInOrder(dialog, dialogs, orderedDialogs);
}
if (orderedDialogs.size() < all.size()) {
for (String key : all) {
if (!orderedDialogs.contains(key)) {
orderedDialogs.add(key);
}
}
}
return orderedDialogs;
}
use of com.servoy.j2db.gui.FormDialog 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.gui.FormDialog 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