Skip to content

Commit

Permalink
Separate pure client side util methods to a new class (#15553, #15544)
Browse files Browse the repository at this point in the history
* Deprecated old methods in Util for backwards compatibility

Change-Id: I9de5e6b930d9f2c0268967dc7b1cf465e6310280
  • Loading branch information
Artur- authored and Legioth committed Jan 9, 2015
1 parent 79a9182 commit bf8836b
Show file tree
Hide file tree
Showing 86 changed files with 2,106 additions and 1,444 deletions.
4 changes: 2 additions & 2 deletions client/src/com/vaadin/client/ApplicationConfiguration.java
Expand Up @@ -411,14 +411,14 @@ private void loadFromDOM() {
* desired locations even if the base URL of the page changes later
* (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)
if (!useServiceUrlPathParam() && !serviceUrl.endsWith("/")) {
serviceUrl += '/';
}

vaadinDirUrl = Util.getAbsoluteUrl(jsoConfiguration
vaadinDirUrl = WidgetUtil.getAbsoluteUrl(jsoConfiguration
.getConfigString(ApplicationConstants.VAADIN_DIR_URL));
uiId = jsoConfiguration.getConfigInteger(UIConstants.UI_ID_PARAMETER)
.intValue();
Expand Down
16 changes: 9 additions & 7 deletions client/src/com/vaadin/client/ApplicationConnection.java
Expand Up @@ -62,6 +62,7 @@
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConfiguration.ErrorMessage;
import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener;
import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
Expand Down Expand Up @@ -1865,7 +1866,7 @@ private void doDelegateToWidget(ComponentConnector component,
} catch (NoDataException e) {
throw new RuntimeException(
"Missing data needed to invoke @DelegateToWidget for "
+ Util.getSimpleName(component), e);
+ WidgetUtil.getSimpleName(component), e);
}
}

Expand Down Expand Up @@ -2046,7 +2047,8 @@ private void updateVaadin6StyleConnectors(ValueMap json) {
String key = null;
if (Profiler.isEnabled()) {
key = "updateFromUIDL for "
+ Util.getSimpleName(legacyConnector);
+ WidgetUtil
.getSimpleName(legacyConnector);
Profiler.enter(key);
}

Expand Down Expand Up @@ -2146,12 +2148,12 @@ private JsArrayObject<StateChangeEvent> updateConnectorState(
Profiler.enter("updateConnectorState inner loop");
if (Profiler.isEnabled()) {
Profiler.enter("Decode connector state "
+ Util.getSimpleName(connector));
+ WidgetUtil.getSimpleName(connector));
}

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

if (connector instanceof HasJavaScriptConnectorHelper) {
((HasJavaScriptConnectorHelper) connector)
Expand Down Expand Up @@ -2183,7 +2185,7 @@ private JsArrayObject<StateChangeEvent> updateConnectorState(

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

Profiler.enter("updateConnectorState create event");
Expand Down Expand Up @@ -2523,7 +2525,7 @@ private void handleRpcInvocations(ValueMap json) {

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

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

int rpcLength = rpcCalls.length();
Expand Down Expand Up @@ -3648,7 +3650,7 @@ public void flushActiveConnector() {
* @return Connector for focused element or null.
*/
private ComponentConnector getActiveConnector() {
Element focusedElement = Util.getFocusedElement();
Element focusedElement = WidgetUtil.getFocusedElement();
if (focusedElement == null) {
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions client/src/com/vaadin/client/BrowserInfo.java
Expand Up @@ -343,7 +343,7 @@ public boolean isTouchDevice() {
public boolean requiresOverflowAutoFix() {
return (getWebkitVersion() > 0 || getOperaVersion() >= 11
|| getIEVersion() >= 10 || isFirefox())
&& Util.getNativeScrollbarSize() > 0;
&& WidgetUtil.getNativeScrollbarSize() > 0;
}

/**
Expand All @@ -359,7 +359,8 @@ public boolean requiresOverflowAutoFix() {
* otherwise <code>false</code>
*/
public boolean requiresPositionAbsoluteOverflowAutoFix() {
return (getWebkitVersion() > 0) && Util.getNativeScrollbarSize() > 0;
return (getWebkitVersion() > 0)
&& WidgetUtil.getNativeScrollbarSize() > 0;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions client/src/com/vaadin/client/JavaScriptConnectorHelper.java
Expand Up @@ -319,7 +319,7 @@ private void fireRpc(String iface, String method,
iface = findWildcardInterface(method);
}

JsonArray argumentsArray = Util.jso2json(arguments);
JsonArray argumentsArray = WidgetUtil.jso2json(arguments);
Object[] parameters = new Object[arguments.length()];
for (int i = 0; i < parameters.length; i++) {
parameters[i] = argumentsArray.get(i);
Expand Down Expand Up @@ -383,7 +383,7 @@ private static native void updateNativeState(JavaScriptObject state,
}-*/;

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

public void setTag(int tag) {
Expand All @@ -397,10 +397,11 @@ public void invokeJsRpc(MethodInvocation invocation,
if ("com.vaadin.ui.JavaScript$JavaScriptCallbackRpc".equals(iface)
&& "call".equals(method)) {
String callbackName = parametersJson.getString(0);
JavaScriptObject arguments = Util.json2jso(parametersJson.get(1));
JavaScriptObject arguments = WidgetUtil.json2jso(parametersJson
.get(1));
invokeCallback(getConnectorWrapper(), callbackName, arguments);
} else {
JavaScriptObject arguments = Util.json2jso(parametersJson);
JavaScriptObject arguments = WidgetUtil.json2jso(parametersJson);
invokeJsRpc(rpcMap, iface, method, arguments);
// Also invoke wildcard interface
invokeJsRpc(rpcMap, "", method, arguments);
Expand Down
15 changes: 9 additions & 6 deletions client/src/com/vaadin/client/LayoutManager.java
Expand Up @@ -346,7 +346,8 @@ private void doLayout() {
if (Profiler.isEnabled()) {
Profiler.enter("ElementResizeListener.onElementResize construct profiler key");
key = "ElementResizeListener.onElementResize for "
+ Util.getSimpleName(listener);
+ WidgetUtil
.getSimpleName(listener);
Profiler.leave("ElementResizeListener.onElementResize construct profiler key");
Profiler.enter(key);
}
Expand Down Expand Up @@ -389,7 +390,7 @@ private void doLayout() {
String key = null;
if (Profiler.isEnabled()) {
key = "layoutHorizontally() for "
+ Util.getSimpleName(cl);
+ WidgetUtil.getSimpleName(cl);
Profiler.enter(key);
}

Expand All @@ -411,7 +412,8 @@ private void doLayout() {
try {
String key = null;
if (Profiler.isEnabled()) {
key = "layout() for " + Util.getSimpleName(rr);
key = "layout() for "
+ WidgetUtil.getSimpleName(rr);
Profiler.enter(key);
}

Expand Down Expand Up @@ -444,7 +446,7 @@ private void doLayout() {
String key = null;
if (Profiler.isEnabled()) {
key = "layoutVertically() for "
+ Util.getSimpleName(cl);
+ WidgetUtil.getSimpleName(cl);
Profiler.enter(key);
}

Expand All @@ -466,7 +468,8 @@ private void doLayout() {
try {
String key = null;
if (Profiler.isEnabled()) {
key = "layout() for " + Util.getSimpleName(rr);
key = "layout() for "
+ WidgetUtil.getSimpleName(rr);
Profiler.enter(key);
}

Expand Down Expand Up @@ -545,7 +548,7 @@ private void doLayout() {
String key = null;
if (Profiler.isEnabled()) {
key = "layout PostLayoutListener for "
+ Util.getSimpleName(connector);
+ WidgetUtil.getSimpleName(connector);
Profiler.enter(key);
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/com/vaadin/client/LayoutManagerIE8.java
Expand Up @@ -94,7 +94,7 @@ protected void performBrowserLayoutHacks() {
* the containing element. To force a reflow by modifying the magical
* zoom property.
*/
Util.forceIE8Redraw(RootPanel.get().getElement());
WidgetUtil.forceIE8Redraw(RootPanel.get().getElement());
Profiler.leave("LayoutManagerIE8.performBrowserLayoutHacks");
}
}
4 changes: 2 additions & 2 deletions client/src/com/vaadin/client/MeasuredSize.java
Expand Up @@ -236,7 +236,7 @@ public MeasureResult measure(Element element) {
Profiler.leave("Measure borders");

Profiler.enter("Measure height");
int requiredHeight = Util.getRequiredHeight(element);
int requiredHeight = WidgetUtil.getRequiredHeight(element);
int marginHeight = sumHeights(margins);
int oldHeight = height;
int oldWidth = width;
Expand All @@ -247,7 +247,7 @@ public MeasureResult measure(Element element) {
Profiler.leave("Measure height");

Profiler.enter("Measure width");
int requiredWidth = Util.getRequiredWidth(element);
int requiredWidth = WidgetUtil.getRequiredWidth(element);
int marginWidth = sumWidths(margins);
if (setOuterWidth(requiredWidth + marginWidth)) {
debugSizeChange(element, "Width (outer)", oldWidth, width);
Expand Down
4 changes: 2 additions & 2 deletions client/src/com/vaadin/client/MouseEventDetailsBuilder.java
Expand Up @@ -57,8 +57,8 @@ public static MouseEventDetails buildMouseEventDetails(NativeEvent evt,
Element relativeToElement) {
MouseEventDetails mouseEventDetails = new MouseEventDetails();
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) {
mouseEventDetails.setButton(MouseButton.LEFT);
} else if (evt.getButton() == NativeEvent.BUTTON_RIGHT) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/com/vaadin/client/RenderSpace.java
Expand Up @@ -34,7 +34,7 @@ public RenderSpace() {
public RenderSpace(int width, int height, boolean useNativeScrollbarSize) {
super(width, height);
if (useNativeScrollbarSize) {
scrollBarSize = Util.getNativeScrollbarSize();
scrollBarSize = WidgetUtil.getNativeScrollbarSize();
}
}

Expand Down
6 changes: 3 additions & 3 deletions client/src/com/vaadin/client/ResourceLoader.java
Expand Up @@ -225,7 +225,7 @@ public void loadScript(final String scriptUrl,
*/
public void loadScript(final String scriptUrl,
final ResourceLoadListener resourceLoadListener, boolean async) {
final String url = Util.getAbsoluteUrl(scriptUrl);
final String url = WidgetUtil.getAbsoluteUrl(scriptUrl);
ResourceLoadEvent event = new ResourceLoadEvent(this, url, false);
if (loadedResources.contains(url)) {
if (resourceLoadListener != null) {
Expand Down Expand Up @@ -307,7 +307,7 @@ public static boolean supportsInOrderScriptExecution() {
*/
public void preloadResource(String url,
ResourceLoadListener resourceLoadListener) {
url = Util.getAbsoluteUrl(url);
url = WidgetUtil.getAbsoluteUrl(url);
ResourceLoadEvent event = new ResourceLoadEvent(this, url, true);
if (loadedResources.contains(url) || preloadedResources.contains(url)) {
// Already loaded or preloaded -> just fire listener
Expand Down Expand Up @@ -424,7 +424,7 @@ public static native void addOnloadHandler(Element element,
*/
public void loadStylesheet(final String stylesheetUrl,
final ResourceLoadListener resourceLoadListener) {
final String url = Util.getAbsoluteUrl(stylesheetUrl);
final String url = WidgetUtil.getAbsoluteUrl(stylesheetUrl);
final ResourceLoadEvent event = new ResourceLoadEvent(this, url, false);
if (loadedResources.contains(url)) {
if (resourceLoadListener != null) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/com/vaadin/client/SuperDevMode.java
Expand Up @@ -89,7 +89,7 @@ public void onFailure(Throwable caught) {
VConsole.error("JSONP compile call failed");
// Don't log exception as they are shown as
// notifications
VConsole.error(Util.getSimpleName(caught) + ": "
VConsole.error(WidgetUtil.getSimpleName(caught) + ": "
+ caught.getMessage());
failed();

Expand Down

0 comments on commit bf8836b

Please sign in to comment.