summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ui/VWindow.java7
-rw-r--r--client/src/com/vaadin/client/ui/window/WindowConnector.java43
-rw-r--r--server/src/com/vaadin/ui/Window.java117
-rw-r--r--shared/src/com/vaadin/shared/ui/window/WindowMode.java39
-rw-r--r--shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java3
-rw-r--r--shared/src/com/vaadin/shared/ui/window/WindowState.java6
-rw-r--r--uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java22
7 files changed, 132 insertions, 105 deletions
diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java
index bd9a0ed07c..138a7f7adc 100644
--- a/client/src/com/vaadin/client/ui/VWindow.java
+++ b/client/src/com/vaadin/client/ui/VWindow.java
@@ -49,7 +49,7 @@ import com.vaadin.client.LayoutManager;
import com.vaadin.client.Util;
import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
import com.vaadin.shared.EventId;
-import com.vaadin.shared.ui.window.WindowState.DisplayState;
+import com.vaadin.shared.ui.window.WindowMode;
/**
* "Sub window" component.
@@ -571,10 +571,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
}
}
- public void updateMaximizeRestoreClassName(boolean visible,
- DisplayState state) {
+ public void updateMaximizeRestoreClassName(boolean visible, WindowMode windowMode) {
String className;
- if (state == DisplayState.MAXIMIZED) {
+ if (windowMode == WindowMode.MAXIMIZED) {
className = CLASSNAME + "-restorebox";
} else {
className = CLASSNAME + "-maximizebox";
diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java
index 66907fbfa4..f1ea99f3f5 100644
--- a/client/src/com/vaadin/client/ui/window/WindowConnector.java
+++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java
@@ -45,9 +45,9 @@ import com.vaadin.client.ui.VWindow;
import com.vaadin.client.ui.layout.MayScrollChildren;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.shared.ui.window.WindowServerRpc;
import com.vaadin.shared.ui.window.WindowState;
-import com.vaadin.shared.ui.window.WindowState.DisplayState;
@Connect(value = com.vaadin.ui.Window.class)
public class WindowConnector extends AbstractSingleComponentContainerConnector
@@ -245,8 +245,7 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
@Override
public void postLayout() {
VWindow window = getWidget();
- if (window.centered
- && getState().displayState != DisplayState.MAXIMIZED) {
+ if (window.centered && getState().windowMode != WindowMode.MAXIMIZED) {
window.center();
}
window.positionOrSizeUpdated();
@@ -272,16 +271,15 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
window.show();
}
boolean resizeable = state.resizable
- && state.displayState == DisplayState.NORMAL;
+ && state.windowMode == WindowMode.NORMAL;
window.setResizable(resizeable);
window.resizeLazy = state.resizeLazy;
window.setDraggable(state.draggable
- && state.displayState == DisplayState.NORMAL);
+ && state.windowMode == WindowMode.NORMAL);
- window.updateMaximizeRestoreClassName(state.resizable,
- state.displayState);
+ window.updateMaximizeRestoreClassName(state.resizable, state.windowMode);
// Caption must be set before required header size is measured. If
// the caption attribute is missing the caption should be cleared.
@@ -320,12 +318,12 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
}
}
- // Need to override default because of DisplayState
+ // Need to override default because of window mode
@Override
protected void updateComponentSize() {
- if (getState().displayState == DisplayState.NORMAL) {
+ if (getState().windowMode == WindowMode.NORMAL) {
super.updateComponentSize();
- } else if (getState().displayState == DisplayState.MAXIMIZED) {
+ } else if (getState().windowMode == WindowMode.MAXIMIZED) {
super.updateComponentSize("100%", "100%");
}
}
@@ -333,45 +331,44 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
protected void updateWindowPosition() {
VWindow window = getWidget();
WindowState state = getState();
- if (state.displayState == DisplayState.NORMAL) {
+ if (state.windowMode == WindowMode.NORMAL) {
// if centered, position handled in postLayout()
if (!state.centered) {
window.setPopupPosition(state.positionX, state.positionY);
}
- } else if (state.displayState == DisplayState.MAXIMIZED) {
+ } else if (state.windowMode == WindowMode.MAXIMIZED) {
window.setPopupPositionNoUpdate(0, 0);
window.bringToFront();
}
}
- protected void updateDisplayState() {
+ protected void updateWindowMode() {
VWindow window = getWidget();
WindowState state = getState();
// update draggable on widget
window.setDraggable(state.draggable
- && state.displayState == DisplayState.NORMAL);
+ && state.windowMode == WindowMode.NORMAL);
// update resizable on widget
window.setResizable(state.resizable
- && state.displayState == DisplayState.NORMAL);
+ && state.windowMode == WindowMode.NORMAL);
updateComponentSize();
updateWindowPosition();
- window.updateMaximizeRestoreClassName(state.resizable,
- state.displayState);
+ window.updateMaximizeRestoreClassName(state.resizable, state.windowMode);
window.updateContentsSize();
}
protected void onMaximizeRestore() {
WindowState state = getState();
if (state.resizable) {
- if (state.displayState == DisplayState.MAXIMIZED) {
- state.displayState = DisplayState.NORMAL;
+ if (state.windowMode == WindowMode.MAXIMIZED) {
+ state.windowMode = WindowMode.NORMAL;
} else {
- state.displayState = DisplayState.MAXIMIZED;
+ state.windowMode = WindowMode.MAXIMIZED;
}
- updateDisplayState();
- getRpcProxy(WindowServerRpc.class).windowDisplayStateChanged(
- state.displayState);
+ updateWindowMode();
+ getRpcProxy(WindowServerRpc.class).windowModeChanged(
+ state.windowMode);
}
}
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index 479992d084..9f64c9118e 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -35,9 +35,9 @@ import com.vaadin.server.ClientConnector;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.shared.ui.window.WindowServerRpc;
import com.vaadin.shared.ui.window.WindowState;
-import com.vaadin.shared.ui.window.WindowState.DisplayState;
import com.vaadin.util.ReflectTools;
/**
@@ -75,8 +75,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
}
@Override
- public void windowDisplayStateChanged(DisplayState newState) {
- setDisplayState(newState);
+ public void windowModeChanged(WindowMode newState) {
+ setWindowMode(newState);
}
};
@@ -241,8 +241,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
/**
* Gets the distance of Window left border in pixels from left border of the
- * containing (main window) when the window is in
- * {@link DisplayState#NORMAL}.
+ * containing (main window) when the window is in {@link WindowMode#NORMAL}.
*
* @return the Distance of Window left border in pixels from left border of
* the containing (main window).or -1 if unspecified
@@ -254,8 +253,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
/**
* Sets the distance of Window left border in pixels from left border of the
- * containing (main window). Has effect only if in
- * {@link DisplayState#NORMAL} mode.
+ * containing (main window). Has effect only if in {@link WindowMode#NORMAL}
+ * mode.
*
* @param positionX
* the Distance of Window left border in pixels from left border
@@ -269,8 +268,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
/**
* Gets the distance of Window top border in pixels from top border of the
- * containing (main window) when the window is in
- * {@link DisplayState#NORMAL} state, or when next set to that state.
+ * containing (main window) when the window is in {@link WindowMode#NORMAL}
+ * state, or when next set to that state.
*
* @return Distance of Window top border in pixels from top border of the
* containing (main window). or -1 if unspecified
@@ -283,8 +282,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
/**
* Sets the distance of Window top border in pixels from top border of the
- * containing (main window). Has effect only if in
- * {@link DisplayState#NORMAL} mode.
+ * containing (main window). Has effect only if in {@link WindowMode#NORMAL}
+ * mode.
*
* @param positionY
* the Distance of Window top border in pixels from top border of
@@ -413,24 +412,23 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
}
/**
- * Event which is fired when the display state of the Window changes.
+ * Event which is fired when the mode of the Window changes.
*
* @author Vaadin Ltd
* @since 7.1
*
*/
- public static class DisplayStateChangeEvent extends Component.Event {
+ public static class WindowModeChangeEvent extends Component.Event {
- private final DisplayState displayState;
+ private final WindowMode windowMode;
/**
*
* @param source
*/
- public DisplayStateChangeEvent(Component source,
- DisplayState displayState) {
+ public WindowModeChangeEvent(Component source, WindowMode windowMode) {
super(source);
- this.displayState = displayState;
+ this.windowMode = windowMode;
}
/**
@@ -443,73 +441,69 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
}
/**
- * Gets the new DisplayState.
+ * Gets the new window mode.
*
- * @return the displayState
+ * @return the new mode
*/
- public DisplayState getDisplayState() {
- return displayState;
+ public WindowMode getWindowMode() {
+ return windowMode;
}
}
/**
* An interface used for listening to Window maximize / restore events. Add
- * the DisplayStateChangeListener to a window and
- * {@link DisplayStateChangeListener#displayStateChanged(DisplayStateChangeEvent)}
+ * the WindowModeChangeListener to a window and
+ * {@link WindowModeChangeListener#windowModeChanged(WindowModeChangeEvent)}
* will be called whenever the window is maximized (
- * {@link DisplayState#MAXIMIZED}) or restored ({@link DisplayState#NORMAL}
- * ).
+ * {@link WindowMode#MAXIMIZED}) or restored ({@link WindowMode#NORMAL} ).
*/
- public interface DisplayStateChangeListener extends Serializable {
+ public interface WindowModeChangeListener extends Serializable {
- public static final Method displayStateChangeMethod = ReflectTools
- .findMethod(DisplayStateChangeListener.class,
- "displayStateChanged", DisplayStateChangeEvent.class);
+ public static final Method windowModeChangeMethod = ReflectTools
+ .findMethod(WindowModeChangeListener.class,
+ "windowModeChanged", WindowModeChangeEvent.class);
/**
* Called when the user maximizes / restores a window. Use
- * {@link DisplayStateChangeEvent#getWindow()} to get a reference to the
+ * {@link WindowModeChangeEvent#getWindow()} to get a reference to the
* {@link Window} that was maximized / restored. Use
- * {@link DisplayStateChangeEvent#getDisplayState()} to get a reference
- * to the new state.
+ * {@link WindowModeChangeEvent#getWindowMode()} to get a reference to
+ * the new state.
*
* @param event
*/
- public void displayStateChanged(DisplayStateChangeEvent event);
+ public void windowModeChanged(WindowModeChangeEvent event);
}
/**
- * Adds a DisplayStateChangeListener to the window.
+ * Adds a WindowModeChangeListener to the window.
*
- * The DisplayStateChangeEvent is fired when the user changed the display
+ * The WindowModeChangeEvent is fired when the user changed the display
* state by clicking the maximize/restore button or by double clicking on
* the window header. The event is also fired if the state is changed using
- * {@link #setDisplayState(DisplayState)}.
+ * {@link #setWindowMode(WindowMode)}.
*
* @param listener
- * the DisplayStateChangeListener to add.
+ * the WindowModeChangeListener to add.
*/
- public void addDisplayStateChangeListener(
- DisplayStateChangeListener listener) {
- addListener(DisplayStateChangeEvent.class, listener,
- DisplayStateChangeListener.displayStateChangeMethod);
+ public void addWindowModeChangeListener(WindowModeChangeListener listener) {
+ addListener(WindowModeChangeEvent.class, listener,
+ WindowModeChangeListener.windowModeChangeMethod);
}
/**
- * Removes the DisplayStateChangeListener from the window.
+ * Removes the WindowModeChangeListener from the window.
*
* @param listener
- * the DisplayStateChangeListener to remove.
+ * the WindowModeChangeListener to remove.
*/
- public void removeDisplayStateChangeListener(
- DisplayStateChangeListener listener) {
- removeListener(DisplayStateChangeEvent.class, listener,
- DisplayStateChangeListener.displayStateChangeMethod);
+ public void removeWindowModeChangeListener(WindowModeChangeListener listener) {
+ removeListener(WindowModeChangeEvent.class, listener,
+ WindowModeChangeListener.windowModeChangeMethod);
}
- protected void fireWindowDisplayStateChange() {
- fireEvent(new Window.DisplayStateChangeEvent(this,
- getState().displayState));
+ protected void fireWindowWindowModeChange() {
+ fireEvent(new Window.WindowModeChangeEvent(this, getState().windowMode));
}
/**
@@ -782,23 +776,26 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
}
/**
- * Gets the current DisplayState of the window.
+ * Gets the current mode of the window.
*
- * @return displayState the current DisplayState.
+ * @see WindowMode
+ * @return the mode of the window.
*/
- public DisplayState getDisplayState() {
- return getState(false).displayState;
+ public WindowMode getWindowMode() {
+ return getState(false).windowMode;
}
/**
- * Sets the DisplayState for the window.
+ * Sets the mode for the window
*
- * @param displayState
+ * @see WindowMode
+ * @param windowMode
+ * The new mode
*/
- public void setDisplayState(DisplayState displayState) {
- if (displayState != getDisplayState()) {
- getState().displayState = displayState;
- fireWindowDisplayStateChange();
+ public void setWindowMode(WindowMode windowMode) {
+ if (windowMode != getWindowMode()) {
+ getState().windowMode = windowMode;
+ fireWindowWindowModeChange();
}
}
diff --git a/shared/src/com/vaadin/shared/ui/window/WindowMode.java b/shared/src/com/vaadin/shared/ui/window/WindowMode.java
new file mode 100644
index 0000000000..04af77a086
--- /dev/null
+++ b/shared/src/com/vaadin/shared/ui/window/WindowMode.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.ui.window;
+
+/**
+ * Determines the mode of the Window.
+ * <p>
+ * A window mode decides the size and position of the Window. It can be set to
+ * {@link #NORMAL} or {@link #MAXIMIZED}.
+ *
+ *
+ * @author Vaadin Ltd
+ * @since 7.1
+ */
+public enum WindowMode {
+ /**
+ * Normal mode. The window size and position is determined by the window
+ * state.
+ */
+ NORMAL,
+ /**
+ * Maximized mode. The window is positioned in the top left corner and fills
+ * the whole screen.
+ */
+ MAXIMIZED;
+}
diff --git a/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java b/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java
index 0128adca40..cfb10ad86a 100644
--- a/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java
+++ b/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java
@@ -18,11 +18,10 @@ package com.vaadin.shared.ui.window;
import com.vaadin.shared.annotations.Delayed;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.ui.ClickRpc;
-import com.vaadin.shared.ui.window.WindowState.DisplayState;
public interface WindowServerRpc extends ClickRpc, ServerRpc {
@Delayed(lastOnly = true)
- public void windowDisplayStateChanged(DisplayState newState);
+ public void windowModeChanged(WindowMode newState);
} \ No newline at end of file
diff --git a/shared/src/com/vaadin/shared/ui/window/WindowState.java b/shared/src/com/vaadin/shared/ui/window/WindowState.java
index eb6f1c758a..5a2d2b81b0 100644
--- a/shared/src/com/vaadin/shared/ui/window/WindowState.java
+++ b/shared/src/com/vaadin/shared/ui/window/WindowState.java
@@ -22,10 +22,6 @@ public class WindowState extends PanelState {
primaryStyleName = "v-window";
}
- public enum DisplayState {
- NORMAL, MAXIMIZED;
- }
-
public boolean modal = false;
public boolean resizable = true;
public boolean resizeLazy = false;
@@ -33,5 +29,5 @@ public class WindowState extends PanelState {
public boolean centered = false;;
public int positionX = -1;
public int positionY = -1;
- public DisplayState displayState = DisplayState.NORMAL;
+ public WindowMode windowMode = WindowMode.NORMAL;
} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java
index fe45b036a1..a8102a7d1a 100644
--- a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java
+++ b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java
@@ -4,7 +4,7 @@ import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
-import com.vaadin.shared.ui.window.WindowState.DisplayState;
+import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -17,8 +17,8 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.CloseEvent;
import com.vaadin.ui.Window.CloseListener;
-import com.vaadin.ui.Window.DisplayStateChangeEvent;
-import com.vaadin.ui.Window.DisplayStateChangeListener;
+import com.vaadin.ui.Window.WindowModeChangeEvent;
+import com.vaadin.ui.Window.WindowModeChangeListener;
public class WindowMaximizeRestoreTest extends AbstractTestUI {
Button.ClickListener addListener = new Button.ClickListener() {
@@ -72,11 +72,11 @@ public class WindowMaximizeRestoreTest extends AbstractTestUI {
@Override
public void buttonClick(ClickEvent event) {
- if (w.getDisplayState() == DisplayState.MAXIMIZED) {
- w.setDisplayState(DisplayState.NORMAL);
+ if (w.getWindowMode() == WindowMode.MAXIMIZED) {
+ w.setWindowMode(WindowMode.NORMAL);
maximize.setCaption("Maximize");
} else {
- w.setDisplayState(DisplayState.MAXIMIZED);
+ w.setWindowMode(WindowMode.MAXIMIZED);
maximize.setCaption("Restore");
}
}
@@ -85,15 +85,15 @@ public class WindowMaximizeRestoreTest extends AbstractTestUI {
maximize.addClickListener(listener);
((ComponentContainer) w.getContent()).addComponent(maximize);
- w.addDisplayStateChangeListener(new DisplayStateChangeListener() {
+ w.addWindowModeChangeListener(new WindowModeChangeListener() {
@Override
- public void displayStateChanged(DisplayStateChangeEvent event) {
- DisplayState state = (event.getWindow().getDisplayState());
- if (state == DisplayState.NORMAL) {
+ public void windowModeChanged(WindowModeChangeEvent event) {
+ WindowMode state = (event.getWindow().getWindowMode());
+ if (state == WindowMode.NORMAL) {
w.setCaption("Window " + w.getData() + " Normal");
maximize.setCaption("Maximize");
- } else if (state == DisplayState.MAXIMIZED) {
+ } else if (state == WindowMode.MAXIMIZED) {
w.setCaption("Window " + w.getData() + " Maximized");
maximize.setCaption("Restore");
}