]> source.dussan.org Git - vaadin-framework.git/commitdiff
Moved basic Window state attributes to WindowState
authorArtur Signell <artur@vaadin.com>
Mon, 2 Apr 2012 21:56:52 +0000 (00:56 +0300)
committerArtur Signell <artur@vaadin.com>
Wed, 4 Apr 2012 21:08:31 +0000 (00:08 +0300)
src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
src/com/vaadin/ui/Window.java

index f080ced3fa5319bc2cb03757701a67b003bd8e73..a3365c940f95fe2decf65e1cd02e3e8997751420 100644 (file)
@@ -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
index f15b46ce1d053b465bf1040b02a95fe99b0eb756..83be696d54c0d79ae251d36d563d2f4261ecd921 100644 (file)
@@ -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;
@@ -104,12 +103,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)
      */
@@ -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();
     }