Selaa lähdekoodia

Refactor to use the right Element class (#13287)

Changed implementations and APIs to use the non-deprecated Element class
wherever possible without breaking backwards compatibility.
* Methods defined in interfaces have not been touched.
* Return types have only been changed methods that should have no
existing third party callers (i.e. private, internal or @since 7.2)
* For methods that third party code might have overridden, the method
has been deprecated in favor of a new method that just delegates to the
old method.
* For methods that can't reasonably be overridden by third party code
(i.e. private, final, static, internal or @since 7.2), the parameter
type has been changed without retaining the old method.

Change-Id: I7da943a77b8d0d0b9185d8c70f87d676a275d24b
tags/7.2.0.beta1
Leif Åstrand 10 vuotta sitten
vanhempi
commit
a9845c9c10
84 muutettua tiedostoa jossa 938 lisäystä ja 738 poistoa
  1. 6
    7
      client/src/com/vaadin/client/ApplicationConnection.java
  2. 19
    0
      client/src/com/vaadin/client/RenderInformation.java
  3. 20
    2
      client/src/com/vaadin/client/SimpleTree.java
  4. 36
    55
      client/src/com/vaadin/client/Util.java
  5. 9
    11
      client/src/com/vaadin/client/VCaption.java
  6. 14
    0
      client/src/com/vaadin/client/VErrorMessage.java
  7. 3
    2
      client/src/com/vaadin/client/VLoadingIndicator.java
  8. 5
    6
      client/src/com/vaadin/client/VTooltip.java
  9. 45
    21
      client/src/com/vaadin/client/componentlocator/ComponentLocator.java
  10. 21
    32
      client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java
  11. 9
    7
      client/src/com/vaadin/client/componentlocator/LocatorStrategy.java
  12. 20
    28
      client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
  13. 9
    10
      client/src/com/vaadin/client/debug/internal/HierarchySection.java
  14. 13
    15
      client/src/com/vaadin/client/debug/internal/Highlight.java
  15. 2
    1
      client/src/com/vaadin/client/debug/internal/SelectConnectorListener.java
  16. 4
    4
      client/src/com/vaadin/client/debug/internal/SelectorPath.java
  17. 7
    9
      client/src/com/vaadin/client/debug/internal/TestBenchSection.java
  18. 4
    3
      client/src/com/vaadin/client/ui/AbstractClickEventHandler.java
  19. 3
    7
      client/src/com/vaadin/client/ui/FocusElementPanel.java
  20. 3
    9
      client/src/com/vaadin/client/ui/FocusableScrollPanel.java
  21. 5
    4
      client/src/com/vaadin/client/ui/ShortcutActionHandler.java
  22. 2
    1
      client/src/com/vaadin/client/ui/VAbsoluteLayout.java
  23. 8
    10
      client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
  24. 4
    4
      client/src/com/vaadin/client/ui/VAccordion.java
  25. 2
    1
      client/src/com/vaadin/client/ui/VCalendar.java
  26. 4
    4
      client/src/com/vaadin/client/ui/VCalendarPanel.java
  27. 5
    5
      client/src/com/vaadin/client/ui/VCheckBox.java
  28. 3
    3
      client/src/com/vaadin/client/ui/VContextMenu.java
  29. 10
    15
      client/src/com/vaadin/client/ui/VCustomLayout.java
  30. 31
    4
      client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
  31. 17
    3
      client/src/com/vaadin/client/ui/VDragAndDropWrapperIE.java
  32. 2
    1
      client/src/com/vaadin/client/ui/VEmbedded.java
  33. 9
    12
      client/src/com/vaadin/client/ui/VFilterSelect.java
  34. 7
    12
      client/src/com/vaadin/client/ui/VForm.java
  35. 5
    4
      client/src/com/vaadin/client/ui/VFormLayout.java
  36. 27
    4
      client/src/com/vaadin/client/ui/VGridLayout.java
  37. 5
    6
      client/src/com/vaadin/client/ui/VLink.java
  38. 2
    2
      client/src/com/vaadin/client/ui/VMediaBase.java
  39. 22
    6
      client/src/com/vaadin/client/ui/VMenuBar.java
  40. 3
    2
      client/src/com/vaadin/client/ui/VNotification.java
  41. 7
    9
      client/src/com/vaadin/client/ui/VOverlay.java
  42. 7
    10
      client/src/com/vaadin/client/ui/VPanel.java
  43. 2
    1
      client/src/com/vaadin/client/ui/VPopupCalendar.java
  44. 5
    5
      client/src/com/vaadin/client/ui/VPopupView.java
  45. 3
    2
      client/src/com/vaadin/client/ui/VProgressBar.java
  46. 2
    2
      client/src/com/vaadin/client/ui/VRichTextArea.java
  47. 68
    97
      client/src/com/vaadin/client/ui/VScrollTable.java
  48. 8
    10
      client/src/com/vaadin/client/ui/VSlider.java
  49. 21
    22
      client/src/com/vaadin/client/ui/VTabsheet.java
  50. 10
    10
      client/src/com/vaadin/client/ui/VTabsheetPanel.java
  51. 6
    8
      client/src/com/vaadin/client/ui/VTextField.java
  52. 11
    13
      client/src/com/vaadin/client/ui/VTree.java
  53. 21
    30
      client/src/com/vaadin/client/ui/VTreeTable.java
  54. 4
    6
      client/src/com/vaadin/client/ui/VUpload.java
  55. 2
    2
      client/src/com/vaadin/client/ui/VVideo.java
  56. 24
    25
      client/src/com/vaadin/client/ui/VWindow.java
  57. 5
    4
      client/src/com/vaadin/client/ui/VWindowOverlay.java
  58. 21
    0
      client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
  59. 9
    10
      client/src/com/vaadin/client/ui/aria/AriaHelper.java
  60. 3
    4
      client/src/com/vaadin/client/ui/calendar/CalendarConnector.java
  61. 27
    5
      client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java
  62. 2
    2
      client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java
  63. 5
    5
      client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java
  64. 11
    12
      client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java
  65. 4
    4
      client/src/com/vaadin/client/ui/colorpicker/VColorPickerGrid.java
  66. 8
    10
      client/src/com/vaadin/client/ui/dd/DDUtil.java
  67. 6
    12
      client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
  68. 82
    6
      client/src/com/vaadin/client/ui/dd/VDragEvent.java
  69. 3
    2
      client/src/com/vaadin/client/ui/embedded/EmbeddedConnector.java
  70. 2
    6
      client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java
  71. 3
    3
      client/src/com/vaadin/client/ui/layout/VLayoutSlot.java
  72. 13
    13
      client/src/com/vaadin/client/ui/menubar/MenuBar.java
  73. 1
    1
      client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java
  74. 7
    10
      client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
  75. 13
    14
      client/src/com/vaadin/client/ui/orderedlayout/Slot.java
  76. 72
    7
      client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java
  77. 4
    3
      client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java
  78. 1
    3
      client/src/com/vaadin/client/ui/table/TableConnector.java
  79. 1
    3
      client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java
  80. 1
    3
      client/src/com/vaadin/client/ui/tree/TreeConnector.java
  81. 1
    3
      client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java
  82. 2
    2
      client/src/com/vaadin/client/ui/ui/UIConnector.java
  83. 1
    1
      client/src/com/vaadin/client/ui/window/WindowConnector.java
  84. 4
    6
      uitest/src/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java

+ 6
- 7
client/src/com/vaadin/client/ApplicationConnection.java Näytä tiedosto

import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;


// Ensure the overlay container is added to the dom and set as a live // Ensure the overlay container is added to the dom and set as a live
// area for assistive devices // area for assistive devices
com.google.gwt.user.client.Element overlayContainer = VOverlay
.getOverlayContainer(this);
Element overlayContainer = VOverlay.getOverlayContainer(this);
Roles.getAlertRole().setAriaLiveProperty(overlayContainer, Roles.getAlertRole().setAriaLiveProperty(overlayContainer,
LiveValue.ASSERTIVE); LiveValue.ASSERTIVE);
VOverlay.setOverlayContainerLabel(this, VOverlay.setOverlayContainerLabel(this,
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPath(Ljava/lang/String;)(id); return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPath(Ljava/lang/String;)(id);
}); });
client.getElementByPathStartingAt = $entry(function(id, element) { client.getElementByPathStartingAt = $entry(function(id, element) {
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/user/client/Element;)(id, element);
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/dom/client/Element;)(id, element);
}); });
client.getElementsByPath = $entry(function(id) { client.getElementsByPath = $entry(function(id) {
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPath(Ljava/lang/String;)(id); return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPath(Ljava/lang/String;)(id);
}); });
client.getElementsByPathStartingAt = $entry(function(id, element) { client.getElementsByPathStartingAt = $entry(function(id, element) {
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/user/client/Element;)(id, element);
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/dom/client/Element;)(id, element);
}); });
client.getPathForElement = $entry(function(element) { client.getPathForElement = $entry(function(element) {
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element);
return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getPathForElement(Lcom/google/gwt/dom/client/Element;)(element);
}); });
client.initializing = false; client.initializing = false;


* @return Connector for focused element or null. * @return Connector for focused element or null.
*/ */
private ComponentConnector getActiveConnector() { private ComponentConnector getActiveConnector() {
com.google.gwt.user.client.Element focusedElement = Util
.getFocusedElement();
Element focusedElement = Util.getFocusedElement();
if (focusedElement == null) { if (focusedElement == null) {
return null; return null;
} }

+ 19
- 0
client/src/com/vaadin/client/RenderInformation.java Näytä tiedosto

*/ */
package com.vaadin.client; package com.vaadin.client;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;

/** /**
* Contains size information about a rendered container and its content area. * Contains size information about a rendered container and its content area.
* *
* @param widget * @param widget
* *
* @return true if the size has changed since last update * @return true if the size has changed since last update
* @deprecated As of 7.2, call and override {@link #updateSize(Element)}
* instead
*/ */
@Deprecated
public boolean updateSize(com.google.gwt.user.client.Element element) { public boolean updateSize(com.google.gwt.user.client.Element element) {
Size newSize = new Size(element.getOffsetWidth(), Size newSize = new Size(element.getOffsetWidth(),
element.getOffsetHeight()); element.getOffsetHeight());
} }
} }


/**
* Update the size of the widget.
*
* @param widget
*
* @return true if the size has changed since last update
*
* @since 7.2
*/
public boolean updateSize(Element element) {
return updateSize(DOM.asOld(element));
}

@Override @Override
public String toString() { public String toString() {
return "RenderInformation [contentArea=" + contentArea return "RenderInformation [contentArea=" + contentArea

+ 20
- 2
client/src/com/vaadin/client/SimpleTree.java Näytä tiedosto

package com.vaadin.client; package com.vaadin.client;


import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SpanElement; import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Cursor; import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.event.dom.client.HasDoubleClickHandlers; import com.google.gwt.event.dom.client.HasDoubleClickHandlers;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
*/ */
@Deprecated @Deprecated
public class SimpleTree extends ComplexPanel implements HasDoubleClickHandlers { public class SimpleTree extends ComplexPanel implements HasDoubleClickHandlers {
private com.google.gwt.user.client.Element children = Document.get()
.createDivElement().cast();
private Element children = Document.get().createDivElement();
private SpanElement handle = Document.get().createSpanElement(); private SpanElement handle = Document.get().createSpanElement();
private SpanElement text = Document.get().createSpanElement(); private SpanElement text = Document.get().createSpanElement();


add(child, children); add(child, children);
} }


/**
* {@inheritDoc}
*
* @deprecated As of 7.2, call and override {@link #add(Widget, Element)}
* instead.
*/
@Override @Override
@Deprecated
protected void add(Widget child, protected void add(Widget child,
com.google.gwt.user.client.Element container) { com.google.gwt.user.client.Element container) {
super.add(child, container); super.add(child, container);
getElement().getStyle().setPaddingLeft(3, Unit.PX); getElement().getStyle().setPaddingLeft(3, Unit.PX);
} }


/**
* {@inheritDoc}
*
* @since 7.2
*/
@Override
protected void add(Widget child, Element container) {
add(child, DOM.asOld(container));
}

/** /**
* {@inheritDoc} Events are not fired when double clicking child widgets. * {@inheritDoc} Events are not fired when double clicking child widgets.
*/ */

+ 36
- 55
client/src/com/vaadin/client/Util.java Näytä tiedosto

import com.google.gwt.dom.client.AnchorElement; import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.NodeList;
} }
} }


private static final com.google.gwt.user.client.Element escapeHtmlHelper = DOM
.createDiv();
private static final Element escapeHtmlHelper = DOM.createDiv();


/** /**
* Converts html entities to text. * Converts html entities to text.
* @return * @return
*/ */
public static native com.google.gwt.user.client.Element cloneNode( public static native com.google.gwt.user.client.Element cloneNode(
com.google.gwt.user.client.Element element, boolean deep)
Element element, boolean deep)
/*-{ /*-{
return element.cloneNode(deep); return element.cloneNode(deep);
}-*/; }-*/;


public static int measureHorizontalPaddingAndBorder(
com.google.gwt.user.client.Element element, int paddingGuess) {
public static int measureHorizontalPaddingAndBorder(Element element,
int paddingGuess) {
String originalWidth = DOM.getStyleAttribute(element, "width"); String originalWidth = DOM.getStyleAttribute(element, "width");


int originalOffsetWidth = element.getOffsetWidth(); int originalOffsetWidth = element.getOffsetWidth();
return padding; return padding;
} }


public static int measureVerticalPaddingAndBorder(
com.google.gwt.user.client.Element element, int paddingGuess) {
public static int measureVerticalPaddingAndBorder(Element element,
int paddingGuess) {
String originalHeight = DOM.getStyleAttribute(element, "height"); String originalHeight = DOM.getStyleAttribute(element, "height");
int originalOffsetHeight = element.getOffsetHeight(); int originalOffsetHeight = element.getOffsetHeight();
int widthGuess = (originalOffsetHeight - paddingGuess); int widthGuess = (originalOffsetHeight - paddingGuess);
return padding; return padding;
} }


public static int measureHorizontalBorder(
com.google.gwt.user.client.Element element) {
public static int measureHorizontalBorder(Element element) {
int borders; int borders;


if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
return borders; return borders;
} }


public static int measureVerticalBorder(
com.google.gwt.user.client.Element element) {
public static int measureVerticalBorder(Element element) {
int borders; int borders;
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
String width = element.getStyle().getProperty("width"); String width = element.getStyle().getProperty("width");
return borders; return borders;
} }


public static int measureMarginLeft(
com.google.gwt.user.client.Element element) {
public static int measureMarginLeft(Element element) {
return element.getAbsoluteLeft() return element.getAbsoluteLeft()
- element.getParentElement().getAbsoluteLeft(); - element.getParentElement().getAbsoluteLeft();
} }
} }
} }


public static int setWidthExcludingPaddingAndBorder(
com.google.gwt.user.client.Element element, int requestedWidth,
int horizontalPaddingBorderGuess,
public static int setWidthExcludingPaddingAndBorder(Element element,
int requestedWidth, int horizontalPaddingBorderGuess,
boolean requestedWidthIncludesPaddingBorder) { boolean requestedWidthIncludesPaddingBorder) {


int widthGuess = requestedWidth - horizontalPaddingBorderGuess; int widthGuess = requestedWidth - horizontalPaddingBorderGuess;


} }


public static int setHeightExcludingPaddingAndBorder(
com.google.gwt.user.client.Element element, int requestedHeight,
int verticalPaddingBorderGuess,
public static int setHeightExcludingPaddingAndBorder(Element element,
int requestedHeight, int verticalPaddingBorderGuess,
boolean requestedHeightIncludesPaddingBorder) { boolean requestedHeightIncludesPaddingBorder) {


int heightGuess = requestedHeight - verticalPaddingBorderGuess; int heightGuess = requestedHeight - verticalPaddingBorderGuess;
return name.substring(name.lastIndexOf('.') + 1); return name.substring(name.lastIndexOf('.') + 1);
} }


public static void setFloat(com.google.gwt.user.client.Element element,
String value) {
public static void setFloat(Element element, String value) {
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
DOM.setStyleAttribute(element, "styleFloat", value); DOM.setStyleAttribute(element, "styleFloat", value);
} else { } else {


public static int getNativeScrollbarSize() { public static int getNativeScrollbarSize() {
if (detectedScrollbarSize < 0) { if (detectedScrollbarSize < 0) {
com.google.gwt.user.client.Element scroller = DOM.createDiv();
Element scroller = DOM.createDiv();
scroller.getStyle().setProperty("width", "50px"); scroller.getStyle().setProperty("width", "50px");
scroller.getStyle().setProperty("height", "50px"); scroller.getStyle().setProperty("height", "50px");
scroller.getStyle().setProperty("overflow", "scroll"); scroller.getStyle().setProperty("overflow", "scroll");
* @param elem * @param elem
* with overflow auto * with overflow auto
*/ */
public static void runWebkitOverflowAutoFix(
final com.google.gwt.user.client.Element elem) {
public static void runWebkitOverflowAutoFix(final Element elem) {
// Add max version if fix lands sometime to Webkit // Add max version if fix lands sometime to Webkit
// Starting from Opera 11.00, also a problem in Opera // Starting from Opera 11.00, also a problem in Opera
if (BrowserInfo.get().requiresOverflowAutoFix()) { if (BrowserInfo.get().requiresOverflowAutoFix()) {
* element does not belong to a child. * element does not belong to a child.
*/ */
public static ComponentConnector getConnectorForElement( public static ComponentConnector getConnectorForElement(
ApplicationConnection client, Widget parent,
com.google.gwt.user.client.Element element) {
ApplicationConnection client, Widget parent, Element element) {


com.google.gwt.user.client.Element browseElement = element;
com.google.gwt.user.client.Element rootElement = parent.getElement();
Element browseElement = element;
Element rootElement = parent.getElement();


while (browseElement != null && browseElement != rootElement) { while (browseElement != null && browseElement != rootElement) {


if (connector != null) { if (connector != null) {
// check that inside the rootElement // check that inside the rootElement
while (browseElement != null && browseElement != rootElement) { while (browseElement != null && browseElement != rootElement) {
browseElement = (com.google.gwt.user.client.Element) browseElement
.getParentElement();
browseElement = browseElement.getParentElement();
} }
if (browseElement != rootElement) { if (browseElement != rootElement) {
return null; return null;
} }
} }


browseElement = (com.google.gwt.user.client.Element) browseElement
.getParentElement();
browseElement = browseElement.getParentElement();
} }


// No connector found, element is possibly inside a VOverlay // No connector found, element is possibly inside a VOverlay
* @param el * @param el
* the element to focus * the element to focus
*/ */
public static native void focus(com.google.gwt.user.client.Element el)
public static native void focus(Element el)
/*-{ /*-{
try { try {
el.focus(); el.focus();
* the element to start from * the element to start from
*/ */
public static ComponentConnector findPaintable( public static ComponentConnector findPaintable(
ApplicationConnection client,
com.google.gwt.user.client.Element element) {
ApplicationConnection client, Element element) {
Widget widget = Util.findWidget(element, null); Widget widget = Util.findWidget(element, null);
ConnectorMap vPaintableMap = ConnectorMap.get(client); ConnectorMap vPaintableMap = ConnectorMap.get(client);
while (widget != null && !vPaintableMap.isConnector(widget)) { while (widget != null && !vPaintableMap.isConnector(widget)) {
* the Widget type to seek for * the Widget type to seek for
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T findWidget(com.google.gwt.user.client.Element element,
public static <T> T findWidget(Element element,
Class<? extends Widget> class1) { Class<? extends Widget> class1) {
if (element != null) { if (element != null) {
/* First seek for the first EventListener (~Widget) from dom */ /* First seek for the first EventListener (~Widget) from dom */
while (eventListener == null && element != null) { while (eventListener == null && element != null) {
eventListener = Event.getEventListener(element); eventListener = Event.getEventListener(element);
if (eventListener == null) { if (eventListener == null) {
element = (com.google.gwt.user.client.Element) element
.getParentElement();
element = element.getParentElement();
} }
} }
if (eventListener instanceof Widget) { if (eventListener instanceof Widget) {
* @param element * @param element
* The element that should be redrawn * The element that should be redrawn
*/ */
public static void forceWebkitRedraw(
com.google.gwt.user.client.Element element) {
public static void forceWebkitRedraw(Element element) {
Style style = element.getStyle(); Style style = element.getStyle();
String s = style.getProperty("webkitTransform"); String s = style.getProperty("webkitTransform");
if (s == null || s.length() == 0) { if (s == null || s.length() == 0) {
* @param e * @param e
* The element to perform the hack on * The element to perform the hack on
*/ */
public static final void forceIE8Redraw(com.google.gwt.user.client.Element e) {
public static final void forceIE8Redraw(Element e) {
if (BrowserInfo.get().isIE8()) { if (BrowserInfo.get().isIE8()) {
setStyleTemporarily(e, "zoom", "1"); setStyleTemporarily(e, "zoom", "1");
} }
* @param element * @param element
* The element to detach and re-attach * The element to detach and re-attach
*/ */
public static void detachAttach(com.google.gwt.user.client.Element element) {
public static void detachAttach(Element element) {
if (element == null) { if (element == null) {
return; return;
} }


} }


public static void sinkOnloadForImages(
com.google.gwt.user.client.Element element) {
public static void sinkOnloadForImages(Element element) {
NodeList<com.google.gwt.dom.client.Element> imgElements = element NodeList<com.google.gwt.dom.client.Element> imgElements = element
.getElementsByTagName("img"); .getElementsByTagName("img");
for (int i = 0; i < imgElements.getLength(); i++) { for (int i = 0; i < imgElements.getLength(); i++) {
DOM.sinkEvents(
(com.google.gwt.user.client.Element) imgElements.getItem(i),
Event.ONLOAD);
DOM.sinkEvents(imgElements.getItem(i), Event.ONLOAD);
} }


} }
* @param subElement * @param subElement
* @return * @return
*/ */
public static int getChildElementIndex(
com.google.gwt.user.client.Element childElement) {
public static int getChildElementIndex(Element childElement) {
int idx = 0; int idx = 0;
Node n = childElement; Node n = childElement;
while ((n = n.getPreviousSibling()) != null) { while ((n = n.getPreviousSibling()) != null) {
* @param tempValue * @param tempValue
* The temporary value * The temporary value
*/ */
public static void setStyleTemporarily(
com.google.gwt.user.client.Element element,
public static void setStyleTemporarily(Element element,
final String styleProperty, String tempValue) { final String styleProperty, String tempValue) {
final Style style = element.getStyle(); final Style style = element.getStyle();
final String currentValue = style.getProperty(styleProperty); final String currentValue = style.getProperty(styleProperty);
* Get target with element from point as we want the actual element, not * Get target with element from point as we want the actual element, not
* the one that sunk the event. * the one that sunk the event.
*/ */
final com.google.gwt.user.client.Element target = getElementFromPoint(
touch.getClientX(), touch.getClientY());
final Element target = getElementFromPoint(touch.getClientX(),
touch.getClientY());


/* /*
* Fixes infocusable form fields in Safari of iOS 5.x and some Android * Fixes infocusable form fields in Safari of iOS 5.x and some Android
* @param elem * @param elem
* The element to scroll into view * The element to scroll into view
*/ */
public static native void scrollIntoViewVertically(
com.google.gwt.user.client.Element elem)
public static native void scrollIntoViewVertically(Element elem)
/*-{ /*-{
var top = elem.offsetTop; var top = elem.offsetTop;
var height = elem.offsetHeight; var height = elem.offsetHeight;

+ 9
- 11
client/src/com/vaadin/client/VCaption.java Näytä tiedosto

package com.vaadin.client; package com.vaadin.client;


import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;


private final ComponentConnector owner; private final ComponentConnector owner;


private com.google.gwt.user.client.Element errorIndicatorElement;
private Element errorIndicatorElement;


private com.google.gwt.user.client.Element requiredFieldIndicator;
private Element requiredFieldIndicator;


private Icon icon; private Icon icon;


private String iconAltText = ""; private String iconAltText = "";


private com.google.gwt.user.client.Element captionText;
private Element captionText;


private final ApplicationConnection client; private final ApplicationConnection client;


@Override @Override
public void onBrowserEvent(Event event) { public void onBrowserEvent(Event event) {
super.onBrowserEvent(event); super.onBrowserEvent(event);
final com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
final Element target = DOM.eventGetTarget(event);


if (DOM.eventGetType(event) == Event.ONLOAD if (DOM.eventGetType(event) == Event.ONLOAD
&& icon.getElement() == target) { && icon.getElement() == target) {
} }


protected com.google.gwt.user.client.Element getTextElement() { protected com.google.gwt.user.client.Element getTextElement() {
return captionText;
return DOM.asOld(captionText);
} }


public static String getCaptionOwnerPid(com.google.gwt.user.client.Element e) {
public static String getCaptionOwnerPid(Element e) {
return getOwnerPid(e); return getOwnerPid(e);
} }


private native static void setOwnerPid(
com.google.gwt.user.client.Element el, String pid)
private native static void setOwnerPid(Element el, String pid)
/*-{ /*-{
el.vOwnerPid = pid; el.vOwnerPid = pid;
}-*/; }-*/;


public native static String getOwnerPid(
com.google.gwt.user.client.Element el)
public native static String getOwnerPid(Element el)
/*-{ /*-{
return el.vOwnerPid; return el.vOwnerPid;
}-*/; }-*/;

+ 14
- 0
client/src/com/vaadin/client/VErrorMessage.java Näytä tiedosto



package com.vaadin.client; package com.vaadin.client;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
* Shows this error message next to given element. * Shows this error message next to given element.
* *
* @param indicatorElement * @param indicatorElement
* @deprecated As of 7.2, call and override {@link #showAt(Element)} instead
*/ */
@Deprecated
public void showAt(com.google.gwt.user.client.Element indicatorElement) { public void showAt(com.google.gwt.user.client.Element indicatorElement) {
VOverlay errorContainer = (VOverlay) getParent(); VOverlay errorContainer = (VOverlay) getParent();
if (errorContainer == null) { if (errorContainer == null) {


} }


/**
* Shows this error message next to given element.
*
* @param indicatorElement
*
* @since 7.2
*/
public void showAt(Element indicatorElement) {
showAt(DOM.asOld(indicatorElement));
}

public void hide() { public void hide() {
final VOverlay errorContainer = (VOverlay) getParent(); final VOverlay errorContainer = (VOverlay) getParent();
if (errorContainer != null) { if (errorContainer != null) {

+ 3
- 2
client/src/com/vaadin/client/VLoadingIndicator.java Näytä tiedosto



package com.vaadin.client; package com.vaadin.client;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
} }
}; };


private com.google.gwt.user.client.Element element;
private Element element;


/** /**
* Returns the delay (in ms) which must pass before the loading indicator * Returns the delay (in ms) which must pass before the loading indicator
getConnection().getUIConnector().getWidget().getElement() getConnection().getUIConnector().getWidget().getElement()
.appendChild(element); .appendChild(element);
} }
return element;
return DOM.asOld(element);
} }


} }

+ 5
- 6
client/src/com/vaadin/client/VTooltip.java Näytä tiedosto

import com.google.gwt.aria.client.LiveValue; import com.google.gwt.aria.client.LiveValue;
import com.google.gwt.aria.client.RelevantValue; import com.google.gwt.aria.client.RelevantValue;
import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
| Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONMOUSEMOVE | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONMOUSEMOVE
| Event.ONCLICK; | Event.ONCLICK;
VErrorMessage em = new VErrorMessage(); VErrorMessage em = new VErrorMessage();
com.google.gwt.user.client.Element description = DOM.createDiv();
Element description = DOM.createDiv();


private boolean closing = false; private boolean closing = false;
private boolean opening = false; private boolean opening = false;
* Element used in search * Element used in search
* @return true if connector and tooltip found * @return true if connector and tooltip found
*/ */
private boolean resolveConnector(
com.google.gwt.user.client.Element element) {
private boolean resolveConnector(Element element) {


ApplicationConnection ac = getApplicationConnection(); ApplicationConnection ac = getApplicationConnection();
ComponentConnector connector = Util.getConnectorForElement(ac, ComponentConnector connector = Util.getConnectorForElement(ac,


private void handleShowHide(DomEvent domEvent, boolean isFocused) { private void handleShowHide(DomEvent domEvent, boolean isFocused) {
Event event = Event.as(domEvent.getNativeEvent()); Event event = Event.as(domEvent.getNativeEvent());
com.google.gwt.dom.client.Element element = com.google.gwt.user.client.Element
.as(event.getEventTarget());
Element element = Element.as(event.getEventTarget());


// We can ignore move event if it's handled by move or over already // We can ignore move event if it's handled by move or over already
if (currentElement == element && handledByFocus == true) { if (currentElement == element && handledByFocus == true) {
return; return;
} }


boolean connectorAndTooltipFound = resolveConnector((com.google.gwt.user.client.Element) element);
boolean connectorAndTooltipFound = resolveConnector(element);
if (!connectorAndTooltipFound) { if (!connectorAndTooltipFound) {
if (isShowing()) { if (isShowing()) {
handleHideEvent(); handleHideEvent();

+ 45
- 21
client/src/com/vaadin/client/componentlocator/ComponentLocator.java Näytä tiedosto



import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;


/** /**
* The element to generate a path for. * The element to generate a path for.
* @return A String locator that identifies the target element or null if a * @return A String locator that identifies the target element or null if a
* String locator could not be created. * String locator could not be created.
* @deprecated As of 7.2, call and override
* {@link #getPathForElement(Element)} instead
*/ */
@Deprecated
public String getPathForElement( public String getPathForElement(
com.google.gwt.user.client.Element targetElement) { com.google.gwt.user.client.Element targetElement) {
for (LocatorStrategy strategy : locatorStrategies) { for (LocatorStrategy strategy : locatorStrategies) {
return null; return null;
} }


/**
* Generates a String locator which uniquely identifies the target element.
* The {@link #getElementByPath(String)} method can be used for the inverse
* operation, i.e. locating an element based on the return value from this
* method.
* <p>
* Note that getElementByPath(getPathForElement(element)) == element is not
* always true as #getPathForElement(Element) can return a path to another
* element if the widget determines an action on the other element will give
* the same result as the action on the target element.
* </p>
*
* @since 7.2
* @param targetElement
* The element to generate a path for.
* @return A String locator that identifies the target element or null if a
* String locator could not be created.
*/
public String getPathForElement(Element targetElement) {
return getPathForElement(DOM.asOld(targetElement));
}

/** /**
* Locates an element using a String locator (path) which identifies a DOM * Locates an element using a String locator (path) which identifies a DOM
* element. The {@link #getPathForElement(Element)} method can be used for * element. The {@link #getPathForElement(Element)} method can be used for
public com.google.gwt.user.client.Element getElementByPath(String path) { public com.google.gwt.user.client.Element getElementByPath(String path) {
for (LocatorStrategy strategy : locatorStrategies) { for (LocatorStrategy strategy : locatorStrategies) {
if (strategy.validatePath(path)) { if (strategy.validatePath(path)) {
com.google.gwt.user.client.Element element = strategy
.getElementByPath(path);
Element element = strategy.getElementByPath(path);
if (null != element) { if (null != element) {
return element;
return DOM.asOld(element);
} }
} }
} }
* @return The JavaScriptArray of DOM elements identified by {@code path} or * @return The JavaScriptArray of DOM elements identified by {@code path} or
* empty array if elements could not be located. * empty array if elements could not be located.
*/ */
public JsArray<com.google.gwt.user.client.Element> getElementsByPath(
String path) {
JsArray<com.google.gwt.user.client.Element> jsElements = JavaScriptObject
.createArray().cast();
public JsArray<Element> getElementsByPath(String path) {
JsArray<Element> jsElements = JavaScriptObject.createArray().cast();
for (LocatorStrategy strategy : locatorStrategies) { for (LocatorStrategy strategy : locatorStrategies) {
if (strategy.validatePath(path)) { if (strategy.validatePath(path)) {
List<com.google.gwt.user.client.Element> elements = strategy
.getElementsByPath(path);
List<Element> elements = strategy.getElementsByPath(path);
if (elements.size() > 0) { if (elements.size() > 0) {
for (com.google.gwt.user.client.Element e : elements) {
for (Element e : elements) {
jsElements.push(e); jsElements.push(e);
} }
return jsElements; return jsElements;
* @return The JavaScriptArray of DOM elements identified by {@code path} or * @return The JavaScriptArray of DOM elements identified by {@code path} or
* empty array if elements could not be located. * empty array if elements could not be located.
*/ */
public JsArray<com.google.gwt.user.client.Element> getElementsByPathStartingAt(
String path, com.google.gwt.user.client.Element root) {
JsArray<com.google.gwt.user.client.Element> jsElements = JavaScriptObject
.createArray().cast();
public JsArray<Element> getElementsByPathStartingAt(String path,
Element root) {
JsArray<Element> jsElements = JavaScriptObject.createArray().cast();
for (LocatorStrategy strategy : locatorStrategies) { for (LocatorStrategy strategy : locatorStrategies) {
if (strategy.validatePath(path)) { if (strategy.validatePath(path)) {
List<com.google.gwt.user.client.Element> elements = strategy
.getElementsByPathStartingAt(path, root);
List<Element> elements = strategy.getElementsByPathStartingAt(
path, root);
if (elements.size() > 0) { if (elements.size() > 0) {
for (com.google.gwt.user.client.Element e : elements) {
for (Element e : elements) {
jsElements.push(e); jsElements.push(e);
} }
return jsElements; return jsElements;
* *
* @see #getElementByPath(String) * @see #getElementByPath(String)
* *
* @since 7.2
*
* @param path * @param path
* The path of the element to be found * The path of the element to be found
* @param root * @param root
* could not be located. * could not be located.
*/ */
public com.google.gwt.user.client.Element getElementByPathStartingAt( public com.google.gwt.user.client.Element getElementByPathStartingAt(
String path, com.google.gwt.user.client.Element root) {
String path, Element root) {
for (LocatorStrategy strategy : locatorStrategies) { for (LocatorStrategy strategy : locatorStrategies) {
if (strategy.validatePath(path)) { if (strategy.validatePath(path)) {
com.google.gwt.user.client.Element element = strategy
.getElementByPathStartingAt(path, root);
Element element = strategy.getElementByPathStartingAt(path,
root);
if (null != element) { if (null != element) {
return element;
return DOM.asOld(element);
} }
} }
} }

+ 21
- 32
client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java Näytä tiedosto

import java.util.List; import java.util.List;


import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Element;
import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.HasWidgets;
} }


@Override @Override
public String getPathForElement(
com.google.gwt.user.client.Element targetElement) {
public String getPathForElement(Element targetElement) {
ComponentConnector connector = Util ComponentConnector connector = Util
.findPaintable(client, targetElement); .findPaintable(client, targetElement);


* If the widget can provide an identifier for the targetElement we * If the widget can provide an identifier for the targetElement we
* let it do that * let it do that
*/ */
String elementLocator = ((SubPartAware) w)
.getSubPartName(targetElement);
String elementLocator = ((SubPartAware) w).getSubPartName(DOM
.asOld(targetElement));
if (elementLocator != null) { if (elementLocator != null) {
return path + LegacyLocatorStrategy.SUBPART_SEPARATOR return path + LegacyLocatorStrategy.SUBPART_SEPARATOR
+ elementLocator; + elementLocator;
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public com.google.gwt.user.client.Element getElementByPath(String path) {
public Element getElementByPath(String path) {
return getElementByPathStartingAt(path, null); return getElementByPathStartingAt(path, null);
} }


* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public com.google.gwt.user.client.Element getElementByPathStartingAt(
String path, com.google.gwt.user.client.Element baseElement) {
public Element getElementByPathStartingAt(String path, Element baseElement) {
/* /*
* Path is of type "targetWidgetPath#componentPart" or * Path is of type "targetWidgetPath#componentPart" or
* "targetWidgetPath". * "targetWidgetPath".
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List<com.google.gwt.user.client.Element> getElementsByPath(
String path) {
public List<Element> getElementsByPath(String path) {
// This type of search is not supported in LegacyLocator // This type of search is not supported in LegacyLocator
List<com.google.gwt.user.client.Element> array = new ArrayList<com.google.gwt.user.client.Element>();
com.google.gwt.user.client.Element e = getElementByPath(path);
List<Element> array = new ArrayList<Element>();
Element e = getElementByPath(path);
if (e != null) { if (e != null) {
array.add(e); array.add(e);
} }
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List<com.google.gwt.user.client.Element> getElementsByPathStartingAt(
String path, com.google.gwt.user.client.Element root) {
public List<Element> getElementsByPathStartingAt(String path, Element root) {
// This type of search is not supported in LegacyLocator // This type of search is not supported in LegacyLocator
List<com.google.gwt.user.client.Element> array = new ArrayList<com.google.gwt.user.client.Element>();
com.google.gwt.user.client.Element e = getElementByPathStartingAt(path,
root);
List<Element> array = new ArrayList<Element>();
Element e = getElementByPathStartingAt(path, root);
if (e != null) { if (e != null) {
array.add(e); array.add(e);
} }
* @return The widget whose root element is a parent of * @return The widget whose root element is a parent of
* {@code targetElement}. * {@code targetElement}.
*/ */
private Widget findParentWidget(
com.google.gwt.user.client.Element targetElement,
Widget ancestorWidget) {
private Widget findParentWidget(Element targetElement, Widget ancestorWidget) {
/* /*
* As we cannot resolve Widgets from the element we start from the * As we cannot resolve Widgets from the element we start from the
* widget and move downwards to the correct child widget, as long as we * widget and move downwards to the correct child widget, as long as we
* @return The element identified by path, relative to baseElement or null * @return The element identified by path, relative to baseElement or null
* if the element could not be found. * if the element could not be found.
*/ */
private com.google.gwt.user.client.Element getElementByDOMPath(
com.google.gwt.user.client.Element baseElement, String path) {
private Element getElementByDOMPath(Element baseElement, String path) {
String parts[] = path.split(PARENTCHILD_SEPARATOR); String parts[] = path.split(PARENTCHILD_SEPARATOR);
com.google.gwt.user.client.Element element = baseElement;
Element element = baseElement;


for (int i = 0, l = parts.length; i < l; ++i) { for (int i = 0, l = parts.length; i < l; ++i) {
String part = parts[i]; String part = parts[i];


if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) {
if (element.hasChildNodes()) { if (element.hasChildNodes()) {
com.google.gwt.user.client.Element e = element
.getFirstChildElement().cast();
Element e = element.getFirstChildElement().cast();
String cn = e.getClassName(); String cn = e.getClassName();
if (cn != null if (cn != null
&& (cn.equals("v-expand") || cn && (cn.equals("v-expand") || cn
* The starting point for the locator. The generated path is * The starting point for the locator. The generated path is
* relative to this element. * relative to this element.
* @return A String locator that can be used to locate the target element * @return A String locator that can be used to locate the target element
* using
* {@link #getElementByDOMPath(com.google.gwt.user.client.Element, String)}
* or null if the locator String cannot be created.
* using {@link #getElementByDOMPath(Element, String)} or null if
* the locator String cannot be created.
*/ */
private String getDOMPathForElement(
com.google.gwt.user.client.Element element,
com.google.gwt.user.client.Element baseElement) {
com.google.gwt.user.client.Element e = element;
private String getDOMPathForElement(Element element, Element baseElement) {
Element e = element;
String path = ""; String path = "";
while (true) { while (true) {
int childIndex = -1; int childIndex = -1;
com.google.gwt.user.client.Element siblingIterator = e;
Element siblingIterator = e;
while (siblingIterator != null) { while (siblingIterator != null) {
childIndex++; childIndex++;
siblingIterator = siblingIterator.getPreviousSiblingElement() siblingIterator = siblingIterator.getPreviousSiblingElement()

+ 9
- 7
client/src/com/vaadin/client/componentlocator/LocatorStrategy.java Näytä tiedosto



import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;

/** /**
* This interface should be implemented by all locator strategies. A locator * This interface should be implemented by all locator strategies. A locator
* strategy is responsible for generating and decoding a string that identifies * strategy is responsible for generating and decoding a string that identifies
* @return A String locator that identifies the target element or null if a * @return A String locator that identifies the target element or null if a
* String locator could not be created. * String locator could not be created.
*/ */
String getPathForElement(com.google.gwt.user.client.Element targetElement);
String getPathForElement(Element targetElement);


/** /**
* Locates an element using a String locator (path) which identifies a DOM * Locates an element using a String locator (path) which identifies a DOM
* @return The DOM element identified by {@code path} or null if the element * @return The DOM element identified by {@code path} or null if the element
* could not be located. * could not be located.
*/ */
com.google.gwt.user.client.Element getElementByPath(String path);
Element getElementByPath(String path);


/** /**
* Locates an element using a String locator (path) which identifies a DOM * Locates an element using a String locator (path) which identifies a DOM
* @return The DOM element identified by {@code path} or null if the element * @return The DOM element identified by {@code path} or null if the element
* could not be located. * could not be located.
*/ */
com.google.gwt.user.client.Element getElementByPathStartingAt(String path,
com.google.gwt.user.client.Element root);
Element getElementByPathStartingAt(String path,
Element root);


/** /**
* Locates all elements that match a String locator (path) which identifies * Locates all elements that match a String locator (path) which identifies
* @return List that contains all matched elements. Empty list if none * @return List that contains all matched elements. Empty list if none
* found. * found.
*/ */
List<com.google.gwt.user.client.Element> getElementsByPath(String path);
List<Element> getElementsByPath(String path);


/** /**
* Locates all elements that match a String locator (path) which identifies * Locates all elements that match a String locator (path) which identifies
* found. * found.
*/ */


List<com.google.gwt.user.client.Element> getElementsByPathStartingAt(
String path, com.google.gwt.user.client.Element root);
List<Element> getElementsByPathStartingAt(
String path, Element root);
} }

+ 20
- 28
client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java Näytä tiedosto

import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public String getPathForElement(
com.google.gwt.user.client.Element targetElement) {
public String getPathForElement(Element targetElement) {
if (targetElement == null) { if (targetElement == null) {
return ""; return "";
} }
* Target element * Target element
* @return Best selector string formatted with a post filter * @return Best selector string formatted with a post filter
*/ */
private String getBestSelector(List<String> selectors,
com.google.gwt.user.client.Element target) {
private String getBestSelector(List<String> selectors, Element target) {
// The last selector gives us smallest list index for target element. // The last selector gives us smallest list index for target element.
String bestSelector = selectors.get(selectors.size() - 1); String bestSelector = selectors.get(selectors.size() - 1);
int min = getElementsByPath(bestSelector).indexOf(target); int min = getElementsByPath(bestSelector).indexOf(target);
* @return a list of ConnectorPath objects, in descending order towards the * @return a list of ConnectorPath objects, in descending order towards the
* common root container. * common root container.
*/ */
private List<ConnectorPath> getConnectorHierarchyForElement(
com.google.gwt.user.client.Element elem) {
com.google.gwt.user.client.Element e = elem;
private List<ConnectorPath> getConnectorHierarchyForElement(Element elem) {
Element e = elem;
ComponentConnector c = Util.findPaintable(client, e); ComponentConnector c = Util.findPaintable(client, e);
List<ConnectorPath> connectorHierarchy = new ArrayList<ConnectorPath>(); List<ConnectorPath> connectorHierarchy = new ArrayList<ConnectorPath>();


} }
} }


e = (com.google.gwt.user.client.Element) e.getParentElement();
e = e.getParentElement();
if (e != null) { if (e != null) {
c = Util.findPaintable(client, e); c = Util.findPaintable(client, e);
e = c != null ? c.getWidget().getElement() : null; e = c != null ? c.getWidget().getElement() : null;
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List<com.google.gwt.user.client.Element> getElementsByPath(
String path) {
public List<Element> getElementsByPath(String path) {
List<SelectorPredicate> postFilters = SelectorPredicate List<SelectorPredicate> postFilters = SelectorPredicate
.extractPostFilterPredicates(path); .extractPostFilterPredicates(path);
if (postFilters.size() > 0) { if (postFilters.size() > 0) {
path = path.substring(1, path.lastIndexOf(')')); path = path.substring(1, path.lastIndexOf(')'));
} }


List<com.google.gwt.user.client.Element> elements = new ArrayList<com.google.gwt.user.client.Element>();
List<Element> elements = new ArrayList<Element>();
if (isNotificationExpression(path)) { if (isNotificationExpression(path)) {


for (VNotification n : findNotificationsByPath(path)) { for (VNotification n : findNotificationsByPath(path)) {
if (p.getIndex() >= elements.size()) { if (p.getIndex() >= elements.size()) {
elements.clear(); elements.clear();
} else { } else {
com.google.gwt.user.client.Element e = elements.get(p
.getIndex());
Element e = elements.get(p.getIndex());
elements.clear(); elements.clear();
elements.add(e); elements.add(e);
} }
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public com.google.gwt.user.client.Element getElementByPath(String path) {
List<com.google.gwt.user.client.Element> elements = getElementsByPath(path);
public Element getElementByPath(String path) {
List<Element> elements = getElementsByPath(path);
if (elements.isEmpty()) { if (elements.isEmpty()) {
return null; return null;
} }
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public com.google.gwt.user.client.Element getElementByPathStartingAt(
String path, com.google.gwt.user.client.Element root) {
List<com.google.gwt.user.client.Element> elements = getElementsByPathStartingAt(
path, root);
public Element getElementByPathStartingAt(String path, Element root) {
List<Element> elements = getElementsByPathStartingAt(path, root);
if (elements.isEmpty()) { if (elements.isEmpty()) {
return null; return null;
} }
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List<com.google.gwt.user.client.Element> getElementsByPathStartingAt(
String path, com.google.gwt.user.client.Element root) {
public List<Element> getElementsByPathStartingAt(String path, Element root) {
List<SelectorPredicate> postFilters = SelectorPredicate List<SelectorPredicate> postFilters = SelectorPredicate
.extractPostFilterPredicates(path); .extractPostFilterPredicates(path);
if (postFilters.size() > 0) { if (postFilters.size() > 0) {
path = path.substring(1, path.lastIndexOf(')')); path = path.substring(1, path.lastIndexOf(')'));
} }


List<com.google.gwt.user.client.Element> elements = getElementsByPathStartingAtConnector(
path, Util.findPaintable(client, root));
List<Element> elements = getElementsByPathStartingAtConnector(path,
Util.findPaintable(client, root));


for (SelectorPredicate p : postFilters) { for (SelectorPredicate p : postFilters) {
// Post filtering supports only indexes and follows instruction // Post filtering supports only indexes and follows instruction
if (p.getIndex() >= elements.size()) { if (p.getIndex() >= elements.size()) {
elements.clear(); elements.clear();
} else { } else {
com.google.gwt.user.client.Element e = elements.get(p
.getIndex());
Element e = elements.get(p.getIndex());
elements.clear(); elements.clear();
elements.add(e); elements.add(e);
} }
* @return the list of elements identified by path or empty list if not * @return the list of elements identified by path or empty list if not
* found. * found.
*/ */
private List<com.google.gwt.user.client.Element> getElementsByPathStartingAtConnector(
String path, ComponentConnector root) {
private List<Element> getElementsByPathStartingAtConnector(String path,
ComponentConnector root) {
String[] pathComponents = path.split(SUBPART_SEPARATOR); String[] pathComponents = path.split(SUBPART_SEPARATOR);
List<ComponentConnector> connectors; List<ComponentConnector> connectors;
if (pathComponents[0].length() > 0) { if (pathComponents[0].length() > 0) {
connectors = Arrays.asList(root); connectors = Arrays.asList(root);
} }


List<com.google.gwt.user.client.Element> output = new ArrayList<com.google.gwt.user.client.Element>();
List<Element> output = new ArrayList<Element>();
if (null != connectors && !connectors.isEmpty()) { if (null != connectors && !connectors.isEmpty()) {
if (pathComponents.length > 1) { if (pathComponents.length > 1) {
// We have subparts // We have subparts

+ 9
- 10
client/src/com/vaadin/client/debug/internal/HierarchySection.java Näytä tiedosto

*/ */
package com.vaadin.client.debug.internal; package com.vaadin.client.debug.internal;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyCodes;
hierarchyPanel.addListener(new SelectConnectorListener() { hierarchyPanel.addListener(new SelectConnectorListener() {
@Override @Override
public void select(ServerConnector connector, public void select(ServerConnector connector,
com.google.gwt.user.client.Element element) {
Element element) {
printState(connector, true); printState(connector, true);
} }
}); });
analyzeLayoutsPanel.addListener(new SelectConnectorListener() { analyzeLayoutsPanel.addListener(new SelectConnectorListener() {
@Override @Override
public void select(ServerConnector connector, public void select(ServerConnector connector,
com.google.gwt.user.client.Element element) {
Element element) {
printState(connector, true); printState(connector, true);
} }
}); });
} }
if (event.getTypeInt() == Event.ONMOUSEMOVE) { if (event.getTypeInt() == Event.ONMOUSEMOVE) {
Highlight.hideAll(); Highlight.hideAll();
com.google.gwt.user.client.Element eventTarget = Util
.getElementFromPoint(event.getNativeEvent()
.getClientX(), event.getNativeEvent()
.getClientY());
Element eventTarget = Util.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY());
if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) {
infoPanel.clear(); infoPanel.clear();
return; return;
event.consume(); event.consume();
event.getNativeEvent().stopPropagation(); event.getNativeEvent().stopPropagation();
stopFind(); stopFind();
com.google.gwt.user.client.Element eventTarget = Util
.getElementFromPoint(event.getNativeEvent()
.getClientX(), event.getNativeEvent()
.getClientY());
Element eventTarget = Util.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY());
for (ApplicationConnection a : ApplicationConfiguration for (ApplicationConnection a : ApplicationConfiguration
.getRunningApplications()) { .getRunningApplications()) {
ComponentConnector connector = Util.getConnectorForElement( ComponentConnector connector = Util.getConnectorForElement(

+ 13
- 15
client/src/com/vaadin/client/debug/internal/Highlight.java Näytä tiedosto



import java.util.HashSet; import java.util.HashSet;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
private static final int MIN_WIDTH = 3; private static final int MIN_WIDTH = 3;
private static final int MIN_HEIGHT = 3; private static final int MIN_HEIGHT = 3;


static HashSet<com.google.gwt.user.client.Element> highlights;
static HashSet<Element> highlights;


/** /**
* Highlight the {@link Widget} for the given {@link ComponentConnector}. * Highlight the {@link Widget} for the given {@link ComponentConnector}.
* ComponentConnector * ComponentConnector
* @return Highlight element * @return Highlight element
*/ */
static com.google.gwt.user.client.Element show(ComponentConnector connector) {
static Element show(ComponentConnector connector) {
return show(connector, DEFAULT_COLOR); return show(connector, DEFAULT_COLOR);
} }


* @return Highlight element, or <code>null</code> if the connector isn't a * @return Highlight element, or <code>null</code> if the connector isn't a
* component * component
*/ */
static com.google.gwt.user.client.Element showOnly(ServerConnector connector) {
static Element showOnly(ServerConnector connector) {
hideAll(); hideAll();
if (connector instanceof ComponentConnector) { if (connector instanceof ComponentConnector) {
return show((ComponentConnector) connector); return show((ComponentConnector) connector);
* Color of highlight * Color of highlight
* @return Highlight element * @return Highlight element
*/ */
static com.google.gwt.user.client.Element show(
ComponentConnector connector, String color) {
static Element show(ComponentConnector connector, String color) {
if (connector != null) { if (connector != null) {
Widget w = connector.getWidget(); Widget w = connector.getWidget();
return show(w, color); return show(w, color);
* Widget to highlight * Widget to highlight
* @return Highlight element * @return Highlight element
*/ */
static com.google.gwt.user.client.Element show(Widget widget) {
static Element show(Widget widget) {
return show(widget, DEFAULT_COLOR); return show(widget, DEFAULT_COLOR);
} }


* Color of highlight * Color of highlight
* @return Highlight element * @return Highlight element
*/ */
static com.google.gwt.user.client.Element show(Widget widget, String color) {
static Element show(Widget widget, String color) {
if (widget != null) { if (widget != null) {
show(widget.getElement(), color); show(widget.getElement(), color);
} }
* Element to highlight * Element to highlight
* @return Highlight element * @return Highlight element
*/ */
static com.google.gwt.user.client.Element show(
com.google.gwt.user.client.Element element) {
static Element show(Element element) {
return show(element, DEFAULT_COLOR); return show(element, DEFAULT_COLOR);
} }


* Color of highlight * Color of highlight
* @return Highlight element * @return Highlight element
*/ */
static com.google.gwt.user.client.Element show(
com.google.gwt.user.client.Element element, String color) {
static Element show(Element element, String color) {
if (element != null) { if (element != null) {
if (highlights == null) { if (highlights == null) {
highlights = new HashSet<com.google.gwt.user.client.Element>();
highlights = new HashSet<Element>();
} }


com.google.gwt.user.client.Element highlight = DOM.createDiv();
Element highlight = DOM.createDiv();
Style style = highlight.getStyle(); Style style = highlight.getStyle();
style.setTop(element.getAbsoluteTop(), Unit.PX); style.setTop(element.getAbsoluteTop(), Unit.PX);
style.setLeft(element.getAbsoluteLeft(), Unit.PX); style.setLeft(element.getAbsoluteLeft(), Unit.PX);
* @param highlight * @param highlight
* Highlight to hide * Highlight to hide
*/ */
static void hide(com.google.gwt.user.client.Element highlight) {
static void hide(Element highlight) {
if (highlight != null && highlight.getParentElement() != null) { if (highlight != null && highlight.getParentElement() != null) {
highlight.getParentElement().removeChild(highlight); highlight.getParentElement().removeChild(highlight);
highlights.remove(highlight); highlights.remove(highlight);
*/ */
static void hideAll() { static void hideAll() {
if (highlights != null) { if (highlights != null) {
for (com.google.gwt.user.client.Element highlight : highlights) {
for (Element highlight : highlights) {
if (highlight.getParentElement() != null) { if (highlight.getParentElement() != null) {
highlight.getParentElement().removeChild(highlight); highlight.getParentElement().removeChild(highlight);
} }

+ 2
- 1
client/src/com/vaadin/client/debug/internal/SelectConnectorListener.java Näytä tiedosto

*/ */
package com.vaadin.client.debug.internal; package com.vaadin.client.debug.internal;


import com.google.gwt.dom.client.Element;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;


/** /**
* selected element of the connector or null if unknown * selected element of the connector or null if unknown
*/ */
public void select(ServerConnector connector, public void select(ServerConnector connector,
com.google.gwt.user.client.Element element);
Element element);
} }

+ 4
- 4
client/src/com/vaadin/client/debug/internal/SelectorPath.java Näytä tiedosto

import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


import com.google.gwt.dom.client.Element;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.componentlocator.ComponentLocator; import com.vaadin.client.componentlocator.ComponentLocator;
import com.vaadin.client.componentlocator.SelectorPredicate; import com.vaadin.client.componentlocator.SelectorPredicate;
*/ */
public class SelectorPath { public class SelectorPath {
private final String path; private final String path;
private final com.google.gwt.user.client.Element element;
private final Element element;
private final ComponentLocator locator; private final ComponentLocator locator;
private static Map<String, Integer> counter = new HashMap<String, Integer>(); private static Map<String, Integer> counter = new HashMap<String, Integer>();
private static Map<String, String> legacyNames = new HashMap<String, String>(); private static Map<String, String> legacyNames = new HashMap<String, String>();
legacyNames.put("ScrollTable", "Table"); legacyNames.put("ScrollTable", "Table");
} }


protected SelectorPath(ServerConnector c,
com.google.gwt.user.client.Element e) {
protected SelectorPath(ServerConnector c, Element e) {
element = e; element = e;
locator = new ComponentLocator(c.getConnection()); locator = new ComponentLocator(c.getConnection());
path = locator.getPathForElement(e); path = locator.getPathForElement(e);
return path; return path;
} }


public com.google.gwt.user.client.Element getElement() {
public Element getElement() {
return element; return element;
} }



+ 7
- 9
client/src/com/vaadin/client/debug/internal/TestBenchSection.java Näytä tiedosto

import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyCodes;
public void onMouseOver(MouseOverEvent event) { public void onMouseOver(MouseOverEvent event) {
Highlight.hideAll(); Highlight.hideAll();


com.google.gwt.user.client.Element element = path.getElement();
Element element = path.getElement();
if (null != element) { if (null != element) {
Highlight.show(element); Highlight.show(element);
} }
Highlight.hideAll(); Highlight.hideAll();
} }


private void pickSelector(ServerConnector connector,
com.google.gwt.user.client.Element element) {
private void pickSelector(ServerConnector connector, Element element) {


SelectorPath p = new SelectorPath(connector, Util SelectorPath p = new SelectorPath(connector, Util
.findPaintable(connector.getConnection(), element).getWidget() .findPaintable(connector.getConnection(), element).getWidget()
} }
if (event.getTypeInt() == Event.ONMOUSEMOVE if (event.getTypeInt() == Event.ONMOUSEMOVE
|| event.getTypeInt() == Event.ONCLICK) { || event.getTypeInt() == Event.ONCLICK) {
com.google.gwt.user.client.Element eventTarget = Util
.getElementFromPoint(event.getNativeEvent()
.getClientX(), event.getNativeEvent()
.getClientY());
Element eventTarget = Util.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY());
if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) {
if (isFindMode() && event.getTypeInt() == Event.ONCLICK) { if (isFindMode() && event.getTypeInt() == Event.ONCLICK) {
stopFind(); stopFind();


}; };


private ComponentConnector findConnector(
com.google.gwt.user.client.Element element) {
private ComponentConnector findConnector(Element element) {
for (ApplicationConnection a : ApplicationConfiguration for (ApplicationConnection a : ApplicationConfiguration
.getRunningApplications()) { .getRunningApplications()) {
ComponentConnector connector = Util.getConnectorForElement(a, a ComponentConnector connector = Util.getConnectorForElement(a, a

+ 4
- 3
client/src/com/vaadin/client/ui/AbstractClickEventHandler.java Näytä tiedosto

*/ */
package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.event.dom.client.ContextMenuHandler; import com.google.gwt.event.dom.client.ContextMenuHandler;
/** /**
* The element where the last mouse down event was registered. * The element where the last mouse down event was registered.
*/ */
private com.google.gwt.user.client.Element lastMouseDownTarget;
private Element lastMouseDownTarget;


/** /**
* Set to true by {@link #mouseUpPreviewHandler} if it gets a mouseup at the * Set to true by {@link #mouseUpPreviewHandler} if it gets a mouseup at the


// Event's reported target not always correct if event // Event's reported target not always correct if event
// capture is in use // capture is in use
com.google.gwt.user.client.Element elementUnderMouse = Util
.getElementUnderMouse(event.getNativeEvent());
Element elementUnderMouse = Util.getElementUnderMouse(event
.getNativeEvent());
if (lastMouseDownTarget != null if (lastMouseDownTarget != null
&& elementUnderMouse == lastMouseDownTarget) { && elementUnderMouse == lastMouseDownTarget) {
mouseUpPreviewMatched = true; mouseUpPreviewMatched = true;

+ 3
- 7
client/src/com/vaadin/client/ui/FocusElementPanel.java Näytä tiedosto

style.setLeft(0, Unit.PX); style.setLeft(0, Unit.PX);
getElement().appendChild(focusElement); getElement().appendChild(focusElement);
/* Sink from focusElement too as focus and blur don't bubble */ /* Sink from focusElement too as focus and blur don't bubble */
DOM.sinkEvents(
(com.google.gwt.user.client.Element) focusElement.cast(),
Event.FOCUSEVENTS);
DOM.sinkEvents(focusElement, Event.FOCUSEVENTS);
// revert to original, not focusable // revert to original, not focusable
getElement().setPropertyObject("tabIndex", null); getElement().setPropertyObject("tabIndex", null);
} else { } else {
@Override @Override
public void setFocus(boolean focus) { public void setFocus(boolean focus) {
if (focus) { if (focus) {
FocusImpl.getFocusImplForPanel().focus(
(com.google.gwt.user.client.Element) focusElement.cast());
FocusImpl.getFocusImplForPanel().focus(focusElement);
} else { } else {
FocusImpl.getFocusImplForPanel().blur(
(com.google.gwt.user.client.Element) focusElement.cast());
FocusImpl.getFocusImplForPanel().blur(focusElement);
} }
} }



+ 3
- 9
client/src/com/vaadin/client/ui/FocusableScrollPanel.java Näytä tiedosto

style.setLeft(0, Unit.PX); style.setLeft(0, Unit.PX);
getElement().appendChild(focusElement); getElement().appendChild(focusElement);
/* Sink from focusElemet too as focusa and blur don't bubble */ /* Sink from focusElemet too as focusa and blur don't bubble */
DOM.sinkEvents(
(com.google.gwt.user.client.Element) focusElement
.cast(), Event.FOCUSEVENTS);
DOM.sinkEvents(focusElement, Event.FOCUSEVENTS);
// revert to original, not focusable // revert to original, not focusable
getElement().setPropertyObject("tabIndex", null); getElement().setPropertyObject("tabIndex", null);


public void setFocus(boolean focus) { public void setFocus(boolean focus) {
if (useFakeFocusElement()) { if (useFakeFocusElement()) {
if (focus) { if (focus) {
FocusImpl.getFocusImplForPanel().focus(
(com.google.gwt.user.client.Element) focusElement
.cast());
FocusImpl.getFocusImplForPanel().focus(focusElement);
} else { } else {
FocusImpl.getFocusImplForPanel().blur(
(com.google.gwt.user.client.Element) focusElement
.cast());
FocusImpl.getFocusImplForPanel().blur(focusElement);
} }
} else { } else {
super.setFocus(focus); super.setFocus(focus);

+ 5
- 4
client/src/com/vaadin/client/ui/ShortcutActionHandler.java Näytä tiedosto

import java.util.Iterator; import java.util.Iterator;


import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;


private void fireAction(final Event event, final ShortcutAction a, private void fireAction(final Event event, final ShortcutAction a,
ComponentConnector target) { ComponentConnector target) {
final com.google.gwt.user.client.Element et = DOM.eventGetTarget(event);
final Element et = DOM.eventGetTarget(event);
if (target == null) { if (target == null) {
target = Util.findPaintable(client, et); target = Util.findPaintable(client, et);
} }
* <p> * <p>
* TODO separate opera impl with generator * TODO separate opera impl with generator
*/ */
private static void shakeTarget(final com.google.gwt.user.client.Element e) {
private static void shakeTarget(final Element e) {
blur(e); blur(e);
if (BrowserInfo.get().isOpera()) { if (BrowserInfo.get().isOpera()) {
// will mess up with focus and blur event if the focus is not // will mess up with focus and blur event if the focus is not
} }
} }


private static native void blur(com.google.gwt.user.client.Element e)
private static native void blur(Element e)
/*-{ /*-{
if(e.blur) { if(e.blur) {
e.blur(); e.blur();
} }
}-*/; }-*/;


private static native void focus(com.google.gwt.user.client.Element e)
private static native void focus(Element e)
/*-{ /*-{
if(e.blur) { if(e.blur) {
e.focus(); e.focus();

+ 2
- 1
client/src/com/vaadin/client/ui/VAbsoluteLayout.java Näytä tiedosto



import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;


private DivElement marginElement; private DivElement marginElement;


protected final com.google.gwt.user.client.Element canvas = DOM.createDiv();
protected final Element canvas = DOM.createDiv();


/** /**
* Default constructor * Default constructor

+ 8
- 10
client/src/com/vaadin/client/ui/VAbstractSplitPanel.java Näytä tiedosto

import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.TouchCancelEvent; import com.google.gwt.event.dom.client.TouchCancelEvent;


Widget secondChild; Widget secondChild;


private final com.google.gwt.user.client.Element wrapper = DOM.createDiv();
private final Element wrapper = DOM.createDiv();


private final com.google.gwt.user.client.Element firstContainer = DOM
.createDiv();
private final Element firstContainer = DOM.createDiv();


private final com.google.gwt.user.client.Element secondContainer = DOM
.createDiv();
private final Element secondContainer = DOM.createDiv();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element splitter = DOM.createDiv();
public final Element splitter = DOM.createDiv();


private boolean resizing; private boolean resizing;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public List<String> componentStyleNames = Collections.emptyList(); public List<String> componentStyleNames = Collections.emptyList();


private com.google.gwt.user.client.Element draggingCurtain;
private Element draggingCurtain;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public ApplicationConnection client; public ApplicationConnection client;


private TouchScrollHandler touchScrollHandler; private TouchScrollHandler touchScrollHandler;


protected com.google.gwt.user.client.Element scrolledContainer;
protected Element scrolledContainer;


protected int origScrollTop; protected int origScrollTop;


if (locked || !isEnabled()) { if (locked || !isEnabled()) {
return; return;
} }
final com.google.gwt.user.client.Element trg = event.getEventTarget()
.cast();
final Element trg = event.getEventTarget().cast();
if (trg == splitter || trg == DOM.getChild(splitter, 0)) { if (trg == splitter || trg == DOM.getChild(splitter, 0)) {
resizing = true; resizing = true;
DOM.setCapture(getElement()); DOM.setCapture(getElement());

+ 4
- 4
client/src/com/vaadin/client/ui/VAccordion.java Näytä tiedosto

import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;


private VCaption caption; private VCaption caption;
private boolean open = false; private boolean open = false;
private com.google.gwt.user.client.Element content = DOM.createDiv();
private com.google.gwt.user.client.Element captionNode = DOM
.createDiv();
private Element content = DOM.createDiv();
private Element captionNode = DOM.createDiv();
private String styleName; private String styleName;


public StackItem(UIDL tabUidl) { public StackItem(UIDL tabUidl) {
} }


public com.google.gwt.user.client.Element getContainerElement() { public com.google.gwt.user.client.Element getContainerElement() {
return content;
return DOM.asOld(content);
} }


public Widget getChildWidget() { public Widget getChildWidget() {

+ 2
- 1
client/src/com/vaadin/client/ui/VCalendar.java Näytä tiedosto

import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.event.dom.client.ContextMenuHandler; import com.google.gwt.event.dom.client.ContextMenuHandler;
import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
* @param e * @param e
* The element to apply the hack on * The element to apply the hack on
*/ */
private native void blockSelect(com.google.gwt.user.client.Element e)
private native void blockSelect(Element e)
/*-{ /*-{
e.onselectstart = function() { e.onselectstart = function() {
return false; return false;

+ 4
- 4
client/src/com/vaadin/client/ui/VCalendarPanel.java Näytä tiedosto



import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.aria.client.SelectedValue; import com.google.gwt.aria.client.SelectedValue;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.BlurHandler;
* @param subElement * @param subElement
* @return true if {@code w} is a parent of subElement, false otherwise. * @return true if {@code w} is a parent of subElement, false otherwise.
*/ */
private boolean contains(Widget w,
com.google.gwt.user.client.Element subElement) {
private boolean contains(Widget w, Element subElement) {
if (w == null || w.getElement() == null) { if (w == null || w.getElement() == null) {
return false; return false;
} }
} }


if (SUBPART_MONTH_YEAR_HEADER.equals(subPart)) { if (SUBPART_MONTH_YEAR_HEADER.equals(subPart)) {
return (com.google.gwt.user.client.Element) getCellFormatter()
.getElement(0, 2).getChild(0);
return DOM.asOld((Element) getCellFormatter().getElement(0, 2)
.getChild(0));
} }
return null; return null;
} }

+ 5
- 5
client/src/com/vaadin/client/ui/VCheckBox.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
public ApplicationConnection client; public ApplicationConnection client;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element errorIndicatorElement;
public Element errorIndicatorElement;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public Icon icon; public Icon icon;
public VCheckBox() { public VCheckBox() {
setStyleName(CLASSNAME); setStyleName(CLASSNAME);


com.google.gwt.user.client.Element el = DOM.getFirstChild(getElement());
Element el = DOM.getFirstChild(getElement());
while (el != null) { while (el != null) {
DOM.sinkEvents(el, DOM.sinkEvents(el,
(DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS)); (DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS));
* *
* @return Element of the CheckBox itself * @return Element of the CheckBox itself
*/ */
private com.google.gwt.user.client.Element getCheckBoxElement() {
private Element getCheckBoxElement() {
// FIXME: Would love to use a better way to access the checkbox element // FIXME: Would love to use a better way to access the checkbox element
return (com.google.gwt.user.client.Element) getElement()
.getFirstChildElement();
return getElement().getFirstChildElement();
} }


@Override @Override

+ 3
- 3
client/src/com/vaadin/client/ui/VContextMenu.java Näytä tiedosto



import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableRowElement;
import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.dom.client.TableSectionElement;


private int top; private int top;


private com.google.gwt.user.client.Element focusedElement;
private Element focusedElement;


private VLazyExecutor delayedImageLoadExecutioner = new VLazyExecutor(100, private VLazyExecutor delayedImageLoadExecutioner = new VLazyExecutor(100,
new ScheduledCommand() { new ScheduledCommand() {
addCloseHandler(new CloseHandler<PopupPanel>() { addCloseHandler(new CloseHandler<PopupPanel>() {
@Override @Override
public void onClose(CloseEvent<PopupPanel> event) { public void onClose(CloseEvent<PopupPanel> event) {
com.google.gwt.user.client.Element currentFocus = Util
.getFocusedElement();
Element currentFocus = Util.getFocusedElement();
if (focusedElement != null if (focusedElement != null
&& (currentFocus == null && (currentFocus == null
|| menu.getElement().isOrHasChild(currentFocus) || RootPanel || menu.getElement().isOrHasChild(currentFocus) || RootPanel

+ 10
- 15
client/src/com/vaadin/client/ui/VCustomLayout.java Näytä tiedosto

import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.ImageElement; import com.google.gwt.dom.client.ImageElement;
import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
public static final String CLASSNAME = "v-customlayout"; public static final String CLASSNAME = "v-customlayout";


/** Location-name to containing element in DOM map */ /** Location-name to containing element in DOM map */
private final HashMap<String, com.google.gwt.user.client.Element> locationToElement = new HashMap<String, com.google.gwt.user.client.Element>();
private final HashMap<String, Element> locationToElement = new HashMap<String, Element>();


/** Location-name to contained widget map */ /** Location-name to contained widget map */
final HashMap<String, Widget> locationToWidget = new HashMap<String, Widget>(); final HashMap<String, Widget> locationToWidget = new HashMap<String, Widget>();


private boolean htmlInitialized = false; private boolean htmlInitialized = false;


private com.google.gwt.user.client.Element elementWithNativeResizeFunction;
private Element elementWithNativeResizeFunction;


private String height = ""; private String height = "";


} }


// If no given location is found in the layout, and exception is throws // If no given location is found in the layout, and exception is throws
com.google.gwt.user.client.Element elem = locationToElement
.get(location);
Element elem = locationToElement.get(location);
if (elem == null && hasTemplate()) { if (elem == null && hasTemplate()) {
throw new IllegalArgumentException("No location " + location throw new IllegalArgumentException("No location " + location
+ " found"); + " found");
} }


/** Collect locations from template */ /** Collect locations from template */
private void scanForLocations(com.google.gwt.user.client.Element elem) {
private void scanForLocations(Element elem) {


final String location = elem.getAttribute("location"); final String location = elem.getAttribute("location");
if (!"".equals(location)) { if (!"".equals(location)) {
* parent about possible size change. * parent about possible size change.
*/ */
private void initImgElements() { private void initImgElements() {
NodeList<com.google.gwt.dom.client.Element> nodeList = getElement()
.getElementsByTagName("IMG");
NodeList<Element> nodeList = getElement().getElementsByTagName("IMG");
for (int i = 0; i < nodeList.getLength(); i++) { for (int i = 0; i < nodeList.getLength(); i++) {
com.google.gwt.dom.client.ImageElement img = (ImageElement) nodeList
.getItem(i);
DOM.sinkEvents((com.google.gwt.user.client.Element) img.cast(),
Event.ONLOAD);
ImageElement img = ImageElement.as(nodeList.getItem(i));
DOM.sinkEvents(img, Event.ONLOAD);
} }
} }


} }
} }


private native void detachResizedFunction(
com.google.gwt.user.client.Element element)
private native void detachResizedFunction(Element element)
/*-{ /*-{
element.notifyChildrenOfSizeChange = null; element.notifyChildrenOfSizeChange = null;
}-*/; }-*/;


private native void publishResizedFunction(
com.google.gwt.user.client.Element element)
private native void publishResizedFunction(Element element)
/*-{ /*-{
var self = this; var self = this;
element.notifyChildrenOfSizeChange = $entry(function() { element.notifyChildrenOfSizeChange = $entry(function() {

+ 31
- 4
client/src/com/vaadin/client/ui/VDragAndDropWrapper.java Näytä tiedosto

import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler; import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.TouchStartEvent; import com.google.gwt.event.dom.client.TouchStartEvent;
import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.dom.client.TouchStartHandler;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
transferable.setDragSource(getConnector()); transferable.setDragSource(getConnector());


ComponentConnector paintable = Util.findPaintable(client, ComponentConnector paintable = Util.findPaintable(client,
(com.google.gwt.user.client.Element) event.getEventTarget()
.cast());
Element.as(event.getEventTarget()));
Widget widget = paintable.getWidget(); Widget widget = paintable.getWidget();
transferable.setData("component", paintable); transferable.setData("component", paintable);
VDragEvent dragEvent = VDragAndDropManager.get().startDrag( VDragEvent dragEvent = VDragAndDropManager.get().startDrag(
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public ValueMap html5DataFlavors; public ValueMap html5DataFlavors;


private com.google.gwt.user.client.Element dragStartElement;
private Element dragStartElement;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public void initDragStartMode() { public void initDragStartMode() {
com.google.gwt.user.client.Element div = getElement();
Element div = getElement();
if (dragStartMode == HTML5) { if (dragStartMode == HTML5) {
if (dragStartElement == null) { if (dragStartElement == null) {
dragStartElement = getDragStartElement(); dragStartElement = getDragStartElement();
return ConnectorMap.get(client).getConnector(this); return ConnectorMap.get(client).getConnector(this);
} }


/**
* @deprecated As of 7.2, call or override
* {@link #hookHtml5DragStart(Element)} instead
*/
@Deprecated
protected native void hookHtml5DragStart( protected native void hookHtml5DragStart(
com.google.gwt.user.client.Element el) com.google.gwt.user.client.Element el)
/*-{ /*-{
}), false); }), false);
}-*/; }-*/;


/**
* @since 7.2
*/
protected void hookHtml5DragStart(Element el) {
hookHtml5DragStart(DOM.asOld(el));
}

/** /**
* Prototype code, memory leak risk. * Prototype code, memory leak risk.
* *
* @param el * @param el
* @deprecated As of 7.2, call or override {@link #hookHtml5Events(Element)}
* instead
*/ */
@Deprecated
protected native void hookHtml5Events(com.google.gwt.user.client.Element el) protected native void hookHtml5Events(com.google.gwt.user.client.Element el)
/*-{ /*-{
var me = this; var me = this;
}), false); }), false);
}-*/; }-*/;


/**
* Prototype code, memory leak risk.
*
* @param el
*
* @since 7.2
*/
protected void hookHtml5Events(Element el) {
hookHtml5Events(DOM.asOld(el));
}

public boolean updateDropDetails(VDragEvent drag) { public boolean updateDropDetails(VDragEvent drag) {
VerticalDropLocation oldVL = verticalDropLocation; VerticalDropLocation oldVL = verticalDropLocation;
verticalDropLocation = DDUtil.getVerticalDropLocation(getElement(), verticalDropLocation = DDUtil.getVerticalDropLocation(getElement(),

+ 17
- 3
client/src/com/vaadin/client/ui/VDragAndDropWrapperIE.java Näytä tiedosto



import com.google.gwt.dom.client.AnchorElement; import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;


public class VDragAndDropWrapperIE extends VDragAndDropWrapper { public class VDragAndDropWrapperIE extends VDragAndDropWrapper {
@Override @Override
protected com.google.gwt.user.client.Element getDragStartElement() { protected com.google.gwt.user.client.Element getDragStartElement() {
VConsole.log("IE get drag start element..."); VConsole.log("IE get drag start element...");
com.google.gwt.user.client.Element div = getElement();
Element div = getElement();
if (dragStartMode == HTML5) { if (dragStartMode == HTML5) {
if (anchor == null) { if (anchor == null) {
anchor = Document.get().createAnchorElement(); anchor = Document.get().createAnchorElement();
div.appendChild(anchor); div.appendChild(anchor);
} }
VConsole.log("IE get drag start element..."); VConsole.log("IE get drag start element...");
return (com.google.gwt.user.client.Element) anchor.cast();
return anchor.cast();
} else { } else {
if (anchor != null) { if (anchor != null) {
div.removeChild(anchor); div.removeChild(anchor);
anchor = null; anchor = null;
} }
return div;
return DOM.asOld(div);
} }
} }


@Deprecated
@Override @Override
protected native void hookHtml5DragStart( protected native void hookHtml5DragStart(
com.google.gwt.user.client.Element el) com.google.gwt.user.client.Element el)
})); }));
}-*/; }-*/;


@Override
protected void hookHtml5DragStart(Element el) {
hookHtml5DragStart(DOM.asOld(el));
}

@Deprecated
@Override @Override
protected native void hookHtml5Events(com.google.gwt.user.client.Element el) protected native void hookHtml5Events(com.google.gwt.user.client.Element el)
/*-{ /*-{
})); }));
}-*/; }-*/;


@Override
protected void hookHtml5Events(Element el) {
hookHtml5Events(DOM.asOld(el));
}

} }

+ 2
- 1
client/src/com/vaadin/client/ui/VEmbedded.java Näytä tiedosto

import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
public static String CLASSNAME = "v-embedded"; public static String CLASSNAME = "v-embedded";


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element browserElement;
public Element browserElement;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public String type; public String type;

+ 9
- 12
client/src/com/vaadin/client/ui/VFilterSelect.java Näytä tiedosto

import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final SuggestionMenu menu; public final SuggestionMenu menu;


private final com.google.gwt.user.client.Element up = DOM.createDiv();
private final com.google.gwt.user.client.Element down = DOM.createDiv();
private final com.google.gwt.user.client.Element status = DOM
.createDiv();
private final Element up = DOM.createDiv();
private final Element down = DOM.createDiv();
private final Element status = DOM.createDiv();


private boolean isPagingEnabled = true; private boolean isPagingEnabled = true;




getElement().getStyle().setZIndex(Z_INDEX); getElement().getStyle().setZIndex(Z_INDEX);


final com.google.gwt.user.client.Element root = getContainerElement();
final Element root = getContainerElement();


up.setInnerHTML("<span>Prev</span>"); up.setInnerHTML("<span>Prev</span>");
DOM.sinkEvents(up, Event.ONCLICK); DOM.sinkEvents(up, Event.ONCLICK);
public void onBrowserEvent(Event event) { public void onBrowserEvent(Event event) {
debug("VFS.SP: onBrowserEvent()"); debug("VFS.SP: onBrowserEvent()");
if (event.getTypeInt() == Event.ONCLICK) { if (event.getTypeInt() == Event.ONCLICK) {
final com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
final Element target = DOM.eventGetTarget(event);
if (target == up || target == DOM.getChild(up, 0)) { if (target == up || target == DOM.getChild(up, 0)) {
lazyPageScroller.scrollUp(); lazyPageScroller.scrollUp();
} else if (target == down || target == DOM.getChild(down, 0)) { } else if (target == down || target == DOM.getChild(down, 0)) {
offsetHeight = getOffsetHeight(); offsetHeight = getOffsetHeight();


final int desiredWidth = getMainWidth(); final int desiredWidth = getMainWidth();
com.google.gwt.user.client.Element menuFirstChild = menu
.getElement().getFirstChildElement().cast();
Element menuFirstChild = menu.getElement().getFirstChildElement();
int naturalMenuWidth = menuFirstChild.getOffsetWidth(); int naturalMenuWidth = menuFirstChild.getOffsetWidth();


if (popupOuterPadding == -1) { if (popupOuterPadding == -1) {
return null; return null;
} }


com.google.gwt.user.client.Element menuItemRoot = subElement;
Element menuItemRoot = subElement;
while (menuItemRoot != null while (menuItemRoot != null
&& !menuItemRoot.getTagName().equalsIgnoreCase("td")) { && !menuItemRoot.getTagName().equalsIgnoreCase("td")) {
menuItemRoot = menuItemRoot.getParentElement().cast(); menuItemRoot = menuItemRoot.getParentElement().cast();
*/ */
preventNextBlurEventInIE = false; preventNextBlurEventInIE = false;


com.google.gwt.user.client.Element focusedElement = Util
.getIEFocusedElement();
Element focusedElement = Util.getIEFocusedElement();
if (getElement().isOrHasChild(focusedElement) if (getElement().isOrHasChild(focusedElement)
|| suggestionPopup.getElement() || suggestionPopup.getElement()
.isOrHasChild(focusedElement)) { .isOrHasChild(focusedElement)) {

+ 7
- 12
client/src/com/vaadin/client/ui/VForm.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.event.shared.HandlerRegistration;
public Widget lo; public Widget lo;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element legend = DOM.createLegend();
public Element legend = DOM.createLegend();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element caption = DOM.createSpan();
public Element caption = DOM.createSpan();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element desc = DOM.createDiv();
public Element desc = DOM.createDiv();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public Icon icon; public Icon icon;
public VErrorMessage errorMessage = new VErrorMessage(); public VErrorMessage errorMessage = new VErrorMessage();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element fieldContainer = DOM.createDiv();
public Element fieldContainer = DOM.createDiv();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element footerContainer = DOM.createDiv();
public Element footerContainer = DOM.createDiv();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element fieldSet = DOM.createFieldSet();
public Element fieldSet = DOM.createFieldSet();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public Widget footer; public Widget footer;
} }
lo = newLayoutWidget; lo = newLayoutWidget;
} }

/** For internal use only. May be removed or replaced in the future. */
@Override
public void add(Widget child, com.google.gwt.user.client.Element container) {
super.add(child, container);
}
} }

+ 5
- 4
client/src/com/vaadin/client/ui/VFormLayout.java Näytä tiedosto

import java.util.List; import java.util.List;


import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
} }


public void setMargins(MarginInfo margins) { public void setMargins(MarginInfo margins) {
com.google.gwt.user.client.Element margin = getElement();
Element margin = getElement();
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP,
margins.hasTop()); margins.hasTop());
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT, setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_RIGHT,


private final ComponentConnector owner; private final ComponentConnector owner;


private com.google.gwt.user.client.Element requiredFieldIndicator;
private Element requiredFieldIndicator;


private Icon icon; private Icon icon;


private com.google.gwt.user.client.Element captionText;
private Element captionText;


/** /**
* *
public class ErrorFlag extends HTML { public class ErrorFlag extends HTML {
private static final String CLASSNAME = VFormLayout.CLASSNAME private static final String CLASSNAME = VFormLayout.CLASSNAME
+ "-error-indicator"; + "-error-indicator";
com.google.gwt.user.client.Element errorIndicatorElement;
Element errorIndicatorElement;


private ComponentConnector owner; private ComponentConnector owner;



+ 27
- 4
client/src/com/vaadin/client/ui/VGridLayout.java Näytä tiedosto



import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
void layoutCellsVertically() { void layoutCellsVertically() {
int verticalSpacing = getVerticalSpacing(); int verticalSpacing = getVerticalSpacing();
LayoutManager layoutManager = LayoutManager.get(client); LayoutManager layoutManager = LayoutManager.get(client);
com.google.gwt.user.client.Element element = getElement();
Element element = getElement();
int paddingTop = layoutManager.getPaddingTop(element); int paddingTop = layoutManager.getPaddingTop(element);
int paddingBottom = layoutManager.getPaddingBottom(element); int paddingBottom = layoutManager.getPaddingBottom(element);




void layoutCellsHorizontally() { void layoutCellsHorizontally() {
LayoutManager layoutManager = LayoutManager.get(client); LayoutManager layoutManager = LayoutManager.get(client);
com.google.gwt.user.client.Element element = getElement();
Element element = getElement();
int x = layoutManager.getPaddingLeft(element); int x = layoutManager.getPaddingLeft(element);
int paddingRight = layoutManager.getPaddingRight(element); int paddingRight = layoutManager.getPaddingRight(element);
int horizontalSpacing = getHorizontalSpacing(); int horizontalSpacing = getHorizontalSpacing();
if (component.isRelativeWidth()) { if (component.isRelativeWidth()) {
slot.getWrapperElement().getStyle().setWidth(100, Unit.PCT); slot.getWrapperElement().getStyle().setWidth(100, Unit.PCT);
} }
com.google.gwt.user.client.Element slotWrapper = slot
.getWrapperElement();
Element slotWrapper = slot.getWrapperElement();
getElement().appendChild(slotWrapper); getElement().appendChild(slotWrapper);


Widget widget = component.getWidget(); Widget widget = component.getWidget();
* this layout * this layout
* @return The Paintable which the element is a part of. Null if the element * @return The Paintable which the element is a part of. Null if the element
* belongs to the layout and not to a child. * belongs to the layout and not to a child.
* @deprecated As of 7.2, call or override {@link #getComponent(Element)}
* instead
*/ */
@Deprecated
public ComponentConnector getComponent( public ComponentConnector getComponent(
com.google.gwt.user.client.Element element) { com.google.gwt.user.client.Element element) {
return Util.getConnectorForElement(client, this, element); return Util.getConnectorForElement(client, this, element);

}

/**
* Returns the deepest nested child component which contains "element". The
* child component is also returned if "element" is part of its caption.
* <p>
* For internal use only. May be removed or replaced in the future.
*
* @param element
* An element that is a nested sub element of the root element in
* this layout
* @return The Paintable which the element is a part of. Null if the element
* belongs to the layout and not to a child.
*
* @since 7.2
*/
public ComponentConnector getComponent(Element element) {
return getComponent(DOM.asOld(element));
} }


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */

+ 5
- 6
client/src/com/vaadin/client/ui/VLink.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
public int targetHeight; public int targetHeight;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element errorIndicatorElement;
public Element errorIndicatorElement;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element anchor = DOM.createAnchor();
public final Element anchor = DOM.createAnchor();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element captionElement = DOM
.createSpan();
public final Element captionElement = DOM.createSpan();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public Icon icon; public Icon icon;


@Override @Override
public void onBrowserEvent(Event event) { public void onBrowserEvent(Event event) {
final com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
final Element target = DOM.eventGetTarget(event);
if (event.getTypeInt() == Event.ONLOAD) { if (event.getTypeInt() == Event.ONLOAD) {
Util.notifyParentOfSizeChange(this, true); Util.notifyParentOfSizeChange(this, true);
} }

+ 2
- 2
client/src/com/vaadin/client/ui/VMediaBase.java Näytä tiedosto

package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.MediaElement; import com.google.gwt.dom.client.MediaElement;
import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.SourceElement; import com.google.gwt.dom.client.SourceElement;
} }


public void addSource(String sourceUrl, String sourceType) { public void addSource(String sourceUrl, String sourceType) {
com.google.gwt.user.client.Element src = Document.get()
.createElement(SourceElement.TAG).cast();
Element src = Document.get().createElement(SourceElement.TAG);
src.setAttribute("src", sourceUrl); src.setAttribute("src", sourceUrl);
src.setAttribute("type", sourceType); src.setAttribute("type", sourceType);
media.appendChild(src); media.appendChild(src);

+ 22
- 6
client/src/com/vaadin/client/ui/VMenuBar.java Näytä tiedosto

import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Overflow; import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
/** Widget fields **/ /** Widget fields **/
protected boolean subMenu; protected boolean subMenu;
protected ArrayList<CustomMenuItem> items; protected ArrayList<CustomMenuItem> items;
protected com.google.gwt.user.client.Element containerElement;
protected Element containerElement;
protected VOverlay popup; protected VOverlay popup;
protected VMenuBar visibleChildMenu; protected VMenuBar visibleChildMenu;
protected boolean menuVisible = false; protected boolean menuVisible = false;
* Remove all the items in this menu * Remove all the items in this menu
*/ */
public void clearItems() { public void clearItems() {
com.google.gwt.user.client.Element e = getContainerElement();
Element e = getContainerElement();
while (DOM.getChildCount(e) > 0) { while (DOM.getChildCount(e) > 0) {
DOM.removeChild(e, DOM.getChild(e, 0)); DOM.removeChild(e, DOM.getChild(e, 0));
} }
*/ */
@Override @Override
public com.google.gwt.user.client.Element getContainerElement() { public com.google.gwt.user.client.Element getContainerElement() {
return containerElement;
return DOM.asOld(containerElement);
} }


/** /**
return; return;
} }


com.google.gwt.user.client.Element targetElement = DOM
.eventGetTarget(e);
Element targetElement = DOM.eventGetTarget(e);
CustomMenuItem targetItem = null; CustomMenuItem targetItem = null;
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
CustomMenuItem item = items.get(i); CustomMenuItem item = items.get(i);
return null; return null;
} }


com.google.gwt.user.client.Element menuItemRoot = subElement;
Element menuItemRoot = subElement;
while (menuItemRoot != null && menuItemRoot.getParentElement() != null while (menuItemRoot != null && menuItemRoot.getParentElement() != null
&& menuItemRoot.getParentElement() != getElement()) { && menuItemRoot.getParentElement() != getElement()) {
menuItemRoot = menuItemRoot.getParentElement().cast(); menuItemRoot = menuItemRoot.getParentElement().cast();
* @param element * @param element
* Element used in search * Element used in search
* @return Menu item or null if not found * @return Menu item or null if not found
* @deprecated As of 7.2, call or override
* {@link #getMenuItemWithElement(Element)} instead
*/ */
@Deprecated
public CustomMenuItem getMenuItemWithElement( public CustomMenuItem getMenuItemWithElement(
com.google.gwt.user.client.Element element) { com.google.gwt.user.client.Element element) {
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {


return null; return null;
} }

/**
* Get menu item with given DOM element
*
* @param element
* Element used in search
* @return Menu item or null if not found
*
* @since 7.2
*/
public CustomMenuItem getMenuItemWithElement(Element element) {
return getMenuItemWithElement(DOM.asOld(element));
}
} }

+ 3
- 2
client/src/com/vaadin/client/ui/VNotification.java Näytä tiedosto



import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
} }


public void setPosition(com.vaadin.shared.Position position) { public void setPosition(com.vaadin.shared.Position position) {
final com.google.gwt.user.client.Element el = getElement();
final Element el = getElement();
DOM.setStyleAttribute(el, "top", ""); DOM.setStyleAttribute(el, "top", "");
DOM.setStyleAttribute(el, "left", ""); DOM.setStyleAttribute(el, "left", "");
DOM.setStyleAttribute(el, "bottom", ""); DOM.setStyleAttribute(el, "bottom", "");
} }
} }


private void setOpacity(com.google.gwt.user.client.Element el, int opacity) {
private void setOpacity(Element el, int opacity) {
DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0)); DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0));
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity

+ 7
- 9
client/src/com/vaadin/client/ui/VOverlay.java Näytä tiedosto

import com.google.gwt.animation.client.Animation; import com.google.gwt.animation.client.Animation;
import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.IFrameElement; import com.google.gwt.dom.client.IFrameElement;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.BorderStyle; import com.google.gwt.dom.client.Style.BorderStyle;
/* /*
* The shadow element for this overlay. * The shadow element for this overlay.
*/ */
private com.google.gwt.user.client.Element shadow;
private Element shadow;


/* /*
* The creator of this VOverlay (the widget that made the instance, not the * The creator of this VOverlay (the widget that made the instance, not the
// Animate the size // Animate the size
positionAndSize.setAnimationFromCenterProgress(progress); positionAndSize.setAnimationFromCenterProgress(progress);


com.google.gwt.user.client.Element container = getElement()
.getParentElement().cast();
Element container = getElement().getParentElement();


if (isShadowEnabled()) { if (isShadowEnabled()) {
updateShadowPosition(progress, zIndex, positionAndSize); updateShadowPosition(progress, zIndex, positionAndSize);
} }


private void updateShimPosition(PositionAndSize positionAndSize) { private void updateShimPosition(PositionAndSize positionAndSize) {
updatePositionAndSize(
(com.google.gwt.user.client.Element) com.google.gwt.user.client.Element
.as(getShimElement()), positionAndSize);
updatePositionAndSize(getShimElement(), positionAndSize);
} }


/** /**
return info.isIE() && info.isBrowserVersionNewerOrEqual(8, 0); return info.isIE() && info.isBrowserVersionNewerOrEqual(8, 0);
} }


private void updatePositionAndSize(com.google.gwt.user.client.Element e,
private void updatePositionAndSize(Element e,
PositionAndSize positionAndSize) { PositionAndSize positionAndSize) {
e.getStyle().setLeft(positionAndSize.getLeft(), Unit.PX); e.getStyle().setLeft(positionAndSize.getLeft(), Unit.PX);
e.getStyle().setTop(positionAndSize.getTop(), Unit.PX); e.getStyle().setTop(positionAndSize.getTop(), Unit.PX);
ApplicationConnection ac) { ApplicationConnection ac) {
String id = ac.getConfiguration().getRootPanelId(); String id = ac.getConfiguration().getRootPanelId();
id = id += "-overlays"; id = id += "-overlays";
com.google.gwt.user.client.Element container = DOM.getElementById(id);
Element container = DOM.getElementById(id);
if (container == null) { if (container == null) {
container = DOM.createDiv(); container = DOM.createDiv();
container.setId(id); container.setId(id);
container.addClassName(CLASSNAME_CONTAINER); container.addClassName(CLASSNAME_CONTAINER);
RootPanel.get().getElement().appendChild(container); RootPanel.get().getElement().appendChild(container);
} }
return container;
return DOM.asOld(container);
} }


/** /**

+ 7
- 10
client/src/com/vaadin/client/ui/VPanel.java Näytä tiedosto



import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.SimplePanel;
public String id; public String id;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element captionNode = DOM
.createDiv();
public final Element captionNode = DOM.createDiv();


private final com.google.gwt.user.client.Element captionText = DOM
.createSpan();
private final Element captionText = DOM.createSpan();


private Icon icon; private Icon icon;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element bottomDecoration = DOM
.createDiv();
public final Element bottomDecoration = DOM.createDiv();


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element contentNode = DOM
.createDiv();
public final Element contentNode = DOM.createDiv();


private com.google.gwt.user.client.Element errorIndicatorElement;
private Element errorIndicatorElement;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public ShortcutActionHandler shortcutHandler; public ShortcutActionHandler shortcutHandler;


@Override @Override
protected com.google.gwt.user.client.Element getContainerElement() { protected com.google.gwt.user.client.Element getContainerElement() {
return contentNode;
return DOM.asOld(contentNode);
} }


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */

+ 2
- 1
client/src/com/vaadin/client/ui/VPopupCalendar.java Näytä tiedosto

import com.google.gwt.aria.client.LiveValue; import com.google.gwt.aria.client.LiveValue;
import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.DomEvent;


private Label selectedDate; private Label selectedDate;


private com.google.gwt.user.client.Element descriptionForAssisitveDevicesElement;
private Element descriptionForAssisitveDevicesElement;


public VPopupCalendar() { public VPopupCalendar() {
super(); super();

+ 5
- 5
client/src/com/vaadin/client/ui/VPopupView.java Näytä tiedosto

import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyCodes;
super.onDetach(); super.onDetach();
} }


private static native void nativeBlur(com.google.gwt.user.client.Element e)
private static native void nativeBlur(Element e)
/*-{ /*-{
if(e && e.blur) { if(e && e.blur) {
e.blur(); e.blur();


private boolean hasHadMouseOver = false; private boolean hasHadMouseOver = false;
private boolean hideOnMouseOut = true; private boolean hideOnMouseOut = true;
private final Set<com.google.gwt.user.client.Element> activeChildren = new HashSet<com.google.gwt.user.client.Element>();
private final Set<Element> activeChildren = new HashSet<Element>();


private ShortcutActionHandler shortcutActionHandler; private ShortcutActionHandler shortcutActionHandler;


// to use ONMOUSEMOVE that doesn't target the popup // to use ONMOUSEMOVE that doesn't target the popup
@Override @Override
public boolean onEventPreview(Event event) { public boolean onEventPreview(Event event) {
com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
Element target = DOM.eventGetTarget(event);
boolean eventTargetsPopup = DOM.isOrHasChild(getElement(), target); boolean eventTargetsPopup = DOM.isOrHasChild(getElement(), target);
int type = DOM.eventGetType(event); int type = DOM.eventGetType(event);


} }


// Notify children that have used the keyboard // Notify children that have used the keyboard
for (com.google.gwt.user.client.Element e : activeChildren) {
for (Element e : activeChildren) {
try { try {
nativeBlur(e); nativeBlur(e);
} catch (Exception ignored) { } catch (Exception ignored) {

+ 3
- 2
client/src/com/vaadin/client/ui/VProgressBar.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.HasEnabled;
*/ */
public class VProgressBar extends Widget implements HasEnabled { public class VProgressBar extends Widget implements HasEnabled {


com.google.gwt.user.client.Element wrapper = DOM.createDiv();
com.google.gwt.user.client.Element indicator = DOM.createDiv();
Element wrapper = DOM.createDiv();
Element indicator = DOM.createDiv();


private boolean indeterminate = false; private boolean indeterminate = false;
private float state = 0.0f; private float state = 0.0f;

+ 2
- 2
client/src/com/vaadin/client/ui/VRichTextArea.java Näytä tiedosto

import java.util.Map.Entry; import java.util.Map.Entry;


import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyDownHandler;
* Detects space used by components paddings and borders. * Detects space used by components paddings and borders.
*/ */
private void detectExtraSizes() { private void detectExtraSizes() {
com.google.gwt.user.client.Element clone = Util.cloneNode(getElement(),
false);
Element clone = Util.cloneNode(getElement(), false);
DOM.setElementAttribute(clone, "id", ""); DOM.setElementAttribute(clone, "id", "");
DOM.setStyleAttribute(clone, "visibility", "hidden"); DOM.setStyleAttribute(clone, "visibility", "hidden");
DOM.setStyleAttribute(clone, "position", "absolute"); DOM.setStyleAttribute(clone, "position", "absolute");

+ 68
- 97
client/src/com/vaadin/client/ui/VScrollTable.java Näytä tiedosto

import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.NodeList;
private final HashMap<Object, String> actionMap = new HashMap<Object, String>(); private final HashMap<Object, String> actionMap = new HashMap<Object, String>();
private String[] visibleColOrder; private String[] visibleColOrder;
private boolean initialContentReceived = false; private boolean initialContentReceived = false;
private com.google.gwt.user.client.Element scrollPositionElement;
private Element scrollPositionElement;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public boolean enabled; public boolean enabled;
super.onDetach(); super.onDetach();
// ensure that scrollPosElement will be detached // ensure that scrollPosElement will be detached
if (scrollPositionElement != null) { if (scrollPositionElement != null) {
final com.google.gwt.user.client.Element parent = DOM
.getParent(scrollPositionElement);
final Element parent = DOM.getParent(scrollPositionElement);
if (parent != null) { if (parent != null) {
DOM.removeChild(parent, scrollPositionElement); DOM.removeChild(parent, scrollPositionElement);
} }


public class HeaderCell extends Widget { public class HeaderCell extends Widget {


com.google.gwt.user.client.Element td = DOM.createTD();
Element td = DOM.createTD();


com.google.gwt.user.client.Element captionContainer = DOM.createDiv();
Element captionContainer = DOM.createDiv();


com.google.gwt.user.client.Element sortIndicator = DOM.createDiv();
Element sortIndicator = DOM.createDiv();


com.google.gwt.user.client.Element colResizeWidget = DOM.createDiv();
Element colResizeWidget = DOM.createDiv();


com.google.gwt.user.client.Element floatingCopyOfHeaderCell;
Element floatingCopyOfHeaderCell;


private boolean sortable = false; private boolean sortable = false;
private final String cid; private final String cid;


HashMap<String, HeaderCell> availableCells = new HashMap<String, HeaderCell>(); HashMap<String, HeaderCell> availableCells = new HashMap<String, HeaderCell>();


com.google.gwt.user.client.Element div = DOM.createDiv();
com.google.gwt.user.client.Element hTableWrapper = DOM.createDiv();
com.google.gwt.user.client.Element hTableContainer = DOM.createDiv();
com.google.gwt.user.client.Element table = DOM.createTable();
com.google.gwt.user.client.Element headerTableBody = DOM.createTBody();
com.google.gwt.user.client.Element tr = DOM.createTR();
Element div = DOM.createDiv();
Element hTableWrapper = DOM.createDiv();
Element hTableContainer = DOM.createDiv();
Element table = DOM.createTable();
Element headerTableBody = DOM.createTBody();
Element tr = DOM.createTR();


private final com.google.gwt.user.client.Element columnSelector = DOM
.createDiv();
private final Element columnSelector = DOM.createDiv();


private int focusedSlot = -1; private int focusedSlot = -1;




public void moveCell(int oldIndex, int newIndex) { public void moveCell(int oldIndex, int newIndex) {
final HeaderCell hCell = getHeaderCell(oldIndex); final HeaderCell hCell = getHeaderCell(oldIndex);
final com.google.gwt.user.client.Element cell = hCell.getElement();
final Element cell = hCell.getElement();


visibleCells.remove(oldIndex); visibleCells.remove(oldIndex);
DOM.removeChild(tr, cell); DOM.removeChild(tr, cell);
private void focusSlot(int index) { private void focusSlot(int index) {
removeSlotFocus(); removeSlotFocus();
if (index > 0) { if (index > 0) {
com.google.gwt.user.client.Element child = tr
.getChild(index - 1).getFirstChild().cast();
Element child = tr.getChild(index - 1).getFirstChild().cast();
child.setClassName(VScrollTable.this.getStylePrimaryName() child.setClassName(VScrollTable.this.getStylePrimaryName()
+ "-resizer"); + "-resizer");
child.addClassName(VScrollTable.this.getStylePrimaryName() child.addClassName(VScrollTable.this.getStylePrimaryName()
+ "-focus-slot-right"); + "-focus-slot-right");
} else { } else {
com.google.gwt.user.client.Element child = tr.getChild(index)
.getFirstChild().cast();
Element child = tr.getChild(index).getFirstChild().cast();
child.setClassName(VScrollTable.this.getStylePrimaryName() child.setClassName(VScrollTable.this.getStylePrimaryName()
+ "-resizer"); + "-resizer");
child.addClassName(VScrollTable.this.getStylePrimaryName() child.addClassName(VScrollTable.this.getStylePrimaryName()
return; return;
} }
if (focusedSlot == 0) { if (focusedSlot == 0) {
com.google.gwt.user.client.Element child = tr
.getChild(focusedSlot).getFirstChild().cast();
Element child = tr.getChild(focusedSlot).getFirstChild().cast();
child.setClassName(VScrollTable.this.getStylePrimaryName() child.setClassName(VScrollTable.this.getStylePrimaryName()
+ "-resizer"); + "-resizer");
} else if (focusedSlot > 0) { } else if (focusedSlot > 0) {
com.google.gwt.user.client.Element child = tr
.getChild(focusedSlot - 1).getFirstChild().cast();
Element child = tr.getChild(focusedSlot - 1).getFirstChild()
.cast();
child.setClassName(VScrollTable.this.getStylePrimaryName() child.setClassName(VScrollTable.this.getStylePrimaryName()
+ "-resizer"); + "-resizer");
} }
* A cell in the footer * A cell in the footer
*/ */
public class FooterCell extends Widget { public class FooterCell extends Widget {
private final com.google.gwt.user.client.Element td = DOM.createTD();
private final com.google.gwt.user.client.Element captionContainer = DOM
.createDiv();
private final Element td = DOM.createTD();
private final Element captionContainer = DOM.createDiv();
private char align = ALIGN_LEFT; private char align = ALIGN_LEFT;
private int width = -1; private int width = -1;
private float expandRatio = 0; private float expandRatio = 0;
// value (greater of header and data // value (greater of header and data
// cols) // cols)


final int hw = ((com.google.gwt.user.client.Element) getElement()
.getLastChild()).getOffsetWidth()
+ getHeaderPadding();
final int hw = ((Element) getElement().getLastChild())
.getOffsetWidth() + getHeaderPadding();
if (columnIndex < 0) { if (columnIndex < 0) {
columnIndex = 0; columnIndex = 0;
for (Iterator<Widget> it = tHead.iterator(); it for (Iterator<Widget> it = tHead.iterator(); it
ArrayList<Widget> visibleCells = new ArrayList<Widget>(); ArrayList<Widget> visibleCells = new ArrayList<Widget>();
HashMap<String, FooterCell> availableCells = new HashMap<String, FooterCell>(); HashMap<String, FooterCell> availableCells = new HashMap<String, FooterCell>();


com.google.gwt.user.client.Element div = DOM.createDiv();
com.google.gwt.user.client.Element hTableWrapper = DOM.createDiv();
com.google.gwt.user.client.Element hTableContainer = DOM.createDiv();
com.google.gwt.user.client.Element table = DOM.createTable();
com.google.gwt.user.client.Element headerTableBody = DOM.createTBody();
com.google.gwt.user.client.Element tr = DOM.createTR();
Element div = DOM.createDiv();
Element hTableWrapper = DOM.createDiv();
Element hTableContainer = DOM.createDiv();
Element table = DOM.createTable();
Element headerTableBody = DOM.createTBody();
Element tr = DOM.createTR();


public TableFooter() { public TableFooter() {


*/ */
public void moveCell(int oldIndex, int newIndex) { public void moveCell(int oldIndex, int newIndex) {
final FooterCell hCell = getFooterCell(oldIndex); final FooterCell hCell = getFooterCell(oldIndex);
final com.google.gwt.user.client.Element cell = hCell.getElement();
final Element cell = hCell.getElement();


visibleCells.remove(oldIndex); visibleCells.remove(oldIndex);
DOM.removeChild(tr, cell); DOM.removeChild(tr, cell);
*/ */
private boolean tBodyMeasurementsDone = false; private boolean tBodyMeasurementsDone = false;


com.google.gwt.user.client.Element preSpacer = DOM.createDiv();
com.google.gwt.user.client.Element postSpacer = DOM.createDiv();
Element preSpacer = DOM.createDiv();
Element postSpacer = DOM.createDiv();


com.google.gwt.user.client.Element container = DOM.createDiv();
Element container = DOM.createDiv();


TableSectionElement tBodyElement = Document.get().createTBodyElement(); TableSectionElement tBodyElement = Document.get().createTBodyElement();
com.google.gwt.user.client.Element table = DOM.createTable();
Element table = DOM.createTable();


private int firstRendered; private int firstRendered;
private int lastRendered; private int lastRendered;
if (BrowserInfo.get().requiresTouchScrollDelegate()) { if (BrowserInfo.get().requiresTouchScrollDelegate()) {
NodeList<Node> childNodes = container.getChildNodes(); NodeList<Node> childNodes = container.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) { for (int i = 0; i < childNodes.getLength(); i++) {
com.google.gwt.user.client.Element item = (com.google.gwt.user.client.Element) childNodes
.getItem(i);
Element item = (Element) childNodes.getItem(i);
item.getStyle().setProperty("webkitTransform", item.getStyle().setProperty("webkitTransform",
"translate3d(0,0,0)"); "translate3d(0,0,0)");
} }
for (Widget row : renderedRows) { for (Widget row : renderedRows) {
if (!(row instanceof VScrollTableGeneratedRow)) { if (!(row instanceof VScrollTableGeneratedRow)) {
TableRowElement tr = row.getElement().cast(); TableRowElement tr = row.getElement().cast();
com.google.gwt.user.client.Element wrapperdiv = tr
.getCells().getItem(columnIndex)
Element wrapperdiv = tr.getCells().getItem(columnIndex)
.getFirstChildElement().cast(); .getFirstChildElement().cast();
return wrapperdiv.getOffsetWidth(); return wrapperdiv.getOffsetWidth();
} }
while (rows.hasNext()) { while (rows.hasNext()) {
final VScrollTableRow row = (VScrollTableRow) rows.next(); final VScrollTableRow row = (VScrollTableRow) rows.next();


final com.google.gwt.user.client.Element td = DOM.getChild(
row.getElement(), oldIndex);
final Element td = DOM.getChild(row.getElement(), oldIndex);
if (td != null) { if (td != null) {
DOM.removeChild(row.getElement(), td); DOM.removeChild(row.getElement(), td);


} }


protected void setCellWidth(int cellIx, int width) { protected void setCellWidth(int cellIx, int width) {
final com.google.gwt.user.client.Element cell = DOM.getChild(
getElement(), cellIx);
final Element cell = DOM.getChild(getElement(), cellIx);
Style wrapperStyle = cell.getFirstChildElement().getStyle(); Style wrapperStyle = cell.getFirstChildElement().getStyle();
int wrapperWidth = width; int wrapperWidth = width;
if (BrowserInfo.get().isWebkit() if (BrowserInfo.get().isWebkit()
protected void initCellWithText(String text, char align, protected void initCellWithText(String text, char align,
String style, boolean textIsHTML, boolean sorted, String style, boolean textIsHTML, boolean sorted,
String description, final TableCellElement td) { String description, final TableCellElement td) {
final com.google.gwt.user.client.Element container = DOM
.createDiv();
final Element container = DOM.createDiv();
container.setClassName(VScrollTable.this.getStylePrimaryName() container.setClassName(VScrollTable.this.getStylePrimaryName()
+ "-cell-wrapper"); + "-cell-wrapper");




protected void updateCellStyleNames(TableCellElement td, protected void updateCellStyleNames(TableCellElement td,
String primaryStyleName) { String primaryStyleName) {
com.google.gwt.user.client.Element container = td
.getFirstChild().cast();
Element container = td.getFirstChild().cast();
container.setClassName(primaryStyleName + "-cell-wrapper"); container.setClassName(primaryStyleName + "-cell-wrapper");


/* /*


protected void initCellWithWidget(Widget w, char align, protected void initCellWithWidget(Widget w, char align,
String style, boolean sorted, final TableCellElement td) { String style, boolean sorted, final TableCellElement td) {
final com.google.gwt.user.client.Element container = DOM
.createDiv();
final Element container = DOM.createDiv();
String className = VScrollTable.this.getStylePrimaryName() String className = VScrollTable.this.getStylePrimaryName()
+ "-cell-content"; + "-cell-content";
if (style != null && !style.equals("")) { if (style != null && !style.equals("")) {
* Whether the event is sent immediately * Whether the event is sent immediately
* @return Whether a click event was sent * @return Whether a click event was sent
*/ */
private boolean handleClickEvent(Event event,
com.google.gwt.user.client.Element targetTdOrTr,
private boolean handleClickEvent(Event event, Element targetTdOrTr,
boolean immediate) { boolean immediate) {
if (!client.hasEventListeners(VScrollTable.this, if (!client.hasEventListeners(VScrollTable.this,
TableConstants.ITEM_CLICK_EVENT_ID)) { TableConstants.ITEM_CLICK_EVENT_ID)) {
com.google.gwt.dom.client.Element target) { com.google.gwt.dom.client.Element target) {


TooltipInfo info = null; TooltipInfo info = null;
final com.google.gwt.user.client.Element targetTdOrTr = getTdOrTr((com.google.gwt.user.client.Element) target
.cast());
final Element targetTdOrTr = getTdOrTr(target);
if (targetTdOrTr != null if (targetTdOrTr != null
&& "td".equals(targetTdOrTr.getTagName().toLowerCase())) { && "td".equals(targetTdOrTr.getTagName().toLowerCase())) {
TableCellElement td = (TableCellElement) targetTdOrTr TableCellElement td = (TableCellElement) targetTdOrTr
return info; return info;
} }


private com.google.gwt.user.client.Element getTdOrTr(
com.google.gwt.user.client.Element target) {
com.google.gwt.user.client.Element thisTrElement = getElement();
private Element getTdOrTr(Element target) {
Element thisTrElement = getElement();
if (target == thisTrElement) { if (target == thisTrElement) {
// This was a on the TR element // This was a on the TR element
return target; return target;
} }


// Iterate upwards until we find the TR element // Iterate upwards until we find the TR element
com.google.gwt.user.client.Element element = target;
Element element = target;
while (element != null while (element != null
&& element.getParentElement().cast() != thisTrElement) {
element = element.getParentElement().cast();
&& element.getParentElement() != thisTrElement) {
element = element.getParentElement();
} }
return element; return element;
} }
boolean touchEventHandled = false; boolean touchEventHandled = false;


if (enabled && hasNativeTouchScrolling) { if (enabled && hasNativeTouchScrolling) {
final com.google.gwt.user.client.Element targetTdOrTr = getEventTargetTdOrTr(event);
final Element targetTdOrTr = getEventTargetTdOrTr(event);
final int type = event.getTypeInt(); final int type = event.getTypeInt();


switch (type) { switch (type) {


if (enabled && !touchEventHandled) { if (enabled && !touchEventHandled) {
final int type = event.getTypeInt(); final int type = event.getTypeInt();
final com.google.gwt.user.client.Element targetTdOrTr = getEventTargetTdOrTr(event);
final Element targetTdOrTr = getEventTargetTdOrTr(event);
if (type == Event.ONCONTEXTMENU) { if (type == Event.ONCONTEXTMENU) {
showContextMenu(event); showContextMenu(event);
if (enabled if (enabled


// Remove IE text selection hack // Remove IE text selection hack
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
((com.google.gwt.user.client.Element) event
.getEventTarget().cast())
((Element) event.getEventTarget().cast())
.setPropertyJSO("onselectstart", .setPropertyJSO("onselectstart",
null); null);
} }


// Prevent default text selection in IE // Prevent default text selection in IE
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
((com.google.gwt.user.client.Element) event
.getEventTarget().cast())
((Element) event.getEventTarget().cast())
.setPropertyJSO( .setPropertyJSO(
"onselectstart", "onselectstart",
getPreventTextSelectionIEHack()); getPreventTextSelectionIEHack());
} }


protected void startRowDrag(Event event, final int type, protected void startRowDrag(Event event, final int type,
com.google.gwt.user.client.Element targetTdOrTr) {
Element targetTdOrTr) {
VTransferable transferable = new VTransferable(); VTransferable transferable = new VTransferable();
transferable.setDragSource(ConnectorMap.get(client) transferable.setDragSource(ConnectorMap.get(client)
.getConnector(VScrollTable.this)); .getConnector(VScrollTable.this));
&& rowKeyIsSelected(rowKey)) { && rowKeyIsSelected(rowKey)) {


// Create a drag image of ALL rows // Create a drag image of ALL rows
ev.createDragImage(
(com.google.gwt.user.client.Element) scrollBody.tBodyElement
.cast(), true);
ev.createDragImage(scrollBody.tBodyElement, true);


// Hide rows which are not selected // Hide rows which are not selected
com.google.gwt.user.client.Element dragImage = ev
.getDragImage();
Element dragImage = ev.getDragImage();
int i = 0; int i = 0;
for (Iterator<Widget> iterator = scrollBody.iterator(); iterator for (Iterator<Widget> iterator = scrollBody.iterator(); iterator
.hasNext();) { .hasNext();) {
VScrollTableRow next = (VScrollTableRow) iterator VScrollTableRow next = (VScrollTableRow) iterator
.next(); .next();


com.google.gwt.user.client.Element child = (com.google.gwt.user.client.Element) dragImage
.getChild(i++);
Element child = (Element) dragImage.getChild(i++);


if (!rowKeyIsSelected(next.rowKey)) { if (!rowKeyIsSelected(next.rowKey)) {
child.getStyle().setVisibility(Visibility.HIDDEN); child.getStyle().setVisibility(Visibility.HIDDEN);
* @return TD or TR element that the event targets (the actual event * @return TD or TR element that the event targets (the actual event
* target is this element or a child of it) * target is this element or a child of it)
*/ */
private com.google.gwt.user.client.Element getEventTargetTdOrTr(
Event event) {
final com.google.gwt.user.client.Element eventTarget = event
.getEventTarget().cast();
private Element getEventTargetTdOrTr(Event event) {
final Element eventTarget = event.getEventTarget().cast();
Widget widget = Util.findWidget(eventTarget, null); Widget widget = Util.findWidget(eventTarget, null);


if (widget != this) { if (widget != this) {
.getVisibleCellCount(); ix++) { .getVisibleCellCount(); ix++) {
spanWidth += tHead.getHeaderCell(ix).getOffsetWidth(); spanWidth += tHead.getHeaderCell(ix).getOffsetWidth();
} }
Util.setWidthExcludingPaddingAndBorder(
(com.google.gwt.user.client.Element) getElement()
.getChild(cellIx), spanWidth, 13, false);
Util.setWidthExcludingPaddingAndBorder((Element) getElement()
.getChild(cellIx), spanWidth, 13, false);
} }
} }




private void updateDropDetails(VDragEvent drag) { private void updateDropDetails(VDragEvent drag) {
dropDetails = new TableDDDetails(); dropDetails = new TableDDDetails();
com.google.gwt.user.client.Element elementOver = drag
.getElementOver();
Element elementOver = drag.getElementOver();


VScrollTableRow row = Util.findWidget(elementOver, getRowClass()); VScrollTableRow row = Util.findWidget(elementOver, getRowClass());
if (row != null) { if (row != null) {
dropDetails.overkey = row.rowKey; dropDetails.overkey = row.rowKey;
com.google.gwt.user.client.Element tr = row.getElement();
com.google.gwt.user.client.Element element = elementOver;
Element tr = row.getElement();
Element element = elementOver;
while (element != null && element.getParentElement() != tr) { while (element != null && element.getParentElement() != tr) {
element = (com.google.gwt.user.client.Element) element
.getParentElement();
element = element.getParentElement();
} }
int childIndex = DOM.getChildIndex(tr, element); int childIndex = DOM.getChildIndex(tr, element);
dropDetails.colkey = tHead.getHeaderCell(childIndex) dropDetails.colkey = tHead.getHeaderCell(childIndex)
* ...and sometimes it sends blur events even though the focus * ...and sometimes it sends blur events even though the focus
* handler is still active. (#10464) * handler is still active. (#10464)
*/ */
com.google.gwt.user.client.Element focusedElement = Util
.getIEFocusedElement();
Element focusedElement = Util.getIEFocusedElement();
if (Util.getConnectorForElement(client, getParent(), focusedElement) == this if (Util.getConnectorForElement(client, getParent(), focusedElement) == this
&& focusedElement != null && focusedElement != null
&& focusedElement != scrollBodyPanel.getFocusElement()) { && focusedElement != scrollBodyPanel.getFocusElement()) {
int colIx = Integer.valueOf(result.getGroup(2)); int colIx = Integer.valueOf(result.getGroup(2));
VScrollTableRow row = scrollBody.getRowByRowIndex(rowIx); VScrollTableRow row = scrollBody.getRowByRowIndex(rowIx);
if (row != null) { if (row != null) {
com.google.gwt.user.client.Element rowElement = row
.getElement();
Element rowElement = row.getElement();
if (colIx < rowElement.getChildCount()) { if (colIx < rowElement.getChildCount()) {
return rowElement.getChild(colIx).getFirstChild().cast(); return rowElement.getChild(colIx).getFirstChild().cast();
} }

+ 8
- 10
client/src/com/vaadin/client/ui/VSlider.java Näytä tiedosto



import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Overflow; import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
}; };


/* DOM element for slider's base */ /* DOM element for slider's base */
private final com.google.gwt.user.client.Element base;
private final Element base;
private final int BASE_BORDER_WIDTH = 1; private final int BASE_BORDER_WIDTH = 1;


/* DOM element for slider's handle */ /* DOM element for slider's handle */
private final com.google.gwt.user.client.Element handle;
private final Element handle;


/* DOM element for decrement arrow */ /* DOM element for decrement arrow */
private final com.google.gwt.user.client.Element smaller;
private final Element smaller;


/* DOM element for increment arrow */ /* DOM element for increment arrow */
private final com.google.gwt.user.client.Element bigger;
private final Element bigger;


/* Temporary dragging/animation variables */ /* Temporary dragging/animation variables */
private boolean dragging = false; private boolean dragging = false;
return; return;
} }


final com.google.gwt.user.client.Element p = getElement()
.getParentElement().cast();
final Element p = getElement().getParentElement();
if (p.getPropertyInt(domProperty) > 50) { if (p.getPropertyInt(domProperty) > 50) {
if (isVertical()) { if (isVertical()) {
setHeight(); setHeight();


@Override @Override
public void execute() { public void execute() {
final com.google.gwt.user.client.Element p = getElement()
.getParentElement().cast();
final Element p = getElement().getParentElement();
if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)) { if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)) {
if (isVertical()) { if (isVertical()) {
setHeight(); setHeight();
if (disabled || readonly) { if (disabled || readonly) {
return; return;
} }
final com.google.gwt.user.client.Element targ = DOM
.eventGetTarget(event);
final Element targ = DOM.eventGetTarget(event);


if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) { if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {
processMouseWheelEvent(event); processMouseWheelEvent(event);

+ 21
- 22
client/src/com/vaadin/client/ui/VTabsheet.java Näytä tiedosto

import com.google.gwt.aria.client.SelectedValue; import com.google.gwt.aria.client.SelectedValue;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.dom.client.TableCellElement; import com.google.gwt.dom.client.TableCellElement;
+ "-focus"; + "-focus";


private TabCaption tabCaption; private TabCaption tabCaption;
com.google.gwt.user.client.Element td = getElement();
Element td = getElement();
private VCloseHandler closeHandler; private VCloseHandler closeHandler;


private boolean enabledOnServer = true; private boolean enabledOnServer = true;
private com.google.gwt.user.client.Element div;
private Element div;
private TabBar tabBar; private TabBar tabBar;
private boolean hiddenOnServer = false; private boolean hiddenOnServer = false;


@Override @Override
protected com.google.gwt.user.client.Element getContainerElement() { protected com.google.gwt.user.client.Element getContainerElement() {
// Attach caption element to div, not td // Attach caption element to div, not td
return div;
return DOM.asOld(div);
} }


public boolean isEnabledOnServer() { public boolean isEnabledOnServer() {
public static class TabCaption extends VCaption { public static class TabCaption extends VCaption {


private boolean closable = false; private boolean closable = false;
private com.google.gwt.user.client.Element closeButton;
private Element closeButton;
private Tab tab; private Tab tab;


TabCaption(Tab tab, ApplicationConnection client) { TabCaption(Tab tab, ApplicationConnection client) {
} }


public com.google.gwt.user.client.Element getCloseButton() { public com.google.gwt.user.client.Element getCloseButton() {
return closeButton;
return DOM.asOld(closeButton);
} }


} }
static class TabBar extends ComplexPanel implements ClickHandler, static class TabBar extends ComplexPanel implements ClickHandler,
VCloseHandler { VCloseHandler {


private final com.google.gwt.user.client.Element tr = DOM.createTR();
private final Element tr = DOM.createTR();


private final com.google.gwt.user.client.Element spacerTd = DOM
.createTD();
private final Element spacerTd = DOM.createTD();


private Tab selected; private Tab selected;


TabBar(VTabsheet tabsheet) { TabBar(VTabsheet tabsheet) {
this.tabsheet = tabsheet; this.tabsheet = tabsheet;


com.google.gwt.user.client.Element el = DOM.createTable();
Element el = DOM.createTable();
Roles.getPresentationRole().set(el); Roles.getPresentationRole().set(el);


com.google.gwt.user.client.Element tbody = DOM.createTBody();
Element tbody = DOM.createTBody();
DOM.appendChild(el, tbody); DOM.appendChild(el, tbody);
DOM.appendChild(tbody, tr); DOM.appendChild(tbody, tr);
setStyleName(spacerTd, CLASSNAME + "-spacertd"); setStyleName(spacerTd, CLASSNAME + "-spacertd");
} }


protected com.google.gwt.user.client.Element getContainerElement() { protected com.google.gwt.user.client.Element getContainerElement() {
return tr;
return DOM.asOld(tr);
} }


public int getTabCount() { public int getTabCount() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
TabCaption caption = (TabCaption) event.getSource(); TabCaption caption = (TabCaption) event.getSource();
com.google.gwt.user.client.Element targetElement = event
.getNativeEvent().getEventTarget().cast();
Element targetElement = event.getNativeEvent().getEventTarget()
.cast();
// the tab should not be focused if the close button was clicked // the tab should not be focused if the close button was clicked
if (targetElement == caption.getCloseButton()) { if (targetElement == caption.getCloseButton()) {
return; return;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
// tabbar and 'scroller' container // tabbar and 'scroller' container
public final com.google.gwt.user.client.Element tabs;
public final Element tabs;
Tab focusedTab; Tab focusedTab;
/** /**
* The tabindex property (position in the browser's focus cycle.) Named like * The tabindex property (position in the browser's focus cycle.) Named like
private static final FocusImpl focusImpl = FocusImpl.getFocusImplForPanel(); private static final FocusImpl focusImpl = FocusImpl.getFocusImplForPanel();


// tab-scroller element // tab-scroller element
private final com.google.gwt.user.client.Element scroller;
private final Element scroller;
// tab-scroller next button element // tab-scroller next button element
private final com.google.gwt.user.client.Element scrollerNext;
private final Element scrollerNext;
// tab-scroller prev button element // tab-scroller prev button element
private final com.google.gwt.user.client.Element scrollerPrev;
private final Element scrollerPrev;


/** /**
* The index of the first visible tab (when scrolled) * The index of the first visible tab (when scrolled)
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final VTabsheetPanel tp = new VTabsheetPanel(); public final VTabsheetPanel tp = new VTabsheetPanel();
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final com.google.gwt.user.client.Element contentNode;
public final Element contentNode;


private final com.google.gwt.user.client.Element deco;
private final Element deco;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public boolean waitingForResponse; public boolean waitingForResponse;
} }


private boolean isClippedTabs() { private boolean isClippedTabs() {
return (tb.getOffsetWidth() - DOM.getElementPropertyInt(
(com.google.gwt.user.client.Element) tb.getContainerElement()
.getLastChild().cast(), "offsetWidth")) > getOffsetWidth()
return (tb.getOffsetWidth() - DOM.getElementPropertyInt((Element) tb
.getContainerElement().getLastChild().cast(), "offsetWidth")) > getOffsetWidth()
- (isScrolledTabs() ? scroller.getOffsetWidth() : 0); - (isScrolledTabs() ? scroller.getOffsetWidth() : 0);
} }



+ 10
- 10
client/src/com/vaadin/client/ui/VTabsheetPanel.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
*/ */
@Override @Override
public void add(Widget w) { public void add(Widget w) {
com.google.gwt.user.client.Element el = createContainerElement();
Element el = createContainerElement();
DOM.appendChild(getElement(), el); DOM.appendChild(getElement(), el);
super.add(w, el); super.add(w, el);
} }


private com.google.gwt.user.client.Element createContainerElement() {
com.google.gwt.user.client.Element el = DOM.createDiv();
private Element createContainerElement() {
Element el = DOM.createDiv();
DOM.setStyleAttribute(el, "position", "absolute"); DOM.setStyleAttribute(el, "position", "absolute");
hide(el); hide(el);
touchScrollHandler.addElement(el); touchScrollHandler.addElement(el);
* if <code>beforeIndex</code> is out of range * if <code>beforeIndex</code> is out of range
*/ */
public void insert(Widget w, int beforeIndex) { public void insert(Widget w, int beforeIndex) {
com.google.gwt.user.client.Element el = createContainerElement();
Element el = createContainerElement();
DOM.insertChild(getElement(), el, beforeIndex); DOM.insertChild(getElement(), el, beforeIndex);
super.insert(w, el, beforeIndex, false); super.insert(w, el, beforeIndex, false);
} }


@Override @Override
public boolean remove(Widget w) { public boolean remove(Widget w) {
com.google.gwt.user.client.Element child = w.getElement();
com.google.gwt.user.client.Element parent = null;
Element child = w.getElement();
Element parent = null;
if (child != null) { if (child != null) {
parent = DOM.getParent(child); parent = DOM.getParent(child);
} }
unHide(DOM.getParent(visibleWidget.getElement())); unHide(DOM.getParent(visibleWidget.getElement()));
} }


private void hide(com.google.gwt.user.client.Element e) {
private void hide(Element e) {
DOM.setStyleAttribute(e, "visibility", "hidden"); DOM.setStyleAttribute(e, "visibility", "hidden");
DOM.setStyleAttribute(e, "top", "-100000px"); DOM.setStyleAttribute(e, "top", "-100000px");
DOM.setStyleAttribute(e, "left", "-100000px"); DOM.setStyleAttribute(e, "left", "-100000px");
} }


private void unHide(com.google.gwt.user.client.Element e) {
private void unHide(Element e) {
DOM.setStyleAttribute(e, "top", "0px"); DOM.setStyleAttribute(e, "top", "0px");
DOM.setStyleAttribute(e, "left", "0px"); DOM.setStyleAttribute(e, "left", "0px");
DOM.setStyleAttribute(e, "visibility", ""); DOM.setStyleAttribute(e, "visibility", "");
width = minWidth; width = minWidth;
} }


com.google.gwt.user.client.Element wrapperDiv = (com.google.gwt.user.client.Element) visibleWidget
.getElement().getParentElement();
Element wrapperDiv = visibleWidget.getElement().getParentElement();


// width first // width first
getElement().getStyle().setPropertyPx("width", width); getElement().getStyle().setPropertyPx("width", width);

+ 6
- 8
client/src/com/vaadin/client/ui/VTextField.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeEvent;
this(DOM.createInputText()); this(DOM.createInputText());
} }


protected VTextField(com.google.gwt.user.client.Element node) {
protected VTextField(Element node) {
super(node); super(node);
setStyleName(CLASSNAME); setStyleName(CLASSNAME);
addChangeHandler(this); addChangeHandler(this);
} }


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public native void attachCutEventListener(
com.google.gwt.user.client.Element el)
public native void attachCutEventListener(Element el)
/*-{ /*-{
var me = this; var me = this;
el.oncut = $entry(function() { el.oncut = $entry(function() {
}); });
}-*/; }-*/;


protected native void detachCutEventListener(
com.google.gwt.user.client.Element el)
protected native void detachCutEventListener(Element el)
/*-{ /*-{
el.oncut = null; el.oncut = null;
}-*/; }-*/;
return !"off".equals(wrap); return !"off".equals(wrap);
} }


private native void addOnInputListener(com.google.gwt.user.client.Element el)
private native void addOnInputListener(Element el)
/*-{ /*-{
var self = this; var self = this;
el.oninput = $entry(function() { el.oninput = $entry(function() {
}); });
}-*/; }-*/;


private native void removeOnInputListener(
com.google.gwt.user.client.Element el)
private native void removeOnInputListener(Element el)
/*-{ /*-{
el.oninput = null; el.oninput = null;
}-*/; }-*/;

+ 11
- 13
client/src/com/vaadin/client/ui/VTree.java Näytä tiedosto

import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurEvent;
if (event.getTypeInt() == Event.ONMOUSEDOWN) { if (event.getTypeInt() == Event.ONMOUSEDOWN) {
// Prevent default text selection in IE // Prevent default text selection in IE
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
((com.google.gwt.user.client.Element) event.getEventTarget()
.cast()).setPropertyJSO("onselectstart",
applyDisableTextSelectionIEHack());
((Element) event.getEventTarget().cast()).setPropertyJSO(
"onselectstart", applyDisableTextSelectionIEHack());
} }
} else if (event.getTypeInt() == Event.ONMOUSEUP) { } else if (event.getTypeInt() == Event.ONMOUSEUP) {
// Remove IE text selection hack // Remove IE text selection hack
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
((com.google.gwt.user.client.Element) event.getEventTarget()
.cast()).setPropertyJSO("onselectstart", null);
((Element) event.getEventTarget().cast()).setPropertyJSO(
"onselectstart", null);
} }
} else if (event.getTypeInt() == Event.ONKEYUP) { } else if (event.getTypeInt() == Event.ONKEYUP) {
if (selectionHasChanged) { if (selectionHasChanged) {


} }


private String findCurrentMouseOverKey(
com.google.gwt.user.client.Element elementOver) {
private String findCurrentMouseOverKey(Element elementOver) {
TreeNode treeNode = Util.findWidget(elementOver, TreeNode.class); TreeNode treeNode = Util.findWidget(elementOver, TreeNode.class);
return treeNode == null ? null : treeNode.key; return treeNode == null ? null : treeNode.key;
} }
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public boolean childrenLoaded; public boolean childrenLoaded;


com.google.gwt.user.client.Element nodeCaptionDiv;
Element nodeCaptionDiv;


protected com.google.gwt.user.client.Element nodeCaptionSpan;
protected Element nodeCaptionSpan;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public FlowPanel childNodeContainer; public FlowPanel childNodeContainer;
public void onBrowserEvent(Event event) { public void onBrowserEvent(Event event) {
super.onBrowserEvent(event); super.onBrowserEvent(event);
final int type = DOM.eventGetType(event); final int type = DOM.eventGetType(event);
final com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
final Element target = DOM.eventGetTarget(event);


if (type == Event.ONLOAD && target == icon.getElement()) { if (type == Event.ONLOAD && target == icon.getElement()) {
iconLoaded.trigger(); iconLoaded.trigger();
nodeCaptionDiv = DOM.createDiv(); nodeCaptionDiv = DOM.createDiv();
DOM.setElementProperty(nodeCaptionDiv, "className", CLASSNAME DOM.setElementProperty(nodeCaptionDiv, "className", CLASSNAME
+ "-caption"); + "-caption");
com.google.gwt.user.client.Element wrapper = DOM.createDiv();
Element wrapper = DOM.createDiv();
wrapper.setId(labelId); wrapper.setId(labelId);
wrapper.setAttribute("for", treeItemId); wrapper.setAttribute("for", treeItemId);


if (expandCollapse) { if (expandCollapse) {
return treeNode.getElement(); return treeNode.getElement();
} else { } else {
return treeNode.nodeCaptionSpan;
return DOM.asOld(treeNode.nodeCaptionSpan);
} }
} catch (Exception e) { } catch (Exception e) {
// Invalid locator string or node could not be found // Invalid locator string or node could not be found

+ 21
- 30
client/src/com/vaadin/client/ui/VTreeTable.java Näytä tiedosto

import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.ImageElement; import com.google.gwt.dom.client.ImageElement;
import com.google.gwt.dom.client.SpanElement; import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Display;


protected boolean addTreeSpacer(UIDL rowUidl) { protected boolean addTreeSpacer(UIDL rowUidl) {
if (cellShowsTreeHierarchy(getElement().getChildCount() - 1)) { if (cellShowsTreeHierarchy(getElement().getChildCount() - 1)) {
com.google.gwt.user.client.Element container = (com.google.gwt.user.client.Element) getElement()
.getLastChild().getFirstChild();
Element container = (Element) getElement().getLastChild()
.getFirstChild();


if (rowUidl.hasAttribute("icon")) { if (rowUidl.hasAttribute("icon")) {
// icons are in first content cell in TreeTable // icons are in first content cell in TreeTable
} }


private int getCellWidthFromDom(int cellIndex) { private int getCellWidthFromDom(int cellIndex) {
final com.google.gwt.user.client.Element cell = DOM.getChild(
getElement(), cellIndex);
final Element cell = DOM.getChild(getElement(), cellIndex);
String w = cell.getStyle().getProperty("width"); String w = cell.getStyle().getProperty("width");
if (w == null || "".equals(w) || !w.endsWith("px")) { if (w == null || "".equals(w) || !w.endsWith("px")) {
return -1; return -1;
.getVisibleCellCount(); ix++) { .getVisibleCellCount(); ix++) {
spanWidth += tHead.getHeaderCell(ix).getOffsetWidth(); spanWidth += tHead.getHeaderCell(ix).getOffsetWidth();
} }
Util.setWidthExcludingPaddingAndBorder(
(com.google.gwt.user.client.Element) getElement()
.getChild(cellIx), spanWidth, 13, false);
Util.setWidthExcludingPaddingAndBorder((Element) getElement()
.getChild(cellIx), spanWidth, 13, false);
} }
} }


} }


private void copyTRBackgroundsToTDs(VScrollTableRow row) { private void copyTRBackgroundsToTDs(VScrollTableRow row) {
com.google.gwt.user.client.Element tr = row.getElement();
Element tr = row.getElement();
ComputedStyle cs = new ComputedStyle(tr); ComputedStyle cs = new ComputedStyle(tr);
String backgroundAttachment = cs String backgroundAttachment = cs
.getProperty("backgroundAttachment"); .getProperty("backgroundAttachment");
String backgroundImage = cs.getProperty("backgroundImage"); String backgroundImage = cs.getProperty("backgroundImage");
String backgroundOrigin = cs.getProperty("backgroundOrigin"); String backgroundOrigin = cs.getProperty("backgroundOrigin");
for (int ix = 0; ix < tr.getChildCount(); ix++) { for (int ix = 0; ix < tr.getChildCount(); ix++) {
com.google.gwt.user.client.Element td = tr.getChild(ix)
.cast();
Element td = tr.getChild(ix).cast();
if (!elementHasBackground(td)) { if (!elementHasBackground(td)) {
td.getStyle().setProperty("backgroundAttachment", td.getStyle().setProperty("backgroundAttachment",
backgroundAttachment); backgroundAttachment);
} }
} }


private boolean elementHasBackground(
com.google.gwt.user.client.Element element) {
private boolean elementHasBackground(Element element) {
ComputedStyle cs = new ComputedStyle(element); ComputedStyle cs = new ComputedStyle(element);
String clr = cs.getProperty("backgroundColor"); String clr = cs.getProperty("backgroundColor");
String img = cs.getProperty("backgroundImage"); String img = cs.getProperty("backgroundImage");
} }


private void restoreStyleForTDsInRow(VScrollTableRow row) { private void restoreStyleForTDsInRow(VScrollTableRow row) {
com.google.gwt.user.client.Element tr = row.getElement();
Element tr = row.getElement();
for (int ix = 0; ix < tr.getChildCount(); ix++) { for (int ix = 0; ix < tr.getChildCount(); ix++) {
com.google.gwt.user.client.Element td = tr.getChild(ix)
.cast();
Element td = tr.getChild(ix).cast();
td.getStyle().clearProperty("backgroundAttachment"); td.getStyle().clearProperty("backgroundAttachment");
td.getStyle().clearProperty("backgroundClip"); td.getStyle().clearProperty("backgroundClip");
td.getStyle().clearProperty("backgroundColor"); td.getStyle().clearProperty("backgroundColor");
private class RowExpandAnimation extends Animation { private class RowExpandAnimation extends Animation {


private final List<VScrollTableRow> rows; private final List<VScrollTableRow> rows;
private com.google.gwt.user.client.Element cloneDiv;
private com.google.gwt.user.client.Element cloneTable;
private Element cloneDiv;
private Element cloneTable;
private AnimationPreparator preparator; private AnimationPreparator preparator;


/** /**
} }


private void cloneAndAppendRow(VScrollTableRow row) { private void cloneAndAppendRow(VScrollTableRow row) {
com.google.gwt.user.client.Element clonedTR = null;
Element clonedTR = null;
clonedTR = row.getElement().cloneNode(true).cast(); clonedTR = row.getElement().cloneNode(true).cast();
clonedTR.getStyle().setVisibility(Visibility.VISIBLE); clonedTR.getStyle().setVisibility(Visibility.VISIBLE);
cloneTable.appendChild(clonedTR); cloneTable.appendChild(clonedTR);
} }


private void insertAnimatingDiv() { private void insertAnimatingDiv() {
com.google.gwt.user.client.Element tableBody = getElement()
.cast();
com.google.gwt.user.client.Element tableBodyParent = tableBody
.getParentElement().cast();
Element tableBody = getElement();
Element tableBodyParent = tableBody.getParentElement();
tableBodyParent.insertAfter(cloneDiv, tableBody); tableBodyParent.insertAfter(cloneDiv, tableBody);
} }


resetCellWrapperDivsDisplayProperty(row); resetCellWrapperDivsDisplayProperty(row);
row.removeStyleName("v-table-row-animating"); row.removeStyleName("v-table-row-animating");
} }
com.google.gwt.user.client.Element tableBodyParent = (com.google.gwt.user.client.Element) getElement()
.getParentElement();
Element tableBodyParent = getElement().getParentElement();
tableBodyParent.removeChild(cloneDiv); tableBodyParent.removeChild(cloneDiv);
} }


private void setCellWrapperDivsToDisplayNone(VScrollTableRow row) { private void setCellWrapperDivsToDisplayNone(VScrollTableRow row) {
com.google.gwt.user.client.Element tr = row.getElement();
Element tr = row.getElement();
for (int ix = 0; ix < tr.getChildCount(); ix++) { for (int ix = 0; ix < tr.getChildCount(); ix++) {
getWrapperDiv(tr, ix).getStyle().setDisplay(Display.NONE); getWrapperDiv(tr, ix).getStyle().setDisplay(Display.NONE);
} }
} }


private com.google.gwt.user.client.Element getWrapperDiv(
com.google.gwt.user.client.Element tr, int tdIx) {
com.google.gwt.user.client.Element td = tr.getChild(tdIx)
.cast();
private Element getWrapperDiv(Element tr, int tdIx) {
Element td = tr.getChild(tdIx).cast();
return td.getChild(0).cast(); return td.getChild(0).cast();
} }


private void resetCellWrapperDivsDisplayProperty(VScrollTableRow row) { private void resetCellWrapperDivsDisplayProperty(VScrollTableRow row) {
com.google.gwt.user.client.Element tr = row.getElement();
Element tr = row.getElement();
for (int ix = 0; ix < tr.getChildCount(); ix++) { for (int ix = 0; ix < tr.getChildCount(); ix++) {
getWrapperDiv(tr, ix).getStyle().clearProperty("display"); getWrapperDiv(tr, ix).getStyle().clearProperty("display");
} }

+ 4
- 6
client/src/com/vaadin/client/ui/VUpload.java Näytä tiedosto

import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.FormElement; import com.google.gwt.dom.client.FormElement;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
setStyleName(CLASSNAME); setStyleName(CLASSNAME);
} }


private static native void setEncoding(
com.google.gwt.user.client.Element form, String encoding)
private static native void setEncoding(Element form, String encoding)
/*-{ /*-{
form.enctype = encoding; form.enctype = encoding;
// For IE8 // For IE8
setStyleName(getElement(), CLASSNAME + "-immediate", immediate); setStyleName(getElement(), CLASSNAME + "-immediate", immediate);
} }


private static native void fireNativeClick(
com.google.gwt.user.client.Element element)
private static native void fireNativeClick(Element element)
/*-{ /*-{
element.click(); element.click();
}-*/; }-*/;


private static native void fireNativeBlur(
com.google.gwt.user.client.Element element)
private static native void fireNativeBlur(Element element)
/*-{ /*-{
element.blur(); element.blur();
}-*/; }-*/;

+ 2
- 2
client/src/com/vaadin/client/ui/VVideo.java Näytä tiedosto

package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.VideoElement; import com.google.gwt.dom.client.VideoElement;
import com.vaadin.client.Util; import com.vaadin.client.Util;
* *
* @param el * @param el
*/ */
private native void updateDimensionsWhenMetadataLoaded(
com.google.gwt.user.client.Element el)
private native void updateDimensionsWhenMetadataLoaded(Element el)
/*-{ /*-{
var self = this; var self = this;
el.addEventListener('loadedmetadata', $entry(function(e) { el.addEventListener('loadedmetadata', $entry(function(e) {

+ 24
- 25
client/src/com/vaadin/client/ui/VWindow.java Näytä tiedosto

import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Position;
public static final int Z_INDEX = 10000; public static final int Z_INDEX = 10000;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element contents;
public Element contents;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element header;
public Element header;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element footer;
public Element footer;


private com.google.gwt.user.client.Element resizeBox;
private Element resizeBox;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public final FocusableScrollPanel contentPanel = new FocusableScrollPanel(); public final FocusableScrollPanel contentPanel = new FocusableScrollPanel();
private int origH; private int origH;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element closeBox;
public Element closeBox;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public com.google.gwt.user.client.Element maximizeRestoreBox;
public Element maximizeRestoreBox;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public ApplicationConnection client; public ApplicationConnection client;
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public boolean resizeLazy = false; public boolean resizeLazy = false;


private com.google.gwt.user.client.Element modalityCurtain;
private com.google.gwt.user.client.Element draggingCurtain;
private com.google.gwt.user.client.Element resizingCurtain;
private Element modalityCurtain;
private Element draggingCurtain;
private Element resizingCurtain;


private com.google.gwt.user.client.Element headerText;
private Element headerText;


private boolean closable = true; private boolean closable = true;


private String assistivePrefix; private String assistivePrefix;
private String assistivePostfix; private String assistivePostfix;


private com.google.gwt.user.client.Element topTabStop;
private com.google.gwt.user.client.Element bottomTabStop;
private Element topTabStop;
private Element bottomTabStop;


private NativePreviewHandler topEventBlocker; private NativePreviewHandler topEventBlocker;
private NativePreviewHandler bottomEventBlocker; private NativePreviewHandler bottomEventBlocker;
/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public boolean immediate; public boolean immediate;


private com.google.gwt.user.client.Element wrapper;
private Element wrapper;


/** For internal use only. May be removed or replaced in the future. */ /** For internal use only. May be removed or replaced in the future. */
public boolean visibilityChangesDisabled; public boolean visibilityChangesDisabled;
modalityCurtain = DOM.createDiv(); modalityCurtain = DOM.createDiv();
modalityCurtain.setClassName(CLASSNAME + "-modalitycurtain"); modalityCurtain.setClassName(CLASSNAME + "-modalitycurtain");
} }
return modalityCurtain;
return DOM.asOld(modalityCurtain);
} }


protected void constructDOM() { protected void constructDOM() {
} }


private void fixIE8FocusCaptureIssue() { private void fixIE8FocusCaptureIssue() {
com.google.gwt.user.client.Element e = DOM.createInputText();
Element e = DOM.createInputText();
Style elemStyle = e.getStyle(); Style elemStyle = e.getStyle();
elemStyle.setPosition(Position.ABSOLUTE); elemStyle.setPosition(Position.ABSOLUTE);
elemStyle.setTop(-10, Unit.PX); elemStyle.setTop(-10, Unit.PX);
} }
} }


private com.google.gwt.user.client.Element getDraggingCurtain() {
private Element getDraggingCurtain() {
if (draggingCurtain == null) { if (draggingCurtain == null) {
draggingCurtain = createCurtain(); draggingCurtain = createCurtain();
draggingCurtain.setClassName(CLASSNAME + "-draggingCurtain"); draggingCurtain.setClassName(CLASSNAME + "-draggingCurtain");
return draggingCurtain; return draggingCurtain;
} }


private com.google.gwt.user.client.Element getResizingCurtain() {
private Element getResizingCurtain() {
if (resizingCurtain == null) { if (resizingCurtain == null) {
resizingCurtain = createCurtain(); resizingCurtain = createCurtain();
resizingCurtain.setClassName(CLASSNAME + "-resizingCurtain"); resizingCurtain.setClassName(CLASSNAME + "-resizingCurtain");
return resizingCurtain; return resizingCurtain;
} }


private com.google.gwt.user.client.Element createCurtain() {
com.google.gwt.user.client.Element curtain = DOM.createDiv();
private Element createCurtain() {
Element curtain = DOM.createDiv();


DOM.setStyleAttribute(curtain, "position", "absolute"); DOM.setStyleAttribute(curtain, "position", "absolute");
DOM.setStyleAttribute(curtain, "top", "0px"); DOM.setStyleAttribute(curtain, "top", "0px");
if (contents == null) { if (contents == null) {
return super.getContainerElement(); return super.getContainerElement();
} }
return contents;
return DOM.asOld(contents);
} }


private Event headerDragPending; private Event headerDragPending;


final int type = event.getTypeInt(); final int type = event.getTypeInt();


final com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
final Element target = DOM.eventGetTarget(event);


if (resizing || resizeBox == target) { if (resizing || resizeBox == target) {
onResizeEvent(event); onResizeEvent(event);
return true; return true;
} }


final com.google.gwt.user.client.Element target = event
.getEventTarget().cast();
final Element target = event.getEventTarget().cast();
if (!DOM.isOrHasChild(getTopmostWindow().getElement(), target)) { if (!DOM.isOrHasChild(getTopmostWindow().getElement(), target)) {
// not within the modal window, but let's see if it's in the // not within the modal window, but let's see if it's in the
// debug window // debug window
"All values in parameter description need to be non-null"); "All values in parameter description need to be non-null");
} }


com.google.gwt.user.client.Element element = ((ComponentConnector) connectors[index])
Element element = ((ComponentConnector) connectors[index])
.getWidget().getElement(); .getWidget().getElement();
AriaHelper.ensureHasId(element); AriaHelper.ensureHasId(element);
ids[index] = Id.of(element); ids[index] = Id.of(element);

+ 5
- 4
client/src/com/vaadin/client/ui/VWindowOverlay.java Näytä tiedosto



package com.vaadin.client.ui; package com.vaadin.client.ui;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
if (ac == null) { if (ac == null) {
return super.getOverlayContainer(); return super.getOverlayContainer();
} else { } else {
com.google.gwt.user.client.Element overlayContainer = getOverlayContainer(ac);
return overlayContainer;
Element overlayContainer = getOverlayContainer(ac);
return DOM.asOld(overlayContainer);
} }
} }


ApplicationConnection ac) { ApplicationConnection ac) {
String id = ac.getConfiguration().getRootPanelId(); String id = ac.getConfiguration().getRootPanelId();
id = id += "-window-overlays"; id = id += "-window-overlays";
com.google.gwt.user.client.Element container = DOM.getElementById(id);
Element container = DOM.getElementById(id);
if (container == null) { if (container == null) {
container = DOM.createDiv(); container = DOM.createDiv();
container.setId(id); container.setId(id);
RootPanel.get().getElement().appendChild(container); RootPanel.get().getElement().appendChild(container);
} }


return container;
return DOM.asOld(container);
} }
} }

+ 21
- 0
client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java Näytä tiedosto



import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.DirectionalManagedLayout; import com.vaadin.client.DirectionalManagedLayout;
* this layout * this layout
* @return The Paintable which the element is a part of. Null if the element * @return The Paintable which the element is a part of. Null if the element
* belongs to the layout and not to a child. * belongs to the layout and not to a child.
* @deprecated As of 7.2, call or override
* {@link #getConnectorForElement(Element)} instead
*/ */
@Deprecated
protected ComponentConnector getConnectorForElement( protected ComponentConnector getConnectorForElement(
com.google.gwt.user.client.Element element) { com.google.gwt.user.client.Element element) {
return Util.getConnectorForElement(getConnection(), getWidget(), return Util.getConnectorForElement(getConnection(), getWidget(),
element); element);
} }


/**
* Returns the deepest nested child component which contains "element". The
* child component is also returned if "element" is part of its caption.
*
* @param element
* An element that is a nested sub element of the root element in
* this layout
* @return The Paintable which the element is a part of. Null if the element
* belongs to the layout and not to a child.
*
* @since 7.2
*/
protected ComponentConnector getConnectorForElement(Element element) {
return getConnectorForElement(DOM.asOld(element));
}

/* /*
* (non-Javadoc) * (non-Javadoc)
* *

+ 9
- 10
client/src/com/vaadin/client/ui/aria/AriaHelper.java Näytä tiedosto

import com.google.gwt.aria.client.Id; import com.google.gwt.aria.client.Id;
import com.google.gwt.aria.client.InvalidValue; import com.google.gwt.aria.client.InvalidValue;
import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;


* @param captionElements * @param captionElements
* Element with of caption to bind * Element with of caption to bind
*/ */
public static void bindCaption(Widget widget,
com.google.gwt.user.client.Element captionElement) {
public static void bindCaption(Widget widget, Element captionElement) {
assert widget != null : "Valid Widget required"; assert widget != null : "Valid Widget required";


if (widget instanceof HandlesAriaCaption) { if (widget instanceof HandlesAriaCaption) {
((HandlesAriaCaption) widget).bindAriaCaption(null); ((HandlesAriaCaption) widget).bindAriaCaption(null);
} else { } else {
ensureHasId(captionElement); ensureHasId(captionElement);
((HandlesAriaCaption) widget).bindAriaCaption(captionElement);
((HandlesAriaCaption) widget).bindAriaCaption(DOM
.asOld(captionElement));
} }
} else if (captionElement != null) { } else if (captionElement != null) {
// Handle the default case // Handle the default case
* @param required * @param required
* boolean, true when the element is required * boolean, true when the element is required
*/ */
public static void handleInputRequired(
com.google.gwt.user.client.Element element, boolean required) {
public static void handleInputRequired(Element element, boolean required) {
if (required) { if (required) {
Roles.getTextboxRole().setAriaRequiredProperty(element, required); Roles.getTextboxRole().setAriaRequiredProperty(element, required);
} else { } else {
* @param invalid * @param invalid
* boolean, true when the element input has an error * boolean, true when the element input has an error
*/ */
public static void handleInputInvalid(
com.google.gwt.user.client.Element element, boolean invalid) {
public static void handleInputInvalid(Element element, boolean invalid) {
if (invalid) { if (invalid) {
Roles.getTextboxRole().setAriaInvalidState(element, Roles.getTextboxRole().setAriaInvalidState(element,
InvalidValue.TRUE); InvalidValue.TRUE);
* Element to check * Element to check
* @return String with the id of the element * @return String with the id of the element
*/ */
public static String ensureHasId(com.google.gwt.user.client.Element element) {
public static String ensureHasId(Element element) {
assert element != null : "Valid Element required"; assert element != null : "Valid Element required";


String id = element.getId(); String id = element.getId();
* @param boolean assistiveOnly true when element should only be visible for * @param boolean assistiveOnly true when element should only be visible for
* assistive devices, false to make the element visible for all * assistive devices, false to make the element visible for all
*/ */
public static void setVisibleForAssistiveDevicesOnly(
com.google.gwt.user.client.Element element, boolean assistiveOnly) {
public static void setVisibleForAssistiveDevicesOnly(Element element,
boolean assistiveOnly) {
if (assistiveOnly) { if (assistiveOnly) {
element.addClassName(ASSISTIVE_DEVICE_ONLY_STYLE); element.addClassName(ASSISTIVE_DEVICE_ONLY_STYLE);
} else { } else {

+ 3
- 4
client/src/com/vaadin/client/ui/calendar/CalendarConnector.java Näytä tiedosto

import java.util.List; import java.util.List;


import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.ContextMenuEvent; import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
*/ */
DateCell cell = (DateCell) widget; DateCell cell = (DateCell) widget;
int slotIndex = DOM.getChildIndex( int slotIndex = DOM.getChildIndex(
cell.getElement(),
(com.google.gwt.user.client.Element) ne
cell.getElement(), (Element) ne
.getEventTarget().cast()); .getEventTarget().cast());
DateCellSlot slot = cell.getSlot(slotIndex); DateCellSlot slot = cell.getSlot(slotIndex);
return CalendarConnector.this.getActionsBetween( return CalendarConnector.this.getActionsBetween(
@Override @Override
public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) { public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) {
TooltipInfo tooltipInfo = null; TooltipInfo tooltipInfo = null;
Widget w = Util.findWidget(
(com.google.gwt.user.client.Element) element, null);
Widget w = Util.findWidget(element, null);
if (w instanceof HasTooltipKey) { if (w instanceof HasTooltipKey) {
tooltipInfo = GWT.create(TooltipInfo.class); tooltipInfo = GWT.create(TooltipInfo.class);
String title = tooltips.get(((HasTooltipKey) w).getTooltipKey()); String title = tooltips.get(((HasTooltipKey) w).getTooltipKey());

+ 27
- 5
client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java Näytä tiedosto

} }


public int getSlotBorder() { public int getSlotBorder() {
return Util
.measureVerticalBorder((com.google.gwt.user.client.Element) slotElements[0]);
return Util.measureVerticalBorder(slotElements[0]);
} }


private void drawDayEvents(List<DateCellGroup> groups) { private void drawDayEvents(List<DateCellGroup> groups) {
updatePositionFor(dayEvent, targetDay, calendarEvent); updatePositionFor(dayEvent, targetDay, calendarEvent);
} }


add(dayEvent, (com.google.gwt.user.client.Element) main);
add(dayEvent, main);
} }


// date methods are not deprecated in GWT // date methods are not deprecated in GWT
} }
index++; index++;
} }
this.insert(dayEvent, (com.google.gwt.user.client.Element) main, index,
true);
this.insert(dayEvent, main, index, true);
} }


public void removeEvent(DateCellDayEvent dayEvent) { public void removeEvent(DateCellDayEvent dayEvent) {
return today != null; return today != null;
} }


/**
* @deprecated As of 7.2, call or override
* {@link #addEmphasisStyle(Element)} instead
*/
@Deprecated
public void addEmphasisStyle(com.google.gwt.user.client.Element elementOver) { public void addEmphasisStyle(com.google.gwt.user.client.Element elementOver) {
String originalStylename = getStyleName(elementOver); String originalStylename = getStyleName(elementOver);
setStyleName(elementOver, originalStylename + DRAGEMPHASISSTYLE); setStyleName(elementOver, originalStylename + DRAGEMPHASISSTYLE);
} }


/**
* @since 7.2
*/
public void addEmphasisStyle(Element elementOver) {
addEmphasisStyle(DOM.asOld(elementOver));
}

/**
* @deprecated As of 7.2, call or override
* {@link #removeEmphasisStyle(Element)} instead
*/
@Deprecated
public void removeEmphasisStyle( public void removeEmphasisStyle(
com.google.gwt.user.client.Element elementOver) { com.google.gwt.user.client.Element elementOver) {
String originalStylename = getStyleName(elementOver); String originalStylename = getStyleName(elementOver);
- DRAGEMPHASISSTYLE.length())); - DRAGEMPHASISSTYLE.length()));
} }


/**
* @since 7.2
*/
public void removeEmphasisStyle(Element elementOver) {
removeEmphasisStyle(DOM.asOld(elementOver));
}

@Override @Override
public void onContextMenu(ContextMenuEvent event) { public void onContextMenu(ContextMenuEvent event) {
if (weekgrid.getCalendar().getMouseEventListener() != null) { if (weekgrid.getCalendar().getMouseEventListener() != null) {

+ 2
- 2
client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java Näytä tiedosto

private int startXrelative; private int startXrelative;
private boolean disabled; private boolean disabled;
private final WeekGrid weekGrid; private final WeekGrid weekGrid;
private com.google.gwt.user.client.Element topResizeBar;
private com.google.gwt.user.client.Element bottomResizeBar;
private Element topResizeBar;
private Element bottomResizeBar;
private Element clickTarget; private Element clickTarget;
private final Integer eventIndex; private final Integer eventIndex;
private int slotHeight; private int slotHeight;

+ 5
- 5
client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java Näytä tiedosto

*/ */
package com.vaadin.client.ui.calendar.schedule.dd; package com.vaadin.client.ui.calendar.schedule.dd;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.ui.calendar.CalendarConnector; import com.vaadin.client.ui.calendar.CalendarConnector;
super(connector); super(connector);
} }


private com.google.gwt.user.client.Element currentTargetElement;
private Element currentTargetElement;
private SimpleDayCell currentTargetDay; private SimpleDayCell currentTargetDay;


/* /*
* The element to check * The element to check
* @return * @return
*/ */
private boolean isLocationValid(
com.google.gwt.user.client.Element elementOver) {
com.google.gwt.user.client.Element monthGridElement = calendarConnector
.getWidget().getMonthGrid().getElement();
private boolean isLocationValid(Element elementOver) {
Element monthGridElement = calendarConnector.getWidget().getMonthGrid()
.getElement();


// drops are not allowed in: // drops are not allowed in:
// - weekday header // - weekday header

+ 11
- 12
client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java Näytä tiedosto

*/ */
package com.vaadin.client.ui.calendar.schedule.dd; package com.vaadin.client.ui.calendar.schedule.dd;


import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.ui.calendar.CalendarConnector; import com.vaadin.client.ui.calendar.CalendarConnector;
*/ */
public class CalendarWeekDropHandler extends CalendarDropHandler { public class CalendarWeekDropHandler extends CalendarDropHandler {


private com.google.gwt.user.client.Element currentTargetElement;
private Element currentTargetElement;
private DateCell currentTargetDay; private DateCell currentTargetDay;


public CalendarWeekDropHandler(CalendarConnector connector) { public CalendarWeekDropHandler(CalendarConnector connector) {
* The element to check * The element to check
* @return * @return
*/ */
private boolean isLocationValid(
com.google.gwt.user.client.Element elementOver) {
com.google.gwt.user.client.Element weekGridElement = calendarConnector
.getWidget().getWeekGrid().getElement();
com.google.gwt.user.client.Element timeBarElement = calendarConnector
.getWidget().getWeekGrid().getTimeBar().getElement();

com.google.gwt.user.client.Element todayBarElement = null;
private boolean isLocationValid(Element elementOver) {
Element weekGridElement = calendarConnector.getWidget().getWeekGrid()
.getElement();
Element timeBarElement = calendarConnector.getWidget().getWeekGrid()
.getTimeBar().getElement();

Element todayBarElement = null;
if (calendarConnector.getWidget().getWeekGrid().hasToday()) { if (calendarConnector.getWidget().getWeekGrid().hasToday()) {
todayBarElement = (com.google.gwt.user.client.Element) calendarConnector
.getWidget().getWeekGrid().getDateCellOfToday()
.getTodaybarElement();
todayBarElement = calendarConnector.getWidget().getWeekGrid()
.getDateCellOfToday().getTodaybarElement();
} }


// drops are not allowed in: // drops are not allowed in:

+ 4
- 4
client/src/com/vaadin/client/ui/colorpicker/VColorPickerGrid.java Näytä tiedosto

*/ */
package com.vaadin.client.ui.colorpicker; package com.vaadin.client.ui.colorpicker;


import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers; import com.google.gwt.event.dom.client.HasClickHandlers;
if (changedColor.length == changedX.length if (changedColor.length == changedX.length
&& changedX.length == changedY.length) { && changedX.length == changedY.length) {
for (int c = 0; c < changedColor.length; c++) { for (int c = 0; c < changedColor.length; c++) {
com.google.gwt.user.client.Element element = grid
.getCellFormatter().getElement(
Integer.parseInt(changedX[c]),
Integer.parseInt(changedY[c]));
Element element = grid.getCellFormatter().getElement(
Integer.parseInt(changedX[c]),
Integer.parseInt(changedY[c]));
element.getStyle().setProperty("background", element.getStyle().setProperty("background",
changedColor[c]); changedColor[c]);
} }

+ 8
- 10
client/src/com/vaadin/client/ui/dd/DDUtil.java Näytä tiedosto

*/ */
package com.vaadin.client.ui.dd; package com.vaadin.client.ui.dd;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.vaadin.client.Util; import com.vaadin.client.Util;


public class DDUtil { public class DDUtil {


public static VerticalDropLocation getVerticalDropLocation(
com.google.gwt.user.client.Element element, NativeEvent event,
double topBottomRatio) {
public static VerticalDropLocation getVerticalDropLocation(Element element,
NativeEvent event, double topBottomRatio) {
int offsetHeight = element.getOffsetHeight(); int offsetHeight = element.getOffsetHeight();
return getVerticalDropLocation(element, offsetHeight, event, return getVerticalDropLocation(element, offsetHeight, event,
topBottomRatio); topBottomRatio);
} }


public static VerticalDropLocation getVerticalDropLocation(
com.google.gwt.user.client.Element element, int offsetHeight,
NativeEvent event, double topBottomRatio) {
public static VerticalDropLocation getVerticalDropLocation(Element element,
int offsetHeight, NativeEvent event, double topBottomRatio) {
int clientY = Util.getTouchOrMouseClientY(event); int clientY = Util.getTouchOrMouseClientY(event);
return getVerticalDropLocation(element, offsetHeight, clientY, return getVerticalDropLocation(element, offsetHeight, clientY,
topBottomRatio); topBottomRatio);
} }


public static VerticalDropLocation getVerticalDropLocation(
com.google.gwt.user.client.Element element, int offsetHeight,
int clientY, double topBottomRatio) {
public static VerticalDropLocation getVerticalDropLocation(Element element,
int offsetHeight, int clientY, double topBottomRatio) {


// Event coordinates are relative to the viewport, element absolute // Event coordinates are relative to the viewport, element absolute
// position is relative to the document. Make element position relative // position is relative to the document. Make element position relative
} }


public static HorizontalDropLocation getHorizontalDropLocation( public static HorizontalDropLocation getHorizontalDropLocation(
com.google.gwt.user.client.Element element, NativeEvent event,
Element element, NativeEvent event,
double leftRightRatio) { double leftRightRatio) {
int clientX = Util.getTouchOrMouseClientX(event); int clientX = Util.getTouchOrMouseClientX(event);



+ 6
- 12
client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java Näytä tiedosto

} }


if (currentDropHandler != null) { if (currentDropHandler != null) {
currentDrag
.setElementOver((com.google.gwt.user.client.Element) targetElement);
currentDrag.setElementOver(targetElement);
currentDropHandler.dragEnter(currentDrag); currentDropHandler.dragEnter(currentDrag);
} }
} else if (findDragTarget != null) { } else if (findDragTarget != null) {
currentDrag
.setElementOver((com.google.gwt.user.client.Element) targetElement);
currentDrag.setElementOver(targetElement);
currentDropHandler.dragOver(currentDrag); currentDropHandler.dragOver(currentDrag);
} }
// prevent text selection on IE // prevent text selection on IE
// ApplicationConnection.getConsole().log( // ApplicationConnection.getConsole().log(
// "Target just modified on " // "Target just modified on "
// + event.getType()); // + event.getType());
currentDrag
.setElementOver((com.google.gwt.user.client.Element) targetElement);
currentDrag.setElementOver(targetElement);
break; break;
} }


// ApplicationConnection.getConsole().log( // ApplicationConnection.getConsole().log(
// "DropHandler now" // "DropHandler now"
// + currentDropHandler.getPaintable()); // + currentDropHandler.getPaintable());
currentDrag
.setElementOver((com.google.gwt.user.client.Element) targetElement);
currentDrag.setElementOver(targetElement);
target.dragEnter(currentDrag); target.dragEnter(currentDrag);
} else if (target == null && currentDropHandler != null) { } else if (target == null && currentDropHandler != null) {
// ApplicationConnection.getConsole().log("Invalid state!?"); // ApplicationConnection.getConsole().log("Invalid state!?");
case Event.ONMOUSEMOVE: case Event.ONMOUSEMOVE:
case Event.ONTOUCHMOVE: case Event.ONTOUCHMOVE:
if (currentDropHandler != null) { if (currentDropHandler != null) {
currentDrag
.setElementOver((com.google.gwt.user.client.Element) targetElement);
currentDrag.setElementOver(targetElement);
currentDropHandler.dragOver(currentDrag); currentDropHandler.dragOver(currentDrag);
} }
nativeEvent.preventDefault(); nativeEvent.preventDefault();
*/ */
private VDropHandler findDragTarget(Element element) { private VDropHandler findDragTarget(Element element) {
try { try {
Widget w = Util.findWidget(
(com.google.gwt.user.client.Element) element, null);
Widget w = Util.findWidget(element, null);
if (w == null) { if (w == null) {
return null; return null;
} }

+ 82
- 6
client/src/com/vaadin/client/ui/dd/VDragEvent.java Näytä tiedosto

import java.util.Map; import java.util.Map;


import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.TableElement; import com.google.gwt.dom.client.TableElement;
import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.event.dom.client.MouseOverEvent; import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.user.client.DOM;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util; import com.vaadin.client.Util;




private HashMap<String, Object> dropDetails = new HashMap<String, Object>(); private HashMap<String, Object> dropDetails = new HashMap<String, Object>();


private com.google.gwt.user.client.Element elementOver;
private Element elementOver;


VDragEvent(VTransferable t, NativeEvent startEvent) { VDragEvent(VTransferable t, NativeEvent startEvent) {
transferable = t; transferable = t;
*/ */
public com.google.gwt.user.client.Element getElementOver() { public com.google.gwt.user.client.Element getElementOver() {
if (elementOver != null) { if (elementOver != null) {
return elementOver;
return DOM.asOld(elementOver);
} else if (currentGwtEvent != null) { } else if (currentGwtEvent != null) {
return currentGwtEvent.getEventTarget().cast(); return currentGwtEvent.getEventTarget().cast();
} }
return null; return null;
} }


/**
* @deprecated As of 7.2, call or override {@link #setElementOver(Element)}
* instead
*/
@Deprecated
public void setElementOver(com.google.gwt.user.client.Element targetElement) { public void setElementOver(com.google.gwt.user.client.Element targetElement) {
elementOver = targetElement; elementOver = targetElement;
} }


/**
* @since 7.2
*/
public void setElementOver(Element targetElement) {
setElementOver(DOM.asOld(targetElement));
}

/** /**
* Sets the drag image used for current drag and drop operation. Drag image * Sets the drag image used for current drag and drop operation. Drag image
* is displayed next to mouse cursor during drag and drop. * is displayed next to mouse cursor during drag and drop.
* to HTML5 DataTransfer * to HTML5 DataTransfer
* *
* @param node * @param node
* @deprecated As of 7.2, call or override {@link #setDragImage(Element)}
* instead
*/ */
@Deprecated
public void setDragImage(com.google.gwt.user.client.Element node) { public void setDragImage(com.google.gwt.user.client.Element node) {
setDragImage(node, DEFAULT_OFFSET, DEFAULT_OFFSET); setDragImage(node, DEFAULT_OFFSET, DEFAULT_OFFSET);
} }


/**
* Sets the drag image used for current drag and drop operation. Drag image
* is displayed next to mouse cursor during drag and drop.
* <p>
* The element to be used as drag image will automatically get CSS style
* name "v-drag-element".
*
* TODO decide if this method should be here or in {@link VTransferable} (in
* HTML5 it is in DataTransfer) or {@link VDragAndDropManager}
*
* TODO should be possible to override behavior. Like to proxy the element
* to HTML5 DataTransfer
*
* @param node
*
* @since 7.2
*/
public void setDragImage(Element node) {
setDragImage(DOM.asOld(node));
}

/** /**
* TODO consider using similar smaller (than map) api as in Transferable * TODO consider using similar smaller (than map) api as in Transferable
* *
* the horizontal offset of drag image from mouse cursor * the horizontal offset of drag image from mouse cursor
* @param offsetY * @param offsetY
* the vertical offset of drag image from mouse cursor * the vertical offset of drag image from mouse cursor
* @deprecated As of 7.2, call or override
* {@link #setDragImage(Element,int,int)} instead
*/ */
@Deprecated
public void setDragImage(com.google.gwt.user.client.Element element, public void setDragImage(com.google.gwt.user.client.Element element,
int offsetX, int offsetY) { int offsetX, int offsetY) {
element.getStyle().setMarginLeft(offsetX, Unit.PX); element.getStyle().setMarginLeft(offsetX, Unit.PX);
element.getStyle().setMarginTop(offsetY, Unit.PX); element.getStyle().setMarginTop(offsetY, Unit.PX);
VDragAndDropManager.get().setDragElement(element); VDragAndDropManager.get().setDragElement(element);

}

/**
* Sets the drag image used for current drag and drop operation. Drag image
* is displayed next to mouse cursor during drag and drop.
* <p>
* The element to be used as drag image will automatically get CSS style
* name "v-drag-element".
*
* @param element
* the dom element to be positioned next to mouse cursor
* @param offsetX
* the horizontal offset of drag image from mouse cursor
* @param offsetY
* the vertical offset of drag image from mouse cursor
*
* @since 7.2
*/
public void setDragImage(Element element, int offsetX, int offsetY) {
setDragImage(DOM.asOld(element), offsetX, offsetY);
} }


/** /**
* if drag image is not currently set for this drag operation. * if drag image is not currently set for this drag operation.
*/ */
public com.google.gwt.user.client.Element getDragImage() { public com.google.gwt.user.client.Element getDragImage() {
return (com.google.gwt.user.client.Element) VDragAndDropManager.get()
.getDragElement();
return DOM.asOld(VDragAndDropManager.get().getDragElement());
} }


/** /**
* @param alignImageToEvent * @param alignImageToEvent
* if true, proxy image is aligned to start event, else next to * if true, proxy image is aligned to start event, else next to
* mouse cursor * mouse cursor
* @deprecated As of 7.2, call or override
* {@link #createDragImage(Element,boolean)} instead
*/ */
@Deprecated
public void createDragImage(com.google.gwt.user.client.Element element, public void createDragImage(com.google.gwt.user.client.Element element,
boolean alignImageToEvent) { boolean alignImageToEvent) {
com.google.gwt.user.client.Element cloneNode = (com.google.gwt.user.client.Element) element
.cloneNode(true);
Element cloneNode = (Element) element.cloneNode(true);
if (BrowserInfo.get().isIE()) { if (BrowserInfo.get().isIE()) {
if (cloneNode.getTagName().toLowerCase().equals("tr")) { if (cloneNode.getTagName().toLowerCase().equals("tr")) {
TableElement table = Document.get().createTableElement(); TableElement table = Document.get().createTableElement();


} }


/**
* Automatically tries to create a proxy image from given element.
*
* @param element
* @param alignImageToEvent
* if true, proxy image is aligned to start event, else next to
* mouse cursor
* @since 7.2
*/
public void createDragImage(Element element, boolean alignImageToEvent) {
createDragImage(DOM.asOld(element), alignImageToEvent);
}

} }

+ 3
- 2
client/src/com/vaadin/client/ui/embedded/EmbeddedConnector.java Näytä tiedosto

import java.util.Map; import java.util.Map;


import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.NodeList;
getWidget().type = uidl.getStringAttribute("type"); getWidget().type = uidl.getStringAttribute("type");
if (getWidget().type.equals("image")) { if (getWidget().type.equals("image")) {
getWidget().addStyleName(VEmbedded.CLASSNAME + "-image"); getWidget().addStyleName(VEmbedded.CLASSNAME + "-image");
com.google.gwt.user.client.Element el = null;
Element el = null;
boolean created = false; boolean created = false;
NodeList<Node> nodes = getWidget().getElement().getChildNodes(); NodeList<Node> nodes = getWidget().getElement().getChildNodes();
if (nodes != null && nodes.getLength() == 1) { if (nodes != null && nodes.getLength() == 1) {
Node n = nodes.getItem(0); Node n = nodes.getItem(0);
if (n.getNodeType() == Node.ELEMENT_NODE) { if (n.getNodeType() == Node.ELEMENT_NODE) {
com.google.gwt.user.client.Element e = (com.google.gwt.user.client.Element) n;
Element e = (Element) n;
if (e.getTagName().equals("IMG")) { if (e.getTagName().equals("IMG")) {
el = e; el = e;
} }

+ 2
- 6
client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java Näytä tiedosto

TooltipInfo info = null; TooltipInfo info = null;


if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(
(com.google.gwt.user.client.Element) element,
VFormLayout.Caption.class);
Object node = Util.findWidget(element, VFormLayout.Caption.class);


if (node != null) { if (node != null) {
VFormLayout.Caption caption = (VFormLayout.Caption) node; VFormLayout.Caption caption = (VFormLayout.Caption) node;
info = caption.getOwner().getTooltipInfo(element); info = caption.getOwner().getTooltipInfo(element);
} else { } else {


node = Util.findWidget(
(com.google.gwt.user.client.Element) element,
VFormLayout.ErrorFlag.class);
node = Util.findWidget(element, VFormLayout.ErrorFlag.class);


if (node != null) { if (node != null) {
VFormLayout.ErrorFlag flag = (VFormLayout.ErrorFlag) node; VFormLayout.ErrorFlag flag = (VFormLayout.ErrorFlag) node;

+ 3
- 3
client/src/com/vaadin/client/ui/layout/VLayoutSlot.java Näytä tiedosto

package com.vaadin.client.ui.layout; package com.vaadin.client.ui.layout;


import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;


public abstract class VLayoutSlot { public abstract class VLayoutSlot {


private final com.google.gwt.user.client.Element wrapper = Document.get()
.createDivElement().cast();
private final Element wrapper = Document.get().createDivElement();


private AlignmentInfo alignment; private AlignmentInfo alignment;
private VCaption caption; private VCaption caption;
} }


public com.google.gwt.user.client.Element getWrapperElement() { public com.google.gwt.user.client.Element getWrapperElement() {
return wrapper;
return DOM.asOld(wrapper);
} }


public void setExpandRatio(double expandRatio) { public void setExpandRatio(double expandRatio) {

+ 13
- 13
client/src/com/vaadin/client/ui/menubar/MenuBar.java Näytä tiedosto

import java.util.List; import java.util.List;


import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
@Deprecated @Deprecated
public class MenuBar extends Widget implements PopupListener { public class MenuBar extends Widget implements PopupListener {


private final com.google.gwt.user.client.Element body;
private final Element body;
private final ArrayList<MenuItem> items = new ArrayList<MenuItem>(); private final ArrayList<MenuItem> items = new ArrayList<MenuItem>();
private MenuBar parentMenu; private MenuBar parentMenu;
private PopupPanel popup; private PopupPanel popup;
public MenuBar(boolean vertical) { public MenuBar(boolean vertical) {
super(); super();


final com.google.gwt.user.client.Element table = DOM.createTable();
final Element table = DOM.createTable();
body = DOM.createTBody(); body = DOM.createTBody();
DOM.appendChild(table, body); DOM.appendChild(table, body);


if (!vertical) { if (!vertical) {
final com.google.gwt.user.client.Element tr = DOM.createTR();
final Element tr = DOM.createTR();
DOM.appendChild(body, tr); DOM.appendChild(body, tr);
} }


this.vertical = vertical; this.vertical = vertical;


final com.google.gwt.user.client.Element outer = DOM.createDiv();
final Element outer = DOM.createDiv();
DOM.appendChild(outer, table); DOM.appendChild(outer, table);
setElement(outer); setElement(outer);


* the item to be added * the item to be added
*/ */
public void addItem(MenuItem item) { public void addItem(MenuItem item) {
com.google.gwt.user.client.Element tr;
Element tr;
if (vertical) { if (vertical) {
tr = DOM.createTR(); tr = DOM.createTR();
DOM.appendChild(body, tr); DOM.appendChild(body, tr);
* Removes all menu items from this menu bar. * Removes all menu items from this menu bar.
*/ */
public void clearItems() { public void clearItems() {
final com.google.gwt.user.client.Element container = getItemContainerElement();
final Element container = getItemContainerElement();
while (DOM.getChildCount(container) > 0) { while (DOM.getChildCount(container) > 0) {
DOM.removeChild(container, DOM.getChild(container, 0)); DOM.removeChild(container, DOM.getChild(container, 0));
} }
return; return;
} }


final com.google.gwt.user.client.Element container = getItemContainerElement();
final Element container = getItemContainerElement();
DOM.removeChild(container, DOM.getChild(container, idx)); DOM.removeChild(container, DOM.getChild(container, idx));
items.remove(idx); items.remove(idx);
} }
// If the event target is part of the parent menu, suppress // If the event target is part of the parent menu, suppress
// the // the
// event altogether. // event altogether.
final com.google.gwt.user.client.Element target = DOM
.eventGetTarget(event);
final com.google.gwt.user.client.Element parentMenuElement = item
.getParentMenu().getElement();
final Element target = DOM.eventGetTarget(event);
final Element parentMenuElement = item.getParentMenu()
.getElement();
if (DOM.isOrHasChild(parentMenuElement, target)) { if (DOM.isOrHasChild(parentMenuElement, target)) {
return false; return false;
} }
} }
} }


private MenuItem findItem(com.google.gwt.user.client.Element hItem) {
private MenuItem findItem(Element hItem) {
for (int i = 0; i < items.size(); ++i) { for (int i = 0; i < items.size(); ++i) {
final MenuItem item = items.get(i); final MenuItem item = items.get(i);
if (DOM.isOrHasChild(item.getElement(), hItem)) { if (DOM.isOrHasChild(item.getElement(), hItem)) {
return null; return null;
} }


private com.google.gwt.user.client.Element getItemContainerElement() {
private Element getItemContainerElement() {
if (vertical) { if (vertical) {
return body; return body;
} else { } else {

+ 1
- 1
client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java Näytä tiedosto

if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {


VMenuBar.CustomMenuItem item = getWidget().getMenuItemWithElement( VMenuBar.CustomMenuItem item = getWidget().getMenuItemWithElement(
(com.google.gwt.user.client.Element) element);
element);
if (item != null) { if (item != null) {
info = item.getTooltip(); info = item.getTooltip();
} }

+ 7
- 10
client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java Näytä tiedosto



import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
public void onElementResize(ElementResizeEvent e) { public void onElementResize(ElementResizeEvent e) {


// Get all needed element references // Get all needed element references
com.google.gwt.user.client.Element captionElement = (com.google.gwt.user.client.Element) e
.getElement().cast();
Element captionElement = e.getElement();


// Caption position determines if the widget element is the first or // Caption position determines if the widget element is the first or
// last child inside the caption wrap // last child inside the caption wrap
CaptionPosition pos = getWidget().getCaptionPositionFromElement( CaptionPosition pos = getWidget().getCaptionPositionFromElement(
(com.google.gwt.user.client.Element) captionElement
.getParentElement().cast());
captionElement.getParentElement());


// The default is the last child // The default is the last child
com.google.gwt.user.client.Element widgetElement = captionElement
.getParentElement().getLastChild().cast();
Element widgetElement = captionElement.getParentElement()
.getLastChild().cast();


// ...but if caption position is bottom or right, the widget is the // ...but if caption position is bottom or right, the widget is the
// first child // first child
@Override @Override
public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) { public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) {
if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Slot slot = Util.findWidget(
(com.google.gwt.user.client.Element) element, Slot.class);
Slot slot = Util.findWidget(element, Slot.class);
if (slot != null && slot.getCaptionElement() != null if (slot != null && slot.getCaptionElement() != null
&& slot.getParent() == getWidget() && slot.getParent() == getWidget()
&& slot.getCaptionElement().isOrHasChild(element)) { && slot.getCaptionElement().isOrHasChild(element)) {
for (ComponentConnector child : getChildComponents()) { for (ComponentConnector child : getChildComponents()) {
Widget childWidget = child.getWidget(); Widget childWidget = child.getWidget();
Slot slot = getWidget().getSlot(childWidget); Slot slot = getWidget().getSlot(childWidget);
com.google.gwt.user.client.Element captionElement = slot
.getCaptionElement();
Element captionElement = slot.getCaptionElement();
CaptionPosition captionPosition = slot.getCaptionPosition(); CaptionPosition captionPosition = slot.getCaptionPosition();


int pixelHeight = layoutManager.getOuterHeight(childWidget int pixelHeight = layoutManager.getOuterHeight(childWidget

+ 13
- 14
client/src/com/vaadin/client/ui/orderedlayout/Slot.java Näytä tiedosto

import com.google.gwt.aria.client.Roles; import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Timer;


public static final String SLOT_CLASSNAME = "v-slot"; public static final String SLOT_CLASSNAME = "v-slot";


private com.google.gwt.user.client.Element spacer;
private com.google.gwt.user.client.Element captionWrap;
private com.google.gwt.user.client.Element caption;
private com.google.gwt.user.client.Element captionText;
private Element spacer;
private Element captionWrap;
private Element caption;
private Element captionText;
private Icon icon; private Icon icon;
private com.google.gwt.user.client.Element errorIcon;
private com.google.gwt.user.client.Element requiredIcon;
private Element errorIcon;
private Element requiredIcon;


private ElementResizeListener captionResizeListener; private ElementResizeListener captionResizeListener;




@Override @Override
public void onElementResize(ElementResizeEvent e) { public void onElementResize(ElementResizeEvent e) {
com.google.gwt.user.client.Element caption = getCaptionElement();
Element caption = getCaptionElement();
if (caption != null) { if (caption != null) {
Util.forceIE8Redraw(caption); Util.forceIE8Redraw(caption);
} }
* @return * @return
*/ */
public com.google.gwt.user.client.Element getSpacingElement() { public com.google.gwt.user.client.Element getSpacingElement() {
return spacer;
return DOM.asOld(spacer);
} }


/** /**


// Caption wrappers // Caption wrappers
Widget widget = getWidget(); Widget widget = getWidget();
final com.google.gwt.user.client.Element focusedElement = Util
.getFocusedElement();
final Element focusedElement = Util.getFocusedElement();
// By default focus will not be lost // By default focus will not be lost
boolean focusLost = false; boolean focusLost = false;
if (captionText != null || icon != null || error != null || required) { if (captionText != null || icon != null || error != null || required) {


if (focusLost) { if (focusLost) {
// Find out what element is currently focused. // Find out what element is currently focused.
com.google.gwt.user.client.Element currentFocus = Util
.getFocusedElement();
Element currentFocus = Util.getFocusedElement();
if (currentFocus != null if (currentFocus != null
&& currentFocus.equals(Document.get().getBody())) { && currentFocus.equals(Document.get().getBody())) {
// Focus has moved to BodyElement and should be moved back to // Focus has moved to BodyElement and should be moved back to
* Get the slots caption element * Get the slots caption element
*/ */
public com.google.gwt.user.client.Element getCaptionElement() { public com.google.gwt.user.client.Element getCaptionElement() {
return caption;
return DOM.asOld(caption);
} }


private boolean relativeWidth = false; private boolean relativeWidth = false;
if (captionWrap == null) { if (captionWrap == null) {
return getElement(); return getElement();
} else { } else {
return captionWrap;
return DOM.asOld(captionWrap);
} }
} }



+ 72
- 7
client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java Näytä tiedosto

import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;


private Map<Widget, Slot> widgetToSlot = new HashMap<Widget, Slot>(); private Map<Widget, Slot> widgetToSlot = new HashMap<Widget, Slot>();


private com.google.gwt.user.client.Element expandWrapper;
private Element expandWrapper;


private LayoutManager layoutManager; private LayoutManager layoutManager;




/** /**
* {@inheritDoc} * {@inheritDoc}
*
* @deprecated As of 7.2, use or override
* {@link #insert(Widget, Element, int, boolean)} instead.
*/ */
@Override @Override
@Deprecated
protected void insert(Widget child, protected void insert(Widget child,
com.google.gwt.user.client.Element container, int beforeIndex, com.google.gwt.user.client.Element container, int beforeIndex,
boolean domInsert) { boolean domInsert) {
getChildren().insert(child, beforeIndex); getChildren().insert(child, beforeIndex);


// Physical attach. // Physical attach.
container = expandWrapper != null ? expandWrapper : getElement();
container = expandWrapper != null ? DOM.asOld(expandWrapper)
: getElement();
if (domInsert) { if (domInsert) {
if (spacing) { if (spacing) {
if (beforeIndex != 0) { if (beforeIndex != 0) {
adopt(child); adopt(child);
} }


/**
* {@inheritDoc}
*
* @since 7.2
*/
@Override
protected void insert(Widget child, Element container, int beforeIndex,
boolean domInsert) {
insert(child, DOM.asOld(container), beforeIndex, domInsert);
}

/** /**
* Remove a slot from the layout * Remove a slot from the layout
* *
* @param widgetElement * @param widgetElement
* The element of the widget ( Same as getWidget().getElement() ) * The element of the widget ( Same as getWidget().getElement() )
* @return * @return
* @deprecated As of 7.2, call or override {@link #getSlot(Element)} instead
*/ */
@Deprecated
public Slot getSlot(com.google.gwt.user.client.Element widgetElement) { public Slot getSlot(com.google.gwt.user.client.Element widgetElement) {
for (Map.Entry<Widget, Slot> entry : widgetToSlot.entrySet()) { for (Map.Entry<Widget, Slot> entry : widgetToSlot.entrySet()) {
if (entry.getKey().getElement() == widgetElement) { if (entry.getKey().getElement() == widgetElement) {
return null; return null;
} }


/**
* Gets a slot based on the widget element. If no slot is found then null is
* returned.
*
* @param widgetElement
* The element of the widget ( Same as getWidget().getElement() )
* @return
*
* @since 7.2
*/
public Slot getSlot(Element widgetElement) {
return getSlot(DOM.asOld(widgetElement));
}

/** /**
* Set the layout manager for the layout * Set the layout manager for the layout
* *
* The wrapping element * The wrapping element
* *
* @return The caption position * @return The caption position
* @deprecated As of 7.2, call or override
* {@link #getCaptionPositionFromElement(Element)} instead
*/ */
@Deprecated
public CaptionPosition getCaptionPositionFromElement( public CaptionPosition getCaptionPositionFromElement(
com.google.gwt.user.client.Element captionWrap) { com.google.gwt.user.client.Element captionWrap) {
RegExp captionPositionRegexp = RegExp.compile("v-caption-on-(\\S+)"); RegExp captionPositionRegexp = RegExp.compile("v-caption-on-(\\S+)");
return captionPosition; return captionPosition;
} }


/**
* Deducts the caption position by examining the wrapping element.
* <p>
* For internal use only. May be removed or replaced in the future.
*
* @param captionWrap
* The wrapping element
*
* @return The caption position
* @since 7.2
*/
public CaptionPosition getCaptionPositionFromElement(Element captionWrap) {
return getCaptionPositionFromElement(DOM.asOld(captionWrap));
}

/** /**
* Update the offset off the caption relative to the slot * Update the offset off the caption relative to the slot
* <p> * <p>
* *
* @param caption * @param caption
* The caption element * The caption element
* @deprecated As of 7.2, call or override
* {@link #updateCaptionOffset(Element)} instead
*/ */
@Deprecated
public void updateCaptionOffset(com.google.gwt.user.client.Element caption) { public void updateCaptionOffset(com.google.gwt.user.client.Element caption) {


com.google.gwt.user.client.Element captionWrap = caption
.getParentElement().cast();
Element captionWrap = caption.getParentElement();


Style captionWrapStyle = captionWrap.getStyle(); Style captionWrapStyle = captionWrap.getStyle();
captionWrapStyle.clearPaddingTop(); captionWrapStyle.clearPaddingTop();
} }
} }


/**
* Update the offset off the caption relative to the slot
* <p>
* For internal use only. May be removed or replaced in the future.
*
* @param caption
* The caption element
* @since 7.2
*/
public void updateCaptionOffset(Element caption) {
updateCaptionOffset(DOM.asOld(caption));
}

/** /**
* Set the margin of the layout * Set the margin of the layout
* *
// Give each expanded child its own share // Give each expanded child its own share
for (Slot slot : widgetToSlot.values()) { for (Slot slot : widgetToSlot.values()) {


com.google.gwt.user.client.Element slotElement = slot.getElement();
Element slotElement = slot.getElement();
slotElement.removeAttribute("aria-hidden"); slotElement.removeAttribute("aria-hidden");


Style slotStyle = slotElement.getStyle(); Style slotStyle = slotElement.getStyle();


lastExpandSize = -1; lastExpandSize = -1;
while (expandWrapper.getChildCount() > 0) { while (expandWrapper.getChildCount() > 0) {
com.google.gwt.user.client.Element el = expandWrapper.getChild(
0).cast();
Element el = expandWrapper.getChild(0).cast();
getElement().appendChild(el); getElement().appendChild(el);
if (vertical) { if (vertical) {
el.getStyle().clearHeight(); el.getStyle().clearHeight();

+ 4
- 3
client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java Näytä tiedosto

import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;


import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.dom.client.DomEvent.Type;
import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;


@Override @Override
protected boolean shouldFireEvent(DomEvent<?> event) { protected boolean shouldFireEvent(DomEvent<?> event) {
com.google.gwt.user.client.Element target = event.getNativeEvent()
.getEventTarget().cast();
Element target = event.getNativeEvent().getEventTarget().cast();
if (!getWidget().splitter.isOrHasChild(target)) { if (!getWidget().splitter.isOrHasChild(target)) {
return false; return false;
} }


@Override @Override
protected com.google.gwt.user.client.Element getRelativeToElement() { protected com.google.gwt.user.client.Element getRelativeToElement() {
return getWidget().splitter;
return DOM.asOld(getWidget().splitter);
} }


@Override @Override

+ 1
- 3
client/src/com/vaadin/client/ui/table/TableConnector.java Näytä tiedosto

TooltipInfo info = null; TooltipInfo info = null;


if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(
(com.google.gwt.user.client.Element) element,
VScrollTableRow.class);
Object node = Util.findWidget(element, VScrollTableRow.class);


if (node != null) { if (node != null) {
VScrollTableRow row = (VScrollTableRow) node; VScrollTableRow row = (VScrollTableRow) node;

+ 1
- 3
client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java Näytä tiedosto



// Find a tooltip for the tab, if the element is a tab // Find a tooltip for the tab, if the element is a tab
if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(
(com.google.gwt.user.client.Element) element,
VTabsheet.TabCaption.class);
Object node = Util.findWidget(element, VTabsheet.TabCaption.class);


if (node != null) { if (node != null) {
VTabsheet.TabCaption caption = (VTabsheet.TabCaption) node; VTabsheet.TabCaption caption = (VTabsheet.TabCaption) node;

+ 1
- 3
client/src/com/vaadin/client/ui/tree/TreeConnector.java Näytä tiedosto



// Try to find a tooltip for a node // Try to find a tooltip for a node
if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(
(com.google.gwt.user.client.Element) element,
TreeNode.class);
Object node = Util.findWidget(element, TreeNode.class);


if (node != null) { if (node != null) {
TreeNode tnode = (TreeNode) node; TreeNode tnode = (TreeNode) node;

+ 1
- 3
client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java Näytä tiedosto

TooltipInfo info = null; TooltipInfo info = null;


if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(
(com.google.gwt.user.client.Element) element,
VTreeTableRow.class);
Object node = Util.findWidget(element, VTreeTableRow.class);


if (node != null) { if (node != null) {
VTreeTableRow row = (VTreeTableRow) node; VTreeTableRow row = (VTreeTableRow) node;

+ 2
- 2
client/src/com/vaadin/client/ui/ui/UIConnector.java Näytä tiedosto

import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.HeadElement; import com.google.gwt.dom.client.HeadElement;
import com.google.gwt.dom.client.LinkElement; import com.google.gwt.dom.client.LinkElement;
import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NativeEvent;


@Override @Override
public void onScroll(ScrollEvent event) { public void onScroll(ScrollEvent event) {
com.google.gwt.user.client.Element element = getWidget()
.getElement();
Element element = getWidget().getElement();
int newScrollTop = element.getScrollTop(); int newScrollTop = element.getScrollTop();
int newScrollLeft = element.getScrollLeft(); int newScrollLeft = element.getScrollLeft();
if (newScrollTop != lastSentScrollTop if (newScrollTop != lastSentScrollTop

+ 1
- 1
client/src/com/vaadin/client/ui/window/WindowConnector.java Näytä tiedosto

Style childStyle = layoutElement.getStyle(); Style childStyle = layoutElement.getStyle();


// IE8 needs some hackery to measure its content correctly // IE8 needs some hackery to measure its content correctly
Util.forceIE8Redraw((com.google.gwt.user.client.Element) layoutElement);
Util.forceIE8Redraw(layoutElement);


if (content.isRelativeHeight() && !BrowserInfo.get().isIE9()) { if (content.isRelativeHeight() && !BrowserInfo.get().isIE9()) {
childStyle.setPosition(Position.ABSOLUTE); childStyle.setPosition(Position.ABSOLUTE);

+ 4
- 6
uitest/src/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java Näytä tiedosto



package com.vaadin.tests.minitutorials.v7a2; package com.vaadin.tests.minitutorials.v7a2;


import com.google.gwt.dom.client.Element;
import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.layout.ElementResizeEvent; import com.vaadin.client.ui.layout.ElementResizeEvent;


@Override @Override
protected void init() { protected void init() {
com.google.gwt.user.client.Element button = getWidget().getWidget(1)
.getElement();
Element button = getWidget().getWidget(1).getElement();
getLayoutManager().addElementResizeListener(button, listener); getLayoutManager().addElementResizeListener(button, listener);


getLayoutManager().registerDependency(this, button); getLayoutManager().registerDependency(this, button);


@Override @Override
public void onUnregister() { public void onUnregister() {
com.google.gwt.user.client.Element button = getWidget().getWidget(1)
.getElement();
Element button = getWidget().getWidget(1).getElement();
getLayoutManager().removeElementResizeListener(button, listener); getLayoutManager().removeElementResizeListener(button, listener);


getLayoutManager().unregisterDependency(this, button); getLayoutManager().unregisterDependency(this, button);


@Override @Override
public void layout() { public void layout() {
com.google.gwt.user.client.Element button = getWidget().getWidget(1)
.getElement();
Element button = getWidget().getWidget(1).getElement();
int buttonWidth = getLayoutManager().getOuterWidth(button); int buttonWidth = getLayoutManager().getOuterWidth(button);
buttonWidth -= getLayoutManager().getMarginRight(button); buttonWidth -= getLayoutManager().getMarginRight(button);
getWidget().adjustButtonSpace(buttonWidth); getWidget().adjustButtonSpace(buttonWidth);

Loading…
Peruuta
Tallenna