use of com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction in project servoy-client by Servoy.
the class MainPage method resetBounds.
public void resetBounds(String windowName) {
touch();
MainPage mp = this;
if (callingContainer != null) {
callingContainer.touch();
mp = callingContainer;
}
mp.addJSAction(new DivDialogAction(null, DivDialogAction.OP_RESET_BOUNDS, new Object[] { COOKIE_PREFIX + windowName }));
}
use of com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction in project servoy-client by Servoy.
the class MainPage method toFront.
public void toFront() {
touch();
if (isShowingInDialog() && callingContainer != null) {
callingContainer.touch();
ServoyDivDialog divDialog = callingContainer.divDialogs.get(getContainerName());
if (divDialog != null) {
callingContainer.addJSAction(new DivDialogAction(divDialog, DivDialogAction.OP_TO_FRONT));
}
} else {
appendJavaScriptChanges("window.focus();");
}
}
use of com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction in project servoy-client by Servoy.
the class MainPage method close.
public void close() {
// first touch this page so that it is locked if this is a normal request
touch();
setWindowSize(null);
if (callingContainer != null) {
if (isShowingInWindow()) {
// this is a non-modal browser window; close it through JS; using setTimeout to allow any pending triggerAjaxUpdate that initiated in this page to do it's job
// $NON-NLS-1$
appendJavaScriptChanges("if (!self.closed) window.setTimeout('self.close();', 1);");
closingAsWindow = true;
}
ServoyDivDialog divDialog = callingContainer.divDialogs.remove(getPageMapName());
if (divDialog != null) {
callingContainer.addJSAction(new DivDialogAction(divDialog, DivDialogAction.OP_SAVE_BOUNDS));
callingContainer.closingAChildDivPopoup = true;
closingAsDivPopup = true;
callingContainer.addJSAction(new DivDialogAction(divDialog, DivDialogAction.OP_CLOSE, new Object[] { this }) {
@Override
protected void onAfterApply() {
MainPage.this.closingAsDivPopup = false;
}
});
}
callingContainer.closeChildWindow(getPageMapName());
}
showingInWindow = false;
showingInDialog = false;
}
use of com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction in project servoy-client by Servoy.
the class MainPage method createDivDialog.
private ServoyDivDialog createDivDialog(MainPage dialogContainer, String name) {
final ServoyDivDialog divDialog = new ServoyDivDialog(divDialogRepeater.newChildId()) {
@Override
public void show(AjaxRequestTarget target) {
super.show(target);
Component toFocus = ((MainPage) page).getFocusedComponent();
if (toFocus == null)
toFocus = page;
target.focusComponent(toFocus);
}
};
divDialog.setPageMapName(null);
divDialog.setCookieName(COOKIE_PREFIX + name);
divDialog.setModal(true);
dialogContainer.showingInDialog = true;
dialogContainer.showingInWindow = false;
divDialog.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = 1L;
public Page createPage() {
MainPage mp = (MainPage) ((FormManager) client.getFormManager()).getOrCreateMainContainer(divDialog.getPageMapName());
divDialog.setPage(mp);
return mp;
}
});
divDialog.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
private static final long serialVersionUID = 1L;
public void onClose(AjaxRequestTarget target) {
divDialogRepeater.remove(divDialog);
String divDialogPageMapName = divDialog.getPageMapName();
if (divDialogs.get(divDialogPageMapName) == divDialog) {
divDialogs.remove(divDialogPageMapName);
}
if (divDialogs.size() == 0) {
divDialogsParent.setVisible(false);
} else {
addJSAction(new DivDialogAction(divDialog, DivDialogAction.OP_DIALOG_ADDED_OR_REMOVED, new Object[] { divDialogsParent }));
}
divDialog.setPageMapName(null);
restoreFocusedComponentInParentIfNeeded();
WebEventExecutor.generateResponse(target, findPage());
}
});
divDialog.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
private static final long serialVersionUID = 1L;
public boolean onCloseButtonClicked(AjaxRequestTarget target) {
if (!divDialog.isShown()) {
// double clicked?
return false;
}
FormManager fm = ((FormManager) client.getFormManager());
IMainContainer divDialogContainer = fm.getMainContainer(divDialog.getPageMapName());
IMainContainer currentContainer = fm.getCurrentContainer();
// get a lock on the dialog container (form onHide code will execute, make sure another req. on the dialog itself is not running at the same time)
if (divDialogContainer instanceof MainPage) {
((MainPage) divDialogContainer).touch();
}
// temporary set the dialog container as the current container (the close event is processed by the main container, not the dialog)
fm.setCurrentContainer(divDialogContainer, divDialogContainer.getContainerName());
if (client.getEventDispatcher() != null) {
client.getEventDispatcher().addEvent(new WicketEvent(client, new Runnable() {
public void run() {
client.getRuntimeWindowManager().closeFormInWindow(divDialog.getPageMapName(), divDialog.getCloseAll());
}
}));
} else {
client.getRuntimeWindowManager().closeFormInWindow(divDialog.getPageMapName(), divDialog.getCloseAll());
}
// reset current container again
fm.setCurrentContainer(currentContainer, currentContainer.getContainerName());
if (divDialogContainer instanceof MainPage) {
target.addComponent(divDialog);
}
WebEventExecutor.generateResponse(target, divDialog.getPage());
return false;
}
});
divDialogRepeater.add(divDialog);
divDialogsParent.setVisible(true);
addJSAction(new DivDialogAction(divDialog, DivDialogAction.OP_DIALOG_ADDED_OR_REMOVED, new Object[] { divDialogsParent }));
divDialogs.put(name, divDialog);
return divDialog;
}
use of com.servoy.j2db.server.headlessclient.PageJSActionBuffer.DivDialogAction in project servoy-client by Servoy.
the class MainPage method showPopupDiv.
public void showPopupDiv(MainPage dialogContainer, String titleString, Rectangle r2, boolean resizeable, boolean closeAll, boolean modal, boolean undecorated, boolean storeBounds, float opacity, boolean transparent) {
// see also triggerBrowserRequestIfNeeded() that uses these references
if ((isShowingInDialog() || isClosingAsDivPopup()) && callingContainer != null)
callingContainer.showPopupDiv(dialogContainer, titleString, r2, resizeable, closeAll, modal, undecorated, storeBounds, opacity, transparent);
else {
if (useAJAX) {
touch();
String windowName = dialogContainer.getPageMap().getName();
ServoyDivDialog divDialog = divDialogs.get(windowName);
if (divDialog == null) {
divDialog = createDivDialog(dialogContainer, windowName);
}
divDialog.setPageMapName(windowName);
divDialog.setResizable(resizeable);
divDialog.setStoreBounds(storeBounds);
divDialog.setUseInitialHeight(true);
divDialog.setModal(modal);
divDialog.setOpacity(opacity);
divDialog.setTransparent(transparent);
if (undecorated)
divDialog.setCssClassName("w_undecorated");
Rectangle bounds = r2;
if (FormManager.FULL_SCREEN.equals(r2)) {
// get the size of the browser window (that will contain the div window)
// it is a bit too high, why? Because windowBounds is size of what the div should occupy, while modalWindow.setInitialHeight() is only applied to the contents (without frame)
bounds = new Rectangle(0, 0, getWidth(), getHeight() - 45);
}
divDialog.setInitialHeight(bounds.height);
divDialog.setInitialWidth(bounds.width);
divDialog.setInitialLocation(new Point(bounds.x, bounds.y));
divDialog.setCloseAll(closeAll);
FormController fp = dialogContainer.getController();
String titleStr = titleString;
if (titleStr == null)
titleStr = fp.getForm().getTitleText();
if (titleStr == null)
titleStr = fp.getName();
titleStr = client.getI18NMessageIfPrefixed(titleStr);
if (titleStr != null) {
String name2 = Text.processTags(titleStr, fp.getTagResolver());
if (name2 != null)
titleStr = name2;
}
divDialog.setTitle(titleStr);
addJSAction(new DivDialogAction(divDialog, DivDialogAction.OP_SHOW, new Object[] { windowName }));
}
// not used for dialogs
dialogContainer.setWindowSize(null);
dialogContainer.callingContainer = this;
}
}
Aggregations