use of com.servoy.j2db.scripting.JSWindow in project servoy-client by Servoy.
the class SwingRuntimeWindow method getParent.
// For future implementation of case 286968 change
// @Override
// public int getState()
// {
// if (wrappedWindow instanceof JFrame)
// {
// int extendedState = ((JFrame)wrappedWindow).getExtendedState();
// int servoyState = NORMAL; // 0
// if ((extendedState & Frame.ICONIFIED) == Frame.ICONIFIED) servoyState = servoyState | ICONIFIED;
// if ((extendedState & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) servoyState = servoyState | MAXIMIZED;
// return servoyState;
// }
// else
// {
// return super.getState();
// }
// }
@Override
public JSWindow getParent() {
if (wrappedWindow != null) {
Window parent = wrappedWindow.getOwner();
RuntimeWindow pw;
if (parent == getApplication().getMainApplicationFrame()) {
pw = getApplication().getRuntimeWindowManager().getWindow(null);
} else if (parent != null) {
pw = getApplication().getRuntimeWindowManager().getWindow(parent.getName());
} else
pw = null;
return (pw != null) ? pw.getJSWindow() : null;
}
return super.getParent();
}
use of com.servoy.j2db.scripting.JSWindow in project servoy-client by Servoy.
the class BasicFormController method showForm.
void showForm(Object window, Object[] windowArgs) throws ServoyException {
if (!application.getFlattenedSolution().formCanBeInstantiated(getForm())) {
// abstract form
throw new ApplicationException(ServoyException.ABSTRACT_FORM);
}
if (window == null) {
getBasicFormManager().showFormInCurrentContainer(getName());
} else {
if (window instanceof String) {
Rectangle rect = new Rectangle(-1, -1, -1, -1);
String title = null;
boolean resizeble = true;
boolean showTextToolbar = false;
boolean modal = false;
boolean dialog = true;
if (windowArgs != null && windowArgs.length > 0) {
if (windowArgs[0] == null) {
dialog = false;
} else {
modal = Utils.getAsBoolean(windowArgs[0]);
}
}
if (dialog) {
getBasicFormManager().showFormInDialog(getName(), rect, title, resizeble, showTextToolbar, true, modal, (String) window);
} else {
getBasicFormManager().showFormInFrame(getName(), rect, title, resizeble, showTextToolbar, (String) window);
}
} else if (window instanceof JSWindow) {
((JSWindow) window).getImpl().show(getName());
} else {
getBasicFormManager().showFormInMainPanel(getName());
}
}
}
use of com.servoy.j2db.scripting.JSWindow 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.scripting.JSWindow in project servoy-client by Servoy.
the class NGRuntimeWindow method hideUI.
@Override
public void hideUI() {
visible = false;
getApplication().getWebsocketSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("hide", new Object[] { getName() });
// assume that just after hiding the window, currentController in js is the main window controller
JSWindow parent = getParent();
IFormController formController = null;
if (parent != null) {
formController = parent.getImpl().getController();
getApplication().getRuntimeWindowManager().setCurrentWindowName(parent.getImpl().getName());
} else if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null) {
if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null)
formController = getApplication().getRuntimeWindowManager().getMainApplicationWindow().getController();
}
if (formController instanceof IWebFormController)
getApplication().getFormManager().setCurrentControllerJS((IWebFormController) formController);
// resume
if (windowType == JSWindow.MODAL_DIALOG && getApplication().getWebsocketSession().getEventDispatcher() != null) {
final IEventDispatcher eventDispatcher = getApplication().getWebsocketSession().getEventDispatcher();
if (eventDispatcher.isEventDispatchThread()) {
eventDispatcher.resume(this);
} else {
eventDispatcher.addEvent(new Runnable() {
@Override
public void run() {
eventDispatcher.resume(NGRuntimeWindow.this);
}
});
}
}
}
Aggregations