@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
VWindow window = getWidget();
WindowState state = getState();
if (state.modal != window.vaadinModality) {
window.setVaadinModality(!window.vaadinModality);
}
if (!window.isAttached()) {
window.setVisible(false); // hide until possible centering
window.show();
}
boolean resizeable = state.resizable
&& state.windowMode == WindowMode.NORMAL;
window.setResizable(resizeable);
window.resizeLazy = state.resizeLazy;
window.setDraggable(state.draggable
&& state.windowMode == WindowMode.NORMAL);
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.
String iconURL = null;
if (getIconUri() != null) {
iconURL = getIconUri();
}
window.setAssistivePrefix(state.assistivePrefix);
window.setAssistivePostfix(state.assistivePostfix);
window.setCaption(state.caption, iconURL);
window.setWaiAriaRole(getState().role);
window.setAssistiveDescription(state.contentDescription);
window.setTabStopEnabled(getState().assistiveTabStop);
window.setTabStopTopAssistiveText(getState().assistiveTabStopTopText);
window.setTabStopBottomAssistiveText(getState().assistiveTabStopBottomText);
clickEventHandler.handleEventHandlerRegistration();
window.immediate = state.immediate;
window.setClosable(!isReadOnly());
// initialize position from state
updateWindowPosition();
// setting scrollposition must happen after children is rendered
window.contentPanel.setScrollPosition(state.scrollTop);
window.contentPanel.setHorizontalScrollPosition(state.scrollLeft);
// 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
// centered is this is unset on move/resize
window.centered = state.centered;
window.setVisible(true);
// ensure window is not larger than browser window
if (window.getOffsetWidth() > Window.getClientWidth()) {
window.setWidth(Window.getClientWidth() + "px");
}
if (window.getOffsetHeight() > Window.getClientHeight()) {
window.setHeight(Window.getClientHeight() + "px");
}
}