diff options
author | Artur Signell <artur@vaadin.com> | 2015-01-12 11:56:40 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-01-12 11:56:40 +0200 |
commit | e7df5a24a5870949ab36683d04ac028c47c1857c (patch) | |
tree | 1589e3036874607cd7711cfbdca2b6b287df4c4c | |
parent | fac1da3160ba4f7479abaa0e671fe697cd7f129c (diff) | |
parent | 2286f9871f7f77dea6139d0cd1dfc6754b1946d5 (diff) | |
download | vaadin-framework-e7df5a24a5870949ab36683d04ac028c47c1857c.tar.gz vaadin-framework-e7df5a24a5870949ab36683d04ac028c47c1857c.zip |
Merge remote-tracking branch 'origin/grid' into 7.4
427 files changed, 4145 insertions, 2663 deletions
diff --git a/.classpath b/.classpath index 847fe8f769..517b236661 100644 --- a/.classpath +++ b/.classpath @@ -10,6 +10,7 @@ <classpathentry kind="src" path="uitest/src"/> <classpathentry kind="src" path="buildhelpers/src"/> <classpathentry kind="src" path="shared/src"/> + <classpathentry kind="src" path="widgets/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <attributes> <attribute name="owner.project.facets" value="java"/> @@ -25,5 +26,6 @@ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&ivyXmlPath=buildhelpers%2Fivy.xml&confs=ide&ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=build.properties"/> <classpathentry exported="true" kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&ivyXmlPath=gwt%2Fivy.xml&confs=ide&ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=%24%7Bworkspace_loc%3Avaadin%2Fbuild.properties%7D"/> + <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=vaadin&ivyXmlPath=widgets%2Fivy.xml&confs=ide&ivySettingsPath=%24%7Bworkspace_loc%3Avaadin%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=build.properties"/> <classpathentry kind="output" path="build/classes"/> </classpath> diff --git a/.gitignore b/.gitignore index 11a0b3db84..1433651abc 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,9 @@ /WebContent/VAADIN/themes/valo/styles.css /WebContent/VAADIN/themes/tests-valo*/styles.css +# Persisted scss cache files +/WebContent/VAADIN/themes/*/styles.scss.cache + # /WebContent/VAADIN/widgetsets/ /WebContent/VAADIN/widgetsets /WebContent/VAADIN/gwt-unitCache* diff --git a/WebContent/VAADIN/themes/base/grid/grid.scss b/WebContent/VAADIN/themes/base/grid/grid.scss index 310e37d0fb..f1889286b7 100644 --- a/WebContent/VAADIN/themes/base/grid/grid.scss +++ b/WebContent/VAADIN/themes/base/grid/grid.scss @@ -191,7 +191,19 @@ $v-grid-editor-background-color: $v-grid-row-background-color !default; left: 0; border: $v-grid-cell-focused-border; display: none; + pointer-events: none; } + + // IE 8-10 apply "pointer-events" only to SVG elements. + // Using an empty SVG instead of an empty text node makes IE + // obey the "pointer-events: none" and forwards click events + // to the underlying element. The data decodes to: + // <svg xmlns="http://www.w3.org/2000/svg"></svg> + .ie8 &:before, + .ie9 &:before, + .ie10 &:before { + content: url(data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==); + } } .#{$primaryStyleName}:focus .#{$primaryStyleName}-cell-focused:before { diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index ced077138f..53b213e110 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -18,13 +18,19 @@ log = console.log; } - var loadTheme = function(url) { + var loadTheme = function(url, version) { if(!themesLoaded[url]) { - log("loadTheme", url); + log("loadTheme", url, version); + + var href = url + '/styles.css'; + if (version) { + href += '?v=' + version; + } + var stylesheet = document.createElement('link'); stylesheet.setAttribute('rel', 'stylesheet'); stylesheet.setAttribute('type', 'text/css'); - stylesheet.setAttribute('href', url + "/styles.css"); + stylesheet.setAttribute('href', href); document.getElementsByTagName('head')[0].appendChild(stylesheet); themesLoaded[url] = true; } @@ -200,8 +206,10 @@ var bootstrapApp = function(mayDefer) { var vaadinDir = getConfig('vaadinDir'); + var versionInfo = getConfig('versionInfo'); + var themeUri = vaadinDir + 'themes/' + getConfig('theme'); - loadTheme(themeUri); + loadTheme(themeUri, versionInfo && versionInfo['vaadinVersion']); var widgetset = getConfig('widgetset'); var widgetsetUrl = getConfig('widgetsetUrl'); diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html index 7be74ee1ed..8e6385684f 100644 --- a/WebContent/release-notes.html +++ b/WebContent/release-notes.html @@ -114,7 +114,8 @@ <li>@Viewport annotation for declaratively defining a mobile viewport definition for a UI.</li> <li>Component captions, TabSheet/Accordion tab captions and Calendar event captions can be configured to be displayed as HTML.</li> <li>Selects use converters when presenting itemids.</li> - <li>Improved performance when server response contains no visual changing (e.g. empty polling responses).</li> + <li>Improved performance when server response contains no visual changes (e.g. empty polling responses).</li> + <li>Development time on-the-fly scss compilation cache may now be preserved when redeploying or restarting the server.</li> <li>Unified JSON library for using the same API in both server-side and client-side code.</li> <li>Range validators and converters for additional numerical types.</li> <li>Support for fine grained add/remove item events in in-memory containers.</li> diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java index 13bd7051f6..f946d87638 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -47,6 +47,7 @@ import com.google.gwt.user.rebind.SourceWriter; import com.vaadin.client.JsArrayObject; import com.vaadin.client.ServerConnector; import com.vaadin.client.annotations.OnStateChange; +import com.vaadin.client.communication.JsonDecoder; import com.vaadin.client.metadata.ConnectorBundleLoader; import com.vaadin.client.metadata.ConnectorBundleLoader.CValUiInfo; import com.vaadin.client.metadata.InvokationHandler; @@ -1011,7 +1012,16 @@ public class ConnectorBundleLoaderFactory extends Generator { w.print(", "); } String parameterTypeName = getBoxedTypeName(parameterType); - w.print("(" + parameterTypeName + ") params[" + i + "]"); + + if (parameterTypeName.startsWith("elemental.json.Json")) { + // Need to pass through native method to allow casting Object to + // JSO if the value is a string + w.print("%s.<%s>obj2jso(params[%d])", + JsonDecoder.class.getCanonicalName(), + parameterTypeName, i); + } else { + w.print("(" + parameterTypeName + ") params[" + i + "]"); + } } w.println(");"); diff --git a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml index 8512d547e3..3047924ac7 100755 --- a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml +++ b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml @@ -8,8 +8,23 @@ <inherits name="com.vaadin.Vaadin" /> + <!-- Elemental is used for handling Json only --> + <inherits name="elemental.Json" /> + <entry-point class="com.vaadin.client.ApplicationConfiguration" /> + <generate-with + class="com.vaadin.server.widgetsetutils.AcceptCriteriaFactoryGenerator"> + <when-type-is class="com.vaadin.client.ui.dd.VAcceptCriterionFactory" /> + </generate-with> + + <generate-with + class="com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory"> + <when-type-assignable + class="com.vaadin.client.metadata.ConnectorBundleLoader" /> + </generate-with> + + <!-- Since 7.2. Compile all permutations (browser support) into one Javascript file. Speeds up compilation and does not make the Javascript significantly larger. --> diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index 7387d0f997..1bbece6bd6 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -10,8 +10,6 @@ <inherits name="com.google.gwt.http.HTTP" /> - <inherits name="elemental.Json"/> - <inherits name="com.google.gwt.logging.Logging" /> <set-property name="gwt.logging.enabled" value="TRUE" /> @@ -26,17 +24,6 @@ <when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" /> </replace-with> - <generate-with - class="com.vaadin.server.widgetsetutils.AcceptCriteriaFactoryGenerator"> - <when-type-is class="com.vaadin.client.ui.dd.VAcceptCriterionFactory" /> - </generate-with> - - <generate-with - class="com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory"> - <when-type-assignable - class="com.vaadin.client.metadata.ConnectorBundleLoader" /> - </generate-with> - <replace-with class="com.vaadin.client.communication.AtmospherePushConnection"> <when-type-is class="com.vaadin.client.communication.PushConnection" /> @@ -92,4 +79,9 @@ <when-type-is class="com.vaadin.client.event.PointerEventSupportImpl" /> <when-property-is value="ie10" name="user.agent" /> </replace-with> + + <!-- Make Sass linking available --> + <define-linker name="sass" + class="com.vaadin.sass.linker.SassLinker" /> + </module> diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index 0ef37df130..d3be69443e 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -411,14 +411,14 @@ public class ApplicationConfiguration implements EntryPoint { * 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(); diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 3b8b7ddc40..aa00516feb 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -62,6 +62,7 @@ import com.google.gwt.user.client.Window.ClosingHandler; 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; @@ -111,14 +112,14 @@ import elemental.json.JsonValue; * This is the client side communication "engine", managing client-server * communication with its server side counterpart * com.vaadin.server.VaadinService. - * + * * Client-side connectors receive updates from the corresponding server-side * connector (typically component) as state updates or RPC calls. The connector * has the possibility to communicate back with its server side counter part * through RPC calls. - * + * * TODO document better - * + * * Entry point classes (widgetsets) define <code>onModuleLoad()</code>. */ public class ApplicationConnection implements HasHandlers { @@ -143,26 +144,31 @@ public class ApplicationConnection implements HasHandlers { private FastStringSet detachedConnectorIds = FastStringSet.create(); } - public static final String MODIFIED_CLASSNAME = "v-modified"; + @Deprecated + public static final String MODIFIED_CLASSNAME = StyleConstants.MODIFIED; - public static final String DISABLED_CLASSNAME = "v-disabled"; + @Deprecated + public static final String DISABLED_CLASSNAME = StyleConstants.DISABLED; - public static final String REQUIRED_CLASSNAME = "v-required"; + @Deprecated + public static final String REQUIRED_CLASSNAME = StyleConstants.REQUIRED; - public static final String REQUIRED_CLASSNAME_EXT = "-required"; + @Deprecated + public static final String REQUIRED_CLASSNAME_EXT = StyleConstants.REQUIRED_EXT; - public static final String ERROR_CLASSNAME_EXT = "-error"; + @Deprecated + public static final String ERROR_CLASSNAME_EXT = StyleConstants.ERROR_EXT; /** * A string that, if found in a non-JSON response to a UIDL request, will * cause the browser to refresh the page. If followed by a colon, optional * whitespace, and a URI, causes the browser to synchronously load the URI. - * + * * <p> * This allows, for instance, a servlet filter to redirect the application * to a custom login page when the session expires. For example: * </p> - * + * * <pre> * if (sessionExpired) { * response.setHeader("Content-Type", "text/html"); @@ -345,7 +351,7 @@ public class ApplicationConnection implements HasHandlers { /** * Event triggered when a XHR request has finished with the status code of * the response. - * + * * Useful for handlers observing network failures like online/off-line * monitors. */ @@ -401,12 +407,12 @@ public class ApplicationConnection implements HasHandlers { /** * Event triggered when a application is stopped by calling * {@link ApplicationConnection#setApplicationRunning(false)}. - * + * * To listen for the event add a {@link ApplicationStoppedHandler} by * invoking * {@link ApplicationConnection#addHandler(ApplicationConnection.ApplicationStoppedEvent.Type, ApplicationStoppedHandler)} * to the {@link ApplicationConnection} - * + * * @since 7.1.8 * @author Vaadin Ltd */ @@ -433,7 +439,7 @@ public class ApplicationConnection implements HasHandlers { /** * Called when a communication error has occurred. Returning * <code>true</code> from this method suppresses error handling. - * + * * @param details * A string describing the error. * @param statusCode @@ -448,7 +454,7 @@ public class ApplicationConnection implements HasHandlers { * A listener for listening to application stopped events. The listener can * be added to a {@link ApplicationConnection} by invoking * {@link ApplicationConnection#addHandler(ApplicationStoppedEvent.Type, ApplicationStoppedHandler)} - * + * * @since 7.1.8 * @author Vaadin Ltd */ @@ -458,7 +464,7 @@ public class ApplicationConnection implements HasHandlers { * Triggered when the {@link ApplicationConnection} marks a previously * running application as stopped by invoking * {@link ApplicationConnection#setApplicationRunning(false)} - * + * * @param event * the event triggered by the {@link ApplicationConnection} */ @@ -561,7 +567,7 @@ public class ApplicationConnection implements HasHandlers { * called once this application has started (first response received) or * failed to start. This ensures that the applications are started in order, * to avoid session-id problems. - * + * */ public void start() { String jsonText = configuration.getUIDL(); @@ -638,7 +644,7 @@ public class ApplicationConnection implements HasHandlers { return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/dom/client/Element;)(id, element); }); client.getPathForElement = $entry(function(element) { - return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getLegacyPathForElement(Lcom/google/gwt/dom/client/Element;)(element); + return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getPathForElement(Lcom/google/gwt/dom/client/Element;)(element); }); client.initializing = false; @@ -671,7 +677,7 @@ public class ApplicationConnection implements HasHandlers { * <li><code>vaadin.postRequestHooks</code> is a map of functions which gets * called after each XHR made by vaadin application. Note, that it is * attaching js functions responsibility to create the variable like this: - * + * * <code><pre> * if(!vaadin.postRequestHooks) {vaadin.postRequestHooks = new Object();} * postRequestHooks.myHook = function(appId) { @@ -682,7 +688,7 @@ public class ApplicationConnection implements HasHandlers { * </pre></code> First parameter passed to these functions is the identifier * of Vaadin application that made the request. * </ul> - * + * * TODO make this multi-app aware */ private native void initializeClientHooks() @@ -713,7 +719,7 @@ public class ApplicationConnection implements HasHandlers { /** * Runs possibly registered client side post request hooks. This is expected * to be run after each uidl request made by Vaadin application. - * + * * @param appId */ private static native void runPostRequestHooks(String appId) @@ -733,7 +739,7 @@ public class ApplicationConnection implements HasHandlers { /** * If on Liferay and logged in, ask the client side session management * JavaScript to extend the session duration. - * + * * Otherwise, Liferay client side JavaScript will explicitly expire the * session even though the server side considers the session to be active. * See ticket #8305 for more information. @@ -752,7 +758,7 @@ public class ApplicationConnection implements HasHandlers { /** * Indicates whether or not there are currently active UIDL requests. Used * internally to sequence requests properly, seldom needed in Widgets. - * + * * @return true if there are active requests */ public boolean hasActiveRequest() { @@ -772,7 +778,7 @@ public class ApplicationConnection implements HasHandlers { /** * Requests an analyze of layouts, to find inconsistencies. Exclusively used * for debugging during development. - * + * * @deprecated as of 7.1. Replaced by {@link UIConnector#analyzeLayouts()} */ @Deprecated @@ -784,7 +790,7 @@ public class ApplicationConnection implements HasHandlers { * Sends a request to the server to print details to console that will help * the developer to locate the corresponding server-side connector in the * source code. - * + * * @param serverConnector * @deprecated as of 7.1. Replaced by * {@link UIConnector#showServerDebugInfo(ServerConnector)} @@ -796,7 +802,7 @@ public class ApplicationConnection implements HasHandlers { /** * Makes an UIDL request to the server. - * + * * @param reqInvocations * Data containing RPC invocations and all related information. * @param extraParams @@ -834,7 +840,7 @@ public class ApplicationConnection implements HasHandlers { /** * Sends an asynchronous or synchronous UIDL request to the server using the * given URI. - * + * * @param uri * The URI to use for the request. May includes GET parameters * @param payload @@ -1003,7 +1009,7 @@ public class ApplicationConnection implements HasHandlers { /** * Handles received UIDL JSON text, parsing it, and passing it on to the * appropriate handlers, while logging timing information. - * + * * @param jsonText * @param statusCode */ @@ -1031,7 +1037,7 @@ public class ApplicationConnection implements HasHandlers { /** * Sends an asynchronous UIDL request to the server using the given URI. - * + * * @param uri * The URI to use for the request. May includes GET parameters * @param payload @@ -1166,7 +1172,7 @@ public class ApplicationConnection implements HasHandlers { /** * Checks whether or not the CSS is loaded. By default checks the size of * the loading indicator element. - * + * * @return */ protected boolean isCSSLoaded() { @@ -1176,12 +1182,12 @@ public class ApplicationConnection implements HasHandlers { /** * Shows the communication error notification. - * + * * @param details * Optional details for debugging. * @param statusCode * The status code returned for the request - * + * */ protected void showCommunicationError(String details, int statusCode) { VConsole.error("Communication error: " + details); @@ -1190,7 +1196,7 @@ public class ApplicationConnection implements HasHandlers { /** * Shows the authentication error notification. - * + * * @param details * Optional details for debugging. */ @@ -1201,7 +1207,7 @@ public class ApplicationConnection implements HasHandlers { /** * Shows the session expiration notification. - * + * * @param details * Optional details for debugging. */ @@ -1212,7 +1218,7 @@ public class ApplicationConnection implements HasHandlers { /** * Shows an error notification. - * + * * @param details * Optional details for debugging. * @param message @@ -1225,7 +1231,7 @@ public class ApplicationConnection implements HasHandlers { /** * Shows the error notification. - * + * * @param details * Optional details for debugging. */ @@ -1312,7 +1318,7 @@ public class ApplicationConnection implements HasHandlers { /** * This method is called after applying uidl change set to application. - * + * * It will clean current and queued variable change sets. And send next * change set if it exists. */ @@ -1331,7 +1337,7 @@ public class ApplicationConnection implements HasHandlers { /** * Cleans given queue of variable changes of such changes that came from * components that do not exist anymore. - * + * * @param variableBurst */ private void cleanVariableBurst( @@ -1380,7 +1386,7 @@ public class ApplicationConnection implements HasHandlers { * <p> * Used by the native "client.isActive" function. * </p> - * + * * @return true if deferred commands are (potentially) being executed, false * otherwise */ @@ -1395,7 +1401,7 @@ public class ApplicationConnection implements HasHandlers { /** * Returns the loading indicator used by this ApplicationConnection - * + * * @return The loading indicator for this ApplicationConnection */ public VLoadingIndicator getLoadingIndicator() { @@ -1404,7 +1410,7 @@ public class ApplicationConnection implements HasHandlers { /** * Determines whether or not the loading indicator is showing. - * + * * @return true if the loading indicator is visible * @deprecated As of 7.1. Use {@link #getLoadingIndicator()} and * {@link VLoadingIndicator#isVisible()}.isVisible() instead. @@ -1438,7 +1444,7 @@ public class ApplicationConnection implements HasHandlers { * server is received. * <p> * The initial id when no request has yet been processed is -1. - * + * * @return and id identifying the response */ public int getLastResponseId() { @@ -1865,20 +1871,20 @@ public class ApplicationConnection implements HasHandlers { } catch (NoDataException e) { throw new RuntimeException( "Missing data needed to invoke @DelegateToWidget for " - + Util.getSimpleName(component), e); + + component.getClass().getSimpleName(), e); } } /** * Sends the state change events created while updating the state * information. - * + * * This must be called after hierarchy change listeners have been * called. At least caption updates for the parent are strange if * fired from state change listeners and thus calls the parent * BEFORE the parent is aware of the child (through a * ConnectorHierarchyChangedEvent) - * + * * @param pendingStateChangeEvents * The events to send */ @@ -2046,7 +2052,8 @@ public class ApplicationConnection implements HasHandlers { String key = null; if (Profiler.isEnabled()) { key = "updateFromUIDL for " - + Util.getSimpleName(legacyConnector); + + legacyConnector.getClass() + .getSimpleName(); Profiler.enter(key); } @@ -2146,7 +2153,7 @@ public class ApplicationConnection implements HasHandlers { Profiler.enter("updateConnectorState inner loop"); if (Profiler.isEnabled()) { Profiler.enter("Decode connector state " - + Util.getSimpleName(connector)); + + connector.getClass().getSimpleName()); } JavaScriptObject jso = states @@ -2183,7 +2190,7 @@ public class ApplicationConnection implements HasHandlers { if (Profiler.isEnabled()) { Profiler.leave("Decode connector state " - + Util.getSimpleName(connector)); + + connector.getClass().getSimpleName()); } Profiler.enter("updateConnectorState create event"); @@ -2233,7 +2240,7 @@ public class ApplicationConnection implements HasHandlers { * Updates the connector hierarchy and returns a list of events that * should be fired after update of the hierarchy and the state is * done. - * + * * @param json * The JSON containing the hierarchy information * @return A collection of events that should be fired when update @@ -2645,9 +2652,9 @@ public class ApplicationConnection implements HasHandlers { /** * Adds an explicit RPC method invocation to the send queue. - * + * * @since 7.0 - * + * * @param invocation * RPC method invocation * @param delayed @@ -2687,7 +2694,7 @@ public class ApplicationConnection implements HasHandlers { /** * Removes any pending invocation of the given method from the queue - * + * * @param invocation * The invocation to remove */ @@ -2705,12 +2712,12 @@ public class ApplicationConnection implements HasHandlers { /** * This method sends currently queued variable changes to server. It is * called when immediate variable update must happen. - * + * * To ensure correct order for variable changes (due servers multithreading * or network), we always wait for active request to be handler before * sending a new one. If there is an active request, we will put varible * "burst" to queue that will be purged after current request is handled. - * + * */ public void sendPendingVariableChanges() { if (!deferedSendPending) { @@ -2751,11 +2758,11 @@ public class ApplicationConnection implements HasHandlers { /** * Build the variable burst and send it to server. - * + * * When sync is forced, we also force sending of all pending variable-bursts * at the same time. This is ok as we can assume that DOM will never be * updated after this. - * + * * @param pendingInvocations * List of RPC method invocations to send */ @@ -2840,7 +2847,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -2862,7 +2869,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -2885,7 +2892,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -2908,7 +2915,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -2931,7 +2938,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -2954,7 +2961,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -2977,7 +2984,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -3000,7 +3007,7 @@ public class ApplicationConnection implements HasHandlers { * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. * </p> - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -3017,13 +3024,13 @@ public class ApplicationConnection implements HasHandlers { /** * Sends a new value for the given paintables given variable to the server. - * + * * The update is actually queued to be sent at a suitable time. If immediate * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. - * + * * A null array is sent as an empty array. - * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -3040,14 +3047,14 @@ public class ApplicationConnection implements HasHandlers { /** * Sends a new value for the given paintables given variable to the server. - * + * * The update is actually queued to be sent at a suitable time. If immediate * is true, the update is sent as soon as possible. If immediate is false, * the update will be sent along with the next immediate update. </p> - * + * * A null array is sent as an empty array. - * - * + * + * * @param paintableId * the id of the paintable that owns the variable * @param variableName @@ -3064,7 +3071,7 @@ public class ApplicationConnection implements HasHandlers { /** * Does absolutely nothing. Replaced by {@link LayoutManager}. - * + * * @param container * @deprecated As of 7.0, serves no purpose */ @@ -3086,7 +3093,7 @@ public class ApplicationConnection implements HasHandlers { /** * Returns false - * + * * @param paintable * @return false, always * @deprecated As of 7.0, serves no purpose @@ -3098,7 +3105,7 @@ public class ApplicationConnection implements HasHandlers { /** * Returns false - * + * * @param paintable * @return false, always * @deprecated As of 7.0, serves no purpose @@ -3119,16 +3126,16 @@ public class ApplicationConnection implements HasHandlers { /** * Get either an existing ComponentConnector or create a new * ComponentConnector with the given type and id. - * + * * If a ComponentConnector with the given id already exists, returns it. * Otherwise creates and registers a new ComponentConnector of the given * type. - * + * * @param connectorId * Id of the paintable * @param connectorType * Type of the connector, as passed from the server side - * + * * @return Either an existing ComponentConnector or a new ComponentConnector * of the given type */ @@ -3141,15 +3148,15 @@ public class ApplicationConnection implements HasHandlers { /** * Creates a new ServerConnector with the given type and id. - * + * * Creates and registers a new ServerConnector of the given type. Should * never be called with the connector id of an existing connector. - * + * * @param connectorId * Id of the new connector * @param connectorType * Type of the connector, as passed from the server side - * + * * @return A new ServerConnector of the given type */ private ServerConnector createAndRegisterConnector(String connectorId, @@ -3169,7 +3176,7 @@ public class ApplicationConnection implements HasHandlers { /** * Gets a recource that has been pre-loaded via UIDL, such as custom * layouts. - * + * * @param name * identifier of the resource to get * @return the resource @@ -3180,7 +3187,7 @@ public class ApplicationConnection implements HasHandlers { /** * Singleton method to get instance of app's context menu. - * + * * @return VContextMenu object */ public VContextMenu getContextMenu() { @@ -3195,7 +3202,7 @@ public class ApplicationConnection implements HasHandlers { /** * Gets an {@link Icon} instance corresponding to a URI. - * + * * @since 7.2 * @param uri * @return Icon object @@ -3217,7 +3224,7 @@ public class ApplicationConnection implements HasHandlers { * Translates custom protocols in UIDL URI's to be recognizable by browser. * All uri's from UIDL should be routed via this method before giving them * to browser due URI's in UIDL may contain custom protocols like theme://. - * + * * @param uidlUri * Vaadin URI from uidl * @return translated URI ready for browser @@ -3289,7 +3296,7 @@ public class ApplicationConnection implements HasHandlers { /** * Gets the URI for the current theme. Can be used to reference theme * resources. - * + * * @return URI to the current theme */ public String getThemeUri() { @@ -3300,7 +3307,7 @@ public class ApplicationConnection implements HasHandlers { /** * Listens for Notification hide event, and redirects. Used for system * messages, such as session expired. - * + * */ private class NotificationRedirect implements VNotification.EventListener { String url; @@ -3329,7 +3336,7 @@ public class ApplicationConnection implements HasHandlers { /** * Gets the token (aka double submit cookie) that the server uses to protect * against Cross Site Request Forgery attacks. - * + * * @return the CSRF token string */ public String getCsrfToken() { @@ -3339,7 +3346,7 @@ public class ApplicationConnection implements HasHandlers { /** * Use to notify that the given component's caption has changed; layouts may * have to be recalculated. - * + * * @param component * the Paintable whose caption has changed * @deprecated As of 7.0.2, has not had any effect for a long time @@ -3351,7 +3358,7 @@ public class ApplicationConnection implements HasHandlers { /** * Gets the main view - * + * * @return the main view */ public UIConnector getUIConnector() { @@ -3360,7 +3367,7 @@ public class ApplicationConnection implements HasHandlers { /** * Gets the {@link ApplicationConfiguration} for the current application. - * + * * @see ApplicationConfiguration * @return the configuration for this application */ @@ -3373,7 +3380,7 @@ public class ApplicationConnection implements HasHandlers { * list of events which has server side listeners is updated automatically * before the component is updated so the value is correct if called from * updatedFromUIDL. - * + * * @param paintable * The connector to register event listeners for * @param eventIdentifier @@ -3393,7 +3400,7 @@ public class ApplicationConnection implements HasHandlers { /** * Adds the get parameters to the uri and returns the new uri that contains * the parameters. - * + * * @param uri * The uri to which the parameters should be added. * @param extraParams @@ -3446,7 +3453,7 @@ public class ApplicationConnection implements HasHandlers { /** * Get VTooltip instance related to application connection - * + * * @return VTooltip instance */ public VTooltip getVTooltip() { @@ -3458,7 +3465,7 @@ public class ApplicationConnection implements HasHandlers { * this method is now handled by the state change event handler in * AbstractComponentConnector. The only function this method has is to * return true if the UIDL is a "cached" update. - * + * * @param component * @param uidl * @param manageCaption @@ -3509,7 +3516,7 @@ public class ApplicationConnection implements HasHandlers { * Schedules a heartbeat request to occur after the configured heartbeat * interval elapses if the interval is a positive number. Otherwise, does * nothing. - * + * * @deprecated as of 7.2, use {@link Heartbeat#schedule()} instead */ @Deprecated @@ -3523,7 +3530,7 @@ public class ApplicationConnection implements HasHandlers { * Heartbeat requests are used to inform the server that the client-side is * still alive. If the client page is closed or the connection lost, the * server will eventually close the inactive UI. - * + * * @deprecated as of 7.2, use {@link Heartbeat#send()} instead */ @Deprecated @@ -3547,7 +3554,7 @@ public class ApplicationConnection implements HasHandlers { /** * This method can be used to postpone rendering of a response for a short * period of time (e.g. to avoid the rendering process during animation). - * + * * @param lock */ public void suspendReponseHandling(Object lock) { @@ -3556,7 +3563,7 @@ public class ApplicationConnection implements HasHandlers { /** * Resumes the rendering process once all locks have been removed. - * + * * @param lock */ public void resumeResponseHandling(Object lock) { @@ -3601,7 +3608,7 @@ public class ApplicationConnection implements HasHandlers { /** * Sets the delegate that is called whenever a communication error occurrs. - * + * * @param delegate * the delegate. */ @@ -3644,11 +3651,11 @@ public class ApplicationConnection implements HasHandlers { /** * Gets the active connector for focused element in browser. - * + * * @return Connector for focused element or null. */ private ComponentConnector getActiveConnector() { - Element focusedElement = Util.getFocusedElement(); + Element focusedElement = WidgetUtil.getFocusedElement(); if (focusedElement == null) { return null; } @@ -3658,7 +3665,7 @@ public class ApplicationConnection implements HasHandlers { /** * Sets the status for the push connection. - * + * * @param enabled * <code>true</code> to enable the push connection; * <code>false</code> to disable the push connection. @@ -3708,7 +3715,7 @@ public class ApplicationConnection implements HasHandlers { /** * Returns a human readable string representation of the method used to * communicate with the server. - * + * * @since 7.1 * @return A string representation of the current transport type */ diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index e8b8d8309a..5ca79cb121 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -343,7 +343,7 @@ public class BrowserInfo { public boolean requiresOverflowAutoFix() { return (getWebkitVersion() > 0 || getOperaVersion() >= 11 || getIEVersion() >= 10 || isFirefox()) - && Util.getNativeScrollbarSize() > 0; + && WidgetUtil.getNativeScrollbarSize() > 0; } /** @@ -359,7 +359,8 @@ public class BrowserInfo { * otherwise <code>false</code> */ public boolean requiresPositionAbsoluteOverflowAutoFix() { - return (getWebkitVersion() > 0) && Util.getNativeScrollbarSize() > 0; + return (getWebkitVersion() > 0) + && WidgetUtil.getNativeScrollbarSize() > 0; } /** diff --git a/client/src/com/vaadin/client/LayoutManager.java b/client/src/com/vaadin/client/LayoutManager.java index 2f39eaedd4..893a57298f 100644 --- a/client/src/com/vaadin/client/LayoutManager.java +++ b/client/src/com/vaadin/client/LayoutManager.java @@ -346,7 +346,8 @@ public class LayoutManager { if (Profiler.isEnabled()) { Profiler.enter("ElementResizeListener.onElementResize construct profiler key"); key = "ElementResizeListener.onElementResize for " - + Util.getSimpleName(listener); + + listener.getClass() + .getSimpleName(); Profiler.leave("ElementResizeListener.onElementResize construct profiler key"); Profiler.enter(key); } @@ -389,7 +390,7 @@ public class LayoutManager { String key = null; if (Profiler.isEnabled()) { key = "layoutHorizontally() for " - + Util.getSimpleName(cl); + + cl.getClass().getSimpleName(); Profiler.enter(key); } @@ -411,7 +412,8 @@ public class LayoutManager { try { String key = null; if (Profiler.isEnabled()) { - key = "layout() for " + Util.getSimpleName(rr); + key = "layout() for " + + rr.getClass().getSimpleName(); Profiler.enter(key); } @@ -444,7 +446,7 @@ public class LayoutManager { String key = null; if (Profiler.isEnabled()) { key = "layoutVertically() for " - + Util.getSimpleName(cl); + + cl.getClass().getSimpleName(); Profiler.enter(key); } @@ -466,7 +468,8 @@ public class LayoutManager { try { String key = null; if (Profiler.isEnabled()) { - key = "layout() for " + Util.getSimpleName(rr); + key = "layout() for " + + rr.getClass().getSimpleName(); Profiler.enter(key); } @@ -545,7 +548,7 @@ public class LayoutManager { String key = null; if (Profiler.isEnabled()) { key = "layout PostLayoutListener for " - + Util.getSimpleName(connector); + + connector.getClass().getSimpleName(); Profiler.enter(key); } diff --git a/client/src/com/vaadin/client/LayoutManagerIE8.java b/client/src/com/vaadin/client/LayoutManagerIE8.java index 941ac589b2..9fb6819e83 100644 --- a/client/src/com/vaadin/client/LayoutManagerIE8.java +++ b/client/src/com/vaadin/client/LayoutManagerIE8.java @@ -94,7 +94,7 @@ public class LayoutManagerIE8 extends LayoutManager { * 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"); } } diff --git a/client/src/com/vaadin/client/MeasuredSize.java b/client/src/com/vaadin/client/MeasuredSize.java index 2531ff9389..8520635a4d 100644 --- a/client/src/com/vaadin/client/MeasuredSize.java +++ b/client/src/com/vaadin/client/MeasuredSize.java @@ -236,7 +236,7 @@ public class MeasuredSize { 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; @@ -247,7 +247,7 @@ public class MeasuredSize { 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); diff --git a/client/src/com/vaadin/client/MouseEventDetailsBuilder.java b/client/src/com/vaadin/client/MouseEventDetailsBuilder.java index 313fe682fd..11ebe3925c 100644 --- a/client/src/com/vaadin/client/MouseEventDetailsBuilder.java +++ b/client/src/com/vaadin/client/MouseEventDetailsBuilder.java @@ -57,8 +57,8 @@ public class MouseEventDetailsBuilder { 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) { diff --git a/client/src/com/vaadin/client/Profiler.java b/client/src/com/vaadin/client/Profiler.java index 6c0967099f..4b35427575 100644 --- a/client/src/com/vaadin/client/Profiler.java +++ b/client/src/com/vaadin/client/Profiler.java @@ -17,11 +17,13 @@ package com.vaadin.client; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -29,8 +31,6 @@ import com.google.gwt.core.client.Duration; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.shared.GWT; -import com.vaadin.client.debug.internal.ProfilerSection.Node; -import com.vaadin.client.debug.internal.ProfilerSection.ProfilerResultConsumer; /** * Lightweight profiling tool that can be used to collect profiling data with @@ -55,6 +55,236 @@ public class Profiler { } } + /** + * Interface for getting data from the {@link Profiler}. + * <p> + * <b>Warning!</b> This interface is most likely to change in the future + * + * @since 7.1 + * @author Vaadin Ltd + */ + public interface ProfilerResultConsumer { + public void addProfilerData(Node rootNode, List<Node> totals); + + public void addBootstrapData(LinkedHashMap<String, Double> timings); + } + + /** + * A hierarchical representation of the time spent running a named block of + * code. + * <p> + * <b>Warning!</b> This class is most likely to change in the future and is + * therefore defined in this class in an internal package instead of + * Profiler where it might seem more logical. + */ + public static class Node { + private final String name; + private final LinkedHashMap<String, Node> children = new LinkedHashMap<String, Node>(); + private double time = 0; + private int count = 0; + private double enterTime = 0; + private double minTime = 1000000000; + private double maxTime = 0; + + /** + * Create a new node with the given name. + * + * @param name + */ + public Node(String name) { + this.name = name; + } + + /** + * Gets the name of the node + * + * @return the name of the node + */ + public String getName() { + return name; + } + + /** + * Creates a new child node or retrieves and existing child and updates + * its total time and hit count. + * + * @param name + * the name of the child + * @param timestamp + * the timestamp for when the node is entered + * @return the child node object + */ + public Node enterChild(String name, double timestamp) { + Node child = children.get(name); + if (child == null) { + child = new Node(name); + children.put(name, child); + } + child.enterTime = timestamp; + child.count++; + return child; + } + + /** + * Gets the total time spent in this node, including time spent in sub + * nodes + * + * @return the total time spent, in milliseconds + */ + public double getTimeSpent() { + return time; + } + + /** + * Gets the minimum time spent for one invocation of this node, + * including time spent in sub nodes + * + * @return the time spent for the fastest invocation, in milliseconds + */ + public double getMinTimeSpent() { + return minTime; + } + + /** + * Gets the maximum time spent for one invocation of this node, + * including time spent in sub nodes + * + * @return the time spent for the slowest invocation, in milliseconds + */ + public double getMaxTimeSpent() { + return maxTime; + } + + /** + * Gets the number of times this node has been entered + * + * @return the number of times the node has been entered + */ + public int getCount() { + return count; + } + + /** + * Gets the total time spent in this node, excluding time spent in sub + * nodes + * + * @return the total time spent, in milliseconds + */ + public double getOwnTime() { + double time = getTimeSpent(); + for (Node node : children.values()) { + time -= node.getTimeSpent(); + } + return time; + } + + /** + * Gets the child nodes of this node + * + * @return a collection of child nodes + */ + public Collection<Node> getChildren() { + return Collections.unmodifiableCollection(children.values()); + } + + private void buildRecursiveString(StringBuilder builder, String prefix) { + if (getName() != null) { + String msg = getStringRepresentation(prefix); + builder.append(msg + '\n'); + } + String childPrefix = prefix + "*"; + for (Node node : children.values()) { + node.buildRecursiveString(builder, childPrefix); + } + } + + @Override + public String toString() { + return getStringRepresentation(""); + } + + public String getStringRepresentation(String prefix) { + if (getName() == null) { + return ""; + } + String msg = prefix + " " + getName() + " in " + getTimeSpent() + + " ms."; + if (getCount() > 1) { + msg += " Invoked " + + getCount() + + " times (" + + roundToSignificantFigures(getTimeSpent() / getCount()) + + " ms per time, min " + + roundToSignificantFigures(getMinTimeSpent()) + + " ms, max " + + roundToSignificantFigures(getMaxTimeSpent()) + + " ms)."; + } + if (!children.isEmpty()) { + double ownTime = getOwnTime(); + msg += " " + ownTime + " ms spent in own code"; + if (getCount() > 1) { + msg += " (" + + roundToSignificantFigures(ownTime / getCount()) + + " ms per time)"; + } + msg += '.'; + } + return msg; + } + + private static double roundToSignificantFigures(double num) { + // Number of significant digits + int n = 3; + if (num == 0) { + return 0; + } + + final double d = Math.ceil(Math.log10(num < 0 ? -num : num)); + final int power = n - (int) d; + + final double magnitude = Math.pow(10, power); + final long shifted = Math.round(num * magnitude); + return shifted / magnitude; + } + + public void sumUpTotals(Map<String, Node> totals) { + String name = getName(); + if (name != null) { + Node totalNode = totals.get(name); + if (totalNode == null) { + totalNode = new Node(name); + totals.put(name, totalNode); + } + + totalNode.time += getOwnTime(); + totalNode.count += getCount(); + totalNode.minTime = Math.min(totalNode.minTime, + getMinTimeSpent()); + totalNode.maxTime = Math.max(totalNode.maxTime, + getMaxTimeSpent()); + } + for (Node node : children.values()) { + node.sumUpTotals(totals); + } + } + + /** + * @param timestamp + */ + public void leave(double timestamp) { + double elapsed = (timestamp - enterTime); + time += elapsed; + enterTime = 0; + if (elapsed < minTime) { + minTime = elapsed; + } + if (elapsed > maxTime) { + maxTime = elapsed; + } + } + } + private static final String evtGroup = "VaadinProfiler"; private static final class GwtStatsEvent extends JavaScriptObject { diff --git a/client/src/com/vaadin/client/RenderSpace.java b/client/src/com/vaadin/client/RenderSpace.java index 5a7440b682..dff774aa6f 100644 --- a/client/src/com/vaadin/client/RenderSpace.java +++ b/client/src/com/vaadin/client/RenderSpace.java @@ -34,7 +34,7 @@ public class RenderSpace extends Size { public RenderSpace(int width, int height, boolean useNativeScrollbarSize) { super(width, height); if (useNativeScrollbarSize) { - scrollBarSize = Util.getNativeScrollbarSize(); + scrollBarSize = WidgetUtil.getNativeScrollbarSize(); } } diff --git a/client/src/com/vaadin/client/ResourceLoader.java b/client/src/com/vaadin/client/ResourceLoader.java index ceede263fc..9e9ce5ac49 100644 --- a/client/src/com/vaadin/client/ResourceLoader.java +++ b/client/src/com/vaadin/client/ResourceLoader.java @@ -225,7 +225,7 @@ public class ResourceLoader { */ 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) { @@ -307,7 +307,7 @@ public class ResourceLoader { */ 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 @@ -424,7 +424,7 @@ public class ResourceLoader { */ 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) { diff --git a/client/src/com/vaadin/client/StyleConstants.java b/client/src/com/vaadin/client/StyleConstants.java index c4588587d4..fad88f1359 100644 --- a/client/src/com/vaadin/client/StyleConstants.java +++ b/client/src/com/vaadin/client/StyleConstants.java @@ -35,4 +35,13 @@ public class StyleConstants { * Added to all layouts to denote they are layouts */ public static final String UI_LAYOUT = "v-layout"; + + public static final String MODIFIED = "v-modified"; + public static final String DISABLED = "v-disabled"; + + public static final String REQUIRED = "v-required"; + + public static final String REQUIRED_EXT = "-required"; + + public static final String ERROR_EXT = "-error"; } diff --git a/client/src/com/vaadin/client/SuperDevMode.java b/client/src/com/vaadin/client/SuperDevMode.java index f1020b3d25..821af6075a 100644 --- a/client/src/com/vaadin/client/SuperDevMode.java +++ b/client/src/com/vaadin/client/SuperDevMode.java @@ -89,7 +89,7 @@ public class SuperDevMode { VConsole.error("JSONP compile call failed"); // Don't log exception as they are shown as // notifications - VConsole.error(Util.getSimpleName(caught) + ": " + VConsole.error(caught.getClass().getSimpleName() + ": " + caught.getMessage()); failed(); diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 8b23bf433b..778f7c3861 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -16,40 +16,20 @@ package com.vaadin.client; -import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.dom.client.AnchorElement; -import com.google.gwt.dom.client.DivElement; -import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.dom.client.Node; -import com.google.gwt.dom.client.NodeList; -import com.google.gwt.dom.client.Style; -import com.google.gwt.dom.client.Style.Display; -import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.dom.client.Touch; import com.google.gwt.event.dom.client.KeyEvent; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; -import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.EventListener; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.HasWidgets; -import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.RenderInformation.FloatSize; import com.vaadin.client.ui.VOverlay; @@ -66,72 +46,62 @@ public class Util { /** * Helper method for debugging purposes. - * + * * Stops execution on firefox browsers on a breakpoint. - * + * */ - public static native void browserDebugger() - /*-{ - if($wnd.console) - debugger; - }-*/; + @Deprecated + public static void browserDebugger() { + WidgetUtil.browserDebugger(); + } /** * Helper method for a bug fix #14041. For mozilla getKeyCode return 0 for * space bar (because space is considered as char). If return 0 use * getCharCode. - * + * * @param event * @return return key code * @since 7.2.4 */ + @Deprecated public static int getKeyCode(KeyEvent<?> event) { - int keyCode = event.getNativeEvent().getKeyCode(); - if (keyCode == 0) { - keyCode = event.getNativeEvent().getCharCode(); - } - return keyCode; + return WidgetUtil.getKeyCode(event); } /** - * + * * Returns the topmost element of from given coordinates. - * + * * TODO fix crossplat issues clientX vs pageX. See quircksmode. Not critical * for vaadin as we scroll div istead of page. - * + * * @param x * @param y * @return the element at given coordinates */ - public static native com.google.gwt.user.client.Element getElementFromPoint( - int clientX, int clientY) - /*-{ - var el = $wnd.document.elementFromPoint(clientX, clientY); - // Call elementFromPoint two times to make sure IE8 also returns something sensible if the application is running in an iframe - el = $wnd.document.elementFromPoint(clientX, clientY); - if(el != null && el.nodeType == 3) { - el = el.parentNode; - } - return el; - }-*/; + @Deprecated + public static com.google.gwt.user.client.Element getElementFromPoint( + int clientX, int clientY) { + return DOM.asOld(WidgetUtil.getElementFromPoint(clientX, clientY)); + } /** * This helper method can be called if components size have been changed * outside rendering phase. It notifies components parent about the size * change so it can react. - * + * * When using this method, developer should consider if size changes could * be notified lazily. If lazy flag is true, method will save widget and * wait for a moment until it notifies parents in chunks. This may vastly * optimize layout in various situation. Example: if component have a lot of * images their onload events may fire "layout phase" many times in a short * period. - * + * * @param widget * @param lazy * run componentSizeUpdated lazyly - * + * * @deprecated As of 7.0, use * {@link LayoutManager#setNeedsMeasure(ComponentConnector)} * instead @@ -164,284 +134,112 @@ public class Util { return null; } + @Deprecated public static float parseRelativeSize(String size) { - if (size == null || !size.endsWith("%")) { - return -1; - } - - try { - return Float.parseFloat(size.substring(0, size.length() - 1)); - } catch (Exception e) { - VConsole.log("Unable to parse relative size"); - return -1; - } + return WidgetUtil.parseRelativeSize(size); } - private static final Element escapeHtmlHelper = DOM.createDiv(); - /** * Converts html entities to text. - * + * * @param html * @return escaped string presentation of given html */ + @Deprecated public static String escapeHTML(String html) { - DOM.setInnerText(escapeHtmlHelper, html); - String escapedText = DOM.getInnerHTML(escapeHtmlHelper); - if (BrowserInfo.get().isIE8()) { - // #7478 IE8 "incorrectly" returns "<br>" for newlines set using - // setInnerText. The same for " " which is converted to " " - escapedText = escapedText.replaceAll("<(BR|br)>", "\n"); - escapedText = escapedText.replaceAll(" ", " "); - } - return escapedText; + return WidgetUtil.escapeHTML(html); } /** * Escapes the string so it is safe to write inside an HTML attribute. - * + * * @param attribute * The string to escape * @return An escaped version of <literal>attribute</literal>. */ + @Deprecated public static String escapeAttribute(String attribute) { - if (attribute == null) { - return ""; - } - attribute = attribute.replace("\"", """); - attribute = attribute.replace("'", "'"); - attribute = attribute.replace(">", ">"); - attribute = attribute.replace("<", "<"); - attribute = attribute.replace("&", "&"); - return attribute; + return WidgetUtil.escapeAttribute(attribute); } /** * Clones given element as in JavaScript. - * + * * Deprecate this if there appears similar method into GWT someday. - * + * * @param element * @param deep * clone child tree also * @return */ - public static native com.google.gwt.user.client.Element cloneNode( - Element element, boolean deep) - /*-{ - return element.cloneNode(deep); - }-*/; + @Deprecated + public static com.google.gwt.user.client.Element cloneNode(Element element, + boolean deep) { + return DOM.asOld(WidgetUtil.cloneNode(element, deep)); + } + @Deprecated public static int measureHorizontalPaddingAndBorder(Element element, int paddingGuess) { - String originalWidth = DOM.getStyleAttribute(element, "width"); - - int originalOffsetWidth = element.getOffsetWidth(); - int widthGuess = (originalOffsetWidth - paddingGuess); - if (widthGuess < 1) { - widthGuess = 1; - } - element.getStyle().setWidth(widthGuess, Unit.PX); - int padding = element.getOffsetWidth() - widthGuess; - - element.getStyle().setProperty("width", originalWidth); - - return padding; + return WidgetUtil.measureHorizontalPaddingAndBorder(element, + paddingGuess); } + @Deprecated public static int measureVerticalPaddingAndBorder(Element element, int paddingGuess) { - String originalHeight = DOM.getStyleAttribute(element, "height"); - int originalOffsetHeight = element.getOffsetHeight(); - int widthGuess = (originalOffsetHeight - paddingGuess); - if (widthGuess < 1) { - widthGuess = 1; - } - element.getStyle().setHeight(widthGuess, Unit.PX); - int padding = element.getOffsetHeight() - widthGuess; - - element.getStyle().setProperty("height", originalHeight); - return padding; + return WidgetUtil + .measureVerticalPaddingAndBorder(element, paddingGuess); } + @Deprecated public static int measureHorizontalBorder(Element element) { - int borders; - - if (BrowserInfo.get().isIE()) { - String width = element.getStyle().getProperty("width"); - String height = element.getStyle().getProperty("height"); - - int offsetWidth = element.getOffsetWidth(); - int offsetHeight = element.getOffsetHeight(); - if (offsetHeight < 1) { - offsetHeight = 1; - } - if (offsetWidth < 1) { - offsetWidth = 10; - } - element.getStyle().setPropertyPx("height", offsetHeight); - element.getStyle().setPropertyPx("width", offsetWidth); - - borders = element.getOffsetWidth() - element.getClientWidth(); - - element.getStyle().setProperty("width", width); - element.getStyle().setProperty("height", height); - } else { - borders = element.getOffsetWidth() - - element.getPropertyInt("clientWidth"); - } - assert borders >= 0; - - return borders; + return WidgetUtil.measureHorizontalBorder(element); } + @Deprecated public static int measureVerticalBorder(Element element) { - int borders; - if (BrowserInfo.get().isIE()) { - String width = element.getStyle().getProperty("width"); - String height = element.getStyle().getProperty("height"); - - int offsetWidth = element.getOffsetWidth(); - int offsetHeight = element.getOffsetHeight(); - if (offsetHeight < 1) { - offsetHeight = 1; - } - if (offsetWidth < 1) { - offsetWidth = 10; - } - element.getStyle().setPropertyPx("width", offsetWidth); - - element.getStyle().setPropertyPx("height", offsetHeight); - - borders = element.getOffsetHeight() - - element.getPropertyInt("clientHeight"); - - element.getStyle().setProperty("height", height); - element.getStyle().setProperty("width", width); - } else { - borders = element.getOffsetHeight() - - element.getPropertyInt("clientHeight"); - } - assert borders >= 0; - - return borders; + return WidgetUtil.measureVerticalBorder(element); } + @Deprecated public static int measureMarginLeft(Element element) { - return element.getAbsoluteLeft() - - element.getParentElement().getAbsoluteLeft(); + return WidgetUtil.measureMarginLeft(element); } + @Deprecated public static int setHeightExcludingPaddingAndBorder(Widget widget, String height, int paddingBorderGuess) { - if (height.equals("")) { - setHeight(widget, ""); - return paddingBorderGuess; - } else if (height.endsWith("px")) { - int pixelHeight = Integer.parseInt(height.substring(0, - height.length() - 2)); - return setHeightExcludingPaddingAndBorder(widget.getElement(), - pixelHeight, paddingBorderGuess, false); - } else { - // Set the height in unknown units - setHeight(widget, height); - // Use the offsetWidth - return setHeightExcludingPaddingAndBorder(widget.getElement(), - widget.getOffsetHeight(), paddingBorderGuess, true); - } - } - - private static void setWidth(Widget widget, String width) { - widget.getElement().getStyle().setProperty("width", width); - } - - private static void setHeight(Widget widget, String height) { - widget.getElement().getStyle().setProperty("height", height); + return WidgetUtil.setHeightExcludingPaddingAndBorder(widget, height, + paddingBorderGuess); } + @Deprecated public static int setWidthExcludingPaddingAndBorder(Widget widget, String width, int paddingBorderGuess) { - if (width.equals("")) { - setWidth(widget, ""); - return paddingBorderGuess; - } else if (width.endsWith("px")) { - int pixelWidth = Integer.parseInt(width.substring(0, - width.length() - 2)); - return setWidthExcludingPaddingAndBorder(widget.getElement(), - pixelWidth, paddingBorderGuess, false); - } else { - setWidth(widget, width); - return setWidthExcludingPaddingAndBorder(widget.getElement(), - widget.getOffsetWidth(), paddingBorderGuess, true); - } + return WidgetUtil.setWidthExcludingPaddingAndBorder(widget, width, + paddingBorderGuess); } + @Deprecated public static int setWidthExcludingPaddingAndBorder(Element element, int requestedWidth, int horizontalPaddingBorderGuess, boolean requestedWidthIncludesPaddingBorder) { - - int widthGuess = requestedWidth - horizontalPaddingBorderGuess; - if (widthGuess < 0) { - widthGuess = 0; - } - - element.getStyle().setWidth(widthGuess, Unit.PX); - int captionOffsetWidth = DOM.getElementPropertyInt(element, - "offsetWidth"); - - int actualPadding = captionOffsetWidth - widthGuess; - - if (requestedWidthIncludesPaddingBorder) { - actualPadding += actualPadding; - } - - if (actualPadding != horizontalPaddingBorderGuess) { - int w = requestedWidth - actualPadding; - if (w < 0) { - // Cannot set negative width even if we would want to - w = 0; - } - element.getStyle().setWidth(w, Unit.PX); - - } - - return actualPadding; - + return WidgetUtil.setWidthExcludingPaddingAndBorder(element, + requestedWidth, horizontalPaddingBorderGuess, + requestedWidthIncludesPaddingBorder); } + @Deprecated public static int setHeightExcludingPaddingAndBorder(Element element, int requestedHeight, int verticalPaddingBorderGuess, boolean requestedHeightIncludesPaddingBorder) { - - int heightGuess = requestedHeight - verticalPaddingBorderGuess; - if (heightGuess < 0) { - heightGuess = 0; - } - - element.getStyle().setHeight(heightGuess, Unit.PX); - int captionOffsetHeight = DOM.getElementPropertyInt(element, - "offsetHeight"); - - int actualPadding = captionOffsetHeight - heightGuess; - - if (requestedHeightIncludesPaddingBorder) { - actualPadding += actualPadding; - } - - if (actualPadding != verticalPaddingBorderGuess) { - int h = requestedHeight - actualPadding; - if (h < 0) { - // Cannot set negative height even if we would want to - h = 0; - } - element.getStyle().setHeight(h, Unit.PX); - - } - - return actualPadding; - + return WidgetUtil.setHeightExcludingPaddingAndBorder(element, + requestedHeight, verticalPaddingBorderGuess, + requestedHeightIncludesPaddingBorder); } + @Deprecated public static String getSimpleName(Object widget) { if (widget == null) { return "(null)"; @@ -451,31 +249,14 @@ public class Util { return name.substring(name.lastIndexOf('.') + 1); } + @Deprecated public static void setFloat(Element element, String value) { - if (BrowserInfo.get().isIE()) { - element.getStyle().setProperty("styleFloat", value); - } else { - element.getStyle().setProperty("cssFloat", value); - } + WidgetUtil.setFloat(element, value); } - private static int detectedScrollbarSize = -1; - + @Deprecated public static int getNativeScrollbarSize() { - if (detectedScrollbarSize < 0) { - Element scroller = DOM.createDiv(); - scroller.getStyle().setProperty("width", "50px"); - scroller.getStyle().setProperty("height", "50px"); - scroller.getStyle().setProperty("overflow", "scroll"); - scroller.getStyle().setProperty("position", "absolute"); - scroller.getStyle().setProperty("marginLeft", "-5000px"); - RootPanel.getBodyElement().appendChild(scroller); - detectedScrollbarSize = scroller.getOffsetWidth() - - scroller.getPropertyInt("clientWidth"); - - RootPanel.getBodyElement().removeChild(scroller); - } - return detectedScrollbarSize; + return WidgetUtil.getNativeScrollbarSize(); } /** @@ -485,85 +266,22 @@ public class Util { * @param elem * with overflow auto */ + @Deprecated public static void runWebkitOverflowAutoFixDeferred(final Element elem) { - Scheduler.get().scheduleDeferred(new Command() { - - @Override - public void execute() { - Util.runWebkitOverflowAutoFix(elem); - } - }); - + WidgetUtil.runWebkitOverflowAutoFixDeferred(elem); } /** * Run workaround for webkits overflow auto issue. - * + * * See: our bug #2138 and https://bugs.webkit.org/show_bug.cgi?id=21462 - * + * * @param elem * with overflow auto */ + @Deprecated public static void runWebkitOverflowAutoFix(final Element elem) { - // Add max version if fix lands sometime to Webkit - // Starting from Opera 11.00, also a problem in Opera - if (BrowserInfo.get().requiresOverflowAutoFix()) { - final String originalOverflow = elem.getStyle().getProperty( - "overflow"); - if ("hidden".equals(originalOverflow)) { - return; - } - - // check the scrolltop value before hiding the element - final int scrolltop = elem.getScrollTop(); - final int scrollleft = elem.getScrollLeft(); - elem.getStyle().setProperty("overflow", "hidden"); - - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - // Dough, Safari scroll auto means actually just a moped - elem.getStyle().setProperty("overflow", originalOverflow); - - if (scrolltop > 0 || elem.getScrollTop() > 0) { - int scrollvalue = scrolltop; - if (scrollvalue == 0) { - // mysterious are the ways of webkits scrollbar - // handling. In some cases webkit reports bad (0) - // scrolltop before hiding the element temporary, - // sometimes after. - scrollvalue = elem.getScrollTop(); - } - // fix another bug where scrollbar remains in wrong - // position - elem.setScrollTop(scrollvalue - 1); - elem.setScrollTop(scrollvalue); - } - - // fix for #6940 : Table horizontal scroll sometimes not - // updated when collapsing/expanding columns - // Also appeared in Safari 5.1 with webkit 534 (#7667) - if ((BrowserInfo.get().isChrome() || (BrowserInfo.get() - .isSafari() && BrowserInfo.get().getWebkitVersion() >= 534)) - && (scrollleft > 0 || elem.getScrollLeft() > 0)) { - int scrollvalue = scrollleft; - - if (scrollvalue == 0) { - // mysterious are the ways of webkits scrollbar - // handling. In some cases webkit may report a bad - // (0) scrollleft before hiding the element - // temporary, sometimes after. - scrollvalue = elem.getScrollLeft(); - } - // fix another bug where scrollbar remains in wrong - // position - elem.setScrollLeft(scrollvalue - 1); - elem.setScrollLeft(scrollvalue); - } - } - }); - } - + WidgetUtil.runWebkitOverflowAutoFix(elem); } /** @@ -571,7 +289,7 @@ public class Util { * dimension is not specified as relative it will return -1. If the shared * state does not contain width or height specifications this will return * null. - * + * * @param state * @return */ @@ -581,8 +299,8 @@ public class Util { return null; } - float relativeWidth = Util.parseRelativeSize(state.width); - float relativeHeight = Util.parseRelativeSize(state.height); + float relativeWidth = WidgetUtil.parseRelativeSize(state.width); + float relativeHeight = WidgetUtil.parseRelativeSize(state.height); FloatSize relativeSize = new FloatSize(relativeWidth, relativeHeight); return relativeSize; @@ -594,17 +312,16 @@ public class Util { return uidl.getBooleanAttribute("cached"); } + @Deprecated public static void alert(String string) { - if (true) { - Window.alert(string); - } + WidgetUtil.alert(string); } /** * Checks if a and b are equals using {@link #equals(Object)}. Handles null * values as well. Does not ensure that objects are of the same type. * Assumes that the first object's equals method handle equals properly. - * + * * @param a * The first value to compare * @param b @@ -625,242 +342,85 @@ public class Util { /** * Gets the border-box width for the given element, i.e. element width + * border + padding. Always rounds up to nearest integer. - * + * * @param element * The element to check * @return The border-box width for the element */ + @Deprecated public static int getRequiredWidth(com.google.gwt.dom.client.Element element) { - int reqWidth = getRequiredWidthBoundingClientRect(element); - if (BrowserInfo.get().isIE() && !BrowserInfo.get().isIE8()) { - int csSize = getRequiredWidthComputedStyle(element); - if (csSize == reqWidth + 1) { - // If computed style reports one pixel larger than requiredWidth - // we would be rounding in the wrong direction in IE9. Round up - // instead. - // We do not always use csSize as it e.g. for 100% wide Labels - // in GridLayouts produces senseless values (see e.g. - // ThemeTestUI with Runo). - return csSize; - } - } - return reqWidth; + return WidgetUtil.getRequiredWidth(element); } /** * Gets the border-box height for the given element, i.e. element height + * border + padding. Always rounds up to nearest integer. - * + * * @param element * The element to check * @return The border-box height for the element */ + @Deprecated public static int getRequiredHeight( com.google.gwt.dom.client.Element element) { - int reqHeight = getRequiredHeightBoundingClientRect(element); - if (BrowserInfo.get().isIE() && !BrowserInfo.get().isIE8()) { - int csSize = getRequiredHeightComputedStyle(element); - if (csSize == reqHeight + 1) { - // If computed style reports one pixel larger than - // requiredHeight we would be rounding in the wrong direction in - // IE9. Round up instead. - // We do not always use csSize as it e.g. for 100% wide Labels - // in GridLayouts produces senseless values (see e.g. - // ThemeTestUI with Runo). - return csSize; - } - } - return reqHeight; + return WidgetUtil.getRequiredHeight(element); } - /** - * Calculates the width of the element's bounding rectangle. - * <p> - * In case the browser doesn't support bounding rectangles, the returned - * value is the offset width. - * - * @param element - * the element of which to calculate the width - * @return the width of the element - */ - public static int getRequiredWidthBoundingClientRect( + @Deprecated + public int getRequiredWidthBoundingClientRect( com.google.gwt.dom.client.Element element) { - return (int) getRequiredWidthBoundingClientRectDouble(element); + return WidgetUtil.getRequiredWidthBoundingClientRect(element); } - /** - * Calculates the width of the element's bounding rectangle to subpixel - * precision. - * <p> - * In case the browser doesn't support bounding rectangles, the returned - * value is the offset width. - * - * @param element - * the element of which to calculate the width - * @return the subpixel-accurate width of the element - * @since 7.4 - */ - public static native double getRequiredWidthBoundingClientRectDouble( - com.google.gwt.dom.client.Element element) - /*-{ - if (element.getBoundingClientRect) { - var rect = element.getBoundingClientRect(); - return Math.ceil(rect.right - rect.left); - } else { - return element.offsetWidth; - } - }-*/; + @Deprecated + public static int getRequiredHeightComputedStyle( + com.google.gwt.dom.client.Element element) { + return WidgetUtil.getRequiredHeightComputedStyle(element); + } - public static native int getRequiredHeightComputedStyle( - com.google.gwt.dom.client.Element element) - /*-{ - var cs = element.ownerDocument.defaultView.getComputedStyle(element); - var heightPx = cs.height; - if(heightPx == 'auto'){ - // Fallback for when IE reports auto - heightPx = @com.vaadin.client.Util::getRequiredHeightBoundingClientRect(Lcom/google/gwt/dom/client/Element;)(element) + 'px'; - } - var borderTopPx = cs.borderTop; - var borderBottomPx = cs.borderBottom; - var paddingTopPx = cs.paddingTop; - var paddingBottomPx = cs.paddingBottom; - - var height = heightPx.substring(0,heightPx.length-2); - var border = borderTopPx.substring(0,borderTopPx.length-2)+borderBottomPx.substring(0,borderBottomPx.length-2); - var padding = paddingTopPx.substring(0,paddingTopPx.length-2)+paddingBottomPx.substring(0,paddingBottomPx.length-2); - return Math.ceil(height+border+padding); - }-*/; - - public static native int getRequiredWidthComputedStyle( - com.google.gwt.dom.client.Element element) - /*-{ - var cs = element.ownerDocument.defaultView.getComputedStyle(element); - var widthPx = cs.width; - if(widthPx == 'auto'){ - // Fallback for when IE reports auto - widthPx = @com.vaadin.client.Util::getRequiredWidthBoundingClientRect(Lcom/google/gwt/dom/client/Element;)(element) + 'px'; - } - var borderLeftPx = cs.borderLeft; - var borderRightPx = cs.borderRight; - var paddingLeftPx = cs.paddingLeft; - var paddingRightPx = cs.paddingRight; - - var width = widthPx.substring(0,widthPx.length-2); - var border = borderLeftPx.substring(0,borderLeftPx.length-2)+borderRightPx.substring(0,borderRightPx.length-2); - var padding = paddingLeftPx.substring(0,paddingLeftPx.length-2)+paddingRightPx.substring(0,paddingRightPx.length-2); - return Math.ceil(width+border+padding); - }-*/; + @Deprecated + public static int getRequiredWidthComputedStyle( + com.google.gwt.dom.client.Element element) { + return WidgetUtil.getRequiredWidthComputedStyle(element); + } - /** - * Calculates the height of the element's bounding rectangle. - * <p> - * In case the browser doesn't support bounding rectangles, the returned - * value is the offset height. - * - * @param element - * the element of which to calculate the height - * @return the height of the element - */ + @Deprecated public static int getRequiredHeightBoundingClientRect( com.google.gwt.dom.client.Element element) { - return (int) getRequiredHeightBoundingClientRectDouble(element); + return WidgetUtil.getRequiredHeightBoundingClientRect(element); } - /** - * Calculates the height of the element's bounding rectangle to subpixel - * precision. - * <p> - * In case the browser doesn't support bounding rectangles, the returned - * value is the offset height. - * - * @param element - * the element of which to calculate the height - * @return the subpixel-accurate height of the element - * @since 7.4 - */ - public static native double getRequiredHeightBoundingClientRectDouble( - com.google.gwt.dom.client.Element element) - /*-{ - var height; - if (element.getBoundingClientRect != null) { - var rect = element.getBoundingClientRect(); - height = Math.ceil(rect.bottom - rect.top); - } else { - height = element.offsetHeight; - } - return height; - }-*/; - + @Deprecated public static int getRequiredWidth(Widget widget) { - return getRequiredWidth(widget.getElement()); + return WidgetUtil.getRequiredWidth(widget); } + @Deprecated public static int getRequiredHeight(Widget widget) { - return getRequiredHeight(widget.getElement()); + return WidgetUtil.getRequiredHeight(widget); } /** * Detects what is currently the overflow style attribute in given element. - * + * * @param pe * the element to detect * @return true if auto or scroll */ + @Deprecated public static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe) { - String overflow = getComputedStyle(pe, "overflow"); - if (overflow != null) { - if (overflow.equals("auto") || overflow.equals("scroll")) { - return true; - } else { - return false; - } - } else { - return false; - } + return WidgetUtil.mayHaveScrollBars(pe); } /** - * A simple helper method to detect "computed style" (aka style sheets + - * element styles). Values returned differ a lot depending on browsers. - * Always be very careful when using this. - * - * @param el - * the element from which the style property is detected - * @param p - * the property to detect - * @return String value of style property - */ - private static native String getComputedStyle( - com.google.gwt.dom.client.Element el, String p) - /*-{ - try { - - if (el.currentStyle) { - // IE - return el.currentStyle[p]; - } else if (window.getComputedStyle) { - // Sa, FF, Opera - var view = el.ownerDocument.defaultView; - return view.getComputedStyle(el,null).getPropertyValue(p); - } else { - // fall back for non IE, Sa, FF, Opera - return ""; - } - } catch (e) { - return ""; - } - - }-*/; - - /** * Locates the nested child component of <literal>parent</literal> which * contains the element <literal>element</literal>. The child component is * also returned if "element" is part of its caption. If * <literal>element</literal> is not part of any child component, null is * returned. - * + * * This method returns the deepest nested VPaintableWidget. - * + * * @param client * A reference to ApplicationConnection * @param parent @@ -918,23 +478,19 @@ public class Util { /** * Will (attempt) to focus the given DOM Element. - * + * * @param el * the element to focus */ - public static native void focus(Element el) - /*-{ - try { - el.focus(); - } catch (e) { - - } - }-*/; + @Deprecated + public static void focus(Element el) { + WidgetUtil.focus(el); + } /** * Helper method to find the nearest parent paintable instance by traversing * the DOM upwards from given element. - * + * * @param element * the element to start from */ @@ -952,145 +508,84 @@ public class Util { /** * Helper method to find first instance of given Widget type found by * traversing DOM upwards from given element. - * <p> - * <strong>Note:</strong> If {@code element} is inside some widget {@code W} - * , <em>and</em> {@code W} in turn is wrapped in a {@link Composite} - * {@code C}, this method will not find {@code W}. It returns either - * {@code C} or null, depending on whether the class parameter matches. This - * may also be the case with other Composite-like classes that hijack the - * event handling of their child widget(s). - * + * * @param element * the element where to start seeking of Widget * @param class1 * the Widget type to seek for */ - @SuppressWarnings("unchecked") + @Deprecated public static <T> T findWidget(Element element, Class<? extends Widget> class1) { - if (element != null) { - /* First seek for the first EventListener (~Widget) from dom */ - EventListener eventListener = null; - while (eventListener == null && element != null) { - eventListener = Event.getEventListener(element); - if (eventListener == null) { - element = element.getParentElement(); - } - } - if (eventListener instanceof Widget) { - /* - * Then find the first widget of type class1 from widget - * hierarchy - */ - Widget w = (Widget) eventListener; - while (w != null) { - if (class1 == null || w.getClass() == class1) { - return (T) w; - } - w = w.getParent(); - } - } - } - return null; + return WidgetUtil.findWidget(element, class1); } /** * Force webkit to redraw an element - * + * * @param element * The element that should be redrawn */ + @Deprecated public static void forceWebkitRedraw(Element element) { - Style style = element.getStyle(); - String s = style.getProperty("webkitTransform"); - if (s == null || s.length() == 0) { - style.setProperty("webkitTransform", "scale(1)"); - } else { - style.setProperty("webkitTransform", ""); - } + WidgetUtil.forceWebkitRedraw(element); } /** * Performs a hack to trigger a re-layout in the IE8. This is usually * necessary in cases where IE8 "forgets" to update child elements when they * resize. - * + * * @param e * The element to perform the hack on */ + @Deprecated public static final void forceIE8Redraw(Element e) { - if (BrowserInfo.get().isIE8()) { - forceIERedraw(e); - } + WidgetUtil.forceIE8Redraw(e); } /** * Performs a hack to trigger a re-layout in the IE browser. This is usually * necessary in cases where IE "forgets" to update child elements when they * resize. - * + * * @since 7.3 * @param e * The element to perform the hack on */ + @Deprecated public static void forceIERedraw(Element e) { - if (BrowserInfo.get().isIE()) { - setStyleTemporarily(e, "zoom", "1"); - } + WidgetUtil.forceIERedraw(e); } /** * Detaches and re-attaches the element from its parent. The element is * reattached at the same position in the DOM as it was before. - * + * * Does nothing if the element is not attached to the DOM. - * + * * @param element * The element to detach and re-attach */ + @Deprecated public static void detachAttach(Element element) { - if (element == null) { - return; - } - - Node nextSibling = element.getNextSibling(); - Node parent = element.getParentNode(); - if (parent == null) { - return; - } - - parent.removeChild(element); - if (nextSibling == null) { - parent.appendChild(element); - } else { - parent.insertBefore(element, nextSibling); - } - + WidgetUtil.detachAttach(element); } + @Deprecated public static void sinkOnloadForImages(Element element) { - NodeList<com.google.gwt.dom.client.Element> imgElements = element - .getElementsByTagName("img"); - for (int i = 0; i < imgElements.getLength(); i++) { - DOM.sinkEvents(imgElements.getItem(i), Event.ONLOAD); - } - + WidgetUtil.sinkOnloadForImages(element); } /** * Returns the index of the childElement within its parent. - * + * * @param subElement * @return */ + @Deprecated public static int getChildElementIndex(Element childElement) { - int idx = 0; - Node n = childElement; - while ((n = n.getPreviousSibling()) != null) { - idx++; - } - - return idx; + return WidgetUtil.getChildElementIndex(childElement); } private static void printConnectorInvocations( @@ -1155,7 +650,7 @@ public class Util { * Temporarily sets the {@code styleProperty} to {@code tempValue} and then * resets it to its current value. Used mainly to work around rendering * issues in IE (and possibly in other browsers) - * + * * @param element * The target element * @param styleProperty @@ -1163,162 +658,104 @@ public class Util { * @param tempValue * The temporary value */ + @Deprecated public static void setStyleTemporarily(Element element, final String styleProperty, String tempValue) { - final Style style = element.getStyle(); - final String currentValue = style.getProperty(styleProperty); - - style.setProperty(styleProperty, tempValue); - element.getOffsetWidth(); - style.setProperty(styleProperty, currentValue); - + WidgetUtil.setStyleTemporarily(element, styleProperty, tempValue); } /** * A helper method to return the client position from an event. Returns * position from either first changed touch (if touch event) or from the * event itself. - * + * * @param event * @return */ + @Deprecated public static int getTouchOrMouseClientX(Event event) { - if (isTouchEvent(event)) { - return event.getChangedTouches().get(0).getClientX(); - } else { - return event.getClientX(); - } + return WidgetUtil.getTouchOrMouseClientX(event); } /** * Find the element corresponding to the coordinates in the passed mouse * event. Please note that this is not always the same as the target of the * event e.g. if event capture is used. - * + * * @param event * the mouse event to get coordinates from * @return the element at the coordinates of the event */ + @Deprecated public static com.google.gwt.user.client.Element getElementUnderMouse( NativeEvent event) { - int pageX = getTouchOrMouseClientX(event); - int pageY = getTouchOrMouseClientY(event); - - return getElementFromPoint(pageX, pageY); + return DOM.asOld(WidgetUtil.getElementUnderMouse(event)); } /** * A helper method to return the client position from an event. Returns * position from either first changed touch (if touch event) or from the * event itself. - * + * * @param event * @return */ + @Deprecated public static int getTouchOrMouseClientY(Event event) { - if (isTouchEvent(event)) { - return event.getChangedTouches().get(0).getClientY(); - } else { - return event.getClientY(); - } + return WidgetUtil.getTouchOrMouseClientY(event); } /** - * + * * @see #getTouchOrMouseClientY(Event) * @param currentGwtEvent * @return */ + @Deprecated public static int getTouchOrMouseClientY(NativeEvent currentGwtEvent) { - return getTouchOrMouseClientY(Event.as(currentGwtEvent)); + return WidgetUtil.getTouchOrMouseClientY(currentGwtEvent); } /** * @see #getTouchOrMouseClientX(Event) - * + * * @param event * @return */ + @Deprecated public static int getTouchOrMouseClientX(NativeEvent event) { - return getTouchOrMouseClientX(Event.as(event)); + return WidgetUtil.getTouchOrMouseClientX(event); } + @Deprecated public static boolean isTouchEvent(Event event) { - return event.getType().contains("touch"); + return WidgetUtil.isTouchEvent(event); } + @Deprecated public static boolean isTouchEvent(NativeEvent event) { - return isTouchEvent(Event.as(event)); + return WidgetUtil.isTouchEvent(event); } + @Deprecated public static void simulateClickFromTouchEvent(Event touchevent, Widget widget) { - Touch touch = touchevent.getChangedTouches().get(0); - final NativeEvent createMouseUpEvent = Document.get() - .createMouseUpEvent(0, touch.getScreenX(), touch.getScreenY(), - touch.getClientX(), touch.getClientY(), false, false, - false, false, NativeEvent.BUTTON_LEFT); - final NativeEvent createMouseDownEvent = Document.get() - .createMouseDownEvent(0, touch.getScreenX(), - touch.getScreenY(), touch.getClientX(), - touch.getClientY(), false, false, false, false, - NativeEvent.BUTTON_LEFT); - final NativeEvent createMouseClickEvent = Document.get() - .createClickEvent(0, touch.getScreenX(), touch.getScreenY(), - touch.getClientX(), touch.getClientY(), false, false, - false, false); - - /* - * Get target with element from point as we want the actual element, not - * the one that sunk the event. - */ - final Element target = getElementFromPoint(touch.getClientX(), - touch.getClientY()); - - /* - * Fixes infocusable form fields in Safari of iOS 5.x and some Android - * browsers. - */ - Widget targetWidget = findWidget(target, null); - if (targetWidget instanceof com.google.gwt.user.client.ui.Focusable) { - final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) targetWidget; - toBeFocusedWidget.setFocus(true); - } else if (targetWidget instanceof Focusable) { - ((Focusable) targetWidget).focus(); - } - - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - @Override - public void execute() { - try { - target.dispatchEvent(createMouseDownEvent); - target.dispatchEvent(createMouseUpEvent); - target.dispatchEvent(createMouseClickEvent); - } catch (Exception e) { - } - - } - }); - + WidgetUtil.simulateClickFromTouchEvent(touchevent, widget); } /** * Gets the currently focused element. - * + * * @return The active element or null if no active element could be found. */ - public native static com.google.gwt.user.client.Element getFocusedElement() - /*-{ - if ($wnd.document.activeElement) { - return $wnd.document.activeElement; - } - - return null; - }-*/; + @Deprecated + public static com.google.gwt.user.client.Element getFocusedElement() { + return DOM.asOld(WidgetUtil.getFocusedElement()); + } /** * Gets the currently focused element for Internet Explorer. - * + * * @return The currently focused element * @deprecated Use #getFocusedElement instead */ @@ -1334,18 +771,9 @@ public class Util { * * @return true if focused element is editable */ + @Deprecated public static boolean isFocusedElementEditable() { - Element focusedElement = Util.getFocusedElement(); - if (focusedElement != null) { - String tagName = focusedElement.getTagName(); - String contenteditable = focusedElement - .getAttribute("contenteditable"); - - return "textarea".equalsIgnoreCase(tagName) - || "input".equalsIgnoreCase(tagName) - || "true".equalsIgnoreCase(contenteditable); - } - return false; + return WidgetUtil.isFocusedElementEditable(); } /** @@ -1353,87 +781,43 @@ public class Util { * this method checks that this widget nor any of its parents is hidden. Can * be e.g used to check whether component should react to some events or * not. - * + * * @param widget * @return true if attached and displayed */ + @Deprecated public static boolean isAttachedAndDisplayed(Widget widget) { - if (widget.isAttached()) { - /* - * Failfast using offset size, then by iterating the widget tree - */ - boolean notZeroSized = widget.getOffsetHeight() > 0 - || widget.getOffsetWidth() > 0; - return notZeroSized || checkVisibilityRecursively(widget); - } else { - return false; - } - } - - private static boolean checkVisibilityRecursively(Widget widget) { - if (widget.isVisible()) { - Widget parent = widget.getParent(); - if (parent == null) { - return true; // root panel - } else { - return checkVisibilityRecursively(parent); - } - } else { - return false; - } + return WidgetUtil.isAttachedAndDisplayed(widget); } /** * Scrolls an element into view vertically only. Modified version of * Element.scrollIntoView. - * + * * @param elem * The element to scroll into view */ - public static native void scrollIntoViewVertically(Element elem) - /*-{ - var top = elem.offsetTop; - var height = elem.offsetHeight; - - if (elem.parentNode != elem.offsetParent) { - top -= elem.parentNode.offsetTop; - } - - var cur = elem.parentNode; - while (cur && (cur.nodeType == 1)) { - if (top < cur.scrollTop) { - cur.scrollTop = top; - } - if (top + height > cur.scrollTop + cur.clientHeight) { - cur.scrollTop = (top + height) - cur.clientHeight; - } - - var offsetTop = cur.offsetTop; - if (cur.parentNode != cur.offsetParent) { - offsetTop -= cur.parentNode.offsetTop; - } - - top += offsetTop - cur.scrollTop; - cur = cur.parentNode; - } - }-*/; + @Deprecated + public static void scrollIntoViewVertically(Element elem) { + WidgetUtil.scrollIntoViewVertically(elem); + } /** * Checks if the given event is either a touch event or caused by the left * mouse button - * + * * @param event * @return true if the event is a touch event or caused by the left mouse * button, false otherwise */ + @Deprecated public static boolean isTouchEventOrLeftMouseButton(Event event) { - boolean touchEvent = Util.isTouchEvent(event); - return touchEvent || event.getButton() == Event.BUTTON_LEFT; + return WidgetUtil.isTouchEventOrLeftMouseButton(event); } /** * Performs a shallow comparison of the collections. - * + * * @param collection1 * The first collection * @param collection2 @@ -1479,31 +863,14 @@ public class Util { /** * Resolve a relative URL to an absolute URL based on the current document's * location. - * + * * @param url * a string with the relative URL to resolve * @return the corresponding absolute URL as a string */ + @Deprecated public static String getAbsoluteUrl(String url) { - if (BrowserInfo.get().isIE8()) { - // The hard way - must use innerHTML and attach to DOM in IE8 - DivElement divElement = Document.get().createDivElement(); - divElement.getStyle().setDisplay(Display.NONE); - - RootPanel.getBodyElement().appendChild(divElement); - divElement.setInnerHTML("<a href='" + escapeAttribute(url) - + "' ></a>"); - - AnchorElement a = divElement.getChild(0).cast(); - String href = a.getHref(); - - RootPanel.getBodyElement().removeChild(divElement); - return href; - } else { - AnchorElement a = Document.get().createAnchorElement(); - a.setHref(url); - return a.getHref(); - } + return WidgetUtil.getAbsoluteUrl(url); } /** @@ -1527,15 +894,11 @@ public class Util { * * @since 7.3 */ - public native static void setSelectionRange(Element elem, int pos, - int length, String direction) - /*-{ - try { - elem.setSelectionRange(pos, pos + length, direction); - } catch (e) { - // Firefox throws exception if TextBox is not visible, even if attached - } - }-*/; + @Deprecated + public static void setSelectionRange(Element elem, int pos, int length, + String direction) { + WidgetUtil.setSelectionRange(elem, pos, length, direction); + } /** * Converts a native {@link JavaScriptObject} into a {@link JsonValue}. This @@ -1597,184 +960,4 @@ public class Util { return JSON.parse(jsonAsString); }-*/; - /** - * The allowed value inaccuracy when comparing two double-typed pixel - * values. - * <p> - * Since we're comparing pixels on a screen, epsilon must be less than 1. - * 0.49 was deemed a perfectly fine and beautifully round number. - */ - public static final double PIXEL_EPSILON = 0.49d; - - /** - * Compares two double values with the error margin of - * {@link #PIXEL_EPSILON} (i.e. {@value #PIXEL_EPSILON}) - * - * @param num1 - * the first value for which to compare equality - * @param num2 - * the second value for which to compare equality - * @since 7.4 - * - * @return true if the values are considered equals; false otherwise - */ - public static boolean pixelValuesEqual(final double num1, final double num2) { - return Math.abs(num1 - num2) <= PIXEL_EPSILON; - } - - /** - * Wrap a css size value and its unit and translate back and forth to the - * string representation.<br/> - * Eg. 50%, 123px, ... - * - * @since 7.2.6 - * @author Vaadin Ltd - */ - @SuppressWarnings("serial") - public static class CssSize implements Serializable { - - /* - * Map the size units with their type. - */ - private static Map<String, Unit> type2Unit = new HashMap<String, Style.Unit>(); - static { - for (Unit unit : Unit.values()) { - type2Unit.put(unit.getType(), unit); - } - } - - /** - * Gets the unit value by its type. - * - * @param type - * the type of the unit as found in the style. - * @return the unit value. - */ - public static Unit unitByType(String type) { - return type2Unit.get(type); - } - - /* - * Regex to parse the size. - */ - private static final RegExp sizePattern = RegExp - .compile(SharedUtil.SIZE_PATTERN); - - /** - * Parse the size from string format to {@link CssSize}. - * - * @param s - * the size as string. - * @return a {@link CssSize} object. - */ - public static CssSize fromString(String s) { - if (s == null) { - return null; - } - - s = s.trim(); - if ("".equals(s)) { - return null; - } - - float size = 0; - Unit unit = null; - - MatchResult matcher = sizePattern.exec(s); - if (matcher.getGroupCount() > 1) { - - size = Float.parseFloat(matcher.getGroup(1)); - if (size < 0) { - size = -1; - unit = Unit.PX; - - } else { - String symbol = matcher.getGroup(2); - unit = unitByType(symbol); - } - } else { - throw new IllegalArgumentException("Invalid size argument: \"" - + s + "\" (should match " + sizePattern.getSource() - + ")"); - } - return new CssSize(size, unit); - } - - /** - * Creates a {@link CssSize} using a value and its measurement unit. - * - * @param value - * the value. - * @param unit - * the unit. - * @return the {@link CssSize} object. - */ - public static CssSize fromValueUnit(float value, Unit unit) { - return new CssSize(value, unit); - } - - /* - * The value. - */ - private final float value; - - /* - * The measure unit. - */ - private final Unit unit; - - private CssSize(float value, Unit unit) { - this.value = value; - this.unit = unit; - } - - /** - * Gets the value for this css size. - * - * @return the value. - */ - public float getValue() { - return value; - } - - /** - * Gets the measurement unit for this css size. - * - * @return the unit. - */ - public Unit getUnit() { - return unit; - } - - @Override - public String toString() { - return value + unit.getType(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof CssSize) { - CssSize size = (CssSize) obj; - return size.value == value && size.unit == unit; - } - - return false; - } - - /** - * Check whether the two sizes are equals. - * - * @param cssSize1 - * the first size to compare. - * @param cssSize2 - * the other size to compare with the first one. - * @return true if the two sizes are equals, otherwise false. - */ - public static boolean equals(String cssSize1, String cssSize2) { - return CssSize.fromString(cssSize1).equals( - CssSize.fromString(cssSize2)); - } - - } - } diff --git a/client/src/com/vaadin/client/VCaption.java b/client/src/com/vaadin/client/VCaption.java index eb19dedf8b..050edae8be 100644 --- a/client/src/com/vaadin/client/VCaption.java +++ b/client/src/com/vaadin/client/VCaption.java @@ -148,7 +148,7 @@ public class VCaption extends HTML { } } if (!owner.isEnabled()) { - style += " " + ApplicationConnection.DISABLED_CLASSNAME; + style += " " + StyleConstants.DISABLED; } setStyleName(style); @@ -328,7 +328,7 @@ public class VCaption extends HTML { String style = VCaption.CLASSNAME; if (disabled) { - style += " " + ApplicationConnection.DISABLED_CLASSNAME; + style += " " + StyleConstants.DISABLED; } setStyleName(style); if (hasDescription) { @@ -510,17 +510,17 @@ public class VCaption extends HTML { int width = 0; if (icon != null) { - width += Util.getRequiredWidth(icon.getElement()); + width += WidgetUtil.getRequiredWidth(icon.getElement()); } if (captionText != null) { - width += Util.getRequiredWidth(captionText); + width += WidgetUtil.getRequiredWidth(captionText); } if (requiredFieldIndicator != null) { - width += Util.getRequiredWidth(requiredFieldIndicator); + width += WidgetUtil.getRequiredWidth(requiredFieldIndicator); } if (errorIndicatorElement != null) { - width += Util.getRequiredWidth(errorIndicatorElement); + width += WidgetUtil.getRequiredWidth(errorIndicatorElement); } return width; @@ -531,7 +531,7 @@ public class VCaption extends HTML { int width = 0; if (icon != null) { - width += Util.getRequiredWidth(icon.getElement()); + width += WidgetUtil.getRequiredWidth(icon.getElement()); } if (captionText != null) { int textWidth = captionText.getScrollWidth(); @@ -540,7 +540,7 @@ public class VCaption extends HTML { * In Firefox3 the caption might require more space than the * scrollWidth returns as scrollWidth is rounded down. */ - int requiredWidth = Util.getRequiredWidth(captionText); + int requiredWidth = WidgetUtil.getRequiredWidth(captionText); if (requiredWidth > textWidth) { textWidth = requiredWidth; } @@ -549,10 +549,10 @@ public class VCaption extends HTML { width += textWidth; } if (requiredFieldIndicator != null) { - width += Util.getRequiredWidth(requiredFieldIndicator); + width += WidgetUtil.getRequiredWidth(requiredFieldIndicator); } if (errorIndicatorElement != null) { - width += Util.getRequiredWidth(errorIndicatorElement); + width += WidgetUtil.getRequiredWidth(errorIndicatorElement); } return width; @@ -564,26 +564,26 @@ public class VCaption extends HTML { int h; if (icon != null) { - h = Util.getRequiredHeight(icon.getElement()); + h = WidgetUtil.getRequiredHeight(icon.getElement()); if (h > height) { height = h; } } if (captionText != null) { - h = Util.getRequiredHeight(captionText); + h = WidgetUtil.getRequiredHeight(captionText); if (h > height) { height = h; } } if (requiredFieldIndicator != null) { - h = Util.getRequiredHeight(requiredFieldIndicator); + h = WidgetUtil.getRequiredHeight(requiredFieldIndicator); if (h > height) { height = h; } } if (errorIndicatorElement != null) { - h = Util.getRequiredHeight(errorIndicatorElement); + h = WidgetUtil.getRequiredHeight(errorIndicatorElement); if (h > height) { height = h; } @@ -619,11 +619,13 @@ public class VCaption extends HTML { // DOM.setStyleAttribute(getElement(), "width", maxWidth + "px"); if (requiredFieldIndicator != null) { - availableWidth -= Util.getRequiredWidth(requiredFieldIndicator); + availableWidth -= WidgetUtil + .getRequiredWidth(requiredFieldIndicator); } if (errorIndicatorElement != null) { - availableWidth -= Util.getRequiredWidth(errorIndicatorElement); + availableWidth -= WidgetUtil + .getRequiredWidth(errorIndicatorElement); } if (availableWidth < 0) { @@ -631,8 +633,8 @@ public class VCaption extends HTML { } if (icon != null) { - int iconRequiredWidth = Util - .getRequiredWidth(icon.getElement()); + int iconRequiredWidth = WidgetUtil.getRequiredWidth(icon + .getElement()); if (availableWidth > iconRequiredWidth) { availableWidth -= iconRequiredWidth; } else { @@ -642,7 +644,7 @@ public class VCaption extends HTML { } } if (captionText != null) { - int captionWidth = Util.getRequiredWidth(captionText); + int captionWidth = WidgetUtil.getRequiredWidth(captionText); if (availableWidth > captionWidth) { availableWidth -= captionWidth; diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 47a1b71228..453563370c 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -134,11 +134,11 @@ public class VTooltip extends VOverlay { description.setInnerHTML(info.getTitle()); /* * Issue #11871: to correctly update the offsetWidth of description - * element we need to clear style width of it's parent DIV from old + * element we need to clear style width of its parent DIV from old * value (in some strange cases this width=[tooltip MAX_WIDTH] after * tooltip text has been already updated to new shortly value: * - * <div class="popupContent"> <div style="width: 500px;"> <div + * <div class="popupContent"> <div style="width:500px;"> <div * class="v-errormessage" aria-hidden="true" style="display: none;"> * <div class="gwt-HTML"> </div> </div> <div * class="v-tooltip-text">This is a short tooltip</div> </div> diff --git a/client/src/com/vaadin/client/WidgetUtil.java b/client/src/com/vaadin/client/WidgetUtil.java new file mode 100644 index 0000000000..96f161c4a8 --- /dev/null +++ b/client/src/com/vaadin/client/WidgetUtil.java @@ -0,0 +1,1405 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.client; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.AnchorElement; +import com.google.gwt.dom.client.DivElement; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.Node; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Display; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.dom.client.Touch; +import com.google.gwt.event.dom.client.KeyEvent; +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.EventListener; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.shared.util.SharedUtil; + +/** + * Utility methods which are related to client side code only + */ +public class WidgetUtil { + + /** + * Helper method for debugging purposes. + * + * Stops execution on firefox browsers on a breakpoint. + * + */ + public static native void browserDebugger() + /*-{ + if($wnd.console) + debugger; + }-*/; + + /** + * Helper method for a bug fix #14041. For mozilla getKeyCode return 0 for + * space bar (because space is considered as char). If return 0 use + * getCharCode. + * + * @param event + * @return return key code + * @since 7.2.4 + */ + public static int getKeyCode(KeyEvent<?> event) { + int keyCode = event.getNativeEvent().getKeyCode(); + if (keyCode == 0) { + keyCode = event.getNativeEvent().getCharCode(); + } + return keyCode; + } + + /** + * + * Returns the topmost element of from given coordinates. + * + * TODO fix crossplat issues clientX vs pageX. See quircksmode. Not critical + * for vaadin as we scroll div istead of page. + * + * @param x + * @param y + * @return the element at given coordinates + */ + public static native Element getElementFromPoint(int clientX, int clientY) + /*-{ + var el = $wnd.document.elementFromPoint(clientX, clientY); + // Call elementFromPoint two times to make sure IE8 also returns something sensible if the application is running in an iframe + el = $wnd.document.elementFromPoint(clientX, clientY); + if(el != null && el.nodeType == 3) { + el = el.parentNode; + } + return el; + }-*/; + + public static float parseRelativeSize(String size) { + if (size == null || !size.endsWith("%")) { + return -1; + } + + try { + return Float.parseFloat(size.substring(0, size.length() - 1)); + } catch (Exception e) { + getLogger().warning("Unable to parse relative size"); + return -1; + } + } + + private static final Element escapeHtmlHelper = DOM.createDiv(); + + /** + * Converts html entities to text. + * + * @param html + * @return escaped string presentation of given html + */ + public static String escapeHTML(String html) { + DOM.setInnerText(escapeHtmlHelper, html); + String escapedText = DOM.getInnerHTML(escapeHtmlHelper); + if (BrowserInfo.get().isIE8()) { + // #7478 IE8 "incorrectly" returns "<br>" for newlines set using + // setInnerText. The same for " " which is converted to " " + escapedText = escapedText.replaceAll("<(BR|br)>", "\n"); + escapedText = escapedText.replaceAll(" ", " "); + } + return escapedText; + } + + /** + * Escapes the string so it is safe to write inside an HTML attribute. + * + * @param attribute + * The string to escape + * @return An escaped version of <literal>attribute</literal>. + */ + public static String escapeAttribute(String attribute) { + if (attribute == null) { + return ""; + } + attribute = attribute.replace("\"", """); + attribute = attribute.replace("'", "'"); + attribute = attribute.replace(">", ">"); + attribute = attribute.replace("<", "<"); + attribute = attribute.replace("&", "&"); + return attribute; + } + + /** + * Clones given element as in JavaScript. + * + * Deprecate this if there appears similar method into GWT someday. + * + * @param element + * @param deep + * clone child tree also + * @return + */ + public static native Element cloneNode(Element element, boolean deep) + /*-{ + return element.cloneNode(deep); + }-*/; + + public static int measureHorizontalPaddingAndBorder(Element element, + int paddingGuess) { + String originalWidth = DOM.getStyleAttribute(element, "width"); + + int originalOffsetWidth = element.getOffsetWidth(); + int widthGuess = (originalOffsetWidth - paddingGuess); + if (widthGuess < 1) { + widthGuess = 1; + } + element.getStyle().setWidth(widthGuess, Unit.PX); + int padding = element.getOffsetWidth() - widthGuess; + + element.getStyle().setProperty("width", originalWidth); + + return padding; + } + + public static int measureVerticalPaddingAndBorder(Element element, + int paddingGuess) { + String originalHeight = DOM.getStyleAttribute(element, "height"); + int originalOffsetHeight = element.getOffsetHeight(); + int widthGuess = (originalOffsetHeight - paddingGuess); + if (widthGuess < 1) { + widthGuess = 1; + } + element.getStyle().setHeight(widthGuess, Unit.PX); + int padding = element.getOffsetHeight() - widthGuess; + + element.getStyle().setProperty("height", originalHeight); + return padding; + } + + public static int measureHorizontalBorder(Element element) { + int borders; + + if (BrowserInfo.get().isIE()) { + String width = element.getStyle().getProperty("width"); + String height = element.getStyle().getProperty("height"); + + int offsetWidth = element.getOffsetWidth(); + int offsetHeight = element.getOffsetHeight(); + if (offsetHeight < 1) { + offsetHeight = 1; + } + if (offsetWidth < 1) { + offsetWidth = 10; + } + element.getStyle().setPropertyPx("height", offsetHeight); + element.getStyle().setPropertyPx("width", offsetWidth); + + borders = element.getOffsetWidth() - element.getClientWidth(); + + element.getStyle().setProperty("width", width); + element.getStyle().setProperty("height", height); + } else { + borders = element.getOffsetWidth() + - element.getPropertyInt("clientWidth"); + } + assert borders >= 0; + + return borders; + } + + public static int measureVerticalBorder(Element element) { + int borders; + if (BrowserInfo.get().isIE()) { + String width = element.getStyle().getProperty("width"); + String height = element.getStyle().getProperty("height"); + + int offsetWidth = element.getOffsetWidth(); + int offsetHeight = element.getOffsetHeight(); + if (offsetHeight < 1) { + offsetHeight = 1; + } + if (offsetWidth < 1) { + offsetWidth = 10; + } + element.getStyle().setPropertyPx("width", offsetWidth); + + element.getStyle().setPropertyPx("height", offsetHeight); + + borders = element.getOffsetHeight() + - element.getPropertyInt("clientHeight"); + + element.getStyle().setProperty("height", height); + element.getStyle().setProperty("width", width); + } else { + borders = element.getOffsetHeight() + - element.getPropertyInt("clientHeight"); + } + assert borders >= 0; + + return borders; + } + + public static int measureMarginLeft(Element element) { + return element.getAbsoluteLeft() + - element.getParentElement().getAbsoluteLeft(); + } + + public static int setHeightExcludingPaddingAndBorder(Widget widget, + String height, int paddingBorderGuess) { + if (height.equals("")) { + setHeight(widget, ""); + return paddingBorderGuess; + } else if (height.endsWith("px")) { + int pixelHeight = Integer.parseInt(height.substring(0, + height.length() - 2)); + return setHeightExcludingPaddingAndBorder(widget.getElement(), + pixelHeight, paddingBorderGuess, false); + } else { + // Set the height in unknown units + setHeight(widget, height); + // Use the offsetWidth + return setHeightExcludingPaddingAndBorder(widget.getElement(), + widget.getOffsetHeight(), paddingBorderGuess, true); + } + } + + private static void setWidth(Widget widget, String width) { + widget.getElement().getStyle().setProperty("width", width); + } + + private static void setHeight(Widget widget, String height) { + widget.getElement().getStyle().setProperty("height", height); + } + + public static int setWidthExcludingPaddingAndBorder(Widget widget, + String width, int paddingBorderGuess) { + if (width.equals("")) { + setWidth(widget, ""); + return paddingBorderGuess; + } else if (width.endsWith("px")) { + int pixelWidth = Integer.parseInt(width.substring(0, + width.length() - 2)); + return setWidthExcludingPaddingAndBorder(widget.getElement(), + pixelWidth, paddingBorderGuess, false); + } else { + setWidth(widget, width); + return setWidthExcludingPaddingAndBorder(widget.getElement(), + widget.getOffsetWidth(), paddingBorderGuess, true); + } + } + + public static int setWidthExcludingPaddingAndBorder(Element element, + int requestedWidth, int horizontalPaddingBorderGuess, + boolean requestedWidthIncludesPaddingBorder) { + + int widthGuess = requestedWidth - horizontalPaddingBorderGuess; + if (widthGuess < 0) { + widthGuess = 0; + } + + element.getStyle().setWidth(widthGuess, Unit.PX); + int captionOffsetWidth = DOM.getElementPropertyInt(element, + "offsetWidth"); + + int actualPadding = captionOffsetWidth - widthGuess; + + if (requestedWidthIncludesPaddingBorder) { + actualPadding += actualPadding; + } + + if (actualPadding != horizontalPaddingBorderGuess) { + int w = requestedWidth - actualPadding; + if (w < 0) { + // Cannot set negative width even if we would want to + w = 0; + } + element.getStyle().setWidth(w, Unit.PX); + + } + + return actualPadding; + + } + + public static int setHeightExcludingPaddingAndBorder(Element element, + int requestedHeight, int verticalPaddingBorderGuess, + boolean requestedHeightIncludesPaddingBorder) { + + int heightGuess = requestedHeight - verticalPaddingBorderGuess; + if (heightGuess < 0) { + heightGuess = 0; + } + + element.getStyle().setHeight(heightGuess, Unit.PX); + int captionOffsetHeight = DOM.getElementPropertyInt(element, + "offsetHeight"); + + int actualPadding = captionOffsetHeight - heightGuess; + + if (requestedHeightIncludesPaddingBorder) { + actualPadding += actualPadding; + } + + if (actualPadding != verticalPaddingBorderGuess) { + int h = requestedHeight - actualPadding; + if (h < 0) { + // Cannot set negative height even if we would want to + h = 0; + } + element.getStyle().setHeight(h, Unit.PX); + + } + + return actualPadding; + + } + + public static void setFloat(Element element, String value) { + if (BrowserInfo.get().isIE()) { + element.getStyle().setProperty("styleFloat", value); + } else { + element.getStyle().setProperty("cssFloat", value); + } + } + + private static int detectedScrollbarSize = -1; + + public static int getNativeScrollbarSize() { + if (detectedScrollbarSize < 0) { + Element scroller = DOM.createDiv(); + scroller.getStyle().setProperty("width", "50px"); + scroller.getStyle().setProperty("height", "50px"); + scroller.getStyle().setProperty("overflow", "scroll"); + scroller.getStyle().setProperty("position", "absolute"); + scroller.getStyle().setProperty("marginLeft", "-5000px"); + RootPanel.getBodyElement().appendChild(scroller); + detectedScrollbarSize = scroller.getOffsetWidth() + - scroller.getPropertyInt("clientWidth"); + + RootPanel.getBodyElement().removeChild(scroller); + } + return detectedScrollbarSize; + } + + /** + * Defers the execution of {@link #runWebkitOverflowAutoFix(Element)} + * + * @since 7.2.6 + * @param elem + * with overflow auto + */ + public static void runWebkitOverflowAutoFixDeferred(final Element elem) { + Scheduler.get().scheduleDeferred(new Command() { + + @Override + public void execute() { + WidgetUtil.runWebkitOverflowAutoFix(elem); + } + }); + + } + + /** + * Run workaround for webkits overflow auto issue. + * + * See: our bug #2138 and https://bugs.webkit.org/show_bug.cgi?id=21462 + * + * @param elem + * with overflow auto + */ + public static void runWebkitOverflowAutoFix(final Element elem) { + // Add max version if fix lands sometime to Webkit + // Starting from Opera 11.00, also a problem in Opera + if (BrowserInfo.get().requiresOverflowAutoFix()) { + final String originalOverflow = elem.getStyle().getProperty( + "overflow"); + if ("hidden".equals(originalOverflow)) { + return; + } + + // check the scrolltop value before hiding the element + final int scrolltop = elem.getScrollTop(); + final int scrollleft = elem.getScrollLeft(); + elem.getStyle().setProperty("overflow", "hidden"); + + Scheduler.get().scheduleDeferred(new Command() { + @Override + public void execute() { + // Dough, Safari scroll auto means actually just a moped + elem.getStyle().setProperty("overflow", originalOverflow); + + if (scrolltop > 0 || elem.getScrollTop() > 0) { + int scrollvalue = scrolltop; + if (scrollvalue == 0) { + // mysterious are the ways of webkits scrollbar + // handling. In some cases webkit reports bad (0) + // scrolltop before hiding the element temporary, + // sometimes after. + scrollvalue = elem.getScrollTop(); + } + // fix another bug where scrollbar remains in wrong + // position + elem.setScrollTop(scrollvalue - 1); + elem.setScrollTop(scrollvalue); + } + + // fix for #6940 : Table horizontal scroll sometimes not + // updated when collapsing/expanding columns + // Also appeared in Safari 5.1 with webkit 534 (#7667) + if ((BrowserInfo.get().isChrome() || (BrowserInfo.get() + .isSafari() && BrowserInfo.get().getWebkitVersion() >= 534)) + && (scrollleft > 0 || elem.getScrollLeft() > 0)) { + int scrollvalue = scrollleft; + + if (scrollvalue == 0) { + // mysterious are the ways of webkits scrollbar + // handling. In some cases webkit may report a bad + // (0) scrollleft before hiding the element + // temporary, sometimes after. + scrollvalue = elem.getScrollLeft(); + } + // fix another bug where scrollbar remains in wrong + // position + elem.setScrollLeft(scrollvalue - 1); + elem.setScrollLeft(scrollvalue); + } + } + }); + } + + } + + public static void alert(String string) { + if (true) { + Window.alert(string); + } + } + + /** + * Gets the border-box width for the given element, i.e. element width + + * border + padding. Always rounds up to nearest integer. + * + * @param element + * The element to check + * @return The border-box width for the element + */ + public static int getRequiredWidth(com.google.gwt.dom.client.Element element) { + int reqWidth = getRequiredWidthBoundingClientRect(element); + if (BrowserInfo.get().isIE() && !BrowserInfo.get().isIE8()) { + int csSize = getRequiredWidthComputedStyle(element); + if (csSize == reqWidth + 1) { + // If computed style reports one pixel larger than requiredWidth + // we would be rounding in the wrong direction in IE9. Round up + // instead. + // We do not always use csSize as it e.g. for 100% wide Labels + // in GridLayouts produces senseless values (see e.g. + // ThemeTestUI with Runo). + return csSize; + } + } + return reqWidth; + } + + /** + * Gets the border-box height for the given element, i.e. element height + + * border + padding. Always rounds up to nearest integer. + * + * @param element + * The element to check + * @return The border-box height for the element + */ + public static int getRequiredHeight( + com.google.gwt.dom.client.Element element) { + int reqHeight = getRequiredHeightBoundingClientRect(element); + if (BrowserInfo.get().isIE() && !BrowserInfo.get().isIE8()) { + int csSize = getRequiredHeightComputedStyle(element); + if (csSize == reqHeight + 1) { + // If computed style reports one pixel larger than + // requiredHeight we would be rounding in the wrong direction in + // IE9. Round up instead. + // We do not always use csSize as it e.g. for 100% wide Labels + // in GridLayouts produces senseless values (see e.g. + // ThemeTestUI with Runo). + return csSize; + } + } + return reqHeight; + } + + /** + * Calculates the width of the element's bounding rectangle. + * <p> + * In case the browser doesn't support bounding rectangles, the returned + * value is the offset width. + * + * @param element + * the element of which to calculate the width + * @return the width of the element + */ + public static int getRequiredWidthBoundingClientRect( + com.google.gwt.dom.client.Element element) { + return (int) getRequiredWidthBoundingClientRectDouble(element); + } + + /** + * Calculates the width of the element's bounding rectangle to subpixel + * precision. + * <p> + * In case the browser doesn't support bounding rectangles, the returned + * value is the offset width. + * + * @param element + * the element of which to calculate the width + * @return the subpixel-accurate width of the element + * @since 7.4 + */ + public static native double getRequiredWidthBoundingClientRectDouble( + com.google.gwt.dom.client.Element element) + /*-{ + if (element.getBoundingClientRect) { + var rect = element.getBoundingClientRect(); + return Math.ceil(rect.right - rect.left); + } else { + return element.offsetWidth; + } + }-*/; + + public static native int getRequiredHeightComputedStyle( + com.google.gwt.dom.client.Element element) + /*-{ + var cs = element.ownerDocument.defaultView.getComputedStyle(element); + var heightPx = cs.height; + if(heightPx == 'auto'){ + // Fallback for when IE reports auto + heightPx = @com.vaadin.client.WidgetUtil::getRequiredHeightBoundingClientRect(Lcom/google/gwt/dom/client/Element;)(element) + 'px'; + } + var borderTopPx = cs.borderTop; + var borderBottomPx = cs.borderBottom; + var paddingTopPx = cs.paddingTop; + var paddingBottomPx = cs.paddingBottom; + + var height = heightPx.substring(0,heightPx.length-2); + var border = borderTopPx.substring(0,borderTopPx.length-2)+borderBottomPx.substring(0,borderBottomPx.length-2); + var padding = paddingTopPx.substring(0,paddingTopPx.length-2)+paddingBottomPx.substring(0,paddingBottomPx.length-2); + return Math.ceil(height+border+padding); + }-*/; + + public static native int getRequiredWidthComputedStyle( + com.google.gwt.dom.client.Element element) + /*-{ + var cs = element.ownerDocument.defaultView.getComputedStyle(element); + var widthPx = cs.width; + if(widthPx == 'auto'){ + // Fallback for when IE reports auto + widthPx = @com.vaadin.client.WidgetUtil::getRequiredWidthBoundingClientRect(Lcom/google/gwt/dom/client/Element;)(element) + 'px'; + } + var borderLeftPx = cs.borderLeft; + var borderRightPx = cs.borderRight; + var paddingLeftPx = cs.paddingLeft; + var paddingRightPx = cs.paddingRight; + + var width = widthPx.substring(0,widthPx.length-2); + var border = borderLeftPx.substring(0,borderLeftPx.length-2)+borderRightPx.substring(0,borderRightPx.length-2); + var padding = paddingLeftPx.substring(0,paddingLeftPx.length-2)+paddingRightPx.substring(0,paddingRightPx.length-2); + return Math.ceil(width+border+padding); + }-*/; + + /** + * Calculates the height of the element's bounding rectangle. + * <p> + * In case the browser doesn't support bounding rectangles, the returned + * value is the offset height. + * + * @param element + * the element of which to calculate the height + * @return the height of the element + */ + public static int getRequiredHeightBoundingClientRect( + com.google.gwt.dom.client.Element element) { + return (int) getRequiredHeightBoundingClientRectDouble(element); + } + + /** + * Calculates the height of the element's bounding rectangle to subpixel + * precision. + * <p> + * In case the browser doesn't support bounding rectangles, the returned + * value is the offset height. + * + * @param element + * the element of which to calculate the height + * @return the subpixel-accurate height of the element + * @since 7.4 + */ + public static native double getRequiredHeightBoundingClientRectDouble( + com.google.gwt.dom.client.Element element) + /*-{ + var height; + if (element.getBoundingClientRect != null) { + var rect = element.getBoundingClientRect(); + height = Math.ceil(rect.bottom - rect.top); + } else { + height = element.offsetHeight; + } + return height; + }-*/; + + public static int getRequiredWidth(Widget widget) { + return getRequiredWidth(widget.getElement()); + } + + public static int getRequiredHeight(Widget widget) { + return getRequiredHeight(widget.getElement()); + } + + /** + * Detects what is currently the overflow style attribute in given element. + * + * @param pe + * the element to detect + * @return true if auto or scroll + */ + public static boolean mayHaveScrollBars(com.google.gwt.dom.client.Element pe) { + String overflow = getComputedStyle(pe, "overflow"); + if (overflow != null) { + if (overflow.equals("auto") || overflow.equals("scroll")) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + /** + * A simple helper method to detect "computed style" (aka style sheets + + * element styles). Values returned differ a lot depending on browsers. + * Always be very careful when using this. + * + * @param el + * the element from which the style property is detected + * @param p + * the property to detect + * @return String value of style property + */ + private static native String getComputedStyle( + com.google.gwt.dom.client.Element el, String p) + /*-{ + try { + + if (el.currentStyle) { + // IE + return el.currentStyle[p]; + } else if (window.getComputedStyle) { + // Sa, FF, Opera + var view = el.ownerDocument.defaultView; + return view.getComputedStyle(el,null).getPropertyValue(p); + } else { + // fall back for non IE, Sa, FF, Opera + return ""; + } + } catch (e) { + return ""; + } + + }-*/; + + /** + * Will (attempt) to focus the given DOM Element. + * + * @param el + * the element to focus + */ + public static native void focus(Element el) + /*-{ + try { + el.focus(); + } catch (e) { + + } + }-*/; + + /** + * Helper method to find first instance of given Widget type found by + * traversing DOM upwards from given element. + * <p> + * <strong>Note:</strong> If {@code element} is inside some widget {@code W} + * , <em>and</em> {@code W} in turn is wrapped in a {@link Composite} + * {@code C}, this method will not find {@code W}. It returns either + * {@code C} or null, depending on whether the class parameter matches. This + * may also be the case with other Composite-like classes that hijack the + * event handling of their child widget(s). + * + * @param element + * the element where to start seeking of Widget + * @param class1 + * the Widget type to seek for + */ + @SuppressWarnings("unchecked") + public static <T> T findWidget(Element element, + Class<? extends Widget> class1) { + if (element != null) { + /* First seek for the first EventListener (~Widget) from dom */ + EventListener eventListener = null; + while (eventListener == null && element != null) { + eventListener = Event.getEventListener(element); + if (eventListener == null) { + element = element.getParentElement(); + } + } + if (eventListener instanceof Widget) { + /* + * Then find the first widget of type class1 from widget + * hierarchy + */ + Widget w = (Widget) eventListener; + while (w != null) { + if (class1 == null || w.getClass() == class1) { + return (T) w; + } + w = w.getParent(); + } + } + } + return null; + } + + /** + * Force webkit to redraw an element + * + * @param element + * The element that should be redrawn + */ + public static void forceWebkitRedraw(Element element) { + Style style = element.getStyle(); + String s = style.getProperty("webkitTransform"); + if (s == null || s.length() == 0) { + style.setProperty("webkitTransform", "scale(1)"); + } else { + style.setProperty("webkitTransform", ""); + } + } + + /** + * Performs a hack to trigger a re-layout in the IE8. This is usually + * necessary in cases where IE8 "forgets" to update child elements when they + * resize. + * + * @param e + * The element to perform the hack on + */ + public static final void forceIE8Redraw(Element e) { + if (BrowserInfo.get().isIE8()) { + forceIERedraw(e); + } + } + + /** + * Performs a hack to trigger a re-layout in the IE browser. This is usually + * necessary in cases where IE "forgets" to update child elements when they + * resize. + * + * @since 7.3 + * @param e + * The element to perform the hack on + */ + public static void forceIERedraw(Element e) { + if (BrowserInfo.get().isIE()) { + setStyleTemporarily(e, "zoom", "1"); + } + } + + /** + * Detaches and re-attaches the element from its parent. The element is + * reattached at the same position in the DOM as it was before. + * + * Does nothing if the element is not attached to the DOM. + * + * @param element + * The element to detach and re-attach + */ + public static void detachAttach(Element element) { + if (element == null) { + return; + } + + Node nextSibling = element.getNextSibling(); + Node parent = element.getParentNode(); + if (parent == null) { + return; + } + + parent.removeChild(element); + if (nextSibling == null) { + parent.appendChild(element); + } else { + parent.insertBefore(element, nextSibling); + } + + } + + public static void sinkOnloadForImages(Element element) { + NodeList<com.google.gwt.dom.client.Element> imgElements = element + .getElementsByTagName("img"); + for (int i = 0; i < imgElements.getLength(); i++) { + DOM.sinkEvents(imgElements.getItem(i), Event.ONLOAD); + } + + } + + /** + * Returns the index of the childElement within its parent. + * + * @param subElement + * @return + */ + public static int getChildElementIndex(Element childElement) { + int idx = 0; + Node n = childElement; + while ((n = n.getPreviousSibling()) != null) { + idx++; + } + + return idx; + } + + /** + * Temporarily sets the {@code styleProperty} to {@code tempValue} and then + * resets it to its current value. Used mainly to work around rendering + * issues in IE (and possibly in other browsers) + * + * @param element + * The target element + * @param styleProperty + * The name of the property to set + * @param tempValue + * The temporary value + */ + public static void setStyleTemporarily(Element element, + final String styleProperty, String tempValue) { + final Style style = element.getStyle(); + final String currentValue = style.getProperty(styleProperty); + + style.setProperty(styleProperty, tempValue); + element.getOffsetWidth(); + style.setProperty(styleProperty, currentValue); + + } + + /** + * A helper method to return the client position from an event. Returns + * position from either first changed touch (if touch event) or from the + * event itself. + * + * @param event + * @return + */ + public static int getTouchOrMouseClientX(Event event) { + if (isTouchEvent(event)) { + return event.getChangedTouches().get(0).getClientX(); + } else { + return event.getClientX(); + } + } + + /** + * Find the element corresponding to the coordinates in the passed mouse + * event. Please note that this is not always the same as the target of the + * event e.g. if event capture is used. + * + * @param event + * the mouse event to get coordinates from + * @return the element at the coordinates of the event + */ + public static Element getElementUnderMouse(NativeEvent event) { + int pageX = getTouchOrMouseClientX(event); + int pageY = getTouchOrMouseClientY(event); + + return getElementFromPoint(pageX, pageY); + } + + /** + * A helper method to return the client position from an event. Returns + * position from either first changed touch (if touch event) or from the + * event itself. + * + * @param event + * @return + */ + public static int getTouchOrMouseClientY(Event event) { + if (isTouchEvent(event)) { + return event.getChangedTouches().get(0).getClientY(); + } else { + return event.getClientY(); + } + } + + /** + * + * @see #getTouchOrMouseClientY(Event) + * @param currentGwtEvent + * @return + */ + public static int getTouchOrMouseClientY(NativeEvent currentGwtEvent) { + return getTouchOrMouseClientY(Event.as(currentGwtEvent)); + } + + /** + * @see #getTouchOrMouseClientX(Event) + * + * @param event + * @return + */ + public static int getTouchOrMouseClientX(NativeEvent event) { + return getTouchOrMouseClientX(Event.as(event)); + } + + public static boolean isTouchEvent(Event event) { + return event.getType().contains("touch"); + } + + public static boolean isTouchEvent(NativeEvent event) { + return isTouchEvent(Event.as(event)); + } + + public static void simulateClickFromTouchEvent(Event touchevent, + Widget widget) { + Touch touch = touchevent.getChangedTouches().get(0); + final NativeEvent createMouseUpEvent = Document.get() + .createMouseUpEvent(0, touch.getScreenX(), touch.getScreenY(), + touch.getClientX(), touch.getClientY(), false, false, + false, false, NativeEvent.BUTTON_LEFT); + final NativeEvent createMouseDownEvent = Document.get() + .createMouseDownEvent(0, touch.getScreenX(), + touch.getScreenY(), touch.getClientX(), + touch.getClientY(), false, false, false, false, + NativeEvent.BUTTON_LEFT); + final NativeEvent createMouseClickEvent = Document.get() + .createClickEvent(0, touch.getScreenX(), touch.getScreenY(), + touch.getClientX(), touch.getClientY(), false, false, + false, false); + + /* + * Get target with element from point as we want the actual element, not + * the one that sunk the event. + */ + final Element target = getElementFromPoint(touch.getClientX(), + touch.getClientY()); + + /* + * Fixes infocusable form fields in Safari of iOS 5.x and some Android + * browsers. + */ + Widget targetWidget = findWidget(target, null); + if (targetWidget instanceof com.google.gwt.user.client.ui.Focusable) { + final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) targetWidget; + toBeFocusedWidget.setFocus(true); + } else if (targetWidget instanceof Focusable) { + ((Focusable) targetWidget).focus(); + } + + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override + public void execute() { + try { + target.dispatchEvent(createMouseDownEvent); + target.dispatchEvent(createMouseUpEvent); + target.dispatchEvent(createMouseClickEvent); + } catch (Exception e) { + } + + } + }); + + } + + /** + * Gets the currently focused element. + * + * @return The active element or null if no active element could be found. + */ + public native static Element getFocusedElement() + /*-{ + if ($wnd.document.activeElement) { + return $wnd.document.activeElement; + } + + return null; + }-*/; + + /** + * Gets currently focused element and checks if it's editable + * + * @since 7.4 + * + * @return true if focused element is editable + */ + public static boolean isFocusedElementEditable() { + Element focusedElement = WidgetUtil.getFocusedElement(); + if (focusedElement != null) { + String tagName = focusedElement.getTagName(); + String contenteditable = focusedElement + .getAttribute("contenteditable"); + + return "textarea".equalsIgnoreCase(tagName) + || "input".equalsIgnoreCase(tagName) + || "true".equalsIgnoreCase(contenteditable); + } + return false; + } + + /** + * Kind of stronger version of isAttached(). In addition to std isAttached, + * this method checks that this widget nor any of its parents is hidden. Can + * be e.g used to check whether component should react to some events or + * not. + * + * @param widget + * @return true if attached and displayed + */ + public static boolean isAttachedAndDisplayed(Widget widget) { + if (widget.isAttached()) { + /* + * Failfast using offset size, then by iterating the widget tree + */ + boolean notZeroSized = widget.getOffsetHeight() > 0 + || widget.getOffsetWidth() > 0; + return notZeroSized || checkVisibilityRecursively(widget); + } else { + return false; + } + } + + private static boolean checkVisibilityRecursively(Widget widget) { + if (widget.isVisible()) { + Widget parent = widget.getParent(); + if (parent == null) { + return true; // root panel + } else { + return checkVisibilityRecursively(parent); + } + } else { + return false; + } + } + + /** + * Scrolls an element into view vertically only. Modified version of + * Element.scrollIntoView. + * + * @param elem + * The element to scroll into view + */ + public static native void scrollIntoViewVertically(Element elem) + /*-{ + var top = elem.offsetTop; + var height = elem.offsetHeight; + + if (elem.parentNode != elem.offsetParent) { + top -= elem.parentNode.offsetTop; + } + + var cur = elem.parentNode; + while (cur && (cur.nodeType == 1)) { + if (top < cur.scrollTop) { + cur.scrollTop = top; + } + if (top + height > cur.scrollTop + cur.clientHeight) { + cur.scrollTop = (top + height) - cur.clientHeight; + } + + var offsetTop = cur.offsetTop; + if (cur.parentNode != cur.offsetParent) { + offsetTop -= cur.parentNode.offsetTop; + } + + top += offsetTop - cur.scrollTop; + cur = cur.parentNode; + } + }-*/; + + /** + * Checks if the given event is either a touch event or caused by the left + * mouse button + * + * @param event + * @return true if the event is a touch event or caused by the left mouse + * button, false otherwise + */ + public static boolean isTouchEventOrLeftMouseButton(Event event) { + boolean touchEvent = WidgetUtil.isTouchEvent(event); + return touchEvent || event.getButton() == Event.BUTTON_LEFT; + } + + /** + * Resolve a relative URL to an absolute URL based on the current document's + * location. + * + * @param url + * a string with the relative URL to resolve + * @return the corresponding absolute URL as a string + */ + public static String getAbsoluteUrl(String url) { + if (BrowserInfo.get().isIE8()) { + // The hard way - must use innerHTML and attach to DOM in IE8 + DivElement divElement = Document.get().createDivElement(); + divElement.getStyle().setDisplay(Display.NONE); + + RootPanel.getBodyElement().appendChild(divElement); + divElement.setInnerHTML("<a href='" + escapeAttribute(url) + + "' ></a>"); + + AnchorElement a = divElement.getChild(0).cast(); + String href = a.getHref(); + + RootPanel.getBodyElement().removeChild(divElement); + return href; + } else { + AnchorElement a = Document.get().createAnchorElement(); + a.setHref(url); + return a.getHref(); + } + } + + /** + * Sets the selection range of an input element. + * + * We need this JSNI function to set selection range so that we can use the + * optional direction attribute to set the anchor to the end and the focus + * to the start. This makes Firefox work the same way as other browsers + * (#13477) + * + * @param elem + * the html input element. + * @param pos + * the index of the first selected character. + * @param length + * the selection length. + * @param direction + * a string indicating the direction in which the selection was + * performed. This may be "forward" or "backward", or "none" if + * the direction is unknown or irrelevant. + * + * @since 7.3 + */ + public native static void setSelectionRange(Element elem, int pos, + int length, String direction) + /*-{ + try { + elem.setSelectionRange(pos, pos + length, direction); + } catch (e) { + // Firefox throws exception if TextBox is not visible, even if attached + } + }-*/; + + /** + * The allowed value inaccuracy when comparing two double-typed pixel + * values. + * <p> + * Since we're comparing pixels on a screen, epsilon must be less than 1. + * 0.49 was deemed a perfectly fine and beautifully round number. + */ + public static final double PIXEL_EPSILON = 0.49d; + + /** + * Compares two double values with the error margin of + * {@link #PIXEL_EPSILON} (i.e. {@value #PIXEL_EPSILON}) + * + * @param num1 + * the first value for which to compare equality + * @param num2 + * the second value for which to compare equality + * @since 7.4 + * + * @return true if the values are considered equals; false otherwise + */ + public static boolean pixelValuesEqual(final double num1, final double num2) { + return Math.abs(num1 - num2) <= PIXEL_EPSILON; + } + + /** + * Wrap a css size value and its unit and translate back and forth to the + * string representation.<br/> + * Eg. 50%, 123px, ... + * + * @since 7.2.6 + * @author Vaadin Ltd + */ + @SuppressWarnings("serial") + public static class CssSize implements Serializable { + + /* + * Map the size units with their type. + */ + private static Map<String, Unit> type2Unit = new HashMap<String, Style.Unit>(); + static { + for (Unit unit : Unit.values()) { + type2Unit.put(unit.getType(), unit); + } + } + + /** + * Gets the unit value by its type. + * + * @param type + * the type of the unit as found in the style. + * @return the unit value. + */ + public static Unit unitByType(String type) { + return type2Unit.get(type); + } + + /* + * Regex to parse the size. + */ + private static final RegExp sizePattern = RegExp + .compile(SharedUtil.SIZE_PATTERN); + + /** + * Parse the size from string format to {@link CssSize}. + * + * @param s + * the size as string. + * @return a {@link CssSize} object. + */ + public static CssSize fromString(String s) { + if (s == null) { + return null; + } + + s = s.trim(); + if ("".equals(s)) { + return null; + } + + float size = 0; + Unit unit = null; + + MatchResult matcher = sizePattern.exec(s); + if (matcher.getGroupCount() > 1) { + + size = Float.parseFloat(matcher.getGroup(1)); + if (size < 0) { + size = -1; + unit = Unit.PX; + + } else { + String symbol = matcher.getGroup(2); + unit = unitByType(symbol); + } + } else { + throw new IllegalArgumentException("Invalid size argument: \"" + + s + "\" (should match " + sizePattern.getSource() + + ")"); + } + return new CssSize(size, unit); + } + + /** + * Creates a {@link CssSize} using a value and its measurement unit. + * + * @param value + * the value. + * @param unit + * the unit. + * @return the {@link CssSize} object. + */ + public static CssSize fromValueUnit(float value, Unit unit) { + return new CssSize(value, unit); + } + + /* + * The value. + */ + private final float value; + + /* + * The measure unit. + */ + private final Unit unit; + + private CssSize(float value, Unit unit) { + this.value = value; + this.unit = unit; + } + + /** + * Gets the value for this css size. + * + * @return the value. + */ + public float getValue() { + return value; + } + + /** + * Gets the measurement unit for this css size. + * + * @return the unit. + */ + public Unit getUnit() { + return unit; + } + + @Override + public String toString() { + return value + unit.getType(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof CssSize) { + CssSize size = (CssSize) obj; + return size.value == value && size.unit == unit; + } + + return false; + } + + /** + * Check whether the two sizes are equals. + * + * @param cssSize1 + * the first size to compare. + * @param cssSize2 + * the other size to compare with the first one. + * @return true if the two sizes are equals, otherwise false. + */ + public static boolean equals(String cssSize1, String cssSize2) { + return CssSize.fromString(cssSize1).equals( + CssSize.fromString(cssSize2)); + } + + } + + private static Logger getLogger() { + return Logger.getLogger(WidgetUtil.class.getName()); + } + +} diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java index 628933fd86..dc8d497a69 100644 --- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java @@ -30,6 +30,7 @@ import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.VConsole; import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.Version; import com.vaadin.shared.communication.PushConstants; import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; @@ -514,16 +515,10 @@ public class AtmospherePushConnection implements PushConnection { }-*/; private void runWhenAtmosphereLoaded(final Command command) { - if (isAtmosphereLoaded()) { command.execute(); } else { - final String pushJs; - if (ApplicationConfiguration.isProductionMode()) { - pushJs = ApplicationConstants.VAADIN_PUSH_JS; - } else { - pushJs = ApplicationConstants.VAADIN_PUSH_DEBUG_JS; - } + final String pushJs = getVersionedPushJs(); VConsole.log("Loading " + pushJs); ResourceLoader.get().loadScript( @@ -553,6 +548,18 @@ public class AtmospherePushConnection implements PushConnection { } } + private String getVersionedPushJs() { + String pushJs; + if (ApplicationConfiguration.isProductionMode()) { + pushJs = ApplicationConstants.VAADIN_PUSH_JS; + } else { + pushJs = ApplicationConstants.VAADIN_PUSH_DEBUG_JS; + } + // Parameter appended to bypass caches after version upgrade. + pushJs += "?v=" + Version.getFullVersion(); + return pushJs; + } + /* * (non-Javadoc) * diff --git a/client/src/com/vaadin/client/communication/JsonDecoder.java b/client/src/com/vaadin/client/communication/JsonDecoder.java index a8adbac0c6..0ce89c873e 100644 --- a/client/src/com/vaadin/client/communication/JsonDecoder.java +++ b/client/src/com/vaadin/client/communication/JsonDecoder.java @@ -82,13 +82,16 @@ public class JsonDecoder { */ public static Object decodeValue(Type type, JsonValue jsonValue, Object target, ApplicationConnection connection) { + String baseTypeName = type.getBaseTypeName(); + if (baseTypeName.startsWith("elemental.json.Json")) { + return jsonValue; + } - // Null is null, regardless of type + // Null is null, regardless of type (except JSON) if (jsonValue.getType() == JsonType.NULL) { return null; } - String baseTypeName = type.getBaseTypeName(); if (Map.class.getName().equals(baseTypeName) || HashMap.class.getName().equals(baseTypeName)) { return decodeMap(type, jsonValue, connection); @@ -293,4 +296,14 @@ public class JsonDecoder { tokens.add(decodeValue(childType, entryValue, null, connection)); } } + + /** + * Called by generated deserialization code to treat a generic object as a + * JsonValue. This is needed because GWT refuses to directly cast String + * typed as Object into a JSO. + */ + public static native <T extends JsonValue> T obj2jso(Object object) + /*-{ + return object; + }-*/; } diff --git a/client/src/com/vaadin/client/communication/StateChangeEvent.java b/client/src/com/vaadin/client/communication/StateChangeEvent.java index 7db1d1b249..c2c1ceaea9 100644 --- a/client/src/com/vaadin/client/communication/StateChangeEvent.java +++ b/client/src/com/vaadin/client/communication/StateChangeEvent.java @@ -30,6 +30,7 @@ import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; import com.vaadin.client.ui.AbstractConnector; + import elemental.json.JsonObject; public class StateChangeEvent extends diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java index feb1c91767..0dfaf99cc1 100644 --- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -36,7 +36,6 @@ import com.vaadin.client.ApplicationConnection; public class ComponentLocator { private final List<LocatorStrategy> locatorStrategies; - private final LocatorStrategy legacyLocatorStrategy; /** * Reference to ApplicationConnection instance. @@ -52,9 +51,8 @@ public class ComponentLocator { */ public ComponentLocator(ApplicationConnection client) { this.client = client; - legacyLocatorStrategy = new LegacyLocatorStrategy(client); locatorStrategies = Arrays.asList(new VaadinFinderLocatorStrategy( - client), legacyLocatorStrategy); + client), new LegacyLocatorStrategy(client)); } /** @@ -115,24 +113,6 @@ public class ComponentLocator { } /** - * Returns a String locator which uniquely identifies the target element. - * The returned locator is in a legacy format that is suitable for Vaadin - * TestBench Recorder. For non-legacy format, use - * {@link #getPathForElement(com.google.gwt.user.client.Element)} instead. - * - * - * @since 7.4 - * @param targetElement - * The element to generate a path for. - * @return A String locator that identifies the target element or null if a - * String locator could not be created. - */ - public String getLegacyPathForElement(Element targetElement) { - return legacyLocatorStrategy - .getPathForElement(DOM.asOld(targetElement)); - } - - /** * Locates an element using a String locator (path) which identifies a DOM * element. The {@link #getPathForElement(Element)} method can be used for * the inverse operation, i.e. generating a string expression for a DOM diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 5df9854038..16f21d5d66 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -32,6 +32,7 @@ import com.vaadin.client.ConnectorMap; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.VCaption; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.VCssLayout; import com.vaadin.client.ui.VGridLayout; @@ -211,10 +212,10 @@ public class LegacyLocatorStrategy implements LocatorStrategy { // widget to which the path is relative. Otherwise, the current // implementation simply interprets the path as if baseElement was // null. - Widget baseWidget = Util.findWidget(baseElement, null); + Widget baseWidget = WidgetUtil.findWidget(baseElement, null); Widget w = getWidgetFromPath(widgetPath, baseWidget); - if (w == null || !Util.isAttachedAndDisplayed(w)) { + if (w == null || !WidgetUtil.isAttachedAndDisplayed(w)) { return null; } if (parts.length == 1) { @@ -333,7 +334,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { String childIndexString = part.substring("domChild[".length(), part.length() - 1); - if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { + if (WidgetUtil.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { if (element.hasChildNodes()) { Element e = element.getFirstChildElement().cast(); String cn = e.getClassName(); @@ -454,7 +455,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { if (basePath == null) { return null; } - String simpleName = Util.getSimpleName(w); + String simpleName = w.getClass().getSimpleName(); /* * Check if the parent implements Iterable. At least VPopupView does not @@ -474,7 +475,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { return basePath + PARENTCHILD_SEPARATOR + simpleName + "[" + pos + "]"; } - String simpleName2 = Util.getSimpleName(child); + String simpleName2 = child.getClass().getSimpleName(); if (simpleName.equals(simpleName2)) { pos++; } @@ -605,8 +606,8 @@ public class LegacyLocatorStrategy implements LocatorStrategy { // the same type before it int nextIndex = 0; for (Widget child : layout) { - boolean matchingType = nextWidgetClassName.equals(Util - .getSimpleName(child)); + boolean matchingType = nextWidgetClassName.equals(child + .getClass().getSimpleName()); if (matchingType && widgetPosition == 0) { // This is the n:th child that we looked for break; @@ -660,7 +661,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { while (iterator.hasNext()) { Widget child = iterator.next(); - String simpleName2 = Util.getSimpleName(child); + String simpleName2 = child.getClass().getSimpleName(); if (!widgetClassName.equals(simpleName2) && child instanceof Slot) { @@ -670,7 +671,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { * directly checking the stuff inside the slot */ child = ((Slot) child).getWidget(); - simpleName2 = Util.getSimpleName(child); + simpleName2 = child.getClass().getSimpleName(); } if (widgetClassName.equals(simpleName2)) { diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 44bdeddff3..ea0fd2042e 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -644,7 +644,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { // If the server-side class name didn't match, fall back to testing for // the explicit widget name - String widget = Util.getSimpleName(connector.getWidget()); + String widget = connector.getWidget().getClass().getSimpleName(); return widgetName.equals(widget) || widgetName.equals(widget + ".class"); diff --git a/client/src/com/vaadin/client/connectors/AbstractRendererConnector.java b/client/src/com/vaadin/client/connectors/AbstractRendererConnector.java index b258980fe1..f7e3c15ac8 100644 --- a/client/src/com/vaadin/client/connectors/AbstractRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/AbstractRendererConnector.java @@ -16,7 +16,6 @@ package com.vaadin.client.connectors; import com.vaadin.client.ServerConnector; -import com.vaadin.client.Util; import com.vaadin.client.communication.JsonDecoder; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.metadata.NoDataException; @@ -42,7 +41,7 @@ import elemental.json.JsonValue; * @param <T> * the presentation type of the renderer * - * @since + * @since 7.4 * @author Vaadin Ltd */ public abstract class AbstractRendererConnector<T> extends @@ -57,7 +56,7 @@ public abstract class AbstractRendererConnector<T> extends if (presentationType == null) { throw new IllegalStateException( "No presentation type found for " - + Util.getSimpleName(this) + + getClass().getSimpleName() + ". This may be caused by some unspecified problem in widgetset compilation."); } } @@ -110,7 +109,7 @@ public abstract class AbstractRendererConnector<T> extends } catch (NoDataException e) { throw new IllegalStateException( "Default implementation of createRenderer() does not work for " - + Util.getSimpleName(this) + + getClass().getSimpleName() + ". This might be caused by explicitely using " + "super.createRenderer() or some unspecified " + "problem with the widgetset compilation.", e); diff --git a/client/src/com/vaadin/client/connectors/ButtonRendererConnector.java b/client/src/com/vaadin/client/connectors/ButtonRendererConnector.java index a74db590da..44c34e3bf4 100644 --- a/client/src/com/vaadin/client/connectors/ButtonRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/ButtonRendererConnector.java @@ -25,7 +25,7 @@ import elemental.json.JsonObject; /** * A connector for {@link ButtonRenderer}. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.ButtonRenderer.class) diff --git a/client/src/com/vaadin/client/connectors/ClickableRendererConnector.java b/client/src/com/vaadin/client/connectors/ClickableRendererConnector.java index 90aaad7032..87f88c5106 100644 --- a/client/src/com/vaadin/client/connectors/ClickableRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/ClickableRendererConnector.java @@ -29,7 +29,7 @@ import elemental.json.JsonObject; * @param <T> * the presentation type of the renderer * - * @since + * @since 7.4 * @author Vaadin Ltd */ public abstract class ClickableRendererConnector<T> extends diff --git a/client/src/com/vaadin/client/connectors/DateRendererConnector.java b/client/src/com/vaadin/client/connectors/DateRendererConnector.java index 2df8184eaf..30d1db345d 100644 --- a/client/src/com/vaadin/client/connectors/DateRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/DateRendererConnector.java @@ -25,7 +25,7 @@ import com.vaadin.shared.ui.Connect; * string, and displayed as-is on the client side. This is to be able to support * the server's locale. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.DateRenderer.class) diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 0044025d40..450df31b36 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -87,7 +87,7 @@ import elemental.json.JsonValue; * at {@link com.vaadin.shared.data.DataProviderRpc#setRowData(int, List) * DataProviderRpc.setRowData(int, List)}. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.Grid.class) @@ -326,7 +326,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements */ private Map<String, CustomGridColumn> columnIdToColumn = new HashMap<String, CustomGridColumn>(); - private AbstractRowHandleSelectionModel<JsonObject> selectionModel = createSelectionModel(SharedSelectionMode.NONE); + private AbstractRowHandleSelectionModel<JsonObject> selectionModel; private Set<String> selectedKeys = new LinkedHashSet<String>(); private List<String> columnOrder = new ArrayList<String>(); @@ -356,7 +356,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements selectedKeys.add(dataSource.getRowKey(row)); } - getRpcProxy(GridServerRpc.class).selectionChange( + getRpcProxy(GridServerRpc.class).select( new ArrayList<String>(selectedKeys)); } else { updatedFromState = false; @@ -396,8 +396,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements } }); - getWidget().setSelectionModel(selectionModel); - getWidget().addSelectionHandler(internalSelectionChangeHandler); getWidget().addSortHandler(new SortHandler<JsonObject>() { @@ -751,7 +749,8 @@ public class GridConnector extends AbstractHasComponentsConnector implements } AbstractRowHandleSelectionModel<JsonObject> model = createSelectionModel(mode); - if (!model.getClass().equals(selectionModel.getClass())) { + if (selectionModel == null + || !model.getClass().equals(selectionModel.getClass())) { selectionModel = model; getWidget().setSelectionModel(model); selectedKeys.clear(); diff --git a/client/src/com/vaadin/client/connectors/ImageRendererConnector.java b/client/src/com/vaadin/client/connectors/ImageRendererConnector.java index 341a98e9a8..9000ebb1c2 100644 --- a/client/src/com/vaadin/client/connectors/ImageRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/ImageRendererConnector.java @@ -29,7 +29,7 @@ import elemental.json.JsonValue; /** * A connector for {@link ImageRenderer}. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.ImageRenderer.class) diff --git a/client/src/com/vaadin/client/connectors/NumberRendererConnector.java b/client/src/com/vaadin/client/connectors/NumberRendererConnector.java index 68c96d21bc..84b319710d 100644 --- a/client/src/com/vaadin/client/connectors/NumberRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/NumberRendererConnector.java @@ -26,7 +26,7 @@ import com.vaadin.shared.ui.Connect; * string, and displayed as-is on the client side. This is to be able to support * the server's locale. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.NumberRenderer.class) diff --git a/client/src/com/vaadin/client/connectors/ProgressBarRendererConnector.java b/client/src/com/vaadin/client/connectors/ProgressBarRendererConnector.java index 812a729da3..fe410ccbe7 100644 --- a/client/src/com/vaadin/client/connectors/ProgressBarRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/ProgressBarRendererConnector.java @@ -21,7 +21,7 @@ import com.vaadin.shared.ui.Connect; /** * A connector for {@link ProgressBarRenderer}. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.ProgressBarRenderer.class) diff --git a/client/src/com/vaadin/client/connectors/RpcDataSourceConnector.java b/client/src/com/vaadin/client/connectors/RpcDataSourceConnector.java index 754c87f0ca..c46db08553 100644 --- a/client/src/com/vaadin/client/connectors/RpcDataSourceConnector.java +++ b/client/src/com/vaadin/client/connectors/RpcDataSourceConnector.java @@ -39,7 +39,7 @@ import elemental.json.JsonValue; * connector type. This will be changed once framework support for something * more flexible has been implemented. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.data.RpcDataProviderExtension.class) diff --git a/client/src/com/vaadin/client/connectors/TextRendererConnector.java b/client/src/com/vaadin/client/connectors/TextRendererConnector.java index b610b3ed55..3059d3f8bb 100644 --- a/client/src/com/vaadin/client/connectors/TextRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/TextRendererConnector.java @@ -21,7 +21,7 @@ import com.vaadin.shared.ui.Connect; /** * A connector for {@link TextRenderer}. * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.TextRenderer.class) diff --git a/client/src/com/vaadin/client/connectors/UnsafeHtmlRendererConnector.java b/client/src/com/vaadin/client/connectors/UnsafeHtmlRendererConnector.java index 91833ae9ac..420f18427d 100644 --- a/client/src/com/vaadin/client/connectors/UnsafeHtmlRendererConnector.java +++ b/client/src/com/vaadin/client/connectors/UnsafeHtmlRendererConnector.java @@ -22,7 +22,7 @@ import com.vaadin.shared.ui.Connect; /** * A connector for {@link UnsafeHtmlRenderer} * - * @since + * @since 7.4 * @author Vaadin Ltd */ @Connect(com.vaadin.ui.renderer.HtmlRenderer.class) diff --git a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java index c6aa7c6291..ffd1d4d170 100644 --- a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java +++ b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java @@ -35,7 +35,7 @@ import com.vaadin.shared.ui.grid.Range; * {@link #requestRows(int, int, RequestRowsCallback)} to trigger asynchronously * loading of data and then pass the loaded data into the provided callback. * - * @since + * @since 7.4 * @author Vaadin Ltd * @param <T> * the row type diff --git a/client/src/com/vaadin/client/data/CacheStrategy.java b/client/src/com/vaadin/client/data/CacheStrategy.java index 3448659e61..79ce537314 100644 --- a/client/src/com/vaadin/client/data/CacheStrategy.java +++ b/client/src/com/vaadin/client/data/CacheStrategy.java @@ -22,7 +22,7 @@ import com.vaadin.shared.ui.grid.Range; * Determines what data an {@link AbstractRemoteDataSource} should fetch and * keep cached. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface CacheStrategy { diff --git a/client/src/com/vaadin/client/data/DataChangeHandler.java b/client/src/com/vaadin/client/data/DataChangeHandler.java index 57e25ef11a..35f1eafea9 100644 --- a/client/src/com/vaadin/client/data/DataChangeHandler.java +++ b/client/src/com/vaadin/client/data/DataChangeHandler.java @@ -20,7 +20,7 @@ package com.vaadin.client.data; * Callback interface used by {@link DataSource} to inform its user about * updates to the data. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface DataChangeHandler { diff --git a/client/src/com/vaadin/client/data/DataSource.java b/client/src/com/vaadin/client/data/DataSource.java index a4cff64078..076226bf5c 100644 --- a/client/src/com/vaadin/client/data/DataSource.java +++ b/client/src/com/vaadin/client/data/DataSource.java @@ -21,7 +21,7 @@ package com.vaadin.client.data; * items (e.g. rows) of a specified type. The data source is a lazy view into a * larger data set. * - * @since + * @since 7.4 * @author Vaadin Ltd * @param <T> * the row type diff --git a/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java b/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java index 1238d88345..fc9f3856b5 100644 --- a/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java +++ b/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java @@ -40,7 +40,6 @@ import com.vaadin.client.ComputedStyle; import com.vaadin.client.ConnectorMap; import com.vaadin.client.ServerConnector; import com.vaadin.client.SimpleTree; -import com.vaadin.client.Util; import com.vaadin.client.ValueMap; /** @@ -112,9 +111,12 @@ public class AnalyzeLayoutsPanel extends FlowPanel { final ServerConnector parent = connector.getParent(); final String parentId = parent.getConnectorId(); - final Label errorDetails = new Label(Util.getSimpleName(connector) - + "[" + connector.getConnectorId() + "]" + " inside " - + Util.getSimpleName(parent)); + final Label errorDetails = new Label(connector.getClass() + .getSimpleName() + + "[" + + connector.getConnectorId() + + "]" + + " inside " + parent.getClass().getSimpleName()); if (parent instanceof ComponentConnector) { final ComponentConnector parentConnector = (ComponentConnector) parent; @@ -171,8 +173,8 @@ public class AnalyzeLayoutsPanel extends FlowPanel { Highlight.show(connector); - final SimpleTree errorNode = new SimpleTree( - Util.getSimpleName(connector) + " id: " + pid); + final SimpleTree errorNode = new SimpleTree(connector.getClass() + .getSimpleName() + " id: " + pid); errorNode.addDomHandler(new MouseOverHandler() { @Override public void onMouseOver(MouseOverEvent event) { diff --git a/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java b/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java index 0b49fa7aaf..0856bb3575 100644 --- a/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java +++ b/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java @@ -24,8 +24,8 @@ import com.google.gwt.user.client.ui.HTML; import com.vaadin.client.ComponentConnector; import com.vaadin.client.JsArrayObject; import com.vaadin.client.ServerConnector; -import com.vaadin.client.Util; import com.vaadin.client.VConsole; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; import com.vaadin.client.ui.AbstractConnector; @@ -51,7 +51,7 @@ public class ConnectorInfoPanel extends FlowPanel { ignoreProperties.add("id"); String html = getRowHTML("Id", connector.getConnectorId()); - html += getRowHTML("Connector", Util.getSimpleName(connector)); + html += getRowHTML("Connector", connector.getClass().getSimpleName()); if (connector instanceof ComponentConnector) { ComponentConnector component = (ComponentConnector) connector; @@ -61,8 +61,8 @@ public class ConnectorInfoPanel extends FlowPanel { AbstractComponentState componentState = component.getState(); - html += getRowHTML("Widget", - Util.getSimpleName(component.getWidget())); + html += getRowHTML("Widget", component.getWidget().getClass() + .getSimpleName()); html += getRowHTML("Caption", componentState.caption); html += getRowHTML("Description", componentState.description); html += getRowHTML("Width", componentState.width + " (actual: " @@ -95,7 +95,8 @@ public class ConnectorInfoPanel extends FlowPanel { return "<div class=\"" + VDebugWindow.STYLENAME + "-row\"><span class=\"caption\">" + caption + "</span><span class=\"value\">" - + Util.escapeHTML(String.valueOf(value)) + "</span></div>"; + + WidgetUtil.escapeHTML(String.valueOf(value)) + + "</span></div>"; } /** diff --git a/client/src/com/vaadin/client/debug/internal/HierarchySection.java b/client/src/com/vaadin/client/debug/internal/HierarchySection.java index 404ac430df..c772a9d267 100644 --- a/client/src/com/vaadin/client/debug/internal/HierarchySection.java +++ b/client/src/com/vaadin/client/debug/internal/HierarchySection.java @@ -35,6 +35,7 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.ValueMap; +import com.vaadin.client.WidgetUtil; /** * Provides functionality for examining the UI component hierarchy. @@ -240,7 +241,7 @@ public class HierarchySection implements Section { } if (event.getTypeInt() == Event.ONMOUSEMOVE) { Highlight.hideAll(); - Element eventTarget = Util.getElementFromPoint(event + Element eventTarget = WidgetUtil.getElementFromPoint(event .getNativeEvent().getClientX(), event.getNativeEvent() .getClientY()); if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { @@ -272,7 +273,7 @@ public class HierarchySection implements Section { event.consume(); event.getNativeEvent().stopPropagation(); stopFind(); - Element eventTarget = Util.getElementFromPoint(event + Element eventTarget = WidgetUtil.getElementFromPoint(event .getNativeEvent().getClientX(), event.getNativeEvent() .getClientY()); for (ApplicationConnection a : ApplicationConfiguration diff --git a/client/src/com/vaadin/client/debug/internal/ProfilerSection.java b/client/src/com/vaadin/client/debug/internal/ProfilerSection.java index c4fea5cf71..7fb0284f8e 100644 --- a/client/src/com/vaadin/client/debug/internal/ProfilerSection.java +++ b/client/src/com/vaadin/client/debug/internal/ProfilerSection.java @@ -16,10 +16,8 @@ package com.vaadin.client.debug.internal; import java.util.Collection; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -29,6 +27,8 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Profiler; +import com.vaadin.client.Profiler.Node; +import com.vaadin.client.Profiler.ProfilerResultConsumer; import com.vaadin.client.SimpleTree; import com.vaadin.client.ValueMap; @@ -42,237 +42,6 @@ import com.vaadin.client.ValueMap; * @see Profiler */ public class ProfilerSection implements Section { - /** - * Interface for getting data from the {@link Profiler}. - * <p> - * <b>Warning!</b> This interface is most likely to change in the future and - * is therefore defined in this class in an internal package instead of - * Profiler where it might seem more logical. - * - * @since 7.1 - * @author Vaadin Ltd - */ - public interface ProfilerResultConsumer { - public void addProfilerData(Node rootNode, List<Node> totals); - - public void addBootstrapData(LinkedHashMap<String, Double> timings); - } - - /** - * A hierarchical representation of the time spent running a named block of - * code. - * <p> - * <b>Warning!</b> This class is most likely to change in the future and is - * therefore defined in this class in an internal package instead of - * Profiler where it might seem more logical. - */ - public static class Node { - private final String name; - private final LinkedHashMap<String, Node> children = new LinkedHashMap<String, Node>(); - private double time = 0; - private int count = 0; - private double enterTime = 0; - private double minTime = 1000000000; - private double maxTime = 0; - - /** - * Create a new node with the given name. - * - * @param name - */ - public Node(String name) { - this.name = name; - } - - /** - * Gets the name of the node - * - * @return the name of the node - */ - public String getName() { - return name; - } - - /** - * Creates a new child node or retrieves and existing child and updates - * its total time and hit count. - * - * @param name - * the name of the child - * @param timestamp - * the timestamp for when the node is entered - * @return the child node object - */ - public Node enterChild(String name, double timestamp) { - Node child = children.get(name); - if (child == null) { - child = new Node(name); - children.put(name, child); - } - child.enterTime = timestamp; - child.count++; - return child; - } - - /** - * Gets the total time spent in this node, including time spent in sub - * nodes - * - * @return the total time spent, in milliseconds - */ - public double getTimeSpent() { - return time; - } - - /** - * Gets the minimum time spent for one invocation of this node, - * including time spent in sub nodes - * - * @return the time spent for the fastest invocation, in milliseconds - */ - public double getMinTimeSpent() { - return minTime; - } - - /** - * Gets the maximum time spent for one invocation of this node, - * including time spent in sub nodes - * - * @return the time spent for the slowest invocation, in milliseconds - */ - public double getMaxTimeSpent() { - return maxTime; - } - - /** - * Gets the number of times this node has been entered - * - * @return the number of times the node has been entered - */ - public int getCount() { - return count; - } - - /** - * Gets the total time spent in this node, excluding time spent in sub - * nodes - * - * @return the total time spent, in milliseconds - */ - public double getOwnTime() { - double time = getTimeSpent(); - for (Node node : children.values()) { - time -= node.getTimeSpent(); - } - return time; - } - - /** - * Gets the child nodes of this node - * - * @return a collection of child nodes - */ - public Collection<Node> getChildren() { - return Collections.unmodifiableCollection(children.values()); - } - - private void buildRecursiveString(StringBuilder builder, String prefix) { - if (getName() != null) { - String msg = getStringRepresentation(prefix); - builder.append(msg + '\n'); - } - String childPrefix = prefix + "*"; - for (Node node : children.values()) { - node.buildRecursiveString(builder, childPrefix); - } - } - - @Override - public String toString() { - return getStringRepresentation(""); - } - - public String getStringRepresentation(String prefix) { - if (getName() == null) { - return ""; - } - String msg = prefix + " " + getName() + " in " + getTimeSpent() - + " ms."; - if (getCount() > 1) { - msg += " Invoked " - + getCount() - + " times (" - + roundToSignificantFigures(getTimeSpent() / getCount()) - + " ms per time, min " - + roundToSignificantFigures(getMinTimeSpent()) - + " ms, max " - + roundToSignificantFigures(getMaxTimeSpent()) - + " ms)."; - } - if (!children.isEmpty()) { - double ownTime = getOwnTime(); - msg += " " + ownTime + " ms spent in own code"; - if (getCount() > 1) { - msg += " (" - + roundToSignificantFigures(ownTime / getCount()) - + " ms per time)"; - } - msg += '.'; - } - return msg; - } - - private static double roundToSignificantFigures(double num) { - // Number of significant digits - int n = 3; - if (num == 0) { - return 0; - } - - final double d = Math.ceil(Math.log10(num < 0 ? -num : num)); - final int power = n - (int) d; - - final double magnitude = Math.pow(10, power); - final long shifted = Math.round(num * magnitude); - return shifted / magnitude; - } - - public void sumUpTotals(Map<String, Node> totals) { - String name = getName(); - if (name != null) { - Node totalNode = totals.get(name); - if (totalNode == null) { - totalNode = new Node(name); - totals.put(name, totalNode); - } - - totalNode.time += getOwnTime(); - totalNode.count += getCount(); - totalNode.minTime = Math.min(totalNode.minTime, - getMinTimeSpent()); - totalNode.maxTime = Math.max(totalNode.maxTime, - getMaxTimeSpent()); - } - for (Node node : children.values()) { - node.sumUpTotals(totals); - } - } - - /** - * @param timestamp - */ - public void leave(double timestamp) { - double elapsed = (timestamp - enterTime); - time += elapsed; - enterTime = 0; - if (elapsed < minTime) { - minTime = elapsed; - } - if (elapsed > maxTime) { - maxTime = elapsed; - } - } - } private static final int MAX_ROWS = 10; diff --git a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java index 355565f706..d0b6b10722 100644 --- a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java +++ b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java @@ -41,6 +41,7 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.ValueMap; +import com.vaadin.client.WidgetUtil; /** * Provides functionality for picking selectors for Vaadin TestBench. @@ -62,7 +63,8 @@ public class TestBenchSection implements Section { String html = "<div class=\"" + VDebugWindow.STYLENAME + "-selector\"><span class=\"tb-selector\">" - + Util.escapeHTML(path.getElementQuery()) + "</span></div>"; + + WidgetUtil.escapeHTML(path.getElementQuery()) + + "</span></div>"; setHTML(html); addMouseOverHandler(this); @@ -216,7 +218,7 @@ public class TestBenchSection implements Section { } if (event.getTypeInt() == Event.ONMOUSEMOVE || event.getTypeInt() == Event.ONCLICK) { - Element eventTarget = Util.getElementFromPoint(event + Element eventTarget = WidgetUtil.getElementFromPoint(event .getNativeEvent().getClientX(), event.getNativeEvent() .getClientY()); if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { @@ -230,8 +232,9 @@ public class TestBenchSection implements Section { // make sure that not finding the highlight element only Highlight.hideAll(); - eventTarget = Util.getElementFromPoint(event.getNativeEvent() - .getClientX(), event.getNativeEvent().getClientY()); + eventTarget = WidgetUtil.getElementFromPoint(event + .getNativeEvent().getClientX(), event.getNativeEvent() + .getClientY()); ComponentConnector connector = findConnector(eventTarget); if (event.getTypeInt() == Event.ONMOUSEMOVE) { diff --git a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java index 8e349bac7b..59e6600949 100644 --- a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java +++ b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java @@ -357,7 +357,7 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements /** * 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. * * @param element diff --git a/client/src/com/vaadin/client/renderers/ButtonRenderer.java b/client/src/com/vaadin/client/renderers/ButtonRenderer.java index 8dfa3d6fae..c1952556f9 100644 --- a/client/src/com/vaadin/client/renderers/ButtonRenderer.java +++ b/client/src/com/vaadin/client/renderers/ButtonRenderer.java @@ -24,7 +24,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; * corresponding column are used as the captions. Click handlers can be added to * the renderer, invoked when any of the rendered buttons is clicked. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ButtonRenderer extends ClickableRenderer<String, Button> { diff --git a/client/src/com/vaadin/client/renderers/ClickableRenderer.java b/client/src/com/vaadin/client/renderers/ClickableRenderer.java index 93e68763e0..f5368d31c9 100644 --- a/client/src/com/vaadin/client/renderers/ClickableRenderer.java +++ b/client/src/com/vaadin/client/renderers/ClickableRenderer.java @@ -26,7 +26,7 @@ import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.ui.Widget; 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.RowContainer; import com.vaadin.client.widget.grid.CellReference; @@ -44,7 +44,7 @@ import com.vaadin.client.widgets.Grid; * @param <W> * the widget type * - * @since + * @since 7.4 * @author Vaadin Ltd */ public abstract class ClickableRenderer<T, W extends Widget> extends @@ -167,15 +167,16 @@ public abstract class ClickableRenderer<T, W extends Widget> extends * <strong>Note:</strong> This method may not work reliably if the grid * 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; - * 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 * the element whose parent grid to find * @return the parent grid or null if none found. */ private static Grid<?> findClosestParentGrid(Element e) { - Widget w = Util.findWidget(e, null); + Widget w = WidgetUtil.findWidget(e, null); while (w != null && !(w instanceof Grid)) { w = w.getParent(); diff --git a/client/src/com/vaadin/client/renderers/DateRenderer.java b/client/src/com/vaadin/client/renderers/DateRenderer.java index ee5af2dce9..4d15fac724 100644 --- a/client/src/com/vaadin/client/renderers/DateRenderer.java +++ b/client/src/com/vaadin/client/renderers/DateRenderer.java @@ -25,7 +25,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; /** * A renderer for rendering dates into cells * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class DateRenderer implements Renderer<Date> { diff --git a/client/src/com/vaadin/client/renderers/HtmlRenderer.java b/client/src/com/vaadin/client/renderers/HtmlRenderer.java index df95e07367..ec6dc761f6 100644 --- a/client/src/com/vaadin/client/renderers/HtmlRenderer.java +++ b/client/src/com/vaadin/client/renderers/HtmlRenderer.java @@ -27,7 +27,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; * contract. For more information see * {@link SafeHtmlUtils#fromSafeConstant(String)}. * - * @since + * @since 7.4 * @author Vaadin Ltd * @see SafeHtmlUtils#fromSafeConstant(String) */ diff --git a/client/src/com/vaadin/client/renderers/ImageRenderer.java b/client/src/com/vaadin/client/renderers/ImageRenderer.java index 9b3d05ec0b..b1e8ce5702 100644 --- a/client/src/com/vaadin/client/renderers/ImageRenderer.java +++ b/client/src/com/vaadin/client/renderers/ImageRenderer.java @@ -24,7 +24,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; * the renderer, invoked every time any of the images rendered by that rendered * is clicked. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ImageRenderer extends ClickableRenderer<String, Image> { diff --git a/client/src/com/vaadin/client/renderers/NumberRenderer.java b/client/src/com/vaadin/client/renderers/NumberRenderer.java index 552a88644a..a040e8d1ce 100644 --- a/client/src/com/vaadin/client/renderers/NumberRenderer.java +++ b/client/src/com/vaadin/client/renderers/NumberRenderer.java @@ -23,7 +23,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; * default uses the default number format returned by * {@link NumberFormat#getDecimalFormat()}. * - * @since + * @since 7.4 * @author Vaadin Ltd * @param <T> * The number type to render. diff --git a/client/src/com/vaadin/client/renderers/ProgressBarRenderer.java b/client/src/com/vaadin/client/renderers/ProgressBarRenderer.java index f5aff7191d..8e09641cfc 100644 --- a/client/src/com/vaadin/client/renderers/ProgressBarRenderer.java +++ b/client/src/com/vaadin/client/renderers/ProgressBarRenderer.java @@ -22,7 +22,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; /** * A Renderer that represents a double value as a graphical progress bar. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ProgressBarRenderer extends WidgetRenderer<Double, VProgressBar> { diff --git a/client/src/com/vaadin/client/renderers/Renderer.java b/client/src/com/vaadin/client/renderers/Renderer.java index 7149181b61..a3faa1e9df 100644 --- a/client/src/com/vaadin/client/renderers/Renderer.java +++ b/client/src/com/vaadin/client/renderers/Renderer.java @@ -29,7 +29,7 @@ import com.vaadin.client.widgets.Grid; * @param <T> * The column type * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface Renderer<T> { diff --git a/client/src/com/vaadin/client/renderers/TextRenderer.java b/client/src/com/vaadin/client/renderers/TextRenderer.java index 76ccd9f206..3f704fd0b4 100644 --- a/client/src/com/vaadin/client/renderers/TextRenderer.java +++ b/client/src/com/vaadin/client/renderers/TextRenderer.java @@ -20,7 +20,7 @@ import com.vaadin.client.widget.grid.RendererCellReference; /** * Renderer that renders text into a cell. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class TextRenderer implements Renderer<String> { diff --git a/client/src/com/vaadin/client/renderers/WidgetRenderer.java b/client/src/com/vaadin/client/renderers/WidgetRenderer.java index ef0338ce70..668ec7b59e 100644 --- a/client/src/com/vaadin/client/renderers/WidgetRenderer.java +++ b/client/src/com/vaadin/client/renderers/WidgetRenderer.java @@ -17,13 +17,13 @@ package com.vaadin.client.renderers; import com.google.gwt.dom.client.TableCellElement; 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; /** * A renderer for rendering widgets into cells. * - * @since + * @since 7.4 * @author Vaadin Ltd * @param <T> * the row data type @@ -97,7 +97,7 @@ public abstract class WidgetRenderer<T, W extends Widget> extends */ protected static <W extends Widget> W getWidget(TableCellElement e, 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"; return w; } diff --git a/client/src/com/vaadin/client/ui/AbstractClickEventHandler.java b/client/src/com/vaadin/client/ui/AbstractClickEventHandler.java index c08656c4d9..a2c54ec7ca 100644 --- a/client/src/com/vaadin/client/ui/AbstractClickEventHandler.java +++ b/client/src/com/vaadin/client/ui/AbstractClickEventHandler.java @@ -32,7 +32,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event.NativePreviewEvent; import com.google.gwt.user.client.Event.NativePreviewHandler; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; public abstract class AbstractClickEventHandler implements MouseDownHandler, @@ -72,8 +72,8 @@ public abstract class AbstractClickEventHandler implements MouseDownHandler, // Event's reported target not always correct if event // capture is in use - Element elementUnderMouse = Util.getElementUnderMouse(event - .getNativeEvent()); + Element elementUnderMouse = WidgetUtil + .getElementUnderMouse(event.getNativeEvent()); if (lastMouseDownTarget != null && elementUnderMouse == lastMouseDownTarget) { mouseUpPreviewMatched = true; @@ -171,7 +171,8 @@ public abstract class AbstractClickEventHandler implements MouseDownHandler, * When getting a mousedown event, we must detect where the * 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; mouseUpEventPreviewRegistration = Event .addNativePreviewHandler(mouseUpPreviewHandler); @@ -188,7 +189,7 @@ public abstract class AbstractClickEventHandler implements MouseDownHandler, if (hasEventListener() && mouseUpPreviewMatched && lastMouseDownTarget != null - && Util.getElementUnderMouse(event.getNativeEvent()) == lastMouseDownTarget + && WidgetUtil.getElementUnderMouse(event.getNativeEvent()) == lastMouseDownTarget && shouldFireEvent(event)) { // "Click" with left, right or middle button fireClick(event.getNativeEvent()); diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index c3f14be40c..46ad289488 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -21,7 +21,6 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.LayoutManager; @@ -89,7 +88,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector } catch (NoDataException e) { throw new IllegalStateException( "Default implementation of createWidget() does not work for " - + Util.getSimpleName(this) + + getClass().getSimpleName() + ". This might be caused by explicitely using " + "super.createWidget() or some unspecified " + "problem with the widgetset compilation.", e); @@ -106,10 +105,10 @@ public abstract class AbstractComponentConnector extends AbstractConnector public Widget getWidget() { if (widget == null) { Profiler.enter("AbstractComponentConnector.createWidget for " - + Util.getSimpleName(this)); + + getClass().getSimpleName()); widget = createWidget(); Profiler.leave("AbstractComponentConnector.createWidget for " - + Util.getSimpleName(this)); + + getClass().getSimpleName()); } return widget; @@ -195,8 +194,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector @Override public void setWidgetEnabled(boolean widgetEnabled) { // add or remove v-disabled style name from the widget - setWidgetStyleName(ApplicationConnection.DISABLED_CLASSNAME, - !widgetEnabled); + setWidgetStyleName(StyleConstants.DISABLED, !widgetEnabled); if (getWidget() instanceof HasEnabled) { // set widget specific enabled state @@ -343,8 +341,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector // add / remove error style name setWidgetStyleNameWithPrefix(primaryStyleName, - ApplicationConnection.ERROR_CLASSNAME_EXT, - null != state.errorMessage); + StyleConstants.ERROR_EXT, null != state.errorMessage); // add additional user defined style names as class names, prefixed with // component default class name. remove nonexistent style names. diff --git a/client/src/com/vaadin/client/ui/AbstractConnector.java b/client/src/com/vaadin/client/ui/AbstractConnector.java index e93ea0f507..a20c3463c2 100644 --- a/client/src/com/vaadin/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractConnector.java @@ -120,11 +120,13 @@ public abstract class AbstractConnector implements ServerConnector, addStateChangeHandler(this); if (Profiler.isEnabled()) { - Profiler.enter("AbstractConnector.init " + Util.getSimpleName(this)); + Profiler.enter("AbstractConnector.init " + + getClass().getSimpleName()); } init(); if (Profiler.isEnabled()) { - Profiler.leave("AbstractConnector.init " + Util.getSimpleName(this)); + Profiler.leave("AbstractConnector.init " + + getClass().getSimpleName()); } Profiler.leave("AbstractConnector.doInit"); } @@ -214,8 +216,8 @@ public abstract class AbstractConnector implements ServerConnector, public void fireEvent(GwtEvent<?> event) { String profilerKey = null; if (Profiler.isEnabled()) { - profilerKey = "Fire " + Util.getSimpleName(event) + " for " - + Util.getSimpleName(this); + profilerKey = "Fire " + event.getClass().getSimpleName() + " for " + + getClass().getSimpleName(); Profiler.enter(profilerKey); } if (handlerManager != null) { @@ -377,7 +379,7 @@ public abstract class AbstractConnector implements ServerConnector, } catch (NoDataException e) { throw new IllegalStateException( "There is no information about the state for " - + Util.getSimpleName(this) + + getClass().getSimpleName() + ". Did you remember to compile the right widgetset?", e); } @@ -391,7 +393,7 @@ public abstract class AbstractConnector implements ServerConnector, } catch (NoDataException e) { throw new IllegalStateException( "There is no information about the state for " - + Util.getSimpleName(connector) + + connector.getClass().getSimpleName() + ". Did you remember to compile the right widgetset?", e); } diff --git a/client/src/com/vaadin/client/ui/AbstractFieldConnector.java b/client/src/com/vaadin/client/ui/AbstractFieldConnector.java index 965e79b6fd..8d8df81bd8 100644 --- a/client/src/com/vaadin/client/ui/AbstractFieldConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractFieldConnector.java @@ -15,7 +15,7 @@ */ package com.vaadin.client.ui; -import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.StyleConstants; import com.vaadin.shared.AbstractFieldState; public abstract class AbstractFieldConnector extends AbstractComponentConnector { @@ -51,14 +51,12 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector super.updateWidgetStyleNames(); // add / remove modified style name to Fields - setWidgetStyleName(ApplicationConnection.MODIFIED_CLASSNAME, - isModified()); + setWidgetStyleName(StyleConstants.MODIFIED, isModified()); // add / remove error style name to Fields setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(), - ApplicationConnection.REQUIRED_CLASSNAME_EXT, isRequired()); + StyleConstants.REQUIRED_EXT, isRequired()); - getWidget().setStyleName(ApplicationConnection.REQUIRED_CLASSNAME, - isRequired()); + getWidget().setStyleName(StyleConstants.REQUIRED, isRequired()); } } diff --git a/client/src/com/vaadin/client/ui/MediaBaseConnector.java b/client/src/com/vaadin/client/ui/MediaBaseConnector.java index cebb2e3836..fdd9610517 100644 --- a/client/src/com/vaadin/client/ui/MediaBaseConnector.java +++ b/client/src/com/vaadin/client/ui/MediaBaseConnector.java @@ -15,7 +15,7 @@ */ package com.vaadin.client.ui; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.shared.communication.URLReference; import com.vaadin.shared.ui.AbstractMediaState; @@ -78,7 +78,7 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector { if (altText == null || "".equals(altText)) { altText = getDefaultAltHtml(); } else if (!getState().htmlContentAllowed) { - altText = Util.escapeHTML(altText); + altText = WidgetUtil.escapeHTML(altText); } getWidget().setAltText(altText); } diff --git a/client/src/com/vaadin/client/ui/SubPartAware.java b/client/src/com/vaadin/client/ui/SubPartAware.java index a064b8a8a8..7a40eea20e 100644 --- a/client/src/com/vaadin/client/ui/SubPartAware.java +++ b/client/src/com/vaadin/client/ui/SubPartAware.java @@ -16,11 +16,10 @@ package com.vaadin.client.ui; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.componentlocator.ComponentLocator; /** * Interface implemented by {@link Widget}s which can provide identifiers for at - * least one element inside the component. Used by {@link ComponentLocator}. + * least one element inside the component. * */ public interface SubPartAware { diff --git a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java index 9d32355b70..b52663b161 100644 --- a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java +++ b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java @@ -44,7 +44,7 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorMap; import com.vaadin.client.LayoutManager; import com.vaadin.client.StyleConstants; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent; @@ -577,7 +577,7 @@ public class VAbstractSplitPanel extends ComplexPanel { break; } // Only fire click event listeners if the splitter isn't moved - if (Util.isTouchEvent(event) || !resized) { + if (WidgetUtil.isTouchEvent(event) || !resized) { super.onBrowserEvent(event); } else if (DOM.eventGetType(event) == Event.ONMOUSEUP) { // Reset the resized flag after a mouseup has occured so the next @@ -596,8 +596,8 @@ public class VAbstractSplitPanel extends ComplexPanel { DOM.setCapture(getElement()); origX = DOM.getElementPropertyInt(splitter, "offsetLeft"); origY = DOM.getElementPropertyInt(splitter, "offsetTop"); - origMouseX = Util.getTouchOrMouseClientX(event); - origMouseY = Util.getTouchOrMouseClientY(event); + origMouseX = WidgetUtil.getTouchOrMouseClientX(event); + origMouseY = WidgetUtil.getTouchOrMouseClientY(event); event.stopPropagation(); event.preventDefault(); } @@ -606,12 +606,12 @@ public class VAbstractSplitPanel extends ComplexPanel { public void onMouseMove(Event event) { switch (orientation) { case HORIZONTAL: - final int x = Util.getTouchOrMouseClientX(event); + final int x = WidgetUtil.getTouchOrMouseClientX(event); onHorizontalMouseMove(x); break; case VERTICAL: default: - final int y = Util.getTouchOrMouseClientY(event); + final int y = WidgetUtil.getTouchOrMouseClientY(event); onVerticalMouseMove(y); break; } @@ -688,7 +688,7 @@ public class VAbstractSplitPanel extends ComplexPanel { DOM.releaseCapture(getElement()); hideDraggingCurtain(); resizing = false; - if (!Util.isTouchEvent(event)) { + if (!WidgetUtil.isTouchEvent(event)) { onMouseMove(event); } fireEvent(new SplitterMoveEvent(this)); diff --git a/client/src/com/vaadin/client/ui/VAccordion.java b/client/src/com/vaadin/client/ui/VAccordion.java index 422f195af9..06eaecaf70 100644 --- a/client/src/com/vaadin/client/ui/VAccordion.java +++ b/client/src/com/vaadin/client/ui/VAccordion.java @@ -29,7 +29,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VCaption; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; import com.vaadin.shared.ComponentConstants; @@ -203,7 +203,7 @@ public class VAccordion extends VTabsheetBase { } int captionWidth = caption.getRequiredWidth(); - int padding = Util.measureHorizontalPaddingAndBorder( + int padding = WidgetUtil.measureHorizontalPaddingAndBorder( caption.getElement(), 18); return captionWidth + padding; } diff --git a/client/src/com/vaadin/client/ui/VButton.java b/client/src/com/vaadin/client/ui/VButton.java index dcc364c1da..bf321f7f00 100644 --- a/client/src/com/vaadin/client/ui/VButton.java +++ b/client/src/com/vaadin/client/ui/VButton.java @@ -30,6 +30,7 @@ import com.google.gwt.user.client.ui.FocusWidget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; public class VButton extends FocusWidget implements ClickHandler { @@ -373,10 +374,10 @@ public class VButton extends FocusWidget implements ClickHandler { // Set (x,y) client coordinates to the middle of the button int x = getElement().getAbsoluteLeft() - getElement().getScrollLeft() - getElement().getOwnerDocument().getScrollLeft() - + Util.getRequiredWidth(getElement()) / 2; + + WidgetUtil.getRequiredWidth(getElement()) / 2; int y = getElement().getAbsoluteTop() - getElement().getScrollTop() - getElement().getOwnerDocument().getScrollTop() - + Util.getRequiredHeight(getElement()) / 2; + + WidgetUtil.getRequiredHeight(getElement()) / 2; NativeEvent evt = Document.get().createClickEvent(1, 0, 0, x, y, false, false, false, false); getElement().dispatchEvent(evt); diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java index 6fc06bb153..e1b906b6e4 100644 --- a/client/src/com/vaadin/client/ui/VCalendarPanel.java +++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java @@ -54,7 +54,7 @@ import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.BrowserInfo; import com.vaadin.client.DateTimeService; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.shared.util.SharedUtil; @@ -2065,7 +2065,7 @@ public class VCalendarPanel extends FocusableFlexTable implements return SUBPART_PREV_YEAR; } else if (contains(days, subElement)) { // 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) { Date date = day.getDate(); int id = date.getDate(); diff --git a/client/src/com/vaadin/client/ui/VContextMenu.java b/client/src/com/vaadin/client/ui/VContextMenu.java index fa6d67fc0c..6028eea52c 100644 --- a/client/src/com/vaadin/client/ui/VContextMenu.java +++ b/client/src/com/vaadin/client/ui/VContextMenu.java @@ -51,7 +51,7 @@ import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.impl.FocusImpl; import com.vaadin.client.Focusable; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; public class VContextMenu extends VOverlay implements SubPartAware { @@ -89,7 +89,7 @@ public class VContextMenu extends VOverlay implements SubPartAware { addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { - Element currentFocus = Util.getFocusedElement(); + Element currentFocus = WidgetUtil.getFocusedElement(); if (focusedElement != null && (currentFocus == null || menu.getElement().isOrHasChild(currentFocus) || RootPanel @@ -137,11 +137,11 @@ public class VContextMenu extends VOverlay implements SubPartAware { } // 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 // context menu is closed - focusedElement = Util.getFocusedElement(); + focusedElement = WidgetUtil.getFocusedElement(); // reset height (if it has been previously set explicitly) setHeight(""); diff --git a/client/src/com/vaadin/client/ui/VCustomLayout.java b/client/src/com/vaadin/client/ui/VCustomLayout.java index f5d572007a..5f8a8197d0 100644 --- a/client/src/com/vaadin/client/ui/VCustomLayout.java +++ b/client/src/com/vaadin/client/ui/VCustomLayout.java @@ -37,6 +37,7 @@ import com.vaadin.client.StyleConstants; import com.vaadin.client.Util; import com.vaadin.client.VCaption; import com.vaadin.client.VCaptionWrapper; +import com.vaadin.client.WidgetUtil; /** * Custom Layout implements complex layout defined with HTML template. @@ -158,7 +159,8 @@ public class VCustomLayout extends ComplexPanel { // 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 // regexp search diff --git a/client/src/com/vaadin/client/ui/VEmbedded.java b/client/src/com/vaadin/client/ui/VEmbedded.java index acf814471a..f3970f9ac7 100644 --- a/client/src/com/vaadin/client/ui/VEmbedded.java +++ b/client/src/com/vaadin/client/ui/VEmbedded.java @@ -31,6 +31,7 @@ import com.vaadin.client.ConnectorMap; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.VConsole; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.ui.embedded.EmbeddedConstants; public class VEmbedded extends HTML { @@ -83,8 +84,8 @@ public class VEmbedded extends HTML { */ if (uidl.hasAttribute("classid")) { html.append("classid=\"" - + Util.escapeAttribute(uidl.getStringAttribute("classid")) - + "\" "); + + WidgetUtil.escapeAttribute(uidl + .getStringAttribute("classid")) + "\" "); } else { html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "); } @@ -99,8 +100,8 @@ public class VEmbedded extends HTML { */ if (uidl.hasAttribute("codebase")) { html.append("codebase=\"" - + Util.escapeAttribute(uidl.getStringAttribute("codebase")) - + "\" "); + + WidgetUtil.escapeAttribute(uidl + .getStringAttribute("codebase")) + "\" "); } else { html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); } @@ -111,29 +112,29 @@ public class VEmbedded extends HTML { String width = paintable.getState().width; // 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\" "); // Codetype if (uidl.hasAttribute("codetype")) { html.append("codetype=\"" - + Util.escapeAttribute(uidl.getStringAttribute("codetype")) - + "\" "); + + WidgetUtil.escapeAttribute(uidl + .getStringAttribute("codetype")) + "\" "); } // Standby if (uidl.hasAttribute("standby")) { html.append("standby=\"" - + Util.escapeAttribute(uidl.getStringAttribute("standby")) - + "\" "); + + WidgetUtil.escapeAttribute(uidl + .getStringAttribute("standby")) + "\" "); } // Archive if (uidl.hasAttribute("archive")) { html.append("archive=\"" - + Util.escapeAttribute(uidl.getStringAttribute("archive")) - + "\" "); + + WidgetUtil.escapeAttribute(uidl + .getStringAttribute("archive")) + "\" "); } // End object tag @@ -148,25 +149,25 @@ public class VEmbedded extends HTML { // Add parameters to OBJECT for (String name : parameters.keySet()) { 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("/>"); } // Build inner EMBED tag 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\" "); // Add the parameters to the Embed for (String name : parameters.keySet()) { - html.append(Util.escapeAttribute(name)); + html.append(WidgetUtil.escapeAttribute(name)); html.append("="); - html.append("\"" + Util.escapeAttribute(parameters.get(name)) + html.append("\"" + WidgetUtil.escapeAttribute(parameters.get(name)) + "\""); } diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index bb217f2de2..c0575b1ea5 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -67,8 +67,8 @@ import com.vaadin.client.ComputedStyle; import com.vaadin.client.ConnectorMap; import com.vaadin.client.Focusable; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; import com.vaadin.client.VConsole; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.aria.AriaHelper; import com.vaadin.client.ui.aria.HandlesAriaCaption; import com.vaadin.client.ui.aria.HandlesAriaInvalid; @@ -134,7 +134,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, // options and are not collapsed (#7506) content = " "; } else { - content = Util.escapeHTML(caption); + content = WidgetUtil.escapeHTML(caption); } sb.append("<span>" + content + "</span>"); return sb.toString(); @@ -599,8 +599,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, final int naturalMenuWidth = menuFirstChild.getOffsetWidth(); if (popupOuterPadding == -1) { - popupOuterPadding = Util.measureHorizontalPaddingAndBorder( - getElement(), 2); + popupOuterPadding = WidgetUtil + .measureHorizontalPaddingAndBorder(getElement(), 2); } if (naturalMenuWidth < desiredWidth) { @@ -657,7 +657,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, menu.setHeight(menuHeight + "px"); final int naturalMenuWidthPlusScrollBar = naturalMenuWidth - + Util.getNativeScrollbarSize(); + + WidgetUtil.getNativeScrollbarSize(); if (offsetWidth < naturalMenuWidthPlusScrollBar) { menu.setWidth(naturalMenuWidthPlusScrollBar + "px"); } @@ -818,7 +818,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, final MenuItem mi = new MenuItem(s.getDisplayString(), true, s); Roles.getListitemRole().set(mi.getElement()); - Util.sinkOnloadForImages(mi.getElement()); + WidgetUtil.sinkOnloadForImages(mi.getElement()); this.addItem(mi); if (s == currentSuggestion) { @@ -1069,7 +1069,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * the end and the focus to the start. This makes Firefox work * the same way as other browsers (#13477) */ - Util.setSelectionRange(getElement(), pos, length, "backward"); + WidgetUtil.setSelectionRange(getElement(), pos, length, + "backward"); } else { /* @@ -1609,7 +1610,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, } private void forceReflow() { - Util.setStyleTemporarily(tb.getElement(), "zoom", "1"); + WidgetUtil.setStyleTemporarily(tb.getElement(), "zoom", "1"); } /** @@ -1621,7 +1622,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, int availableHeight = 0; availableHeight = getOffsetHeight(); - int iconHeight = Util.getRequiredHeight(selectedItemIcon); + int iconHeight = WidgetUtil.getRequiredHeight(selectedItemIcon); int marginTop = (availableHeight - iconHeight) / 2; selectedItemIcon.getElement().getStyle() .setMarginTop(marginTop, Unit.PX); @@ -1936,7 +1937,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ public void updateSuggestionPopupMinWidth() { // used only to calculate minimum width - String captions = Util.escapeHTML(inputPrompt); + String captions = WidgetUtil.escapeHTML(inputPrompt); for (FilterSelectSuggestion suggestion : currentSuggestions) { // Collect captions so we can calculate minimum width for @@ -1944,7 +1945,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, if (captions.length() > 0) { captions += "|"; } - captions += Util.escapeHTML(suggestion.getReplacementString()); + captions += WidgetUtil + .escapeHTML(suggestion.getReplacementString()); } // Calculate minimum textarea width @@ -2051,7 +2053,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ preventNextBlurEventInIE = false; - Element focusedElement = Util.getIEFocusedElement(); + Element focusedElement = WidgetUtil.getFocusedElement(); if (getElement().isOrHasChild(focusedElement) || suggestionPopup.getElement() .isOrHasChild(focusedElement)) { @@ -2129,7 +2131,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * when the popup is used to view longer items than the text box is * wide. */ - int w = Util.getRequiredWidth(this); + int w = WidgetUtil.getRequiredWidth(this); if ((!initDone || currentPage + 1 < 0) && suggestionPopupMinWidth > w) { @@ -2150,9 +2152,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, // Use util.getRequiredWidth instead of getOffsetWidth here - int iconWidth = selectedItemIcon == null ? 0 : Util + int iconWidth = selectedItemIcon == null ? 0 : WidgetUtil .getRequiredWidth(selectedItemIcon); - int buttonWidth = popupOpener == null ? 0 : Util + int buttonWidth = popupOpener == null ? 0 : WidgetUtil .getRequiredWidth(popupOpener); /* diff --git a/client/src/com/vaadin/client/ui/VFlash.java b/client/src/com/vaadin/client/ui/VFlash.java index cf15f89cb4..eaf53836ee 100644 --- a/client/src/com/vaadin/client/ui/VFlash.java +++ b/client/src/com/vaadin/client/ui/VFlash.java @@ -19,7 +19,7 @@ import java.util.HashMap; import java.util.Map; import com.google.gwt.user.client.ui.HTML; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; public class VFlash extends HTML { @@ -156,7 +156,8 @@ public class VFlash extends HTML { * this by setting his own classid. */ if (classId != null) { - html.append("classid=\"" + Util.escapeAttribute(classId) + "\" "); + html.append("classid=\"" + WidgetUtil.escapeAttribute(classId) + + "\" "); } else { html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "); } @@ -170,29 +171,33 @@ public class VFlash extends HTML { * codebase */ if (codebase != null) { - html.append("codebase=\"" + Util.escapeAttribute(codebase) + "\" "); + html.append("codebase=\"" + WidgetUtil.escapeAttribute(codebase) + + "\" "); } else { html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" "); } // 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\" "); // Codetype if (codetype != null) { - html.append("codetype=\"" + Util.escapeAttribute(codetype) + "\" "); + html.append("codetype=\"" + WidgetUtil.escapeAttribute(codetype) + + "\" "); } // Standby if (standby != null) { - html.append("standby=\"" + Util.escapeAttribute(standby) + "\" "); + html.append("standby=\"" + WidgetUtil.escapeAttribute(standby) + + "\" "); } // Archive if (archive != null) { - html.append("archive=\"" + Util.escapeAttribute(archive) + "\" "); + html.append("archive=\"" + WidgetUtil.escapeAttribute(archive) + + "\" "); } // End object tag @@ -206,25 +211,25 @@ public class VFlash extends HTML { // Add parameters to OBJECT for (String name : embedParams.keySet()) { html.append("<param "); - html.append("name=\"" + Util.escapeAttribute(name) + "\" "); + html.append("name=\"" + WidgetUtil.escapeAttribute(name) + "\" "); html.append("value=\"" - + Util.escapeAttribute(embedParams.get(name)) + "\" "); + + WidgetUtil.escapeAttribute(embedParams.get(name)) + "\" "); html.append("/>"); } // Build inner EMBED tag 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\" "); // Add the parameters to the Embed for (String name : embedParams.keySet()) { - html.append(Util.escapeAttribute(name)); + html.append(WidgetUtil.escapeAttribute(name)); html.append("="); - html.append("\"" + Util.escapeAttribute(embedParams.get(name)) - + "\""); + html.append("\"" + + WidgetUtil.escapeAttribute(embedParams.get(name)) + "\""); } // End embed tag diff --git a/client/src/com/vaadin/client/ui/VFormLayout.java b/client/src/com/vaadin/client/ui/VFormLayout.java index 64a7c5e579..a2ea77d31c 100644 --- a/client/src/com/vaadin/client/ui/VFormLayout.java +++ b/client/src/com/vaadin/client/ui/VFormLayout.java @@ -30,7 +30,6 @@ import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.Focusable; @@ -78,7 +77,7 @@ public class VFormLayout extends SimplePanel { } if (!enabled) { - styles.add(ApplicationConnection.DISABLED_CLASSNAME); + styles.add(StyleConstants.DISABLED); } return styles.toArray(new String[styles.size()]); @@ -242,7 +241,7 @@ public class VFormLayout extends SimplePanel { if (styles != null) { for (String style : styles) { - if (ApplicationConnection.DISABLED_CLASSNAME.equals(style)) { + if (StyleConstants.DISABLED.equals(style)) { // Add v-disabled also without classname prefix so // generic v-disabled CSS rules work styleName += " " + style; diff --git a/client/src/com/vaadin/client/ui/VLabel.java b/client/src/com/vaadin/client/ui/VLabel.java index 0f996fa6b9..a3572759c4 100644 --- a/client/src/com/vaadin/client/ui/VLabel.java +++ b/client/src/com/vaadin/client/ui/VLabel.java @@ -21,6 +21,7 @@ import com.google.gwt.user.client.ui.HTML; import com.vaadin.client.BrowserInfo; import com.vaadin.client.Util; import com.vaadin.client.VTooltip; +import com.vaadin.client.WidgetUtil; public class VLabel extends HTML { @@ -63,7 +64,7 @@ public class VLabel extends HTML { if (BrowserInfo.get().isIE8()) { // #3983 - IE8 incorrectly replaces \n with <br> so we do the // escaping manually and set as HTML - super.setHTML(Util.escapeHTML(text)); + super.setHTML(WidgetUtil.escapeHTML(text)); } else { super.setText(text); } diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java index b5dac3f7ef..08f70f4dde 100644 --- a/client/src/com/vaadin/client/ui/VMenuBar.java +++ b/client/src/com/vaadin/client/ui/VMenuBar.java @@ -50,6 +50,7 @@ import com.vaadin.client.LayoutManager; import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.ui.menubar.MenuBarConstants; public class VMenuBar extends SimpleFocusablePanel implements @@ -234,7 +235,7 @@ public class VMenuBar extends SimpleFocusablePanel implements } String itemText = item.getStringAttribute("text"); if (!htmlContentAllowed) { - itemText = Util.escapeHTML(itemText); + itemText = WidgetUtil.escapeHTML(itemText); } itemHTML.append(itemText); itemHTML.append("</span>"); @@ -658,7 +659,8 @@ public class VMenuBar extends SimpleFocusablePanel implements // Make room for the scroll bar by adjusting the width of the // popup - style.setWidth(contentWidth + Util.getNativeScrollbarSize(), + style.setWidth( + contentWidth + WidgetUtil.getNativeScrollbarSize(), Unit.PX); popup.positionOrSizeUpdated(); } @@ -983,7 +985,7 @@ public class VMenuBar extends SimpleFocusablePanel implements // Sink the onload event for any icons. The onload // events are handled by the parent VMenuBar. - Util.sinkOnloadForImages(getElement()); + WidgetUtil.sinkOnloadForImages(getElement()); } @Override @@ -993,7 +995,7 @@ public class VMenuBar extends SimpleFocusablePanel implements @Override public void setText(String text) { - setHTML(Util.escapeHTML(text)); + setHTML(WidgetUtil.escapeHTML(text)); } public void setEnabled(boolean enabled) { diff --git a/client/src/com/vaadin/client/ui/VNativeButton.java b/client/src/com/vaadin/client/ui/VNativeButton.java index 8e0dd2bce1..77b2515f45 100644 --- a/client/src/com/vaadin/client/ui/VNativeButton.java +++ b/client/src/com/vaadin/client/ui/VNativeButton.java @@ -25,6 +25,7 @@ import com.google.gwt.user.client.ui.Button; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.MouseEventDetailsBuilder; +import com.vaadin.client.StyleConstants; import com.vaadin.client.Util; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.button.ButtonServerRpc; @@ -146,7 +147,7 @@ public class VNativeButton extends Button implements ClickHandler { setEnabled(false); // FIXME: This should be moved to NativeButtonConnector along with // buttonRpcProxy - addStyleName(ApplicationConnection.DISABLED_CLASSNAME); + addStyleName(StyleConstants.DISABLED); buttonRpcProxy.disableOnClick(); } diff --git a/client/src/com/vaadin/client/ui/VNotification.java b/client/src/com/vaadin/client/ui/VNotification.java index 1df58bb38f..b995ef840a 100644 --- a/client/src/com/vaadin/client/ui/VNotification.java +++ b/client/src/com/vaadin/client/ui/VNotification.java @@ -37,7 +37,7 @@ import com.vaadin.client.AnimationUtil.AnimationEndListener; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; 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.shared.Position; import com.vaadin.shared.ui.ui.NotificationRole; @@ -258,7 +258,7 @@ public class VNotification extends VOverlay { * nudge (#8551) */ if (BrowserInfo.get().isAndroid()) { - Util.setStyleTemporarily(getElement(), "display", "none"); + WidgetUtil.setStyleTemporarily(getElement(), "display", "none"); } } @@ -476,7 +476,7 @@ public class VNotification extends VOverlay { String caption = notification .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION); if (onlyPlainText) { - caption = Util.escapeHTML(caption); + caption = WidgetUtil.escapeHTML(caption); caption = caption.replaceAll("\\n", "<br />"); } html += "<h1>" + caption + "</h1>"; @@ -486,7 +486,7 @@ public class VNotification extends VOverlay { String message = notification .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE); if (onlyPlainText) { - message = Util.escapeHTML(message); + message = WidgetUtil.escapeHTML(message); message = message.replaceAll("\\n", "<br />"); } html += "<p>" + message + "</p>"; diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java index 34227831b9..d429752069 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroup.java +++ b/client/src/com/vaadin/client/ui/VOptionGroup.java @@ -40,10 +40,11 @@ import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; +import com.vaadin.client.StyleConstants; import com.vaadin.client.UIDL; import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.EventId; import com.vaadin.shared.ui.optiongroup.OptionGroupConstants; @@ -136,7 +137,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, String itemHtml = opUidl.getStringAttribute("caption"); if (!htmlContentAllowed) { - itemHtml = Util.escapeHTML(itemHtml); + itemHtml = WidgetUtil.escapeHTML(itemHtml); } String iconUrl = opUidl.getStringAttribute("icon"); @@ -160,7 +161,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, op.setStyleName("v-radiobutton"); } if (iconUrl != null && iconUrl.length() != 0) { - Util.sinkOnloadForImages(op.getElement()); + WidgetUtil.sinkOnloadForImages(op.getElement()); op.addHandler(iconLoadHandler, LoadEvent.getType()); } @@ -178,8 +179,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, op.setEnabled(enabled); optionsEnabled.put(op, optionEnabled); - setStyleName(op.getElement(), - ApplicationConnection.DISABLED_CLASSNAME, + setStyleName(op.getElement(), StyleConstants.DISABLED, !(optionEnabled && isEnabled())); newwidgets.add(op); @@ -248,14 +248,12 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, Boolean isOptionEnabled = optionsEnabled.get(w); if (isOptionEnabled == null) { hasEnabled.setEnabled(optionGroupEnabled); - setStyleName(w.getElement(), - ApplicationConnection.DISABLED_CLASSNAME, + setStyleName(w.getElement(), StyleConstants.DISABLED, !isEnabled()); } else { hasEnabled .setEnabled(isOptionEnabled && optionGroupEnabled); - setStyleName(w.getElement(), - ApplicationConnection.DISABLED_CLASSNAME, + setStyleName(w.getElement(), StyleConstants.DISABLED, !(isOptionEnabled && isEnabled())); } } diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java index 9845e89dab..3649afc74f 100644 --- a/client/src/com/vaadin/client/ui/VOverlay.java +++ b/client/src/com/vaadin/client/ui/VOverlay.java @@ -44,6 +44,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComputedStyle; import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; /** * <p> @@ -672,7 +673,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { // 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 if (BrowserInfo.get().isIE9() || BrowserInfo.get().isIE10()) { - Util.forceIERedraw(getElement()); + WidgetUtil.forceIERedraw(getElement()); } } diff --git a/client/src/com/vaadin/client/ui/VPopupView.java b/client/src/com/vaadin/client/ui/VPopupView.java index 1923fc55e6..0f4e68acab 100644 --- a/client/src/com/vaadin/client/ui/VPopupView.java +++ b/client/src/com/vaadin/client/ui/VPopupView.java @@ -33,7 +33,14 @@ import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.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.ComponentConnector; import com.vaadin.client.DeferredWorker; diff --git a/client/src/com/vaadin/client/ui/VProgressBar.java b/client/src/com/vaadin/client/ui/VProgressBar.java index 00646f7a5e..348791728f 100644 --- a/client/src/com/vaadin/client/ui/VProgressBar.java +++ b/client/src/com/vaadin/client/ui/VProgressBar.java @@ -21,8 +21,7 @@ import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ApplicationConnection; -import com.vaadin.shared.ui.progressindicator.ProgressBarState; +import com.vaadin.client.StyleConstants; /** * Widget for showing the current progress of a long running task. @@ -37,6 +36,8 @@ import com.vaadin.shared.ui.progressindicator.ProgressBarState; */ public class VProgressBar extends Widget implements HasEnabled { + public static final String PRIMARY_STYLE_NAME = "v-progressbar"; + Element wrapper = DOM.createDiv(); Element indicator = DOM.createDiv(); @@ -49,7 +50,7 @@ public class VProgressBar extends Widget implements HasEnabled { getElement().appendChild(wrapper); wrapper.appendChild(indicator); - setStylePrimaryName(ProgressBarState.PRIMARY_STYLE_NAME); + setStylePrimaryName(PRIMARY_STYLE_NAME); } /* @@ -94,7 +95,7 @@ public class VProgressBar extends Widget implements HasEnabled { public void setEnabled(boolean enabled) { if (this.enabled != enabled) { this.enabled = enabled; - setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled); + setStyleName(StyleConstants.DISABLED, !enabled); } } } diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 14e4c658ad..78db5c4096 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -91,6 +91,7 @@ import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.VConsole; import com.vaadin.client.VTooltip; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow; import com.vaadin.client.ui.dd.DDUtil; import com.vaadin.client.ui.dd.VAbstractDropHandler; @@ -510,8 +511,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, @Override 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); if (menuShown) { event.stopPropagation(); @@ -796,8 +797,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Event's reported target not always correct if event // capture is in use - Element elementUnderMouse = Util.getElementUnderMouse(event - .getNativeEvent()); + Element elementUnderMouse = WidgetUtil + .getElementUnderMouse(event.getNativeEvent()); if (lastMouseDownTarget != null && lastMouseDownTarget.isOrHasChild(elementUnderMouse)) { mouseUpPreviewMatched = true; @@ -2244,7 +2245,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, int w = total; w += scrollBody.getCellExtraWidth() * visibleColOrder.length; if (willHaveScrollbarz) { - w += Util.getNativeScrollbarSize(); + w += WidgetUtil.getNativeScrollbarSize(); } setContentWidth(w); } @@ -2257,7 +2258,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, availW -= scrollBody.getCellExtraWidth() * visibleColOrder.length; if (willHaveScrollbarz) { - availW -= Util.getNativeScrollbarSize(); + availW -= WidgetUtil.getNativeScrollbarSize(); } // TODO refactor this code to be the same as in resize timer @@ -2429,10 +2430,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } boolean needsSpaceForHorizontalSrollbar = (total > availW); if (needsSpaceForHorizontalSrollbar) { - bodyHeight += Util.getNativeScrollbarSize(); + bodyHeight += WidgetUtil.getNativeScrollbarSize(); } scrollBodyPanel.setHeight(bodyHeight + "px"); - Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement()); + WidgetUtil.runWebkitOverflowAutoFix(scrollBodyPanel.getElement()); } isNewBody = false; @@ -2463,7 +2464,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * Ensures the column alignments are correct at initial loading. <br/> * (child components widths are correct) */ - Util.runWebkitOverflowAutoFixDeferred(scrollBodyPanel.getElement()); + WidgetUtil.runWebkitOverflowAutoFixDeferred(scrollBodyPanel + .getElement()); hadScrollBars = willHaveScrollbarz; } @@ -3118,7 +3120,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, case Event.ONTOUCHSTART: case Event.ONMOUSEDOWN: if (columnReordering - && Util.isTouchEventOrLeftMouseButton(event)) { + && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { if (event.getTypeInt() == Event.ONTOUCHSTART) { /* * prevent using this event in e.g. scrolling @@ -3138,11 +3140,11 @@ public class VScrollTable extends FlowPanel implements HasWidgets, case Event.ONTOUCHEND: case Event.ONTOUCHCANCEL: if (columnReordering - && Util.isTouchEventOrLeftMouseButton(event)) { + && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { dragging = false; DOM.releaseCapture(getElement()); - if (Util.isTouchEvent(event)) { + if (WidgetUtil.isTouchEvent(event)) { /* * Prevent using in e.g. scrolling and prevent generated * events. @@ -3168,7 +3170,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (!moved) { // mouse event was a click to header -> sort column - if (sortable && Util.isTouchEventOrLeftMouseButton(event)) { + if (sortable + && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { if (sortColumn.equals(cid)) { // just toggle order client.updateVariable(paintableId, "sortascending", @@ -3190,7 +3193,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, rowRequestHandler.run(); // run immediately } fireHeaderClickedEvent(event); - if (Util.isTouchEvent(event)) { + if (WidgetUtil.isTouchEvent(event)) { /* * Prevent using in e.g. scrolling and prevent generated * events. @@ -3206,7 +3209,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, break; case Event.ONTOUCHMOVE: case Event.ONMOUSEMOVE: - if (dragging && Util.isTouchEventOrLeftMouseButton(event)) { + if (dragging && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { if (event.getTypeInt() == Event.ONTOUCHMOVE) { /* * prevent using this event in e.g. scrolling @@ -3218,7 +3221,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, moved = true; } - final int clientX = Util.getTouchOrMouseClientX(event); + final int clientX = WidgetUtil + .getTouchOrMouseClientX(event); final int x = clientX + tHead.hTableWrapper.getScrollLeft(); int slotX = headerX; closestSlot = colIndex; @@ -3256,7 +3260,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private void onResizeEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: - if (!Util.isTouchEventOrLeftMouseButton(event)) { + if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) { return; } isResizing = true; @@ -3267,7 +3271,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, DOM.eventPreventDefault(event); break; case Event.ONMOUSEUP: - if (!Util.isTouchEventOrLeftMouseButton(event)) { + if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) { return; } isResizing = false; @@ -3284,7 +3288,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, fireColumnResizeEvent(cid, originalWidth, getColWidth(cid)); break; case Event.ONMOUSEMOVE: - if (!Util.isTouchEventOrLeftMouseButton(event)) { + if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) { return; } if (isResizing) { @@ -4722,7 +4726,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, */ public int getRequiredHeight() { return preSpacer.getOffsetHeight() + postSpacer.getOffsetHeight() - + Util.getRequiredHeight(table); + + WidgetUtil.getRequiredHeight(table); } private void constructDOM() { @@ -5936,8 +5940,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (!BrowserInfo.get().isAndroid()) { event.preventDefault(); event.stopPropagation(); - Util.simulateClickFromTouchEvent(touchStart, - this); + WidgetUtil.simulateClickFromTouchEvent( + touchStart, this); } touchStart = null; } @@ -5996,7 +6000,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, */ if (mouseUpPreviewMatched && lastMouseDownTarget != null - && lastMouseDownTarget == getElementTdOrTr(Util + && lastMouseDownTarget == getElementTdOrTr(WidgetUtil .getElementUnderMouse(event))) { // "Click" with left, right or middle button @@ -6123,7 +6127,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * Touch has not been handled as neither context or * drag start, handle it as a click. */ - Util.simulateClickFromTouchEvent(touchStart, this); + WidgetUtil.simulateClickFromTouchEvent(touchStart, + this); touchStart = null; } touchContextProvider.cancel(); @@ -6225,7 +6230,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * the corresponding mouseup event if it's on a * different part of the page. */ - lastMouseDownTarget = getElementTdOrTr(Util + lastMouseDownTarget = getElementTdOrTr(WidgetUtil .getElementUnderMouse(event)); mouseUpPreviewMatched = false; mouseUpEventPreviewRegistration = Event @@ -6370,7 +6375,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private Element getElementTdOrTr(Element element) { - Widget widget = Util.findWidget(element, null); + Widget widget = WidgetUtil.findWidget(element, null); if (widget != this) { /* @@ -6397,9 +6402,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets, public void showContextMenu(Event event) { if (enabled && actionKeys != null) { // Show context menu if there are registered action handlers - int left = Util.getTouchOrMouseClientX(event) + int left = WidgetUtil.getTouchOrMouseClientX(event) + Window.getScrollLeft(); - int top = Util.getTouchOrMouseClientY(event) + int top = WidgetUtil.getTouchOrMouseClientY(event) + Window.getScrollTop(); showContextMenu(left, top); } @@ -6678,8 +6683,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets, .getVisibleCellCount(); ix++) { spanWidth += tHead.getHeaderCell(ix).getOffsetWidth(); } - Util.setWidthExcludingPaddingAndBorder((Element) getElement() - .getChild(cellIx), spanWidth, 13, false); + WidgetUtil.setWidthExcludingPaddingAndBorder( + (Element) getElement().getChild(cellIx), spanWidth, 13, + false); } } @@ -6869,7 +6875,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, int totalExtraWidth = scrollBody.getCellExtraWidth() * visibleCellCount; if (willHaveScrollbars()) { - totalExtraWidth += Util.getNativeScrollbarSize(); + totalExtraWidth += WidgetUtil.getNativeScrollbarSize(); } availW -= totalExtraWidth; int forceScrollBodyWidth = -1; @@ -6999,7 +7005,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, int bodyHeight = scrollBody.getRequiredHeight(); boolean needsSpaceForHorizontalScrollbar = (availW < usedMinimumWidth); if (needsSpaceForHorizontalScrollbar) { - bodyHeight += Util.getNativeScrollbarSize(); + bodyHeight += WidgetUtil.getNativeScrollbarSize(); } int heightBefore = getOffsetHeight(); scrollBodyPanel.setHeight(bodyHeight + "px"); @@ -7044,7 +7050,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, */ private int getBorderWidth() { if (borderWidth < 0) { - borderWidth = Util.measureHorizontalPaddingAndBorder( + borderWidth = WidgetUtil.measureHorizontalPaddingAndBorder( scrollBodyPanel.getElement(), 2); if (borderWidth < 0) { borderWidth = 0; @@ -7373,7 +7379,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, Class<? extends Widget> clazz = getRowClass(); VScrollTableRow row = null; if (clazz != null) { - row = Util.findWidget(elementOver, clazz); + row = WidgetUtil.findWidget(elementOver, clazz); } if (row != null) { dropDetails.overkey = row.rowKey; @@ -7565,7 +7571,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * 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. */ - Util.scrollIntoViewVertically(row.getElement()); + WidgetUtil.scrollIntoViewVertically(row.getElement()); } /** @@ -7866,7 +7872,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * ...and sometimes it sends blur events even though the focus * handler is still active. (#10464) */ - Element focusedElement = Util.getIEFocusedElement(); + Element focusedElement = WidgetUtil.getFocusedElement(); if (Util.getConnectorForElement(client, getParent(), focusedElement) == this && focusedElement != null && focusedElement != scrollBodyPanel.getFocusElement()) { @@ -8175,7 +8181,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, @Override 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) { return SUBPART_HEADER + "[" + tHead.visibleCells.indexOf(widget) + "]"; diff --git a/client/src/com/vaadin/client/ui/VSlider.java b/client/src/com/vaadin/client/ui/VSlider.java index 27c8522f37..f5769ddf74 100644 --- a/client/src/com/vaadin/client/ui/VSlider.java +++ b/client/src/com/vaadin/client/ui/VSlider.java @@ -34,7 +34,7 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasValue; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.ui.slider.SliderOrientation; public class VSlider extends SimpleFocusablePanel implements Field, @@ -299,7 +299,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { feedbackPopup.show(); } - if (Util.isTouchEvent(event)) { + if (WidgetUtil.isTouchEvent(event)) { event.preventDefault(); // avoid simulated events event.stopPropagation(); } @@ -423,9 +423,9 @@ public class VSlider extends SimpleFocusablePanel implements Field, */ protected int getEventPosition(Event event) { if (isVertical()) { - return Util.getTouchOrMouseClientY(event); + return WidgetUtil.getTouchOrMouseClientY(event); } else { - return Util.getTouchOrMouseClientX(event); + return WidgetUtil.getTouchOrMouseClientX(event); } } diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 96af09bb32..c8984ece51 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -63,7 +63,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.Focusable; import com.vaadin.client.TooltipInfo; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VCaption; import com.vaadin.client.VTooltip; import com.vaadin.client.ui.aria.AriaHelper; @@ -415,7 +415,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, SubPartAware public int getRequiredWidth() { int width = super.getRequiredWidth(); if (closeButton != null) { - width += Util.getRequiredWidth(closeButton); + width += WidgetUtil.getRequiredWidth(closeButton); } return width; } @@ -1330,7 +1330,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, SubPartAware /** For internal use only. May be removed or replaced in the future. */ public int getContentAreaBorderWidth() { - return Util.measureHorizontalBorder(contentNode); + return WidgetUtil.measureHorizontalBorder(contentNode); } @Override diff --git a/client/src/com/vaadin/client/ui/VTextArea.java b/client/src/com/vaadin/client/ui/VTextArea.java index bb48b29e61..50930f2fee 100644 --- a/client/src/com/vaadin/client/ui/VTextArea.java +++ b/client/src/com/vaadin/client/ui/VTextArea.java @@ -32,7 +32,7 @@ import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.vaadin.client.BrowserInfo; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.dd.DragImageModifier; /** @@ -310,7 +310,7 @@ public class VTextArea extends VTextField implements DragImageModifier { // and reattach the whole TextArea. // Webkit fails to properly reflow the text when enabling wrapping, // same workaround - Util.detachAttach(getElement()); + WidgetUtil.detachAttach(getElement()); } this.wordwrap = wordwrap; } diff --git a/client/src/com/vaadin/client/ui/VTextField.java b/client/src/com/vaadin/client/ui/VTextField.java index b402ced218..1554bd1a22 100644 --- a/client/src/com/vaadin/client/ui/VTextField.java +++ b/client/src/com/vaadin/client/ui/VTextField.java @@ -34,7 +34,7 @@ import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.TextBoxBase; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.EventId; import com.vaadin.shared.ui.textfield.TextFieldConstants; @@ -422,7 +422,7 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler, * @return true iff the value was updated */ protected boolean updateCursorPosition() { - if (Util.isAttachedAndDisplayed(this)) { + if (WidgetUtil.isAttachedAndDisplayed(this)) { int cursorPos = getCursorPos(); if (lastCursorPos != cursorPos) { client.updateVariable(paintableId, diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java index 82ffaced1f..6539eb49a9 100644 --- a/client/src/com/vaadin/client/ui/VTree.java +++ b/client/src/com/vaadin/client/ui/VTree.java @@ -60,6 +60,7 @@ import com.vaadin.client.ConnectorMap; import com.vaadin.client.MouseEventDetailsBuilder; 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.HandlesAriaCaption; import com.vaadin.client.ui.dd.DDUtil; @@ -346,7 +347,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, } 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; } @@ -1132,7 +1133,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, * Scrolls the caption into view */ public void scrollIntoView() { - Util.scrollIntoViewVertically(nodeCaptionDiv); + WidgetUtil.scrollIntoViewVertically(nodeCaptionDiv); } public void setIcon(String iconUrl, String altText) { @@ -2143,7 +2144,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, return "fe"; } - TreeNode treeNode = Util.findWidget(subElement, TreeNode.class); + TreeNode treeNode = WidgetUtil.findWidget(subElement, TreeNode.class); if (treeNode == null) { // Did not click on a node, let somebody else take care of the // locator string diff --git a/client/src/com/vaadin/client/ui/VTreeTable.java b/client/src/com/vaadin/client/ui/VTreeTable.java index 9e5940a2f2..0ba84af4bb 100644 --- a/client/src/com/vaadin/client/ui/VTreeTable.java +++ b/client/src/com/vaadin/client/ui/VTreeTable.java @@ -37,7 +37,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComputedStyle; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.VTreeTable.VTreeTableScrollBody.VTreeTableRow; public class VTreeTable extends VScrollTable { @@ -418,8 +418,9 @@ public class VTreeTable extends VScrollTable { .getVisibleCellCount(); ix++) { spanWidth += tHead.getHeaderCell(ix).getOffsetWidth(); } - Util.setWidthExcludingPaddingAndBorder((Element) getElement() - .getChild(cellIx), spanWidth, 13, false); + WidgetUtil.setWidthExcludingPaddingAndBorder( + (Element) getElement().getChild(cellIx), spanWidth, 13, + false); } } diff --git a/client/src/com/vaadin/client/ui/VTwinColSelect.java b/client/src/com/vaadin/client/ui/VTwinColSelect.java index 3987460989..853bd8d456 100644 --- a/client/src/com/vaadin/client/ui/VTwinColSelect.java +++ b/client/src/com/vaadin/client/ui/VTwinColSelect.java @@ -37,9 +37,9 @@ import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.Panel; -import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.StyleConstants; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.ui.twincolselect.TwinColSelectConstants; public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, @@ -352,7 +352,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, /** For internal use only. May be removed or replaced in the future. */ public void setInternalHeights() { - int captionHeight = Util.getRequiredHeight(captionWrapper); + int captionHeight = WidgetUtil.getRequiredHeight(captionWrapper); int totalHeight = getOffsetHeight(); String selectHeight = (totalHeight - captionHeight) + "px"; @@ -394,10 +394,10 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, /** For internal use only. May be removed or replaced in the future. */ public void setInternalWidths() { getElement().getStyle().setPosition(Position.RELATIVE); - int bordersAndPaddings = Util.measureHorizontalPaddingAndBorder( + int bordersAndPaddings = WidgetUtil.measureHorizontalPaddingAndBorder( buttons.getElement(), 0); - int buttonWidth = Util.getRequiredWidth(buttons); + int buttonWidth = WidgetUtil.getRequiredWidth(buttons); int totalWidth = getOffsetWidth(); int spaceForSelect = (totalWidth - buttonWidth - bordersAndPaddings) / 2; @@ -429,8 +429,8 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, selections.setEnabled(enabled); add.setEnabled(enabled); remove.setEnabled(enabled); - add.setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled); - remove.setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled); + add.setStyleName(StyleConstants.DISABLED, !enabled); + remove.setStyleName(StyleConstants.DISABLED, !enabled); } @Override @@ -609,14 +609,14 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, if (options.getElement() == subElement) { return SUBPART_OPTION_SELECT; } else { - int idx = Util.getChildElementIndex(subElement); + int idx = WidgetUtil.getChildElementIndex(subElement); return SUBPART_OPTION_SELECT_ITEM + idx; } } else if (selections.getElement().isOrHasChild(subElement)) { if (selections.getElement() == subElement) { return SUBPART_SELECTION_SELECT; } else { - int idx = Util.getChildElementIndex(subElement); + int idx = WidgetUtil.getChildElementIndex(subElement); return SUBPART_SELECTION_SELECT_ITEM + idx; } } else if (add.getElement().isOrHasChild(subElement)) { diff --git a/client/src/com/vaadin/client/ui/VUI.java b/client/src/com/vaadin/client/ui/VUI.java index eae4f6319d..0c1b83ab0f 100644 --- a/client/src/com/vaadin/client/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/VUI.java @@ -44,7 +44,7 @@ import com.vaadin.client.ConnectorMap; import com.vaadin.client.Focusable; import com.vaadin.client.LayoutManager; import com.vaadin.client.Profiler; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; @@ -501,7 +501,7 @@ public class VUI extends SimplePanel implements ResizeHandler, * @param focusedElement */ public void storeFocus() { - storedFocus = Util.getFocusedElement(); + storedFocus = WidgetUtil.getFocusedElement(); } /** diff --git a/client/src/com/vaadin/client/ui/VUpload.java b/client/src/com/vaadin/client/ui/VUpload.java index 42fb08fb3c..dff45a6951 100644 --- a/client/src/com/vaadin/client/ui/VUpload.java +++ b/client/src/com/vaadin/client/ui/VUpload.java @@ -36,6 +36,7 @@ import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.SimplePanel; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; +import com.vaadin.client.StyleConstants; import com.vaadin.client.VConsole; import com.vaadin.client.ui.upload.UploadIFrameOnloadStrategy; @@ -211,8 +212,7 @@ public class VUpload extends SimplePanel { private void setEnabledForSubmitButton(boolean enabled) { submitButton.setEnabled(enabled); - submitButton.setStyleName(ApplicationConnection.DISABLED_CLASSNAME, - !enabled); + submitButton.setStyleName(StyleConstants.DISABLED, !enabled); } /** diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index eb3c89beb0..28918bb393 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -16,7 +16,7 @@ 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.Arrays; @@ -62,7 +62,7 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorMap; import com.vaadin.client.Focusable; 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.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.aria.AriaHelper; @@ -581,7 +581,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, * ticket #11994 which was changing the size to 110% was replaced * with this due to ticket #12943 */ - Util.runWebkitOverflowAutoFix(contents.getFirstChildElement()); + WidgetUtil + .runWebkitOverflowAutoFix(contents.getFirstChildElement()); } } @@ -878,7 +879,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, public void setCaption(String c, String iconURL, boolean asHtml) { String html = c; if (!asHtml) { - c = Util.escapeHTML(c); + c = WidgetUtil.escapeHTML(c); } // Provide information to assistive device users that a sub window was @@ -1038,7 +1039,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } private void onResizeEvent(Event event) { - if (resizable && Util.isTouchEventOrLeftMouseButton(event)) { + if (resizable && WidgetUtil.isTouchEventOrLeftMouseButton(event)) { switch (event.getTypeInt()) { case Event.ONMOUSEDOWN: case Event.ONTOUCHSTART: @@ -1050,8 +1051,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, resizeBox.getStyle().setVisibility(Visibility.HIDDEN); } resizing = true; - startX = Util.getTouchOrMouseClientX(event); - startY = Util.getTouchOrMouseClientY(event); + startX = WidgetUtil.getTouchOrMouseClientX(event); + startY = WidgetUtil.getTouchOrMouseClientY(event); origW = getElement().getOffsetWidth(); origH = getElement().getOffsetHeight(); DOM.setCapture(getElement()); @@ -1117,8 +1118,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, 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()); h = Math.max(h, getMinHeight()); @@ -1181,7 +1182,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } private void onDragEvent(Event event) { - if (!Util.isTouchEventOrLeftMouseButton(event)) { + if (!WidgetUtil.isTouchEventOrLeftMouseButton(event)) { return; } @@ -1216,9 +1217,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, centered = false; if (cursorInsideBrowserContentArea(event)) { // 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; - final int y = Util.getTouchOrMouseClientY(event) - startY + final int y = WidgetUtil.getTouchOrMouseClientY(event) - startY + origY; setPopupPosition(x, y); } @@ -1230,8 +1231,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, if (draggable) { showDraggingCurtain(); dragging = true; - startX = Util.getTouchOrMouseClientX(event); - startY = Util.getTouchOrMouseClientY(event); + startX = WidgetUtil.getTouchOrMouseClientX(event); + startY = WidgetUtil.getTouchOrMouseClientY(event); origX = DOM.getAbsoluteLeft(getElement()); origY = DOM.getAbsoluteTop(getElement()); DOM.setCapture(getElement()); @@ -1279,7 +1280,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, if (!DOM.isOrHasChild(getTopmostWindow().getElement(), target)) { // not within the modal window, but let's see if it's in the // debug window - Widget w = Util.findWidget(target, null); + Widget w = WidgetUtil.findWidget(target, null); while (w != null) { if (w instanceof VDebugWindow) { return true; // allow debug-window clicks diff --git a/client/src/com/vaadin/client/ui/accordion/AccordionConnector.java b/client/src/com/vaadin/client/ui/accordion/AccordionConnector.java index 72aa2dbdfd..949e19071c 100644 --- a/client/src/com/vaadin/client/ui/accordion/AccordionConnector.java +++ b/client/src/com/vaadin/client/ui/accordion/AccordionConnector.java @@ -17,7 +17,7 @@ package com.vaadin.client.ui.accordion; import com.vaadin.client.ComponentConnector; 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.ui.SimpleManagedLayout; import com.vaadin.client.ui.VAccordion; @@ -106,7 +106,8 @@ public class AccordionConnector extends TabsheetBaseConnector implements usedPixels += item.getCaptionHeight(); } else { // This includes the captionNode borders - usedPixels += Util.getRequiredHeight(item.getElement()); + usedPixels += WidgetUtil.getRequiredHeight(item + .getElement()); } } int rootElementInnerHeight = getLayoutManager().getInnerHeight( diff --git a/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java b/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java index 8c92ef1233..e9bbf2015c 100644 --- a/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java +++ b/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java @@ -35,7 +35,7 @@ import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Paintable; import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; @@ -422,7 +422,7 @@ public class CalendarConnector extends AbstractComponentConnector implements @Override public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) { TooltipInfo tooltipInfo = null; - Widget w = Util.findWidget(element, null); + Widget w = WidgetUtil.findWidget(element, null); if (w instanceof HasTooltipKey) { tooltipInfo = GWT.create(TooltipInfo.class); String title = tooltips.get(((HasTooltipKey) w).getTooltipKey()); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java index 448083ba26..39d516b694 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java @@ -43,7 +43,7 @@ import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; public class DateCell extends FocusableComplexPanel implements MouseDownHandler, MouseMoveHandler, MouseUpHandler, KeyDownHandler, @@ -201,7 +201,7 @@ public class DateCell extends FocusableComplexPanel implements addStyleDependentName("Hsized"); width = getOffsetWidth() - - Util.measureHorizontalBorder(getElement()); + - WidgetUtil.measureHorizontalBorder(getElement()); // Update moveWidth for any DateCellDayEvent child updateEventCellsWidth(); recalculateEventWidths(); @@ -338,7 +338,7 @@ public class DateCell extends FocusableComplexPanel implements } public int getSlotBorder() { - return Util.measureVerticalBorder(slotElements[0]); + return WidgetUtil.measureVerticalBorder(slotElements[0]); } private void drawDayEvents(List<DateCellGroup> groups) { diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java index 82af89c794..26f5951987 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java @@ -23,7 +23,7 @@ import com.google.gwt.event.dom.client.MouseUpEvent; import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.VCalendar; /** @@ -48,7 +48,7 @@ public class DateCellContainer extends FlowPanel implements MouseDownHandler, public static int measureBorderWidth(DateCellContainer dc) { if (borderWidth == -1) { - borderWidth = Util.measureHorizontalBorder(dc.getElement()); + borderWidth = WidgetUtil.measureHorizontalBorder(dc.getElement()); } return borderWidth; } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java index 8b08e9bc7a..1a54fe0454 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java @@ -41,7 +41,7 @@ import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.HorizontalPanel; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.ui.calendar.DateConstants; /** @@ -190,7 +190,7 @@ public class DateCellDayEvent extends FocusableHTML implements if (dateCell.weekgrid.getCalendar().isEventCaptionAsHtml()) { htmlOrText = calendarEvent.getCaption(); } else { - htmlOrText = Util.escapeHTML(calendarEvent.getCaption()); + htmlOrText = WidgetUtil.escapeHTML(calendarEvent.getCaption()); } if (bigMode) { diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java index 545ddadc52..aecaff1931 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java @@ -31,7 +31,7 @@ import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.DateTimeService; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.ui.VCalendar; import com.vaadin.shared.ui.calendar.DateConstants; @@ -160,7 +160,7 @@ public class WeekGrid extends SimplePanel { // Otherwise the scroll wrapper is somehow too narrow = horizontal // scroll wrapper.setWidth(content.getOffsetWidth() - + Util.getNativeScrollbarSize() + "px"); + + WidgetUtil.getNativeScrollbarSize() + "px"); this.width = content.getOffsetWidth() - timebar.getOffsetWidth(); @@ -169,7 +169,7 @@ public class WeekGrid extends SimplePanel { - timebar.getOffsetWidth(); if (isVerticalScrollable() && width != -1) { - this.width = this.width - Util.getNativeScrollbarSize(); + this.width = this.width - WidgetUtil.getNativeScrollbarSize(); } updateCellWidths(); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java index 9cab421200..39e08e9d70 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java @@ -17,7 +17,7 @@ package com.vaadin.client.ui.calendar.schedule.dd; import com.google.gwt.dom.client.Element; 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.schedule.SimpleDayCell; import com.vaadin.client.ui.dd.VAcceptCallback; @@ -51,7 +51,7 @@ public class CalendarMonthDropHandler extends CalendarDropHandler { protected void dragAccepted(VDragEvent drag) { deEmphasis(); currentTargetElement = drag.getElementOver(); - currentTargetDay = Util.findWidget(currentTargetElement, + currentTargetDay = WidgetUtil.findWidget(currentTargetElement, SimpleDayCell.class); emphasis(); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java index 853e4b724e..e0edf21e89 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java @@ -17,7 +17,7 @@ package com.vaadin.client.ui.calendar.schedule.dd; import com.google.gwt.dom.client.Element; 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.schedule.DateCell; import com.vaadin.client.ui.calendar.schedule.DateCellDayEvent; @@ -52,8 +52,8 @@ public class CalendarWeekDropHandler extends CalendarDropHandler { protected void dragAccepted(VDragEvent drag) { deEmphasis(); currentTargetElement = drag.getElementOver(); - currentTargetDay = Util - .findWidget(currentTargetElement, DateCell.class); + currentTargetDay = WidgetUtil.findWidget(currentTargetElement, + DateCell.class); emphasis(); } @@ -121,7 +121,7 @@ public class CalendarWeekDropHandler extends CalendarDropHandler { return DOM.isOrHasChild(weekGridElement, elementOver) && !DOM.isOrHasChild(timeBarElement, elementOver) && todayBarElement != elementOver - && (Util.findWidget(elementOver, DateCellDayEvent.class) == null); + && (WidgetUtil.findWidget(elementOver, DateCellDayEvent.class) == null); } /* diff --git a/client/src/com/vaadin/client/ui/dd/DDUtil.java b/client/src/com/vaadin/client/ui/dd/DDUtil.java index 77de1f9b1a..fdccd61767 100644 --- a/client/src/com/vaadin/client/ui/dd/DDUtil.java +++ b/client/src/com/vaadin/client/ui/dd/DDUtil.java @@ -18,7 +18,7 @@ package com.vaadin.client.ui.dd; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; 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.VerticalDropLocation; @@ -33,7 +33,7 @@ public class DDUtil { public static VerticalDropLocation getVerticalDropLocation(Element element, int offsetHeight, NativeEvent event, double topBottomRatio) { - int clientY = Util.getTouchOrMouseClientY(event); + int clientY = WidgetUtil.getTouchOrMouseClientY(event); return getVerticalDropLocation(element, offsetHeight, clientY, topBottomRatio); } @@ -59,7 +59,7 @@ public class DDUtil { public static HorizontalDropLocation getHorizontalDropLocation( 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 // position is relative to the document. Make element position relative diff --git a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java index 4ee19328d6..844f4c1b9c 100644 --- a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java +++ b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java @@ -38,7 +38,7 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.Profiler; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; import com.vaadin.client.ValueMap; import com.vaadin.client.ui.VOverlay; @@ -92,16 +92,16 @@ public class VDragAndDropManager { targetElement = targetNode.getParentElement(); } - if (Util.isTouchEvent(nativeEvent) || dragElement != null) { + if (WidgetUtil.isTouchEvent(nativeEvent) || dragElement != null) { // to detect the "real" target, hide dragelement temporary and // use elementFromPoint String display = dragElement.getStyle().getDisplay(); dragElement.getStyle().setDisplay(Display.NONE); try { - int x = Util.getTouchOrMouseClientX(nativeEvent); - int y = Util.getTouchOrMouseClientY(nativeEvent); + int x = WidgetUtil.getTouchOrMouseClientX(nativeEvent); + int y = WidgetUtil.getTouchOrMouseClientY(nativeEvent); // Util.browserDebugger(); - targetElement = Util.getElementFromPoint(x, y); + targetElement = WidgetUtil.getElementFromPoint(x, y); if (targetElement == null) { // ApplicationConnection.getConsole().log( // "Event on dragImage, ignored"); @@ -361,10 +361,10 @@ public class VDragAndDropManager { deferredStartRegistration = Event .addNativePreviewHandler(new NativePreviewHandler() { - private int startX = Util + private int startX = WidgetUtil .getTouchOrMouseClientX(currentDrag .getCurrentGwtEvent()); - private int startY = Util + private int startY = WidgetUtil .getTouchOrMouseClientY(currentDrag .getCurrentGwtEvent()); @@ -419,10 +419,10 @@ public class VDragAndDropManager { } case Event.ONMOUSEMOVE: case Event.ONTOUCHMOVE: - int currentX = Util + int currentX = WidgetUtil .getTouchOrMouseClientX(event .getNativeEvent()); - int currentY = Util + int currentY = WidgetUtil .getTouchOrMouseClientY(event .getNativeEvent()); if (Math.abs(startX - currentX) > 3 @@ -462,9 +462,9 @@ public class VDragAndDropManager { private void updateDragImagePosition() { if (currentDrag.getCurrentGwtEvent() != null && dragElement != null) { Style style = dragElement.getStyle(); - int clientY = Util.getTouchOrMouseClientY(currentDrag + int clientY = WidgetUtil.getTouchOrMouseClientY(currentDrag .getCurrentGwtEvent()); - int clientX = Util.getTouchOrMouseClientX(currentDrag + int clientX = WidgetUtil.getTouchOrMouseClientX(currentDrag .getCurrentGwtEvent()); style.setTop(clientY, Unit.PX); style.setLeft(clientX, Unit.PX); @@ -480,7 +480,7 @@ public class VDragAndDropManager { */ private VDropHandler findDragTarget(Element element) { try { - Widget w = Util.findWidget(element, null); + Widget w = WidgetUtil.findWidget(element, null); if (w == null) { return null; } diff --git a/client/src/com/vaadin/client/ui/dd/VDragEvent.java b/client/src/com/vaadin/client/ui/dd/VDragEvent.java index 45f89bdb87..c889dbf34e 100644 --- a/client/src/com/vaadin/client/ui/dd/VDragEvent.java +++ b/client/src/com/vaadin/client/ui/dd/VDragEvent.java @@ -30,7 +30,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; 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, @@ -262,8 +262,8 @@ public class VDragEvent { if (alignImageToEvent) { int absoluteTop = element.getAbsoluteTop(); 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 offsetY = absoluteTop - clientY; setDragImage(cloneNode, offsetX, offsetY); diff --git a/client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java b/client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java index 494a1a87ff..9517619cf3 100644 --- a/client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/formlayout/FormLayoutConnector.java @@ -20,7 +20,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; 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.ui.AbstractFieldConnector; import com.vaadin.client.ui.AbstractLayoutConnector; @@ -114,14 +114,16 @@ public class FormLayoutConnector extends AbstractLayoutConnector { TooltipInfo info = null; if (element != getWidget().getElement()) { - Object node = Util.findWidget(element, VFormLayout.Caption.class); + Object node = WidgetUtil.findWidget(element, + VFormLayout.Caption.class); if (node != null) { VFormLayout.Caption caption = (VFormLayout.Caption) node; info = caption.getOwner().getTooltipInfo(element); } else { - node = Util.findWidget(element, VFormLayout.ErrorFlag.class); + node = WidgetUtil.findWidget(element, + VFormLayout.ErrorFlag.class); if (node != null) { VFormLayout.ErrorFlag flag = (VFormLayout.ErrorFlag) node; diff --git a/client/src/com/vaadin/client/ui/label/LabelConnector.java b/client/src/com/vaadin/client/ui/label/LabelConnector.java index 07defcc64d..fc94f27cf0 100644 --- a/client/src/com/vaadin/client/ui/label/LabelConnector.java +++ b/client/src/com/vaadin/client/ui/label/LabelConnector.java @@ -18,7 +18,7 @@ package com.vaadin.client.ui.label; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.PreElement; 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.ui.AbstractComponentConnector; import com.vaadin.client.ui.VLabel; @@ -69,7 +69,7 @@ public class LabelConnector extends AbstractComponentConnector { if (sinkOnloads) { Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); - Util.sinkOnloadForImages(getWidget().getElement()); + WidgetUtil.sinkOnloadForImages(getWidget().getElement()); Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); } } diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index ae866e3354..da3aed4bbc 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -586,7 +586,7 @@ public class LayoutDependencyTree { } private static String getCompactConnectorString(ServerConnector connector) { - return Util.getSimpleName(connector) + " (" + return connector.getClass().getSimpleName() + " (" + connector.getConnectorId() + ")"; } diff --git a/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java b/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java index 20cabf9a36..03eeb85165 100644 --- a/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java +++ b/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java @@ -25,7 +25,7 @@ import com.vaadin.client.ApplicationConnection; import com.vaadin.client.Paintable; import com.vaadin.client.TooltipInfo; 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.ImageIcon; import com.vaadin.client.ui.SimpleManagedLayout; @@ -78,7 +78,7 @@ public class MenuBarConnector extends AbstractComponentConnector implements if (moreItemUIDL.hasAttribute("icon")) { itemHTML.append("<img src=\"" - + Util.escapeAttribute(client + + WidgetUtil.escapeAttribute(client .translateVaadinUri(moreItemUIDL .getStringAttribute("icon"))) + "\" class=\"" + ImageIcon.CLASSNAME diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index c2157650a5..8fa885c2b9 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -30,6 +30,7 @@ import com.vaadin.client.Profiler; import com.vaadin.client.ServerConnector; 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.StateChangeHandler; import com.vaadin.client.ui.AbstractFieldConnector; @@ -387,7 +388,7 @@ public abstract class AbstractOrderedLayoutConnector extends @Override public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) { if (element != getWidget().getElement()) { - Slot slot = Util.findWidget(element, Slot.class); + Slot slot = WidgetUtil.findWidget(element, Slot.class); if (slot != null && slot.getCaptionElement() != null && slot.getParent() == getWidget() && slot.getCaptionElement().isOrHasChild(element)) { diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index 4b60f11ab4..b97cf73989 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -30,7 +30,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.BrowserInfo; import com.vaadin.client.LayoutManager; 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.Icon; import com.vaadin.client.ui.ImageIcon; @@ -74,7 +74,7 @@ public final class Slot extends SimplePanel { public void onElementResize(ElementResizeEvent e) { Element caption = getCaptionElement(); if (caption != null) { - Util.forceIE8Redraw(caption); + WidgetUtil.forceIE8Redraw(caption); } } }; @@ -493,7 +493,7 @@ public final class Slot extends SimplePanel { // Caption wrappers Widget widget = getWidget(); - final Element focusedElement = Util.getFocusedElement(); + final Element focusedElement = WidgetUtil.getFocusedElement(); // By default focus will not be lost boolean focusLost = false; if (captionText != null || icon != null || error != null || required) { @@ -613,7 +613,7 @@ public final class Slot extends SimplePanel { if (focusLost) { // Find out what element is currently focused. - Element currentFocus = Util.getFocusedElement(); + Element currentFocus = WidgetUtil.getFocusedElement(); if (currentFocus != null && currentFocus.equals(Document.get().getBody())) { // Focus has moved to BodyElement and should be moved back to @@ -627,12 +627,12 @@ public final class Slot extends SimplePanel { @Override public void run() { - if (Util.getFocusedElement() == null) { + if (WidgetUtil.getFocusedElement() == null) { // This should never become an infinite loop and // even if it does it will be stopped once something // is done with the browser. schedule(25); - } else if (Util.getFocusedElement().equals( + } else if (WidgetUtil.getFocusedElement().equals( Document.get().getBody())) { // Focus found it's way to BodyElement. Now it can // be restored diff --git a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java index 4c74358753..2e6d4cf5c8 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java @@ -33,6 +33,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.LayoutManager; import com.vaadin.client.Profiler; import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.shared.ui.MarginInfo; /** @@ -674,7 +675,7 @@ public class VAbstractOrderedLayout extends FlowPanel { } } } - Util.forceIE8Redraw(getElement()); + WidgetUtil.forceIE8Redraw(getElement()); } /** diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index 7fb4bc108a..6a9ef6722e 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -31,7 +31,7 @@ import com.vaadin.client.Paintable; import com.vaadin.client.ServerConnector; import com.vaadin.client.TooltipInfo; 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.PostLayoutListener; import com.vaadin.client.ui.VScrollTable; @@ -342,7 +342,7 @@ public class TableConnector extends AbstractHasComponentsConnector implements @Override public void execute() { // IE8 needs some hacks to measure sizes correctly - Util.forceIE8Redraw(getWidget().getElement()); + WidgetUtil.forceIE8Redraw(getWidget().getElement()); getLayoutManager().setNeedsMeasure(TableConnector.this); ServerConnector parent = getParent(); @@ -394,7 +394,7 @@ public class TableConnector extends AbstractHasComponentsConnector implements TooltipInfo info = null; if (element != getWidget().getElement()) { - Object node = Util.findWidget(element, VScrollTableRow.class); + Object node = WidgetUtil.findWidget(element, VScrollTableRow.class); if (node != null) { VScrollTableRow row = (VScrollTableRow) node; diff --git a/client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java b/client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java index d49581eaad..469fc6ba95 100644 --- a/client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java +++ b/client/src/com/vaadin/client/ui/tabsheet/TabsheetConnector.java @@ -20,7 +20,7 @@ import com.google.gwt.dom.client.Style.Overflow; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; 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.ui.SimpleManagedLayout; import com.vaadin.client.ui.VTabsheet; @@ -139,7 +139,8 @@ public class TabsheetConnector extends TabsheetBaseConnector implements // Find a tooltip for the tab, if the element is a tab if (element != getWidget().getElement()) { - Object node = Util.findWidget(element, VTabsheet.TabCaption.class); + Object node = WidgetUtil.findWidget(element, + VTabsheet.TabCaption.class); if (node != null) { VTabsheet.TabCaption caption = (VTabsheet.TabCaption) node; diff --git a/client/src/com/vaadin/client/ui/textarea/TextAreaConnector.java b/client/src/com/vaadin/client/ui/textarea/TextAreaConnector.java index e9dc3e1dd7..3bc0a86df4 100644 --- a/client/src/com/vaadin/client/ui/textarea/TextAreaConnector.java +++ b/client/src/com/vaadin/client/ui/textarea/TextAreaConnector.java @@ -19,7 +19,7 @@ package com.vaadin.client.ui.textarea; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.MouseUpEvent; 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.textfield.TextFieldConnector; import com.vaadin.shared.ui.Connect; diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java index 55224b455f..fc3e6ca0fc 100644 --- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java +++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java @@ -27,7 +27,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.Paintable; import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; -import com.vaadin.client.Util; +import com.vaadin.client.WidgetUtil; import com.vaadin.client.VConsole; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentConnector; @@ -172,7 +172,7 @@ public class TreeConnector extends AbstractComponentConnector implements } // IE8 needs a hack to measure the tree again after update - Util.forceIE8Redraw(getWidget().getElement()); + WidgetUtil.forceIE8Redraw(getWidget().getElement()); getWidget().rendering = false; @@ -333,7 +333,7 @@ public class TreeConnector extends AbstractComponentConnector implements // Try to find a tooltip for a node if (element != getWidget().getElement()) { - Object node = Util.findWidget(element, TreeNode.class); + Object node = WidgetUtil.findWidget(element, TreeNode.class); if (node != null) { TreeNode tnode = (TreeNode) node; diff --git a/client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java b/client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java index 5a42484b28..4aab248e29 100644 --- a/client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java +++ b/client/src/com/vaadin/client/ui/treetable/TreeTableConnector.java @@ -19,7 +19,7 @@ import com.google.gwt.dom.client.Element; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.TooltipInfo; 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.VScrollTable.VScrollTableBody.VScrollTableRow; import com.vaadin.client.ui.VTreeTable; @@ -129,7 +129,7 @@ public class TreeTableConnector extends TableConnector { TooltipInfo info = null; if (element != getWidget().getElement()) { - Object node = Util.findWidget(element, VTreeTableRow.class); + Object node = WidgetUtil.findWidget(element, VTreeTableRow.class); if (node != null) { VTreeTableRow row = (VTreeTableRow) node; diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index d6f14bf158..9e1da113bf 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -76,6 +76,7 @@ import com.vaadin.client.ui.window.WindowConnector; import com.vaadin.server.Page.Styles; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.Version; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; @@ -1014,9 +1015,13 @@ public class UIConnector extends AbstractSingleComponentContainerConnector * @return The URL the theme can be loaded from */ private String getThemeUrl(String theme) { - return getConnection().translateVaadinUri( + String themeUrl = getConnection().translateVaadinUri( ApplicationConstants.VAADIN_PROTOCOL_PREFIX + "themes/" + theme + "/styles" + ".css"); + // Parameter appended to bypass caches after version upgrade. + themeUrl += "?v=" + Version.getFullVersion(); + return themeUrl; + } /** diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java index b3e3c9f70f..b47152b903 100644 --- a/client/src/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java @@ -38,7 +38,7 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; 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.StateChangeEvent; import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; @@ -247,7 +247,7 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector Style childStyle = layoutElement.getStyle(); // IE8 needs some hackery to measure its content correctly - Util.forceIE8Redraw(layoutElement); + WidgetUtil.forceIE8Redraw(layoutElement); if (content.isRelativeHeight() && !BrowserInfo.get().isIE9()) { childStyle.setPosition(Position.ABSOLUTE); diff --git a/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java b/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java index 883bbae0bd..d7122329b7 100644 --- a/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java +++ b/client/src/com/vaadin/client/widget/escalator/ScrollbarBundle.java @@ -31,7 +31,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.Timer; 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.ScrollHandler; @@ -490,7 +490,7 @@ public abstract class ScrollbarBundle implements DeferredWorker { double oldScrollPos = scrollPos; scrollPos = Math.max(0, Math.min(maxScrollPos, truncate(px))); - if (!Util.pixelValuesEqual(oldScrollPos, scrollPos)) { + if (!WidgetUtil.pixelValuesEqual(oldScrollPos, scrollPos)) { if (isInvisibleScrollbar) { invisibleScrollbarTemporaryResizer.show(); } diff --git a/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java b/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java index ea19e04c8e..5024c8bffa 100644 --- a/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java +++ b/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java @@ -32,7 +32,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event.NativePreviewEvent; 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.widget.grid.CellReference; import com.vaadin.client.widget.grid.RendererCellReference; @@ -260,7 +260,7 @@ public class MultiSelectionRenderer<T> extends ComplexRenderer<Boolean> { int constrainedPageY = Math.max(bodyAbsoluteTop, Math.min(bodyAbsoluteBottom, pageY)); - int logicalRow = getLogicalRowIndex(Util.getElementFromPoint( + int logicalRow = getLogicalRowIndex(WidgetUtil.getElementFromPoint( initialPageX, constrainedPageY)); int incrementOrDecrement = (logicalRow > lastModifiedLogicalRow) ? 1 @@ -434,8 +434,8 @@ public class MultiSelectionRenderer<T> extends ComplexRenderer<Boolean> { switch (event.getTypeInt()) { case Event.ONMOUSEMOVE: case Event.ONTOUCHMOVE: - pageY = Util.getTouchOrMouseClientY(nativeEvent); - pageX = Util.getTouchOrMouseClientX(nativeEvent); + pageY = WidgetUtil.getTouchOrMouseClientY(nativeEvent); + pageX = WidgetUtil.getTouchOrMouseClientX(nativeEvent); autoScroller.updatePointerCoords(pageX, pageY); break; case Event.ONMOUSEUP: diff --git a/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java b/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java index 7796425612..528beb5809 100644 --- a/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java +++ b/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java @@ -105,7 +105,7 @@ public class SelectionEvent<T> extends GwtEvent<SelectionHandler> { } /** - * Get a reference to the Grid object that fired this event. + * Gets a reference to the Grid object that fired this event. * * @return a grid reference */ @@ -115,8 +115,8 @@ public class SelectionEvent<T> extends GwtEvent<SelectionHandler> { } /** - * Get all rows added to the selection since the last {@link SelectionEvent} - * . + * Gets all rows added to the selection since the last + * {@link SelectionEvent} . * * @return a collection of added rows. Empty collection if no rows were * added. @@ -126,7 +126,7 @@ public class SelectionEvent<T> extends GwtEvent<SelectionHandler> { } /** - * Get all rows removed from the selection since the last + * Gets all rows removed from the selection since the last * {@link SelectionEvent}. * * @return a collection of removed rows. Empty collection if no rows were @@ -137,6 +137,15 @@ public class SelectionEvent<T> extends GwtEvent<SelectionHandler> { } /** + * Gets currently selected rows. + * + * @return a non-null collection containing all currently selected rows. + */ + public Collection<T> getSelected() { + return grid.getSelectedRows(); + } + + /** * Gets a type identifier for this event. * * @return a {@link Type} identifier. diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java index 57c55d457d..deaa9005c3 100644 --- a/client/src/com/vaadin/client/widgets/Escalator.java +++ b/client/src/com/vaadin/client/widgets/Escalator.java @@ -53,7 +53,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.BrowserInfo; import com.vaadin.client.DeferredWorker; 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.ColumnConfiguration; import com.vaadin.client.widget.escalator.EscalatorUpdater; @@ -74,7 +74,6 @@ import com.vaadin.client.widget.escalator.ScrollbarBundle.VerticalScrollbarBundl import com.vaadin.client.widget.grid.events.ScrollEvent; import com.vaadin.client.widget.grid.events.ScrollHandler; import com.vaadin.client.widgets.Escalator.JsniUtil.TouchHandlerBundle; -import com.vaadin.shared.ui.grid.GridState; import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.Range; import com.vaadin.shared.ui.grid.ScrollDestination; @@ -1061,10 +1060,11 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker final double viewportStartPx = getScrollLeft(); double viewportEndPx = viewportStartPx - + Util.getRequiredWidthBoundingClientRectDouble(getElement()) + + WidgetUtil + .getRequiredWidthBoundingClientRectDouble(getElement()) - frozenPixels; if (verticalScrollbar.showsScrollHandle()) { - viewportEndPx -= Util.getNativeScrollbarSize(); + viewportEndPx -= WidgetUtil.getNativeScrollbarSize(); } final double scrollLeft = getScrollPos(destination, targetStartPx, @@ -1731,9 +1731,8 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker final boolean isVisible = !cell.getStyle().getDisplay() .equals(Display.NONE.getCssName()); if (isVisible) { - maxWidth = Math - .max(maxWidth, - Util.getRequiredWidthBoundingClientRectDouble(cell)); + maxWidth = Math.max(maxWidth, WidgetUtil + .getRequiredWidthBoundingClientRectDouble(cell)); } row = TableRowElement.as(row.getNextSiblingElement()); } @@ -2011,7 +2010,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker cellClone.getStyle().clearWidth(); rowElement.insertBefore(cellClone, cellOriginal); - double requiredWidth = Util + double requiredWidth = WidgetUtil .getRequiredWidthBoundingClientRectDouble(cellClone); if (BrowserInfo.get().isIE9()) { @@ -3681,7 +3680,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker private TableRowElement getEscalatorRowWithFocus() { TableRowElement rowContainingFocus = null; - final Element focusedElement = Util.getFocusedElement(); + final Element focusedElement = WidgetUtil.getFocusedElement(); if (focusedElement != null && root.isOrHasChild(focusedElement)) { Element e = focusedElement; @@ -4266,7 +4265,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker private double heightOfEscalator = 0; /** The height of Escalator in terms of body rows. */ - private double heightByRows = GridState.DEFAULT_HEIGHT_BY_ROWS; + private double heightByRows = 10.0d; /** The height of Escalator, as defined by {@link #setHeight(String)} */ private String heightByCss = ""; @@ -4307,12 +4306,13 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker root.appendChild(verticalScrollbar.getElement()); verticalScrollbar.addScrollHandler(scrollHandler); - verticalScrollbar.setScrollbarThickness(Util.getNativeScrollbarSize()); + verticalScrollbar.setScrollbarThickness(WidgetUtil + .getNativeScrollbarSize()); root.appendChild(horizontalScrollbar.getElement()); horizontalScrollbar.addScrollHandler(scrollHandler); - horizontalScrollbar - .setScrollbarThickness(Util.getNativeScrollbarSize()); + horizontalScrollbar.setScrollbarThickness(WidgetUtil + .getNativeScrollbarSize()); horizontalScrollbar .addVisibilityHandler(new ScrollbarBundle.VisibilityHandler() { @Override @@ -4338,18 +4338,18 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker table.appendChild(footElem); Style hCornerStyle = headerDeco.getStyle(); - hCornerStyle.setWidth(Util.getNativeScrollbarSize(), Unit.PX); + hCornerStyle.setWidth(WidgetUtil.getNativeScrollbarSize(), Unit.PX); hCornerStyle.setDisplay(Display.NONE); root.appendChild(headerDeco); Style fCornerStyle = footerDeco.getStyle(); - fCornerStyle.setWidth(Util.getNativeScrollbarSize(), Unit.PX); + fCornerStyle.setWidth(WidgetUtil.getNativeScrollbarSize(), Unit.PX); fCornerStyle.setDisplay(Display.NONE); root.appendChild(footerDeco); Style hWrapperStyle = horizontalScrollbarDeco.getStyle(); hWrapperStyle.setDisplay(Display.NONE); - hWrapperStyle.setHeight(Util.getNativeScrollbarSize(), Unit.PX); + hWrapperStyle.setHeight(WidgetUtil.getNativeScrollbarSize(), Unit.PX); root.appendChild(horizontalScrollbarDeco); setStylePrimaryName("v-escalator"); @@ -4721,10 +4721,10 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker } 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(); body.recalculateSectionHeight(); @@ -4828,7 +4828,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker @SuppressWarnings("deprecation") com.google.gwt.user.client.Element castElement = (com.google.gwt.user.client.Element) possibleWidgetNode .cast(); - Widget w = Util.findWidget(castElement, null); + Widget w = WidgetUtil.findWidget(castElement, null); // Ensure findWidget did not traverse past the cell element in the // DOM hierarchy @@ -4891,7 +4891,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker * Gets the amount of rows in Escalator's body that are shown, while * {@link #getHeightMode()} is {@link HeightMode#ROW}. * <p> - * By default, it is {@value GridState#DEFAULT_HEIGHT_BY_ROWS}. + * By default, it is 10. * * @return the amount of rows that are being shown in Escalator's body * @see #setHeightByRows(double) @@ -5086,6 +5086,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker * @return escalator's inner width */ public double getInnerWidth() { - return Util.getRequiredWidthBoundingClientRectDouble(tableWrapper); + return WidgetUtil + .getRequiredWidthBoundingClientRectDouble(tableWrapper); } } diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index a32dccd391..d401b4da78 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -59,7 +59,7 @@ import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.ResizeComposite; import com.google.gwt.user.client.ui.Widget; 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.DataSource; import com.vaadin.client.renderers.ComplexRenderer; @@ -121,8 +121,8 @@ import com.vaadin.client.widget.grid.sort.SortEvent; import com.vaadin.client.widget.grid.sort.SortHandler; import com.vaadin.client.widget.grid.sort.SortOrder; import com.vaadin.client.widgets.Escalator.AbstractRowContainer; +import com.vaadin.client.widgets.Grid.Editor.State; import com.vaadin.shared.data.sort.SortDirection; -import com.vaadin.shared.ui.grid.GridColumnState; import com.vaadin.shared.ui.grid.GridConstants; import com.vaadin.shared.ui.grid.GridStaticCellType; import com.vaadin.shared.ui.grid.HeightMode; @@ -1186,8 +1186,10 @@ public class Grid<T> extends ResizeComposite implements int bodyTop = body.getElement().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 - wrapperTop, width, height); @@ -1276,8 +1278,10 @@ public class Grid<T> extends ResizeComposite implements */ protected Element createCell(TableCellElement td) { 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, height); return cell; @@ -2543,7 +2547,7 @@ public class Grid<T> extends ResizeComposite implements * Width of column in pixels as {@link #setWidth(double)} has been * called */ - private double widthUser = GridColumnState.DEFAULT_COLUMN_WIDTH_PX; + private double widthUser = GridConstants.DEFAULT_COLUMN_WIDTH_PX; /** * Renderer for rendering a value into the cell @@ -2552,11 +2556,11 @@ public class Grid<T> extends ResizeComposite implements private boolean sortable = false; - private String headerText = ""; + private String headerCaption = ""; - private double minimumWidthPx = GridColumnState.DEFAULT_MIN_WIDTH; - private double maximumWidthPx = GridColumnState.DEFAULT_MAX_WIDTH; - private int expandRatio = GridColumnState.DEFAULT_EXPAND_RATIO; + private double minimumWidthPx = GridConstants.DEFAULT_MIN_WIDTH; + private double maximumWidthPx = GridConstants.DEFAULT_MAX_WIDTH; + private int expandRatio = GridConstants.DEFAULT_EXPAND_RATIO; /** * Constructs a new column with a simple TextRenderer. @@ -2568,15 +2572,15 @@ public class Grid<T> extends ResizeComposite implements /** * Constructs a new column with a simple TextRenderer. * - * @param headerText - * The header text for this column + * @param caption + * The header caption for this column * * @throws IllegalArgumentException - * if given header text is null + * if given header caption is null */ - public Column(String headerText) throws IllegalArgumentException { + public Column(String caption) throws IllegalArgumentException { this(); - setHeaderText(headerText); + setHeaderCaption(caption); } /** @@ -2598,16 +2602,16 @@ public class Grid<T> extends ResizeComposite implements * * @param renderer * The renderer to use for rendering the cells - * @param headerText - * The header text for this column + * @param caption + * The header caption for this column * * @throws IllegalArgumentException - * if given Renderer or header text is null + * if given Renderer or header caption is null */ - public Column(String headerText, Renderer<? super C> renderer) + public Column(String caption, Renderer<? super C> renderer) throws IllegalArgumentException { this(renderer); - setHeaderText(headerText); + setHeaderCaption(caption); } /** @@ -2634,23 +2638,22 @@ public class Grid<T> extends ResizeComposite implements } /** - * Sets a header text for this column. + * Sets a header caption for this column. * - * @param headerText - * The header text for this column + * @param caption + * The header caption for this column * @return the column itself * * @throws IllegalArgumentException - * if given header text is null + * if given caption text is null */ - public Column<C, T> setHeaderText(String headerText) { - if (headerText == null) { - throw new IllegalArgumentException( - "Header text cannot be null."); + public Column<C, T> setHeaderCaption(String caption) { + if (caption == null) { + throw new IllegalArgumentException("Caption cannot be null."); } - if (!this.headerText.equals(headerText)) { - this.headerText = headerText; + if (!this.headerCaption.equals(caption)) { + this.headerCaption = caption; if (grid != null) { updateHeader(); } @@ -2662,7 +2665,7 @@ public class Grid<T> extends ResizeComposite implements private void updateHeader() { HeaderRow row = grid.getHeader().getDefaultRow(); if (row != null) { - row.getCell(this).setText(headerText); + row.getCell(this).setText(headerCaption); } } @@ -2810,8 +2813,8 @@ public class Grid<T> extends ResizeComposite implements public String toString() { String details = ""; - if (headerText != null && !headerText.isEmpty()) { - details += "header:\"" + headerText + "\" "; + if (headerCaption != null && !headerCaption.isEmpty()) { + details += "header:\"" + headerCaption + "\" "; } else { details += "header:empty "; } @@ -3170,7 +3173,7 @@ public class Grid<T> extends ResizeComposite implements Renderer renderer = findRenderer(cell); if (renderer instanceof WidgetRenderer) { try { - Widget w = Util.findWidget(cell.getElement() + Widget w = WidgetUtil.findWidget(cell.getElement() .getFirstChildElement(), Widget.class); if (w != null) { @@ -3400,7 +3403,7 @@ public class Grid<T> extends ResizeComposite implements editor.setGrid(this); - setSelectionMode(SelectionMode.MULTI); + setSelectionMode(SelectionMode.SINGLE); escalator.addScrollHandler(new ScrollHandler() { @Override @@ -3819,7 +3822,7 @@ public class Grid<T> extends ResizeComposite implements /** * Returns the current default row of the header section. The default row is * a special header row providing a user interface for sorting columns. - * Setting a header text for column updates cells in the default header. + * Setting a header caption for column updates cells in the default header. * * @return the default row or null if no default row set */ @@ -4517,7 +4520,7 @@ public class Grid<T> extends ResizeComposite implements } private boolean isElementInChildWidget(Element e) { - Widget w = Util.findWidget(e, null); + Widget w = WidgetUtil.findWidget(e, null); if (w == this) { return false; @@ -4768,6 +4771,20 @@ public class Grid<T> extends ResizeComposite implements container = escalator.getBody(); } else if (type.equalsIgnoreCase("footer")) { container = escalator.getFooter(); + } else if (type.equalsIgnoreCase("editor")) { + if (editor.getState() != State.ACTIVE) { + // Editor is not there. + return null; + } + + if (indices.length == 0) { + return DOM.asOld(editor.editorOverlay); + } else if (indices.length == 1 && indices[0] < columns.size()) { + escalator.scrollToColumn(indices[0], ScrollDestination.ANY, 0); + return editor.getWidget(columns.get(indices[0])).getElement(); + } else { + return null; + } } if (null != container) { @@ -4853,6 +4870,22 @@ public class Grid<T> extends ResizeComposite implements + (containerRow ? "]" : "][" + cell.getColumn() + "]"); } } + + // Check if subelement is part of editor. + if (editor.getState() == State.ACTIVE) { + if (editor.editorOverlay.isOrHasChild(subElement)) { + int i = 0; + for (Column<?, T> column : columns) { + if (editor.getWidget(column).getElement() + .isOrHasChild(subElement)) { + return "editor[" + i + "]"; + } + ++i; + } + return "editor"; + } + } + return null; } diff --git a/client/tests/src/com/vaadin/client/ApplicationConnectionTestURLGeneration.java b/client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java index cb4f1f4068..36baa163cb 100644 --- a/client/tests/src/com/vaadin/client/ApplicationConnectionTestURLGeneration.java +++ b/client/tests/src/com/vaadin/client/ApplicationConnectionURLGenerationTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; -public class ApplicationConnectionTestURLGeneration { +public class ApplicationConnectionURLGenerationTest { private static final String[] URIS = new String[] { "http://demo.vaadin.com/", // diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java index cb70fc7a39..62b727e5f5 100644 --- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java +++ b/client/tests/src/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java @@ -6,7 +6,7 @@ import org.junit.Assert; import com.vaadin.shared.VBrowserDetails; -public class TestVBrowserDetailsUserAgentParser extends TestCase { +public class VBrowserDetailsUserAgentParserTest extends TestCase { private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"; private static final String FIREFOX30_LINUX = "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12"; diff --git a/common.xml b/common.xml index edd941c5e3..4f7d0e4f62 100644 --- a/common.xml +++ b/common.xml @@ -9,7 +9,7 @@ <property name="gwt.basedir" location="${vaadin.basedir}/../gwt" /> <property file="${vaadin.basedir}/build.properties" /> - <property name="modules.to.publish.to.maven" value="shared,server,client,client-compiler,client-compiled,themes,push" /> + <property name="modules.to.publish.to.maven" value="shared,server,client,client-compiler,client-compiled,themes,push,widgets" /> <property name="modules.to.publish.to.download" value="${modules.to.publish.to.maven},all" /> <ivy:settings file="${vaadin.basedir}/ivysettings.xml" /> @@ -353,14 +353,8 @@ <batchtest fork="yes" todir="${report.dir}"> <fileset dir="${test.src}"> - <exclude name="**/Abstract*" /> - <exclude name="**/Mock*" /> - <exclude name="com/vaadin/tests/data/bean/*" /> - <exclude name="com/vaadin/tests/util/*" /> - <exclude name="com/vaadin/benchmarks/*" /> - <exclude name="**/VaadinClasses.java" /> - <exclude name="**/*TestRunner.java" /> - <exclude name="**/SQLTestsConstants.java" /> + <include name="**/*Test.java" /> + <include name="**/*Tests.java" /> </fileset> </batchtest> </junit> diff --git a/gwt-files.xml b/gwt-files.xml index 26126a7ffb..fd31482bdc 100644 --- a/gwt-files.xml +++ b/gwt-files.xml @@ -185,10 +185,5 @@ <!-- Server files from gwt-user --> <include name="com/google/gwt/*/server/**" /> </fileset> - <!-- GWT Elemental --> - <fileset dir="${gwt.elemental.jar.files}"> - <exclude name="META-INF/**" /> - <exclude name="super/**" /> - </fileset> </union> </project> diff --git a/server/ivy.xml b/server/ivy.xml index 2901be8090..b30e6a72ef 100644 --- a/server/ivy.xml +++ b/server/ivy.xml @@ -70,6 +70,8 @@ conf="test,ide -> default" /> <dependency org="org.mockito" name="mockito-all" rev="1.9.5" conf="test,ide->default" /> + <dependency org="org.hamcrest" name="hamcrest-all" rev="1.3" + conf="test,ide->default" /> <dependency org="org.easymock" name="easymock" rev="3.0" conf="test,ide-> default" transitive="true" /> <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" diff --git a/server/src/com/vaadin/data/RpcDataProviderExtension.java b/server/src/com/vaadin/data/RpcDataProviderExtension.java index 2b3e00e6f0..10857f8d6a 100644 --- a/server/src/com/vaadin/data/RpcDataProviderExtension.java +++ b/server/src/com/vaadin/data/RpcDataProviderExtension.java @@ -441,8 +441,8 @@ public class RpcDataProviderExtension extends AbstractExtension { * @param removedPropertyIds * the property ids that have been removed from the container */ - public void propertiesRemoved(@SuppressWarnings("unused") - Collection<Object> removedPropertyIds) { + public void propertiesRemoved( + @SuppressWarnings("unused") Collection<Object> removedPropertyIds) { /* * no-op, for now. * @@ -762,7 +762,7 @@ public class RpcDataProviderExtension extends AbstractExtension { Grid grid = getGrid(); for (Column column : columns) { - Object propertyId = column.getColumnProperty(); + Object propertyId = column.getPropertyId(); Object propertyValue = item.getItemProperty(propertyId).getValue(); JsonValue encodedValue = encodeValue(propertyValue, @@ -794,7 +794,7 @@ public class RpcDataProviderExtension extends AbstractExtension { JsonObject rowObject, Collection<Column> columns) { JsonObject cellStyles = null; for (Column column : columns) { - Object propertyId = column.getColumnProperty(); + Object propertyId = column.getPropertyId(); cellReference.set(propertyId); String style = generator.getStyle(cellReference); if (style != null) { diff --git a/server/src/com/vaadin/event/SelectionEvent.java b/server/src/com/vaadin/event/SelectionEvent.java index b6ade2aa9c..e75369e6da 100644 --- a/server/src/com/vaadin/event/SelectionEvent.java +++ b/server/src/com/vaadin/event/SelectionEvent.java @@ -17,6 +17,7 @@ package com.vaadin.event; import java.io.Serializable; import java.util.Collection; +import java.util.Collections; import java.util.EventObject; import java.util.LinkedHashSet; import java.util.Set; @@ -67,6 +68,15 @@ public class SelectionEvent extends EventObject { } /** + * A {@link Collection} of all the itemIds that are currently selected. + * + * @return a Collection of the itemIds that are currently selected + */ + public Set<Object> getSelected() { + return Collections.unmodifiableSet(newSelection); + } + + /** * The listener interface for receiving {@link SelectionEvent * SelectionEvents}. */ diff --git a/server/src/com/vaadin/event/SortEvent.java b/server/src/com/vaadin/event/SortEvent.java index b331f37efa..f303e47781 100644 --- a/server/src/com/vaadin/event/SortEvent.java +++ b/server/src/com/vaadin/event/SortEvent.java @@ -105,6 +105,6 @@ public class SortEvent extends Component.Event { * @param listener * the sort order change listener to remove */ - public void removeSortistener(SortListener listener); + public void removeSortListener(SortListener listener); } } diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index bfe195ccf9..c45e2b70e0 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -414,6 +414,9 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { String vaadinLocation = vaadinService.getStaticFileLocation(request) + "/VAADIN/"; + // Parameter appended to JS to bypass caches after version upgrade. + String versionQueryParam = "?v=" + Version.getFullVersion(); + if (context.getPushMode().isEnabled()) { // Load client-side dependencies for push support String pushJS = vaadinLocation; @@ -424,12 +427,14 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { pushJS += ApplicationConstants.VAADIN_PUSH_DEBUG_JS; } + pushJS += versionQueryParam; + fragmentNodes.add(new Element(Tag.valueOf("script"), "").attr( "type", "text/javascript").attr("src", pushJS)); } String bootstrapLocation = vaadinLocation - + ApplicationConstants.VAADIN_BOOTSTRAP_JS; + + ApplicationConstants.VAADIN_BOOTSTRAP_JS + versionQueryParam; fragmentNodes.add(new Element(Tag.valueOf("script"), "").attr("type", "text/javascript").attr("src", bootstrapLocation)); Element mainScriptTag = new Element(Tag.valueOf("script"), "").attr( @@ -513,7 +518,6 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { } appConfig.put("versionInfo", versionInfo); - appConfig.put("widgetset", context.getWidgetsetName()); // Use locale from session if set, else from the request @@ -525,42 +529,32 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { if (systemMessages != null) { // Write the CommunicationError -message to client JsonObject comErrMsg = Json.createObject(); - comErrMsg.put("caption", + putValueOrNull(comErrMsg, "caption", systemMessages.getCommunicationErrorCaption()); - comErrMsg.put("message", + putValueOrNull(comErrMsg, "message", systemMessages.getCommunicationErrorMessage()); - if (systemMessages.getCommunicationErrorURL() == null) { - comErrMsg.put("url", Json.createNull()); - } else { - comErrMsg.put("url", systemMessages.getCommunicationErrorURL()); - } + putValueOrNull(comErrMsg, "url", + systemMessages.getCommunicationErrorURL()); appConfig.put("comErrMsg", comErrMsg); JsonObject authErrMsg = Json.createObject(); - authErrMsg.put("caption", + putValueOrNull(authErrMsg, "caption", systemMessages.getAuthenticationErrorCaption()); - authErrMsg.put("message", + putValueOrNull(authErrMsg, "message", systemMessages.getAuthenticationErrorMessage()); - if (systemMessages.getAuthenticationErrorURL() == null) { - authErrMsg.put("url", Json.createNull()); - } else { - authErrMsg.put("url", - systemMessages.getAuthenticationErrorURL()); - } + putValueOrNull(authErrMsg, "url", + systemMessages.getAuthenticationErrorURL()); appConfig.put("authErrMsg", authErrMsg); JsonObject sessExpMsg = Json.createObject(); - sessExpMsg - .put("caption", systemMessages.getSessionExpiredCaption()); - sessExpMsg - .put("message", systemMessages.getSessionExpiredMessage()); - if (systemMessages.getSessionExpiredURL() == null) { - sessExpMsg.put("url", Json.createNull()); - } else { - sessExpMsg.put("url", systemMessages.getSessionExpiredURL()); - } + putValueOrNull(sessExpMsg, "caption", + systemMessages.getSessionExpiredCaption()); + putValueOrNull(sessExpMsg, "message", + systemMessages.getSessionExpiredMessage()); + putValueOrNull(sessExpMsg, "url", + systemMessages.getSessionExpiredURL()); appConfig.put("sessExpMsg", sessExpMsg); } @@ -624,7 +618,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { } /** - * Don not override. + * Do not override. * * @param context * @return @@ -648,4 +642,14 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getLocalizedMessage()); } + + private void putValueOrNull(JsonObject object, String key, String value) { + assert object != null; + assert key != null; + if (value == null) { + object.put(key, Json.createNull()); + } else { + object.put(key, value); + } + } } diff --git a/server/src/com/vaadin/server/JsonCodec.java b/server/src/com/vaadin/server/JsonCodec.java index 1f7b4ead43..ec1ea10f2b 100644 --- a/server/src/com/vaadin/server/JsonCodec.java +++ b/server/src/com/vaadin/server/JsonCodec.java @@ -300,7 +300,9 @@ public class JsonCodec implements Serializable { } // Try to decode object using fields - if (value.getType() == JsonType.NULL) { + if (isJsonType(targetType)) { + return value; + } else if (value.getType() == JsonType.NULL) { return null; } else if (targetType == byte.class || targetType == Byte.class) { return Byte.valueOf((byte) value.asNumber()); @@ -334,6 +336,11 @@ public class JsonCodec implements Serializable { } } + private static boolean isJsonType(Type type) { + return type instanceof Class<?> + && JsonValue.class.isAssignableFrom((Class<?>) type); + } + private static Object decodeArray(Type componentType, JsonArray value, ConnectorTracker connectorTracker) { Class<?> componentClass = getClassForType(componentType); diff --git a/server/src/com/vaadin/server/LegacyCommunicationManager.java b/server/src/com/vaadin/server/LegacyCommunicationManager.java index 485084b515..fda5ad444f 100644 --- a/server/src/com/vaadin/server/LegacyCommunicationManager.java +++ b/server/src/com/vaadin/server/LegacyCommunicationManager.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,6 +82,8 @@ public class LegacyCommunicationManager implements Serializable { return session; } + private static final ConcurrentHashMap<Class<? extends SharedState>, JsonValue> referenceDiffStates = new ConcurrentHashMap<Class<? extends SharedState>, JsonValue>(); + /** * @deprecated As of 7.1. See #11411. */ @@ -96,17 +99,10 @@ public class LegacyCommunicationManager implements Serializable { if (diffState == null && supportsDiffState) { // Use an empty state object as reference for full // repaints - - try { - SharedState referenceState = stateType.newInstance(); - EncodeResult encodeResult = JsonCodec.encode(referenceState, - null, stateType, uI.getConnectorTracker()); - diffState = encodeResult.getEncodedValue(); - } catch (Exception e) { - getLogger() - .log(Level.WARNING, - "Error creating reference object for state of type {0}", - stateType.getName()); + diffState = referenceDiffStates.get(stateType); + if (diffState == null) { + diffState = createReferenceDiffStateState(stateType); + referenceDiffStates.put(stateType, diffState); } } EncodeResult encodeResult = JsonCodec.encode(state, diffState, @@ -118,6 +114,21 @@ public class LegacyCommunicationManager implements Serializable { return (JsonObject) encodeResult.getDiff(); } + private static JsonValue createReferenceDiffStateState( + Class<? extends SharedState> stateType) { + try { + SharedState referenceState = stateType.newInstance(); + EncodeResult encodeResult = JsonCodec.encode(referenceState, null, + stateType, null); + return encodeResult.getEncodedValue(); + } catch (Exception e) { + getLogger().log(Level.WARNING, + "Error creating reference object for state of type {0}", + stateType.getName()); + return null; + } + } + /** * Resolves a dependency URI, registering the URI with this * {@code LegacyCommunicationManager} if needed and returns a fully diff --git a/server/src/com/vaadin/server/VaadinPortletResponse.java b/server/src/com/vaadin/server/VaadinPortletResponse.java index d9f133ac8a..2b6e0c75fb 100644 --- a/server/src/com/vaadin/server/VaadinPortletResponse.java +++ b/server/src/com/vaadin/server/VaadinPortletResponse.java @@ -97,6 +97,14 @@ public class VaadinPortletResponse implements VaadinResponse { } @Override + public void setContentLength(int len) { + if (response instanceof ResourceResponse) { + ((ResourceResponse) response).setContentLength(len); + } + + } + + @Override public PrintWriter getWriter() throws IOException { if (response instanceof MimeResponse) { return ((MimeResponse) response).getWriter(); diff --git a/server/src/com/vaadin/server/VaadinResponse.java b/server/src/com/vaadin/server/VaadinResponse.java index 1d5fcf141f..c31c6c05d8 100644 --- a/server/src/com/vaadin/server/VaadinResponse.java +++ b/server/src/com/vaadin/server/VaadinResponse.java @@ -169,4 +169,17 @@ public interface VaadinResponse extends Serializable { * @see PortletResponse#addProperty(Cookie) */ public void addCookie(Cookie cookie); + + /** + * Sets the length of the content body in the response In HTTP servlets, + * this method sets the HTTP Content-Length header. For some portlet + * responses, this method sets the content-length header, for others this + * method does nothing. + * + * @param len + * an integer specifying the length of the content being returned + * to the client + * @since 7.3.8 + */ + public void setContentLength(int len); } diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index d1242676da..aa76dc8e08 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -28,6 +28,7 @@ import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; @@ -45,14 +46,21 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.google.gwt.thirdparty.guava.common.base.Charsets; +import com.google.gwt.thirdparty.guava.common.io.Files; import com.vaadin.annotations.VaadinServletConfiguration; import com.vaadin.annotations.VaadinServletConfiguration.InitParameterName; import com.vaadin.sass.internal.ScssStylesheet; import com.vaadin.server.communication.ServletUIInitHandler; import com.vaadin.shared.JsonConstants; +import com.vaadin.shared.Version; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; +import elemental.json.Json; +import elemental.json.JsonArray; +import elemental.json.JsonObject; + @SuppressWarnings("serial") public class VaadinServlet extends HttpServlet implements Constants { @@ -61,14 +69,47 @@ public class VaadinServlet extends HttpServlet implements Constants { private final String css; private final List<String> sourceUris; private final long timestamp; + private final String scssFileName; - public ScssCacheEntry(String css, List<String> sourceUris) { + public ScssCacheEntry(String scssFileName, String css, + List<String> sourceUris) { + this.scssFileName = scssFileName; this.css = css; this.sourceUris = sourceUris; timestamp = getLastModified(); } + public ScssCacheEntry(JsonObject json) { + css = json.getString("css"); + timestamp = Long.parseLong(json.getString("timestamp")); + + sourceUris = new ArrayList<String>(); + + JsonArray uris = json.getArray("uris"); + for (int i = 0; i < uris.length(); i++) { + sourceUris.add(uris.getString(i)); + } + + // Not set for cache entries read from disk + scssFileName = null; + } + + public String asJson() { + JsonArray uris = Json.createArray(); + for (String uri : sourceUris) { + uris.set(uris.length(), uri); + } + + JsonObject object = Json.createObject(); + object.put("version", Version.getFullVersion()); + object.put("timestamp", Long.toString(timestamp)); + object.put("uris", uris); + object.put("css", css); + + return object.toJson(); + } + public String getCss() { return css; } @@ -117,6 +158,10 @@ public class VaadinServlet extends HttpServlet implements Constants { } } + public String getScssFileName() { + return scssFileName; + } + } private VaadinServletService servletService; @@ -612,7 +657,14 @@ public class VaadinServlet extends HttpServlet implements Constants { * Global cache of scss compilation results. This map is protected from * concurrent access by {@link #SCSS_MUTEX}. */ - private static final Map<String, ScssCacheEntry> scssCache = new HashMap<String, ScssCacheEntry>(); + private final Map<String, ScssCacheEntry> scssCache = new HashMap<String, ScssCacheEntry>(); + + /** + * Keeps track of whether a warning about not being able to persist cache + * files has already been printed. The flag is protected from concurrent + * access by {@link #SCSS_MUTEX}. + */ + private static boolean scssCompileWarWarningEmitted = false; /** * Returns the default theme. Must never return null. @@ -900,10 +952,20 @@ public class VaadinServlet extends HttpServlet implements Constants { synchronized (SCSS_MUTEX) { ScssCacheEntry cacheEntry = scssCache.get(scssFilename); + if (cacheEntry == null) { + try { + cacheEntry = loadPersistedScssCache(scssFilename, sc); + } catch (Exception e) { + getLogger().log(Level.WARNING, + "Could not read persisted scss cache", e); + } + } + if (cacheEntry == null || !cacheEntry.isStillValid()) { cacheEntry = compileScssOnTheFly(filename, scssFilename, sc); - scssCache.put(scssFilename, cacheEntry); + persistCacheEntry(cacheEntry); } + scssCache.put(scssFilename, cacheEntry); if (cacheEntry == null) { // compilation did not produce any result, but logged a message @@ -920,6 +982,29 @@ public class VaadinServlet extends HttpServlet implements Constants { } } + private ScssCacheEntry loadPersistedScssCache(String scssFilename, + ServletContext sc) throws IOException { + String realFilename = sc.getRealPath(scssFilename); + + File scssCacheFile = getScssCacheFile(new File(realFilename)); + if (!scssCacheFile.exists()) { + return null; + } + + String jsonString = Files.toString(scssCacheFile, Charsets.UTF_8); + + JsonObject entryJson = Json.parse(jsonString); + + String cacheVersion = entryJson.getString("version"); + if (!Version.getFullVersion().equals(cacheVersion)) { + // Compiled for some other Vaadin version, discard cache + scssCacheFile.delete(); + return null; + } + + return new ScssCacheEntry(entryJson); + } + private ScssCacheEntry compileScssOnTheFly(String filename, String scssFilename, ServletContext sc) throws IOException { String realFilename = sc.getRealPath(scssFilename); @@ -951,7 +1036,8 @@ public class VaadinServlet extends HttpServlet implements Constants { return null; } - return new ScssCacheEntry(scss.printState(), scss.getSourceUris()); + return new ScssCacheEntry(realFilename, scss.printState(), + scss.getSourceUris()); } /** @@ -1196,6 +1282,36 @@ public class VaadinServlet extends HttpServlet implements Constants { getService().destroy(); } + private static void persistCacheEntry(ScssCacheEntry cacheEntry) { + String scssFileName = cacheEntry.getScssFileName(); + if (scssFileName == null) { + if (!scssCompileWarWarningEmitted) { + getLogger() + .warning( + "Could not persist scss cache because no real file was found for the compiled scss file. " + + "This might happen e.g. if serving the scss file directly from a .war file."); + scssCompileWarWarningEmitted = true; + } + return; + } + + File scssFile = new File(scssFileName); + File cacheFile = getScssCacheFile(scssFile); + + String cacheEntryJsonString = cacheEntry.asJson(); + + try { + Files.write(cacheEntryJsonString, cacheFile, Charsets.UTF_8); + } catch (IOException e) { + getLogger().log(Level.WARNING, + "Error persisting scss cache " + cacheFile, e); + } + } + + private static File getScssCacheFile(File scssFile) { + return new File(scssFile.getParentFile(), scssFile.getName() + ".cache"); + } + /** * Escapes characters to html entities. An exception is made for some * "safe characters" to keep the text somewhat readable. diff --git a/server/src/com/vaadin/server/communication/UIInitHandler.java b/server/src/com/vaadin/server/communication/UIInitHandler.java index 018274330f..3a6dc1e55f 100644 --- a/server/src/com/vaadin/server/communication/UIInitHandler.java +++ b/server/src/com/vaadin/server/communication/UIInitHandler.java @@ -112,7 +112,7 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler { response.setHeader("Cache-Control", "no-cache"); byte[] b = json.getBytes("UTF-8"); - response.setHeader("Content-Length", String.valueOf(b.length)); + response.setContentLength(b.length); OutputStream outputStream = response.getOutputStream(); outputStream.write(b); diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index 12aa8ea9a6..6353a4b25d 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -746,7 +746,7 @@ public class AbsoluteLayout extends AbstractLayout implements /** * Private method for writing position attributes * - * @since + * @since 7.4 * @param node * target node * @param key diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index d61458297a..316f7682de 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -1781,7 +1781,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, /** * Backing property for column */ - private final Object columnProperty; + private final Object propertyId; private Converter<?, Object> converter; @@ -1799,13 +1799,13 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * The grid this column belongs to. Should not be null. * @param state * the shared state of this column - * @param columnProperty + * @param propertyId * the backing property id for this column */ - Column(Grid grid, GridColumnState state, Object columnProperty) { + Column(Grid grid, GridColumnState state, Object propertyId) { this.grid = grid; this.state = state; - this.columnProperty = columnProperty; + this.propertyId = propertyId; internalSetRenderer(new TextRenderer()); } @@ -1824,8 +1824,8 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * * @return property id */ - public Object getColumnProperty() { - return columnProperty; + public Object getPropertyId() { + return propertyId; } /** @@ -2578,7 +2578,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * Grid initial setup */ private void initGrid() { - setSelectionMode(SelectionMode.MULTI); + setSelectionMode(SelectionMode.SINGLE); addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { @@ -2619,7 +2619,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, registerRpc(new GridServerRpc() { @Override - public void selectionChange(List<String> selection) { + public void select(List<String> selection) { Collection<Object> receivedSelection = getKeyMapper() .getItemIds(selection); @@ -2719,10 +2719,10 @@ public class Grid extends AbstractComponent implements SelectionNotifier, try { Object id = getContainerDataSource().getIdByIndex(rowIndex); doEditItem(id); - getEditorRpc().confirmBind(); } catch (Exception e) { handleError(e); } + getEditorRpc().confirmBind(); } @Override @@ -2739,10 +2739,10 @@ public class Grid extends AbstractComponent implements SelectionNotifier, public void save(int rowIndex) { try { saveEditor(); - getEditorRpc().confirmSave(); } catch (Exception e) { handleError(e); } + getEditorRpc().confirmSave(); } private void handleError(Exception e) { @@ -3763,7 +3763,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * the sort order change listener to remove */ @Override - public void removeSortistener(SortListener listener) { + public void removeSortListener(SortListener listener) { removeListener(SortEvent.class, listener, SORT_ORDER_CHANGE_METHOD); } @@ -4387,7 +4387,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, editedItemId = itemId; for (Column column : getColumns()) { - Object propertyId = column.getColumnProperty(); + Object propertyId = column.getPropertyId(); Field<?> editor = getEditorField(propertyId); diff --git a/server/src/com/vaadin/ui/renderer/ButtonRenderer.java b/server/src/com/vaadin/ui/renderer/ButtonRenderer.java index 4a7a86daa2..b0819794c0 100644 --- a/server/src/com/vaadin/ui/renderer/ButtonRenderer.java +++ b/server/src/com/vaadin/ui/renderer/ButtonRenderer.java @@ -20,7 +20,7 @@ package com.vaadin.ui.renderer; * corresponding property is used as the caption. Click listeners can be added * to the renderer, invoked when any of the rendered buttons is clicked. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ButtonRenderer extends ClickableRenderer<String> { diff --git a/server/src/com/vaadin/ui/renderer/ClickableRenderer.java b/server/src/com/vaadin/ui/renderer/ClickableRenderer.java index ef293c7e3c..d640ce8b71 100644 --- a/server/src/com/vaadin/ui/renderer/ClickableRenderer.java +++ b/server/src/com/vaadin/ui/renderer/ClickableRenderer.java @@ -34,7 +34,7 @@ import com.vaadin.util.ReflectTools; * @param <T> * the type presented by the renderer * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ClickableRenderer<T> extends AbstractRenderer<T> { @@ -91,6 +91,15 @@ public class ClickableRenderer<T> extends AbstractRenderer<T> { public Column getColumn() { return column; } + + /** + * Returns the property ID where the click event originated. + * + * @return the property ID of the clicked cell + */ + public Object getPropertyId() { + return column.getPropertyId(); + } } protected ClickableRenderer(Class<T> presentationType) { diff --git a/server/src/com/vaadin/ui/renderer/DateRenderer.java b/server/src/com/vaadin/ui/renderer/DateRenderer.java index 4d1d702993..d3d2df573d 100644 --- a/server/src/com/vaadin/ui/renderer/DateRenderer.java +++ b/server/src/com/vaadin/ui/renderer/DateRenderer.java @@ -26,7 +26,7 @@ import elemental.json.JsonValue; /** * A renderer for presenting date values. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class DateRenderer extends AbstractRenderer<Date> { diff --git a/server/src/com/vaadin/ui/renderer/HtmlRenderer.java b/server/src/com/vaadin/ui/renderer/HtmlRenderer.java index bdab51991c..02d153dedf 100644 --- a/server/src/com/vaadin/ui/renderer/HtmlRenderer.java +++ b/server/src/com/vaadin/ui/renderer/HtmlRenderer.java @@ -20,7 +20,7 @@ import com.vaadin.ui.Grid.AbstractRenderer; /** * A renderer for presenting HTML content. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class HtmlRenderer extends AbstractRenderer<String> { diff --git a/server/src/com/vaadin/ui/renderer/ImageRenderer.java b/server/src/com/vaadin/ui/renderer/ImageRenderer.java index 87a044c4a6..3ef3eed3e5 100644 --- a/server/src/com/vaadin/ui/renderer/ImageRenderer.java +++ b/server/src/com/vaadin/ui/renderer/ImageRenderer.java @@ -30,7 +30,7 @@ import elemental.json.JsonValue; * the data source. Only {@link ExternalResource}s and {@link ThemeResource}s * are currently supported. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ImageRenderer extends ClickableRenderer<Resource> { diff --git a/server/src/com/vaadin/ui/renderer/NumberRenderer.java b/server/src/com/vaadin/ui/renderer/NumberRenderer.java index 9af5c4cffb..3406e1837a 100644 --- a/server/src/com/vaadin/ui/renderer/NumberRenderer.java +++ b/server/src/com/vaadin/ui/renderer/NumberRenderer.java @@ -25,7 +25,7 @@ import elemental.json.JsonValue; /** * A renderer for presenting number values. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class NumberRenderer extends AbstractRenderer<Number> { diff --git a/server/src/com/vaadin/ui/renderer/ProgressBarRenderer.java b/server/src/com/vaadin/ui/renderer/ProgressBarRenderer.java index cb688b178b..9bdc0b299a 100644 --- a/server/src/com/vaadin/ui/renderer/ProgressBarRenderer.java +++ b/server/src/com/vaadin/ui/renderer/ProgressBarRenderer.java @@ -22,7 +22,7 @@ import elemental.json.JsonValue; /** * A renderer that represents a double values as a graphical progress bar. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ProgressBarRenderer extends AbstractRenderer<Double> { diff --git a/server/src/com/vaadin/ui/renderer/Renderer.java b/server/src/com/vaadin/ui/renderer/Renderer.java index 0c704495a4..cab1cdfe3c 100644 --- a/server/src/com/vaadin/ui/renderer/Renderer.java +++ b/server/src/com/vaadin/ui/renderer/Renderer.java @@ -30,7 +30,7 @@ import elemental.json.JsonValue; * @param <T> * the type this renderer knows how to present * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface Renderer<T> extends Extension { diff --git a/server/src/com/vaadin/ui/renderer/TextRenderer.java b/server/src/com/vaadin/ui/renderer/TextRenderer.java index 42bd02fa2a..154a09ccd8 100644 --- a/server/src/com/vaadin/ui/renderer/TextRenderer.java +++ b/server/src/com/vaadin/ui/renderer/TextRenderer.java @@ -20,7 +20,7 @@ import com.vaadin.ui.Grid.AbstractRenderer; /** * A renderer for presenting simple plain-text string values. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class TextRenderer extends AbstractRenderer<String> { diff --git a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDateTest.java index fd5d47b32f..ce76f8427b 100644 --- a/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDate.java +++ b/server/tests/src/com/vaadin/data/fieldgroup/FieldGroupDateTest.java @@ -25,7 +25,7 @@ import com.vaadin.data.util.BeanItem; import com.vaadin.ui.Field; import com.vaadin.ui.PopupDateField; -public class FieldGroupDate { +public class FieldGroupDateTest { private FieldGroup fieldGroup; diff --git a/server/tests/src/com/vaadin/data/util/AbstractBeanContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractBeanContainerTestBase.java index 1e663afdd2..3d8f08a7ef 100644 --- a/server/tests/src/com/vaadin/data/util/AbstractBeanContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/AbstractBeanContainerTestBase.java @@ -6,8 +6,8 @@ package com.vaadin.data.util; * Only a limited subset of the functionality is tested here, the rest in tests * of subclasses including {@link BeanItemContainer} and {@link BeanContainer}. */ -public abstract class AbstractBeanContainerTest extends - AbstractInMemoryContainerTest { +public abstract class AbstractBeanContainerTestBase extends + AbstractInMemoryContainerTestBase { public static class Person { private String name; @@ -34,7 +34,7 @@ public abstract class AbstractBeanContainerTest extends public ClassName(String fullyQualifiedName, Integer idNumber) { this.fullyQualifiedName = fullyQualifiedName; - simpleName = AbstractContainerTest + simpleName = AbstractContainerTestBase .getSimpleName(fullyQualifiedName); reverseFullyQualifiedName = reverse(fullyQualifiedName); this.idNumber = idNumber; diff --git a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractContainerTestBase.java index a443499a89..54cbc5305d 100644 --- a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/AbstractContainerTestBase.java @@ -15,7 +15,7 @@ import com.vaadin.data.Container.Sortable; import com.vaadin.data.Item; import com.vaadin.data.util.filter.SimpleStringFilter; -public abstract class AbstractContainerTest extends TestCase { +public abstract class AbstractContainerTestBase extends TestCase { /** * Helper class for testing e.g. listeners expecting events to be fired. diff --git a/server/tests/src/com/vaadin/data/util/AbstractHierarchicalContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java index 772cd250ce..3bd00cce3c 100644 --- a/server/tests/src/com/vaadin/data/util/AbstractHierarchicalContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/AbstractHierarchicalContainerTestBase.java @@ -7,8 +7,8 @@ import com.vaadin.data.Container.Hierarchical; import com.vaadin.data.Container.Sortable; import com.vaadin.data.Item; -public abstract class AbstractHierarchicalContainerTest extends - AbstractContainerTest { +public abstract class AbstractHierarchicalContainerTestBase extends + AbstractContainerTestBase { /** * @param container diff --git a/server/tests/src/com/vaadin/data/util/AbstractInMemoryContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractInMemoryContainerTest.java deleted file mode 100644 index bbad33c5bc..0000000000 --- a/server/tests/src/com/vaadin/data/util/AbstractInMemoryContainerTest.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.vaadin.data.util; - -public abstract class AbstractInMemoryContainerTest extends - AbstractContainerTest { - -} diff --git a/server/tests/src/com/vaadin/data/util/AbstractInMemoryContainerTestBase.java b/server/tests/src/com/vaadin/data/util/AbstractInMemoryContainerTestBase.java new file mode 100644 index 0000000000..d2c1a17bf8 --- /dev/null +++ b/server/tests/src/com/vaadin/data/util/AbstractInMemoryContainerTestBase.java @@ -0,0 +1,6 @@ +package com.vaadin.data.util; + +public abstract class AbstractInMemoryContainerTestBase extends + AbstractContainerTestBase { + +} diff --git a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java index f22ab8478e..3d755f4397 100644 --- a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java @@ -13,7 +13,7 @@ import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.util.AbstractBeanContainer.BeanIdResolver; -public class BeanContainerTest extends AbstractBeanContainerTest { +public class BeanContainerTest extends AbstractBeanContainerTestBase { protected static class PersonNameResolver implements BeanIdResolver<String, Person> { @@ -345,7 +345,7 @@ public class BeanContainerTest extends AbstractBeanContainerTest { Person.class); // resolver that returns null as item id container - .setBeanIdResolver(new BeanIdResolver<String, AbstractBeanContainerTest.Person>() { + .setBeanIdResolver(new BeanIdResolver<String, AbstractBeanContainerTestBase.Person>() { @Override public String getIdForBean(Person bean) { diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerGenerator.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerGenerator.java index 7400f0efcf..a5bdcc7cf9 100644 --- a/server/tests/src/com/vaadin/data/util/BeanItemContainerGenerator.java +++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerGenerator.java @@ -3,9 +3,6 @@ package com.vaadin.data.util; import java.util.Date; import java.util.concurrent.atomic.AtomicLong; -import org.junit.Ignore; - -@Ignore public class BeanItemContainerGenerator { public static class PortableRandom { diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java index 2cf64bbc7c..3c30b41d39 100644 --- a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java @@ -25,7 +25,7 @@ import com.vaadin.data.util.filter.Compare; * * Most sorting related tests are in {@link BeanItemContainerSortTest}. */ -public class BeanItemContainerTest extends AbstractBeanContainerTest { +public class BeanItemContainerTest extends AbstractBeanContainerTestBase { // basics from the common container test diff --git a/server/tests/src/com/vaadin/data/util/TestContainerHierarchicalWrapper.java b/server/tests/src/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java index ff6de50651..2fd21ef118 100644 --- a/server/tests/src/com/vaadin/data/util/TestContainerHierarchicalWrapper.java +++ b/server/tests/src/com/vaadin/data/util/ContainerHierarchicalWrapperTest.java @@ -2,8 +2,8 @@ package com.vaadin.data.util; import java.util.Collection; -public class TestContainerHierarchicalWrapper extends - AbstractHierarchicalContainerTest { +public class ContainerHierarchicalWrapperTest extends + AbstractHierarchicalContainerTestBase { public void testBasicOperations() { testBasicContainerOperations(new ContainerHierarchicalWrapper( diff --git a/server/tests/src/com/vaadin/data/util/TestContainerSorting.java b/server/tests/src/com/vaadin/data/util/ContainerSortingTest.java index 497699605a..dd713dd7b0 100644 --- a/server/tests/src/com/vaadin/data/util/TestContainerSorting.java +++ b/server/tests/src/com/vaadin/data/util/ContainerSortingTest.java @@ -10,7 +10,7 @@ import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.tests.util.TestUtil; -public class TestContainerSorting extends TestCase { +public class ContainerSortingTest extends TestCase { private static final String ITEM_DATA_MINUS2_NULL = "Data -2 null"; private static final String ITEM_DATA_MINUS2 = "Data -2"; diff --git a/server/tests/src/com/vaadin/data/util/TestHierarchicalContainer.java b/server/tests/src/com/vaadin/data/util/HierarchicalContainerTest.java index 2a336ffc1c..0b71b3dff9 100644 --- a/server/tests/src/com/vaadin/data/util/TestHierarchicalContainer.java +++ b/server/tests/src/com/vaadin/data/util/HierarchicalContainerTest.java @@ -3,8 +3,8 @@ package com.vaadin.data.util; import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; -public class TestHierarchicalContainer extends - AbstractHierarchicalContainerTest { +public class HierarchicalContainerTest extends + AbstractHierarchicalContainerTestBase { public void testBasicOperations() { testBasicContainerOperations(new HierarchicalContainer()); diff --git a/server/tests/src/com/vaadin/data/util/TestIndexedContainer.java b/server/tests/src/com/vaadin/data/util/IndexedContainerTest.java index 91e222af77..5828ac88cc 100644 --- a/server/tests/src/com/vaadin/data/util/TestIndexedContainer.java +++ b/server/tests/src/com/vaadin/data/util/IndexedContainerTest.java @@ -11,7 +11,7 @@ import com.vaadin.data.Container.Indexed.ItemRemoveEvent; import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Item; -public class TestIndexedContainer extends AbstractInMemoryContainerTest { +public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { public void testBasicOperations() { testBasicContainerOperations(new IndexedContainer()); diff --git a/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java b/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumptionTest.java index ce0711a29e..b4621b823a 100644 --- a/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumption.java +++ b/server/tests/src/com/vaadin/data/util/MethodPropertyMemoryConsumptionTest.java @@ -32,7 +32,7 @@ import org.junit.Test; * @since 7.2 * @author Vaadin Ltd */ -public class MethodPropertyMemoryConsumption { +public class MethodPropertyMemoryConsumptionTest { @Test public void testSetArguments() throws NoSuchFieldException, diff --git a/server/tests/src/com/vaadin/data/util/PerformanceTestIndexedContainer.java b/server/tests/src/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java index 1c49017bf1..042f260be8 100644 --- a/server/tests/src/com/vaadin/data/util/PerformanceTestIndexedContainer.java +++ b/server/tests/src/com/vaadin/data/util/PerformanceTestIndexedContainerTest.java @@ -10,7 +10,7 @@ import junit.framework.TestCase; import org.junit.Assert; -public class PerformanceTestIndexedContainer extends TestCase { +public class PerformanceTestIndexedContainerTest extends TestCase { private static final int REPEATS = 10; private final static int ITEMS = 50000; diff --git a/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperField.java b/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperFieldTest.java index dc828689a8..5f31150210 100644 --- a/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperField.java +++ b/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperFieldTest.java @@ -8,7 +8,7 @@ import com.vaadin.data.fieldgroup.FieldGroup; import com.vaadin.data.fieldgroup.PropertyId; import com.vaadin.ui.TextField; -public class ReflectToolsGetSuperField { +public class ReflectToolsGetSuperFieldTest { @Test public void getFieldFromSuperClass() { diff --git a/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTestBase.java index 96673ff608..ebd843fb53 100644 --- a/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTestBase.java @@ -8,7 +8,7 @@ import com.vaadin.data.Property; import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertysetItem; -public abstract class AbstractFilterTest<FILTERTYPE extends Filter> extends +public abstract class AbstractFilterTestBase<FILTERTYPE extends Filter> extends TestCase { protected static final String PROPERTY1 = "property1"; diff --git a/server/tests/src/com/vaadin/data/util/filter/AndOrFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/AndOrFilterTest.java index e5bc622e39..012d0ef0bc 100644 --- a/server/tests/src/com/vaadin/data/util/filter/AndOrFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/AndOrFilterTest.java @@ -6,7 +6,7 @@ import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; import com.vaadin.data.util.BeanItem; -public class AndOrFilterTest extends AbstractFilterTest<AbstractJunctionFilter> { +public class AndOrFilterTest extends AbstractFilterTestBase<AbstractJunctionFilter> { protected Item item1 = new BeanItem<Integer>(1); protected Item item2 = new BeanItem<Integer>(2); diff --git a/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java index 732a541c89..fc5ffb9b56 100644 --- a/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/CompareFilterTest.java @@ -15,7 +15,7 @@ import com.vaadin.data.util.filter.Compare.GreaterOrEqual; import com.vaadin.data.util.filter.Compare.Less; import com.vaadin.data.util.filter.Compare.LessOrEqual; -public class CompareFilterTest extends AbstractFilterTest<Compare> { +public class CompareFilterTest extends AbstractFilterTestBase<Compare> { protected Item itemNull; protected Item itemEmpty; diff --git a/server/tests/src/com/vaadin/data/util/filter/IsNullFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/IsNullFilterTest.java index d3e959e069..953bf3cd65 100644 --- a/server/tests/src/com/vaadin/data/util/filter/IsNullFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/IsNullFilterTest.java @@ -7,7 +7,7 @@ import com.vaadin.data.Item; import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertysetItem; -public class IsNullFilterTest extends AbstractFilterTest<IsNull> { +public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { public void testIsNull() { Item item1 = new PropertysetItem(); diff --git a/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java index 0fcbd26b8e..9ba5168ac9 100644 --- a/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/LikeFilterTest.java @@ -22,7 +22,7 @@ import com.vaadin.data.Item; import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertysetItem; -public class LikeFilterTest extends AbstractFilterTest<Like> { +public class LikeFilterTest extends AbstractFilterTestBase<Like> { protected Item item1 = new PropertysetItem(); protected Item item2 = new PropertysetItem(); diff --git a/server/tests/src/com/vaadin/data/util/filter/NotFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/NotFilterTest.java index 966ffd3a6e..310b749ce2 100644 --- a/server/tests/src/com/vaadin/data/util/filter/NotFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/NotFilterTest.java @@ -6,7 +6,7 @@ import com.vaadin.data.Container.Filter; import com.vaadin.data.Item; import com.vaadin.data.util.BeanItem; -public class NotFilterTest extends AbstractFilterTest<Not> { +public class NotFilterTest extends AbstractFilterTestBase<Not> { protected Item item1 = new BeanItem<Integer>(1); protected Item item2 = new BeanItem<Integer>(2); diff --git a/server/tests/src/com/vaadin/data/util/filter/SimpleStringFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/SimpleStringFilterTest.java index eb7dff6015..fcaff6f2c3 100644 --- a/server/tests/src/com/vaadin/data/util/filter/SimpleStringFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/SimpleStringFilterTest.java @@ -3,7 +3,7 @@ package com.vaadin.data.util.filter; import org.junit.Assert; public class SimpleStringFilterTest extends - AbstractFilterTest<SimpleStringFilter> { + AbstractFilterTestBase<SimpleStringFilter> { protected static TestItem<String, String> createTestItem() { return new TestItem<String, String>("abcde", "TeSt"); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java index b76e3df10e..f6619a33b6 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/DataGenerator.java @@ -13,12 +13,6 @@ import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; public class DataGenerator { - @Test - public void testDummy() { - // Added dummy test so JUnit will not complain about - // "No runnable methods". - } - public static void addPeopleToDatabase(JDBCConnectionPool connectionPool) throws SQLException { Connection conn = connectionPool.reserveConnection(); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java index e30ff8f5da..288cb65fae 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/FreeformQueryUtil.java @@ -11,12 +11,6 @@ import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder; public class FreeformQueryUtil { - @Test - public void testDummy() { - // Added dummy test so JUnit will not complain about - // "No runnable methods". - } - public static StatementHelper getQueryWithFilters(List<Filter> filters, int offset, int limit) { StatementHelper sh = new StatementHelper(); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java index 324899e373..1c70c8dad7 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/connection/MockInitialContextFactory.java @@ -12,12 +12,6 @@ import org.junit.Test; public class MockInitialContextFactory implements InitialContextFactory { private static Context mockCtx = null; - @Test - public void testDummy() { - // Added dummy test so JUnit will not complain about - // "No runnable methods". - } - public static void setMockContext(Context ctx) { mockCtx = ctx; } diff --git a/server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java b/server/tests/src/com/vaadin/server/VaadinGateInRequestTest.java index 4478b4cf39..eda2b3a006 100644 --- a/server/tests/src/com/vaadin/server/VaadinGateInRequestTests.java +++ b/server/tests/src/com/vaadin/server/VaadinGateInRequestTest.java @@ -20,8 +20,8 @@ import static org.mockito.Mockito.spy; import com.vaadin.server.VaadinPortlet.VaadinGateInRequest; -public class VaadinGateInRequestTests extends - VaadinHttpAndPortletRequestTests<VaadinGateInRequest> { +public class VaadinGateInRequestTest extends + VaadinHttpAndPortletRequestTestBase<VaadinGateInRequest> { @Override protected VaadinGateInRequest createSut() { diff --git a/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java b/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTestBase.java index a87eb1870e..0f7cce5f75 100644 --- a/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTests.java +++ b/server/tests/src/com/vaadin/server/VaadinHttpAndPortletRequestTestBase.java @@ -33,9 +33,7 @@ import org.junit.Test; import com.vaadin.server.VaadinPortlet.VaadinHttpAndPortletRequest; import com.vaadin.server.VaadinPortletService; -//Have to ignore this class - otherwise JUnit tries to instantiate it... -@Ignore -public abstract class VaadinHttpAndPortletRequestTests<T extends VaadinHttpAndPortletRequest> { +public abstract class VaadinHttpAndPortletRequestTestBase<T extends VaadinHttpAndPortletRequest> { protected VaadinHttpAndPortletRequest sut; protected HttpServletRequest servletRequest; diff --git a/server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java b/server/tests/src/com/vaadin/server/VaadinLiferayRequestTest.java index 8ccd649ea4..3024cd652f 100644 --- a/server/tests/src/com/vaadin/server/VaadinLiferayRequestTests.java +++ b/server/tests/src/com/vaadin/server/VaadinLiferayRequestTest.java @@ -20,8 +20,8 @@ import static org.mockito.Mockito.spy; import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest; -public class VaadinLiferayRequestTests extends - VaadinHttpAndPortletRequestTests<VaadinLiferayRequest> { +public class VaadinLiferayRequestTest extends + VaadinHttpAndPortletRequestTestBase<VaadinLiferayRequest> { @Override protected VaadinLiferayRequest createSut() { diff --git a/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java b/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTest.java index a1abfbd280..3a4c5c69be 100644 --- a/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTests.java +++ b/server/tests/src/com/vaadin/server/VaadinWebSpherePortalRequestTest.java @@ -20,8 +20,8 @@ import static org.mockito.Mockito.spy; import com.vaadin.server.VaadinPortlet.VaadinWebSpherePortalRequest; -public class VaadinWebSpherePortalRequestTests extends - VaadinHttpAndPortletRequestTests<VaadinWebSpherePortalRequest> { +public class VaadinWebSpherePortalRequestTest extends + VaadinHttpAndPortletRequestTestBase<VaadinWebSpherePortalRequest> { @Override protected VaadinWebSpherePortalRequest createSut() { diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java b/server/tests/src/com/vaadin/tests/data/converter/AnyEnumToStringConverterTest.java index 64b06f651e..83b4abad3f 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestAnyEnumToStringConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/AnyEnumToStringConverterTest.java @@ -29,7 +29,7 @@ import com.vaadin.tests.data.bean.AnotherTestEnum; import com.vaadin.tests.data.bean.TestEnum; import com.vaadin.ui.TextField; -public class TestAnyEnumToStringConverter { +public class AnyEnumToStringConverterTest { public class AnyEnumToStringConverter implements Converter<Enum, String> { diff --git a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactoryTest.java index 32c9dc6604..a61c0c9986 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactoryTest.java @@ -25,7 +25,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.TextField; -public class ConverterFactory extends TestCase { +public class ConverterFactoryTest extends TestCase { public static class ConvertTo42 implements Converter<String, Integer> { diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestDateToLongConverter.java b/server/tests/src/com/vaadin/tests/data/converter/DateToLongConverterTest.java index 6b9fa93e27..d767430cc1 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestDateToLongConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/DateToLongConverterTest.java @@ -6,7 +6,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.DateToLongConverter; -public class TestDateToLongConverter extends TestCase { +public class DateToLongConverterTest extends TestCase { DateToLongConverter converter = new DateToLongConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java b/server/tests/src/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java index d591d10e18..46dca6d13e 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/DateToSqlDateConverterTest.java @@ -7,7 +7,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.DateToSqlDateConverter; -public class TestDateToSqlDateConverter extends TestCase { +public class DateToSqlDateConverterTest extends TestCase { DateToSqlDateConverter converter = new DateToSqlDateConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestDefaultConverterFactory.java b/server/tests/src/com/vaadin/tests/data/converter/DefaultConverterFactoryTest.java index e1becf43e1..047ed8a79f 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestDefaultConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/data/converter/DefaultConverterFactoryTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import com.vaadin.data.util.converter.DefaultConverterFactory; -public class TestDefaultConverterFactory { +public class DefaultConverterFactoryTest { private DefaultConverterFactory factory = new DefaultConverterFactory(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java b/server/tests/src/com/vaadin/tests/data/converter/SpecificEnumToStringConverterTest.java index 75c742775f..377998db1e 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestSpecificEnumToStringConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/SpecificEnumToStringConverterTest.java @@ -29,7 +29,7 @@ import com.vaadin.tests.data.bean.AnotherTestEnum; import com.vaadin.tests.data.bean.TestEnum; import com.vaadin.ui.TextField; -public class TestSpecificEnumToStringConverter { +public class SpecificEnumToStringConverterTest { public class SpecificEnumToStringConverter implements Converter<Enum, String> { diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java index b8e74c7572..06d407c9f4 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigDecimalConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java @@ -22,7 +22,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToBigDecimalConverter; -public class TestStringToBigDecimalConverter extends TestCase { +public class StringToBigDecimalConverterTest extends TestCase { StringToBigDecimalConverter converter = new StringToBigDecimalConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigIntegerConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java index 8d493609fe..057017790d 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBigIntegerConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java @@ -22,7 +22,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToBigIntegerConverter; -public class TestStringToBigIntegerConverter extends TestCase { +public class StringToBigIntegerConverterTest extends TestCase { StringToBigIntegerConverter converter = new StringToBigIntegerConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBooleanConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java index 7be922a63a..f734d76633 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToBooleanConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToBooleanConverter; -public class TestStringToBooleanConverter extends TestCase { +public class StringToBooleanConverterTest extends TestCase { StringToBooleanConverter converter = new StringToBooleanConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToByteConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToByteConverterTest.java index 19a68fbfdb..3859d03cc3 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToByteConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToByteConverterTest.java @@ -9,7 +9,7 @@ import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToByteConverter; -public class TestStringToByteConverter extends TestCase { +public class StringToByteConverterTest extends TestCase { StringToByteConverter converter = new StringToByteConverter(); Converter<Byte, String> reverseConverter = new ReverseConverter<Byte, String>( diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToDateConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToDateConverterTest.java index eb0e1461b2..16008d89c2 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToDateConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToDateConverterTest.java @@ -7,7 +7,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToDateConverter; -public class TestStringToDateConverter extends TestCase { +public class StringToDateConverterTest extends TestCase { StringToDateConverter converter = new StringToDateConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToDoubleConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java index 14691bd922..7054587009 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToDoubleConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToDoubleConverter; -public class TestStringToDoubleConverter extends TestCase { +public class StringToDoubleConverterTest extends TestCase { StringToDoubleConverter converter = new StringToDoubleConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToEnumConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java index 5dc24ca43a..a4c3732e1f 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToEnumConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToEnumConverterTest.java @@ -7,7 +7,7 @@ import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToEnumConverter; -public class TestStringToEnumConverter extends TestCase { +public class StringToEnumConverterTest extends TestCase { public static enum FooEnum { VALUE1, SOME_VALUE, FOO_BAR_BAZ, Bar, nonStandardCase, _HUGH; diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToFloatConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToFloatConverterTest.java index 6721a92b1a..86319e641c 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToFloatConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToFloatConverterTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.StringToFloatConverter; -public class TestStringToFloatConverter extends TestCase { +public class StringToFloatConverterTest extends TestCase { StringToFloatConverter converter = new StringToFloatConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java index e810106631..0076f2c9d1 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToIntegerConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java @@ -5,7 +5,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.StringToIntegerConverter; -public class TestStringToIntegerConverter extends TestCase { +public class StringToIntegerConverterTest extends TestCase { StringToIntegerConverter converter = new StringToIntegerConverter(); diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToLongConverterTest.java index 0e95975c17..989dbcbbf5 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToLongConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToLongConverterTest.java @@ -10,7 +10,7 @@ import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToLongConverter; -public class TestStringToLongConverter extends TestCase { +public class StringToLongConverterTest extends TestCase { StringToLongConverter converter = new StringToLongConverter(); Converter<Long, String> reverseConverter = new ReverseConverter<Long, String>( diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestStringToShortConverter.java b/server/tests/src/com/vaadin/tests/data/converter/StringToShortConverterTest.java index 542c580025..ab255bce80 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/TestStringToShortConverter.java +++ b/server/tests/src/com/vaadin/tests/data/converter/StringToShortConverterTest.java @@ -9,7 +9,7 @@ import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.ReverseConverter; import com.vaadin.data.util.converter.StringToShortConverter; -public class TestStringToShortConverter extends TestCase { +public class StringToShortConverterTest extends TestCase { StringToShortConverter converter = new StringToShortConverter(); Converter<Short, String> reverseConverter = new ReverseConverter<Short, String>( diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestBigDecimalRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java index 2ce576fb77..36f120151b 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestBigDecimalRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/BigDecimalRangeValidatorTest.java @@ -6,7 +6,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.BigDecimalRangeValidator; -public class TestBigDecimalRangeValidator extends TestCase { +public class BigDecimalRangeValidatorTest extends TestCase { private BigDecimalRangeValidator cleanValidator = new BigDecimalRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestBigIntegerRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java index d3263df6d2..92fabbb02a 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestBigIntegerRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/BigIntegerRangeValidatorTest.java @@ -6,7 +6,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.BigIntegerRangeValidator; -public class TestBigIntegerRangeValidator extends TestCase { +public class BigIntegerRangeValidatorTest extends TestCase { private BigIntegerRangeValidator cleanValidator = new BigIntegerRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestByteRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java index 6fac06c31b..03f35fe1bb 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestByteRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/ByteRangeValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.ByteRangeValidator; -public class TestByteRangeValidator extends TestCase { +public class ByteRangeValidatorTest extends TestCase { private ByteRangeValidator cleanValidator = new ByteRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestCompositeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/CompositeValidatorTest.java index 1d69c77a3d..8199419b67 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestCompositeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/CompositeValidatorTest.java @@ -8,7 +8,7 @@ import com.vaadin.data.validator.CompositeValidator.CombinationMode; import com.vaadin.data.validator.EmailValidator; import com.vaadin.data.validator.RegexpValidator; -public class TestCompositeValidator extends TestCase { +public class CompositeValidatorTest extends TestCase { CompositeValidator and = new CompositeValidator(CombinationMode.AND, "One validator not valid"); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestDateRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/DateRangeValidatorTest.java index cdb1e12545..7bb3e20160 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestDateRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/DateRangeValidatorTest.java @@ -10,7 +10,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.DateRangeValidator; import com.vaadin.shared.ui.datefield.Resolution; -public class TestDateRangeValidator extends TestCase { +public class DateRangeValidatorTest extends TestCase { Calendar startDate = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); Calendar endDate = new GregorianCalendar(TimeZone.getTimeZone("GMT"), diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestDoubleRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java index 3fe61e13f4..b096937bd2 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestDoubleRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/DoubleRangeValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.DoubleRangeValidator; -public class TestDoubleRangeValidator extends TestCase { +public class DoubleRangeValidatorTest extends TestCase { private DoubleRangeValidator cleanValidator = new DoubleRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestEmailValidator.java b/server/tests/src/com/vaadin/tests/data/validator/EmailValidatorTest.java index 7644b4738c..19fe9e6580 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestEmailValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/EmailValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.EmailValidator; -public class TestEmailValidator extends TestCase { +public class EmailValidatorTest extends TestCase { private EmailValidator validator = new EmailValidator("Error"); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestFloatRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java index 8de363e3d7..c5a07be43f 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestFloatRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/FloatRangeValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.FloatRangeValidator; -public class TestFloatRangeValidator extends TestCase { +public class FloatRangeValidatorTest extends TestCase { private FloatRangeValidator cleanValidator = new FloatRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestIntegerRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java index 864fc61ab6..5e64d0107e 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestIntegerRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/IntegerRangeValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.IntegerRangeValidator; -public class TestIntegerRangeValidator extends TestCase { +public class IntegerRangeValidatorTest extends TestCase { private IntegerRangeValidator cleanValidator = new IntegerRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestLongRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/LongRangeValidatorTest.java index a9aeb6b67b..440e9c3fd2 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestLongRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/LongRangeValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.LongRangeValidator; -public class TestLongRangeValidator extends TestCase { +public class LongRangeValidatorTest extends TestCase { private LongRangeValidator cleanValidator = new LongRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestNullValidator.java b/server/tests/src/com/vaadin/tests/data/validator/NullValidatorTest.java index 0a0634ec8f..1e08ea7e2c 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestNullValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/NullValidatorTest.java @@ -5,7 +5,7 @@ import junit.framework.TestCase; import com.vaadin.data.Validator; import com.vaadin.data.validator.NullValidator; -public class TestNullValidator extends TestCase { +public class NullValidatorTest extends TestCase { NullValidator notNull = new NullValidator("Null not accepted", false); NullValidator onlyNull = new NullValidator("Only null accepted", true); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestRegexpValidator.java b/server/tests/src/com/vaadin/tests/data/validator/RegexpValidatorTest.java index bcff224451..2a62d23059 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestRegexpValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/RegexpValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.RegexpValidator; -public class TestRegexpValidator extends TestCase { +public class RegexpValidatorTest extends TestCase { private RegexpValidator completeValidator = new RegexpValidator("pattern", true, "Complete match validator error"); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestShortRangeValidator.java b/server/tests/src/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java index b522abb179..69d22eb91e 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestShortRangeValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/ShortRangeValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.ShortRangeValidator; -public class TestShortRangeValidator extends TestCase { +public class ShortRangeValidatorTest extends TestCase { private ShortRangeValidator cleanValidator = new ShortRangeValidator( "no values", null, null); diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestStringLengthValidator.java b/server/tests/src/com/vaadin/tests/data/validator/StringLengthValidatorTest.java index 6b4b2b0d51..5f12367f09 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestStringLengthValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/StringLengthValidatorTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.data.validator.StringLengthValidator; -public class TestStringLengthValidator extends TestCase { +public class StringLengthValidatorTest extends TestCase { private StringLengthValidator validator = new StringLengthValidator("Error"); private StringLengthValidator validatorNoNull = new StringLengthValidator( diff --git a/server/tests/src/com/vaadin/tests/design/DesignReadInConstructor.java b/server/tests/src/com/vaadin/tests/design/DesignReadInConstructor.java index ce80d98324..6eccaf6a2c 100644 --- a/server/tests/src/com/vaadin/tests/design/DesignReadInConstructor.java +++ b/server/tests/src/com/vaadin/tests/design/DesignReadInConstructor.java @@ -15,12 +15,9 @@ */ package com.vaadin.tests.design; -import org.junit.Ignore; - import com.vaadin.ui.CssLayout; import com.vaadin.ui.declarative.Design; -@Ignore public class DesignReadInConstructor extends CssLayout { public DesignReadInConstructor() { diff --git a/server/tests/src/com/vaadin/tests/design/InvalidLayoutTemplate.java b/server/tests/src/com/vaadin/tests/design/InvalidLayoutTemplate.java index bdfa4b47cc..8a2dec5a35 100644 --- a/server/tests/src/com/vaadin/tests/design/InvalidLayoutTemplate.java +++ b/server/tests/src/com/vaadin/tests/design/InvalidLayoutTemplate.java @@ -15,8 +15,6 @@ */ package com.vaadin.tests.design; -import org.junit.Ignore; - import com.vaadin.ui.Button; import com.vaadin.ui.NativeButton; import com.vaadin.ui.TextField; @@ -27,7 +25,6 @@ import com.vaadin.ui.VerticalLayout; * @since * @author Vaadin Ltd */ -@Ignore public class InvalidLayoutTemplate extends VerticalLayout { private NativeButton firstButton; private NativeButton secondButton; diff --git a/server/tests/src/com/vaadin/tests/design/LayoutTemplate.java b/server/tests/src/com/vaadin/tests/design/LayoutTemplate.java index 95f30fb728..fdfddf5c08 100644 --- a/server/tests/src/com/vaadin/tests/design/LayoutTemplate.java +++ b/server/tests/src/com/vaadin/tests/design/LayoutTemplate.java @@ -15,8 +15,6 @@ */ package com.vaadin.tests.design; -import org.junit.Ignore; - import com.vaadin.ui.Button; import com.vaadin.ui.NativeButton; import com.vaadin.ui.VerticalLayout; @@ -27,7 +25,6 @@ import com.vaadin.ui.VerticalLayout; * @since * @author Vaadin Ltd */ -@Ignore public class LayoutTemplate extends VerticalLayout { private NativeButton firstButton; // assigned based on local id private NativeButton secondButton; // assigned based on id diff --git a/server/tests/src/com/vaadin/tests/design/TestLocale.java b/server/tests/src/com/vaadin/tests/design/LocaleTest.java index a4100f7d71..939080fbbc 100644 --- a/server/tests/src/com/vaadin/tests/design/TestLocale.java +++ b/server/tests/src/com/vaadin/tests/design/LocaleTest.java @@ -32,6 +32,11 @@ import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; import com.vaadin.ui.declarative.DesignContext; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * Tests the handling of the locale property in parsing and html generation. @@ -39,10 +44,10 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestLocale extends TestCase { +public class LocaleTest { DesignContext ctx; - @Override + @Before public void setUp() { ctx = new DesignContext(); } @@ -52,6 +57,7 @@ public class TestLocale extends TestCase { * constructed, the result only contains locale attributes for a component * if its locale differs from that of its parent. */ + @Test public void testHtmlGeneration() { // create a component hierarchy VerticalLayout vLayout = new VerticalLayout(); @@ -130,6 +136,7 @@ public class TestLocale extends TestCase { * Checks that the locale of a component is set when the html element * corresponding to the component specifies a locale. */ + @Test public void testParsing() { // create an html document Document doc = new Document(""); diff --git a/server/tests/src/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java b/server/tests/src/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java index 4f3f205631..5f901cd746 100644 --- a/server/tests/src/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java +++ b/server/tests/src/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java @@ -22,26 +22,28 @@ import junit.framework.TestCase; import com.vaadin.ui.declarative.Design; import com.vaadin.ui.declarative.DesignContext; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; /** * Just top level test case that contains all synchronizable components * * @author Vaadin Ltd */ -public class ParseAllSupportedComponentsTest extends TestCase { +public class ParseAllSupportedComponentsTest { + + @Test + public void allComponentsAreParsed() throws FileNotFoundException { + DesignContext ctx = Design + .read(new FileInputStream( + "server/tests/src/com/vaadin/tests/design/all-components.html"), + null); - public void testParsing() { - try { - DesignContext ctx = Design - .read(new FileInputStream( - "server/tests/src/com/vaadin/tests/design/all-components.html"), - null); - assertNotNull("The returned design context can not be null", ctx); - assertNotNull("the component root can not be null", - ctx.getRootComponent()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail("Template parsing threw exception"); - } + assertThat(ctx, is(not(nullValue()))); + assertThat(ctx.getRootComponent(), is(not(nullValue()))); } } diff --git a/server/tests/src/com/vaadin/tests/design/ParseLayoutTest.java b/server/tests/src/com/vaadin/tests/design/ParseLayoutTest.java index c517b0e5e2..70376c79f8 100644 --- a/server/tests/src/com/vaadin/tests/design/ParseLayoutTest.java +++ b/server/tests/src/com/vaadin/tests/design/ParseLayoutTest.java @@ -22,25 +22,27 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import junit.framework.TestCase; - import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; +import org.junit.Before; import org.junit.Test; -import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.NativeButton; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.DesignException; +import org.junit.rules.ExpectedException; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.*; /** * A test for checking that parsing a layout preserves the IDs and the mapping @@ -50,45 +52,62 @@ import com.vaadin.ui.declarative.DesignException; * @since * @author Vaadin Ltd */ -public class ParseLayoutTest extends TestCase { +public class ParseLayoutTest { // The context is used for accessing the created component hierarchy. private DesignContext ctx; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { ctx = Design .read(new FileInputStream( "server/tests/src/com/vaadin/tests/design/testFile.html"), null); } - /* - * Checks the component hierarchy created by parsing a design. Also checks - * that components can be found by id and caption. - */ @Test - public void testGettingByIDAndCaption() throws FileNotFoundException { - findElements(ctx); - checkHierarchy(ctx); - } - - /* - * Check that captions, ids and package mappings are preserved when an html - * tree is generated from a DesignContext containing the component root of - * the component hierarchy. Done by writing the design to a string and then - * reading it back, not using the original context information after reading - * the written design. The mapping from prefixes to package names is checked - * directly from the html tree. - */ + public void buttonWithIdIsParsed() { + Component button = ctx.getComponentByLocalId("firstButton"); + + assertThat(ctx.getComponentByCaption("Native click me"), is(button)); + assertThat(button.getCaption(), is("Native click me")); + } + @Test - public void testThatSerializationPreservesProperties() throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Design.write(ctx, out); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - DesignContext newContext = Design.read(in, null); - findElements(newContext); - checkHierarchy(newContext); + public void buttonWithIdAndLocalIdIsParsed() { + Component button = ctx.getComponentById("secondButton"); + + assertThat(ctx.getComponentByCaption("Another button"), is(button)); + assertThat(ctx.getComponentByLocalId("localID"), is(button)); + assertThat(button.getCaption(), is("Another button")); + } + + @Test + public void buttonWithoutIdsIsParsed() { + assertThat(ctx.getComponentByCaption("Yet another button"), + is(not(nullValue()))); + } + + @Test + public void serializationPreservesProperties() throws IOException { + ByteArrayOutputStream out = serializeDesign(ctx); + ctx = deSerializeDesign(out); + + assertButtonProperties(); + } + + @Test + public void serializationPreservesHierarchy() throws IOException { + ByteArrayOutputStream out = serializeDesign(ctx); + ctx = deSerializeDesign(out); + + assertComponentHierarchy(); + } + + @Test + public void designIsSerializedWithCorrectPrefixesAndPackageNames() + throws IOException { + ByteArrayOutputStream out = serializeDesign(ctx); + // Check the mapping from prefixes to package names using the html tree String[] expectedPrefixes = { "my" }; String[] expectedPackageNames = { "com.addon.mypackage" }; @@ -114,13 +133,26 @@ public class ParseLayoutTest extends TestCase { index); } - /* - * Check that the field binding works if root instance with member fields is - * passed to the LayoutHandler - * - * @throws IOException - */ - public void testFieldBinding() throws IOException { + private DesignContext deSerializeDesign(ByteArrayOutputStream out) { + ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); + return Design.read(in, null); + } + + private ByteArrayOutputStream serializeDesign(DesignContext context) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + Design.write(context, out); + + return out; + } + + private void assertButtonProperties() { + buttonWithIdAndLocalIdIsParsed(); + buttonWithIdIsParsed(); + buttonWithoutIdsIsParsed(); + } + + @Test + public void fieldsAreBoundToATemplate() throws IOException { LayoutTemplate template = new LayoutTemplate(); InputStream htmlFile = new FileInputStream( "server/tests/src/com/vaadin/tests/design/testFile.html"); @@ -132,92 +164,59 @@ public class ParseLayoutTest extends TestCase { assertEquals("Native click me", template.getFirstButton().getCaption()); } - /* - * Check that the field binding fails if some of the fields in the root - * instance were not bound - * - * @throws IOException - */ - public void testUnboundFields() throws IOException { + @Test(expected = DesignException.class) + public void fieldsCannotBeBoundToAnInvalidTemplate() throws IOException { InvalidLayoutTemplate template = new InvalidLayoutTemplate(); InputStream htmlFile = new FileInputStream( "server/tests/src/com/vaadin/tests/design/testFile.html"); - try { - Design.read(htmlFile, template); - // we are expecting an exception - fail(); - } catch (DesignException e) { - // expected - } + + Design.read(htmlFile, template); } - /* - * Checks that the correct components occur in the correct order in the - * component hierarchy rooted at context.getComponentRoot(). - */ - private void checkHierarchy(DesignContext context) { - Component root = context.getRootComponent(); + @Test + public void rootHasCorrectComponents() { + Component root = ctx.getRootComponent(); + VerticalLayout vlayout = (VerticalLayout) root; - int numComponents = vlayout.getComponentCount(); - assertEquals("Wrong number of child components", 3, numComponents); - // Check the contents of the horizontal layout + assertThat(vlayout.getComponentCount(), is(3)); + } + + @Test + public void rootChildHasCorrectComponents() { + Component root = ctx.getRootComponent(); + VerticalLayout vlayout = (VerticalLayout) root; HorizontalLayout hlayout = (HorizontalLayout) vlayout.getComponent(0); - int numHLComponents = hlayout.getComponentCount(); - assertEquals(5, numHLComponents); - Label label = (Label) hlayout.getComponent(0); - assertEquals("Wrong caption.", "FooBar", label.getCaption()); - NativeButton nb = (NativeButton) hlayout.getComponent(1); - assertEquals("Wrong caption.", "Native click me", nb.getCaption()); - nb = (NativeButton) hlayout.getComponent(2); - assertEquals("Wrong caption.", "Another button", nb.getCaption()); - nb = (NativeButton) hlayout.getComponent(3); - assertEquals("Wrong caption.", "Yet another button", nb.getCaption()); - Button b = (Button) hlayout.getComponent(4); - assertEquals("Wrong caption.", "Click me", b.getCaption()); - assertEquals("Wrong width.", 150f, b.getWidth()); + + assertThat(hlayout.getComponentCount(), is(5)); + assertThat(hlayout.getComponent(0).getCaption(), is("FooBar")); + assertThat(hlayout.getComponent(1).getCaption(), is("Native click me")); + assertThat(hlayout.getComponent(2).getCaption(), is("Another button")); + assertThat(hlayout.getComponent(3).getCaption(), is("Yet another button")); + assertThat(hlayout.getComponent(4).getCaption(), is("Click me")); + assertThat(hlayout.getComponent(4).getWidth(), is(150f)); // Check the remaining two components of the vertical layout + assertTextField(vlayout); + assertTextArea(vlayout); + } + + private void assertComponentHierarchy() { + rootHasCorrectComponents(); + rootChildHasCorrectComponents(); + } + + private void assertTextField(VerticalLayout vlayout) { TextField tf = (TextField) vlayout.getComponent(1); - assertEquals("Wrong caption.", "Text input", tf.getCaption()); - TextArea ta = (TextArea) vlayout.getComponent(2); - assertEquals("Wrong caption.", "Text area", ta.getCaption()); - assertEquals("Wrong width.", 300f, ta.getWidth()); - assertEquals("Wrong height.", 200f, ta.getHeight()); - } - - /* - * Checks that the correct elements are found using a local id, a global id - * or a caption. - */ - private void findElements(DesignContext designContext) { - NativeButton firstButton = (NativeButton) designContext - .getComponentByLocalId("firstButton"); - NativeButton firstButton_2 = (NativeButton) designContext - .getComponentByCaption("Native click me"); - NativeButton secondButton = (NativeButton) designContext - .getComponentById("secondButton"); - NativeButton secondButton_2 = (NativeButton) designContext - .getComponentByLocalId("localID"); - NativeButton secondButton_3 = (NativeButton) designContext - .getComponentByCaption("Another button"); - NativeButton thirdButton = (NativeButton) designContext - .getComponentByCaption("Yet another button"); - // Check that the first button was found using both identifiers. - assertEquals("The found buttons should be identical but they are not.", - firstButton, firstButton_2); - assertTrue("The found button element is incorrect.", firstButton - .getCaption().equals("Native click me")); - // Check that the second button was found using all three identifiers. - assertEquals("The found buttons should be identical but they are not.", - secondButton, secondButton_2); - assertEquals("The found buttons should be identical but they are not.", - secondButton_2, secondButton_3); - assertTrue("The found button is incorrect.", secondButton.getCaption() - .equals("Another button")); - // Check that the third button was found by caption. - assertTrue("The found button is incorrect.", thirdButton.getCaption() - .equals("Yet another button")); + + assertThat(tf.getCaption(), is("Text input")); } + private void assertTextArea(VerticalLayout layout) { + TextArea ta = (TextArea) layout.getComponent(2); + + assertThat(ta.getCaption(), is("Text area")); + assertThat(ta.getWidth(), is(300f)); + assertThat(ta.getHeight(), is(200f)); + } } diff --git a/server/tests/src/com/vaadin/tests/design/designroot/DesignWithAnnotation.java b/server/tests/src/com/vaadin/tests/design/designroot/DesignWithAnnotation.java index 70809cb694..ef9de9dcb0 100644 --- a/server/tests/src/com/vaadin/tests/design/designroot/DesignWithAnnotation.java +++ b/server/tests/src/com/vaadin/tests/design/designroot/DesignWithAnnotation.java @@ -15,8 +15,6 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Ignore; - import com.vaadin.annotations.DesignRoot; import com.vaadin.ui.Button; import com.vaadin.ui.Label; @@ -24,7 +22,6 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; @DesignRoot("DesignWithEmptyAnnotation.html") -@Ignore public class DesignWithAnnotation extends VerticalLayout { public Button ok; diff --git a/server/tests/src/com/vaadin/tests/design/designroot/DesignWithEmptyAnnotation.java b/server/tests/src/com/vaadin/tests/design/designroot/DesignWithEmptyAnnotation.java index f6fb928e75..55fd571ee2 100644 --- a/server/tests/src/com/vaadin/tests/design/designroot/DesignWithEmptyAnnotation.java +++ b/server/tests/src/com/vaadin/tests/design/designroot/DesignWithEmptyAnnotation.java @@ -15,8 +15,6 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Ignore; - import com.vaadin.annotations.DesignRoot; import com.vaadin.ui.Button; import com.vaadin.ui.Label; @@ -24,7 +22,6 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; @DesignRoot -@Ignore public class DesignWithEmptyAnnotation extends VerticalLayout { protected Button ok; diff --git a/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithAnnotation.java b/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithAnnotation.java index 14e4269e80..d47b4540df 100644 --- a/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithAnnotation.java +++ b/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithAnnotation.java @@ -15,11 +15,8 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Ignore; - import com.vaadin.ui.TextField; -@Ignore public class ExtendedDesignWithAnnotation extends DesignWithAnnotation { private TextField customField = new TextField(); diff --git a/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java b/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java index 22865b098c..ea513f6d3e 100644 --- a/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java +++ b/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotation.java @@ -15,14 +15,11 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Ignore; - import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; import com.vaadin.ui.TextField; -@Ignore public class ExtendedDesignWithEmptyAnnotation extends DesignWithEmptyAnnotation { diff --git a/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotationUI.java b/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotationUI.java index 34f517d25d..1d0e8de4eb 100644 --- a/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotationUI.java +++ b/server/tests/src/com/vaadin/tests/design/designroot/ExtendedDesignWithEmptyAnnotationUI.java @@ -15,12 +15,9 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Ignore; - import com.vaadin.server.VaadinRequest; import com.vaadin.ui.UI; -@Ignore public class ExtendedDesignWithEmptyAnnotationUI extends UI { @Override diff --git a/server/tests/src/com/vaadin/tests/design/nested/MyChildDesign.java b/server/tests/src/com/vaadin/tests/design/nested/MyChildDesign.java index e85c0aca5f..3b0d80c32c 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/MyChildDesign.java +++ b/server/tests/src/com/vaadin/tests/design/nested/MyChildDesign.java @@ -15,8 +15,6 @@ */ package com.vaadin.tests.design.nested; -import org.junit.Ignore; - import com.vaadin.annotations.DesignRoot; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -27,7 +25,6 @@ import com.vaadin.ui.declarative.Design; * * @author Vaadin Ltd */ -@Ignore @DesignRoot("mychilddesign.html") public class MyChildDesign extends HorizontalLayout { public Label childLabel; diff --git a/server/tests/src/com/vaadin/tests/design/nested/MyChildDesignCustomComponent.java b/server/tests/src/com/vaadin/tests/design/nested/MyChildDesignCustomComponent.java index 94e34baea2..8402224cf9 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/MyChildDesignCustomComponent.java +++ b/server/tests/src/com/vaadin/tests/design/nested/MyChildDesignCustomComponent.java @@ -15,11 +15,8 @@ */ package com.vaadin.tests.design.nested; -import org.junit.Ignore; - import com.vaadin.ui.Button; -@Ignore public class MyChildDesignCustomComponent extends Button { } diff --git a/server/tests/src/com/vaadin/tests/design/nested/MyDesignRoot.java b/server/tests/src/com/vaadin/tests/design/nested/MyDesignRoot.java index 5727322ce3..abde002ef8 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/MyDesignRoot.java +++ b/server/tests/src/com/vaadin/tests/design/nested/MyDesignRoot.java @@ -15,8 +15,6 @@ */ package com.vaadin.tests.design.nested; -import org.junit.Ignore; - import com.vaadin.annotations.DesignRoot; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; @@ -26,7 +24,6 @@ import com.vaadin.ui.declarative.Design; * * @author Vaadin Ltd */ -@Ignore @DesignRoot("mydesignroot.html") public class MyDesignRoot extends VerticalLayout { // should be assigned automatically diff --git a/server/tests/src/com/vaadin/tests/design/nested/MyExtendedChildDesign.java b/server/tests/src/com/vaadin/tests/design/nested/MyExtendedChildDesign.java index 2012e4ec14..579fdfb869 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/MyExtendedChildDesign.java +++ b/server/tests/src/com/vaadin/tests/design/nested/MyExtendedChildDesign.java @@ -15,9 +15,6 @@ */ package com.vaadin.tests.design.nested; -import org.junit.Ignore; - -@Ignore public class MyExtendedChildDesign extends MyChildDesign { public MyExtendedChildDesign() { super(); diff --git a/server/tests/src/com/vaadin/tests/design/nested/TestNestedCustomLayouts.java b/server/tests/src/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java index c71ccca85b..beaa9519cb 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/TestNestedCustomLayouts.java +++ b/server/tests/src/com/vaadin/tests/design/nested/NestedCustomLayoutsTest.java @@ -15,29 +15,20 @@ */ package com.vaadin.tests.design.nested; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import junit.framework.TestCase; - +import com.vaadin.tests.design.nested.customlayouts.*; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.declarative.Design; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.junit.Test; -import com.vaadin.tests.design.nested.customlayouts.CustomAbsoluteLayout; -import com.vaadin.tests.design.nested.customlayouts.CustomAccordion; -import com.vaadin.tests.design.nested.customlayouts.CustomCssLayout; -import com.vaadin.tests.design.nested.customlayouts.CustomFormLayout; -import com.vaadin.tests.design.nested.customlayouts.CustomGridLayout; -import com.vaadin.tests.design.nested.customlayouts.CustomHorizontalLayout; -import com.vaadin.tests.design.nested.customlayouts.CustomHorizontalSplitPanel; -import com.vaadin.tests.design.nested.customlayouts.CustomPanel; -import com.vaadin.tests.design.nested.customlayouts.CustomTabSheet; -import com.vaadin.tests.design.nested.customlayouts.CustomVerticalLayout; -import com.vaadin.tests.design.nested.customlayouts.CustomVerticalSplitPanel; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.declarative.Design; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; /** * Test case for nested custom layouts. The children of the custom layouts must @@ -45,12 +36,24 @@ import com.vaadin.ui.declarative.Design; * * @author Vaadin Ltd */ -public class TestNestedCustomLayouts extends TestCase { +public class NestedCustomLayoutsTest { private static String PACKAGE_MAPPING = "com_vaadin_tests_design_nested_customlayouts:com.vaadin.tests.design.nested.customlayouts"; @Test public void testNestedLayouts() throws IOException { + VerticalLayout rootLayout = createRootLayout(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + Design.write(rootLayout, out); + Document doc = Jsoup.parse(out.toString("UTF-8")); + + assertThat(doc.head().child(0).attr("name"), is("package-mapping")); + assertThat(doc.head().child(0).attr("content"), is(PACKAGE_MAPPING)); + assertChildrenCount(doc); + } + + private VerticalLayout createRootLayout() { VerticalLayout rootLayout = new VerticalLayout(); rootLayout.addComponent(new CustomAbsoluteLayout()); rootLayout.addComponent(new CustomAccordion()); @@ -63,18 +66,17 @@ public class TestNestedCustomLayouts extends TestCase { rootLayout.addComponent(new CustomTabSheet()); rootLayout.addComponent(new CustomVerticalLayout()); rootLayout.addComponent(new CustomVerticalSplitPanel()); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - Design.write(rootLayout, out); - Document doc = Jsoup.parse(out.toString("UTF-8")); - assertEquals("package-mapping", doc.head().child(0).attr("name")); - assertEquals(PACKAGE_MAPPING, doc.head().child(0).attr("content")); + + return rootLayout; + } + + private void assertChildrenCount(Document doc) { Element rootNode = doc.body().child(0); - assertTrue("Root node must have children", - rootNode.children().size() > 0); + assertThat(rootNode.children().size(), greaterThan(0)); + for (Element child : rootNode.children()) { // make sure that the nested custom layouts do not render children - assertEquals("Child nodes must not have children", 0, child - .children().size()); + assertThat(child.children().size(), is(0)); } } } diff --git a/server/tests/src/com/vaadin/tests/design/nested/ReadNestedTemplatesTest.java b/server/tests/src/com/vaadin/tests/design/nested/ReadNestedTemplatesTest.java new file mode 100644 index 0000000000..dc95306cd3 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/design/nested/ReadNestedTemplatesTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.design.nested; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.core.IsNot.not; +import static org.junit.Assert.*; + +/** + * Test case for reading nested templates + * + * @since + * @author Vaadin Ltd + */ +public class ReadNestedTemplatesTest { + + private MyDesignRoot root; + + @Before + public void setUp() { + root = new MyDesignRoot(); + } + + @Test + public void rootContainsOneChild() { + assertThat(root.getComponentCount(), is(1)); + assertThat(root.iterator().next(), + instanceOf(MyExtendedChildDesign.class)); + } + + @Test + public void rootContainsTwoGrandChildren() { + assertThat(root.childDesign.getComponentCount(), is(2)); + } + + @Test + public void childComponentIsNotNull() { + assertThat(root.childDesign, is(not(nullValue()))); + } + + @Test + public void childLabelIsNotNull() { + assertThat(root.childDesign.childLabel, is(not(nullValue()))); + assertThat(root.childDesign.childLabel.getValue(), is("test content")); + } + + @Test + public void childCustomComponentsIsNotNull() { + assertThat(root.childDesign.childCustomComponent, is(not(nullValue()))); + assertThat(root.childDesign.childCustomComponent.getCaption(), + is("custom content")); + } +} diff --git a/server/tests/src/com/vaadin/tests/design/nested/TestReadNestedTemplates.java b/server/tests/src/com/vaadin/tests/design/nested/TestReadNestedTemplates.java deleted file mode 100644 index c1483adc8a..0000000000 --- a/server/tests/src/com/vaadin/tests/design/nested/TestReadNestedTemplates.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.design.nested; - -import junit.framework.TestCase; - -/** - * Test case for reading nested templates - * - * @since - * @author Vaadin Ltd - */ -public class TestReadNestedTemplates extends TestCase { - - private MyDesignRoot root; - - @Override - protected void setUp() throws Exception { - super.setUp(); - root = new MyDesignRoot(); - } - - public void testChildren() { - assertEquals("The root layout must contain one child", 1, - root.getComponentCount()); - assertTrue(root.iterator().next() instanceof MyExtendedChildDesign); - } - - public void testGrandChildren() { - assertEquals("The root layout must have two grandchildren", 2, - root.childDesign.getComponentCount()); - } - - public void testRootComponentFields() { - assertNotNull("The child component must not be null", root.childDesign); - } - - public void testChildComponentFields() { - assertNotNull("Grandchildren must not be null", - root.childDesign.childLabel); - assertNotNull("Grandchildren must not be null", - root.childDesign.childCustomComponent); - assertEquals("child label caption must be read", "test content", - root.childDesign.childLabel.getValue()); - assertEquals("child custom component caption must be read", - "custom content", - root.childDesign.childCustomComponent.getCaption()); - } -} diff --git a/server/tests/src/com/vaadin/tests/design/nested/TestWriteNestedTemplates.java b/server/tests/src/com/vaadin/tests/design/nested/WriteNestedTemplatesTest.java index 7fe63baa73..344cd94ac2 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/TestWriteNestedTemplates.java +++ b/server/tests/src/com/vaadin/tests/design/nested/WriteNestedTemplatesTest.java @@ -15,13 +15,15 @@ */ package com.vaadin.tests.design.nested; -import junit.framework.TestCase; - +import com.vaadin.ui.declarative.DesignContext; import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; import org.jsoup.parser.Tag; +import org.junit.Before; +import org.junit.Test; -import com.vaadin.ui.declarative.DesignContext; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; /** * @@ -29,21 +31,29 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteNestedTemplates extends TestCase { +public class WriteNestedTemplatesTest { private MyDesignRoot root; private Element design; - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() { root = new MyDesignRoot(); design = createDesign(); + } + + private Element createDesign() { + Element design = new Element(Tag.valueOf("v-vertical-layout"), "", + new Attributes()); + DesignContext designContext = new DesignContext(); designContext.setRootComponent(root); root.writeDesign(design, designContext); + + return design; } + @Test public void testChildRendered() { assertEquals("Root layout must have one child", 1, design.children() .size()); @@ -51,39 +61,29 @@ public class TestWriteNestedTemplates extends TestCase { design.child(0).tagName()); } - public void testRootCaptionWritten() { - assertTrue("Root layout caption must be written", - design.hasAttr("caption")); - assertEquals("Root layout caption must be written", "root caption", - design.attr("caption")); + @Test + public void rootCaptionIsWritten() { + assertTrue(design.hasAttr("caption")); + assertThat(design.attr("caption"), is("root caption")); } - public void testChildCaptionWritten() { - assertTrue("Child design caption must be written", design.child(0) - .hasAttr("caption")); - assertEquals("Child design caption must be written", "child caption", - design.child(0).attr("caption")); + @Test + public void childCaptionIsWritten() { + assertTrue(design.child(0).hasAttr("caption")); + assertThat(design.child(0).attr("caption"), is("child caption")); } // The default caption is read from child template - public void testDefaultCaptionShouldNotBeWritten() { - design = createDesign(); + @Test + public void defaultCaptionIsNotOverwritten() { root.childDesign.setCaption("Default caption for child design"); - DesignContext designContext = new DesignContext(); - designContext.setRootComponent(root); - root.writeDesign(design, designContext); - assertFalse("Default caption must not be written", design.child(0) - .hasAttr("caption")); - } + design = createDesign(); - public void testChildDesignChildrenNotWrittenInRootTemplate() { - assertEquals( - "Children of the child template must not be written to root template", - 0, design.child(0).children().size()); + assertFalse(design.child(0).hasAttr("caption")); } - private Element createDesign() { - return new Element(Tag.valueOf("v-vertical-layout"), "", - new Attributes()); + @Test + public void childDesignChildrenIsNotWrittenInRootTemplate() { + assertThat(design.child(0).children().size(), is(0)); } } diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAbsoluteLayout.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAbsoluteLayout.java index ed2b27215e..8eef3b07a6 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAbsoluteLayout.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAbsoluteLayout.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomAbsoluteLayout extends AbsoluteLayout { public CustomAbsoluteLayout() { this.addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAccordion.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAccordion.java index 7d45917520..93606f296c 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAccordion.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomAccordion.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.Accordion; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomAccordion extends Accordion { public CustomAccordion() { addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomCssLayout.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomCssLayout.java index 328a025e01..b2aaa2c015 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomCssLayout.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomCssLayout.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomCssLayout extends CssLayout { public CustomCssLayout() { this.addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomFormLayout.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomFormLayout.java index 179b195926..66ac083c0d 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomFormLayout.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomFormLayout.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomFormLayout extends FormLayout { public CustomFormLayout() { this.addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomGridLayout.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomGridLayout.java index 0b3b90ca1f..1059ea0e14 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomGridLayout.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomGridLayout.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomGridLayout extends GridLayout { public CustomGridLayout() { this.addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalLayout.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalLayout.java index b742f7c629..482a9feb95 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalLayout.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalLayout.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomHorizontalLayout extends HorizontalLayout { public CustomHorizontalLayout() { this.addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalSplitPanel.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalSplitPanel.java index deeb311858..21c8745796 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalSplitPanel.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomHorizontalSplitPanel.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; /** * @author Vaadin Ltd */ -@Ignore public class CustomHorizontalSplitPanel extends HorizontalSplitPanel { public CustomHorizontalSplitPanel() { addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomPanel.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomPanel.java index fa7827bdfd..5841fbcfee 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomPanel.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomPanel.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.Label; import com.vaadin.ui.Panel; /** * @author Vaadin Ltd */ -@Ignore public class CustomPanel extends Panel { public CustomPanel() { setContent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomTabSheet.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomTabSheet.java index 6298b67727..128de7de1f 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomTabSheet.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomTabSheet.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; /** * @author Vaadin Ltd */ -@Ignore public class CustomTabSheet extends TabSheet { public CustomTabSheet() { addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalLayout.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalLayout.java index 7859ae0227..3bc8fba7de 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalLayout.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalLayout.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; /** * @author Vaadin Ltd */ -@Ignore public class CustomVerticalLayout extends VerticalLayout { public CustomVerticalLayout() { this.addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalSplitPanel.java b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalSplitPanel.java index f6eb460c1b..486d71ea75 100644 --- a/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalSplitPanel.java +++ b/server/tests/src/com/vaadin/tests/design/nested/customlayouts/CustomVerticalSplitPanel.java @@ -15,15 +15,12 @@ */ package com.vaadin.tests.design.nested.customlayouts; -import org.junit.Ignore; - import com.vaadin.ui.Label; import com.vaadin.ui.VerticalSplitPanel; /** * @author Vaadin Ltd */ -@Ignore public class CustomVerticalSplitPanel extends VerticalSplitPanel { public CustomVerticalSplitPanel() { addComponent(new Label()); diff --git a/server/tests/src/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java b/server/tests/src/com/vaadin/tests/server/AbstractBeanContainerListenersTest.java index 0d8433d1c6..b9b4f8025d 100644 --- a/server/tests/src/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java +++ b/server/tests/src/com/vaadin/tests/server/AbstractBeanContainerListenersTest.java @@ -3,10 +3,10 @@ package com.vaadin.tests.server; import com.vaadin.data.Container.PropertySetChangeEvent; import com.vaadin.data.Container.PropertySetChangeListener; import com.vaadin.data.util.BeanItemContainer; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -public class TestAbstractBeanContainerListeners extends - AbstractListenerMethodsTest { +public class AbstractBeanContainerListenersTest extends + AbstractListenerMethodsTestBase { public void testPropertySetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(BeanItemContainer.class, PropertySetChangeEvent.class, PropertySetChangeListener.class, diff --git a/server/tests/src/com/vaadin/tests/server/TestAbstractContainerListeners.java b/server/tests/src/com/vaadin/tests/server/AbstractContainerListenersTest.java index b63e4f809a..a5c7dc3ab2 100644 --- a/server/tests/src/com/vaadin/tests/server/TestAbstractContainerListeners.java +++ b/server/tests/src/com/vaadin/tests/server/AbstractContainerListenersTest.java @@ -5,9 +5,9 @@ import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Container.PropertySetChangeEvent; import com.vaadin.data.Container.PropertySetChangeListener; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -public class TestAbstractContainerListeners extends AbstractListenerMethodsTest { +public class AbstractContainerListenersTest extends AbstractListenerMethodsTestBase { public void testItemSetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, diff --git a/server/tests/src/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java b/server/tests/src/com/vaadin/tests/server/AbstractInMemoryContainerListenersTest.java index a8e2a4aa2a..072998b8e1 100644 --- a/server/tests/src/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java +++ b/server/tests/src/com/vaadin/tests/server/AbstractInMemoryContainerListenersTest.java @@ -3,10 +3,10 @@ package com.vaadin.tests.server; import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -public class TestAbstractInMemoryContainerListeners extends - AbstractListenerMethodsTest { +public class AbstractInMemoryContainerListenersTest extends + AbstractListenerMethodsTestBase { public void testItemSetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, ItemSetChangeEvent.class, ItemSetChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/TestAbstractPropertyListeners.java b/server/tests/src/com/vaadin/tests/server/AbstractPropertyListenersTest.java index a1d01d1930..28e6f7e0a5 100644 --- a/server/tests/src/com/vaadin/tests/server/TestAbstractPropertyListeners.java +++ b/server/tests/src/com/vaadin/tests/server/AbstractPropertyListenersTest.java @@ -6,9 +6,9 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.AbstractProperty; import com.vaadin.data.util.ObjectProperty; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -public class TestAbstractPropertyListeners extends AbstractListenerMethodsTest { +public class AbstractPropertyListenersTest extends AbstractListenerMethodsTestBase { public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(AbstractProperty.class, ValueChangeEvent.class, ValueChangeListener.class, diff --git a/server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java b/server/tests/src/com/vaadin/tests/server/AssertionsEnabledTest.java index 7e120cb9dd..087a7fb0f5 100644 --- a/server/tests/src/com/vaadin/tests/server/TestAssertionsEnabled.java +++ b/server/tests/src/com/vaadin/tests/server/AssertionsEnabledTest.java @@ -18,7 +18,7 @@ package com.vaadin.tests.server; import junit.framework.TestCase; -public class TestAssertionsEnabled extends TestCase { +public class AssertionsEnabledTest extends TestCase { public void testAssertionsEnabled() { boolean assertFailed = false; try { diff --git a/server/tests/src/com/vaadin/tests/server/TestAtmosphereVersion.java b/server/tests/src/com/vaadin/tests/server/AtmosphereVersionTest.java index 3d37022b81..90a0283cda 100644 --- a/server/tests/src/com/vaadin/tests/server/TestAtmosphereVersion.java +++ b/server/tests/src/com/vaadin/tests/server/AtmosphereVersionTest.java @@ -6,7 +6,7 @@ import org.atmosphere.util.Version; import com.vaadin.server.Constants; -public class TestAtmosphereVersion extends TestCase { +public class AtmosphereVersionTest extends TestCase { /** * Test that the atmosphere version constant matches the version on our * classpath diff --git a/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java b/server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java index 83269ede28..6e7b778f78 100644 --- a/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java +++ b/server/tests/src/com/vaadin/tests/server/ClassesSerializableTest.java @@ -19,7 +19,7 @@ import junit.framework.TestCase; import org.junit.Ignore; import org.junit.Test; -public class TestClassesSerializable extends TestCase { +public class ClassesSerializableTest extends TestCase { /** * JARs that will be scanned for classes to test, in addition to classpath @@ -63,6 +63,10 @@ public class TestClassesSerializable extends TestCase { "com\\.vaadin\\.buildhelpers.*", // "com\\.vaadin\\.util\\.ReflectTools.*", // "com\\.vaadin\\.data\\.util\\.ReflectTools.*", // + "com\\.vaadin\\.data\\.util.BeanItemContainerGenerator.*", + "com\\.vaadin\\.data\\.util\\.sqlcontainer\\.connection\\.MockInitialContextFactory", + "com\\.vaadin\\.data\\.util\\.sqlcontainer\\.DataGenerator", + "com\\.vaadin\\.data\\.util\\.sqlcontainer\\.FreeformQueryUtil", "com\\.vaadin\\.sass.*", // "com\\.vaadin\\.testbench.*", // "com\\.vaadin\\.util\\.CurrentInstance\\$1", // @@ -149,11 +153,6 @@ public class TestClassesSerializable extends TestCase { } private boolean isTestClass(Class<?> cls) { - // @Ignore is used on test util classes - if (cls.isAnnotationPresent(Ignore.class)) { - return true; - } - if (cls.getEnclosingClass() != null && isTestClass(cls.getEnclosingClass())) { return true; diff --git a/server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java b/server/tests/src/com/vaadin/tests/server/ClientMethodSerializationTest.java index d6a71028db..da6bc76a0f 100644 --- a/server/tests/src/com/vaadin/tests/server/TestClientMethodSerialization.java +++ b/server/tests/src/com/vaadin/tests/server/ClientMethodSerializationTest.java @@ -33,18 +33,18 @@ import elemental.json.Json; import elemental.json.JsonArray; import elemental.json.impl.JsonUtil; -public class TestClientMethodSerialization extends TestCase { +public class ClientMethodSerializationTest extends TestCase { private static final Method JAVASCRIPT_CALLBACK_METHOD = ReflectTools .findMethod(JavaScriptCallbackRpc.class, "call", String.class, JsonArray.class); private static final Method BASIC_PARAMS_CALL_METHOD = ReflectTools - .findMethod(TestClientMethodSerialization.class, + .findMethod(ClientMethodSerializationTest.class, "basicParamsMethodForTesting", String.class, Integer.class); private static final Method NO_PARAMS_CALL_METHOD = ReflectTools - .findMethod(TestClientMethodSerialization.class, + .findMethod(ClientMethodSerializationTest.class, "noParamsMethodForTesting"); public void basicParamsMethodForTesting(String stringParam, diff --git a/server/tests/src/com/vaadin/tests/server/CsrfTokenMissingTestServer.java b/server/tests/src/com/vaadin/tests/server/CsrfTokenMissingTest.java index b127ffe7e5..18fbf70a2a 100644 --- a/server/tests/src/com/vaadin/tests/server/CsrfTokenMissingTestServer.java +++ b/server/tests/src/com/vaadin/tests/server/CsrfTokenMissingTest.java @@ -47,7 +47,7 @@ import elemental.json.JsonException; * @since * @author Vaadin Ltd */ -public class CsrfTokenMissingTestServer { +public class CsrfTokenMissingTest { // Dummy fields just to run the test. private VaadinServlet mockServlet; @@ -185,7 +185,7 @@ public class CsrfTokenMissingTestServer { } private static Logger LOGGER = Logger - .getLogger(CsrfTokenMissingTestServer.class.getName()); + .getLogger(CsrfTokenMissingTest.class.getName()); static { LOGGER.setLevel(Level.ALL); } diff --git a/server/tests/src/com/vaadin/tests/server/TestEventRouter.java b/server/tests/src/com/vaadin/tests/server/EventRouterTest.java index a8f5039042..67f39d301d 100644 --- a/server/tests/src/com/vaadin/tests/server/TestEventRouter.java +++ b/server/tests/src/com/vaadin/tests/server/EventRouterTest.java @@ -6,7 +6,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.TextField; -public class TestEventRouter extends TestCase { +public class EventRouterTest extends TestCase { int innerListenerCalls = 0; diff --git a/server/tests/src/com/vaadin/tests/server/TestFileTypeResolver.java b/server/tests/src/com/vaadin/tests/server/FileTypeResolverTest.java index 413926c89a..3c68e86afa 100644 --- a/server/tests/src/com/vaadin/tests/server/TestFileTypeResolver.java +++ b/server/tests/src/com/vaadin/tests/server/FileTypeResolverTest.java @@ -6,7 +6,7 @@ import junit.framework.TestCase; import com.vaadin.util.FileTypeResolver; -public class TestFileTypeResolver extends TestCase { +public class FileTypeResolverTest extends TestCase { private static final String FLASH_MIME_TYPE = "application/x-shockwave-flash"; private static final String TEXT_MIME_TYPE = "text/plain"; diff --git a/server/tests/src/com/vaadin/tests/server/IndexedContainerListeners.java b/server/tests/src/com/vaadin/tests/server/IndexedContainerListenersTest.java index 8334c7f183..2e1fa83540 100644 --- a/server/tests/src/com/vaadin/tests/server/IndexedContainerListeners.java +++ b/server/tests/src/com/vaadin/tests/server/IndexedContainerListenersTest.java @@ -5,9 +5,9 @@ import com.vaadin.data.Container.PropertySetChangeListener; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -public class IndexedContainerListeners extends AbstractListenerMethodsTest { +public class IndexedContainerListenersTest extends AbstractListenerMethodsTestBase { public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(IndexedContainer.class, ValueChangeEvent.class, ValueChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/TestKeyMapper.java b/server/tests/src/com/vaadin/tests/server/KeyMapperTest.java index 1c1f9624c8..d632e65c9f 100644 --- a/server/tests/src/com/vaadin/tests/server/TestKeyMapper.java +++ b/server/tests/src/com/vaadin/tests/server/KeyMapperTest.java @@ -7,7 +7,7 @@ import junit.framework.TestCase; import com.vaadin.server.KeyMapper; -public class TestKeyMapper extends TestCase { +public class KeyMapperTest extends TestCase { public void testAdd() { KeyMapper<Object> mapper = new KeyMapper<Object>(); diff --git a/server/tests/src/com/vaadin/tests/server/TestMimeTypes.java b/server/tests/src/com/vaadin/tests/server/MimeTypesTest.java index 12e5b09632..36007fae17 100644 --- a/server/tests/src/com/vaadin/tests/server/TestMimeTypes.java +++ b/server/tests/src/com/vaadin/tests/server/MimeTypesTest.java @@ -5,7 +5,7 @@ import junit.framework.TestCase; import com.vaadin.server.ClassResource; import com.vaadin.ui.Embedded; -public class TestMimeTypes extends TestCase { +public class MimeTypesTest extends TestCase { public void testEmbeddedPDF() { Embedded e = new Embedded("A pdf", new ClassResource("file.pddf")); diff --git a/server/tests/src/com/vaadin/tests/server/TestPropertyFormatter.java b/server/tests/src/com/vaadin/tests/server/PropertyFormatterTest.java index b47a2953ce..6563556a4e 100644 --- a/server/tests/src/com/vaadin/tests/server/TestPropertyFormatter.java +++ b/server/tests/src/com/vaadin/tests/server/PropertyFormatterTest.java @@ -10,7 +10,7 @@ import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertyFormatter; @SuppressWarnings("unchecked") -public class TestPropertyFormatter extends TestCase { +public class PropertyFormatterTest extends TestCase { class TestFormatter extends PropertyFormatter { diff --git a/server/tests/src/com/vaadin/tests/server/PropertysetItemListeners.java b/server/tests/src/com/vaadin/tests/server/PropertysetItemListenersTest.java index d493f22779..7edaa2826a 100644 --- a/server/tests/src/com/vaadin/tests/server/PropertysetItemListeners.java +++ b/server/tests/src/com/vaadin/tests/server/PropertysetItemListenersTest.java @@ -3,9 +3,9 @@ package com.vaadin.tests.server; import com.vaadin.data.Item.PropertySetChangeEvent; import com.vaadin.data.Item.PropertySetChangeListener; import com.vaadin.data.util.PropertysetItem; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -public class PropertysetItemListeners extends AbstractListenerMethodsTest { +public class PropertysetItemListenersTest extends AbstractListenerMethodsTestBase { public void testPropertySetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(PropertysetItem.class, PropertySetChangeEvent.class, PropertySetChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/TestSerialization.java b/server/tests/src/com/vaadin/tests/server/SerializationTest.java index 3c18035dab..4de30e579e 100644 --- a/server/tests/src/com/vaadin/tests/server/TestSerialization.java +++ b/server/tests/src/com/vaadin/tests/server/SerializationTest.java @@ -17,7 +17,7 @@ import com.vaadin.data.validator.RegexpValidator; import com.vaadin.server.VaadinSession; import com.vaadin.ui.Form; -public class TestSerialization extends TestCase { +public class SerializationTest extends TestCase { public void testValidators() throws Exception { RegexpValidator validator = new RegexpValidator(".*", "Error"); diff --git a/server/tests/src/com/vaadin/tests/server/TestSimpleMultiPartInputStream.java b/server/tests/src/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java index 6907594b5e..04e621d5d2 100644 --- a/server/tests/src/com/vaadin/tests/server/TestSimpleMultiPartInputStream.java +++ b/server/tests/src/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java @@ -9,7 +9,7 @@ import junit.framework.TestCase; import com.vaadin.server.communication.FileUploadHandler.SimpleMultiPartInputStream; -public class TestSimpleMultiPartInputStream extends TestCase { +public class SimpleMultiPartInputStreamTest extends TestCase { /** * Check that the output for a given stream until boundary is as expected. diff --git a/server/tests/src/com/vaadin/tests/server/TestStreamResource.java b/server/tests/src/com/vaadin/tests/server/StreamResourceTest.java index 0fdcc9e39c..4971f556db 100644 --- a/server/tests/src/com/vaadin/tests/server/TestStreamResource.java +++ b/server/tests/src/com/vaadin/tests/server/StreamResourceTest.java @@ -26,7 +26,7 @@ import com.vaadin.server.StreamResource.StreamSource; * * @author Vaadin Ltd */ -public class TestStreamResource { +public class StreamResourceTest { @Test public void testEqualsWithNullFields() { diff --git a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java b/server/tests/src/com/vaadin/tests/server/StreamVariableMappingTest.java index b2faca1ed6..e15e722199 100644 --- a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java +++ b/server/tests/src/com/vaadin/tests/server/StreamVariableMappingTest.java @@ -17,7 +17,7 @@ import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.UI; import com.vaadin.ui.Upload; -public class TestStreamVariableMapping extends TestCase { +public class StreamVariableMappingTest extends TestCase { private static final String variableName = "myName"; private Upload owner; diff --git a/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java b/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListenersTest.java index bd7053af40..68964dbfd1 100644 --- a/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java +++ b/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListenersTest.java @@ -25,7 +25,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.UI; -public class AttachDetachListeners { +public class AttachDetachListenersTest { private IMocksControl control; diff --git a/server/tests/src/com/vaadin/tests/server/component/AbstractListenerMethodsTest.java b/server/tests/src/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index e189ffc77d..ec3754d037 100644 --- a/server/tests/src/com/vaadin/tests/server/component/AbstractListenerMethodsTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -14,7 +14,7 @@ import org.junit.Assert; import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.Component; -public abstract class AbstractListenerMethodsTest extends TestCase { +public abstract class AbstractListenerMethodsTestBase extends TestCase { public static void main(String[] args) { findAllListenerMethods(); @@ -48,13 +48,13 @@ public abstract class AbstractListenerMethodsTest extends TestCase { System.out.println("package " + packageName + ";"); System.out.println("import " - + AbstractListenerMethodsTest.class.getName() + + AbstractListenerMethodsTestBase.class.getName() + ";"); System.out.println("import " + c.getName() + ";"); System.out.println("public class " + c.getSimpleName() + "Listeners extends " - + AbstractListenerMethodsTest.class + + AbstractListenerMethodsTestBase.class .getSimpleName() + " {"); } diff --git a/server/tests/src/com/vaadin/tests/server/component/TestReadEmptyDesign.java b/server/tests/src/com/vaadin/tests/server/component/ReadEmptyDesignTest.java index ecd303b678..5cf3b9700e 100644 --- a/server/tests/src/com/vaadin/tests/server/component/TestReadEmptyDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/ReadEmptyDesignTest.java @@ -34,7 +34,7 @@ import com.vaadin.ui.declarative.DesignException; * Test cases for checking that reading a design with no elements in the html * body produces null as the root component. */ -public class TestReadEmptyDesign extends TestCase { +public class ReadEmptyDesignTest extends TestCase { InputStream is; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirty.java b/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java index 280d638707..da4d8a92d4 100644 --- a/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirty.java +++ b/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java @@ -17,7 +17,7 @@ import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.Label; import com.vaadin.ui.UI; -public class StateGetDoesNotMarkDirty extends TestCase { +public class StateGetDoesNotMarkDirtyTest extends TestCase { private Set<String> excludedMethods = new HashSet<String>(); diff --git a/server/tests/src/com/vaadin/tests/server/component/TestWriteEmptyDesign.java b/server/tests/src/com/vaadin/tests/server/component/WriteEmptyDesignTest.java index b50915f1fd..a535de2b24 100644 --- a/server/tests/src/com/vaadin/tests/server/component/TestWriteEmptyDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/WriteEmptyDesignTest.java @@ -33,7 +33,7 @@ import com.vaadin.ui.declarative.DesignContext; * Test cases for checking that writing a component hierarchy with null root * produces an html document that has no elements in the html body. */ -public class TestWriteEmptyDesign extends TestCase { +public class WriteEmptyDesignTest extends TestCase { public void testWriteComponent() throws IOException { OutputStream os = new ByteArrayOutputStream(); diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListenersTest.java index 7d6db42d1a..062a89ad62 100644 --- a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListenersTest.java @@ -2,10 +2,10 @@ package com.vaadin.tests.server.component.absolutelayout; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.AbsoluteLayout; -public class AbsoluteLayoutListeners extends AbstractListenerMethodsTest { +public class AbsoluteLayoutListenersTest extends AbstractListenerMethodsTestBase { public void testLayoutClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(AbsoluteLayout.class, LayoutClickEvent.class, LayoutClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java index d76dcffa2f..eac7ff4d8a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java +++ b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/ComponentPositionTest.java @@ -7,7 +7,7 @@ import com.vaadin.server.Sizeable.Unit; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; -public class ComponentPosition extends TestCase { +public class ComponentPositionTest extends TestCase { private static final String CSS = "top:7.0px;right:7.0%;bottom:7.0pc;left:7.0em;z-index:7;"; private static final String PARTIAL_CSS = "top:7.0px;left:7.0em;"; diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/ReadDesignTest.java index f8af0a992e..f17e1ada44 100644 --- a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/ReadDesignTest.java @@ -35,7 +35,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private AbsoluteLayout root; diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/WriteDesignTest.java index 5f42b1fa81..39a2207819 100644 --- a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/WriteDesignTest.java @@ -31,7 +31,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { public void testSynchronizeEmptyLayout() { AbsoluteLayout layout = createTestLayout(); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestAbstractComponentStyleNames.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java index 1903e66f92..18eb79aadc 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestAbstractComponentStyleNames.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentStyleNamesTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.ui.AbstractComponent; -public class TestAbstractComponentStyleNames extends TestCase { +public class AbstractComponentStyleNamesTest extends TestCase { public void testSetMultiple() { AbstractComponent component = getComponent(); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/ReadDesignTest.java index 43a050ba80..79979e03d9 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/ReadDesignTest.java @@ -36,7 +36,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/WriteDesignTest.java index 7f207a25ae..68b7a46cde 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/WriteDesignTest.java @@ -42,7 +42,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java index 9763354b57..3a2150b700 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/AbstractComponentContainerListenersTest.java @@ -1,6 +1,6 @@ package com.vaadin.tests.server.component.abstractcomponentcontainer; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.HasComponents.ComponentAttachEvent; import com.vaadin.ui.HasComponents.ComponentAttachListener; import com.vaadin.ui.HasComponents.ComponentDetachEvent; @@ -8,8 +8,8 @@ import com.vaadin.ui.HasComponents.ComponentDetachListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.VerticalLayout; -public class TestAbstractComponentContainerListeners extends - AbstractListenerMethodsTest { +public class AbstractComponentContainerListenersTest extends + AbstractListenerMethodsTestBase { public void testComponentDetachListenerAddGetRemove() throws Exception { testListenerAddGetRemove(HorizontalLayout.class, ComponentDetachEvent.class, ComponentDetachListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/AddParentAsChild.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/AddParentAsChildTest.java index 67e6d09adc..176d178112 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/AddParentAsChild.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponentcontainer/AddParentAsChildTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.HasComponents; * * @author Vaadin Ltd */ -public class AddParentAsChild { +public class AddParentAsChildTest { @Test(expected = IllegalArgumentException.class) public void testAddComponent() { diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidators.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java index 764446f7aa..61aafe317d 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidators.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValidatorsTest.java @@ -8,7 +8,7 @@ import com.vaadin.data.Validator; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Field; -public class AbsFieldValidators extends TestCase { +public class AbsFieldValidatorsTest extends TestCase { Field<Object> field = new AbstractField<Object>() { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java index 887f1b8ff3..02aa6afe07 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java @@ -14,7 +14,7 @@ import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.Sex; import com.vaadin.ui.TextField; -public class AbsFieldValueConversionError extends TestCase { +public class AbsFieldValueConversionErrorTest extends TestCase { Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com", 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town", diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversions.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java index beb32e7dba..94ff10926f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversions.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java @@ -21,7 +21,7 @@ import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; -public class AbsFieldValueConversions extends TestCase { +public class AbsFieldValueConversionsTest extends TestCase { Person paulaBean = new Person("Paula", "Brilliant", "paula@brilliant.com", 34, Sex.FEMALE, new Address("Paula street 1", 12345, "P-town", diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java index 9937bf92d5..def3ceb643 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java @@ -4,10 +4,10 @@ import com.vaadin.data.Property.ReadOnlyStatusChangeEvent; import com.vaadin.data.Property.ReadOnlyStatusChangeListener; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.CheckBox; -public class TestAbstractFieldListeners extends AbstractListenerMethodsTest { +public class AbstractFieldListenersTest extends AbstractListenerMethodsTestBase { public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(CheckBox.class, ReadOnlyStatusChangeEvent.class, diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java index 99397e9e8f..68e198c37a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactoryTest.java @@ -14,7 +14,7 @@ import com.vaadin.tests.data.bean.Sex; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.TextField; -public class DefaultConverterFactory extends TestCase { +public class DefaultConverterFactoryTest extends TestCase { public static class FloatBean { float f1; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/ReadDesignTest.java index dd0e629199..4fa3400af5 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/ReadDesignTest.java @@ -31,7 +31,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetachTest.java index f391d15fb3..f547f2c66b 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetachTest.java @@ -13,7 +13,7 @@ import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.AbstractField; import com.vaadin.ui.UI; -public class RemoveListenersOnDetach { +public class RemoveListenersOnDetachTest { int numValueChanges = 0; int numReadOnlyChanges = 0; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/WriteDesignTest.java index 969713abe6..37ff8cf3aa 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/WriteDesignTest.java @@ -31,7 +31,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutListenersTest.java index a0b34aca78..e7393e5f7d 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutListenersTest.java @@ -2,11 +2,11 @@ package com.vaadin.tests.server.component.abstractorderedlayout; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.VerticalLayout; -public class TestAbstractOrderedLayoutListeners extends - AbstractListenerMethodsTest { +public class AbstractOrderedLayoutListenersTest extends + AbstractListenerMethodsTestBase { public void testLayoutClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(VerticalLayout.class, LayoutClickEvent.class, LayoutClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplace.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplaceTest.java index fd951f1692..9d1972c232 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplace.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplaceTest.java @@ -29,7 +29,7 @@ import com.vaadin.ui.Alignment; * @since 7.2 * @author Vaadin Ltd */ -public class LayoutSettingsOnReplace { +public class LayoutSettingsOnReplaceTest { @Test public void testExpandRatio() { diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/ReadDesignTest.java index 874fbd83b2..b0a2e678c2 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/ReadDesignTest.java @@ -32,7 +32,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { public void testChildCount() { VerticalLayout root = createLayout(0f, false); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/WriteDesignTest.java index 302cf985bd..96697af3cd 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/WriteDesignTest.java @@ -32,7 +32,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { public void testSynchronizeMargin() { VerticalLayout layout = new VerticalLayout(); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java index 75c19b0517..8ec0414e03 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java @@ -4,10 +4,10 @@ import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.Container.ItemSetChangeListener; import com.vaadin.data.Container.PropertySetChangeEvent; import com.vaadin.data.Container.PropertySetChangeListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.ComboBox; -public class TestAbstractSelectListeners extends AbstractListenerMethodsTest { +public class AbstractSelectListenersTest extends AbstractListenerMethodsTestBase { public void testItemSetChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(ComboBox.class, ItemSetChangeEvent.class, ItemSetChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java b/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java index fd4a1df766..e277d4e075 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/TestRemoveFromParentLocking.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java @@ -26,7 +26,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -public class TestRemoveFromParentLocking { +public class RemoveFromParentLockingTest { private static VerticalLayout createTestComponent() { VaadinSession session = new VaadinSession(null) { diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/SetParentAsContent.java b/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/SetParentAsContentTest.java index dae0e57d02..b84794d58a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/SetParentAsContent.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/SetParentAsContentTest.java @@ -29,7 +29,7 @@ import com.vaadin.ui.HasComponents; * * @author Vaadin Ltd */ -public class SetParentAsContent { +public class SetParentAsContentTest { @Test(expected = IllegalArgumentException.class) public void testSetContent() { diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelListenersTest.java index 2b6cdaa6cc..5dd2f406bc 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelListenersTest.java @@ -1,12 +1,12 @@ package com.vaadin.tests.server.component.abstractsplitpanel; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent; import com.vaadin.ui.AbstractSplitPanel.SplitterClickListener; import com.vaadin.ui.HorizontalSplitPanel; -public class TestAbstractSplitPanelListeners extends - AbstractListenerMethodsTest { +public class AbstractSplitPanelListenersTest extends + AbstractListenerMethodsTestBase { public void testSplitterClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(HorizontalSplitPanel.class, SplitterClickEvent.class, SplitterClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/ReadDesignTest.java index db30f05c5f..f3a7e32e96 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/ReadDesignTest.java @@ -38,7 +38,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/WriteDesignTest.java index 649498c20b..a75fe911f8 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/WriteDesignTest.java @@ -32,7 +32,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java index 9868d6ebfd..1b7f4fdce1 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldListenersTest.java @@ -6,10 +6,10 @@ import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.TextChangeEvent; import com.vaadin.event.FieldEvents.TextChangeListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.TextField; -public class TestAbstractTextFieldListeners extends AbstractListenerMethodsTest { +public class AbstractTextFieldListenersTest extends AbstractListenerMethodsTestBase { public void testTextChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(TextField.class, TextChangeEvent.class, TextChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/ReadDesignTest.java index 3b4b6f1f03..2645ce4255 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/ReadDesignTest.java @@ -29,7 +29,7 @@ import com.vaadin.ui.declarative.DesignContext; /** * Test case for reading the attributes of the AbstractTextField from design */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/WriteDesignTest.java index be5c384d3b..9b1129ce14 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/WriteDesignTest.java @@ -31,7 +31,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java b/server/tests/src/com/vaadin/tests/server/component/button/ButtonClickTest.java index 3d5fe77f8e..6283ccf6af 100644 --- a/server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java +++ b/server/tests/src/com/vaadin/tests/server/component/button/ButtonClickTest.java @@ -13,7 +13,7 @@ import com.vaadin.ui.UI; /** * Tests the public click() method. */ -public class ButtonClick { +public class ButtonClickTest { private boolean clicked = false; @Test diff --git a/server/tests/src/com/vaadin/tests/server/component/button/ButtonListeners.java b/server/tests/src/com/vaadin/tests/server/component/button/ButtonListenersTest.java index dc37312eea..4478048b12 100644 --- a/server/tests/src/com/vaadin/tests/server/component/button/ButtonListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/button/ButtonListenersTest.java @@ -4,12 +4,12 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -public class ButtonListeners extends AbstractListenerMethodsTest { +public class ButtonListenersTest extends AbstractListenerMethodsTestBase { public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Button.class, FocusEvent.class, FocusListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/button/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/button/ReadDesignTest.java index e194232742..0e503b54b8 100644 --- a/server/tests/src/com/vaadin/tests/server/component/button/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/button/ReadDesignTest.java @@ -37,7 +37,7 @@ import com.vaadin.ui.declarative.DesignContext; * design. * */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/button/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/button/WriteDesignTest.java index dff80769f4..6d553da835 100644 --- a/server/tests/src/com/vaadin/tests/server/component/button/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/button/WriteDesignTest.java @@ -32,7 +32,7 @@ import com.vaadin.ui.declarative.DesignContext; * Tests generating html tree nodes corresponding to the contents of a Button * and a NativeButton. */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java index 773631642a..95b4aecdb3 100644 --- a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java +++ b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasicsTest.java @@ -41,7 +41,7 @@ import com.vaadin.ui.components.calendar.event.CalendarEventProvider; /** * Basic API tests for the calendar */ -public class CalendarBasics { +public class CalendarBasicsTest { @Test public void testEmptyConstructorInitialization() { diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java b/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java index 030abc0eb2..8a066497cd 100644 --- a/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java +++ b/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSourceTest.java @@ -33,7 +33,7 @@ import com.vaadin.ui.components.calendar.ContainerEventProvider; import com.vaadin.ui.components.calendar.event.BasicEvent; import com.vaadin.ui.components.calendar.event.CalendarEvent; -public class ContainerDataSource extends TestCase { +public class ContainerDataSourceTest extends TestCase { private Calendar calendar; diff --git a/server/tests/src/com/vaadin/tests/server/component/checkbox/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/checkbox/ReadDesignTest.java index c58b3b6bdd..9456fa4b31 100644 --- a/server/tests/src/com/vaadin/tests/server/component/checkbox/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/checkbox/ReadDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * Test cases for reading the contents of a Checkbox from a design. * */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/checkbox/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/checkbox/WriteDesignTest.java index d187371db6..4c41f67ac5 100644 --- a/server/tests/src/com/vaadin/tests/server/component/checkbox/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/checkbox/WriteDesignTest.java @@ -26,7 +26,7 @@ import com.vaadin.ui.declarative.DesignContext; /** * Tests generating html tree nodes corresponding to the contents of a Checkbox */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversions.java b/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversionsTest.java index 46d72a6ae6..8c05e58b9c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversions.java +++ b/server/tests/src/com/vaadin/tests/server/component/colorpicker/ColorConversionsTest.java @@ -21,7 +21,7 @@ import org.junit.Test; import com.vaadin.shared.ui.colorpicker.Color; -public class ColorConversions { +public class ColorConversionsTest { @Test public void convertHSL2RGB() { diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListenersTest.java index ee75d6ed59..e000df593b 100644 --- a/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutListenersTest.java @@ -2,10 +2,10 @@ package com.vaadin.tests.server.component.csslayout; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.CssLayout; -public class CssLayoutListeners extends AbstractListenerMethodsTest { +public class CssLayoutListenersTest extends AbstractListenerMethodsTestBase { public void testLayoutClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(CssLayout.class, LayoutClickEvent.class, LayoutClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/ReadDesignTest.java index bac3dc70eb..5c3517fa56 100644 --- a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/csslayout/ReadDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { public void testChildCount() { CssLayout root = createLayout(); diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/WriteDesignTest.java index d660eb77ec..0fdb1c8335 100644 --- a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/csslayout/WriteDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { public void testSynchronizeEmptyLayout() { CssLayout layout = new CssLayout(); diff --git a/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldListeners.java b/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java index 0f4aee35c7..6d774366a9 100644 --- a/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java @@ -4,10 +4,10 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.DateField; -public class DateFieldListeners extends AbstractListenerMethodsTest { +public class DateFieldListenersTest extends AbstractListenerMethodsTestBase { public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(DateField.class, FocusEvent.class, FocusListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java b/server/tests/src/com/vaadin/tests/server/component/embedded/EmbeddedListenersTest.java index 7512f0f499..b41d5e9e13 100644 --- a/server/tests/src/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/embedded/EmbeddedListenersTest.java @@ -2,10 +2,10 @@ package com.vaadin.tests.server.component.embedded; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Embedded; -public class EmbeddedListeners extends AbstractListenerMethodsTest { +public class EmbeddedListenersTest extends AbstractListenerMethodsTestBase { public void testClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Embedded.class, ClickEvent.class, ClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBindingTest.java index ea34d8b04e..cb29a84aa8 100644 --- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java +++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBindingTest.java @@ -10,7 +10,7 @@ import com.vaadin.data.util.PropertysetItem; import com.vaadin.ui.FormLayout; import com.vaadin.ui.TextField; -public class CaseInsensitiveBinding { +public class CaseInsensitiveBindingTest { @Test public void caseInsensitivityAndUnderscoreRemoval() { diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldNamedDescription.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldNamedDescriptionTest.java index 033f1458e8..029dcc66a3 100644 --- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldNamedDescription.java +++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldNamedDescriptionTest.java @@ -11,7 +11,7 @@ import com.vaadin.data.util.PropertysetItem; import com.vaadin.ui.FormLayout; import com.vaadin.ui.TextField; -public class FieldNamedDescription { +public class FieldNamedDescriptionTest { @Test public void bindReadOnlyPropertyToFieldGroup() { diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java index 07a138c6ca..7f09677b50 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java @@ -99,8 +99,8 @@ public class GridSelection { } @Test - public void defaultSelectionModeIsMulti() { - assertTrue(grid.getSelectionModel() instanceof SelectionModel.Multi); + public void defaultSelectionModeIsSingle() { + assertTrue(grid.getSelectionModel() instanceof SelectionModel.Single); } @Test(expected = IllegalStateException.class) diff --git a/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignment.java b/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignmentTest.java index 244f1f9e45..9b6368474f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignment.java +++ b/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignmentTest.java @@ -9,7 +9,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; -public class DefaultAlignment { +public class DefaultAlignmentTest { private GridLayout gridLayout; diff --git a/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java b/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutListenersTest.java index ce3a9faa65..ed18a24608 100644 --- a/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/gridlayout/GridLayoutListenersTest.java @@ -2,10 +2,10 @@ package com.vaadin.tests.server.component.gridlayout; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.GridLayout; -public class GridLayoutListeners extends AbstractListenerMethodsTest { +public class GridLayoutListenersTest extends AbstractListenerMethodsTestBase { public void testLayoutClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(GridLayout.class, LayoutClickEvent.class, LayoutClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java b/server/tests/src/com/vaadin/tests/server/component/label/LabelConvertersTest.java index e6cecee1bf..7e65e6a044 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/LabelConvertersTest.java @@ -24,7 +24,7 @@ import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.Label; -public class LabelConverters extends TestCase { +public class LabelConvertersTest extends TestCase { public void testLabelSetDataSourceLaterOn() { Person p = Person.createTestPerson1(); diff --git a/server/tests/src/com/vaadin/tests/server/component/label/LabelListeners.java b/server/tests/src/com/vaadin/tests/server/component/label/LabelListenersTest.java index 9bb4c53ba2..4287d58d9c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/LabelListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/LabelListenersTest.java @@ -10,11 +10,11 @@ import org.easymock.EasyMock; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Label; import com.vaadin.ui.Label.ValueChangeEvent; -public class LabelListeners extends AbstractListenerMethodsTest { +public class LabelListenersTest extends AbstractListenerMethodsTestBase { public void testValueChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Label.class, ValueChangeEvent.class, ValueChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/label/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/label/ReadDesignTest.java index 3e577b5578..9ccaf43398 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/ReadDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * Test case for reading the contents of a Label from a design. * */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/label/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/label/WriteDesignTest.java index 3368a7d22e..3d13767d35 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/WriteDesignTest.java @@ -29,7 +29,7 @@ import com.vaadin.ui.declarative.DesignContext; /** * Tests generating an html tree node corresponding to a Label. */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; diff --git a/server/tests/src/com/vaadin/tests/server/component/loginform/LoginFormListeners.java b/server/tests/src/com/vaadin/tests/server/component/loginform/LoginFormListenersTest.java index fd3e02994c..1c06d2652a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/loginform/LoginFormListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/loginform/LoginFormListenersTest.java @@ -1,11 +1,11 @@ package com.vaadin.tests.server.component.loginform; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.LoginForm; import com.vaadin.ui.LoginForm.LoginEvent; import com.vaadin.ui.LoginForm.LoginListener; -public class LoginFormListeners extends AbstractListenerMethodsTest { +public class LoginFormListenersTest extends AbstractListenerMethodsTestBase { public void testLoginListenerAddGetRemove() throws Exception { testListenerAddGetRemove(LoginForm.class, LoginEvent.class, LoginListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/menubar/MenuBarIds.java b/server/tests/src/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java index f304315ebc..68007bd870 100644 --- a/server/tests/src/com/vaadin/tests/server/component/menubar/MenuBarIds.java +++ b/server/tests/src/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java @@ -9,7 +9,7 @@ import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.Command; import com.vaadin.ui.MenuBar.MenuItem; -public class MenuBarIds extends TestCase implements Command { +public class MenuBarIdsTest extends TestCase implements Command { private MenuItem lastSelectedItem; private MenuItem menuFile; diff --git a/server/tests/src/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java b/server/tests/src/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java index 7eb35c3882..c2dc175c75 100644 --- a/server/tests/src/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java @@ -4,10 +4,10 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.OptionGroup; -public class OptionGroupListeners extends AbstractListenerMethodsTest { +public class OptionGroupListenersTest extends AbstractListenerMethodsTestBase { public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(OptionGroup.class, FocusEvent.class, FocusListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignment.java b/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignmentTest.java index 9497a13c0a..7560c21adb 100644 --- a/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignment.java +++ b/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignmentTest.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; -public class DefaultAlignment { +public class DefaultAlignmentTest { private VerticalLayout verticalLayout; private HorizontalLayout horizontalLayout; diff --git a/server/tests/src/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java b/server/tests/src/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java index 6a9d55d7e4..3b3dfb94d8 100644 --- a/server/tests/src/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java +++ b/server/tests/src/com/vaadin/tests/server/component/orderedlayout/OrderedLayoutTest.java @@ -10,7 +10,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; -public class TestOrderedLayout extends TestCase { +public class OrderedLayoutTest extends TestCase { public void testVLIteration() { testIndexing(new VerticalLayout(), 10); diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/PanelListeners.java b/server/tests/src/com/vaadin/tests/server/component/panel/PanelListenersTest.java index 275e90f5d1..929553a682 100644 --- a/server/tests/src/com/vaadin/tests/server/component/panel/PanelListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/panel/PanelListenersTest.java @@ -2,10 +2,10 @@ package com.vaadin.tests.server.component.panel; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Panel; -public class PanelListeners extends AbstractListenerMethodsTest { +public class PanelListenersTest extends AbstractListenerMethodsTestBase { public void testClickListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Panel.class, ClickEvent.class, ClickListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/panel/ReadDesignTest.java index 3eb52309a8..41b19c9778 100644 --- a/server/tests/src/com/vaadin/tests/server/component/panel/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/panel/ReadDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignException; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/panel/WriteDesignTest.java index f81193d511..8b8c6e5e13 100644 --- a/server/tests/src/com/vaadin/tests/server/component/panel/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/panel/WriteDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { Element panelElement; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewListeners.java b/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewListenersTest.java index 12a5a0f520..06782818a8 100644 --- a/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/popupview/PopupViewListenersTest.java @@ -1,12 +1,12 @@ package com.vaadin.tests.server.component.popupview; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Label; import com.vaadin.ui.PopupView; import com.vaadin.ui.PopupView.PopupVisibilityEvent; import com.vaadin.ui.PopupView.PopupVisibilityListener; -public class PopupViewListeners extends AbstractListenerMethodsTest { +public class PopupViewListenersTest extends AbstractListenerMethodsTestBase { public void testPopupVisibilityListenerAddGetRemove() throws Exception { testListenerAddGetRemove(PopupView.class, PopupVisibilityEvent.class, PopupVisibilityListener.class, new PopupView("", new Label())); diff --git a/server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java b/server/tests/src/com/vaadin/tests/server/component/select/SelectListenersTest.java index 2a1cc0deb0..9a2a5f1f50 100644 --- a/server/tests/src/com/vaadin/tests/server/component/select/SelectListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/select/SelectListenersTest.java @@ -4,10 +4,10 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Select; -public class SelectListeners extends AbstractListenerMethodsTest { +public class SelectListenersTest extends AbstractListenerMethodsTestBase { public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Select.class, FocusEvent.class, FocusListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/table/CacheUpdateExceptionCauses.java b/server/tests/src/com/vaadin/tests/server/component/table/CacheUpdateExceptionCausesTest.java index beb5da0885..03f50c6b5f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/CacheUpdateExceptionCauses.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/CacheUpdateExceptionCausesTest.java @@ -22,7 +22,7 @@ import org.junit.Test; import com.vaadin.ui.Table; import com.vaadin.ui.Table.CacheUpdateException; -public class CacheUpdateExceptionCauses { +public class CacheUpdateExceptionCausesTest { @Test public void testSingleCauseException() { Table table = new Table(); diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TestFooter.java b/server/tests/src/com/vaadin/tests/server/component/table/FooterTest.java index 647d13855b..f9d373e864 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TestFooter.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/FooterTest.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Table; * Test case for testing the footer API * */ -public class TestFooter extends TestCase { +public class FooterTest extends TestCase { /** * Tests if setting the footer visibility works properly diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TestMultipleSelection.java b/server/tests/src/com/vaadin/tests/server/component/table/MultipleSelectionTest.java index ff80cdb3c3..ceb4c865d2 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TestMultipleSelection.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/MultipleSelectionTest.java @@ -10,7 +10,7 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.shared.ui.MultiSelectMode; import com.vaadin.ui.Table; -public class TestMultipleSelection extends TestCase { +public class MultipleSelectionTest extends TestCase { /** * Tests weather the multiple select mode is set when using Table.set diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignments.java b/server/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignmentsTest.java index 299f9c79d4..5e33ff2f4a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignments.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignmentsTest.java @@ -7,12 +7,12 @@ import org.junit.Test; import com.vaadin.ui.Table; import com.vaadin.ui.Table.Align; -public class TableColumnAlignments { +public class TableColumnAlignmentsTest { @Test public void defaultColumnAlignments() { for (int properties = 0; properties < 10; properties++) { - Table t = TableGenerator.createTableWithDefaultContainer( + Table t = TableGeneratorTest.createTableWithDefaultContainer( properties, 10); Object[] expected = new Object[properties]; for (int i = 0; i < properties; i++) { @@ -26,7 +26,7 @@ public class TableColumnAlignments { @Test public void explicitColumnAlignments() { int properties = 5; - Table t = TableGenerator + Table t = TableGeneratorTest .createTableWithDefaultContainer(properties, 10); Align[] explicitAlignments = new Align[] { Align.CENTER, Align.LEFT, Align.RIGHT, Align.RIGHT, Align.LEFT }; @@ -39,7 +39,7 @@ public class TableColumnAlignments { @Test public void invalidColumnAlignmentStrings() { - Table t = TableGenerator.createTableWithDefaultContainer(3, 7); + Table t = TableGeneratorTest.createTableWithDefaultContainer(3, 7); Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT, Align.LEFT }; try { @@ -57,7 +57,7 @@ public class TableColumnAlignments { @Test public void columnAlignmentForPropertyNotInContainer() { - Table t = TableGenerator.createTableWithDefaultContainer(3, 7); + Table t = TableGeneratorTest.createTableWithDefaultContainer(3, 7); Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT, Align.LEFT }; try { @@ -81,7 +81,7 @@ public class TableColumnAlignments { @Test public void invalidColumnAlignmentsLength() { - Table t = TableGenerator.createTableWithDefaultContainer(7, 7); + Table t = TableGeneratorTest.createTableWithDefaultContainer(7, 7); Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT }; @@ -122,7 +122,7 @@ public class TableColumnAlignments { @Test public void explicitColumnAlignmentOneByOne() { int properties = 5; - Table t = TableGenerator + Table t = TableGeneratorTest .createTableWithDefaultContainer(properties, 10); Align[] explicitAlignments = new Align[] { Align.CENTER, Align.LEFT, Align.RIGHT, Align.RIGHT, Align.LEFT }; diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableGenerator.java b/server/tests/src/com/vaadin/tests/server/component/table/TableGeneratorTest.java index 0e63049944..f3c2589f4a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TableGenerator.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableGeneratorTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import com.vaadin.data.Item; import com.vaadin.ui.Table; -public class TableGenerator { +public class TableGeneratorTest { public static Table createTableWithDefaultContainer(int properties, int items) { Table t = new Table(); diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java b/server/tests/src/com/vaadin/tests/server/component/table/TableListenersTest.java index fbe5bb3146..fce514954a 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TableListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableListenersTest.java @@ -2,7 +2,7 @@ package com.vaadin.tests.server.component.table; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Table; import com.vaadin.ui.Table.ColumnReorderEvent; import com.vaadin.ui.Table.ColumnReorderListener; @@ -13,7 +13,7 @@ import com.vaadin.ui.Table.FooterClickListener; import com.vaadin.ui.Table.HeaderClickEvent; import com.vaadin.ui.Table.HeaderClickListener; -public class TableListeners extends AbstractListenerMethodsTest { +public class TableListenersTest extends AbstractListenerMethodsTestBase { public void testColumnResizeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Table.class, ColumnResizeEvent.class, ColumnResizeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverter.java b/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java index 418ca333bc..7fd5bc67f6 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverter.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/TablePropertyValueConverterTest.java @@ -39,7 +39,7 @@ import com.vaadin.ui.Table; * @since * @author Vaadin Ltd */ -public class TablePropertyValueConverter extends TestCase { +public class TablePropertyValueConverterTest extends TestCase { protected TestableTable table; protected Collection<?> initialProperties; diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableSerialization.java b/server/tests/src/com/vaadin/tests/server/component/table/TableSerializationTest.java index ee6349093c..3f3c52d6c0 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TableSerialization.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableSerializationTest.java @@ -6,7 +6,7 @@ import org.apache.commons.lang.SerializationUtils; import com.vaadin.ui.Table; -public class TableSerialization extends TestCase { +public class TableSerializationTest extends TestCase { public void testSerialization() { Table t = new Table(); diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumns.java b/server/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumnsTest.java index ee3eefba05..e4f229590f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumns.java +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumnsTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import com.vaadin.ui.Table; -public class TableVisibleColumns { +public class TableVisibleColumnsTest { String[] defaultColumns3 = new String[] { "Property 0", "Property 1", "Property 2" }; @@ -14,7 +14,7 @@ public class TableVisibleColumns { @Test public void defaultVisibleColumns() { for (int properties = 0; properties < 10; properties++) { - Table t = TableGenerator.createTableWithDefaultContainer( + Table t = TableGeneratorTest.createTableWithDefaultContainer( properties, 10); Object[] expected = new Object[properties]; for (int i = 0; i < properties; i++) { @@ -27,7 +27,7 @@ public class TableVisibleColumns { @Test public void explicitVisibleColumns() { - Table t = TableGenerator.createTableWithDefaultContainer(5, 10); + Table t = TableGeneratorTest.createTableWithDefaultContainer(5, 10); Object[] newVisibleColumns = new Object[] { "Property 1", "Property 2" }; t.setVisibleColumns(newVisibleColumns); assertArrayEquals("Explicit visible columns, 5 properties", @@ -37,7 +37,7 @@ public class TableVisibleColumns { @Test public void invalidVisibleColumnIds() { - Table t = TableGenerator.createTableWithDefaultContainer(3, 10); + Table t = TableGeneratorTest.createTableWithDefaultContainer(3, 10); try { t.setVisibleColumns(new Object[] { "a", "Property 2", "Property 3" }); @@ -50,7 +50,7 @@ public class TableVisibleColumns { @Test public void duplicateVisibleColumnIds() { - Table t = TableGenerator.createTableWithDefaultContainer(3, 10); + Table t = TableGeneratorTest.createTableWithDefaultContainer(3, 10); try { t.setVisibleColumns(new Object[] { "Property 0", "Property 1", "Property 2", "Property 1" }); @@ -62,7 +62,7 @@ public class TableVisibleColumns { @Test public void noVisibleColumns() { - Table t = TableGenerator.createTableWithDefaultContainer(3, 10); + Table t = TableGeneratorTest.createTableWithDefaultContainer(3, 10); t.setVisibleColumns(new Object[] {}); assertArrayEquals(new Object[] {}, t.getVisibleColumns()); diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/ReadDesignTest.java index f7c4f16cdc..67533c8b11 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/tabsheet/ReadDesignTest.java @@ -33,7 +33,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private TabSheet sheet; diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetListenersTest.java index 5c01a1c99f..b1acf05d63 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetListenersTest.java @@ -1,11 +1,11 @@ package com.vaadin.tests.server.component.tabsheet; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; -public class TabSheetListeners extends AbstractListenerMethodsTest { +public class TabSheetListenersTest extends AbstractListenerMethodsTestBase { public void testSelectedTabChangeListenerAddGetRemove() throws Exception { testListenerAddGetRemove(TabSheet.class, SelectedTabChangeEvent.class, SelectedTabChangeListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java index 0ef8ae5a76..29f12fa4b6 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java +++ b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java @@ -14,7 +14,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.Tab; -public class TestTabSheet { +public class TabSheetTest { @Test public void addExistingComponent() { diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/WriteDesignTest.java index a46b33e2d6..ab7ef9977c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/tabsheet/WriteDesignTest.java @@ -33,7 +33,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private TabSheet sheet; private Element design; diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/textarea/ReadDesignTest.java index a31367008a..aad831e91c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textarea/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/textarea/ReadDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/textarea/WriteDesignTest.java index 01b0095fe9..63712eba15 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textarea/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/textarea/WriteDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/textfield/ReadDesignTest.java index 62cb1a53bc..d3da7fef8b 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textfield/TestReadDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/textfield/ReadDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestReadDesign extends TestCase { +public class ReadDesignTest extends TestCase { private DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidator.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java index cdb001e266..83c45f94db 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidator.java +++ b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithConverterAndValidatorTest.java @@ -4,10 +4,10 @@ import junit.framework.TestCase; import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.validator.RangeValidator; -import com.vaadin.tests.data.converter.ConverterFactory.ConvertTo42; +import com.vaadin.tests.data.converter.ConverterFactoryTest.ConvertTo42; import com.vaadin.ui.TextField; -public class TextFieldWithConverterAndValidator extends TestCase { +public class TextFieldWithConverterAndValidatorTest extends TestCase { private TextField field; private ObjectProperty<Integer> property; diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java index 59922d819f..8f2bec455b 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java +++ b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatterTest.java @@ -11,7 +11,7 @@ import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.PropertyFormatter; import com.vaadin.ui.TextField; -public class TextFieldWithPropertyFormatter extends TestCase { +public class TextFieldWithPropertyFormatterTest extends TestCase { private static final String INPUT_VALUE = "foo"; private static final String PARSED_VALUE = "BAR"; diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithValidator.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java index 2a79d1fe27..b2a51aad8b 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithValidator.java +++ b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldWithValidatorTest.java @@ -10,7 +10,7 @@ import com.vaadin.data.validator.RegexpValidator; import com.vaadin.data.validator.StringLengthValidator; import com.vaadin.ui.TextField; -public class TextFieldWithValidator extends TestCase { +public class TextFieldWithValidatorTest extends TestCase { private TextField field; private ObjectProperty<String> property; diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/textfield/WriteDesignTest.java index 479c94f6a8..061b0ff402 100644 --- a/server/tests/src/com/vaadin/tests/server/component/textfield/TestWriteDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/textfield/WriteDesignTest.java @@ -30,7 +30,7 @@ import com.vaadin.ui.declarative.DesignContext; * * @author Vaadin Ltd */ -public class TestWriteDesign extends TestCase { +public class WriteDesignTest extends TestCase { private DesignContext ctx; @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java b/server/tests/src/com/vaadin/tests/server/component/tree/ListenersTest.java index 4984cf161b..c327fe8c5f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/tree/ListenersTest.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Tree.CollapseListener; import com.vaadin.ui.Tree.ExpandEvent; import com.vaadin.ui.Tree.ExpandListener; -public class TestListeners extends TestCase implements ExpandListener, +public class ListenersTest extends TestCase implements ExpandListener, CollapseListener { private int expandCalled; private int collapseCalled; diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java b/server/tests/src/com/vaadin/tests/server/component/tree/TreeListenersTest.java index 8d5b499264..449f418596 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tree/TreeListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/tree/TreeListenersTest.java @@ -2,14 +2,14 @@ package com.vaadin.tests.server.component.tree; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.CollapseEvent; import com.vaadin.ui.Tree.CollapseListener; import com.vaadin.ui.Tree.ExpandEvent; import com.vaadin.ui.Tree.ExpandListener; -public class TreeListeners extends AbstractListenerMethodsTest { +public class TreeListenersTest extends AbstractListenerMethodsTestBase { public void testExpandListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Tree.class, ExpandEvent.class, ExpandListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/treetable/EmptyTreeTable.java b/server/tests/src/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java index 535ed8e860..a886b74f57 100644 --- a/server/tests/src/com/vaadin/tests/server/component/treetable/EmptyTreeTable.java +++ b/server/tests/src/com/vaadin/tests/server/component/treetable/EmptyTreeTableTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.ui.TreeTable; -public class EmptyTreeTable extends TestCase { +public class EmptyTreeTableTest extends TestCase { public void testLastId() { TreeTable treeTable = new TreeTable(); diff --git a/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java b/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java index a3b79a14f0..4a34094da1 100644 --- a/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNull.java +++ b/server/tests/src/com/vaadin/tests/server/component/treetable/TreeTableSetContainerNullTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; import com.vaadin.ui.TreeTable; -public class TreeTableSetContainerNull extends TestCase { +public class TreeTableSetContainerNullTest extends TestCase { public void testNullContainer() { TreeTable treeTable = new TreeTable(); diff --git a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java index 1df1d36cab..be23a998a3 100644 --- a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java +++ b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoaderTest.java @@ -18,7 +18,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.AlwaysLockedVaadinSession; import com.vaadin.ui.UI; -public class CustomUIClassLoader extends TestCase { +public class CustomUIClassLoaderTest extends TestCase { /** * Stub root @@ -68,7 +68,7 @@ public class CustomUIClassLoader extends TestCase { private static DeploymentConfiguration createConfigurationMock() { Properties properties = new Properties(); properties.put(VaadinSession.UI_PARAMETER, MyUI.class.getName()); - return new DefaultDeploymentConfiguration(CustomUIClassLoader.class, + return new DefaultDeploymentConfiguration(CustomUIClassLoaderTest.class, properties); } diff --git a/server/tests/src/com/vaadin/tests/server/component/ui/LegacyUIAddRemoveComponents.java b/server/tests/src/com/vaadin/tests/server/component/ui/LegacyUIAddRemoveComponentsTest.java index 24fd3d85a8..2a88bb3208 100644 --- a/server/tests/src/com/vaadin/tests/server/component/ui/LegacyUIAddRemoveComponents.java +++ b/server/tests/src/com/vaadin/tests/server/component/ui/LegacyUIAddRemoveComponentsTest.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.LegacyWindow; -public class LegacyUIAddRemoveComponents { +public class LegacyUIAddRemoveComponentsTest { private static class TestUI extends LegacyWindow { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/upload/UploadListeners.java b/server/tests/src/com/vaadin/tests/server/component/upload/UploadListenersTest.java index 265e5382d4..13d4c6bfe6 100644 --- a/server/tests/src/com/vaadin/tests/server/component/upload/UploadListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/upload/UploadListenersTest.java @@ -1,7 +1,7 @@ package com.vaadin.tests.server.component.upload; import com.vaadin.server.StreamVariable.StreamingProgressEvent; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Upload; import com.vaadin.ui.Upload.FailedEvent; import com.vaadin.ui.Upload.FailedListener; @@ -13,7 +13,7 @@ import com.vaadin.ui.Upload.StartedListener; import com.vaadin.ui.Upload.SucceededEvent; import com.vaadin.ui.Upload.SucceededListener; -public class UploadListeners extends AbstractListenerMethodsTest { +public class UploadListenersTest extends AbstractListenerMethodsTestBase { public void testProgressListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Upload.class, StreamingProgressEvent.class, ProgressListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindowTest.java index 774eafceaf..7fa8665c01 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindowTest.java @@ -13,7 +13,7 @@ import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.UI; import com.vaadin.ui.Window; -public class AddRemoveSubWindow { +public class AddRemoveSubWindowTest { public class TestApp extends LegacyApplication { diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java index 5720744e2f..9f7a54df9c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java @@ -19,7 +19,7 @@ import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class AttachDetachWindow { +public class AttachDetachWindowTest { private VaadinSession testApp = new AlwaysLockedVaadinSession(null); diff --git a/server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java b/server/tests/src/com/vaadin/tests/server/component/window/WindowAttachTest.java index 586300f650..867342ab03 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/WindowAttach.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/WindowAttachTest.java @@ -22,7 +22,7 @@ import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class WindowAttach { +public class WindowAttachTest { private static class MyUI extends UI { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/window/WindowListeners.java b/server/tests/src/com/vaadin/tests/server/component/window/WindowListenersTest.java index c33871cbd8..87a1af301c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/WindowListeners.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/WindowListenersTest.java @@ -4,14 +4,14 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTest; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; import com.vaadin.ui.Window; import com.vaadin.ui.Window.CloseEvent; import com.vaadin.ui.Window.CloseListener; import com.vaadin.ui.Window.ResizeEvent; import com.vaadin.ui.Window.ResizeListener; -public class WindowListeners extends AbstractListenerMethodsTest { +public class WindowListenersTest extends AbstractListenerMethodsTestBase { public void testFocusListenerAddGetRemove() throws Exception { testListenerAddGetRemove(Window.class, FocusEvent.class, FocusListener.class); diff --git a/server/tests/src/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java b/server/tests/src/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java index e3e743d02a..f19821f92e 100644 --- a/server/tests/src/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java +++ b/server/tests/src/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTestBase.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -public abstract class AbstractIndexedLayoutTest extends TestCase { +public abstract class AbstractIndexedLayoutTestBase extends TestCase { private Layout layout; diff --git a/server/tests/src/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java b/server/tests/src/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java index dc9667c38e..8dd36beda3 100644 --- a/server/tests/src/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java +++ b/server/tests/src/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java @@ -4,7 +4,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Layout; -public class CssLayoutTest extends AbstractIndexedLayoutTest { +public class CssLayoutTest extends AbstractIndexedLayoutTestBase { @Override protected Layout createLayout() { diff --git a/server/tests/src/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java b/server/tests/src/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java index 50de871106..c689e7fe06 100644 --- a/server/tests/src/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java +++ b/server/tests/src/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java @@ -10,7 +10,7 @@ import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -public class FormLayoutTest extends AbstractIndexedLayoutTest { +public class FormLayoutTest extends AbstractIndexedLayoutTestBase { @Override protected Layout createLayout() { diff --git a/server/tests/src/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java b/server/tests/src/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java index 0e3a1d5734..565cc8e8ab 100644 --- a/server/tests/src/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java +++ b/server/tests/src/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java @@ -4,7 +4,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout; -public class VerticalLayoutTest extends AbstractIndexedLayoutTest { +public class VerticalLayoutTest extends AbstractIndexedLayoutTestBase { @Override protected Layout createLayout() { diff --git a/server/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/server/tests/src/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java index c8d6ecce9c..637947fc9b 100644 --- a/server/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java +++ b/server/tests/src/com/vaadin/tests/server/components/AbstractFieldValueChangeTestBase.java @@ -22,7 +22,7 @@ import com.vaadin.ui.AbstractField; * override {@link #setValue(AbstractField)} to set the field value via * <code>changeVariables()</code>. */ -public abstract class AbstractTestFieldValueChange<T> extends TestCase { +public abstract class AbstractFieldValueChangeTestBase<T> extends TestCase { private AbstractField<T> field; private ValueChangeListener listener; diff --git a/server/tests/src/com/vaadin/tests/server/components/TestComboBoxValueChange.java b/server/tests/src/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java index 308889fa33..f3cc337657 100644 --- a/server/tests/src/com/vaadin/tests/server/components/TestComboBoxValueChange.java +++ b/server/tests/src/com/vaadin/tests/server/components/ComboBoxValueChangeTest.java @@ -12,8 +12,8 @@ import com.vaadin.ui.ComboBox; * * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>. */ -public class TestComboBoxValueChange extends - AbstractTestFieldValueChange<Object> { +public class ComboBoxValueChangeTest extends + AbstractFieldValueChangeTestBase<Object> { @Override protected void setUp() throws Exception { ComboBox combo = new ComboBox(); diff --git a/server/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java b/server/tests/src/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java index 92664917fd..3467d1d80c 100644 --- a/server/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java +++ b/server/tests/src/com/vaadin/tests/server/components/GridLayoutLastRowRemovalTest.java @@ -5,7 +5,7 @@ import junit.framework.TestCase; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -public class TestGridLayoutLastRowRemoval extends TestCase { +public class GridLayoutLastRowRemovalTest extends TestCase { public void testRemovingLastRow() { GridLayout grid = new GridLayout(2, 1); diff --git a/server/tests/src/com/vaadin/tests/server/components/TestTextFieldValueChange.java b/server/tests/src/com/vaadin/tests/server/components/TextFieldValueChangeTest.java index 7c47b94df4..cfceb6f7d7 100644 --- a/server/tests/src/com/vaadin/tests/server/components/TestTextFieldValueChange.java +++ b/server/tests/src/com/vaadin/tests/server/components/TextFieldValueChangeTest.java @@ -17,8 +17,8 @@ import com.vaadin.ui.TextField; * * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>. */ -public class TestTextFieldValueChange extends - AbstractTestFieldValueChange<String> { +public class TextFieldValueChangeTest extends + AbstractFieldValueChangeTestBase<String> { @Override protected void setUp() throws Exception { diff --git a/server/tests/src/com/vaadin/tests/server/components/TestWindow.java b/server/tests/src/com/vaadin/tests/server/components/WindowTest.java index 6707965be6..26fe238342 100644 --- a/server/tests/src/com/vaadin/tests/server/components/TestWindow.java +++ b/server/tests/src/com/vaadin/tests/server/components/WindowTest.java @@ -14,7 +14,7 @@ import com.vaadin.ui.Window.CloseListener; import com.vaadin.ui.Window.ResizeEvent; import com.vaadin.ui.Window.ResizeListener; -public class TestWindow extends TestCase { +public class WindowTest extends TestCase { private Window window; diff --git a/server/tests/src/com/vaadin/tests/server/validation/TestBeanValidation.java b/server/tests/src/com/vaadin/tests/server/validation/BeanValidationTest.java index 832ae14950..6b7582525e 100644 --- a/server/tests/src/com/vaadin/tests/server/validation/TestBeanValidation.java +++ b/server/tests/src/com/vaadin/tests/server/validation/BeanValidationTest.java @@ -9,7 +9,7 @@ import com.vaadin.data.validator.BeanValidator; import com.vaadin.tests.data.bean.BeanToValidate; import com.vaadin.ui.Field; -public class TestBeanValidation { +public class BeanValidationTest { @Test(expected = InvalidValueException.class) public void testBeanValidationNull() { BeanValidator validator = new BeanValidator(BeanToValidate.class, diff --git a/server/tests/src/com/vaadin/tests/server/validation/TestReadOnlyValidation.java b/server/tests/src/com/vaadin/tests/server/validation/ReadOnlyValidationTest.java index e37b97e02c..661236e597 100644 --- a/server/tests/src/com/vaadin/tests/server/validation/TestReadOnlyValidation.java +++ b/server/tests/src/com/vaadin/tests/server/validation/ReadOnlyValidationTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import com.vaadin.data.validator.IntegerValidator; import com.vaadin.ui.TextField; -public class TestReadOnlyValidation { +public class ReadOnlyValidationTest { @Test public void testIntegerValidation() { diff --git a/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChangeTest.java index fa69fc46da..bb5babf360 100644 --- a/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChange.java +++ b/server/tests/src/com/vaadin/ui/AbsFieldDataSourceLocaleChangeTest.java @@ -12,7 +12,7 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.AlwaysLockedVaadinSession; -public class AbsFieldDataSourceLocaleChange { +public class AbsFieldDataSourceLocaleChangeTest { private VaadinSession vaadinSession; private UI ui; diff --git a/server/tests/src/com/vaadin/ui/AbstractSelectTest.java b/server/tests/src/com/vaadin/ui/AbsSelectTest.java index bd399f088c..0b807c5f21 100644 --- a/server/tests/src/com/vaadin/ui/AbstractSelectTest.java +++ b/server/tests/src/com/vaadin/ui/AbsSelectTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import com.vaadin.data.util.ObjectProperty; -public class AbstractSelectTest { +public class AbsSelectTest { @Test public void addItemsStrings() { diff --git a/server/tests/src/com/vaadin/ui/LabelDataSource.java b/server/tests/src/com/vaadin/ui/LabelDataSourceTest.java index b57e83df8e..8ec3ca1245 100644 --- a/server/tests/src/com/vaadin/ui/LabelDataSource.java +++ b/server/tests/src/com/vaadin/ui/LabelDataSourceTest.java @@ -26,7 +26,7 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; import com.vaadin.tests.util.AlwaysLockedVaadinSession; -public class LabelDataSource { +public class LabelDataSourceTest { Label label; private static final String STRING_DS_VALUE = "String DatA source"; diff --git a/server/tests/src/com/vaadin/ui/UIThemeEscaping.java b/server/tests/src/com/vaadin/ui/UIThemeEscapingTest.java index 236f283823..7a0a5551e3 100644 --- a/server/tests/src/com/vaadin/ui/UIThemeEscaping.java +++ b/server/tests/src/com/vaadin/ui/UIThemeEscapingTest.java @@ -25,7 +25,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class UIThemeEscaping { +public class UIThemeEscapingTest { private UI ui; diff --git a/server/tests/src/com/vaadin/util/TestCurrentInstance.java b/server/tests/src/com/vaadin/util/CurrentInstanceTest.java index 666a0ef019..36055a036a 100644 --- a/server/tests/src/com/vaadin/util/TestCurrentInstance.java +++ b/server/tests/src/com/vaadin/util/CurrentInstanceTest.java @@ -30,7 +30,7 @@ import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinSession; import com.vaadin.ui.UI; -public class TestCurrentInstance { +public class CurrentInstanceTest { @Test public void testInitiallyCleared() throws Exception { @@ -39,20 +39,20 @@ public class TestCurrentInstance { @Test public void testClearedAfterRemove() throws Exception { - CurrentInstance.set(TestCurrentInstance.class, this); + CurrentInstance.set(CurrentInstanceTest.class, this); Assert.assertEquals(this, - CurrentInstance.get(TestCurrentInstance.class)); - CurrentInstance.set(TestCurrentInstance.class, null); + CurrentInstance.get(CurrentInstanceTest.class)); + CurrentInstance.set(CurrentInstanceTest.class, null); assertCleared(); } @Test public void testClearedAfterRemoveInheritable() throws Exception { - CurrentInstance.setInheritable(TestCurrentInstance.class, this); + CurrentInstance.setInheritable(CurrentInstanceTest.class, this); Assert.assertEquals(this, - CurrentInstance.get(TestCurrentInstance.class)); - CurrentInstance.setInheritable(TestCurrentInstance.class, null); + CurrentInstance.get(CurrentInstanceTest.class)); + CurrentInstance.setInheritable(CurrentInstanceTest.class, null); assertCleared(); } @@ -61,19 +61,19 @@ public class TestCurrentInstance { public void testInheritableThreadLocal() throws Exception { final AtomicBoolean threadFailed = new AtomicBoolean(true); - CurrentInstance.setInheritable(TestCurrentInstance.class, this); + CurrentInstance.setInheritable(CurrentInstanceTest.class, this); Assert.assertEquals(this, - CurrentInstance.get(TestCurrentInstance.class)); + CurrentInstance.get(CurrentInstanceTest.class)); Thread t = new Thread() { @Override public void run() { - Assert.assertEquals(TestCurrentInstance.this, - CurrentInstance.get(TestCurrentInstance.class)); + Assert.assertEquals(CurrentInstanceTest.this, + CurrentInstance.get(CurrentInstanceTest.class)); threadFailed.set(false); } }; t.start(); - CurrentInstance.set(TestCurrentInstance.class, null); + CurrentInstance.set(CurrentInstanceTest.class, null); assertCleared(); while (t.isAlive()) { @@ -87,16 +87,16 @@ public class TestCurrentInstance { public void testClearedAfterRemoveInSeparateThread() throws Exception { final AtomicBoolean threadFailed = new AtomicBoolean(true); - CurrentInstance.setInheritable(TestCurrentInstance.class, this); + CurrentInstance.setInheritable(CurrentInstanceTest.class, this); Assert.assertEquals(this, - CurrentInstance.get(TestCurrentInstance.class)); + CurrentInstance.get(CurrentInstanceTest.class)); Thread t = new Thread() { @Override public void run() { try { - Assert.assertEquals(TestCurrentInstance.this, - CurrentInstance.get(TestCurrentInstance.class)); - CurrentInstance.set(TestCurrentInstance.class, null); + Assert.assertEquals(CurrentInstanceTest.this, + CurrentInstance.get(CurrentInstanceTest.class)); + CurrentInstance.set(CurrentInstanceTest.class, null); assertCleared(); threadFailed.set(false); @@ -115,18 +115,18 @@ public class TestCurrentInstance { // Clearing the threadlocal in the thread should not have cleared it // here Assert.assertEquals(this, - CurrentInstance.get(TestCurrentInstance.class)); + CurrentInstance.get(CurrentInstanceTest.class)); // Clearing the only remaining threadlocal should free all memory - CurrentInstance.set(TestCurrentInstance.class, null); + CurrentInstance.set(CurrentInstanceTest.class, null); assertCleared(); } @Test public void testClearedWithClearAll() throws Exception { - CurrentInstance.set(TestCurrentInstance.class, this); + CurrentInstance.set(CurrentInstanceTest.class, this); Assert.assertEquals(this, - CurrentInstance.get(TestCurrentInstance.class)); + CurrentInstance.get(CurrentInstanceTest.class)); CurrentInstance.clearAll(); assertCleared(); diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByTypeTest.java index 25f8ba7796..67796314c0 100644 --- a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java +++ b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByTypeTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.fail; import org.junit.Test; -public class ReflectToolsGetFieldValueByType { +public class ReflectToolsGetFieldValueByTypeTest { @Test public void getFieldValue() { class MyClass { diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java b/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValueTest.java index 690f77d9a5..40e8f05e1e 100644 --- a/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java +++ b/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValueTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertFalse; import org.junit.Test; -public class ReflectToolsGetPrimitiveFieldValue { +public class ReflectToolsGetPrimitiveFieldValueTest { @Test public void getFieldValueViaGetter() { class MyClass { diff --git a/shared/src/com/vaadin/shared/annotations/NoLayout.java b/shared/src/com/vaadin/shared/annotations/NoLayout.java index 78ff1e2984..b77729cdcc 100644 --- a/shared/src/com/vaadin/shared/annotations/NoLayout.java +++ b/shared/src/com/vaadin/shared/annotations/NoLayout.java @@ -32,7 +32,7 @@ import java.lang.annotation.Target; * the potential of causing sizes to change with appropriate style definitions * in the application theme. * - * @since + * @since 7.4 * * @author Vaadin Ltd */ diff --git a/shared/src/com/vaadin/shared/data/DataProviderRpc.java b/shared/src/com/vaadin/shared/data/DataProviderRpc.java index 3e5dd9a332..4bf4f3af5b 100644 --- a/shared/src/com/vaadin/shared/data/DataProviderRpc.java +++ b/shared/src/com/vaadin/shared/data/DataProviderRpc.java @@ -22,7 +22,7 @@ import com.vaadin.shared.communication.ClientRpc; /** * RPC interface used for pushing container data to the client. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface DataProviderRpc extends ClientRpc { diff --git a/shared/src/com/vaadin/shared/data/DataRequestRpc.java b/shared/src/com/vaadin/shared/data/DataRequestRpc.java index 637a353447..773a82fa9a 100644 --- a/shared/src/com/vaadin/shared/data/DataRequestRpc.java +++ b/shared/src/com/vaadin/shared/data/DataRequestRpc.java @@ -22,7 +22,7 @@ import com.vaadin.shared.communication.ServerRpc; /** * RPC interface used for requesting container data to the client. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface DataRequestRpc extends ServerRpc { diff --git a/shared/src/com/vaadin/shared/data/sort/SortDirection.java b/shared/src/com/vaadin/shared/data/sort/SortDirection.java index 043b363226..cd572087d7 100644 --- a/shared/src/com/vaadin/shared/data/sort/SortDirection.java +++ b/shared/src/com/vaadin/shared/data/sort/SortDirection.java @@ -20,7 +20,7 @@ import java.io.Serializable; /** * Describes sorting direction. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public enum SortDirection implements Serializable { diff --git a/shared/src/com/vaadin/shared/ui/grid/ColumnGroupState.java b/shared/src/com/vaadin/shared/ui/grid/ColumnGroupState.java index 2ef0dfc3f8..79e6c9a89f 100644 --- a/shared/src/com/vaadin/shared/ui/grid/ColumnGroupState.java +++ b/shared/src/com/vaadin/shared/ui/grid/ColumnGroupState.java @@ -23,7 +23,7 @@ import java.util.List; /** * The column group data shared between the server and the client * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class ColumnGroupState implements Serializable { diff --git a/shared/src/com/vaadin/shared/ui/grid/EditorClientRpc.java b/shared/src/com/vaadin/shared/ui/grid/EditorClientRpc.java index c083252754..7466df9c99 100644 --- a/shared/src/com/vaadin/shared/ui/grid/EditorClientRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/EditorClientRpc.java @@ -20,7 +20,7 @@ import com.vaadin.shared.communication.ClientRpc; /** * An RPC interface for the grid editor server-to-client communications. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface EditorClientRpc extends ClientRpc { @@ -42,14 +42,14 @@ public interface EditorClientRpc extends ClientRpc { void cancel(int rowIndex); /** - * Confirms a pending {@link EditorServerRpc#bind(int) bind request} - * sent by the client. + * Confirms a pending {@link EditorServerRpc#bind(int) bind request} sent by + * the client. */ void confirmBind(); /** - * Confirms a pending {@link EditorServerRpc#save(int) save request} - * sent by the client. + * Confirms a pending {@link EditorServerRpc#save(int) save request} sent by + * the client. */ void confirmSave(); } diff --git a/shared/src/com/vaadin/shared/ui/grid/EditorServerRpc.java b/shared/src/com/vaadin/shared/ui/grid/EditorServerRpc.java index 57df691547..34a16ccb38 100644 --- a/shared/src/com/vaadin/shared/ui/grid/EditorServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/EditorServerRpc.java @@ -20,7 +20,7 @@ import com.vaadin.shared.communication.ServerRpc; /** * An RPC interface for the grid editor client-to-server communications. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface EditorServerRpc extends ServerRpc { @@ -28,8 +28,8 @@ public interface EditorServerRpc extends ServerRpc { /** * Asks the server to open the editor and bind data to it. When a bind * request is sent, it must be acknowledged with a - * {@link EditorClientRpc#confirmBind() confirm call} before the client - * can open the editor. + * {@link EditorClientRpc#confirmBind() confirm call} before the client can + * open the editor. * * @param rowIndex * the index of the edited row diff --git a/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java b/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java index ade9e87f36..ed849cb361 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridClientRpc.java @@ -20,7 +20,7 @@ import com.vaadin.shared.communication.ClientRpc; /** * Server-to-client RPC interface for the Grid component. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface GridClientRpc extends ClientRpc { diff --git a/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java b/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java index 11cb133fa5..070d146736 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java @@ -23,17 +23,11 @@ import com.vaadin.shared.Connector; * Column state DTO for transferring column properties from the server to the * client * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class GridColumnState implements Serializable { - public static final double DEFAULT_MAX_WIDTH = -1; - public static final double DEFAULT_MIN_WIDTH = 10.0d; - public static final int DEFAULT_EXPAND_RATIO = -1; - - public static final double DEFAULT_COLUMN_WIDTH_PX = -1; - /** * Id used by grid connector to map server side column with client side * column @@ -42,9 +36,9 @@ public class GridColumnState implements Serializable { /** * Column width in pixels. Default column width is - * {@value #DEFAULT_COLUMN_WIDTH_PX}. + * {@value GridConstants#DEFAULT_COLUMN_WIDTH_PX}. */ - public double width = DEFAULT_COLUMN_WIDTH_PX; + public double width = GridConstants.DEFAULT_COLUMN_WIDTH_PX; /** * The connector for the renderer used to render the cells in this column. @@ -63,17 +57,17 @@ public class GridColumnState implements Serializable { public boolean sortable = false; /** How much of the remaining space this column will reserve. */ - public int expandRatio = DEFAULT_EXPAND_RATIO; + public int expandRatio = GridConstants.DEFAULT_EXPAND_RATIO; /** * The maximum expansion width of this column. -1 for "no maximum". If * maxWidth is less than the calculated width, maxWidth is ignored. */ - public double maxWidth = DEFAULT_MAX_WIDTH; + public double maxWidth = GridConstants.DEFAULT_MAX_WIDTH; /** * The minimum expansion width of this column. -1 for "no minimum". If * minWidth is less than the calculated width, minWidth will win. */ - public double minWidth = DEFAULT_MIN_WIDTH; + public double minWidth = GridConstants.DEFAULT_MIN_WIDTH; } diff --git a/shared/src/com/vaadin/shared/ui/grid/GridConstants.java b/shared/src/com/vaadin/shared/ui/grid/GridConstants.java index 1ee79a5d37..994b109204 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridConstants.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridConstants.java @@ -21,7 +21,7 @@ import java.io.Serializable; * Container class for common constants and default values used by the Grid * component. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public final class GridConstants implements Serializable { @@ -41,4 +41,26 @@ public final class GridConstants implements Serializable { * The threshold in pixels a finger can move while long tapping. */ public static final int LONG_TAP_THRESHOLD = 3; + + /* Column constants */ + + /** + * Default maximum width for columns. + */ + public static final double DEFAULT_MAX_WIDTH = -1; + + /** + * Default minimum width for columns. + */ + public static final double DEFAULT_MIN_WIDTH = 10.0d; + + /** + * Default expand ratio for columns. + */ + public static final int DEFAULT_EXPAND_RATIO = -1; + + /** + * Default width for columns. + */ + public static final double DEFAULT_COLUMN_WIDTH_PX = -1; } diff --git a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java index 141b1ed9ca..77eda7a2f6 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java @@ -23,14 +23,15 @@ import com.vaadin.shared.data.sort.SortDirection; /** * Client-to-server RPC interface for the Grid component * - * @since + * @since 7.4 * @author Vaadin Ltd */ public interface GridServerRpc extends ServerRpc { - void selectionChange(List<String> newSelection); - void sort(String[] columnIds, SortDirection[] directions, - boolean userOriginated); + void select(List<String> newSelection); void selectAll(); + + void sort(String[] columnIds, SortDirection[] directions, + boolean userOriginated); } diff --git a/shared/src/com/vaadin/shared/ui/grid/GridState.java b/shared/src/com/vaadin/shared/ui/grid/GridState.java index 1f98431caf..2b18d5b642 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridState.java @@ -26,7 +26,7 @@ import com.vaadin.shared.data.sort.SortDirection; /** * The shared state for the {@link com.vaadin.ui.components.grid.Grid} component * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class GridState extends AbstractComponentState { diff --git a/shared/src/com/vaadin/shared/ui/grid/GridStaticCellType.java b/shared/src/com/vaadin/shared/ui/grid/GridStaticCellType.java index eae4bc8da4..c646717d2c 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridStaticCellType.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridStaticCellType.java @@ -18,7 +18,7 @@ package com.vaadin.shared.ui.grid; /** * Enumeration, specifying the content type of a Cell in a GridStaticSection. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public enum GridStaticCellType { @@ -36,4 +36,4 @@ public enum GridStaticCellType { * Widget content */ WIDGET; -}
\ No newline at end of file +} diff --git a/shared/src/com/vaadin/shared/ui/grid/GridStaticSectionState.java b/shared/src/com/vaadin/shared/ui/grid/GridStaticSectionState.java index 88539913d1..a3c485af08 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridStaticSectionState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridStaticSectionState.java @@ -27,7 +27,7 @@ import com.vaadin.shared.Connector; /** * Shared state for Grid headers and footers. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public class GridStaticSectionState implements Serializable { diff --git a/shared/src/com/vaadin/shared/ui/grid/HeightMode.java b/shared/src/com/vaadin/shared/ui/grid/HeightMode.java index 228fcbf0f4..4cd19a01b1 100644 --- a/shared/src/com/vaadin/shared/ui/grid/HeightMode.java +++ b/shared/src/com/vaadin/shared/ui/grid/HeightMode.java @@ -21,7 +21,7 @@ package com.vaadin.shared.ui.grid; * {@link com.vaadin.ui.components.grid.Grid server}) / * {@link com.vaadin.client.ui.grid.Escalator Escalator}. * - * @since + * @since 7.4 * @author Vaadin Ltd * @see com.vaadin.client.ui.grid.Grid#setHeightMode(HeightMode) * @see com.vaadin.ui.components.grid.Grid#setHeightMode(HeightMode) diff --git a/shared/src/com/vaadin/shared/ui/grid/Range.java b/shared/src/com/vaadin/shared/ui/grid/Range.java index 6be9e04cbc..21e70d3dbf 100644 --- a/shared/src/com/vaadin/shared/ui/grid/Range.java +++ b/shared/src/com/vaadin/shared/ui/grid/Range.java @@ -27,7 +27,7 @@ import java.io.Serializable; * The range is considered {@link #isEmpty() empty} if the start is the same as * the end. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public final class Range implements Serializable { diff --git a/shared/src/com/vaadin/shared/ui/grid/ScrollDestination.java b/shared/src/com/vaadin/shared/ui/grid/ScrollDestination.java index 43d5fcc21b..64cf070e46 100644 --- a/shared/src/com/vaadin/shared/ui/grid/ScrollDestination.java +++ b/shared/src/com/vaadin/shared/ui/grid/ScrollDestination.java @@ -19,7 +19,7 @@ package com.vaadin.shared.ui.grid; * Enumeration, specifying the destinations that are supported when scrolling * rows or columns into view. * - * @since + * @since 7.4 * @author Vaadin Ltd */ public enum ScrollDestination { diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 1f72495596..e2b93ab7d2 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -17,6 +17,7 @@ package com.vaadin.launcher; import java.io.File; import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; @@ -45,10 +46,16 @@ import com.vaadin.server.LegacyVaadinServlet; import com.vaadin.server.ServiceException; import com.vaadin.server.SessionInitEvent; import com.vaadin.server.SessionInitListener; +import com.vaadin.server.SystemMessages; +import com.vaadin.server.SystemMessagesInfo; +import com.vaadin.server.SystemMessagesProvider; import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinServlet; import com.vaadin.server.VaadinServletRequest; +import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.UI; @@ -57,6 +64,9 @@ import com.vaadin.util.CurrentInstance; @SuppressWarnings("serial") public class ApplicationRunnerServlet extends LegacyVaadinServlet { + public static String CUSTOM_SYSTEM_MESSAGES_PROPERTY = "custom-" + + SystemMessages.class.getName(); + /** * The name of the application class currently used. Only valid within one * request. @@ -184,6 +194,29 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { return getApplicationRunnerURIs(request).applicationClassname; } + private final static class ProxyDeploymentConfiguration implements + InvocationHandler, Serializable { + private final DeploymentConfiguration originalConfiguration; + + private ProxyDeploymentConfiguration( + DeploymentConfiguration originalConfiguration) { + this.originalConfiguration = originalConfiguration; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + if (method.getDeclaringClass() == DeploymentConfiguration.class) { + // Find the configuration instance to delegate to + DeploymentConfiguration configuration = findDeploymentConfiguration(originalConfiguration); + + return method.invoke(configuration, args); + } else { + return method.invoke(proxy, args); + } + } + } + private static final class ApplicationRunnerUIProvider extends UIProvider { private final Class<?> classToRun; @@ -309,23 +342,38 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { return (DeploymentConfiguration) Proxy.newProxyInstance( DeploymentConfiguration.class.getClassLoader(), new Class[] { DeploymentConfiguration.class }, - new InvocationHandler() { - @Override - public Object invoke(Object proxy, Method method, - Object[] args) throws Throwable { - if (method.getDeclaringClass() == DeploymentConfiguration.class) { - // Find the configuration instance to delegate to - DeploymentConfiguration configuration = findDeploymentConfiguration(originalConfiguration); - - return method.invoke(configuration, args); - } else { - return method.invoke(proxy, args); - } - } - }); + new ProxyDeploymentConfiguration(originalConfiguration)); + } + + @Override + protected VaadinServletService createServletService( + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { + VaadinServletService service = super + .createServletService(deploymentConfiguration); + final SystemMessagesProvider provider = service + .getSystemMessagesProvider(); + service.setSystemMessagesProvider(new SystemMessagesProvider() { + + @Override + public SystemMessages getSystemMessages( + SystemMessagesInfo systemMessagesInfo) { + if (systemMessagesInfo.getRequest() == null) { + return provider.getSystemMessages(systemMessagesInfo); + } + Object messages = systemMessagesInfo.getRequest().getAttribute( + CUSTOM_SYSTEM_MESSAGES_PROPERTY); + if (messages instanceof SystemMessages) { + return (SystemMessages) messages; + } + return provider.getSystemMessages(systemMessagesInfo); + } + + }); + return service; } - private DeploymentConfiguration findDeploymentConfiguration( + private static DeploymentConfiguration findDeploymentConfiguration( DeploymentConfiguration originalConfiguration) throws Exception { // First level of cache DeploymentConfiguration configuration = CurrentInstance @@ -344,16 +392,19 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { * request. */ - HttpServletRequest currentRequest = request.get(); + HttpServletRequest currentRequest = VaadinServletService + .getCurrentServletRequest(); if (currentRequest != null) { HttpSession httpSession = currentRequest.getSession(false); if (httpSession != null) { Map<Class<?>, CurrentInstance> oldCurrent = CurrentInstance .setCurrent((VaadinSession) null); try { - session = getService().findVaadinSession( - new VaadinServletRequest(currentRequest, - getService())); + VaadinServletService service = (VaadinServletService) VaadinService + .getCurrent(); + session = service + .findVaadinSession(new VaadinServletRequest( + currentRequest, service)); } finally { /* * Clear some state set by findVaadinSession to @@ -377,9 +428,11 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { .getAttribute(name); if (configuration == null) { + ApplicationRunnerServlet servlet = (ApplicationRunnerServlet) VaadinServlet + .getCurrent(); Class<?> classToRun; try { - classToRun = getClassToRun(); + classToRun = servlet.getClassToRun(); } catch (ClassNotFoundException e) { /* * This happens e.g. if the UI class defined in the @@ -402,7 +455,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } configuration = new DefaultDeploymentConfiguration( - getClass(), initParameters); + servlet.getClass(), initParameters); } else { configuration = originalConfiguration; } diff --git a/uitest/src/com/vaadin/testbench/elements/GridElement.java b/uitest/src/com/vaadin/testbench/elements/GridElement.java index 254acbfa2a..0c94c1dd88 100644 --- a/uitest/src/com/vaadin/testbench/elements/GridElement.java +++ b/uitest/src/com/vaadin/testbench/elements/GridElement.java @@ -62,6 +62,51 @@ public class GridElement extends AbstractComponentElement { } } + public static class GridEditorElement extends AbstractElement { + + private GridElement grid; + + private GridEditorElement setGrid(GridElement grid) { + this.grid = grid; + return this; + } + + /** + * Gets the editor field for column in given index. + * + * @param colIndex + * column index + * @return the editor field for given location + */ + public TestBenchElement getField(int colIndex) { + return grid.getSubPart("#editor[" + colIndex + "]"); + } + + /** + * Saves the fields of this editor. + * <p> + * <em>Note:</em> that this closes the editor making this element + * useless. + */ + public void save() { + getField(0); + List<WebElement> buttons = findElements(By.xpath("./button")); + buttons.get(0).click(); + } + + /** + * Cancels this editor. + * <p> + * <em>Note:</em> that this closes the editor making this element + * useless. + */ + public void cancel() { + getField(0); + List<WebElement> buttons = findElements(By.xpath("./button")); + buttons.get(1).click(); + } + } + /** * Scrolls Grid element so that wanted row is displayed * @@ -262,6 +307,11 @@ public class GridElement extends AbstractComponentElement { return rootElements.get(2); } + public GridEditorElement getEditor() { + return getSubPart("#editor").wrap(GridEditorElement.class) + .setGrid(this); + } + /** * Helper function to get Grid subparts wrapped correctly * @@ -272,5 +322,4 @@ public class GridElement extends AbstractComponentElement { private TestBenchElement getSubPart(String subPartSelector) { return (TestBenchElement) findElement(By.vaadin(subPartSelector)); } - } diff --git a/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java b/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java index 38ce49b622..ceaceb661d 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java @@ -31,14 +31,14 @@ public class GridAddAndRemoveDataOnInitTest extends MultiBrowserTest { openTestURL(); GridElement gridAdd = $(GridElement.class).first(); - if (!gridAdd.isElementPresent(By.vaadin("#cell[9][1]")) - || gridAdd.isElementPresent(By.vaadin("#cell[10][1]"))) { + if (!gridAdd.isElementPresent(By.vaadin("#cell[9][0]")) + || gridAdd.isElementPresent(By.vaadin("#cell[10][0]"))) { Assert.fail("Grid with added data contained incorrect rows"); } GridElement gridRemove = $(GridElement.class).get(1); - if (!gridRemove.isElementPresent(By.vaadin("#cell[4][1]")) - || gridRemove.isElementPresent(By.vaadin("#cell[5][1]"))) { + if (!gridRemove.isElementPresent(By.vaadin("#cell[4][0]")) + || gridRemove.isElementPresent(By.vaadin("#cell[5][0]"))) { Assert.fail("Grid with removed data contained incorrect rows"); } } diff --git a/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java b/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java index 74beb20914..fa2d7b5399 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java @@ -20,6 +20,7 @@ import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; public class GridAddRow extends AbstractTestUI { @@ -27,6 +28,7 @@ public class GridAddRow extends AbstractTestUI { protected void setup(VaadinRequest request) { final Grid grid = new Grid(); + grid.setSelectionMode(SelectionMode.MULTI); grid.addColumn("firstName"); grid.addColumn("age", Integer.class); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridColspans.java b/uitest/src/com/vaadin/tests/components/grid/GridColspans.java index f61a39a1f2..80337971b6 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridColspans.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridColspans.java @@ -25,6 +25,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.FooterRow; import com.vaadin.ui.Grid.HeaderRow; +import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.renderer.NumberRenderer; public class GridColspans extends AbstractTestUI { @@ -48,6 +49,7 @@ public class GridColspans extends AbstractTestUI { grid = new Grid(dataSource); grid.setWidth("600px"); grid.getColumn("zipCode").setRenderer(new NumberRenderer()); + grid.setSelectionMode(SelectionMode.MULTI); addComponent(grid); HeaderRow row = grid.prependHeaderRow(); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridColumnExpand.java b/uitest/src/com/vaadin/tests/components/grid/GridColumnExpand.java index eb0c14ae41..f8338f991a 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridColumnExpand.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridColumnExpand.java @@ -151,7 +151,7 @@ public class GridColumnExpand extends AbstractTestUI { double minimumWidth = Math.round(column.getMinimumWidth() * 100) / 100; double maximumWidth = Math.round(column.getMaximumWidth() * 100) / 100; double width = Math.round(column.getWidth() * 100) / 100; - Object propertyId = column.getColumnProperty(); + Object propertyId = column.getPropertyId(); label.setValue(String.format( "[%s] Expand ratio: %s - min: %s - max: %s - width: %s", propertyId, expandRatio, minimumWidth, maximumWidth, width)); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java index af9aa3aad3..c71dd80360 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java @@ -34,7 +34,7 @@ public class GridGeneratedPropertiesTest extends MultiBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); assertEquals("Miles header wasn't present.", "miles", grid - .getHeaderCell(0, 3).getText().toLowerCase()); + .getHeaderCell(0, 2).getText().toLowerCase()); } @Test @@ -43,13 +43,13 @@ public class GridGeneratedPropertiesTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); // Overwritten foo property should not be sortable - GridCellElement fooHeader = grid.getHeaderCell(0, 1); + GridCellElement fooHeader = grid.getHeaderCell(0, 0); fooHeader.click(); assertFalse("Column foo was unexpectedly sorted.", fooHeader .getAttribute("class").contains("sort")); // Generated property miles is not sortable - GridCellElement milesHeader = grid.getHeaderCell(0, 3); + GridCellElement milesHeader = grid.getHeaderCell(0, 2); milesHeader.click(); assertFalse("Column miles was unexpectedly sorted.", milesHeader .getAttribute("class").contains("sort")); @@ -61,7 +61,7 @@ public class GridGeneratedPropertiesTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); // Generated property baz is sortable - GridCellElement bazHeader = grid.getHeaderCell(0, 4); + GridCellElement bazHeader = grid.getHeaderCell(0, 3); bazHeader.click(); assertTrue("Column baz was not sorted ascending", bazHeader .getAttribute("class").contains("sort-asc")); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java index 7c9eb66012..765cd01812 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java @@ -27,6 +27,7 @@ import com.vaadin.ui.Grid.FooterCell; import com.vaadin.ui.Grid.FooterRow; import com.vaadin.ui.Grid.HeaderCell; import com.vaadin.ui.Grid.HeaderRow; +import com.vaadin.ui.Grid.SelectionMode; @Theme("valo") public class GridHeaderStyleNames extends AbstractTestUIWithLog { @@ -40,6 +41,7 @@ public class GridHeaderStyleNames extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { Grid grid = new Grid(); + grid.setSelectionMode(SelectionMode.MULTI); grid.setContainerDataSource(BeanItemContainerGenerator .createContainer(100)); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridInTabSheet.java b/uitest/src/com/vaadin/tests/components/grid/GridInTabSheet.java index 4a331f3fa4..6c7f254a0d 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridInTabSheet.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridInTabSheet.java @@ -20,6 +20,7 @@ import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -29,6 +30,7 @@ public class GridInTabSheet extends AbstractTestUI { protected void setup(VaadinRequest request) { TabSheet sheet = new TabSheet(); final Grid grid = new Grid(); + grid.setSelectionMode(SelectionMode.MULTI); grid.addColumn("count", Integer.class); for (Integer i = 0; i < 3; ++i) { grid.addRow(i); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridInTabSheetTest.java b/uitest/src/com/vaadin/tests/components/grid/GridInTabSheetTest.java index 0fe15b149b..cd165e4678 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridInTabSheetTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridInTabSheetTest.java @@ -23,8 +23,10 @@ import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; +@TestCategory("grid") public class GridInTabSheetTest extends MultiBrowserTest { @Test diff --git a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java index de6fb30e1c..310cd357fa 100644 --- a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java +++ b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderers.java @@ -31,8 +31,11 @@ import com.vaadin.ui.renderer.ClickableRenderer.RendererClickListener; import com.vaadin.ui.renderer.ImageRenderer; import com.vaadin.ui.renderer.ProgressBarRenderer; +@SuppressWarnings("all") public class WidgetRenderers extends AbstractTestUI { + static final String PROPERTY_ID = "property id"; + @Override protected void setup(VaadinRequest request) { IndexedContainer container = new IndexedContainer(); @@ -43,6 +46,7 @@ public class WidgetRenderers extends AbstractTestUI { .addContainerProperty(ButtonRenderer.class, String.class, null); container.addContainerProperty(ImageRenderer.class, Resource.class, null); + container.addContainerProperty(PROPERTY_ID, String.class, null); final Item item = container.getItem(container.addItem()); @@ -50,6 +54,7 @@ public class WidgetRenderers extends AbstractTestUI { item.getItemProperty(ButtonRenderer.class).setValue("Click"); item.getItemProperty(ImageRenderer.class).setValue( new ThemeResource("window/img/close.png")); + item.getItemProperty(PROPERTY_ID).setValue("Click"); final Grid grid = new Grid(container); @@ -78,6 +83,15 @@ public class WidgetRenderers extends AbstractTestUI { } })); + grid.getColumn(PROPERTY_ID).setRenderer( + new ButtonRenderer(new RendererClickListener() { + @Override + public void click(RendererClickEvent event) { + item.getItemProperty(PROPERTY_ID).setValue( + event.getPropertyId()); + } + })); + addComponent(grid); addComponent(new Button("Change column order", diff --git a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java index 864a559fc6..01b957ccf5 100644 --- a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java @@ -17,10 +17,12 @@ package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.ButtonElement; @@ -60,6 +62,28 @@ public class WidgetRenderersTest extends MultiBrowserTest { } @Test + public void testButtonRendererAfterCellBeingFocused() { + openTestURL(); + + GridCellElement buttonCell = getGridCell(0, 1); + assertFalse("cell should not be focused before focusing", + buttonCell.isFocused()); + + // avoid clicking on the button + buttonCell.click(150, 5); + assertTrue("cell should be focused after focusing", + buttonCell.isFocused()); + + WebElement button = buttonCell.findElement(By.className("gwt-Button")); + assertNotEquals("Button should not be clicked before click", + "Clicked!", button.getText()); + + new Actions(getDriver()).moveToElement(button).click().perform(); + assertEquals("Button should be clicked after click", "Clicked!", + button.getText()); + } + + @Test public void testImageRenderer() { openTestURL(); @@ -92,6 +116,15 @@ public class WidgetRenderersTest extends MultiBrowserTest { By.className("gwt-Button"))); } + @Test + public void testPropertyIdInEvent() { + openTestURL(); + WebElement button = getGridCell(0, 3).findElement( + By.className("gwt-Button")); + button.click(); + assertEquals(WidgetRenderers.PROPERTY_ID, button.getText()); + } + GridCellElement getGridCell(int row, int col) { return $(GridElement.class).first().getCell(row, col); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/DisabledGridClientTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/DisabledGridClientTest.java index 0038d3dabe..63d031bc85 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/DisabledGridClientTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/DisabledGridClientTest.java @@ -24,9 +24,9 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.elements.GridElement.GridRowElement; -import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; +import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; -public class DisabledGridClientTest extends GridBasicFeaturesTest { +public class DisabledGridClientTest extends GridBasicClientFeaturesTest { @Before public void setUp() { diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java index faa7744ff8..35b2fc24fe 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.components.grid.basicfeatures.server; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -30,6 +31,8 @@ import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import com.vaadin.testbench.elements.GridElement.GridEditorElement; +import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; @@ -37,6 +40,7 @@ public class GridEditorTest extends GridBasicFeaturesTest { @Before public void setUp() { + setDebug(true); openTestURL(); selectMenuPath("Component", "Editor", "Enabled"); } @@ -165,4 +169,21 @@ public class GridEditorTest extends GridBasicFeaturesTest { return getEditor().findElements(By.className("v-textfield")); } + + @Test + public void testInvalidEdition() { + selectMenuPath("Component", "Editor", "Edit item 5"); + assertFalse(logContainsText("Exception occured, java.lang.IllegalStateException")); + GridEditorElement editor = getGridElement().getEditor(); + WebElement intField = editor.getField(7); + intField.clear(); + intField.sendKeys("banana phone"); + editor.save(); + assertTrue( + "No exception on invalid value.", + logContainsText("Exception occured, com.vaadin.data.fieldgroup.FieldGroup$CommitExceptionCommit failed")); + selectMenuPath("Component", "Editor", "Edit item 100"); + assertFalse("Exception should not exist", + isElementPresent(NotificationElement.class)); + } } diff --git a/uitest/src/com/vaadin/tests/components/ui/UISerializationTest.java b/uitest/src/com/vaadin/tests/components/ui/UISerializationTest.java index f499f29b9b..649f48c9ce 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UISerializationTest.java +++ b/uitest/src/com/vaadin/tests/components/ui/UISerializationTest.java @@ -1,21 +1,24 @@ package com.vaadin.tests.components.ui; -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.SingleBrowserTest; -import org.junit.Ignore; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.startsWith; +import static org.junit.Assert.assertThat; + import org.junit.Test; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.SingleBrowserTest; public class UISerializationTest extends SingleBrowserTest { @Test - @Ignore - // Broken on all browsers since 9696e6c3e7e952b66ac3f5c9ddc3dfca4233451e - public void tb2test() throws Exception { + public void uiIsSerialized() throws Exception { openTestURL(); - $(ButtonElement.class).first().click(); + + serialize(); + assertThat(getLogRow(0), startsWith("3. Diff states match, size: ")); assertThat(getLogRow(1), startsWith("2. Deserialized UI in ")); assertThat( @@ -23,4 +26,8 @@ public class UISerializationTest extends SingleBrowserTest { allOf(startsWith("1. Serialized UI in"), containsString(" into "), endsWith(" bytes"))); } + + private void serialize() { + $(ButtonElement.class).first().click(); + } } diff --git a/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java b/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java new file mode 100644 index 0000000000..31ec7658ee --- /dev/null +++ b/uitest/src/com/vaadin/tests/requesthandlers/CommunicationError.java @@ -0,0 +1,107 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.requesthandlers; + +import com.vaadin.launcher.ApplicationRunnerServlet; +import com.vaadin.server.CustomizedSystemMessages; +import com.vaadin.server.SystemMessages; +import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UIProvider; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinServletRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; + +/** + * Test UI provider to check communication error json object null values. + * + * @author Vaadin Ltd + */ +public class CommunicationError extends UIProvider { + + @Override + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + VaadinServletRequest request = (VaadinServletRequest) event + .getRequest(); + String currentUrl = request.getRequestURL().toString(); + StringBuilder redirectClass = new StringBuilder( + CommunicationError.class.getSimpleName()); + redirectClass.append('$'); + redirectClass.append(RedirectedUI.class.getSimpleName()); + + String restartApplication = "?restartApplication"; + if (!currentUrl.contains(restartApplication)) { + redirectClass.append(restartApplication); + } + final String url = currentUrl.replace( + CommunicationError.class.getSimpleName(), redirectClass); + + request.setAttribute( + ApplicationRunnerServlet.CUSTOM_SYSTEM_MESSAGES_PROPERTY, + createSystemMessages(url)); + + return CommunicationErrorUI.class; + } + + public static class CommunicationErrorUI extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Button button = new Button("Send bad request", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + VaadinService.getCurrentResponse().setStatus(400); + } + }); + addComponent(button); + } + + @Override + protected Integer getTicketNumber() { + return 14594; + } + + @Override + protected String getTestDescription() { + return "Null values should be wrapped into JsonNull objects."; + } + } + + public static class RedirectedUI extends UI { + + @Override + protected void init(VaadinRequest request) { + Label label = new Label("redirected"); + label.addStyleName("redirected"); + setContent(label); + } + + } + + private SystemMessages createSystemMessages(String url) { + CustomizedSystemMessages messages = new CustomizedSystemMessages(); + messages.setCommunicationErrorCaption(null); + messages.setCommunicationErrorMessage(null); + messages.setCommunicationErrorURL(url); + return messages; + } +} diff --git a/uitest/src/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java b/uitest/src/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java new file mode 100644 index 0000000000..f295ec5ba3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.requesthandlers; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for null values in communication error json object . + * + * @author Vaadin Ltd + */ +public class CommunicationErrorTest extends MultiBrowserTest { + + @Test + public void testRedirection() { + openTestURL(); + + $(ButtonElement.class).first().click(); + + Assert.assertTrue(isElementPresent(By.className("redirected"))); + } + +} diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java index 333964e9bf..2ac10c161d 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java @@ -17,9 +17,11 @@ package com.vaadin.tests.serialization; import java.text.DateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -42,10 +44,14 @@ import com.vaadin.tests.widgetset.client.SerializerTestState; import com.vaadin.tests.widgetset.client.SimpleTestBean; import com.vaadin.tests.widgetset.server.SerializerTestExtension; +import elemental.json.Json; +import elemental.json.JsonString; +import elemental.json.JsonValue; + @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") public class SerializerTest extends AbstractTestUI { - private Log log = new Log(40); + private Log log = new Log(45); @Override protected void setup(VaadinRequest request) { @@ -256,6 +262,12 @@ public class SerializerTest extends AbstractTestUI { rpc.sendDate(new Date(1)); rpc.sendDate(new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13)); + + state.jsonNull = Json.createNull(); + state.jsonString = Json.create("a string"); + state.jsonBoolean = Json.create(false); + rpc.sendJson(Json.create(true), Json.createNull(), Json.create("JSON")); + state.date1 = new Date(1); state.date2 = new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13); @@ -377,9 +389,17 @@ public class SerializerTest extends AbstractTestUI { @Override public void sendSet(Set<Integer> intSet, Set<Connector> connectorSet, Set<SimpleTestBean> beanSet) { - log.log("sendSet: " + intSet + ", " - + connectorCollectionToString(connectorSet) + ", " - + beanSet); + List<Integer> intList = new ArrayList<Integer>(intSet); + Collections.sort(intList); + List<Connector> connectorList = new ArrayList<Connector>( + connectorSet); + Collections.sort(connectorList, new ConnectorComparator()); + List<SimpleTestBean> beanList = new ArrayList<SimpleTestBean>( + beanSet); + Collections.sort(beanList, new SimpleBeanComparator()); + log.log("sendSet: " + intList + ", " + + connectorCollectionToString(connectorList) + ", " + + beanList); } @Override @@ -448,6 +468,13 @@ public class SerializerTest extends AbstractTestUI { } @Override + public void sendJson(JsonValue value1, JsonValue value2, + JsonString string) { + log.log("sendJson: " + value1.toJson() + ", " + value2.toJson() + + ", " + string.toJson()); + } + + @Override public void log(String string) { log.log(string); @@ -458,7 +485,7 @@ public class SerializerTest extends AbstractTestUI { @Override protected String getTestDescription() { - return "Test for lots of different cases of encoding and decoding variuos data types"; + return "Test for lots of different cases of encoding and decoding various data types"; } @Override @@ -466,4 +493,19 @@ public class SerializerTest extends AbstractTestUI { return Integer.valueOf(8655); } + private static class ConnectorComparator implements Comparator<Connector> { + + @Override + public int compare(Connector o1, Connector o2) { + return o1.getConnectorId().compareTo(o2.getConnectorId()); + } + } + + private static class SimpleBeanComparator implements + Comparator<SimpleTestBean> { + @Override + public int compare(SimpleTestBean o1, SimpleTestBean o2) { + return Integer.valueOf(o1.getValue()).compareTo(o2.getValue()); + } + } } diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java index 1624a89a01..23af74c78b 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java @@ -27,6 +27,9 @@ public class SerializerTestTest extends MultiBrowserTest { openTestURL(); int logRow = 0; + Assert.assertEquals( + "sendJson: {\"b\":false,\"s\":\"JSON\"}, null, \"value\"", + getLogRow(logRow++)); Assert.assertEquals("sendDate: May 31, 2013 8:12:13 AM UTC", getLogRow(logRow++)); Assert.assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC", @@ -77,6 +80,9 @@ public class SerializerTestTest extends MultiBrowserTest { "sendBoolean: false, false, [false, false, true, false, true, true]", getLogRow(logRow++)); Assert.assertEquals("sendBeanSubclass: 43", getLogRow(logRow++)); + Assert.assertEquals("state.jsonBoolean: false", getLogRow(logRow++)); + Assert.assertEquals("state.jsonString: a string", getLogRow(logRow++)); + Assert.assertEquals("state.jsonNull: NULL", getLogRow(logRow++)); Assert.assertEquals( "state.doubleArray: [1.7976931348623157e+308, 5e-324]", getLogRow(logRow++)); diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index b5a345bd30..2e3d25cbbe 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -837,7 +837,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { runPath = "/run-push"; } - if (UI.class.isAssignableFrom(uiClass)) { + if (UI.class.isAssignableFrom(uiClass) + || UIProvider.class.isAssignableFrom(uiClass)) { return runPath + "/" + uiClass.getCanonicalName() + (isDebug() ? "?debug" : ""); } else if (LegacyApplication.class.isAssignableFrom(uiClass)) { diff --git a/uitest/src/com/vaadin/tests/widgetset/client/BasicExtensionTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/BasicExtensionTestConnector.java index 6bd2abec60..86c918536f 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/BasicExtensionTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/BasicExtensionTestConnector.java @@ -19,7 +19,6 @@ package com.vaadin.tests.widgetset.client; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.vaadin.client.ServerConnector; -import com.vaadin.client.Util; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.shared.ui.Connect; import com.vaadin.tests.extensions.BasicExtension; @@ -35,8 +34,8 @@ public class BasicExtensionTestConnector extends AbstractExtensionConnector { } private void appendMessage(String action) { - String message = Util.getSimpleName(this) + action - + Util.getSimpleName(target); + String message = getClass().getSimpleName() + action + + target.getClass().getSimpleName(); DivElement element = Document.get().createDivElement(); element.setInnerText(message); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/CustomUIConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/CustomUIConnector.java index b43da8e27e..7a93f5e360 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/CustomUIConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/CustomUIConnector.java @@ -18,7 +18,6 @@ package com.vaadin.tests.widgetset.client; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.SpanElement; -import com.vaadin.client.Util; import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.shared.ui.Connect; import com.vaadin.ui.UI; @@ -33,7 +32,7 @@ public class CustomUIConnector extends UIConnector { public void test() { SpanElement span = Document.get().createSpanElement(); span.setInnerText("This is the " - + Util.getSimpleName(CustomUIConnector.this)); + + CustomUIConnector.this.getClass().getSimpleName()); Document.get().getBody().insertFirst(span); } }); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 7758cdc2ac..07acd3d021 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -35,6 +35,13 @@ import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.widgetset.server.SerializerTestExtension; +import elemental.json.Json; +import elemental.json.JsonBoolean; +import elemental.json.JsonObject; +import elemental.json.JsonString; +import elemental.json.JsonType; +import elemental.json.JsonValue; + @Connect(SerializerTestExtension.class) public class SerializerTestConnector extends AbstractExtensionConnector { @@ -259,6 +266,27 @@ public class SerializerTestConnector extends AbstractExtensionConnector { } @Override + public void sendJson(JsonValue value1, JsonValue value2, + JsonString string) { + if (value1.getType() != JsonType.BOOLEAN) { + throw new RuntimeException("Expected boolean, got " + + value1.toJson()); + } + + if (value2.getType() != JsonType.NULL) { + throw new RuntimeException("Expected null, got " + + value2.toJson()); + } + + JsonObject returnObject = Json.createObject(); + returnObject.put("b", !((JsonBoolean) value1).asBoolean()); + returnObject.put("s", string); + + rpc.sendJson(returnObject, Json.createNull(), + Json.create("value")); + } + + @Override public void log(String message) { // Do nothing, used only in the other direction } @@ -311,6 +339,11 @@ public class SerializerTestConnector extends AbstractExtensionConnector { rpc.log("state.doubleObjectValue: " + getState().doubleObjectValue); rpc.log("state.doubleArray: " + Arrays.toString(getState().doubleArray)); + rpc.log("state.jsonNull: " + getState().jsonNull.getType().name()); + rpc.log("state.jsonString: " + + ((JsonString) getState().jsonString).getString()); + rpc.log("state.jsonBoolean: " + getState().jsonBoolean.getBoolean()); + /* * TODO public double doubleValue; public Double DoubleValue; public * double[] doubleArray; ; diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java index 6b4c4e7ac1..4baebc819e 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java @@ -26,6 +26,9 @@ import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.label.ContentMode; +import elemental.json.JsonString; +import elemental.json.JsonValue; + @SuppressWarnings("javadoc") public interface SerializerTestRpc extends ServerRpc, ClientRpc { public void sendBoolean(boolean value, Boolean boxedValue, boolean[] array); @@ -82,5 +85,7 @@ public interface SerializerTestRpc extends ServerRpc, ClientRpc { public void sendDate(Date date); + public void sendJson(JsonValue value1, JsonValue value2, JsonString string); + public void log(String string); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java index faf41fbf88..31ff58971f 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java @@ -24,6 +24,9 @@ import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.Connector; import com.vaadin.shared.ui.label.ContentMode; +import elemental.json.JsonBoolean; +import elemental.json.JsonValue; + public class SerializerTestState extends AbstractComponentState { public boolean booleanValue; @@ -99,4 +102,8 @@ public class SerializerTestState extends AbstractComponentState { public BeanWithAbstractSuperclass beanWithAbstractSuperclass; + public JsonValue jsonNull = null; + public JsonValue jsonString = null; + public JsonBoolean jsonBoolean = null; + } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index 73f604d2bc..64fc60e488 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -273,7 +273,7 @@ public class GridBasicClientFeaturesWidget extends }; column.setWidth(50 + c * 25); - column.setHeaderText("Header (0," + c + ")"); + column.setHeaderCaption("Header (0," + c + ")"); grid.addColumn(column); } @@ -289,7 +289,7 @@ public class GridBasicClientFeaturesWidget extends } }; grid.addColumn(column); - column.setHeaderText("Header (0," + c + ")"); + column.setHeaderCaption("Header (0," + c + ")"); } // Some date @@ -303,7 +303,7 @@ public class GridBasicClientFeaturesWidget extends } }; grid.addColumn(column); - column.setHeaderText("Header (0," + c + ")"); + column.setHeaderCaption("Header (0," + c + ")"); } // Row number as a HTML string @@ -317,7 +317,7 @@ public class GridBasicClientFeaturesWidget extends } }; grid.addColumn(column); - column.setHeaderText("Header (0," + c + ")"); + column.setHeaderCaption("Header (0," + c + ")"); } // Random integer value @@ -331,7 +331,7 @@ public class GridBasicClientFeaturesWidget extends } }; grid.addColumn(column); - column.setHeaderText("Header (0," + c + ")"); + column.setHeaderCaption("Header (0," + c + ")"); } // Random integer value between 0 and 5 @@ -345,7 +345,7 @@ public class GridBasicClientFeaturesWidget extends } }; grid.addColumn(column); - column.setHeaderText("Header (0," + c + ")"); + column.setHeaderCaption("Header (0," + c + ")"); } HeaderRow row = grid.getDefaultHeaderRow(); @@ -606,6 +606,14 @@ public class GridBasicClientFeaturesWidget extends } }, "Component", "State", "Frozen column count"); } + + addMenuCommand("Enabled", new ScheduledCommand() { + + @Override + public void execute() { + grid.setEnabled(!grid.isEnabled()); + } + }, "Component", "State"); } private void createColumnsMenu() { @@ -643,7 +651,7 @@ public class GridBasicClientFeaturesWidget extends addMenuCommand("Text Header", new ScheduledCommand() { @Override public void execute() { - column.setHeaderText("Text Header"); + column.setHeaderCaption("Text Header"); } }, "Component", "Columns", "Column " + i, "Header Type"); addMenuCommand("HTML Header", new ScheduledCommand() { diff --git a/widgets/build.xml b/widgets/build.xml new file mode 100644 index 0000000000..3e5ed61be2 --- /dev/null +++ b/widgets/build.xml @@ -0,0 +1,124 @@ +<?xml version="1.0"?> + +<project name="vaadin-widgets" basedir="." default="publish-local" xmlns:ivy="antlib:org.apache.ivy.ant"> + <description> + Widgets package for using Vaadin widgets with GWT 2.7+ + </description> + <include file="../common.xml" as="common" /> + <include file="../build.xml" as="vaadin" /> + <include file="../gwt-files.xml" as="gwtfiles" /> + + <!-- global properties --> + <property name="module.name" value="vaadin-widgets" /> + <property name="module.symbolic" value="com.vaadin.widgets" /> + <property name="result.dir" value="result" /> + <property name="result.src" value="${result.dir}/src" /> + <property name="result.deps" value="${result.dir}/deps" /> + + <path id="classpath.compile.custom"> + <fileset file="${gwt.user.jar}" /> + <fileset file="${gwt.dev.jar}" /> + </path> + <path id="classpath.test.custom" /> + + <union id="jar.includes"> + + </union> + + <target name="dependencies"> + <antcall target="common.dependencies" /> + </target> + + <target name="copysrc" depends="dependencies"> + <delete dir="${result.deps}" /> + + <ivy:resolve transitive="false" type="jar" conf="build" /> + <ivy:cachepath pathid="vaadin.jars" /> + <ivy:resolve transitive="false" type="jar" conf="build-provided" /> + <ivy:cachepath pathid="compile.deps" /> + <unjar dest="${result.deps}"> + <path refid="vaadin.jars" /> + </unjar> + + <copy todir="${result.src}"> + <fileset dir="src" /> + <fileset dir="${result.deps}"> + <include name="com/vaadin/*.gwt.xml" /> + <include name="com/vaadin/client/BrowserInfo.java" /> + <include name="com/vaadin/client/DeferredWorker.java" /> + <include name="com/vaadin/client/Profiler.java" /> + <include name="com/vaadin/client/StyleConstants.java" /> + <include name="com/vaadin/client/WidgetUtil.java" /> + <include name="com/vaadin/client/data/**/*.java" /> + <include name="com/vaadin/client/widget/**/*.java" /> + <include name="com/vaadin/client/Focusable.java" /> + <include name="com/vaadin/client/widgets/*.java" /> + <include name="com/vaadin/client/renderers/*.java" /> + <include name="com/vaadin/client/ui/SubPartAware.java" /> + <include name="com/vaadin/client/ui/VProgressBar.java" /> + <include name="com/vaadin/client/VSchedulerImpl.java" /> + + <include name="com/vaadin/shared/ui/grid/*.java" /> + <include name="com/vaadin/shared/ui/grid/**/*.java" /> + <include name="com/vaadin/shared/util/SharedUtil.java" /> + <include name="com/vaadin/shared/VBrowserDetails.java" /> + <include name="com/vaadin/shared/data/sort/SortDirection.java" /> + + <include name="com/vaadin/sass/linker/*.java" /> + + <exclude name="com/vaadin/shared/**/*Rpc.java" /> + <exclude name="com/vaadin/shared/**/*State.java" /> + </fileset> + </copy> + + <mkdir dir="${result.src}/com/vaadin/themes" /> + <copy todir="${result.src}/com/vaadin/themes/valo"> + <fileset dir="${result.deps}/VAADIN/themes/valo" /> + </copy> + <copy todir="${result.src}/com/vaadin/themes/base"> + <fileset dir="${result.deps}/VAADIN/themes/base" /> + </copy> + </target> + <target name="compile" description="Compiles the module" depends="dependencies,copysrc"> + <property name="classes" location="${result.dir}/classes" /> + <mkdir dir="${classes}" /> + + <javac destdir="${classes}" source="${vaadin.java.version}" target="${vaadin.java.version}" debug="true" encoding="UTF-8" includeantruntime="false"> + <src path="${result.src}" /> + <classpath refid="classpath.compile.custom" /> + <classpath refid="compile.deps" /> + </javac> + </target> + + <target name="jar" depends="compile"> + <property name="jar.file" location="${result.dir}/lib/${module.name}-${vaadin.version}.jar" /> + <antcall target="common.jar"> + <param name="src" value="${result.dir}/src" /> + <reference refid="jar.includes" torefid="extra.jar.includes" /> + </antcall> + </target> + + <target name="publish-local" depends="jar"> + <antcall target="common.sources.jar"> + <reference torefid="extra.jar.includes" refid="jar.includes" /> + </antcall> + <antcall target="common.javadoc.jar" /> + + <antcall target="common.publish-local" /> + </target> + + <target name="clean"> + <antcall target="common.clean" /> + </target> + + <target name="checkstyle"> + <antcall target="common.checkstyle"> + <param name="cs.src" location="src" /> + </antcall> + </target> + + <target name="test" depends="checkstyle"> + <!-- <antcall target="common.test.run" />--> + </target> + +</project> diff --git a/widgets/ivy.xml b/widgets/ivy.xml new file mode 100644 index 0000000000..d7c29631f4 --- /dev/null +++ b/widgets/ivy.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ivy-module version="2.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" + xmlns:m="http://ant.apache.org/ivy/maven"> + + <info organisation="com.vaadin" module="vaadin-widgets" + revision="${vaadin.version}" /> + + <configurations> + <conf name="build" /> + <conf name="build-provided" /> + <conf name="ide" visibility="private" /> + <conf name="test" /> + </configurations> + <publications> + <artifact type="jar" ext="jar" /> + <artifact type="source" ext="jar" m:classifier="sources" /> + <artifact type="javadoc" ext="jar" m:classifier="javadoc" /> + <artifact type="pom" ext="pom" /> + </publications> + <dependencies defaultconf="build" defaultconfmapping="build->default"> + <!-- API DEPENDENCIES --> + + <!-- LIBRARY DEPENDENCIES (compile time) --> + <!-- Project modules --> + <dependency org="com.vaadin" name="vaadin-shared" + rev="${vaadin.version}" conf="build,test->build"> + <exclude type="pom" conf="test" /> + </dependency> + <dependency org="com.vaadin" name="vaadin-client" + rev="${vaadin.version}" conf="build,test->build"> + <exclude type="pom" conf="test" /> + </dependency> + <dependency org="com.vaadin" name="vaadin-client-compiler" + rev="${vaadin.version}" conf="build,test->build"> + <exclude type="pom" conf="test" /> + </dependency> + <dependency org="com.vaadin" name="vaadin-themes" + rev="${vaadin.version}" conf="build,test->build"> + <exclude type="pom" conf="test" /> + </dependency> + <dependency org="com.vaadin" name="vaadin-sass-compiler" + rev="${vaadin.sass.version}" conf="build-provided->default" /> + + </dependencies> + +</ivy-module> diff --git a/widgets/src/com/vaadin/themes/Valo.gwt.xml b/widgets/src/com/vaadin/themes/Valo.gwt.xml new file mode 100644 index 0000000000..7c58d61ecf --- /dev/null +++ b/widgets/src/com/vaadin/themes/Valo.gwt.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" + "http://gwtproject.org/doctype/2.7.0/gwt-module.dtd"> +<module> + <entry-point class='com.vaadin.themes.valoutil.BodyStyleName' /> + <source path='valoutil' /> + <public path="valo" /> + <stylesheet src="styles.css" /> +</module> diff --git a/widgets/src/com/vaadin/themes/valoutil/BodyStyleName.java b/widgets/src/com/vaadin/themes/valoutil/BodyStyleName.java new file mode 100644 index 0000000000..73a01b6fd2 --- /dev/null +++ b/widgets/src/com/vaadin/themes/valoutil/BodyStyleName.java @@ -0,0 +1,13 @@ +package com.vaadin.themes.valoutil; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.dom.client.Document; + +public class BodyStyleName implements EntryPoint { + + @Override + public void onModuleLoad() { + Document.get().getBody().addClassName("valo"); + } + +} |