}
public static class WindowState extends PanelState {
+ private boolean modal = false;
+ private boolean resizable = true;
+ private boolean resizeLazy = false;
+ private boolean draggable = true;
+ private boolean centered = false;;
+ private int positionX = -1;
+ private int positionY = -1;
+
+ public boolean isModal() {
+ return modal;
+ }
+
+ public void setModal(boolean modal) {
+ this.modal = modal;
+ }
+
+ public boolean isResizable() {
+ return resizable;
+ }
+
+ public void setResizable(boolean resizable) {
+ this.resizable = resizable;
+ }
+
+ public boolean isResizeLazy() {
+ return resizeLazy;
+ }
+
+ public void setResizeLazy(boolean resizeLazy) {
+ this.resizeLazy = resizeLazy;
+ }
+
+ public boolean isDraggable() {
+ return draggable;
+ }
+
+ public void setDraggable(boolean draggable) {
+ this.draggable = draggable;
+ }
+
+ public boolean isCentered() {
+ return centered;
+ }
+
+ public void setCentered(boolean centered) {
+ this.centered = centered;
+ }
+
+ public int getPositionX() {
+ return positionX;
+ }
+
+ public void setPositionX(int positionX) {
+ this.positionX = positionX;
+ }
+
+ public int getPositionY() {
+ return positionY;
+ }
+
+ public void setPositionY(int positionY) {
+ this.positionY = positionY;
+ }
}
DOM.setElementProperty(getWidget().closeBox, "id", getConnectorId()
+ "_window_close");
- if (uidl.hasAttribute("invisible")) {
- getWidget().hide();
- return;
- }
-
if (isRealUpdate(uidl)) {
- if (uidl.getBooleanAttribute("modal") != getWidget().vaadinModality) {
+ if (getState().isModal() != getWidget().vaadinModality) {
getWidget().setVaadinModality(!getWidget().vaadinModality);
}
if (!getWidget().isAttached()) {
// possible centering
getWidget().show();
}
- if (uidl.getBooleanAttribute("resizable") != getWidget().resizable) {
- getWidget().setResizable(!getWidget().resizable);
+ if (getState().isResizable() != getWidget().resizable) {
+ getWidget().setResizable(getState().isResizable());
}
- getWidget().resizeLazy = uidl.hasAttribute(VView.RESIZE_LAZY);
+ getWidget().resizeLazy = getState().isResizeLazy();
- getWidget().setDraggable(!uidl.hasAttribute("fixedposition"));
+ getWidget().setDraggable(getState().isDraggable());
// Caption must be set before required header size is measured. If
// the caption attribute is missing the caption should be cleared.
getWidget().setClosable(!isReadOnly());
// Initialize the position form UIDL
- int positionx = uidl.getIntVariable("positionx");
- int positiony = uidl.getIntVariable("positiony");
+ int positionx = getState().getPositionX();
+ int positiony = getState().getPositionY();
if (positionx >= 0 || positiony >= 0) {
if (positionx < 0) {
positionx = 0;
// Center this window on screen if requested
// This had to be here because we might not know the content size before
// everything is painted into the window
- if (uidl.getBooleanAttribute("center")) {
- // mark as centered - this is unset on move/resize
- getWidget().centered = true;
- } else {
- // don't try to center the window anymore
- getWidget().centered = false;
- }
+
+ // centered is this is unset on move/resize
+ getWidget().centered = getState().isCentered();
getWidget().setVisible(true);
// ensure window is not larger than browser window
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
-import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.terminal.gwt.client.ui.WindowConnector;
import com.vaadin.terminal.gwt.client.ui.WindowConnector.WindowServerRPC;
import com.vaadin.terminal.gwt.client.ui.WindowConnector.WindowState;
*/
private boolean draggable = true;
- /**
- * <b>Sub window only</b>. Flag which is true if the window is centered on
- * the screen.
- */
- private boolean centerRequested = false;
-
/**
* Should resize recalculate layouts lazily (as opposed to immediately)
*/
@Override
public synchronized void paintContent(PaintTarget target)
throws PaintException {
-
- if (modal) {
- target.addAttribute("modal", true);
- }
-
- if (resizable) {
- target.addAttribute("resizable", true);
- }
- if (resizeLazy) {
- target.addAttribute(VView.RESIZE_LAZY, resizeLazy);
- }
-
- if (!draggable) {
- // Inverted to prevent an extra attribute for almost all sub windows
- target.addAttribute("fixedposition", true);
- }
-
if (bringToFront != null) {
target.addAttribute("bringToFront", bringToFront.intValue());
bringToFront = null;
}
- if (centerRequested) {
- target.addAttribute("center", true);
- centerRequested = false;
- }
-
// Contents of the window panel is painted
super.paintContent(target);
- // Window position
- target.addVariable(this, "positionx", getPositionX());
- target.addVariable(this, "positiony", getPositionY());
-
// Window closing
target.addVariable(this, "close", false);
}
*/
private void setPositionX(int positionX, boolean repaintRequired) {
this.positionX = positionX;
- centerRequested = false;
+ getState().setCentered(false);
if (repaintRequired) {
requestRepaint();
}
*/
private void setPositionY(int positionY, boolean repaintRequired) {
this.positionY = positionY;
- centerRequested = false;
+ getState().setCentered(false);
if (repaintRequired) {
requestRepaint();
}
* sub-windows only.
*/
public void center() {
- centerRequested = true;
+ getState().setCentered(true);
requestRepaint();
}