@Override public void hide() { /* * If the window has a RichTextArea and the RTA is focused at the time * of hiding in IE8 only the window will have some problems returning * the focus to the correct place. Curiously the focus will be returned * correctly if clicking on the "close" button in the window header but * closing the window from a button for example in the window will fail. * Symptom described in #10776 * * The problematic part is that for the focus to be returned correctly * an input element needs to be focused in the root panel. Focusing some * other element apparently won't work. */ if (BrowserInfo.get().isIE8()) { fixIE8FocusCaptureIssue(); } if (vaadinModality) { hideModalityCurtain(); } super.hide(); // Remove window from windowOrder to avoid references being left // hanging. windowOrder.remove(this); }
@Override protected void setZIndex(int zIndex) { super.setZIndex(zIndex); if (vaadinModality) { DOM.setStyleAttribute(getModalityCurtain(), "zIndex", "" + zIndex); } }
// TODO this will eventually be removed, currently used to avoid updating to // server side. public void setPopupPositionNoUpdate(int left, int top) { if (top < 0) { // ensure window is not moved out of browser window from top of the // screen top = 0; } super.setPopupPosition(left, top); }
@Override public void show() { if (!windowOrder.contains(this)) { // This is needed if the window is hidden and then shown again. // Otherwise this VWindow is added to windowOrder in the // constructor. windowOrder.add(this); } if (vaadinModality) { showModalityCurtain(); } super.show(); }
@Override protected void onDetach() { super.onDetach(); /* * Restores the previously stored focused element. * * When the focus was changed outside the window while the window was * open, the originally stored element is restored. */ getApplicationConnection().getUIConnector().getWidget().focusStoredElement(); removeTabBlockHandlers(); }
@Override public void setPopupPosition(int left, int top) { if (top < 0) { // ensure window is not moved out of browser window from top of the // screen top = 0; } super.setPopupPosition(left, top); if (left != uidlPositionX && client != null) { client.updateVariable(id, "positionx", left, false); uidlPositionX = left; } if (top != uidlPositionY && client != null) { client.updateVariable(id, "positiony", top, false); uidlPositionY = top; } }
@Override public void setVisible(boolean visible) { /* * Visibility with VWindow works differently than with other Paintables * in Vaadin. Invisible VWindows are not attached to DOM at all. Flag is * used to avoid visibility call from * ApplicationConnection.updateComponent(); */ if (!visibilityChangesDisabled) { super.setVisible(visible); } if (visible && BrowserInfo.get().isWebkit()) { /* * Shake up the DOM a bit to make the window shed unnecessary * scrollbars and resize correctly afterwards. This resulting code * took over a week to summon forth, and involved some pretty hairy * black magic. Don't touch it unless you know what you're doing! * Fixes ticket #11994 */ Scheduler.get() .scheduleFinally( new ScheduledCommand() { @Override public void execute() { final com.google.gwt.dom.client.Element scrollable = contents.getFirstChildElement(); final String oldWidth = scrollable.getStyle().getWidth(); final String oldHeight = scrollable.getStyle().getHeight(); scrollable.getStyle().setWidth(110, Unit.PCT); scrollable.getOffsetWidth(); scrollable.getStyle().setProperty("width", oldWidth); scrollable.getStyle().setHeight(110, Unit.PCT); scrollable.getOffsetHeight(); scrollable.getStyle().setProperty("height", oldHeight); updateContentsSize(); positionOrSizeUpdated(); } }); } }
@Override protected void onAttach() { super.onAttach(); /* * Stores the element that has focus in the application UI when the * window is opened, so it can be restored when the window closes. * * This is currently implemented for the case when one non-modal window * can be open at the same time, and the focus is not changed while the * window is open. */ getApplicationConnection().getUIConnector().getWidget().storeFocus(); /* * When this window gets reattached, set the tabstop to the previous * state. */ setTabStopEnabled(doTabStop); }
@Override public void onBrowserEvent(final Event event) { boolean bubble = true; final int type = event.getTypeInt(); final Element target = DOM.eventGetTarget(event); if (resizing || resizeBox == target) { onResizeEvent(event); bubble = false; } else if (isClosable() && target == closeBox) { if (type == Event.ONCLICK) { onCloseClick(); } bubble = false; } else if (target == maximizeRestoreBox) { // handled in connector if (type != Event.ONCLICK) { bubble = false; } } else if (header.isOrHasChild(target) && !dragging) { // dblclick handled in connector if (type != Event.ONDBLCLICK && draggable) { if (type == Event.ONMOUSEDOWN) { headerDragPending = event; } else if (type == Event.ONMOUSEMOVE && headerDragPending != null) { // ie won't work unless this is set here dragging = true; onDragEvent(headerDragPending); onDragEvent(event); headerDragPending = null; } else { headerDragPending = null; } bubble = false; } } else if (dragging || !contents.isOrHasChild(target)) { onDragEvent(event); bubble = false; } else if (type == Event.ONCLICK) { // clicked inside window, ensure to be on top if (!isActive()) { bringToFront(); } } /* * If clicking on other than the content, move focus to the window. * After that this windows e.g. gets all keyboard shortcuts. */ if (type == Event.ONMOUSEDOWN && !contentPanel.getElement().isOrHasChild(target) && target != closeBox && target != maximizeRestoreBox) { contentPanel.focus(); } if (!bubble) { event.stopPropagation(); } else { // Super.onBrowserEvent takes care of Handlers added by the // ClickEventHandler super.onBrowserEvent(event); } }