summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-04-03 00:56:52 +0300
committerArtur Signell <artur@vaadin.com>2012-04-05 00:08:31 +0300
commit6a5cf7f2298935c1eb93f9b47db139c6a610d7bf (patch)
treef629bf6990c5e5207c67adbb6b3d206619e2fe0d
parentf17a574249117c669aaf365f737b929961532beb (diff)
downloadvaadin-framework-6a5cf7f2298935c1eb93f9b47db139c6a610d7bf.tar.gz
vaadin-framework-6a5cf7f2298935c1eb93f9b47db139c6a610d7bf.zip
Moved basic Window state attributes to WindowState
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java92
-rw-r--r--src/com/vaadin/ui/Window.java39
2 files changed, 76 insertions, 55 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
index f080ced3fa..a3365c940f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
@@ -35,6 +35,69 @@ public class WindowConnector extends AbstractComponentContainerConnector
}
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;
+ }
}
@@ -74,13 +137,8 @@ public class WindowConnector extends AbstractComponentContainerConnector
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()) {
@@ -88,12 +146,12 @@ public class WindowConnector extends AbstractComponentContainerConnector
// 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.
@@ -118,8 +176,8 @@ public class WindowConnector extends AbstractComponentContainerConnector
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;
@@ -196,13 +254,9 @@ public class WindowConnector extends AbstractComponentContainerConnector
// 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
diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java
index f15b46ce1d..83be696d54 100644
--- a/src/com/vaadin/ui/Window.java
+++ b/src/com/vaadin/ui/Window.java
@@ -23,7 +23,6 @@ import com.vaadin.event.ShortcutListener;
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;
@@ -105,12 +104,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
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)
*/
private boolean resizeLazy = false;
@@ -178,40 +171,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
@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);
}
@@ -344,7 +311,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
*/
private void setPositionX(int positionX, boolean repaintRequired) {
this.positionX = positionX;
- centerRequested = false;
+ getState().setCentered(false);
if (repaintRequired) {
requestRepaint();
}
@@ -391,7 +358,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
*/
private void setPositionY(int positionY, boolean repaintRequired) {
this.positionY = positionY;
- centerRequested = false;
+ getState().setCentered(false);
if (repaintRequired) {
requestRepaint();
}
@@ -676,7 +643,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
* sub-windows only.
*/
public void center() {
- centerRequested = true;
+ getState().setCentered(true);
requestRepaint();
}