Browse Source

Separate pure client side util methods to a new class (#15553, #15544)

* Deprecated old methods in Util for backwards compatibility

Change-Id: I9de5e6b930d9f2c0268967dc7b1cf465e6310280
tags/7.4.0.beta2
Artur Signell 9 years ago
parent
commit
bf8836bb56
86 changed files with 2106 additions and 1444 deletions
  1. 2
    2
      client/src/com/vaadin/client/ApplicationConfiguration.java
  2. 9
    7
      client/src/com/vaadin/client/ApplicationConnection.java
  3. 3
    2
      client/src/com/vaadin/client/BrowserInfo.java
  4. 5
    4
      client/src/com/vaadin/client/JavaScriptConnectorHelper.java
  5. 9
    6
      client/src/com/vaadin/client/LayoutManager.java
  6. 1
    1
      client/src/com/vaadin/client/LayoutManagerIE8.java
  7. 2
    2
      client/src/com/vaadin/client/MeasuredSize.java
  8. 2
    2
      client/src/com/vaadin/client/MouseEventDetailsBuilder.java
  9. 1
    1
      client/src/com/vaadin/client/RenderSpace.java
  10. 3
    3
      client/src/com/vaadin/client/ResourceLoader.java
  11. 1
    1
      client/src/com/vaadin/client/SuperDevMode.java
  12. 189
    1076
      client/src/com/vaadin/client/Util.java
  13. 19
    17
      client/src/com/vaadin/client/VCaption.java
  14. 1
    1
      client/src/com/vaadin/client/VUIDLBrowser.java
  15. 1479
    0
      client/src/com/vaadin/client/WidgetUtil.java
  16. 2
    2
      client/src/com/vaadin/client/communication/StateChangeEvent.java
  17. 10
    9
      client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java
  18. 2
    1
      client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
  19. 3
    3
      client/src/com/vaadin/client/connectors/AbstractRendererConnector.java
  20. 6
    5
      client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java
  21. 5
    4
      client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java
  22. 3
    2
      client/src/com/vaadin/client/debug/internal/HierarchySection.java
  23. 7
    4
      client/src/com/vaadin/client/debug/internal/TestBenchSection.java
  24. 1
    1
      client/src/com/vaadin/client/extensions/ResponsiveConnector.java
  25. 3
    2
      client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java
  26. 5
    4
      client/src/com/vaadin/client/renderers/ClickableRenderer.java
  27. 2
    2
      client/src/com/vaadin/client/renderers/WidgetRenderer.java
  28. 6
    5
      client/src/com/vaadin/client/ui/AbstractClickEventHandler.java
  29. 4
    3
      client/src/com/vaadin/client/ui/AbstractComponentConnector.java
  30. 9
    6
      client/src/com/vaadin/client/ui/AbstractConnector.java
  31. 2
    2
      client/src/com/vaadin/client/ui/MediaBaseConnector.java
  32. 7
    7
      client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
  33. 2
    2
      client/src/com/vaadin/client/ui/VAccordion.java
  34. 3
    2
      client/src/com/vaadin/client/ui/VButton.java
  35. 2
    2
      client/src/com/vaadin/client/ui/VCalendarPanel.java
  36. 4
    4
      client/src/com/vaadin/client/ui/VContextMenu.java
  37. 3
    1
      client/src/com/vaadin/client/ui/VCustomLayout.java
  38. 21
    20
      client/src/com/vaadin/client/ui/VEmbedded.java
  39. 17
    15
      client/src/com/vaadin/client/ui/VFilterSelect.java
  40. 21
    16
      client/src/com/vaadin/client/ui/VFlash.java
  41. 2
    1
      client/src/com/vaadin/client/ui/VLabel.java
  42. 6
    4
      client/src/com/vaadin/client/ui/VMenuBar.java
  43. 4
    4
      client/src/com/vaadin/client/ui/VNotification.java
  44. 3
    2
      client/src/com/vaadin/client/ui/VOptionGroup.java
  45. 2
    1
      client/src/com/vaadin/client/ui/VOverlay.java
  46. 8
    1
      client/src/com/vaadin/client/ui/VPopupView.java
  47. 43
    37
      client/src/com/vaadin/client/ui/VScrollTable.java
  48. 4
    4
      client/src/com/vaadin/client/ui/VSlider.java
  49. 3
    3
      client/src/com/vaadin/client/ui/VTabsheet.java
  50. 2
    2
      client/src/com/vaadin/client/ui/VTextArea.java
  51. 2
    2
      client/src/com/vaadin/client/ui/VTextField.java
  52. 4
    3
      client/src/com/vaadin/client/ui/VTree.java
  53. 4
    3
      client/src/com/vaadin/client/ui/VTreeTable.java
  54. 6
    6
      client/src/com/vaadin/client/ui/VTwinColSelect.java
  55. 2
    2
      client/src/com/vaadin/client/ui/VUI.java
  56. 16
    15
      client/src/com/vaadin/client/ui/VWindow.java
  57. 3
    2
      client/src/com/vaadin/client/ui/accordion/AccordionConnector.java
  58. 2
    2
      client/src/com/vaadin/client/ui/calendar/CalendarConnector.java
  59. 3
    3
      client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java
  60. 2
    2
      client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java
  61. 3
    2
      client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java
  62. 3
    3
      client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java
  63. 2
    2
      client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java
  64. 4
    4
      client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java
  65. 3
    3
      client/src/com/vaadin/client/ui/dd/DDUtil.java
  66. 12
    12
      client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
  67. 3
    3
      client/src/com/vaadin/client/ui/dd/VDragEvent.java
  68. 5
    3
      client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java
  69. 2
    2
      client/src/com/vaadin/client/ui/label/LabelConnector.java
  70. 2
    1
      client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java
  71. 2
    2
      client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java
  72. 2
    1
      client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
  73. 6
    6
      client/src/com/vaadin/client/ui/orderedlayout/Slot.java
  74. 2
    1
      client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java
  75. 3
    3
      client/src/com/vaadin/client/ui/table/TableConnector.java
  76. 3
    2
      client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java
  77. 1
    1
      client/src/com/vaadin/client/ui/textarea/TextAreaConnector.java
  78. 3
    3
      client/src/com/vaadin/client/ui/tree/TreeConnector.java
  79. 2
    2
      client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java
  80. 2
    2
      client/src/com/vaadin/client/ui/window/WindowConnector.java
  81. 2
    2
      client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java
  82. 4
    4
      client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
  83. 22
    20
      client/src/com/vaadin/client/widgets/Escalator.java
  84. 11
    7
      client/src/com/vaadin/client/widgets/Grid.java
  85. 3
    3
      uitest/src/com/vaadin/tests/widgetset/client/BasicExtensionTestConnector.java
  86. 2
    2
      uitest/src/com/vaadin/tests/widgetset/client/CustomUIConnector.java

+ 2
- 2
client/src/com/vaadin/client/ApplicationConfiguration.java View File

* desired locations even if the base URL of the page changes later * desired locations even if the base URL of the page changes later
* (e.g. with pushState) * (e.g. with pushState)
*/ */
serviceUrl = Util.getAbsoluteUrl(serviceUrl);
serviceUrl = WidgetUtil.getAbsoluteUrl(serviceUrl);
} }
// Ensure there's an ending slash (to make appending e.g. UIDL work) // Ensure there's an ending slash (to make appending e.g. UIDL work)
if (!useServiceUrlPathParam() && !serviceUrl.endsWith("/")) { if (!useServiceUrlPathParam() && !serviceUrl.endsWith("/")) {
serviceUrl += '/'; serviceUrl += '/';
} }


vaadinDirUrl = Util.getAbsoluteUrl(jsoConfiguration
vaadinDirUrl = WidgetUtil.getAbsoluteUrl(jsoConfiguration
.getConfigString(ApplicationConstants.VAADIN_DIR_URL)); .getConfigString(ApplicationConstants.VAADIN_DIR_URL));
uiId = jsoConfiguration.getConfigInteger(UIConstants.UI_ID_PARAMETER) uiId = jsoConfiguration.getConfigInteger(UIConstants.UI_ID_PARAMETER)
.intValue(); .intValue();

+ 9
- 7
client/src/com/vaadin/client/ApplicationConnection.java View File

import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConfiguration.ErrorMessage; import com.vaadin.client.ApplicationConfiguration.ErrorMessage;
import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.ResourceLoader.ResourceLoadListener;
import com.vaadin.client.communication.HasJavaScriptConnectorHelper; import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
} catch (NoDataException e) { } catch (NoDataException e) {
throw new RuntimeException( throw new RuntimeException(
"Missing data needed to invoke @DelegateToWidget for " "Missing data needed to invoke @DelegateToWidget for "
+ Util.getSimpleName(component), e);
+ WidgetUtil.getSimpleName(component), e);
} }
} }


String key = null; String key = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
key = "updateFromUIDL for " key = "updateFromUIDL for "
+ Util.getSimpleName(legacyConnector);
+ WidgetUtil
.getSimpleName(legacyConnector);
Profiler.enter(key); Profiler.enter(key);
} }


Profiler.enter("updateConnectorState inner loop"); Profiler.enter("updateConnectorState inner loop");
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
Profiler.enter("Decode connector state " Profiler.enter("Decode connector state "
+ Util.getSimpleName(connector));
+ WidgetUtil.getSimpleName(connector));
} }


JavaScriptObject jso = states JavaScriptObject jso = states
.getJavaScriptObject(connectorId); .getJavaScriptObject(connectorId);
JsonObject stateJson = Util.jso2json(jso);
JsonObject stateJson = WidgetUtil.jso2json(jso);


if (connector instanceof HasJavaScriptConnectorHelper) { if (connector instanceof HasJavaScriptConnectorHelper) {
((HasJavaScriptConnectorHelper) connector) ((HasJavaScriptConnectorHelper) connector)


if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
Profiler.leave("Decode connector state " Profiler.leave("Decode connector state "
+ Util.getSimpleName(connector));
+ WidgetUtil.getSimpleName(connector));
} }


Profiler.enter("updateConnectorState create event"); Profiler.enter("updateConnectorState create event");


VConsole.log(" * Performing server to client RPC calls"); VConsole.log(" * Performing server to client RPC calls");


JsonArray rpcCalls = Util.jso2json(json
JsonArray rpcCalls = WidgetUtil.jso2json(json
.getJavaScriptObject("rpc")); .getJavaScriptObject("rpc"));


int rpcLength = rpcCalls.length(); int rpcLength = rpcCalls.length();
* @return Connector for focused element or null. * @return Connector for focused element or null.
*/ */
private ComponentConnector getActiveConnector() { private ComponentConnector getActiveConnector() {
Element focusedElement = Util.getFocusedElement();
Element focusedElement = WidgetUtil.getFocusedElement();
if (focusedElement == null) { if (focusedElement == null) {
return null; return null;
} }

+ 3
- 2
client/src/com/vaadin/client/BrowserInfo.java View File

public boolean requiresOverflowAutoFix() { public boolean requiresOverflowAutoFix() {
return (getWebkitVersion() > 0 || getOperaVersion() >= 11 return (getWebkitVersion() > 0 || getOperaVersion() >= 11
|| getIEVersion() >= 10 || isFirefox()) || getIEVersion() >= 10 || isFirefox())
&& Util.getNativeScrollbarSize() > 0;
&& WidgetUtil.getNativeScrollbarSize() > 0;
} }


/** /**
* otherwise <code>false</code> * otherwise <code>false</code>
*/ */
public boolean requiresPositionAbsoluteOverflowAutoFix() { public boolean requiresPositionAbsoluteOverflowAutoFix() {
return (getWebkitVersion() > 0) && Util.getNativeScrollbarSize() > 0;
return (getWebkitVersion() > 0)
&& WidgetUtil.getNativeScrollbarSize() > 0;
} }


/** /**

+ 5
- 4
client/src/com/vaadin/client/JavaScriptConnectorHelper.java View File

iface = findWildcardInterface(method); iface = findWildcardInterface(method);
} }


JsonArray argumentsArray = Util.jso2json(arguments);
JsonArray argumentsArray = WidgetUtil.jso2json(arguments);
Object[] parameters = new Object[arguments.length()]; Object[] parameters = new Object[arguments.length()];
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
parameters[i] = argumentsArray.get(i); parameters[i] = argumentsArray.get(i);
}-*/; }-*/;


public Object[] decodeRpcParameters(JsonArray parametersJson) { public Object[] decodeRpcParameters(JsonArray parametersJson) {
return new Object[] { Util.json2jso(parametersJson) };
return new Object[] { WidgetUtil.json2jso(parametersJson) };
} }


public void setTag(int tag) { public void setTag(int tag) {
if ("com.vaadin.ui.JavaScript$JavaScriptCallbackRpc".equals(iface) if ("com.vaadin.ui.JavaScript$JavaScriptCallbackRpc".equals(iface)
&& "call".equals(method)) { && "call".equals(method)) {
String callbackName = parametersJson.getString(0); String callbackName = parametersJson.getString(0);
JavaScriptObject arguments = Util.json2jso(parametersJson.get(1));
JavaScriptObject arguments = WidgetUtil.json2jso(parametersJson
.get(1));
invokeCallback(getConnectorWrapper(), callbackName, arguments); invokeCallback(getConnectorWrapper(), callbackName, arguments);
} else { } else {
JavaScriptObject arguments = Util.json2jso(parametersJson);
JavaScriptObject arguments = WidgetUtil.json2jso(parametersJson);
invokeJsRpc(rpcMap, iface, method, arguments); invokeJsRpc(rpcMap, iface, method, arguments);
// Also invoke wildcard interface // Also invoke wildcard interface
invokeJsRpc(rpcMap, "", method, arguments); invokeJsRpc(rpcMap, "", method, arguments);

+ 9
- 6
client/src/com/vaadin/client/LayoutManager.java View File

if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
Profiler.enter("ElementResizeListener.onElementResize construct profiler key"); Profiler.enter("ElementResizeListener.onElementResize construct profiler key");
key = "ElementResizeListener.onElementResize for " key = "ElementResizeListener.onElementResize for "
+ Util.getSimpleName(listener);
+ WidgetUtil
.getSimpleName(listener);
Profiler.leave("ElementResizeListener.onElementResize construct profiler key"); Profiler.leave("ElementResizeListener.onElementResize construct profiler key");
Profiler.enter(key); Profiler.enter(key);
} }
String key = null; String key = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
key = "layoutHorizontally() for " key = "layoutHorizontally() for "
+ Util.getSimpleName(cl);
+ WidgetUtil.getSimpleName(cl);
Profiler.enter(key); Profiler.enter(key);
} }


try { try {
String key = null; String key = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
key = "layout() for " + Util.getSimpleName(rr);
key = "layout() for "
+ WidgetUtil.getSimpleName(rr);
Profiler.enter(key); Profiler.enter(key);
} }


String key = null; String key = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
key = "layoutVertically() for " key = "layoutVertically() for "
+ Util.getSimpleName(cl);
+ WidgetUtil.getSimpleName(cl);
Profiler.enter(key); Profiler.enter(key);
} }


try { try {
String key = null; String key = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
key = "layout() for " + Util.getSimpleName(rr);
key = "layout() for "
+ WidgetUtil.getSimpleName(rr);
Profiler.enter(key); Profiler.enter(key);
} }


String key = null; String key = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
key = "layout PostLayoutListener for " key = "layout PostLayoutListener for "
+ Util.getSimpleName(connector);
+ WidgetUtil.getSimpleName(connector);
Profiler.enter(key); Profiler.enter(key);
} }



+ 1
- 1
client/src/com/vaadin/client/LayoutManagerIE8.java View File

* the containing element. To force a reflow by modifying the magical * the containing element. To force a reflow by modifying the magical
* zoom property. * zoom property.
*/ */
Util.forceIE8Redraw(RootPanel.get().getElement());
WidgetUtil.forceIE8Redraw(RootPanel.get().getElement());
Profiler.leave("LayoutManagerIE8.performBrowserLayoutHacks"); Profiler.leave("LayoutManagerIE8.performBrowserLayoutHacks");
} }
} }

+ 2
- 2
client/src/com/vaadin/client/MeasuredSize.java View File

Profiler.leave("Measure borders"); Profiler.leave("Measure borders");


Profiler.enter("Measure height"); Profiler.enter("Measure height");
int requiredHeight = Util.getRequiredHeight(element);
int requiredHeight = WidgetUtil.getRequiredHeight(element);
int marginHeight = sumHeights(margins); int marginHeight = sumHeights(margins);
int oldHeight = height; int oldHeight = height;
int oldWidth = width; int oldWidth = width;
Profiler.leave("Measure height"); Profiler.leave("Measure height");


Profiler.enter("Measure width"); Profiler.enter("Measure width");
int requiredWidth = Util.getRequiredWidth(element);
int requiredWidth = WidgetUtil.getRequiredWidth(element);
int marginWidth = sumWidths(margins); int marginWidth = sumWidths(margins);
if (setOuterWidth(requiredWidth + marginWidth)) { if (setOuterWidth(requiredWidth + marginWidth)) {
debugSizeChange(element, "Width (outer)", oldWidth, width); debugSizeChange(element, "Width (outer)", oldWidth, width);

+ 2
- 2
client/src/com/vaadin/client/MouseEventDetailsBuilder.java View File

Element relativeToElement) { Element relativeToElement) {
MouseEventDetails mouseEventDetails = new MouseEventDetails(); MouseEventDetails mouseEventDetails = new MouseEventDetails();
mouseEventDetails.setType(Event.getTypeInt(evt.getType())); mouseEventDetails.setType(Event.getTypeInt(evt.getType()));
mouseEventDetails.setClientX(Util.getTouchOrMouseClientX(evt));
mouseEventDetails.setClientY(Util.getTouchOrMouseClientY(evt));
mouseEventDetails.setClientX(WidgetUtil.getTouchOrMouseClientX(evt));
mouseEventDetails.setClientY(WidgetUtil.getTouchOrMouseClientY(evt));
if (evt.getButton() == NativeEvent.BUTTON_LEFT) { if (evt.getButton() == NativeEvent.BUTTON_LEFT) {
mouseEventDetails.setButton(MouseButton.LEFT); mouseEventDetails.setButton(MouseButton.LEFT);
} else if (evt.getButton() == NativeEvent.BUTTON_RIGHT) { } else if (evt.getButton() == NativeEvent.BUTTON_RIGHT) {

+ 1
- 1
client/src/com/vaadin/client/RenderSpace.java View File

public RenderSpace(int width, int height, boolean useNativeScrollbarSize) { public RenderSpace(int width, int height, boolean useNativeScrollbarSize) {
super(width, height); super(width, height);
if (useNativeScrollbarSize) { if (useNativeScrollbarSize) {
scrollBarSize = Util.getNativeScrollbarSize();
scrollBarSize = WidgetUtil.getNativeScrollbarSize();
} }
} }



+ 3
- 3
client/src/com/vaadin/client/ResourceLoader.java View File

*/ */
public void loadScript(final String scriptUrl, public void loadScript(final String scriptUrl,
final ResourceLoadListener resourceLoadListener, boolean async) { final ResourceLoadListener resourceLoadListener, boolean async) {
final String url = Util.getAbsoluteUrl(scriptUrl);
final String url = WidgetUtil.getAbsoluteUrl(scriptUrl);
ResourceLoadEvent event = new ResourceLoadEvent(this, url, false); ResourceLoadEvent event = new ResourceLoadEvent(this, url, false);
if (loadedResources.contains(url)) { if (loadedResources.contains(url)) {
if (resourceLoadListener != null) { if (resourceLoadListener != null) {
*/ */
public void preloadResource(String url, public void preloadResource(String url,
ResourceLoadListener resourceLoadListener) { ResourceLoadListener resourceLoadListener) {
url = Util.getAbsoluteUrl(url);
url = WidgetUtil.getAbsoluteUrl(url);
ResourceLoadEvent event = new ResourceLoadEvent(this, url, true); ResourceLoadEvent event = new ResourceLoadEvent(this, url, true);
if (loadedResources.contains(url) || preloadedResources.contains(url)) { if (loadedResources.contains(url) || preloadedResources.contains(url)) {
// Already loaded or preloaded -> just fire listener // Already loaded or preloaded -> just fire listener
*/ */
public void loadStylesheet(final String stylesheetUrl, public void loadStylesheet(final String stylesheetUrl,
final ResourceLoadListener resourceLoadListener) { final ResourceLoadListener resourceLoadListener) {
final String url = Util.getAbsoluteUrl(stylesheetUrl);
final String url = WidgetUtil.getAbsoluteUrl(stylesheetUrl);
final ResourceLoadEvent event = new ResourceLoadEvent(this, url, false); final ResourceLoadEvent event = new ResourceLoadEvent(this, url, false);
if (loadedResources.contains(url)) { if (loadedResources.contains(url)) {
if (resourceLoadListener != null) { if (resourceLoadListener != null) {

+ 1
- 1
client/src/com/vaadin/client/SuperDevMode.java View File

VConsole.error("JSONP compile call failed"); VConsole.error("JSONP compile call failed");
// Don't log exception as they are shown as // Don't log exception as they are shown as
// notifications // notifications
VConsole.error(Util.getSimpleName(caught) + ": "
VConsole.error(WidgetUtil.getSimpleName(caught) + ": "
+ caught.getMessage()); + caught.getMessage());
failed(); failed();



+ 189
- 1076
client/src/com/vaadin/client/Util.java
File diff suppressed because it is too large
View File


+ 19
- 17
client/src/com/vaadin/client/VCaption.java View File

int width = 0; int width = 0;


if (icon != null) { if (icon != null) {
width += Util.getRequiredWidth(icon.getElement());
width += WidgetUtil.getRequiredWidth(icon.getElement());
} }


if (captionText != null) { if (captionText != null) {
width += Util.getRequiredWidth(captionText);
width += WidgetUtil.getRequiredWidth(captionText);
} }
if (requiredFieldIndicator != null) { if (requiredFieldIndicator != null) {
width += Util.getRequiredWidth(requiredFieldIndicator);
width += WidgetUtil.getRequiredWidth(requiredFieldIndicator);
} }
if (errorIndicatorElement != null) { if (errorIndicatorElement != null) {
width += Util.getRequiredWidth(errorIndicatorElement);
width += WidgetUtil.getRequiredWidth(errorIndicatorElement);
} }


return width; return width;
int width = 0; int width = 0;


if (icon != null) { if (icon != null) {
width += Util.getRequiredWidth(icon.getElement());
width += WidgetUtil.getRequiredWidth(icon.getElement());
} }
if (captionText != null) { if (captionText != null) {
int textWidth = captionText.getScrollWidth(); int textWidth = captionText.getScrollWidth();
* In Firefox3 the caption might require more space than the * In Firefox3 the caption might require more space than the
* scrollWidth returns as scrollWidth is rounded down. * scrollWidth returns as scrollWidth is rounded down.
*/ */
int requiredWidth = Util.getRequiredWidth(captionText);
int requiredWidth = WidgetUtil.getRequiredWidth(captionText);
if (requiredWidth > textWidth) { if (requiredWidth > textWidth) {
textWidth = requiredWidth; textWidth = requiredWidth;
} }
width += textWidth; width += textWidth;
} }
if (requiredFieldIndicator != null) { if (requiredFieldIndicator != null) {
width += Util.getRequiredWidth(requiredFieldIndicator);
width += WidgetUtil.getRequiredWidth(requiredFieldIndicator);
} }
if (errorIndicatorElement != null) { if (errorIndicatorElement != null) {
width += Util.getRequiredWidth(errorIndicatorElement);
width += WidgetUtil.getRequiredWidth(errorIndicatorElement);
} }


return width; return width;
int h; int h;


if (icon != null) { if (icon != null) {
h = Util.getRequiredHeight(icon.getElement());
h = WidgetUtil.getRequiredHeight(icon.getElement());
if (h > height) { if (h > height) {
height = h; height = h;
} }
} }


if (captionText != null) { if (captionText != null) {
h = Util.getRequiredHeight(captionText);
h = WidgetUtil.getRequiredHeight(captionText);
if (h > height) { if (h > height) {
height = h; height = h;
} }
} }
if (requiredFieldIndicator != null) { if (requiredFieldIndicator != null) {
h = Util.getRequiredHeight(requiredFieldIndicator);
h = WidgetUtil.getRequiredHeight(requiredFieldIndicator);
if (h > height) { if (h > height) {
height = h; height = h;
} }
} }
if (errorIndicatorElement != null) { if (errorIndicatorElement != null) {
h = Util.getRequiredHeight(errorIndicatorElement);
h = WidgetUtil.getRequiredHeight(errorIndicatorElement);
if (h > height) { if (h > height) {
height = h; height = h;
} }


// DOM.setStyleAttribute(getElement(), "width", maxWidth + "px"); // DOM.setStyleAttribute(getElement(), "width", maxWidth + "px");
if (requiredFieldIndicator != null) { if (requiredFieldIndicator != null) {
availableWidth -= Util.getRequiredWidth(requiredFieldIndicator);
availableWidth -= WidgetUtil
.getRequiredWidth(requiredFieldIndicator);
} }


if (errorIndicatorElement != null) { if (errorIndicatorElement != null) {
availableWidth -= Util.getRequiredWidth(errorIndicatorElement);
availableWidth -= WidgetUtil
.getRequiredWidth(errorIndicatorElement);
} }


if (availableWidth < 0) { if (availableWidth < 0) {
} }


if (icon != null) { if (icon != null) {
int iconRequiredWidth = Util
.getRequiredWidth(icon.getElement());
int iconRequiredWidth = WidgetUtil.getRequiredWidth(icon
.getElement());
if (availableWidth > iconRequiredWidth) { if (availableWidth > iconRequiredWidth) {
availableWidth -= iconRequiredWidth; availableWidth -= iconRequiredWidth;
} else { } else {
} }
} }
if (captionText != null) { if (captionText != null) {
int captionWidth = Util.getRequiredWidth(captionText);
int captionWidth = WidgetUtil.getRequiredWidth(captionText);
if (availableWidth > captionWidth) { if (availableWidth > captionWidth) {
availableWidth -= captionWidth; availableWidth -= captionWidth;



+ 1
- 1
client/src/com/vaadin/client/VUIDLBrowser.java View File

} else { } else {
setText("Unknown connector (" + connectorId + ")"); setText("Unknown connector (" + connectorId + ")");
} }
dir((JsonObject) Util.jso2json(stateChanges), this);
dir((JsonObject) WidgetUtil.jso2json(stateChanges), this);
} }


@Override @Override

+ 1479
- 0
client/src/com/vaadin/client/WidgetUtil.java
File diff suppressed because it is too large
View File


+ 2
- 2
client/src/com/vaadin/client/communication/StateChangeEvent.java View File

import com.vaadin.client.JsArrayObject; import com.vaadin.client.JsArrayObject;
import com.vaadin.client.Profiler; import com.vaadin.client.Profiler;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.Property;
return true; return true;
} else if (stateJson != null) { } else if (stateJson != null) {
// Check whether it's in the json object // Check whether it's in the json object
return isInJson(property, Util.json2jso(stateJson));
return isInJson(property, WidgetUtil.json2jso(stateJson));
} else { } else {
// Legacy cases // Legacy cases
if (changedProperties != null) { if (changedProperties != null) {

+ 10
- 9
client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VCaption; import com.vaadin.client.VCaption;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.SubPartAware;
import com.vaadin.client.ui.VCssLayout; import com.vaadin.client.ui.VCssLayout;
import com.vaadin.client.ui.VGridLayout; import com.vaadin.client.ui.VGridLayout;
// widget to which the path is relative. Otherwise, the current // widget to which the path is relative. Otherwise, the current
// implementation simply interprets the path as if baseElement was // implementation simply interprets the path as if baseElement was
// null. // null.
Widget baseWidget = Util.findWidget(baseElement, null);
Widget baseWidget = WidgetUtil.findWidget(baseElement, null);


Widget w = getWidgetFromPath(widgetPath, baseWidget); Widget w = getWidgetFromPath(widgetPath, baseWidget);
if (w == null || !Util.isAttachedAndDisplayed(w)) {
if (w == null || !WidgetUtil.isAttachedAndDisplayed(w)) {
return null; return null;
} }
if (parts.length == 1) { if (parts.length == 1) {
String childIndexString = part.substring("domChild[".length(), String childIndexString = part.substring("domChild[".length(),
part.length() - 1); part.length() - 1);


if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) {
if (WidgetUtil.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) {
if (element.hasChildNodes()) { if (element.hasChildNodes()) {
Element e = element.getFirstChildElement().cast(); Element e = element.getFirstChildElement().cast();
String cn = e.getClassName(); String cn = e.getClassName();
if (basePath == null) { if (basePath == null) {
return null; return null;
} }
String simpleName = Util.getSimpleName(w);
String simpleName = WidgetUtil.getSimpleName(w);


/* /*
* Check if the parent implements Iterable. At least VPopupView does not * Check if the parent implements Iterable. At least VPopupView does not
return basePath + PARENTCHILD_SEPARATOR + simpleName + "[" return basePath + PARENTCHILD_SEPARATOR + simpleName + "["
+ pos + "]"; + pos + "]";
} }
String simpleName2 = Util.getSimpleName(child);
String simpleName2 = WidgetUtil.getSimpleName(child);
if (simpleName.equals(simpleName2)) { if (simpleName.equals(simpleName2)) {
pos++; pos++;
} }
// the same type before it // the same type before it
int nextIndex = 0; int nextIndex = 0;
for (Widget child : layout) { for (Widget child : layout) {
boolean matchingType = nextWidgetClassName.equals(Util
.getSimpleName(child));
boolean matchingType = nextWidgetClassName
.equals(WidgetUtil.getSimpleName(child));
if (matchingType && widgetPosition == 0) { if (matchingType && widgetPosition == 0) {
// This is the n:th child that we looked for // This is the n:th child that we looked for
break; break;
while (iterator.hasNext()) { while (iterator.hasNext()) {


Widget child = iterator.next(); Widget child = iterator.next();
String simpleName2 = Util.getSimpleName(child);
String simpleName2 = WidgetUtil.getSimpleName(child);


if (!widgetClassName.equals(simpleName2) if (!widgetClassName.equals(simpleName2)
&& child instanceof Slot) { && child instanceof Slot) {
* directly checking the stuff inside the slot * directly checking the stuff inside the slot
*/ */
child = ((Slot) child).getWidget(); child = ((Slot) child).getWidget();
simpleName2 = Util.getSimpleName(child);
simpleName2 = WidgetUtil.getSimpleName(child);
} }


if (widgetClassName.equals(simpleName2)) { if (widgetClassName.equals(simpleName2)) {

+ 2
- 1
client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.HasComponentsConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.Property;
import com.vaadin.client.metadata.TypeDataStore; import com.vaadin.client.metadata.TypeDataStore;
import com.vaadin.client.ui.AbstractConnector; import com.vaadin.client.ui.AbstractConnector;


// If the server-side class name didn't match, fall back to testing for // If the server-side class name didn't match, fall back to testing for
// the explicit widget name // the explicit widget name
String widget = Util.getSimpleName(connector.getWidget());
String widget = WidgetUtil.getSimpleName(connector.getWidget());
return widgetName.equals(widget) return widgetName.equals(widget)
|| widgetName.equals(widget + ".class"); || widgetName.equals(widget + ".class");



+ 3
- 3
client/src/com/vaadin/client/connectors/AbstractRendererConnector.java View File

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


import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.JsonDecoder; import com.vaadin.client.communication.JsonDecoder;
import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.NoDataException;
if (presentationType == null) { if (presentationType == null) {
throw new IllegalStateException( throw new IllegalStateException(
"No presentation type found for " "No presentation type found for "
+ Util.getSimpleName(this)
+ WidgetUtil.getSimpleName(this)
+ ". This may be caused by some unspecified problem in widgetset compilation."); + ". This may be caused by some unspecified problem in widgetset compilation.");
} }
} }
} catch (NoDataException e) { } catch (NoDataException e) {
throw new IllegalStateException( throw new IllegalStateException(
"Default implementation of createRenderer() does not work for " "Default implementation of createRenderer() does not work for "
+ Util.getSimpleName(this)
+ WidgetUtil.getSimpleName(this)
+ ". This might be caused by explicitely using " + ". This might be caused by explicitely using "
+ "super.createRenderer() or some unspecified " + "super.createRenderer() or some unspecified "
+ "problem with the widgetset compilation.", e); + "problem with the widgetset compilation.", e);

+ 6
- 5
client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java View File

import com.vaadin.client.ConnectorMap; import com.vaadin.client.ConnectorMap;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.SimpleTree; import com.vaadin.client.SimpleTree;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ValueMap; import com.vaadin.client.ValueMap;


/** /**
final ServerConnector parent = connector.getParent(); final ServerConnector parent = connector.getParent();
final String parentId = parent.getConnectorId(); final String parentId = parent.getConnectorId();


final Label errorDetails = new Label(Util.getSimpleName(connector)
+ "[" + connector.getConnectorId() + "]" + " inside "
+ Util.getSimpleName(parent));
final Label errorDetails = new Label(
WidgetUtil.getSimpleName(connector) + "["
+ connector.getConnectorId() + "]" + " inside "
+ WidgetUtil.getSimpleName(parent));


if (parent instanceof ComponentConnector) { if (parent instanceof ComponentConnector) {
final ComponentConnector parentConnector = (ComponentConnector) parent; final ComponentConnector parentConnector = (ComponentConnector) parent;
Highlight.show(connector); Highlight.show(connector);


final SimpleTree errorNode = new SimpleTree( final SimpleTree errorNode = new SimpleTree(
Util.getSimpleName(connector) + " id: " + pid);
WidgetUtil.getSimpleName(connector) + " id: " + pid);
errorNode.addDomHandler(new MouseOverHandler() { errorNode.addDomHandler(new MouseOverHandler() {
@Override @Override
public void onMouseOver(MouseOverEvent event) { public void onMouseOver(MouseOverEvent event) {

+ 5
- 4
client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.JsArrayObject; import com.vaadin.client.JsArrayObject;
import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.Property;
ignoreProperties.add("id"); ignoreProperties.add("id");


String html = getRowHTML("Id", connector.getConnectorId()); String html = getRowHTML("Id", connector.getConnectorId());
html += getRowHTML("Connector", Util.getSimpleName(connector));
html += getRowHTML("Connector", WidgetUtil.getSimpleName(connector));


if (connector instanceof ComponentConnector) { if (connector instanceof ComponentConnector) {
ComponentConnector component = (ComponentConnector) connector; ComponentConnector component = (ComponentConnector) connector;
AbstractComponentState componentState = component.getState(); AbstractComponentState componentState = component.getState();


html += getRowHTML("Widget", html += getRowHTML("Widget",
Util.getSimpleName(component.getWidget()));
WidgetUtil.getSimpleName(component.getWidget()));
html += getRowHTML("Caption", componentState.caption); html += getRowHTML("Caption", componentState.caption);
html += getRowHTML("Description", componentState.description); html += getRowHTML("Description", componentState.description);
html += getRowHTML("Width", componentState.width + " (actual: " html += getRowHTML("Width", componentState.width + " (actual: "
return "<div class=\"" + VDebugWindow.STYLENAME return "<div class=\"" + VDebugWindow.STYLENAME
+ "-row\"><span class=\"caption\">" + caption + "-row\"><span class=\"caption\">" + caption
+ "</span><span class=\"value\">" + "</span><span class=\"value\">"
+ Util.escapeHTML(String.valueOf(value)) + "</span></div>";
+ WidgetUtil.escapeHTML(String.valueOf(value))
+ "</span></div>";
} }


/** /**

+ 3
- 2
client/src/com/vaadin/client/debug/internal/HierarchySection.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.ValueMap; import com.vaadin.client.ValueMap;
import com.vaadin.client.WidgetUtil;


/** /**
* Provides functionality for examining the UI component hierarchy. * Provides functionality for examining the UI component hierarchy.
} }
if (event.getTypeInt() == Event.ONMOUSEMOVE) { if (event.getTypeInt() == Event.ONMOUSEMOVE) {
Highlight.hideAll(); Highlight.hideAll();
Element eventTarget = Util.getElementFromPoint(event
Element eventTarget = WidgetUtil.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent() .getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY()); .getClientY());
if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) {
event.consume(); event.consume();
event.getNativeEvent().stopPropagation(); event.getNativeEvent().stopPropagation();
stopFind(); stopFind();
Element eventTarget = Util.getElementFromPoint(event
Element eventTarget = WidgetUtil.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent() .getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY()); .getClientY());
for (ApplicationConnection a : ApplicationConfiguration for (ApplicationConnection a : ApplicationConfiguration

+ 7
- 4
client/src/com/vaadin/client/debug/internal/TestBenchSection.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.ValueMap; import com.vaadin.client.ValueMap;
import com.vaadin.client.WidgetUtil;


/** /**
* Provides functionality for picking selectors for Vaadin TestBench. * Provides functionality for picking selectors for Vaadin TestBench.


String html = "<div class=\"" + VDebugWindow.STYLENAME String html = "<div class=\"" + VDebugWindow.STYLENAME
+ "-selector\"><span class=\"tb-selector\">" + "-selector\"><span class=\"tb-selector\">"
+ Util.escapeHTML(path.getElementQuery()) + "</span></div>";
+ WidgetUtil.escapeHTML(path.getElementQuery())
+ "</span></div>";
setHTML(html); setHTML(html);


addMouseOverHandler(this); addMouseOverHandler(this);
} }
if (event.getTypeInt() == Event.ONMOUSEMOVE if (event.getTypeInt() == Event.ONMOUSEMOVE
|| event.getTypeInt() == Event.ONCLICK) { || event.getTypeInt() == Event.ONCLICK) {
Element eventTarget = Util.getElementFromPoint(event
Element eventTarget = WidgetUtil.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent() .getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY()); .getClientY());
if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) {
// make sure that not finding the highlight element only // make sure that not finding the highlight element only
Highlight.hideAll(); Highlight.hideAll();


eventTarget = Util.getElementFromPoint(event.getNativeEvent()
.getClientX(), event.getNativeEvent().getClientY());
eventTarget = WidgetUtil.getElementFromPoint(event
.getNativeEvent().getClientX(), event.getNativeEvent()
.getClientY());
ComponentConnector connector = findConnector(eventTarget); ComponentConnector connector = findConnector(eventTarget);


if (event.getTypeInt() == Event.ONMOUSEMOVE) { if (event.getTypeInt() == Event.ONMOUSEMOVE) {

+ 1
- 1
client/src/com/vaadin/client/extensions/ResponsiveConnector.java View File



/** /**
* Forces IE8 to reinterpret CSS rules. * Forces IE8 to reinterpret CSS rules.
* {@link com.vaadin.client.Util#forceIE8Redraw(com.google.gwt.dom.client.Element)}
* {@link com.vaadin.client.WidgetUtil#forceIE8Redraw(com.google.gwt.dom.client.Element)}
* doesn't work in this case. * doesn't work in this case.
* *
* @param element * @param element

+ 3
- 2
client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java View File

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.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.JavaScriptMethodInvocation; import com.vaadin.client.communication.JavaScriptMethodInvocation;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.extensions.AbstractExtensionConnector;
}-*/; }-*/;


public void sendRpc(String name, JsArray<JavaScriptObject> arguments) { public void sendRpc(String name, JsArray<JavaScriptObject> arguments) {
Object[] parameters = new Object[] { name, Util.jso2json(arguments) };
Object[] parameters = new Object[] { name,
WidgetUtil.jso2json(arguments) };


/* /*
* Must invoke manually as the RPC interface can't be used in GWT * Must invoke manually as the RPC interface can't be used in GWT

+ 5
- 4
client/src/com/vaadin/client/renderers/ClickableRenderer.java View File

import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.event.shared.HandlerRegistration; import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.widget.escalator.Cell; import com.vaadin.client.widget.escalator.Cell;
import com.vaadin.client.widget.escalator.RowContainer; import com.vaadin.client.widget.escalator.RowContainer;
import com.vaadin.client.widget.grid.CellReference; import com.vaadin.client.widget.grid.CellReference;
* <strong>Note:</strong> This method may not work reliably if the grid * <strong>Note:</strong> This method may not work reliably if the grid
* in question is wrapped in a {@link Composite} <em>unless</em> the * in question is wrapped in a {@link Composite} <em>unless</em> the
* element is inside another widget that is a child of the wrapped grid; * element is inside another widget that is a child of the wrapped grid;
* please refer to the note in {@link Util#findWidget(Element, Class)
* Util.findWidget} for details.
* please refer to the note in
* {@link WidgetUtil#findWidget(Element, Class) Util.findWidget} for
* details.
* *
* @param e * @param e
* the element whose parent grid to find * the element whose parent grid to find
* @return the parent grid or null if none found. * @return the parent grid or null if none found.
*/ */
private static Grid<?> findClosestParentGrid(Element e) { private static Grid<?> findClosestParentGrid(Element e) {
Widget w = Util.findWidget(e, null);
Widget w = WidgetUtil.findWidget(e, null);


while (w != null && !(w instanceof Grid)) { while (w != null && !(w instanceof Grid)) {
w = w.getParent(); w = w.getParent();

+ 2
- 2
client/src/com/vaadin/client/renderers/WidgetRenderer.java View File



import com.google.gwt.dom.client.TableCellElement; import com.google.gwt.dom.client.TableCellElement;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.widget.grid.RendererCellReference; import com.vaadin.client.widget.grid.RendererCellReference;


/** /**
*/ */
protected static <W extends Widget> W getWidget(TableCellElement e, protected static <W extends Widget> W getWidget(TableCellElement e,
Class<W> klass) { Class<W> klass) {
W w = Util.findWidget(e.getFirstChildElement(), klass);
W w = WidgetUtil.findWidget(e.getFirstChildElement(), klass);
assert w == null || w.getElement() == e.getFirstChildElement() : "Widget not found inside cell"; assert w == null || w.getElement() == e.getFirstChildElement() : "Widget not found inside cell";
return w; return w;
} }

+ 6
- 5
client/src/com/vaadin/client/ui/AbstractClickEventHandler.java View File

import com.google.gwt.user.client.Event.NativePreviewEvent; import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Event.NativePreviewHandler; import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;


public abstract class AbstractClickEventHandler implements MouseDownHandler, public abstract class AbstractClickEventHandler implements MouseDownHandler,


// 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
Element elementUnderMouse = Util.getElementUnderMouse(event
.getNativeEvent());
Element elementUnderMouse = WidgetUtil
.getElementUnderMouse(event.getNativeEvent());
if (lastMouseDownTarget != null if (lastMouseDownTarget != null
&& elementUnderMouse == lastMouseDownTarget) { && elementUnderMouse == lastMouseDownTarget) {
mouseUpPreviewMatched = true; mouseUpPreviewMatched = true;
* When getting a mousedown event, we must detect where the * When getting a mousedown event, we must detect where the
* corresponding mouseup event if it's on a different part of the page. * corresponding mouseup event if it's on a different part of the page.
*/ */
lastMouseDownTarget = Util.getElementUnderMouse(event.getNativeEvent());
lastMouseDownTarget = WidgetUtil.getElementUnderMouse(event
.getNativeEvent());
mouseUpPreviewMatched = false; mouseUpPreviewMatched = false;
mouseUpEventPreviewRegistration = Event mouseUpEventPreviewRegistration = Event
.addNativePreviewHandler(mouseUpPreviewHandler); .addNativePreviewHandler(mouseUpPreviewHandler);
if (hasEventListener() if (hasEventListener()
&& mouseUpPreviewMatched && mouseUpPreviewMatched
&& lastMouseDownTarget != null && lastMouseDownTarget != null
&& Util.getElementUnderMouse(event.getNativeEvent()) == lastMouseDownTarget
&& WidgetUtil.getElementUnderMouse(event.getNativeEvent()) == lastMouseDownTarget
&& shouldFireEvent(event)) { && shouldFireEvent(event)) {
// "Click" with left, right or middle button // "Click" with left, right or middle button
fireClick(event.getNativeEvent()); fireClick(event.getNativeEvent());

+ 4
- 3
client/src/com/vaadin/client/ui/AbstractComponentConnector.java View File

import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.NoDataException;
import com.vaadin.client.metadata.Type; import com.vaadin.client.metadata.Type;
} catch (NoDataException e) { } catch (NoDataException e) {
throw new IllegalStateException( throw new IllegalStateException(
"Default implementation of createWidget() does not work for " "Default implementation of createWidget() does not work for "
+ Util.getSimpleName(this)
+ WidgetUtil.getSimpleName(this)
+ ". This might be caused by explicitely using " + ". This might be caused by explicitely using "
+ "super.createWidget() or some unspecified " + "super.createWidget() or some unspecified "
+ "problem with the widgetset compilation.", e); + "problem with the widgetset compilation.", e);
public Widget getWidget() { public Widget getWidget() {
if (widget == null) { if (widget == null) {
Profiler.enter("AbstractComponentConnector.createWidget for " Profiler.enter("AbstractComponentConnector.createWidget for "
+ Util.getSimpleName(this));
+ WidgetUtil.getSimpleName(this));
widget = createWidget(); widget = createWidget();
Profiler.leave("AbstractComponentConnector.createWidget for " Profiler.leave("AbstractComponentConnector.createWidget for "
+ Util.getSimpleName(this));
+ WidgetUtil.getSimpleName(this));
} }


return widget; return widget;

+ 9
- 6
client/src/com/vaadin/client/ui/AbstractConnector.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;


addStateChangeHandler(this); addStateChangeHandler(this);
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
Profiler.enter("AbstractConnector.init " + Util.getSimpleName(this));
Profiler.enter("AbstractConnector.init "
+ WidgetUtil.getSimpleName(this));
} }
init(); init();
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
Profiler.leave("AbstractConnector.init " + Util.getSimpleName(this));
Profiler.leave("AbstractConnector.init "
+ WidgetUtil.getSimpleName(this));
} }
Profiler.leave("AbstractConnector.doInit"); Profiler.leave("AbstractConnector.doInit");
} }
public void fireEvent(GwtEvent<?> event) { public void fireEvent(GwtEvent<?> event) {
String profilerKey = null; String profilerKey = null;
if (Profiler.isEnabled()) { if (Profiler.isEnabled()) {
profilerKey = "Fire " + Util.getSimpleName(event) + " for "
+ Util.getSimpleName(this);
profilerKey = "Fire " + WidgetUtil.getSimpleName(event) + " for "
+ WidgetUtil.getSimpleName(this);
Profiler.enter(profilerKey); Profiler.enter(profilerKey);
} }
if (handlerManager != null) { if (handlerManager != null) {
} catch (NoDataException e) { } catch (NoDataException e) {
throw new IllegalStateException( throw new IllegalStateException(
"There is no information about the state for " "There is no information about the state for "
+ Util.getSimpleName(this)
+ WidgetUtil.getSimpleName(this)
+ ". Did you remember to compile the right widgetset?", + ". Did you remember to compile the right widgetset?",
e); e);
} }
} catch (NoDataException e) { } catch (NoDataException e) {
throw new IllegalStateException( throw new IllegalStateException(
"There is no information about the state for " "There is no information about the state for "
+ Util.getSimpleName(connector)
+ WidgetUtil.getSimpleName(connector)
+ ". Did you remember to compile the right widgetset?", + ". Did you remember to compile the right widgetset?",
e); e);
} }

+ 2
- 2
client/src/com/vaadin/client/ui/MediaBaseConnector.java View File

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


import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.shared.communication.URLReference; import com.vaadin.shared.communication.URLReference;
import com.vaadin.shared.ui.AbstractMediaState; import com.vaadin.shared.ui.AbstractMediaState;
if (altText == null || "".equals(altText)) { if (altText == null || "".equals(altText)) {
altText = getDefaultAltHtml(); altText = getDefaultAltHtml();
} else if (!getState().htmlContentAllowed) { } else if (!getState().htmlContentAllowed) {
altText = Util.escapeHTML(altText);
altText = WidgetUtil.escapeHTML(altText);
} }
getWidget().setAltText(altText); getWidget().setAltText(altText);
} }

+ 7
- 7
client/src/com/vaadin/client/ui/VAbstractSplitPanel.java View File

import com.vaadin.client.ConnectorMap; import com.vaadin.client.ConnectorMap;
import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.StyleConstants; import com.vaadin.client.StyleConstants;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent; import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent;
break; break;
} }
// Only fire click event listeners if the splitter isn't moved // Only fire click event listeners if the splitter isn't moved
if (Util.isTouchEvent(event) || !resized) {
if (WidgetUtil.isTouchEvent(event) || !resized) {
super.onBrowserEvent(event); super.onBrowserEvent(event);
} else if (DOM.eventGetType(event) == Event.ONMOUSEUP) { } else if (DOM.eventGetType(event) == Event.ONMOUSEUP) {
// Reset the resized flag after a mouseup has occured so the next // Reset the resized flag after a mouseup has occured so the next
DOM.setCapture(getElement()); DOM.setCapture(getElement());
origX = DOM.getElementPropertyInt(splitter, "offsetLeft"); origX = DOM.getElementPropertyInt(splitter, "offsetLeft");
origY = DOM.getElementPropertyInt(splitter, "offsetTop"); origY = DOM.getElementPropertyInt(splitter, "offsetTop");
origMouseX = Util.getTouchOrMouseClientX(event);
origMouseY = Util.getTouchOrMouseClientY(event);
origMouseX = WidgetUtil.getTouchOrMouseClientX(event);
origMouseY = WidgetUtil.getTouchOrMouseClientY(event);
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
} }
public void onMouseMove(Event event) { public void onMouseMove(Event event) {
switch (orientation) { switch (orientation) {
case HORIZONTAL: case HORIZONTAL:
final int x = Util.getTouchOrMouseClientX(event);
final int x = WidgetUtil.getTouchOrMouseClientX(event);
onHorizontalMouseMove(x); onHorizontalMouseMove(x);
break; break;
case VERTICAL: case VERTICAL:
default: default:
final int y = Util.getTouchOrMouseClientY(event);
final int y = WidgetUtil.getTouchOrMouseClientY(event);
onVerticalMouseMove(y); onVerticalMouseMove(y);
break; break;
} }
DOM.releaseCapture(getElement()); DOM.releaseCapture(getElement());
hideDraggingCurtain(); hideDraggingCurtain();
resizing = false; resizing = false;
if (!Util.isTouchEvent(event)) {
if (!WidgetUtil.isTouchEvent(event)) {
onMouseMove(event); onMouseMove(event);
} }
fireEvent(new SplitterMoveEvent(this)); fireEvent(new SplitterMoveEvent(this));

+ 2
- 2
client/src/com/vaadin/client/ui/VAccordion.java View File

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.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VCaption; import com.vaadin.client.VCaption;
import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentConstants;
} }


int captionWidth = caption.getRequiredWidth(); int captionWidth = caption.getRequiredWidth();
int padding = Util.measureHorizontalPaddingAndBorder(
int padding = WidgetUtil.measureHorizontalPaddingAndBorder(
caption.getElement(), 18); caption.getElement(), 18);
return captionWidth + padding; return captionWidth + padding;
} }

+ 3
- 2
client/src/com/vaadin/client/ui/VButton.java View File

import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;


public class VButton extends FocusWidget implements ClickHandler { public class VButton extends FocusWidget implements ClickHandler {


// Set (x,y) client coordinates to the middle of the button // Set (x,y) client coordinates to the middle of the button
int x = getElement().getAbsoluteLeft() - getElement().getScrollLeft() int x = getElement().getAbsoluteLeft() - getElement().getScrollLeft()
- getElement().getOwnerDocument().getScrollLeft() - getElement().getOwnerDocument().getScrollLeft()
+ Util.getRequiredWidth(getElement()) / 2;
+ WidgetUtil.getRequiredWidth(getElement()) / 2;
int y = getElement().getAbsoluteTop() - getElement().getScrollTop() int y = getElement().getAbsoluteTop() - getElement().getScrollTop()
- getElement().getOwnerDocument().getScrollTop() - getElement().getOwnerDocument().getScrollTop()
+ Util.getRequiredHeight(getElement()) / 2;
+ WidgetUtil.getRequiredHeight(getElement()) / 2;
NativeEvent evt = Document.get().createClickEvent(1, 0, 0, x, y, false, NativeEvent evt = Document.get().createClickEvent(1, 0, 0, x, y, false,
false, false, false); false, false, false);
getElement().dispatchEvent(evt); getElement().dispatchEvent(evt);

+ 2
- 2
client/src/com/vaadin/client/ui/VCalendarPanel.java View File

import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.DateTimeService; import com.vaadin.client.DateTimeService;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.shared.util.SharedUtil; import com.vaadin.shared.util.SharedUtil;
return SUBPART_PREV_YEAR; return SUBPART_PREV_YEAR;
} else if (contains(days, subElement)) { } else if (contains(days, subElement)) {
// Day, find out which dayOfMonth and use that as the identifier // Day, find out which dayOfMonth and use that as the identifier
Day day = Util.findWidget(subElement, Day.class);
Day day = WidgetUtil.findWidget(subElement, Day.class);
if (day != null) { if (day != null) {
Date date = day.getDate(); Date date = day.getDate();
int id = date.getDate(); int id = date.getDate();

+ 4
- 4
client/src/com/vaadin/client/ui/VContextMenu.java View File

import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.impl.FocusImpl; import com.google.gwt.user.client.ui.impl.FocusImpl;
import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;


public class VContextMenu extends VOverlay implements SubPartAware { public class VContextMenu extends VOverlay implements SubPartAware {


addCloseHandler(new CloseHandler<PopupPanel>() { addCloseHandler(new CloseHandler<PopupPanel>() {
@Override @Override
public void onClose(CloseEvent<PopupPanel> event) { public void onClose(CloseEvent<PopupPanel> event) {
Element currentFocus = Util.getFocusedElement();
Element currentFocus = WidgetUtil.getFocusedElement();
if (focusedElement != null if (focusedElement != null
&& (currentFocus == null && (currentFocus == null
|| menu.getElement().isOrHasChild(currentFocus) || RootPanel || menu.getElement().isOrHasChild(currentFocus) || RootPanel
} }


// Attach onload listeners to all images // Attach onload listeners to all images
Util.sinkOnloadForImages(menu.getElement());
WidgetUtil.sinkOnloadForImages(menu.getElement());


// Store the currently focused element, which will be re-focused when // Store the currently focused element, which will be re-focused when
// context menu is closed // context menu is closed
focusedElement = Util.getFocusedElement();
focusedElement = WidgetUtil.getFocusedElement();


// reset height (if it has been previously set explicitly) // reset height (if it has been previously set explicitly)
setHeight(""); setHeight("");

+ 3
- 1
client/src/com/vaadin/client/ui/VCustomLayout.java View File

import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VCaption; import com.vaadin.client.VCaption;
import com.vaadin.client.VCaptionWrapper; import com.vaadin.client.VCaptionWrapper;
import com.vaadin.client.WidgetUtil;


/** /**
* Custom Layout implements complex layout defined with HTML template. * Custom Layout implements complex layout defined with HTML template.


// TODO prefix img src:s here with a regeps, cannot work further with IE // TODO prefix img src:s here with a regeps, cannot work further with IE


String relImgPrefix = Util.escapeAttribute(themeUri + "/layouts/");
String relImgPrefix = WidgetUtil
.escapeAttribute(themeUri + "/layouts/");


// prefix all relative image elements to point to theme dir with a // prefix all relative image elements to point to theme dir with a
// regexp search // regexp search

+ 21
- 20
client/src/com/vaadin/client/ui/VEmbedded.java View File

import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.embedded.EmbeddedConstants; import com.vaadin.shared.ui.embedded.EmbeddedConstants;


public class VEmbedded extends HTML { public class VEmbedded extends HTML {
*/ */
if (uidl.hasAttribute("classid")) { if (uidl.hasAttribute("classid")) {
html.append("classid=\"" html.append("classid=\""
+ Util.escapeAttribute(uidl.getStringAttribute("classid"))
+ "\" ");
+ WidgetUtil.escapeAttribute(uidl
.getStringAttribute("classid")) + "\" ");
} else { } else {
html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "); html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ");
} }
*/ */
if (uidl.hasAttribute("codebase")) { if (uidl.hasAttribute("codebase")) {
html.append("codebase=\"" html.append("codebase=\""
+ Util.escapeAttribute(uidl.getStringAttribute("codebase"))
+ "\" ");
+ WidgetUtil.escapeAttribute(uidl
.getStringAttribute("codebase")) + "\" ");
} else { } else {
html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" ");
} }
String width = paintable.getState().width; String width = paintable.getState().width;


// Add width and height // Add width and height
html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
html.append("width=\"" + WidgetUtil.escapeAttribute(width) + "\" ");
html.append("height=\"" + WidgetUtil.escapeAttribute(height) + "\" ");
html.append("type=\"application/x-shockwave-flash\" "); html.append("type=\"application/x-shockwave-flash\" ");


// Codetype // Codetype
if (uidl.hasAttribute("codetype")) { if (uidl.hasAttribute("codetype")) {
html.append("codetype=\"" html.append("codetype=\""
+ Util.escapeAttribute(uidl.getStringAttribute("codetype"))
+ "\" ");
+ WidgetUtil.escapeAttribute(uidl
.getStringAttribute("codetype")) + "\" ");
} }


// Standby // Standby
if (uidl.hasAttribute("standby")) { if (uidl.hasAttribute("standby")) {
html.append("standby=\"" html.append("standby=\""
+ Util.escapeAttribute(uidl.getStringAttribute("standby"))
+ "\" ");
+ WidgetUtil.escapeAttribute(uidl
.getStringAttribute("standby")) + "\" ");
} }


// Archive // Archive
if (uidl.hasAttribute("archive")) { if (uidl.hasAttribute("archive")) {
html.append("archive=\"" html.append("archive=\""
+ Util.escapeAttribute(uidl.getStringAttribute("archive"))
+ "\" ");
+ WidgetUtil.escapeAttribute(uidl
.getStringAttribute("archive")) + "\" ");
} }


// End object tag // End object tag
// Add parameters to OBJECT // Add parameters to OBJECT
for (String name : parameters.keySet()) { for (String name : parameters.keySet()) {
html.append("<param "); html.append("<param ");
html.append("name=\"" + Util.escapeAttribute(name) + "\" ");
html.append("value=\"" + Util.escapeAttribute(parameters.get(name))
+ "\" ");
html.append("name=\"" + WidgetUtil.escapeAttribute(name) + "\" ");
html.append("value=\""
+ WidgetUtil.escapeAttribute(parameters.get(name)) + "\" ");
html.append("/>"); html.append("/>");
} }


// Build inner EMBED tag // Build inner EMBED tag
html.append("<embed "); html.append("<embed ");
html.append("src=\"" + Util.escapeAttribute(getSrc(uidl, client))
html.append("src=\"" + WidgetUtil.escapeAttribute(getSrc(uidl, client))
+ "\" "); + "\" ");
html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
html.append("width=\"" + WidgetUtil.escapeAttribute(width) + "\" ");
html.append("height=\"" + WidgetUtil.escapeAttribute(height) + "\" ");
html.append("type=\"application/x-shockwave-flash\" "); html.append("type=\"application/x-shockwave-flash\" ");


// Add the parameters to the Embed // Add the parameters to the Embed
for (String name : parameters.keySet()) { for (String name : parameters.keySet()) {
html.append(Util.escapeAttribute(name));
html.append(WidgetUtil.escapeAttribute(name));
html.append("="); html.append("=");
html.append("\"" + Util.escapeAttribute(parameters.get(name))
html.append("\"" + WidgetUtil.escapeAttribute(parameters.get(name))
+ "\""); + "\"");
} }



+ 17
- 15
client/src/com/vaadin/client/ui/VFilterSelect.java View File

import com.vaadin.client.ConnectorMap; import com.vaadin.client.ConnectorMap;
import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.client.ui.aria.HandlesAriaCaption; import com.vaadin.client.ui.aria.HandlesAriaCaption;
import com.vaadin.client.ui.aria.HandlesAriaInvalid; import com.vaadin.client.ui.aria.HandlesAriaInvalid;
// options and are not collapsed (#7506) // options and are not collapsed (#7506)
content = "&nbsp;"; content = "&nbsp;";
} else { } else {
content = Util.escapeHTML(caption);
content = WidgetUtil.escapeHTML(caption);
} }
sb.append("<span>" + content + "</span>"); sb.append("<span>" + content + "</span>");
return sb.toString(); return sb.toString();
final int naturalMenuWidth = menuFirstChild.getOffsetWidth(); final int naturalMenuWidth = menuFirstChild.getOffsetWidth();


if (popupOuterPadding == -1) { if (popupOuterPadding == -1) {
popupOuterPadding = Util.measureHorizontalPaddingAndBorder(
getElement(), 2);
popupOuterPadding = WidgetUtil
.measureHorizontalPaddingAndBorder(getElement(), 2);
} }


if (naturalMenuWidth < desiredWidth) { if (naturalMenuWidth < desiredWidth) {
menu.setHeight(menuHeight + "px"); menu.setHeight(menuHeight + "px");


final int naturalMenuWidthPlusScrollBar = naturalMenuWidth final int naturalMenuWidthPlusScrollBar = naturalMenuWidth
+ Util.getNativeScrollbarSize();
+ WidgetUtil.getNativeScrollbarSize();
if (offsetWidth < naturalMenuWidthPlusScrollBar) { if (offsetWidth < naturalMenuWidthPlusScrollBar) {
menu.setWidth(naturalMenuWidthPlusScrollBar + "px"); menu.setWidth(naturalMenuWidthPlusScrollBar + "px");
} }
final MenuItem mi = new MenuItem(s.getDisplayString(), true, s); final MenuItem mi = new MenuItem(s.getDisplayString(), true, s);
Roles.getListitemRole().set(mi.getElement()); Roles.getListitemRole().set(mi.getElement());


Util.sinkOnloadForImages(mi.getElement());
WidgetUtil.sinkOnloadForImages(mi.getElement());


this.addItem(mi); this.addItem(mi);
if (s == currentSuggestion) { if (s == currentSuggestion) {
* the end and the focus to the start. This makes Firefox work * the end and the focus to the start. This makes Firefox work
* the same way as other browsers (#13477) * the same way as other browsers (#13477)
*/ */
Util.setSelectionRange(getElement(), pos, length, "backward");
WidgetUtil.setSelectionRange(getElement(), pos, length,
"backward");


} else { } else {
/* /*
} }


private void forceReflow() { private void forceReflow() {
Util.setStyleTemporarily(tb.getElement(), "zoom", "1");
WidgetUtil.setStyleTemporarily(tb.getElement(), "zoom", "1");
} }


/** /**
int availableHeight = 0; int availableHeight = 0;
availableHeight = getOffsetHeight(); availableHeight = getOffsetHeight();


int iconHeight = Util.getRequiredHeight(selectedItemIcon);
int iconHeight = WidgetUtil.getRequiredHeight(selectedItemIcon);
int marginTop = (availableHeight - iconHeight) / 2; int marginTop = (availableHeight - iconHeight) / 2;
selectedItemIcon.getElement().getStyle() selectedItemIcon.getElement().getStyle()
.setMarginTop(marginTop, Unit.PX); .setMarginTop(marginTop, Unit.PX);
*/ */
public void updateSuggestionPopupMinWidth() { public void updateSuggestionPopupMinWidth() {
// used only to calculate minimum width // used only to calculate minimum width
String captions = Util.escapeHTML(inputPrompt);
String captions = WidgetUtil.escapeHTML(inputPrompt);


for (FilterSelectSuggestion suggestion : currentSuggestions) { for (FilterSelectSuggestion suggestion : currentSuggestions) {
// Collect captions so we can calculate minimum width for // Collect captions so we can calculate minimum width for
if (captions.length() > 0) { if (captions.length() > 0) {
captions += "|"; captions += "|";
} }
captions += Util.escapeHTML(suggestion.getReplacementString());
captions += WidgetUtil
.escapeHTML(suggestion.getReplacementString());
} }


// Calculate minimum textarea width // Calculate minimum textarea width
*/ */
preventNextBlurEventInIE = false; preventNextBlurEventInIE = false;


Element focusedElement = Util.getIEFocusedElement();
Element focusedElement = WidgetUtil.getFocusedElement();
if (getElement().isOrHasChild(focusedElement) if (getElement().isOrHasChild(focusedElement)
|| suggestionPopup.getElement() || suggestionPopup.getElement()
.isOrHasChild(focusedElement)) { .isOrHasChild(focusedElement)) {
* when the popup is used to view longer items than the text box is * when the popup is used to view longer items than the text box is
* wide. * wide.
*/ */
int w = Util.getRequiredWidth(this);
int w = WidgetUtil.getRequiredWidth(this);


if ((!initDone || currentPage + 1 < 0) if ((!initDone || currentPage + 1 < 0)
&& suggestionPopupMinWidth > w) { && suggestionPopupMinWidth > w) {


// Use util.getRequiredWidth instead of getOffsetWidth here // Use util.getRequiredWidth instead of getOffsetWidth here


int iconWidth = selectedItemIcon == null ? 0 : Util
int iconWidth = selectedItemIcon == null ? 0 : WidgetUtil
.getRequiredWidth(selectedItemIcon); .getRequiredWidth(selectedItemIcon);
int buttonWidth = popupOpener == null ? 0 : Util
int buttonWidth = popupOpener == null ? 0 : WidgetUtil
.getRequiredWidth(popupOpener); .getRequiredWidth(popupOpener);


/* /*

+ 21
- 16
client/src/com/vaadin/client/ui/VFlash.java View File

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


import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;


public class VFlash extends HTML { public class VFlash extends HTML {


* this by setting his own classid. * this by setting his own classid.
*/ */
if (classId != null) { if (classId != null) {
html.append("classid=\"" + Util.escapeAttribute(classId) + "\" ");
html.append("classid=\"" + WidgetUtil.escapeAttribute(classId)
+ "\" ");
} else { } else {
html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "); html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ");
} }
* codebase * codebase
*/ */
if (codebase != null) { if (codebase != null) {
html.append("codebase=\"" + Util.escapeAttribute(codebase) + "\" ");
html.append("codebase=\"" + WidgetUtil.escapeAttribute(codebase)
+ "\" ");
} else { } else {
html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" ");
} }


// Add width and height // Add width and height
html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
html.append("width=\"" + WidgetUtil.escapeAttribute(width) + "\" ");
html.append("height=\"" + WidgetUtil.escapeAttribute(height) + "\" ");
html.append("type=\"application/x-shockwave-flash\" "); html.append("type=\"application/x-shockwave-flash\" ");


// Codetype // Codetype
if (codetype != null) { if (codetype != null) {
html.append("codetype=\"" + Util.escapeAttribute(codetype) + "\" ");
html.append("codetype=\"" + WidgetUtil.escapeAttribute(codetype)
+ "\" ");
} }


// Standby // Standby
if (standby != null) { if (standby != null) {
html.append("standby=\"" + Util.escapeAttribute(standby) + "\" ");
html.append("standby=\"" + WidgetUtil.escapeAttribute(standby)
+ "\" ");
} }


// Archive // Archive
if (archive != null) { if (archive != null) {
html.append("archive=\"" + Util.escapeAttribute(archive) + "\" ");
html.append("archive=\"" + WidgetUtil.escapeAttribute(archive)
+ "\" ");
} }


// End object tag // End object tag
// Add parameters to OBJECT // Add parameters to OBJECT
for (String name : embedParams.keySet()) { for (String name : embedParams.keySet()) {
html.append("<param "); html.append("<param ");
html.append("name=\"" + Util.escapeAttribute(name) + "\" ");
html.append("name=\"" + WidgetUtil.escapeAttribute(name) + "\" ");
html.append("value=\"" html.append("value=\""
+ Util.escapeAttribute(embedParams.get(name)) + "\" ");
+ WidgetUtil.escapeAttribute(embedParams.get(name)) + "\" ");
html.append("/>"); html.append("/>");
} }


// Build inner EMBED tag // Build inner EMBED tag
html.append("<embed "); html.append("<embed ");
html.append("src=\"" + Util.escapeAttribute(source) + "\" ");
html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
html.append("src=\"" + WidgetUtil.escapeAttribute(source) + "\" ");
html.append("width=\"" + WidgetUtil.escapeAttribute(width) + "\" ");
html.append("height=\"" + WidgetUtil.escapeAttribute(height) + "\" ");
html.append("type=\"application/x-shockwave-flash\" "); html.append("type=\"application/x-shockwave-flash\" ");


// Add the parameters to the Embed // Add the parameters to the Embed
for (String name : embedParams.keySet()) { for (String name : embedParams.keySet()) {
html.append(Util.escapeAttribute(name));
html.append(WidgetUtil.escapeAttribute(name));
html.append("="); html.append("=");
html.append("\"" + Util.escapeAttribute(embedParams.get(name))
+ "\"");
html.append("\""
+ WidgetUtil.escapeAttribute(embedParams.get(name)) + "\"");
} }


// End embed tag // End embed tag

+ 2
- 1
client/src/com/vaadin/client/ui/VLabel.java View File

import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VTooltip; import com.vaadin.client.VTooltip;
import com.vaadin.client.WidgetUtil;


public class VLabel extends HTML { public class VLabel extends HTML {


if (BrowserInfo.get().isIE8()) { if (BrowserInfo.get().isIE8()) {
// #3983 - IE8 incorrectly replaces \n with <br> so we do the // #3983 - IE8 incorrectly replaces \n with <br> so we do the
// escaping manually and set as HTML // escaping manually and set as HTML
super.setHTML(Util.escapeHTML(text));
super.setHTML(WidgetUtil.escapeHTML(text));
} else { } else {
super.setText(text); super.setText(text);
} }

+ 6
- 4
client/src/com/vaadin/client/ui/VMenuBar.java View File

import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.menubar.MenuBarConstants; import com.vaadin.shared.ui.menubar.MenuBarConstants;


public class VMenuBar extends SimpleFocusablePanel implements public class VMenuBar extends SimpleFocusablePanel implements
} }
String itemText = item.getStringAttribute("text"); String itemText = item.getStringAttribute("text");
if (!htmlContentAllowed) { if (!htmlContentAllowed) {
itemText = Util.escapeHTML(itemText);
itemText = WidgetUtil.escapeHTML(itemText);
} }
itemHTML.append(itemText); itemHTML.append(itemText);
itemHTML.append("</span>"); itemHTML.append("</span>");


// Make room for the scroll bar by adjusting the width of the // Make room for the scroll bar by adjusting the width of the
// popup // popup
style.setWidth(contentWidth + Util.getNativeScrollbarSize(),
style.setWidth(
contentWidth + WidgetUtil.getNativeScrollbarSize(),
Unit.PX); Unit.PX);
popup.positionOrSizeUpdated(); popup.positionOrSizeUpdated();
} }


// Sink the onload event for any icons. The onload // Sink the onload event for any icons. The onload
// events are handled by the parent VMenuBar. // events are handled by the parent VMenuBar.
Util.sinkOnloadForImages(getElement());
WidgetUtil.sinkOnloadForImages(getElement());
} }


@Override @Override


@Override @Override
public void setText(String text) { public void setText(String text) {
setHTML(Util.escapeHTML(text));
setHTML(WidgetUtil.escapeHTML(text));
} }


public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {

+ 4
- 4
client/src/com/vaadin/client/ui/VNotification.java View File

import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.shared.Position; import com.vaadin.shared.Position;
import com.vaadin.shared.ui.ui.NotificationRole; import com.vaadin.shared.ui.ui.NotificationRole;
* nudge (#8551) * nudge (#8551)
*/ */
if (BrowserInfo.get().isAndroid()) { if (BrowserInfo.get().isAndroid()) {
Util.setStyleTemporarily(getElement(), "display", "none");
WidgetUtil.setStyleTemporarily(getElement(), "display", "none");
} }
} }


String caption = notification String caption = notification
.getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION); .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION);
if (onlyPlainText) { if (onlyPlainText) {
caption = Util.escapeHTML(caption);
caption = WidgetUtil.escapeHTML(caption);
caption = caption.replaceAll("\\n", "<br />"); caption = caption.replaceAll("\\n", "<br />");
} }
html += "<h1>" + caption + "</h1>"; html += "<h1>" + caption + "</h1>";
String message = notification String message = notification
.getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE); .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE);
if (onlyPlainText) { if (onlyPlainText) {
message = Util.escapeHTML(message);
message = WidgetUtil.escapeHTML(message);
message = message.replaceAll("\\n", "<br />"); message = message.replaceAll("\\n", "<br />");
} }
html += "<p>" + message + "</p>"; html += "<p>" + message + "</p>";

+ 3
- 2
client/src/com/vaadin/client/ui/VOptionGroup.java View File

import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.EventId; import com.vaadin.shared.EventId;
import com.vaadin.shared.ui.optiongroup.OptionGroupConstants; import com.vaadin.shared.ui.optiongroup.OptionGroupConstants;




String itemHtml = opUidl.getStringAttribute("caption"); String itemHtml = opUidl.getStringAttribute("caption");
if (!htmlContentAllowed) { if (!htmlContentAllowed) {
itemHtml = Util.escapeHTML(itemHtml);
itemHtml = WidgetUtil.escapeHTML(itemHtml);
} }


String iconUrl = opUidl.getStringAttribute("icon"); String iconUrl = opUidl.getStringAttribute("icon");
op.setStyleName("v-radiobutton"); op.setStyleName("v-radiobutton");
} }
if (iconUrl != null && iconUrl.length() != 0) { if (iconUrl != null && iconUrl.length() != 0) {
Util.sinkOnloadForImages(op.getElement());
WidgetUtil.sinkOnloadForImages(op.getElement());
op.addHandler(iconLoadHandler, LoadEvent.getType()); op.addHandler(iconLoadHandler, LoadEvent.getType());
} }



+ 2
- 1
client/src/com/vaadin/client/ui/VOverlay.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ComputedStyle; import com.vaadin.client.ComputedStyle;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;


/** /**
* <p> * <p>
// IE9 and IE10 have a bug, when resize an a element with box-shadow. // IE9 and IE10 have a bug, when resize an a element with box-shadow.
// IE9 and IE10 need explicit update to remove extra box-shadows // IE9 and IE10 need explicit update to remove extra box-shadows
if (BrowserInfo.get().isIE9() || BrowserInfo.get().isIE10()) { if (BrowserInfo.get().isIE9() || BrowserInfo.get().isIE10()) {
Util.forceIERedraw(getElement());
WidgetUtil.forceIERedraw(getElement());
} }
} }



+ 8
- 1
client/src/com/vaadin/client/ui/VPopupView.java View File

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.DOM;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.ui.Focusable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasEnabled;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.DeferredWorker; import com.vaadin.client.DeferredWorker;

+ 43
- 37
client/src/com/vaadin/client/ui/VScrollTable.java View File

import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.VTooltip; import com.vaadin.client.VTooltip;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow; import com.vaadin.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow;
import com.vaadin.client.ui.dd.DDUtil; import com.vaadin.client.ui.dd.DDUtil;
import com.vaadin.client.ui.dd.VAbstractDropHandler; import com.vaadin.client.ui.dd.VAbstractDropHandler;


@Override @Override
public void showContextMenu(Event event) { public void showContextMenu(Event event) {
int left = Util.getTouchOrMouseClientX(event);
int top = Util.getTouchOrMouseClientY(event);
int left = WidgetUtil.getTouchOrMouseClientX(event);
int top = WidgetUtil.getTouchOrMouseClientY(event);
boolean menuShown = handleBodyContextMenu(left, top); boolean menuShown = handleBodyContextMenu(left, top);
if (menuShown) { if (menuShown) {
event.stopPropagation(); event.stopPropagation();


// 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
Element elementUnderMouse = Util.getElementUnderMouse(event
.getNativeEvent());
Element elementUnderMouse = WidgetUtil
.getElementUnderMouse(event.getNativeEvent());
if (lastMouseDownTarget != null if (lastMouseDownTarget != null
&& lastMouseDownTarget.isOrHasChild(elementUnderMouse)) { && lastMouseDownTarget.isOrHasChild(elementUnderMouse)) {
mouseUpPreviewMatched = true; mouseUpPreviewMatched = true;
int w = total; int w = total;
w += scrollBody.getCellExtraWidth() * visibleColOrder.length; w += scrollBody.getCellExtraWidth() * visibleColOrder.length;
if (willHaveScrollbarz) { if (willHaveScrollbarz) {
w += Util.getNativeScrollbarSize();
w += WidgetUtil.getNativeScrollbarSize();
} }
setContentWidth(w); setContentWidth(w);
} }
availW -= scrollBody.getCellExtraWidth() * visibleColOrder.length; availW -= scrollBody.getCellExtraWidth() * visibleColOrder.length;


if (willHaveScrollbarz) { if (willHaveScrollbarz) {
availW -= Util.getNativeScrollbarSize();
availW -= WidgetUtil.getNativeScrollbarSize();
} }


// TODO refactor this code to be the same as in resize timer // TODO refactor this code to be the same as in resize timer
} }
boolean needsSpaceForHorizontalSrollbar = (total > availW); boolean needsSpaceForHorizontalSrollbar = (total > availW);
if (needsSpaceForHorizontalSrollbar) { if (needsSpaceForHorizontalSrollbar) {
bodyHeight += Util.getNativeScrollbarSize();
bodyHeight += WidgetUtil.getNativeScrollbarSize();
} }
scrollBodyPanel.setHeight(bodyHeight + "px"); scrollBodyPanel.setHeight(bodyHeight + "px");
Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
WidgetUtil.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
} }


isNewBody = false; isNewBody = false;
* Ensures the column alignments are correct at initial loading. <br/> * Ensures the column alignments are correct at initial loading. <br/>
* (child components widths are correct) * (child components widths are correct)
*/ */
Util.runWebkitOverflowAutoFixDeferred(scrollBodyPanel.getElement());
WidgetUtil.runWebkitOverflowAutoFixDeferred(scrollBodyPanel
.getElement());


hadScrollBars = willHaveScrollbarz; hadScrollBars = willHaveScrollbarz;
} }
case Event.ONTOUCHSTART: case Event.ONTOUCHSTART:
case Event.ONMOUSEDOWN: case Event.ONMOUSEDOWN:
if (columnReordering if (columnReordering
&& Util.isTouchEventOrLeftMouseButton(event)) {
&& WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
if (event.getTypeInt() == Event.ONTOUCHSTART) { if (event.getTypeInt() == Event.ONTOUCHSTART) {
/* /*
* prevent using this event in e.g. scrolling * prevent using this event in e.g. scrolling
case Event.ONTOUCHEND: case Event.ONTOUCHEND:
case Event.ONTOUCHCANCEL: case Event.ONTOUCHCANCEL:
if (columnReordering if (columnReordering
&& Util.isTouchEventOrLeftMouseButton(event)) {
&& WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
dragging = false; dragging = false;
DOM.releaseCapture(getElement()); DOM.releaseCapture(getElement());


if (Util.isTouchEvent(event)) {
if (WidgetUtil.isTouchEvent(event)) {
/* /*
* Prevent using in e.g. scrolling and prevent generated * Prevent using in e.g. scrolling and prevent generated
* events. * events.


if (!moved) { if (!moved) {
// mouse event was a click to header -> sort column // mouse event was a click to header -> sort column
if (sortable && Util.isTouchEventOrLeftMouseButton(event)) {
if (sortable
&& WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
if (sortColumn.equals(cid)) { if (sortColumn.equals(cid)) {
// just toggle order // just toggle order
client.updateVariable(paintableId, "sortascending", client.updateVariable(paintableId, "sortascending",
rowRequestHandler.run(); // run immediately rowRequestHandler.run(); // run immediately
} }
fireHeaderClickedEvent(event); fireHeaderClickedEvent(event);
if (Util.isTouchEvent(event)) {
if (WidgetUtil.isTouchEvent(event)) {
/* /*
* Prevent using in e.g. scrolling and prevent generated * Prevent using in e.g. scrolling and prevent generated
* events. * events.
break; break;
case Event.ONTOUCHMOVE: case Event.ONTOUCHMOVE:
case Event.ONMOUSEMOVE: case Event.ONMOUSEMOVE:
if (dragging && Util.isTouchEventOrLeftMouseButton(event)) {
if (dragging && WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
if (event.getTypeInt() == Event.ONTOUCHMOVE) { if (event.getTypeInt() == Event.ONTOUCHMOVE) {
/* /*
* prevent using this event in e.g. scrolling * prevent using this event in e.g. scrolling
moved = true; moved = true;
} }


final int clientX = Util.getTouchOrMouseClientX(event);
final int clientX = WidgetUtil
.getTouchOrMouseClientX(event);
final int x = clientX + tHead.hTableWrapper.getScrollLeft(); final int x = clientX + tHead.hTableWrapper.getScrollLeft();
int slotX = headerX; int slotX = headerX;
closestSlot = colIndex; closestSlot = colIndex;
private void onResizeEvent(Event event) { private void onResizeEvent(Event event) {
switch (DOM.eventGetType(event)) { switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN: case Event.ONMOUSEDOWN:
if (!Util.isTouchEventOrLeftMouseButton(event)) {
if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
return; return;
} }
isResizing = true; isResizing = true;
DOM.eventPreventDefault(event); DOM.eventPreventDefault(event);
break; break;
case Event.ONMOUSEUP: case Event.ONMOUSEUP:
if (!Util.isTouchEventOrLeftMouseButton(event)) {
if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
return; return;
} }
isResizing = false; isResizing = false;
fireColumnResizeEvent(cid, originalWidth, getColWidth(cid)); fireColumnResizeEvent(cid, originalWidth, getColWidth(cid));
break; break;
case Event.ONMOUSEMOVE: case Event.ONMOUSEMOVE:
if (!Util.isTouchEventOrLeftMouseButton(event)) {
if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
return; return;
} }
if (isResizing) { if (isResizing) {
*/ */
public int getRequiredHeight() { public int getRequiredHeight() {
return preSpacer.getOffsetHeight() + postSpacer.getOffsetHeight() return preSpacer.getOffsetHeight() + postSpacer.getOffsetHeight()
+ Util.getRequiredHeight(table);
+ WidgetUtil.getRequiredHeight(table);
} }


private void constructDOM() { private void constructDOM() {
if (!BrowserInfo.get().isAndroid()) { if (!BrowserInfo.get().isAndroid()) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
Util.simulateClickFromTouchEvent(touchStart,
this);
WidgetUtil.simulateClickFromTouchEvent(
touchStart, this);
} }
touchStart = null; touchStart = null;
} }
*/ */
if (mouseUpPreviewMatched if (mouseUpPreviewMatched
&& lastMouseDownTarget != null && lastMouseDownTarget != null
&& lastMouseDownTarget == getElementTdOrTr(Util
&& lastMouseDownTarget == getElementTdOrTr(WidgetUtil
.getElementUnderMouse(event))) { .getElementUnderMouse(event))) {
// "Click" with left, right or middle button // "Click" with left, right or middle button


* Touch has not been handled as neither context or * Touch has not been handled as neither context or
* drag start, handle it as a click. * drag start, handle it as a click.
*/ */
Util.simulateClickFromTouchEvent(touchStart, this);
WidgetUtil.simulateClickFromTouchEvent(touchStart,
this);
touchStart = null; touchStart = null;
} }
touchContextProvider.cancel(); touchContextProvider.cancel();
* the corresponding mouseup event if it's on a * the corresponding mouseup event if it's on a
* different part of the page. * different part of the page.
*/ */
lastMouseDownTarget = getElementTdOrTr(Util
lastMouseDownTarget = getElementTdOrTr(WidgetUtil
.getElementUnderMouse(event)); .getElementUnderMouse(event));
mouseUpPreviewMatched = false; mouseUpPreviewMatched = false;
mouseUpEventPreviewRegistration = Event mouseUpEventPreviewRegistration = Event


private Element getElementTdOrTr(Element element) { private Element getElementTdOrTr(Element element) {


Widget widget = Util.findWidget(element, null);
Widget widget = WidgetUtil.findWidget(element, null);


if (widget != this) { if (widget != this) {
/* /*
public void showContextMenu(Event event) { public void showContextMenu(Event event) {
if (enabled && actionKeys != null) { if (enabled && actionKeys != null) {
// Show context menu if there are registered action handlers // Show context menu if there are registered action handlers
int left = Util.getTouchOrMouseClientX(event)
int left = WidgetUtil.getTouchOrMouseClientX(event)
+ Window.getScrollLeft(); + Window.getScrollLeft();
int top = Util.getTouchOrMouseClientY(event)
int top = WidgetUtil.getTouchOrMouseClientY(event)
+ Window.getScrollTop(); + Window.getScrollTop();
showContextMenu(left, top); showContextMenu(left, top);
} }
.getVisibleCellCount(); ix++) { .getVisibleCellCount(); ix++) {
spanWidth += tHead.getHeaderCell(ix).getOffsetWidth(); spanWidth += tHead.getHeaderCell(ix).getOffsetWidth();
} }
Util.setWidthExcludingPaddingAndBorder((Element) getElement()
.getChild(cellIx), spanWidth, 13, false);
WidgetUtil.setWidthExcludingPaddingAndBorder(
(Element) getElement().getChild(cellIx), spanWidth, 13,
false);
} }
} }


int totalExtraWidth = scrollBody.getCellExtraWidth() int totalExtraWidth = scrollBody.getCellExtraWidth()
* visibleCellCount; * visibleCellCount;
if (willHaveScrollbars()) { if (willHaveScrollbars()) {
totalExtraWidth += Util.getNativeScrollbarSize();
totalExtraWidth += WidgetUtil.getNativeScrollbarSize();
} }
availW -= totalExtraWidth; availW -= totalExtraWidth;
int forceScrollBodyWidth = -1; int forceScrollBodyWidth = -1;
int bodyHeight = scrollBody.getRequiredHeight(); int bodyHeight = scrollBody.getRequiredHeight();
boolean needsSpaceForHorizontalScrollbar = (availW < usedMinimumWidth); boolean needsSpaceForHorizontalScrollbar = (availW < usedMinimumWidth);
if (needsSpaceForHorizontalScrollbar) { if (needsSpaceForHorizontalScrollbar) {
bodyHeight += Util.getNativeScrollbarSize();
bodyHeight += WidgetUtil.getNativeScrollbarSize();
} }
int heightBefore = getOffsetHeight(); int heightBefore = getOffsetHeight();
scrollBodyPanel.setHeight(bodyHeight + "px"); scrollBodyPanel.setHeight(bodyHeight + "px");
*/ */
private int getBorderWidth() { private int getBorderWidth() {
if (borderWidth < 0) { if (borderWidth < 0) {
borderWidth = Util.measureHorizontalPaddingAndBorder(
borderWidth = WidgetUtil.measureHorizontalPaddingAndBorder(
scrollBodyPanel.getElement(), 2); scrollBodyPanel.getElement(), 2);
if (borderWidth < 0) { if (borderWidth < 0) {
borderWidth = 0; borderWidth = 0;
Class<? extends Widget> clazz = getRowClass(); Class<? extends Widget> clazz = getRowClass();
VScrollTableRow row = null; VScrollTableRow row = null;
if (clazz != null) { if (clazz != null) {
row = Util.findWidget(elementOver, clazz);
row = WidgetUtil.findWidget(elementOver, clazz);
} }
if (row != null) { if (row != null) {
dropDetails.overkey = row.rowKey; dropDetails.overkey = row.rowKey;
* FIXME The next line doesn't always do what expected, because if the * FIXME The next line doesn't always do what expected, because if the
* row is not in the DOM it won't scroll to it. * row is not in the DOM it won't scroll to it.
*/ */
Util.scrollIntoViewVertically(row.getElement());
WidgetUtil.scrollIntoViewVertically(row.getElement());
} }


/** /**
* ...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)
*/ */
Element focusedElement = Util.getIEFocusedElement();
Element focusedElement = WidgetUtil.getFocusedElement();
if (Util.getConnectorForElement(client, getParent(), focusedElement) == this if (Util.getConnectorForElement(client, getParent(), focusedElement) == this
&& focusedElement != null && focusedElement != null
&& focusedElement != scrollBodyPanel.getFocusElement()) { && focusedElement != scrollBodyPanel.getFocusElement()) {


@Override @Override
public String getSubPartName(com.google.gwt.user.client.Element subElement) { public String getSubPartName(com.google.gwt.user.client.Element subElement) {
Widget widget = Util.findWidget(subElement, null);
Widget widget = WidgetUtil.findWidget(subElement, null);
if (widget instanceof HeaderCell) { if (widget instanceof HeaderCell) {
return SUBPART_HEADER + "[" + tHead.visibleCells.indexOf(widget) return SUBPART_HEADER + "[" + tHead.visibleCells.indexOf(widget)
+ "]"; + "]";

+ 4
- 4
client/src/com/vaadin/client/ui/VSlider.java View File

import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.HasValue;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.slider.SliderOrientation; import com.vaadin.shared.ui.slider.SliderOrientation;


public class VSlider extends SimpleFocusablePanel implements Field, public class VSlider extends SimpleFocusablePanel implements Field,
} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
feedbackPopup.show(); feedbackPopup.show();
} }
if (Util.isTouchEvent(event)) {
if (WidgetUtil.isTouchEvent(event)) {
event.preventDefault(); // avoid simulated events event.preventDefault(); // avoid simulated events
event.stopPropagation(); event.stopPropagation();
} }
*/ */
protected int getEventPosition(Event event) { protected int getEventPosition(Event event) {
if (isVertical()) { if (isVertical()) {
return Util.getTouchOrMouseClientY(event);
return WidgetUtil.getTouchOrMouseClientY(event);
} else { } else {
return Util.getTouchOrMouseClientX(event);
return WidgetUtil.getTouchOrMouseClientX(event);
} }
} }



+ 3
- 3
client/src/com/vaadin/client/ui/VTabsheet.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VCaption; import com.vaadin.client.VCaption;
import com.vaadin.client.VTooltip; import com.vaadin.client.VTooltip;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
public int getRequiredWidth() { public int getRequiredWidth() {
int width = super.getRequiredWidth(); int width = super.getRequiredWidth();
if (closeButton != null) { if (closeButton != null) {
width += Util.getRequiredWidth(closeButton);
width += WidgetUtil.getRequiredWidth(closeButton);
} }
return width; return width;
} }


/** 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 int getContentAreaBorderWidth() { public int getContentAreaBorderWidth() {
return Util.measureHorizontalBorder(contentNode);
return WidgetUtil.measureHorizontalBorder(contentNode);
} }


@Override @Override

+ 2
- 2
client/src/com/vaadin/client/ui/VTextArea.java View File

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.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.dd.DragImageModifier; import com.vaadin.client.ui.dd.DragImageModifier;


/** /**
// and reattach the whole TextArea. // and reattach the whole TextArea.
// Webkit fails to properly reflow the text when enabling wrapping, // Webkit fails to properly reflow the text when enabling wrapping,
// same workaround // same workaround
Util.detachAttach(getElement());
WidgetUtil.detachAttach(getElement());
} }
this.wordwrap = wordwrap; this.wordwrap = wordwrap;
} }

+ 2
- 2
client/src/com/vaadin/client/ui/VTextField.java View File

import com.google.gwt.user.client.ui.TextBoxBase; import com.google.gwt.user.client.ui.TextBoxBase;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.EventId; import com.vaadin.shared.EventId;
import com.vaadin.shared.ui.textfield.TextFieldConstants; import com.vaadin.shared.ui.textfield.TextFieldConstants;


* @return true iff the value was updated * @return true iff the value was updated
*/ */
protected boolean updateCursorPosition() { protected boolean updateCursorPosition() {
if (Util.isAttachedAndDisplayed(this)) {
if (WidgetUtil.isAttachedAndDisplayed(this)) {
int cursorPos = getCursorPos(); int cursorPos = getCursorPos();
if (lastCursorPos != cursorPos) { if (lastCursorPos != cursorPos) {
client.updateVariable(paintableId, client.updateVariable(paintableId,

+ 4
- 3
client/src/com/vaadin/client/ui/VTree.java View File

import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
import com.vaadin.client.ui.aria.HandlesAriaCaption; import com.vaadin.client.ui.aria.HandlesAriaCaption;
import com.vaadin.client.ui.dd.DDUtil; import com.vaadin.client.ui.dd.DDUtil;
} }


private String findCurrentMouseOverKey(Element elementOver) { private String findCurrentMouseOverKey(Element elementOver) {
TreeNode treeNode = Util.findWidget(elementOver, TreeNode.class);
TreeNode treeNode = WidgetUtil.findWidget(elementOver, TreeNode.class);
return treeNode == null ? null : treeNode.key; return treeNode == null ? null : treeNode.key;
} }


* Scrolls the caption into view * Scrolls the caption into view
*/ */
public void scrollIntoView() { public void scrollIntoView() {
Util.scrollIntoViewVertically(nodeCaptionDiv);
WidgetUtil.scrollIntoViewVertically(nodeCaptionDiv);
} }


public void setIcon(String iconUrl, String altText) { public void setIcon(String iconUrl, String altText) {
return "fe"; return "fe";
} }


TreeNode treeNode = Util.findWidget(subElement, TreeNode.class);
TreeNode treeNode = WidgetUtil.findWidget(subElement, TreeNode.class);
if (treeNode == null) { if (treeNode == null) {
// Did not click on a node, let somebody else take care of the // Did not click on a node, let somebody else take care of the
// locator string // locator string

+ 4
- 3
client/src/com/vaadin/client/ui/VTreeTable.java View File

import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComputedStyle; import com.vaadin.client.ComputedStyle;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.VTreeTable.VTreeTableScrollBody.VTreeTableRow; import com.vaadin.client.ui.VTreeTable.VTreeTableScrollBody.VTreeTableRow;


public class VTreeTable extends VScrollTable { public class VTreeTable extends VScrollTable {
.getVisibleCellCount(); ix++) { .getVisibleCellCount(); ix++) {
spanWidth += tHead.getHeaderCell(ix).getOffsetWidth(); spanWidth += tHead.getHeaderCell(ix).getOffsetWidth();
} }
Util.setWidthExcludingPaddingAndBorder((Element) getElement()
.getChild(cellIx), spanWidth, 13, false);
WidgetUtil.setWidthExcludingPaddingAndBorder(
(Element) getElement().getChild(cellIx), spanWidth, 13,
false);
} }
} }



+ 6
- 6
client/src/com/vaadin/client/ui/VTwinColSelect.java View File

import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Panel;
import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.twincolselect.TwinColSelectConstants; import com.vaadin.shared.ui.twincolselect.TwinColSelectConstants;


public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler,


/** 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 setInternalHeights() { public void setInternalHeights() {
int captionHeight = Util.getRequiredHeight(captionWrapper);
int captionHeight = WidgetUtil.getRequiredHeight(captionWrapper);
int totalHeight = getOffsetHeight(); int totalHeight = getOffsetHeight();


String selectHeight = (totalHeight - captionHeight) + "px"; String selectHeight = (totalHeight - captionHeight) + "px";
/** 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 setInternalWidths() { public void setInternalWidths() {
getElement().getStyle().setPosition(Position.RELATIVE); getElement().getStyle().setPosition(Position.RELATIVE);
int bordersAndPaddings = Util.measureHorizontalPaddingAndBorder(
int bordersAndPaddings = WidgetUtil.measureHorizontalPaddingAndBorder(
buttons.getElement(), 0); buttons.getElement(), 0);


int buttonWidth = Util.getRequiredWidth(buttons);
int buttonWidth = WidgetUtil.getRequiredWidth(buttons);
int totalWidth = getOffsetWidth(); int totalWidth = getOffsetWidth();


int spaceForSelect = (totalWidth - buttonWidth - bordersAndPaddings) / 2; int spaceForSelect = (totalWidth - buttonWidth - bordersAndPaddings) / 2;
if (options.getElement() == subElement) { if (options.getElement() == subElement) {
return SUBPART_OPTION_SELECT; return SUBPART_OPTION_SELECT;
} else { } else {
int idx = Util.getChildElementIndex(subElement);
int idx = WidgetUtil.getChildElementIndex(subElement);
return SUBPART_OPTION_SELECT_ITEM + idx; return SUBPART_OPTION_SELECT_ITEM + idx;
} }
} else if (selections.getElement().isOrHasChild(subElement)) { } else if (selections.getElement().isOrHasChild(subElement)) {
if (selections.getElement() == subElement) { if (selections.getElement() == subElement) {
return SUBPART_SELECTION_SELECT; return SUBPART_SELECTION_SELECT;
} else { } else {
int idx = Util.getChildElementIndex(subElement);
int idx = WidgetUtil.getChildElementIndex(subElement);
return SUBPART_SELECTION_SELECT_ITEM + idx; return SUBPART_SELECTION_SELECT_ITEM + idx;
} }
} else if (add.getElement().isOrHasChild(subElement)) { } else if (add.getElement().isOrHasChild(subElement)) {

+ 2
- 2
client/src/com/vaadin/client/ui/VUI.java View File

import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.Profiler; import com.vaadin.client.Profiler;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
* @param focusedElement * @param focusedElement
*/ */
public void storeFocus() { public void storeFocus() {
storedFocus = Util.getFocusedElement();
storedFocus = WidgetUtil.getFocusedElement();
} }


/** /**

+ 16
- 15
client/src/com/vaadin/client/ui/VWindow.java View File



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


import static com.vaadin.client.Util.isFocusedElementEditable;
import static com.vaadin.client.WidgetUtil.isFocusedElementEditable;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import com.vaadin.client.ConnectorMap; import com.vaadin.client.ConnectorMap;
import com.vaadin.client.Focusable; import com.vaadin.client.Focusable;
import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.debug.internal.VDebugWindow; import com.vaadin.client.debug.internal.VDebugWindow;
import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.AriaHelper;
* ticket #11994 which was changing the size to 110% was replaced * ticket #11994 which was changing the size to 110% was replaced
* with this due to ticket #12943 * with this due to ticket #12943
*/ */
Util.runWebkitOverflowAutoFix(contents.getFirstChildElement());
WidgetUtil
.runWebkitOverflowAutoFix(contents.getFirstChildElement());
} }
} }


public void setCaption(String c, String iconURL, boolean asHtml) { public void setCaption(String c, String iconURL, boolean asHtml) {
String html = c; String html = c;
if (!asHtml) { if (!asHtml) {
c = Util.escapeHTML(c);
c = WidgetUtil.escapeHTML(c);
} }


// Provide information to assistive device users that a sub window was // Provide information to assistive device users that a sub window was
} }


private void onResizeEvent(Event event) { private void onResizeEvent(Event event) {
if (resizable && Util.isTouchEventOrLeftMouseButton(event)) {
if (resizable && WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
switch (event.getTypeInt()) { switch (event.getTypeInt()) {
case Event.ONMOUSEDOWN: case Event.ONMOUSEDOWN:
case Event.ONTOUCHSTART: case Event.ONTOUCHSTART:
resizeBox.getStyle().setVisibility(Visibility.HIDDEN); resizeBox.getStyle().setVisibility(Visibility.HIDDEN);
} }
resizing = true; resizing = true;
startX = Util.getTouchOrMouseClientX(event);
startY = Util.getTouchOrMouseClientY(event);
startX = WidgetUtil.getTouchOrMouseClientX(event);
startY = WidgetUtil.getTouchOrMouseClientY(event);
origW = getElement().getOffsetWidth(); origW = getElement().getOffsetWidth();
origH = getElement().getOffsetHeight(); origH = getElement().getOffsetHeight();
DOM.setCapture(getElement()); DOM.setCapture(getElement());
return; return;
} }


int w = Util.getTouchOrMouseClientX(event) - startX + origW;
int h = Util.getTouchOrMouseClientY(event) - startY + origH;
int w = WidgetUtil.getTouchOrMouseClientX(event) - startX + origW;
int h = WidgetUtil.getTouchOrMouseClientY(event) - startY + origH;


w = Math.max(w, getMinWidth()); w = Math.max(w, getMinWidth());
h = Math.max(h, getMinHeight()); h = Math.max(h, getMinHeight());
} }


private void onDragEvent(Event event) { private void onDragEvent(Event event) {
if (!Util.isTouchEventOrLeftMouseButton(event)) {
if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) {
return; return;
} }


centered = false; centered = false;
if (cursorInsideBrowserContentArea(event)) { if (cursorInsideBrowserContentArea(event)) {
// Only drag while cursor is inside the browser client area // Only drag while cursor is inside the browser client area
final int x = Util.getTouchOrMouseClientX(event) - startX
final int x = WidgetUtil.getTouchOrMouseClientX(event) - startX
+ origX; + origX;
final int y = Util.getTouchOrMouseClientY(event) - startY
final int y = WidgetUtil.getTouchOrMouseClientY(event) - startY
+ origY; + origY;
setPopupPosition(x, y); setPopupPosition(x, y);
} }
if (draggable) { if (draggable) {
showDraggingCurtain(); showDraggingCurtain();
dragging = true; dragging = true;
startX = Util.getTouchOrMouseClientX(event);
startY = Util.getTouchOrMouseClientY(event);
startX = WidgetUtil.getTouchOrMouseClientX(event);
startY = WidgetUtil.getTouchOrMouseClientY(event);
origX = DOM.getAbsoluteLeft(getElement()); origX = DOM.getAbsoluteLeft(getElement());
origY = DOM.getAbsoluteTop(getElement()); origY = DOM.getAbsoluteTop(getElement());
DOM.setCapture(getElement()); DOM.setCapture(getElement());
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
Widget w = Util.findWidget(target, null);
Widget w = WidgetUtil.findWidget(target, null);
while (w != null) { while (w != null) {
if (w instanceof VDebugWindow) { if (w instanceof VDebugWindow) {
return true; // allow debug-window clicks return true; // allow debug-window clicks

+ 3
- 2
client/src/com/vaadin/client/ui/accordion/AccordionConnector.java View File



import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VAccordion; import com.vaadin.client.ui.VAccordion;
usedPixels += item.getCaptionHeight(); usedPixels += item.getCaptionHeight();
} else { } else {
// This includes the captionNode borders // This includes the captionNode borders
usedPixels += Util.getRequiredHeight(item.getElement());
usedPixels += WidgetUtil.getRequiredHeight(item
.getElement());
} }
} }
int rootElementInnerHeight = getLayoutManager().getInnerHeight( int rootElementInnerHeight = getLayoutManager().getInnerHeight(

+ 2
- 2
client/src/com/vaadin/client/ui/calendar/CalendarConnector.java View File

import com.vaadin.client.Paintable; import com.vaadin.client.Paintable;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
@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(element, null);
Widget w = WidgetUtil.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());

+ 3
- 3
client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java View File

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.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;


public class DateCell extends FocusableComplexPanel implements public class DateCell extends FocusableComplexPanel implements
MouseDownHandler, MouseMoveHandler, MouseUpHandler, KeyDownHandler, MouseDownHandler, MouseMoveHandler, MouseUpHandler, KeyDownHandler,
addStyleDependentName("Hsized"); addStyleDependentName("Hsized");


width = getOffsetWidth() width = getOffsetWidth()
- Util.measureHorizontalBorder(getElement());
- WidgetUtil.measureHorizontalBorder(getElement());
// Update moveWidth for any DateCellDayEvent child // Update moveWidth for any DateCellDayEvent child
updateEventCellsWidth(); updateEventCellsWidth();
recalculateEventWidths(); recalculateEventWidths();
} }


public int getSlotBorder() { public int getSlotBorder() {
return Util.measureVerticalBorder(slotElements[0]);
return WidgetUtil.measureVerticalBorder(slotElements[0]);
} }


private void drawDayEvents(List<DateCellGroup> groups) { private void drawDayEvents(List<DateCellGroup> groups) {

+ 2
- 2
client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java View File

import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.VCalendar; import com.vaadin.client.ui.VCalendar;


/** /**


public static int measureBorderWidth(DateCellContainer dc) { public static int measureBorderWidth(DateCellContainer dc) {
if (borderWidth == -1) { if (borderWidth == -1) {
borderWidth = Util.measureHorizontalBorder(dc.getElement());
borderWidth = WidgetUtil.measureHorizontalBorder(dc.getElement());
} }
return borderWidth; return borderWidth;
} }

+ 3
- 2
client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java View File

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.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.calendar.DateConstants; import com.vaadin.shared.ui.calendar.DateConstants;


/** /**
*/ */
private void updateCaptions(boolean bigMode) { private void updateCaptions(boolean bigMode) {
String innerHtml; String innerHtml;
String escapedCaption = Util.escapeHTML(calendarEvent.getCaption());
String escapedCaption = WidgetUtil.escapeHTML(calendarEvent
.getCaption());
String timeAsText = calendarEvent.getTimeAsText(); String timeAsText = calendarEvent.getTimeAsText();
if (bigMode) { if (bigMode) {
innerHtml = "<span>" + timeAsText + "</span><br />" innerHtml = "<span>" + timeAsText + "</span><br />"

+ 3
- 3
client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java View File

import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.DateTimeService; import com.vaadin.client.DateTimeService;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.VCalendar; import com.vaadin.client.ui.VCalendar;
import com.vaadin.shared.ui.calendar.DateConstants; import com.vaadin.shared.ui.calendar.DateConstants;


// Otherwise the scroll wrapper is somehow too narrow = horizontal // Otherwise the scroll wrapper is somehow too narrow = horizontal
// scroll // scroll
wrapper.setWidth(content.getOffsetWidth() wrapper.setWidth(content.getOffsetWidth()
+ Util.getNativeScrollbarSize() + "px");
+ WidgetUtil.getNativeScrollbarSize() + "px");


this.width = content.getOffsetWidth() - timebar.getOffsetWidth(); this.width = content.getOffsetWidth() - timebar.getOffsetWidth();


- timebar.getOffsetWidth(); - timebar.getOffsetWidth();


if (isVerticalScrollable() && width != -1) { if (isVerticalScrollable() && width != -1) {
this.width = this.width - Util.getNativeScrollbarSize();
this.width = this.width - WidgetUtil.getNativeScrollbarSize();
} }
updateCellWidths(); updateCellWidths();
} }

+ 2
- 2
client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java View File



import com.google.gwt.dom.client.Element; 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.WidgetUtil;
import com.vaadin.client.ui.calendar.CalendarConnector; import com.vaadin.client.ui.calendar.CalendarConnector;
import com.vaadin.client.ui.calendar.schedule.SimpleDayCell; import com.vaadin.client.ui.calendar.schedule.SimpleDayCell;
import com.vaadin.client.ui.dd.VAcceptCallback; import com.vaadin.client.ui.dd.VAcceptCallback;
protected void dragAccepted(VDragEvent drag) { protected void dragAccepted(VDragEvent drag) {
deEmphasis(); deEmphasis();
currentTargetElement = drag.getElementOver(); currentTargetElement = drag.getElementOver();
currentTargetDay = Util.findWidget(currentTargetElement,
currentTargetDay = WidgetUtil.findWidget(currentTargetElement,
SimpleDayCell.class); SimpleDayCell.class);
emphasis(); emphasis();
} }

+ 4
- 4
client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java View File



import com.google.gwt.dom.client.Element; 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.WidgetUtil;
import com.vaadin.client.ui.calendar.CalendarConnector; import com.vaadin.client.ui.calendar.CalendarConnector;
import com.vaadin.client.ui.calendar.schedule.DateCell; import com.vaadin.client.ui.calendar.schedule.DateCell;
import com.vaadin.client.ui.calendar.schedule.DateCellDayEvent; import com.vaadin.client.ui.calendar.schedule.DateCellDayEvent;
protected void dragAccepted(VDragEvent drag) { protected void dragAccepted(VDragEvent drag) {
deEmphasis(); deEmphasis();
currentTargetElement = drag.getElementOver(); currentTargetElement = drag.getElementOver();
currentTargetDay = Util
.findWidget(currentTargetElement, DateCell.class);
currentTargetDay = WidgetUtil.findWidget(currentTargetElement,
DateCell.class);
emphasis(); emphasis();
} }


return DOM.isOrHasChild(weekGridElement, elementOver) return DOM.isOrHasChild(weekGridElement, elementOver)
&& !DOM.isOrHasChild(timeBarElement, elementOver) && !DOM.isOrHasChild(timeBarElement, elementOver)
&& todayBarElement != elementOver && todayBarElement != elementOver
&& (Util.findWidget(elementOver, DateCellDayEvent.class) == null);
&& (WidgetUtil.findWidget(elementOver, DateCellDayEvent.class) == null);
} }


/* /*

+ 3
- 3
client/src/com/vaadin/client/ui/dd/DDUtil.java View File

import com.google.gwt.dom.client.Element; 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.WidgetUtil;
import com.vaadin.shared.ui.dd.HorizontalDropLocation; import com.vaadin.shared.ui.dd.HorizontalDropLocation;
import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.shared.ui.dd.VerticalDropLocation;




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


public static HorizontalDropLocation getHorizontalDropLocation( public static HorizontalDropLocation getHorizontalDropLocation(
Element element, NativeEvent event, double leftRightRatio) { Element element, NativeEvent event, double leftRightRatio) {
int clientX = Util.getTouchOrMouseClientX(event);
int clientX = WidgetUtil.getTouchOrMouseClientX(event);


// 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

+ 12
- 12
client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java View File

import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.Profiler; import com.vaadin.client.Profiler;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.ValueMap; import com.vaadin.client.ValueMap;
import com.vaadin.client.ui.VOverlay; import com.vaadin.client.ui.VOverlay;
targetElement = targetNode.getParentElement(); targetElement = targetNode.getParentElement();
} }


if (Util.isTouchEvent(nativeEvent) || dragElement != null) {
if (WidgetUtil.isTouchEvent(nativeEvent) || dragElement != null) {
// to detect the "real" target, hide dragelement temporary and // to detect the "real" target, hide dragelement temporary and
// use elementFromPoint // use elementFromPoint
String display = dragElement.getStyle().getDisplay(); String display = dragElement.getStyle().getDisplay();
dragElement.getStyle().setDisplay(Display.NONE); dragElement.getStyle().setDisplay(Display.NONE);
try { try {
int x = Util.getTouchOrMouseClientX(nativeEvent);
int y = Util.getTouchOrMouseClientY(nativeEvent);
int x = WidgetUtil.getTouchOrMouseClientX(nativeEvent);
int y = WidgetUtil.getTouchOrMouseClientY(nativeEvent);
// Util.browserDebugger(); // Util.browserDebugger();
targetElement = Util.getElementFromPoint(x, y);
targetElement = WidgetUtil.getElementFromPoint(x, y);
if (targetElement == null) { if (targetElement == null) {
// ApplicationConnection.getConsole().log( // ApplicationConnection.getConsole().log(
// "Event on dragImage, ignored"); // "Event on dragImage, ignored");
deferredStartRegistration = Event deferredStartRegistration = Event
.addNativePreviewHandler(new NativePreviewHandler() { .addNativePreviewHandler(new NativePreviewHandler() {


private int startX = Util
private int startX = WidgetUtil
.getTouchOrMouseClientX(currentDrag .getTouchOrMouseClientX(currentDrag
.getCurrentGwtEvent()); .getCurrentGwtEvent());
private int startY = Util
private int startY = WidgetUtil
.getTouchOrMouseClientY(currentDrag .getTouchOrMouseClientY(currentDrag
.getCurrentGwtEvent()); .getCurrentGwtEvent());


} }
case Event.ONMOUSEMOVE: case Event.ONMOUSEMOVE:
case Event.ONTOUCHMOVE: case Event.ONTOUCHMOVE:
int currentX = Util
int currentX = WidgetUtil
.getTouchOrMouseClientX(event .getTouchOrMouseClientX(event
.getNativeEvent()); .getNativeEvent());
int currentY = Util
int currentY = WidgetUtil
.getTouchOrMouseClientY(event .getTouchOrMouseClientY(event
.getNativeEvent()); .getNativeEvent());
if (Math.abs(startX - currentX) > 3 if (Math.abs(startX - currentX) > 3
private void updateDragImagePosition() { private void updateDragImagePosition() {
if (currentDrag.getCurrentGwtEvent() != null && dragElement != null) { if (currentDrag.getCurrentGwtEvent() != null && dragElement != null) {
Style style = dragElement.getStyle(); Style style = dragElement.getStyle();
int clientY = Util.getTouchOrMouseClientY(currentDrag
int clientY = WidgetUtil.getTouchOrMouseClientY(currentDrag
.getCurrentGwtEvent()); .getCurrentGwtEvent());
int clientX = Util.getTouchOrMouseClientX(currentDrag
int clientX = WidgetUtil.getTouchOrMouseClientX(currentDrag
.getCurrentGwtEvent()); .getCurrentGwtEvent());
style.setTop(clientY, Unit.PX); style.setTop(clientY, Unit.PX);
style.setLeft(clientX, Unit.PX); style.setLeft(clientX, Unit.PX);
*/ */
private VDropHandler findDragTarget(Element element) { private VDropHandler findDragTarget(Element element) {
try { try {
Widget w = Util.findWidget(element, null);
Widget w = WidgetUtil.findWidget(element, null);
if (w == null) { if (w == null) {
return null; return null;
} }

+ 3
- 3
client/src/com/vaadin/client/ui/dd/VDragEvent.java View File

import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.EventListener;
import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;


/** /**
* DragEvent used by Vaadin client side engine. Supports components, items, * DragEvent used by Vaadin client side engine. Supports components, items,
if (alignImageToEvent) { if (alignImageToEvent) {
int absoluteTop = element.getAbsoluteTop(); int absoluteTop = element.getAbsoluteTop();
int absoluteLeft = element.getAbsoluteLeft(); int absoluteLeft = element.getAbsoluteLeft();
int clientX = Util.getTouchOrMouseClientX(startEvent);
int clientY = Util.getTouchOrMouseClientY(startEvent);
int clientX = WidgetUtil.getTouchOrMouseClientX(startEvent);
int clientY = WidgetUtil.getTouchOrMouseClientY(startEvent);
int offsetX = absoluteLeft - clientX; int offsetX = absoluteLeft - clientX;
int offsetY = absoluteTop - clientY; int offsetY = absoluteTop - clientY;
setDragImage(cloneNode, offsetX, offsetY); setDragImage(cloneNode, offsetX, offsetY);

+ 5
- 3
client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.AbstractFieldConnector;
import com.vaadin.client.ui.AbstractLayoutConnector; import com.vaadin.client.ui.AbstractLayoutConnector;
TooltipInfo info = null; TooltipInfo info = null;


if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(element, VFormLayout.Caption.class);
Object node = WidgetUtil.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(element, VFormLayout.ErrorFlag.class);
node = WidgetUtil.findWidget(element,
VFormLayout.ErrorFlag.class);


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

+ 2
- 2
client/src/com/vaadin/client/ui/label/LabelConnector.java View File

import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.PreElement; import com.google.gwt.dom.client.PreElement;
import com.vaadin.client.Profiler; import com.vaadin.client.Profiler;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.VLabel; import com.vaadin.client.ui.VLabel;


if (sinkOnloads) { if (sinkOnloads) {
Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); Profiler.enter("LabelConnector.onStateChanged sinkOnloads");
Util.sinkOnloadForImages(getWidget().getElement());
WidgetUtil.sinkOnloadForImages(getWidget().getElement());
Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); Profiler.leave("LabelConnector.onStateChanged sinkOnloads");
} }
} }

+ 2
- 1
client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.ManagedLayout; import com.vaadin.client.ui.ManagedLayout;
import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractComponentState;


} }


private static String getCompactConnectorString(ServerConnector connector) { private static String getCompactConnectorString(ServerConnector connector) {
return Util.getSimpleName(connector) + " ("
return WidgetUtil.getSimpleName(connector) + " ("
+ connector.getConnectorId() + ")"; + connector.getConnectorId() + ")";
} }



+ 2
- 2
client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java View File

import com.vaadin.client.Paintable; import com.vaadin.client.Paintable;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.ImageIcon; import com.vaadin.client.ui.ImageIcon;
import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.SimpleManagedLayout;


if (moreItemUIDL.hasAttribute("icon")) { if (moreItemUIDL.hasAttribute("icon")) {
itemHTML.append("<img src=\"" itemHTML.append("<img src=\""
+ Util.escapeAttribute(client
+ WidgetUtil.escapeAttribute(client
.translateVaadinUri(moreItemUIDL .translateVaadinUri(moreItemUIDL
.getStringAttribute("icon"))) .getStringAttribute("icon")))
+ "\" class=\"" + ImageIcon.CLASSNAME + "\" class=\"" + ImageIcon.CLASSNAME

+ 2
- 1
client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.AbstractFieldConnector;
@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(element, Slot.class);
Slot slot = WidgetUtil.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)) {

+ 6
- 6
client/src/com/vaadin/client/ui/orderedlayout/Slot.java View File

import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.StyleConstants; import com.vaadin.client.StyleConstants;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.FontIcon; import com.vaadin.client.ui.FontIcon;
import com.vaadin.client.ui.Icon; import com.vaadin.client.ui.Icon;
import com.vaadin.client.ui.ImageIcon; import com.vaadin.client.ui.ImageIcon;
public void onElementResize(ElementResizeEvent e) { public void onElementResize(ElementResizeEvent e) {
Element caption = getCaptionElement(); Element caption = getCaptionElement();
if (caption != null) { if (caption != null) {
Util.forceIE8Redraw(caption);
WidgetUtil.forceIE8Redraw(caption);
} }
} }
}; };


// Caption wrappers // Caption wrappers
Widget widget = getWidget(); Widget widget = getWidget();
final Element focusedElement = Util.getFocusedElement();
final Element focusedElement = WidgetUtil.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.
Element currentFocus = Util.getFocusedElement();
Element currentFocus = WidgetUtil.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


@Override @Override
public void run() { public void run() {
if (Util.getFocusedElement() == null) {
if (WidgetUtil.getFocusedElement() == null) {
// This should never become an infinite loop and // This should never become an infinite loop and
// even if it does it will be stopped once something // even if it does it will be stopped once something
// is done with the browser. // is done with the browser.
schedule(25); schedule(25);
} else if (Util.getFocusedElement().equals(
} else if (WidgetUtil.getFocusedElement().equals(
Document.get().getBody())) { Document.get().getBody())) {
// Focus found it's way to BodyElement. Now it can // Focus found it's way to BodyElement. Now it can
// be restored // be restored

+ 2
- 1
client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java View File

import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.Profiler; import com.vaadin.client.Profiler;
import com.vaadin.client.Util; import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.MarginInfo;


/** /**
} }
} }
} }
Util.forceIE8Redraw(getElement());
WidgetUtil.forceIE8Redraw(getElement());
} }


/** /**

+ 3
- 3
client/src/com/vaadin/client/ui/table/TableConnector.java View File

import com.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.AbstractHasComponentsConnector; import com.vaadin.client.ui.AbstractHasComponentsConnector;
import com.vaadin.client.ui.PostLayoutListener; import com.vaadin.client.ui.PostLayoutListener;
import com.vaadin.client.ui.VScrollTable; import com.vaadin.client.ui.VScrollTable;
@Override @Override
public void execute() { public void execute() {
// IE8 needs some hacks to measure sizes correctly // IE8 needs some hacks to measure sizes correctly
Util.forceIE8Redraw(getWidget().getElement());
WidgetUtil.forceIE8Redraw(getWidget().getElement());


getLayoutManager().setNeedsMeasure(TableConnector.this); getLayoutManager().setNeedsMeasure(TableConnector.this);
ServerConnector parent = getParent(); ServerConnector parent = getParent();
TooltipInfo info = null; TooltipInfo info = null;


if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(element, VScrollTableRow.class);
Object node = WidgetUtil.findWidget(element, VScrollTableRow.class);


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

+ 3
- 2
client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java View File

import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VTabsheet; import com.vaadin.client.ui.VTabsheet;


// 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(element, VTabsheet.TabCaption.class);
Object node = WidgetUtil.findWidget(element,
VTabsheet.TabCaption.class);


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

+ 1
- 1
client/src/com/vaadin/client/ui/textarea/TextAreaConnector.java View File

import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.MouseUpEvent; import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.event.dom.client.MouseUpHandler;
import com.vaadin.client.Util.CssSize;
import com.vaadin.client.WidgetUtil.CssSize;
import com.vaadin.client.ui.VTextArea; import com.vaadin.client.ui.VTextArea;
import com.vaadin.client.ui.textfield.TextFieldConnector; import com.vaadin.client.ui.textfield.TextFieldConnector;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;

+ 3
- 3
client/src/com/vaadin/client/ui/tree/TreeConnector.java View File

import com.vaadin.client.Paintable; import com.vaadin.client.Paintable;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.VConsole; import com.vaadin.client.VConsole;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.AbstractComponentConnector;
} }


// IE8 needs a hack to measure the tree again after update // IE8 needs a hack to measure the tree again after update
Util.forceIE8Redraw(getWidget().getElement());
WidgetUtil.forceIE8Redraw(getWidget().getElement());


getWidget().rendering = false; getWidget().rendering = false;




// 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(element, TreeNode.class);
Object node = WidgetUtil.findWidget(element, TreeNode.class);


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

+ 2
- 2
client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java View File

import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.TooltipInfo; import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.FocusableScrollPanel; import com.vaadin.client.ui.FocusableScrollPanel;
import com.vaadin.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow; import com.vaadin.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow;
import com.vaadin.client.ui.VTreeTable; import com.vaadin.client.ui.VTreeTable;
TooltipInfo info = null; TooltipInfo info = null;


if (element != getWidget().getElement()) { if (element != getWidget().getElement()) {
Object node = Util.findWidget(element, VTreeTableRow.class);
Object node = WidgetUtil.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/window/WindowConnector.java View File

import com.vaadin.client.LayoutManager; import com.vaadin.client.LayoutManager;
import com.vaadin.client.Paintable; import com.vaadin.client.Paintable;
import com.vaadin.client.UIDL; import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; import com.vaadin.client.ui.AbstractSingleComponentContainerConnector;
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(layoutElement);
WidgetUtil.forceIE8Redraw(layoutElement);


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

+ 2
- 2
client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java View File

import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Timer;
import com.vaadin.client.DeferredWorker; import com.vaadin.client.DeferredWorker;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.widget.grid.events.ScrollEvent; import com.vaadin.client.widget.grid.events.ScrollEvent;
import com.vaadin.client.widget.grid.events.ScrollHandler; import com.vaadin.client.widget.grid.events.ScrollHandler;


double oldScrollPos = scrollPos; double oldScrollPos = scrollPos;
scrollPos = Math.max(0, Math.min(maxScrollPos, truncate(px))); scrollPos = Math.max(0, Math.min(maxScrollPos, truncate(px)));


if (!Util.pixelValuesEqual(oldScrollPos, scrollPos)) {
if (!WidgetUtil.pixelValuesEqual(oldScrollPos, scrollPos)) {
if (isInvisibleScrollbar) { if (isInvisibleScrollbar) {
invisibleScrollbarTemporaryResizer.show(); invisibleScrollbarTemporaryResizer.show();
} }

+ 4
- 4
client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java View File

import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Event.NativePreviewEvent; import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.Event.NativePreviewHandler; import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.renderers.ComplexRenderer; import com.vaadin.client.renderers.ComplexRenderer;
import com.vaadin.client.widget.grid.CellReference; import com.vaadin.client.widget.grid.CellReference;
import com.vaadin.client.widget.grid.RendererCellReference; import com.vaadin.client.widget.grid.RendererCellReference;


int constrainedPageY = Math.max(bodyAbsoluteTop, int constrainedPageY = Math.max(bodyAbsoluteTop,
Math.min(bodyAbsoluteBottom, pageY)); Math.min(bodyAbsoluteBottom, pageY));
int logicalRow = getLogicalRowIndex(Util.getElementFromPoint(
int logicalRow = getLogicalRowIndex(WidgetUtil.getElementFromPoint(
initialPageX, constrainedPageY)); initialPageX, constrainedPageY));


int incrementOrDecrement = (logicalRow > lastModifiedLogicalRow) ? 1 int incrementOrDecrement = (logicalRow > lastModifiedLogicalRow) ? 1
switch (event.getTypeInt()) { switch (event.getTypeInt()) {
case Event.ONMOUSEMOVE: case Event.ONMOUSEMOVE:
case Event.ONTOUCHMOVE: case Event.ONTOUCHMOVE:
pageY = Util.getTouchOrMouseClientY(nativeEvent);
pageX = Util.getTouchOrMouseClientX(nativeEvent);
pageY = WidgetUtil.getTouchOrMouseClientY(nativeEvent);
pageX = WidgetUtil.getTouchOrMouseClientX(nativeEvent);
autoScroller.updatePointerCoords(pageX, pageY); autoScroller.updatePointerCoords(pageX, pageY);
break; break;
case Event.ONMOUSEUP: case Event.ONMOUSEUP:

+ 22
- 20
client/src/com/vaadin/client/widgets/Escalator.java View File

import com.vaadin.client.BrowserInfo; import com.vaadin.client.BrowserInfo;
import com.vaadin.client.DeferredWorker; import com.vaadin.client.DeferredWorker;
import com.vaadin.client.Profiler; import com.vaadin.client.Profiler;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.widget.escalator.Cell; import com.vaadin.client.widget.escalator.Cell;
import com.vaadin.client.widget.escalator.ColumnConfiguration; import com.vaadin.client.widget.escalator.ColumnConfiguration;
import com.vaadin.client.widget.escalator.EscalatorUpdater; import com.vaadin.client.widget.escalator.EscalatorUpdater;


final double viewportStartPx = getScrollLeft(); final double viewportStartPx = getScrollLeft();
double viewportEndPx = viewportStartPx double viewportEndPx = viewportStartPx
+ Util.getRequiredWidthBoundingClientRectDouble(getElement())
+ WidgetUtil
.getRequiredWidthBoundingClientRectDouble(getElement())
- frozenPixels; - frozenPixels;
if (verticalScrollbar.showsScrollHandle()) { if (verticalScrollbar.showsScrollHandle()) {
viewportEndPx -= Util.getNativeScrollbarSize();
viewportEndPx -= WidgetUtil.getNativeScrollbarSize();
} }


final double scrollLeft = getScrollPos(destination, targetStartPx, final double scrollLeft = getScrollPos(destination, targetStartPx,
final boolean isVisible = !cell.getStyle().getDisplay() final boolean isVisible = !cell.getStyle().getDisplay()
.equals(Display.NONE.getCssName()); .equals(Display.NONE.getCssName());
if (isVisible) { if (isVisible) {
maxWidth = Math
.max(maxWidth,
Util.getRequiredWidthBoundingClientRectDouble(cell));
maxWidth = Math.max(maxWidth, WidgetUtil
.getRequiredWidthBoundingClientRectDouble(cell));
} }
row = TableRowElement.as(row.getNextSiblingElement()); row = TableRowElement.as(row.getNextSiblingElement());
} }
cellClone.getStyle().clearWidth(); cellClone.getStyle().clearWidth();


rowElement.insertBefore(cellClone, cellOriginal); rowElement.insertBefore(cellClone, cellOriginal);
double requiredWidth = Util
double requiredWidth = WidgetUtil
.getRequiredWidthBoundingClientRectDouble(cellClone); .getRequiredWidthBoundingClientRectDouble(cellClone);


if (BrowserInfo.get().isIE9()) { if (BrowserInfo.get().isIE9()) {
private TableRowElement getEscalatorRowWithFocus() { private TableRowElement getEscalatorRowWithFocus() {
TableRowElement rowContainingFocus = null; TableRowElement rowContainingFocus = null;


final Element focusedElement = Util.getFocusedElement();
final Element focusedElement = WidgetUtil.getFocusedElement();


if (focusedElement != null && root.isOrHasChild(focusedElement)) { if (focusedElement != null && root.isOrHasChild(focusedElement)) {
Element e = focusedElement; Element e = focusedElement;


root.appendChild(verticalScrollbar.getElement()); root.appendChild(verticalScrollbar.getElement());
verticalScrollbar.addScrollHandler(scrollHandler); verticalScrollbar.addScrollHandler(scrollHandler);
verticalScrollbar.setScrollbarThickness(Util.getNativeScrollbarSize());
verticalScrollbar.setScrollbarThickness(WidgetUtil
.getNativeScrollbarSize());


root.appendChild(horizontalScrollbar.getElement()); root.appendChild(horizontalScrollbar.getElement());
horizontalScrollbar.addScrollHandler(scrollHandler); horizontalScrollbar.addScrollHandler(scrollHandler);
horizontalScrollbar
.setScrollbarThickness(Util.getNativeScrollbarSize());
horizontalScrollbar.setScrollbarThickness(WidgetUtil
.getNativeScrollbarSize());
horizontalScrollbar horizontalScrollbar
.addVisibilityHandler(new ScrollbarBundle.VisibilityHandler() { .addVisibilityHandler(new ScrollbarBundle.VisibilityHandler() {
@Override @Override
table.appendChild(footElem); table.appendChild(footElem);


Style hCornerStyle = headerDeco.getStyle(); Style hCornerStyle = headerDeco.getStyle();
hCornerStyle.setWidth(Util.getNativeScrollbarSize(), Unit.PX);
hCornerStyle.setWidth(WidgetUtil.getNativeScrollbarSize(), Unit.PX);
hCornerStyle.setDisplay(Display.NONE); hCornerStyle.setDisplay(Display.NONE);
root.appendChild(headerDeco); root.appendChild(headerDeco);


Style fCornerStyle = footerDeco.getStyle(); Style fCornerStyle = footerDeco.getStyle();
fCornerStyle.setWidth(Util.getNativeScrollbarSize(), Unit.PX);
fCornerStyle.setWidth(WidgetUtil.getNativeScrollbarSize(), Unit.PX);
fCornerStyle.setDisplay(Display.NONE); fCornerStyle.setDisplay(Display.NONE);
root.appendChild(footerDeco); root.appendChild(footerDeco);


Style hWrapperStyle = horizontalScrollbarDeco.getStyle(); Style hWrapperStyle = horizontalScrollbarDeco.getStyle();
hWrapperStyle.setDisplay(Display.NONE); hWrapperStyle.setDisplay(Display.NONE);
hWrapperStyle.setHeight(Util.getNativeScrollbarSize(), Unit.PX);
hWrapperStyle.setHeight(WidgetUtil.getNativeScrollbarSize(), Unit.PX);
root.appendChild(horizontalScrollbarDeco); root.appendChild(horizontalScrollbarDeco);


setStylePrimaryName("v-escalator"); setStylePrimaryName("v-escalator");
} }


Profiler.enter("Escalator.recalculateElementSizes"); Profiler.enter("Escalator.recalculateElementSizes");
widthOfEscalator = Math.max(0,
Util.getRequiredWidthBoundingClientRectDouble(getElement()));
heightOfEscalator = Math.max(0,
Util.getRequiredHeightBoundingClientRectDouble(getElement()));
widthOfEscalator = Math.max(0, WidgetUtil
.getRequiredWidthBoundingClientRectDouble(getElement()));
heightOfEscalator = Math.max(0, WidgetUtil
.getRequiredHeightBoundingClientRectDouble(getElement()));


header.recalculateSectionHeight(); header.recalculateSectionHeight();
body.recalculateSectionHeight(); body.recalculateSectionHeight();
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
com.google.gwt.user.client.Element castElement = (com.google.gwt.user.client.Element) possibleWidgetNode com.google.gwt.user.client.Element castElement = (com.google.gwt.user.client.Element) possibleWidgetNode
.cast(); .cast();
Widget w = Util.findWidget(castElement, null);
Widget w = WidgetUtil.findWidget(castElement, null);


// Ensure findWidget did not traverse past the cell element in the // Ensure findWidget did not traverse past the cell element in the
// DOM hierarchy // DOM hierarchy
* @return escalator's inner width * @return escalator's inner width
*/ */
public double getInnerWidth() { public double getInnerWidth() {
return Util.getRequiredWidthBoundingClientRectDouble(tableWrapper);
return WidgetUtil
.getRequiredWidthBoundingClientRectDouble(tableWrapper);
} }
} }

+ 11
- 7
client/src/com/vaadin/client/widgets/Grid.java View File

import com.google.gwt.user.client.ui.ResizeComposite; import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.DeferredWorker; import com.vaadin.client.DeferredWorker;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.data.DataChangeHandler; import com.vaadin.client.data.DataChangeHandler;
import com.vaadin.client.data.DataSource; import com.vaadin.client.data.DataSource;
import com.vaadin.client.renderers.ComplexRenderer; import com.vaadin.client.renderers.ComplexRenderer;
int bodyTop = body.getElement().getAbsoluteTop(); int bodyTop = body.getElement().getAbsoluteTop();
int wrapperTop = tableWrapper.getAbsoluteTop(); int wrapperTop = tableWrapper.getAbsoluteTop();


double width = Util.getRequiredWidthBoundingClientRectDouble(tr);
double height = Util.getRequiredHeightBoundingClientRectDouble(tr);
double width = WidgetUtil
.getRequiredWidthBoundingClientRectDouble(tr);
double height = WidgetUtil
.getRequiredHeightBoundingClientRectDouble(tr);
setBounds(editorOverlay, tr.getOffsetLeft(), rowTop + bodyTop setBounds(editorOverlay, tr.getOffsetLeft(), rowTop + bodyTop
- wrapperTop, width, height); - wrapperTop, width, height);


*/ */
protected Element createCell(TableCellElement td) { protected Element createCell(TableCellElement td) {
DivElement cell = DivElement.as(DOM.createDiv()); DivElement cell = DivElement.as(DOM.createDiv());
double width = Util.getRequiredWidthBoundingClientRectDouble(td);
double height = Util.getRequiredHeightBoundingClientRectDouble(td);
double width = WidgetUtil
.getRequiredWidthBoundingClientRectDouble(td);
double height = WidgetUtil
.getRequiredHeightBoundingClientRectDouble(td);
setBounds(cell, td.getOffsetLeft(), td.getOffsetTop(), width, setBounds(cell, td.getOffsetLeft(), td.getOffsetTop(), width,
height); height);
return cell; return cell;
Renderer renderer = findRenderer(cell); Renderer renderer = findRenderer(cell);
if (renderer instanceof WidgetRenderer) { if (renderer instanceof WidgetRenderer) {
try { try {
Widget w = Util.findWidget(cell.getElement()
Widget w = WidgetUtil.findWidget(cell.getElement()
.getFirstChildElement(), Widget.class); .getFirstChildElement(), Widget.class);
if (w != null) { if (w != null) {


} }


private boolean isElementInChildWidget(Element e) { private boolean isElementInChildWidget(Element e) {
Widget w = Util.findWidget(e, null);
Widget w = WidgetUtil.findWidget(e, null);


if (w == this) { if (w == this) {
return false; return false;

+ 3
- 3
uitest/src/com/vaadin/tests/widgetset/client/BasicExtensionTestConnector.java View File

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.vaadin.client.ServerConnector; import com.vaadin.client.ServerConnector;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;
import com.vaadin.tests.extensions.BasicExtension; import com.vaadin.tests.extensions.BasicExtension;
} }


private void appendMessage(String action) { private void appendMessage(String action) {
String message = Util.getSimpleName(this) + action
+ Util.getSimpleName(target);
String message = WidgetUtil.getSimpleName(this) + action
+ WidgetUtil.getSimpleName(target);


DivElement element = Document.get().createDivElement(); DivElement element = Document.get().createDivElement();
element.setInnerText(message); element.setInnerText(message);

+ 2
- 2
uitest/src/com/vaadin/tests/widgetset/client/CustomUIConnector.java View File



import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.SpanElement; import com.google.gwt.dom.client.SpanElement;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.client.ui.ui.UIConnector;
import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect;
import com.vaadin.ui.UI; import com.vaadin.ui.UI;
public void test() { public void test() {
SpanElement span = Document.get().createSpanElement(); SpanElement span = Document.get().createSpanElement();
span.setInnerText("This is the " span.setInnerText("This is the "
+ Util.getSimpleName(CustomUIConnector.this));
+ WidgetUtil.getSimpleName(CustomUIConnector.this));
Document.get().getBody().insertFirst(span); Document.get().getBody().insertFirst(span);
} }
}); });

Loading…
Cancel
Save