import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
-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;
@SuppressWarnings("serial")
public class Window extends Panel implements FocusNotifier, BlurNotifier {
- /**
- * <b>Sub window only</b>. Top offset in pixels for the sub window (relative
- * to the parent application window) or -1 if unspecified.
- */
- private int positionY = -1;
-
- /**
- * <b>Sub window only</b>. Left offset in pixels for the sub window
- * (relative to the parent application window) or -1 if unspecified.
- */
- private int positionX = -1;
-
- /**
- * <b>Sub window only</b>. Modality flag for sub window.
- */
- private boolean modal = false;
-
- /**
- * <b>Sub window only</b>. Controls if the end user can resize the window.
- */
- private boolean resizable = true;
-
- /**
- * <b>Sub window only</b>. Controls if the end user can move the window by
- * dragging.
- */
- private boolean draggable = true;
-
- /**
- * Should resize recalculate layouts lazily (as opposed to immediately)
- */
- private boolean resizeLazy = false;
-
private WindowServerRPC rpc = new WindowServerRPC() {
public void click(MouseEventDetails mouseDetails) {
// Contents of the window panel is painted
super.paintContent(target);
-
- // Window closing
- target.addVariable(this, "close", false);
}
/*
* @since 4.0.0
*/
public int getPositionX() {
- return positionX;
+ return getState().getPositionX();
}
/**
* @since 6.3.4
*/
private void setPositionX(int positionX, boolean repaintRequired) {
- this.positionX = positionX;
+ getState().setPositionX(positionX);
getState().setCentered(false);
if (repaintRequired) {
requestRepaint();
* @since 4.0.0
*/
public int getPositionY() {
- return positionY;
+ return getState().getPositionY();
}
/**
* @since 6.3.4
*/
private void setPositionY(int positionY, boolean repaintRequired) {
- this.positionY = positionY;
+ getState().setPositionY(positionY);
getState().setCentered(false);
if (repaintRequired) {
requestRepaint();
* Sets sub-window modal, so that widgets behind it cannot be accessed.
* <b>Note:</b> affects sub-windows only.
*
- * @param modality
+ * @param modal
* true if modality is to be turned on
*/
- public void setModal(boolean modality) {
- modal = modality;
+ public void setModal(boolean modal) {
+ getState().setModal(modal);
center();
requestRepaint();
}
* @return true if this window is modal.
*/
public boolean isModal() {
- return modal;
+ return getState().isModal();
}
/**
* @param resizable
* true if resizability is to be turned on
*/
- public void setResizable(boolean resizeability) {
- resizable = resizeability;
+ public void setResizable(boolean resizable) {
+ getState().setResizable(resizable);
requestRepaint();
}
* @return true if window is resizable by the end-user, otherwise false.
*/
public boolean isResizable() {
- return resizable;
+ return getState().isResizable();
}
/**
* sizes are recalculated immediately.
*/
public boolean isResizeLazy() {
- return resizeLazy;
+ return getState().isResizeLazy();
}
/**
* calculate immediately.
*/
public void setResizeLazy(boolean resizeLazy) {
- this.resizeLazy = resizeLazy;
+ getState().setResizeLazy(resizeLazy);
requestRepaint();
}
* true if the sub window can be dragged by the user
*/
public boolean isDraggable() {
- return draggable;
+ return getState().isDraggable();
}
/**
* true if the sub window can be dragged by the user
*/
public void setDraggable(boolean draggable) {
- this.draggable = draggable;
+ getState().setDraggable(draggable);
requestRepaint();
}