diff options
126 files changed, 2471 insertions, 810 deletions
diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html index 1e4016db90..c73f9701c5 100644 --- a/WebContent/release-notes.html +++ b/WebContent/release-notes.html @@ -60,6 +60,7 @@ </p> <ul> +<<<<<<< HEAD <li>Vaadin server and client side classes (<tt>/com</tt>)</li> <li>Vaadin server and client side sources (<tt>/com</tt>)</li> <li>The default widget set (<tt>/VAADIN/widgetsets</tt>)</li> @@ -67,6 +68,39 @@ <li>Release notes (<tt>/release-notes.html</tt>)</li> <li>Licensing information (<tt>/license.html</tt>)</li> </ul> +======= + <li><a href="http://dev.vaadin.com/ticket/8932">#8932</a>: Custom build from 6.8</li> + <li><a href="http://dev.vaadin.com/ticket/8193">#8193</a>: Enter ClickShortcut not working in a PopupView</li> + <li><a href="http://dev.vaadin.com/ticket/8584">#8584</a>: Invalid behavior of multiselection for com.vaadin.ui.Table</li> + <li><a href="http://dev.vaadin.com/ticket/9136">#9136</a>: Tree throws wrong ItemClickEvent in IE9 (when immediate is set to true)</li> + <li><a href="http://dev.vaadin.com/ticket/9139">#9139</a>: TextArea in Internet Explorer</li> + <li><a href="http://dev.vaadin.com/ticket/9188">#9188</a>: Error parsing maps with empty string as the last value</li> + <li><a href="http://dev.vaadin.com/ticket/7036">#7036</a>: Enable scrollbars on a read-only RichTextArea</li> + <li><a href="http://dev.vaadin.com/ticket/8109">#8109</a>: Iterating over Table multiselection causes multiple Vaadin SQLContainer full table scans</li> + <li><a href="http://dev.vaadin.com/ticket/8144">#8144</a>: Can't use LoginForm inside an iframe</li> + <li><a href="http://dev.vaadin.com/ticket/9202">#9202</a>: Test using Chrome 21</li> + <li><a href="http://dev.vaadin.com/ticket/6219">#6219</a>: PDF viewer draws itself over floating Vaadin elements</li> + <li><a href="http://dev.vaadin.com/ticket/8230">#8230</a>: TextField's input prompt is persisted if Alt is depressed while in focus (Chrome)</li> + <li><a href="http://dev.vaadin.com/ticket/8399">#8399</a>: On IE 8 or Google Chrome 16, VOverlay components aren't display on top of Applet</li> + <li><a href="http://dev.vaadin.com/ticket/9148">#9148</a>: Oracle TIMESTAMP not supported in SQLContainer</li> + <li><a href="http://dev.vaadin.com/ticket/9189">#9189</a>: Variables sent to the DragAndDropManager are not logged in the debug console</li> + <li><a href="http://dev.vaadin.com/ticket/9128">#9128</a>: Typo in vaadin book</li> + <li><a href="http://dev.vaadin.com/ticket/8736">#8736</a>: com.vaadin.ui.Table component return null value on multiple selection</li> + <li><a href="http://dev.vaadin.com/ticket/9132">#9132</a>: No entries in Table with a defined pageLength causes Table to shrink in height</li> + <li><a href="http://dev.vaadin.com/ticket/9147">#9147</a>: SQLContainer Filters - Comparison against NULL value produces error</li> + <li><a href="http://dev.vaadin.com/ticket/9154">#9154</a>: NumberFormatException in client-side component VSplitPanel</li> + <li><a href="http://dev.vaadin.com/ticket/9171">#9171</a>: StreamVariable never cleaned up in CommunicationManager</li> + <li><a href="http://dev.vaadin.com/ticket/9187">#9187</a>: No horizontal scroll bar on empty Table</li> + <li><a href="http://dev.vaadin.com/ticket/8838">#8838</a>: Drag and Drop in Google Chrome causes ArrayIndexOutOfBoundsException in AbstractCommunicationManager#convertMap (1612)</li> + <li><a href="http://dev.vaadin.com/ticket/8917">#8917</a>: input prompt text is leaking into the component's value</li> + </ul> + + <p> + The <a + href="http://dev.vaadin.com/query?status=closed&resolution=fixed&milestone=Vaadin+@version@&order=priority">full + list of the closed issues</a> can be found at <tt>dev.vaadin.com</tt>. + </p> +>>>>>>> remotes/origin/6.8 <h2 id="enhancements">Enhancements in Vaadin @version-minor@</h2> @@ -348,11 +382,19 @@ </p> <ul> +<<<<<<< HEAD <li>Mozilla Firefox 12</li> <li>Internet Explorer 8-9</li> <li>Safari 5</li> <li>Opera 11</li> <li>Google Chrome 19</li> +======= + <li>Mozilla Firefox 3-14</li> + <li>Internet Explorer 6-9</li> + <li>Safari 4-5</li> + <li>Opera 10-12</li> + <li>Google Chrome 13-21</li> +>>>>>>> remotes/origin/6.8 </ul> <p> diff --git a/WebContent/statictestfiles/applet.html b/WebContent/statictestfiles/applet.html new file mode 100644 index 0000000000..05e1785e10 --- /dev/null +++ b/WebContent/statictestfiles/applet.html @@ -0,0 +1,5 @@ +<html> +<body> + <applet code="com/vaadin/tests/components/embedded/TestApplet/class"></applet> +</body> +</html>
\ No newline at end of file diff --git a/WebContent/statictestfiles/com/vaadin/tests/components/embedded/TestApplet.class b/WebContent/statictestfiles/com/vaadin/tests/components/embedded/TestApplet.class Binary files differnew file mode 100644 index 0000000000..7650e1f870 --- /dev/null +++ b/WebContent/statictestfiles/com/vaadin/tests/components/embedded/TestApplet.class diff --git a/build/bin/package-diff.py b/build/bin/package-diff.py index a9f29e40a9..27f1ade771 100644 --- a/build/bin/package-diff.py +++ b/build/bin/package-diff.py @@ -7,7 +7,7 @@ from sets import Set # Configuration ################################################################################ downloadsite = "http://vaadin.com/download" -latestfile = "/release/6.7/LATEST" +latestfile = "/release/6.8/LATEST" JAPIZE = "japize" JAPICOMPAT = "japicompat" diff --git a/build/build.xml b/build/build.xml index ba9b93a2ab..2988218c4d 100644 --- a/build/build.xml +++ b/build/build.xml @@ -531,6 +531,7 @@ <include name="VAADIN/themes/**/*" /> <include name="VAADIN/vaadinBootstrap.js" /> <include name="META-INF/**/*" /> + <include name="statictestfiles/**" /> </fileset> </copy> diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java index a54798e5d6..6d322c734e 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java @@ -29,6 +29,7 @@ import com.google.gwt.core.ext.typeinfo.JParameter; import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; import com.google.gwt.user.rebind.SourceWriter; +import com.vaadin.shared.annotations.Delayed; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -129,6 +130,10 @@ public class RpcProxyGenerator extends Generator { writer.println(" {"); writer.indent(); + Delayed delayedAnnotation = m.getAnnotation(Delayed.class); + boolean delayed = delayedAnnotation != null; + boolean lastonly = delayed && delayedAnnotation.lastonly(); + writer.print("this.connector.getConnection().addMethodInvocationToQueue(new MethodInvocation(this.connector.getConnectorId(), \"" + requestedType.getQualifiedBinaryName() + "\", \""); writer.print(m.getName()); @@ -145,7 +150,7 @@ public class RpcProxyGenerator extends Generator { writer.print(p.getName()); } - writer.println("}), true);"); + writer.println("}), " + delayed + ", " + lastonly + ");"); writer.outdent(); writer.println("}"); diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java index 2fc9645940..cc92551846 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java @@ -32,6 +32,7 @@ import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JEnumConstant; import com.google.gwt.core.ext.typeinfo.JEnumType; import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JPackage; import com.google.gwt.core.ext.typeinfo.JPrimitiveType; import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.TypeOracleException; @@ -59,8 +60,6 @@ import com.vaadin.terminal.gwt.client.communication.SerializerMap; public class SerializerGenerator extends Generator { private static final String SUBTYPE_SEPARATOR = "___"; - private static String serializerPackageName = SerializerMap.class - .getPackage().getName(); @Override public String generate(TreeLogger logger, GeneratorContext context, @@ -75,8 +74,8 @@ public class SerializerGenerator extends Generator { String serializerClassName = getSerializerSimpleClassName(type); try { // Generate class source code - generateClass(logger, context, type, serializerPackageName, - serializerClassName); + generateClass(logger, context, type, + getSerializerPackageName(type), serializerClassName); } catch (Exception e) { logger.log(TreeLogger.ERROR, "SerializerGenerator failed for " + type.getQualifiedSourceName(), e); @@ -465,6 +464,21 @@ public class SerializerGenerator extends Generator { } public static String getFullyQualifiedSerializerClassName(JClassType type) { - return serializerPackageName + "." + getSerializerSimpleClassName(type); + return getSerializerPackageName(type) + "." + + getSerializerSimpleClassName(type); + } + + private static String getSerializerPackageName(JClassType type) { + JPackage typePackage = type.getPackage(); + if (typePackage == null) { + return SerializerMap.class.getPackage().getName(); + } else { + String packageName = typePackage.getName(); + // Dev mode classloader gets unhappy for some java packages + if (packageName.startsWith("java.")) { + packageName = "com.vaadin." + packageName; + } + return packageName; + } } } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java index dae6f2821e..1f5b301802 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; +import java.util.Map; import java.util.TreeSet; import com.google.gwt.core.ext.Generator; @@ -116,8 +117,10 @@ public class WidgetMapGenerator extends Generator { * Logger object * @param context * Generator context + * @throws UnableToCompleteException */ - private void generateClass(TreeLogger logger, GeneratorContext context) { + private void generateClass(TreeLogger logger, GeneratorContext context) + throws UnableToCompleteException { // get print writer that receives the source code PrintWriter printWriter = null; printWriter = context.tryCreate(logger, packageName, className); @@ -147,7 +150,7 @@ public class WidgetMapGenerator extends Generator { logConnectors(logger, context, connectors); // generator constructor source code - generateImplementationDetector(sourceWriter, connectors); + generateImplementationDetector(logger, sourceWriter, connectors); generateInstantiatorMethod(sourceWriter, connectors); // close generated class sourceWriter.outdent(); @@ -369,13 +372,18 @@ public class WidgetMapGenerator extends Generator { /** * + * @param logger + * logger to print messages to * @param sourceWriter * Source writer to output source code * @param paintablesHavingWidgetAnnotation + * @throws UnableToCompleteException */ private void generateImplementationDetector( + TreeLogger logger, SourceWriter sourceWriter, - Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation) { + Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation) + throws UnableToCompleteException { sourceWriter .println("public Class<? extends " + serverConnectorClassName @@ -385,8 +393,24 @@ public class WidgetMapGenerator extends Generator { sourceWriter .println("fullyQualifiedName = fullyQualifiedName.intern();"); + // Keep track of encountered mappings to detect conflicts + Map<Class<? extends ClientConnector>, Class<? extends ServerConnector>> mappings = new HashMap<Class<? extends ClientConnector>, Class<? extends ServerConnector>>(); + for (Class<? extends ServerConnector> connectorClass : paintablesHavingWidgetAnnotation) { Class<? extends ClientConnector> clientConnectorClass = getClientConnectorClass(connectorClass); + + // Check for conflicts + Class<? extends ServerConnector> prevousMapping = mappings.put( + clientConnectorClass, connectorClass); + if (prevousMapping != null) { + logger.log(Type.ERROR, + "Both " + connectorClass.getName() + " and " + + prevousMapping.getName() + + " have @Connect referring to " + + clientConnectorClass.getName() + "."); + throw new UnableToCompleteException(); + } + sourceWriter.print("if ( fullyQualifiedName == \""); sourceWriter.print(clientConnectorClass.getName()); sourceWriter.print("\" ) { ensureInstantiator(" diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index cd90403139..b4635c6d80 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -22,6 +22,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -54,9 +55,9 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.ComponentState; import com.vaadin.shared.Version; +import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; -import com.vaadin.shared.communication.UidlValue; import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage; import com.vaadin.terminal.gwt.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.terminal.gwt.client.ResourceLoader.ResourceLoadListener; @@ -132,7 +133,18 @@ public class ApplicationConnection { private final HashMap<String, String> resourcesMap = new HashMap<String, String>(); - private ArrayList<MethodInvocation> pendingInvocations = new ArrayList<MethodInvocation>(); + /** + * The pending method invocations that will be send to the server by + * {@link #sendPendingCommand}. The key is defined differently based on + * whether the method invocation is enqueued with lastonly. With lastonly + * enabled, the method signature ( {@link MethodInvocation#getLastonlyTag()} + * ) is used as the key to make enable removing a previously enqueued + * invocation. Without lastonly, an incremental id based on + * {@link #lastInvocationTag} is used to get unique values. + */ + private LinkedHashMap<String, MethodInvocation> pendingInvocations = new LinkedHashMap<String, MethodInvocation>(); + + private int lastInvocationTag = 0; private WidgetSet widgetSet; @@ -155,7 +167,7 @@ public class ApplicationConnection { private ApplicationConfiguration configuration; /** List of pending variable change bursts that must be submitted in order */ - private final ArrayList<ArrayList<MethodInvocation>> pendingBursts = new ArrayList<ArrayList<MethodInvocation>>(); + private final ArrayList<LinkedHashMap<String, MethodInvocation>> pendingBursts = new ArrayList<LinkedHashMap<String, MethodInvocation>>(); /** Timer for automatic refirect to SessionExpiredURL */ private Timer redirectTimer; @@ -888,12 +900,11 @@ public class ApplicationConnection { private void checkForPendingVariableBursts() { cleanVariableBurst(pendingInvocations); if (pendingBursts.size() > 0) { - for (Iterator<ArrayList<MethodInvocation>> iterator = pendingBursts - .iterator(); iterator.hasNext();) { - cleanVariableBurst(iterator.next()); + for (LinkedHashMap<String, MethodInvocation> pendingBurst : pendingBursts) { + cleanVariableBurst(pendingBurst); } - ArrayList<MethodInvocation> nextBurst = pendingBursts.get(0); - pendingBursts.remove(0); + LinkedHashMap<String, MethodInvocation> nextBurst = pendingBursts + .remove(0); buildAndSendVariableBurst(nextBurst, false); } } @@ -904,13 +915,15 @@ public class ApplicationConnection { * * @param variableBurst */ - private void cleanVariableBurst(ArrayList<MethodInvocation> variableBurst) { - for (int i = 1; i < variableBurst.size(); i++) { - String id = variableBurst.get(i).getConnectorId(); + private void cleanVariableBurst( + LinkedHashMap<String, MethodInvocation> variableBurst) { + Iterator<MethodInvocation> iterator = variableBurst.values().iterator(); + while (iterator.hasNext()) { + String id = iterator.next().getConnectorId(); if (!getConnectorMap().hasConnector(id) && !getConnectorMap().isDragAndDropPaintable(id)) { // variable owner does not exist anymore - variableBurst.remove(i); + iterator.remove(); VConsole.log("Removed variable from removed component: " + id); } } @@ -1462,9 +1475,12 @@ public class ApplicationConnection { .getName(), null), stateJson, state, ApplicationConnection.this); - StateChangeEvent event = GWT - .create(StateChangeEvent.class); - event.setConnector(connector); + Set<String> changedProperties = new HashSet<String>(); + addJsonFields(stateJson, changedProperties, ""); + + StateChangeEvent event = new StateChangeEvent( + connector, changedProperties); + events.add(event); } } catch (final Throwable e) { @@ -1476,6 +1492,30 @@ public class ApplicationConnection { } /** + * Recursively adds the names of all fields in all objects in the + * provided json object. + * + * @param json + * the json object to process + * @param fields + * a set of all currently added fields + * @param context + * the base name of the current object + */ + private void addJsonFields(JSONObject json, Set<String> fields, + String context) { + for (String key : json.keySet()) { + String fieldName = context + key; + fields.add(fieldName); + + JSONObject object = json.get(key).isObject(); + if (object != null) { + addJsonFields(object, fields, fieldName + "."); + } + } + } + + /** * Updates the connector hierarchy and returns a list of events that * should be fired after update of the hierarchy and the state is * done. @@ -1695,12 +1735,10 @@ public class ApplicationConnection { private void addVariableToQueue(String connectorId, String variableName, Object value, boolean immediate) { + boolean lastOnly = !immediate; // note that type is now deduced from value - // TODO could eliminate invocations of same shared variable setter - addMethodInvocationToQueue(new MethodInvocation(connectorId, - ApplicationConstants.UPDATE_VARIABLE_INTERFACE, - ApplicationConstants.UPDATE_VARIABLE_METHOD, new Object[] { - variableName, new UidlValue(value) }), immediate); + addMethodInvocationToQueue(new LegacyChangeVariablesInvocation( + connectorId, variableName, value), lastOnly, lastOnly); } /** @@ -1710,16 +1748,31 @@ public class ApplicationConnection { * * @param invocation * RPC method invocation - * @param immediate - * true to trigger sending within a short time window (possibly - * combining subsequent calls to a single request), false to let - * the framework delay sending of RPC calls and variable changes - * until the next immediate change + * @param delayed + * <code>false</code> to trigger sending within a short time + * window (possibly combining subsequent calls to a single + * request), <code>true</code> to let the framework delay sending + * of RPC calls and variable changes until the next non-delayed + * change + * @param lastonly + * <code>true</code> to remove all previously delayed invocations + * of the same method that were also enqueued with lastonly set + * to <code>true</code>. <code>false</code> to add invocation to + * the end of the queue without touching previously enqueued + * invocations. */ public void addMethodInvocationToQueue(MethodInvocation invocation, - boolean immediate) { - pendingInvocations.add(invocation); - if (immediate) { + boolean delayed, boolean lastonly) { + String tag; + if (lastonly) { + tag = invocation.getLastonlyTag(); + assert !tag.matches("\\d+") : "getLastonlyTag value must have at least one non-digit character"; + pendingInvocations.remove(tag); + } else { + tag = Integer.toString(lastInvocationTag++); + } + pendingInvocations.put(tag, invocation); + if (!delayed) { sendPendingVariableChanges(); } } @@ -1750,14 +1803,15 @@ public class ApplicationConnection { }; private boolean deferedSendPending = false; - @SuppressWarnings("unchecked") private void doSendPendingVariableChanges() { if (applicationRunning) { if (hasActiveRequest()) { // skip empty queues if there are pending bursts to be sent if (pendingInvocations.size() > 0 || pendingBursts.size() == 0) { pendingBursts.add(pendingInvocations); - pendingInvocations = new ArrayList<MethodInvocation>(); + pendingInvocations = new LinkedHashMap<String, MethodInvocation>(); + // Keep tag string short + lastInvocationTag = 0; } } else { buildAndSendVariableBurst(pendingInvocations, false); @@ -1778,17 +1832,18 @@ public class ApplicationConnection { * Should we use synchronous request? */ private void buildAndSendVariableBurst( - ArrayList<MethodInvocation> pendingInvocations, boolean forceSync) { + LinkedHashMap<String, MethodInvocation> pendingInvocations, + boolean forceSync) { final StringBuffer req = new StringBuffer(); while (!pendingInvocations.isEmpty()) { if (ApplicationConfiguration.isDebugMode()) { - Util.logVariableBurst(this, pendingInvocations); + Util.logVariableBurst(this, pendingInvocations.values()); } JSONArray reqJson = new JSONArray(); - for (MethodInvocation invocation : pendingInvocations) { + for (MethodInvocation invocation : pendingInvocations.values()) { JSONArray invocationJson = new JSONArray(); invocationJson.set(0, new JSONString(invocation.getConnectorId())); @@ -1812,6 +1867,8 @@ public class ApplicationConnection { req.append(escapeBurstContents(reqJson.toString())); pendingInvocations.clear(); + // Keep tag string short + lastInvocationTag = 0; // Append all the bursts to this synchronous request if (forceSync && !pendingBursts.isEmpty()) { pendingInvocations = pendingBursts.get(0); diff --git a/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index de2d9a9cd8..680131c70c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/client/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -139,7 +139,7 @@ public class BrowserInfo { if (browserDetails.isFirefox()) { browserIdentifier = BROWSER_FIREFOX; majorVersionClass = browserIdentifier - + browserDetails.getBrowserMajorVersion(); + + getBrowserMajorVersion(); minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion(); browserEngineClass = ENGINE_GECKO; @@ -151,21 +151,21 @@ public class BrowserInfo { } else if (browserDetails.isSafari()) { browserIdentifier = BROWSER_SAFARI; majorVersionClass = browserIdentifier - + browserDetails.getBrowserMajorVersion(); + + getBrowserMajorVersion(); minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion(); browserEngineClass = ENGINE_WEBKIT; } else if (browserDetails.isIE()) { browserIdentifier = BROWSER_IE; majorVersionClass = browserIdentifier - + browserDetails.getBrowserMajorVersion(); + + getBrowserMajorVersion(); minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion(); browserEngineClass = ENGINE_TRIDENT; } else if (browserDetails.isOpera()) { browserIdentifier = BROWSER_OPERA; majorVersionClass = browserIdentifier - + browserDetails.getBrowserMajorVersion(); + + getBrowserMajorVersion(); minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion(); browserEngineClass = ENGINE_PRESTO; @@ -222,11 +222,11 @@ public class BrowserInfo { } public boolean isIE8() { - return isIE() && browserDetails.getBrowserMajorVersion() == 8; + return isIE() && getBrowserMajorVersion() == 8; } public boolean isIE9() { - return isIE() && browserDetails.getBrowserMajorVersion() == 9; + return isIE() && getBrowserMajorVersion() == 9; } public boolean isChrome() { @@ -274,7 +274,7 @@ public class BrowserInfo { return -1; } - return browserDetails.getBrowserMajorVersion(); + return getBrowserMajorVersion(); } public float getOperaVersion() { @@ -282,7 +282,7 @@ public class BrowserInfo { return -1; } - return browserDetails.getBrowserMajorVersion(); + return getBrowserMajorVersion(); } public boolean isOpera() { @@ -290,13 +290,11 @@ public class BrowserInfo { } public boolean isOpera10() { - return browserDetails.isOpera() - && browserDetails.getBrowserMajorVersion() == 10; + return browserDetails.isOpera() && getBrowserMajorVersion() == 10; } public boolean isOpera11() { - return browserDetails.isOpera() - && browserDetails.getBrowserMajorVersion() == 11; + return browserDetails.isOpera() && getBrowserMajorVersion() == 11; } public native static String getBrowserString() @@ -387,4 +385,51 @@ public class BrowserInfo { private int getOperatingSystemMajorVersion() { return browserDetails.getOperatingSystemMajorVersion(); } + + /** + * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome + * 4, 8 for Internet Explorer 8. + * <p> + * Note that Internet Explorer 8 and newer will return the document mode so + * IE8 rendering as IE7 will return 7. + * </p> + * + * @return The major version of the browser. + */ + public int getBrowserMajorVersion() { + return browserDetails.getBrowserMajorVersion(); + } + + /** + * Returns the browser minor version e.g., 5 for Firefox 3.5. + * + * @see #getBrowserMajorVersion() + * + * @return The minor version of the browser, or -1 if not known/parsed. + */ + public int getBrowserMinorVersion() { + return browserDetails.getBrowserMinorVersion(); + } + + /** + * Checks if the browser version is newer or equal to the given major+minor + * version. + * + * @param majorVersion + * The major version to check for + * @param minorVersion + * The minor version to check for + * @return true if the browser version is newer or equal to the given + * version + */ + public boolean isBrowserVersionNewerOrEqual(int majorVersion, + int minorVersion) { + if (getBrowserMajorVersion() == majorVersion) { + // Same major + return (getBrowserMinorVersion() >= minorVersion); + } + + // Older or newer major + return (getBrowserMajorVersion() > majorVersion); + } } diff --git a/client/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java b/client/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java index 98c014b5ec..6494ae3480 100644 --- a/client/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java +++ b/client/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java @@ -267,7 +267,7 @@ public class JavaScriptConnectorHelper { } connector.getConnection().addMethodInvocationToQueue( new MethodInvocation(connector.getConnectorId(), iface, method, - parameters), true); + parameters), false, false); } private String findWildcardInterface(String method) { @@ -298,7 +298,8 @@ public class JavaScriptConnectorHelper { connector.getConnectorId(), "com.vaadin.ui.JavaScript$JavaScriptCallbackRpc", "call", new Object[] { name, new JSONArray(arguments) }); - connector.getConnection().addMethodInvocationToQueue(invocation, true); + connector.getConnection().addMethodInvocationToQueue(invocation, false, + false); } public void setNativeState(JavaScriptObject state) { diff --git a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java index ff37f04f04..8788de74bf 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java @@ -75,7 +75,7 @@ public interface ServerConnector extends Connector { String rpcInterfaceId); /** - * Adds a handler that is called whenever some part of the state has been + * Adds a handler that is called whenever any part of the state has been * updated by the server. * * @param handler @@ -86,6 +86,21 @@ public interface ServerConnector extends Connector { public HandlerRegistration addStateChangeHandler(StateChangeHandler handler); /** + * Adds a handler that is called whenever the given part of the state has + * been updated by the server. + * + * @param propertyName + * the name of the property for which the handler should be + * called + * @param handler + * The handler that should be added. + * @return A handler registration reference that can be used to unregister + * the handler + */ + public HandlerRegistration addStateChangeHandler(String propertyName, + StateChangeHandler handler); + + /** * Sends the given event to all registered handlers. * * @param event diff --git a/client/src/com/vaadin/terminal/gwt/client/Util.java b/client/src/com/vaadin/terminal/gwt/client/Util.java index 571258dbe3..96344f0792 100644 --- a/client/src/com/vaadin/terminal/gwt/client/Util.java +++ b/client/src/com/vaadin/terminal/gwt/client/Util.java @@ -874,13 +874,13 @@ public class Util { } static void logVariableBurst(ApplicationConnection c, - ArrayList<MethodInvocation> loggedBurst) { + Collection<MethodInvocation> loggedBurst) { try { VConsole.log("Variable burst to be sent to server:"); String curId = null; ArrayList<MethodInvocation> invocations = new ArrayList<MethodInvocation>(); - for (int i = 0; i < loggedBurst.size(); i++) { - String id = loggedBurst.get(i).getConnectorId(); + for (MethodInvocation methodInvocation : loggedBurst) { + String id = methodInvocation.getConnectorId(); if (curId == null) { curId = id; @@ -889,7 +889,7 @@ public class Util { invocations.clear(); curId = id; } - invocations.add(loggedBurst.get(i)); + invocations.add(methodInvocation); } if (!invocations.isEmpty()) { printConnectorInvocations(invocations, curId, c); diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/StateChangeEvent.java b/client/src/com/vaadin/terminal/gwt/client/communication/StateChangeEvent.java index e1847bdab7..8ed32bc94b 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/StateChangeEvent.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/StateChangeEvent.java @@ -16,8 +16,11 @@ package com.vaadin.terminal.gwt.client.communication; import java.io.Serializable; +import java.util.Collections; +import java.util.Set; import com.google.gwt.event.shared.EventHandler; +import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; public class StateChangeEvent extends @@ -27,12 +30,25 @@ public class StateChangeEvent extends */ public static final Type<StateChangeHandler> TYPE = new Type<StateChangeHandler>(); + private Set<String> changedProperties; + @Override public Type<StateChangeHandler> getAssociatedType() { return TYPE; } - public StateChangeEvent() { + /** + * Creates a new state change event. + * + * @param connector + * the event whose state has changed + * @param changedProperties + * a set of names of the changed properties + */ + public StateChangeEvent(ServerConnector connector, + Set<String> changedProperties) { + setConnector(connector); + this.changedProperties = changedProperties; } @Override @@ -40,7 +56,30 @@ public class StateChangeEvent extends listener.onStateChanged(this); } + /** + * Event handler that gets notified whenever any part of the state has been + * updated by the server. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ public interface StateChangeHandler extends Serializable, EventHandler { + /** + * Notifies the event handler that the state has changed. + * + * @param stateChangeEvent + * the state change event with details about the change + */ public void onStateChanged(StateChangeEvent stateChangeEvent); } + + /** + * Gets the properties that have changed. + * + * @return a set of names of the changed properties + */ + public Set<String> getChangedProperties() { + return Collections.unmodifiableSet(changedProperties); + } } diff --git a/client/src/com/vaadin/terminal/gwt/client/extensions/javascriptmanager/JavaScriptManagerConnector.java b/client/src/com/vaadin/terminal/gwt/client/extensions/javascriptmanager/JavaScriptManagerConnector.java index 5cc5911bb1..46578b0641 100644 --- a/client/src/com/vaadin/terminal/gwt/client/extensions/javascriptmanager/JavaScriptManagerConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/extensions/javascriptmanager/JavaScriptManagerConnector.java @@ -124,7 +124,7 @@ public class JavaScriptManagerConnector extends AbstractExtensionConnector { getConnection().addMethodInvocationToQueue( new MethodInvocation(getConnectorId(), "com.vaadin.ui.JavaScript$JavaScriptCallbackRpc", - "call", parameters), true); + "call", parameters), false, false); } @Override diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index 514f63fdd8..435fff8a5b 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -48,6 +48,7 @@ public abstract class AbstractConnector implements ServerConnector, private String id; private HandlerManager handlerManager; + private Map<String, HandlerManager> statePropertyHandlerManagers; private Map<String, Collection<ClientRpc>> rpcImplementations; private final boolean debugLogging = false; @@ -168,6 +169,17 @@ public abstract class AbstractConnector implements ServerConnector, if (handlerManager != null) { handlerManager.fireEvent(event); } + if (statePropertyHandlerManagers != null + && event instanceof StateChangeEvent) { + for (String property : ((StateChangeEvent) event) + .getChangedProperties()) { + HandlerManager manager = statePropertyHandlerManagers + .get(property); + if (manager != null) { + manager.fireEvent(event); + } + } + } } protected HandlerManager ensureHandlerManager() { @@ -185,6 +197,25 @@ public abstract class AbstractConnector implements ServerConnector, } @Override + public HandlerRegistration addStateChangeHandler(String propertyName, + StateChangeHandler handler) { + return ensureHandlerManager(propertyName).addHandler( + StateChangeEvent.TYPE, handler); + } + + private HandlerManager ensureHandlerManager(String propertyName) { + if (statePropertyHandlerManagers == null) { + statePropertyHandlerManagers = new HashMap<String, HandlerManager>(); + } + HandlerManager manager = statePropertyHandlerManagers.get(propertyName); + if (manager == null) { + manager = new HandlerManager(this); + statePropertyHandlerManagers.put(propertyName, manager); + } + return manager; + } + + @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { if (debugLogging) { VConsole.log("State change event for " diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java b/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java index aef21ac737..97201de297 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java @@ -42,6 +42,14 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { public static class PositionAndSize { private int left, top, width, height; + public PositionAndSize(int left, int top, int width, int height) { + super(); + setLeft(left); + setTop(top); + setWidth(width); + setHeight(height); + } + public int getLeft() { return left; } @@ -63,6 +71,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { } public void setWidth(int width) { + if (width < 0) { + width = 0; + } + this.width = width; } @@ -71,6 +83,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { } public void setHeight(int height) { + if (height < 0) { + height = 0; + } + this.height = height; } @@ -192,7 +208,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { return shadow != null; } - private void removeShim() { + private void removeShimElement() { if (shimElement != null) { shimElement.removeFromParent(); } @@ -211,7 +227,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { return isShadowEnabled() && shadow.getParentElement() != null; } - private boolean isShimAttached() { + private boolean isShimElementAttached() { return shimElement != null && shimElement.hasParentElement(); } @@ -242,11 +258,11 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { style.setMarginLeft(-adjustByRelativeLeftBodyMargin(), Unit.PX); style.setMarginTop(-adjustByRelativeTopBodyMargin(), Unit.PX); super.setPopupPosition(left, top); - sizeOrPositionUpdated(isAnimationEnabled() ? 0 : 1); + positionOrSizeUpdated(isAnimationEnabled() ? 0 : 1); } private IFrameElement getShimElement() { - if (shimElement == null) { + if (shimElement == null && needsShimElement()) { shimElement = Document.get().createIFrameElement(); // Insert shim iframe before the main overlay element. It does not @@ -318,7 +334,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { if (isAnimationEnabled()) { new ResizeAnimation().run(POPUP_PANEL_ANIMATION_DURATION); } else { - sizeOrPositionUpdated(1.0); + positionOrSizeUpdated(1.0); } } @@ -328,7 +344,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { // Always ensure shadow is removed when the overlay is removed. removeShadowIfPresent(); - removeShim(); + removeShimElement(); } @Override @@ -343,13 +359,13 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { @Override public void setWidth(String width) { super.setWidth(width); - sizeOrPositionUpdated(1.0); + positionOrSizeUpdated(1.0); } @Override public void setHeight(String height) { super.setHeight(height); - sizeOrPositionUpdated(1.0); + positionOrSizeUpdated(1.0); } /** @@ -374,8 +390,16 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * 'setHeight(String)' methods (if not calling super.setWidth/Height). * */ - public void sizeOrPositionUpdated() { - sizeOrPositionUpdated(1.0); + public void positionOrSizeUpdated() { + positionOrSizeUpdated(1.0); + } + + /** + * @deprecated Call {@link #positionOrSizeUpdated()} instead. + */ + @Deprecated + protected void updateShadowSizeAndPosition() { + positionOrSizeUpdated(); } /** @@ -388,7 +412,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { * A value between 0.0 and 1.0, indicating the progress of the * animation (0=start, 1=end). */ - private void sizeOrPositionUpdated(final double progress) { + private void positionOrSizeUpdated(final double progress) { // Don't do anything if overlay element is not attached if (!isAttached()) { return; @@ -413,18 +437,8 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { getOffsetWidth(); } - PositionAndSize positionAndSize = new PositionAndSize(); - positionAndSize.left = getActualLeft(); - positionAndSize.top = getActualTop(); - positionAndSize.width = getOffsetWidth(); - positionAndSize.height = getOffsetHeight(); - - if (positionAndSize.width < 0) { - positionAndSize.width = 0; - } - if (positionAndSize.height < 0) { - positionAndSize.height = 0; - } + PositionAndSize positionAndSize = new PositionAndSize(getActualLeft(), + getActualTop(), getOffsetWidth(), getOffsetHeight()); // Animate the size positionAndSize.setAnimationFromCenterProgress(progress); @@ -441,29 +455,31 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { // Update correct values if (isShadowEnabled()) { - updateSizeAndPosition(shadow, positionAndSize); + updatePositionAndSize(shadow, positionAndSize); DOM.setStyleAttribute(shadow, "zIndex", zIndex); DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none" : ""); } - updateSizeAndPosition((Element) Element.as(getShimElement()), - positionAndSize); + if (needsShimElement()) { + updatePositionAndSize((Element) Element.as(getShimElement()), + positionAndSize); + } // Opera fix, part 2 (ticket #2704) if (BrowserInfo.get().isOpera() && isShadowEnabled()) { // We'll fix the height of all the middle elements DOM.getChild(shadow, 3) - .getStyle() - .setPropertyPx("height", - DOM.getChild(shadow, 3).getOffsetHeight()); + .getStyle() + .setPropertyPx("height", + DOM.getChild(shadow, 3).getOffsetHeight()); DOM.getChild(shadow, 4) - .getStyle() - .setPropertyPx("height", - DOM.getChild(shadow, 4).getOffsetHeight()); + .getStyle() + .setPropertyPx("height", + DOM.getChild(shadow, 4).getOffsetHeight()); DOM.getChild(shadow, 5) - .getStyle() - .setPropertyPx("height", - DOM.getChild(shadow, 5).getOffsetHeight()); + .getStyle() + .setPropertyPx("height", + DOM.getChild(shadow, 5).getOffsetHeight()); } // Attach to dom if not there already @@ -471,25 +487,37 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> { RootPanel.get().getElement().insertBefore(shadow, getElement()); sinkShadowEvents(); } - if (!isShimAttached()) { + if (needsShimElement() && !isShimElementAttached()) { RootPanel.get().getElement() - .insertBefore(shimElement, getElement()); + .insertBefore(getShimElement(), getElement()); } } - private void updateSizeAndPosition(Element e, + /** + * Returns true if we should add a shim iframe below the overlay to deal + * with zindex issues with PDFs and applets. Can be overriden to disable + * shim iframes if they are not needed. + * + * @return true if a shim iframe should be added, false otherwise + */ + protected boolean needsShimElement() { + BrowserInfo info = BrowserInfo.get(); + return info.isIE() && info.isBrowserVersionNewerOrEqual(8, 0); + } + + private void updatePositionAndSize(Element e, PositionAndSize positionAndSize) { - e.getStyle().setLeft(positionAndSize.left, Unit.PX); - e.getStyle().setTop(positionAndSize.top, Unit.PX); - e.getStyle().setWidth(positionAndSize.width, Unit.PX); - e.getStyle().setHeight(positionAndSize.height, Unit.PX); + e.getStyle().setLeft(positionAndSize.getLeft(), Unit.PX); + e.getStyle().setTop(positionAndSize.getTop(), Unit.PX); + e.getStyle().setWidth(positionAndSize.getWidth(), Unit.PX); + e.getStyle().setHeight(positionAndSize.getHeight(), Unit.PX); } protected class ResizeAnimation extends Animation { @Override protected void onUpdate(double progress) { - sizeOrPositionUpdated(progress); + positionOrSizeUpdated(progress); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java index 59e187014c..59f90a9840 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java @@ -16,6 +16,8 @@ package com.vaadin.terminal.gwt.client.ui.button; +import java.util.Set; + import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -34,6 +36,7 @@ import com.vaadin.terminal.gwt.client.EventHelper; import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; import com.vaadin.terminal.gwt.client.communication.RpcProxy; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; import com.vaadin.terminal.gwt.client.ui.Icon; import com.vaadin.ui.Button; @@ -59,6 +62,47 @@ public class ButtonConnector extends AbstractComponentConnector implements super.init(); getWidget().addClickHandler(this); getWidget().client = getConnection(); + addStateChangeHandler("errorMessage", new StateChangeHandler() { + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + if (null != getState().getErrorMessage()) { + if (getWidget().errorIndicatorElement == null) { + getWidget().errorIndicatorElement = DOM.createSpan(); + getWidget().errorIndicatorElement + .setClassName("v-errorindicator"); + } + getWidget().wrapper.insertBefore( + getWidget().errorIndicatorElement, + getWidget().captionElement); + + } else if (getWidget().errorIndicatorElement != null) { + getWidget().wrapper + .removeChild(getWidget().errorIndicatorElement); + getWidget().errorIndicatorElement = null; + } + } + }); + + addStateChangeHandler("icon", new StateChangeHandler() { + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + if (getState().getIcon() != null) { + if (getWidget().icon == null) { + getWidget().icon = new Icon(getConnection()); + getWidget().wrapper.insertBefore( + getWidget().icon.getElement(), + getWidget().captionElement); + } + getWidget().icon.setUri(getState().getIcon().getURL()); + } else { + if (getWidget().icon != null) { + getWidget().wrapper.removeChild(getWidget().icon + .getElement()); + getWidget().icon = null; + } + } + } + }); } @Override @@ -68,39 +112,15 @@ public class ButtonConnector extends AbstractComponentConnector implements focusHandlerRegistration); blurHandlerRegistration = EventHelper.updateBlurHandler(this, blurHandlerRegistration); - // Set text - if (getState().isHtmlContentAllowed()) { - getWidget().setHtml(getState().getCaption()); - } else { - getWidget().setText(getState().getCaption()); - } - // handle error - if (null != getState().getErrorMessage()) { - if (getWidget().errorIndicatorElement == null) { - getWidget().errorIndicatorElement = DOM.createSpan(); - getWidget().errorIndicatorElement - .setClassName("v-errorindicator"); - } - getWidget().wrapper.insertBefore(getWidget().errorIndicatorElement, - getWidget().captionElement); - - } else if (getWidget().errorIndicatorElement != null) { - getWidget().wrapper.removeChild(getWidget().errorIndicatorElement); - getWidget().errorIndicatorElement = null; - } - - if (getState().getIcon() != null) { - if (getWidget().icon == null) { - getWidget().icon = new Icon(getConnection()); - getWidget().wrapper.insertBefore(getWidget().icon.getElement(), - getWidget().captionElement); - } - getWidget().icon.setUri(getState().getIcon().getURL()); - } else { - if (getWidget().icon != null) { - getWidget().wrapper.removeChild(getWidget().icon.getElement()); - getWidget().icon = null; + Set<String> changedProperties = stateChangeEvent.getChangedProperties(); + if (changedProperties.contains("caption") + || changedProperties.contains("htmlContentAllowed")) { + // Set text + if (getState().isHtmlContentAllowed()) { + getWidget().setHtml(getState().getCaption()); + } else { + getWidget().setText(getState().getCaption()); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java index 47c2049a67..2e51d717a4 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java @@ -23,7 +23,6 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.LayoutClickRpc; -import com.vaadin.shared.ui.VMarginInfo; import com.vaadin.shared.ui.csslayout.CssLayoutServerRpc; import com.vaadin.shared.ui.csslayout.CssLayoutState; import com.vaadin.terminal.gwt.client.BrowserInfo; @@ -75,9 +74,6 @@ public class CssLayoutConnector extends AbstractLayoutConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - getWidget().setMarginStyles( - new VMarginInfo(getState().getMarginsBitmask())); - for (ComponentConnector child : getChildComponents()) { if (!getState().getChildCss().containsKey(child)) { continue; diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java index 813e95e3ed..e66b1c4208 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java @@ -21,8 +21,6 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.shared.ui.VMarginInfo; -import com.vaadin.terminal.gwt.client.StyleConstants; public class VCssLayout extends SimplePanel { public static final String TAGNAME = "csslayout"; @@ -64,21 +62,4 @@ public class VCssLayout extends SimplePanel { } - /** - * Sets CSS classes for margin based on the given parameters. - * - * @param margins - * A {@link VMarginInfo} object that provides info on - * top/left/bottom/right margins - */ - protected void setMarginStyles(VMarginInfo margins) { - setStyleName(margin, VCssLayout.CLASSNAME + "-" - + StyleConstants.MARGIN_TOP, margins.hasTop()); - setStyleName(margin, VCssLayout.CLASSNAME + "-" - + StyleConstants.MARGIN_RIGHT, margins.hasRight()); - setStyleName(margin, VCssLayout.CLASSNAME + "-" - + StyleConstants.MARGIN_BOTTOM, margins.hasBottom()); - setStyleName(margin, VCssLayout.CLASSNAME + "-" - + StyleConstants.MARGIN_LEFT, margins.hasLeft()); - } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java index 7d5edfadf5..cbe06244af 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java @@ -18,7 +18,7 @@ package com.vaadin.terminal.gwt.client.ui.formlayout; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent; @@ -46,7 +46,7 @@ public class FormLayoutConnector extends AbstractLayoutConnector { VFormLayoutTable formLayoutTable = getWidget().table; - formLayoutTable.setMargins(new VMarginInfo(getState() + formLayoutTable.setMargins(new MarginInfo(getState() .getMarginsBitmask())); formLayoutTable.setSpacing(getState().isSpacing()); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java index d3ce6f3d3f..7f211aaf9c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java @@ -29,7 +29,7 @@ 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.shared.ComponentState; -import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.ComponentConnector; @@ -112,7 +112,7 @@ public class VFormLayout extends SimplePanel { } } - public void setMargins(VMarginInfo margins) { + public void setMargins(MarginInfo margins) { Element margin = getElement(); setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins.hasTop()); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java index 520afb778d..9a2732e408 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java @@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.ui.AlignmentInfo; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.LayoutClickRpc; -import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc; import com.vaadin.shared.ui.gridlayout.GridLayoutState; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -163,7 +163,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector layout.colExpandRatioArray = uidl.getIntArrayAttribute("colExpand"); layout.rowExpandRatioArray = uidl.getIntArrayAttribute("rowExpand"); - layout.updateMarginStyleNames(new VMarginInfo(getState() + layout.updateMarginStyleNames(new MarginInfo(getState() .getMarginsBitmask())); layout.updateSpacingStyleName(getState().isSpacing()); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java index 25d7de6ee6..ef44964da7 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java @@ -29,7 +29,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.ui.AlignmentInfo; -import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.ConnectorMap; @@ -677,7 +677,7 @@ public class VGridLayout extends ComplexPanel { } } - void updateMarginStyleNames(VMarginInfo marginInfo) { + void updateMarginStyleNames(MarginInfo marginInfo) { togglePrefixedStyleName("margin-top", marginInfo.hasTop()); togglePrefixedStyleName("margin-right", marginInfo.hasRight()); togglePrefixedStyleName("margin-bottom", marginInfo.hasBottom()); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java index c4bbcd34f7..f2b8361f2b 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java @@ -17,6 +17,7 @@ package com.vaadin.terminal.gwt.client.ui.link; import com.google.gwt.user.client.DOM; +import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.Connect; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; @@ -57,12 +58,12 @@ public class LinkConnector extends AbstractComponentConnector implements if (uidl.hasAttribute("border")) { if ("none".equals(uidl.getStringAttribute("border"))) { - getWidget().borderStyle = VLink.BORDER_STYLE_NONE; + getWidget().borderStyle = BorderStyle.NONE; } else { - getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL; + getWidget().borderStyle = BorderStyle.MINIMAL; } } else { - getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT; + getWidget().borderStyle = BorderStyle.DEFAULT; } getWidget().targetHeight = uidl.hasAttribute("targetHeight") ? uidl diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java b/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java index e312d4d489..b0e44c9d13 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java @@ -23,6 +23,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.HTML; +import com.vaadin.shared.ui.BorderStyle; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.ui.Icon; @@ -31,15 +32,20 @@ public class VLink extends HTML implements ClickHandler { public static final String CLASSNAME = "v-link"; - protected static final int BORDER_STYLE_DEFAULT = 0; - protected static final int BORDER_STYLE_MINIMAL = 1; - protected static final int BORDER_STYLE_NONE = 2; + @Deprecated + protected static final BorderStyle BORDER_STYLE_DEFAULT = BorderStyle.DEFAULT; + + @Deprecated + protected static final BorderStyle BORDER_STYLE_MINIMAL = BorderStyle.MINIMAL; + + @Deprecated + protected static final BorderStyle BORDER_STYLE_NONE = BorderStyle.NONE; protected String src; protected String target; - protected int borderStyle = BORDER_STYLE_DEFAULT; + protected BorderStyle borderStyle = BorderStyle.DEFAULT; protected boolean enabled; @@ -73,10 +79,10 @@ public class VLink extends HTML implements ClickHandler { } String features; switch (borderStyle) { - case BORDER_STYLE_NONE: + case NONE: features = "menubar=no,location=no,status=no"; break; - case BORDER_STYLE_MINIMAL: + case MINIMAL: features = "menubar=yes,location=no,status=no"; break; default: diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java b/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java index 9f17b81691..fe47fcca66 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/menubar/VMenuBar.java @@ -56,8 +56,8 @@ import com.vaadin.terminal.gwt.client.ui.VLazyExecutor; import com.vaadin.terminal.gwt.client.ui.VOverlay; public class VMenuBar extends SimpleFocusablePanel implements - CloseHandler<PopupPanel>, KeyPressHandler, KeyDownHandler, - FocusHandler, SubPartAware { +CloseHandler<PopupPanel>, KeyPressHandler, KeyDownHandler, +FocusHandler, SubPartAware { // The hierarchy of VMenuBar is a bit weird as VMenuBar is the Paintable, // used for the root menu but also used for the sub menus. @@ -94,11 +94,11 @@ public class VMenuBar extends SimpleFocusablePanel implements private VLazyExecutor iconLoadedExecutioner = new VLazyExecutor(100, new ScheduledCommand() { - @Override - public void execute() { - iLayout(true); - } - }); + @Override + public void execute() { + iLayout(true); + } + }); boolean openRootOnHover; @@ -188,7 +188,7 @@ public class VMenuBar extends SimpleFocusablePanel implements itemHTML.append("<img src=\"" + Util.escapeAttribute(client.translateVaadinUri(item .getStringAttribute("icon"))) + "\" class=\"" - + Icon.CLASSNAME + "\" alt=\"\" />"); + + Icon.CLASSNAME + "\" alt=\"\" />"); } String itemText = item.getStringAttribute("text"); if (!htmlContentAllowed) { @@ -606,7 +606,7 @@ public class VMenuBar extends SimpleFocusablePanel implements // popup style.setWidth(contentWidth + Util.getNativeScrollbarSize(), Unit.PX); - popup.sizeOrPositionUpdated(); + popup.positionOrSizeUpdated(); } } return top; diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java index 451e6badbe..6e253c9137 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java @@ -168,7 +168,7 @@ public class VNotification extends VOverlay { super.show(); notifications.add(this); setPosition(position); - sizeOrPositionUpdated(); + positionOrSizeUpdated(); /** * Android 4 fails to render notifications correctly without a little * nudge (#8551) diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 5da01bf127..122547ddb4 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -23,7 +23,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.ui.AlignmentInfo; import com.vaadin.shared.ui.LayoutClickRpc; -import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState; import com.vaadin.terminal.gwt.client.ComponentConnector; @@ -133,9 +133,8 @@ public abstract class AbstractOrderedLayoutConnector extends slot.setExpandRatio(expandRatio); } - layout.updateMarginStyleNames(new VMarginInfo(getState() + layout.updateMarginStyleNames(new MarginInfo(getState() .getMarginsBitmask())); - layout.updateSpacingStyleName(getState().isSpacing()); getLayoutManager().setNeedsLayout(this); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java index ec2c4afa97..ee55bc07ba 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java @@ -27,7 +27,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.WidgetCollection; -import com.vaadin.shared.ui.VMarginInfo; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.terminal.gwt.client.VCaption; import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot; @@ -75,7 +75,7 @@ public class VMeasuringOrderedLayout extends ComplexPanel { } } - void updateMarginStyleNames(VMarginInfo marginInfo) { + void updateMarginStyleNames(MarginInfo marginInfo) { togglePrefixedStyleName("margin-top", marginInfo.hasTop()); togglePrefixedStyleName("margin-right", marginInfo.hasRight()); togglePrefixedStyleName("margin-bottom", marginInfo.hasBottom()); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java index 39702e6ba0..1759889a1b 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java @@ -23,6 +23,8 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; @@ -84,6 +86,16 @@ public class RootConnector extends AbstractComponentContainerConnector com.google.gwt.user.client.Window.setTitle(title); } }); + getWidget().addResizeHandler(new ResizeHandler() { + @Override + public void onResize(ResizeEvent event) { + rpc.resize(event.getHeight(), event.getWidth(), + Window.getClientWidth(), Window.getClientHeight()); + if (getState().isImmediate()) { + getConnection().sendPendingVariableChanges(); + } + } + }); } @Override diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java index a473bf4846..162e7c55a8 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; +import com.google.gwt.event.logical.shared.HasResizeHandlers; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; @@ -50,7 +51,8 @@ import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; * */ public class VRoot extends SimplePanel implements ResizeHandler, - Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable { + Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable, + HasResizeHandlers { private static final String CLASSNAME = "v-view"; @@ -401,16 +403,7 @@ public class VRoot extends SimplePanel implements ResizeHandler, int viewHeight = parentElement.getClientHeight(); int viewWidth = parentElement.getClientWidth(); - connection.updateVariable(id, "height", viewHeight, false); - connection.updateVariable(id, "width", viewWidth, false); - - int windowWidth = Window.getClientWidth(); - int windowHeight = Window.getClientHeight(); - - connection.updateVariable(id, RootConstants.BROWSER_WIDTH_VAR, - windowWidth, false); - connection.updateVariable(id, RootConstants.BROWSER_HEIGHT_VAR, - windowHeight, immediate); + ResizeEvent.fire(this, viewWidth, viewHeight); } public native static void goTo(String url) @@ -458,4 +451,9 @@ public class VRoot extends SimplePanel implements ResizeHandler, touchScrollHandler.addElement(getElement()); } + @Override + public HandlerRegistration addResizeHandler(ResizeHandler resizeHandler) { + return addHandler(resizeHandler, ResizeEvent.getType()); + } + } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java b/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java index aa7da488d8..345eebc8aa 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/table/VScrollTable.java @@ -4122,8 +4122,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets, row.addStyleName("v-selected"); } tBodyElement.appendChild(row.getElement()); - adopt(row); + // Add to renderedRows before adopt so iterator() will return also + // this row if called in an attach handler (#9264) renderedRows.add(row); + adopt(row); } private void insertRowAt(VScrollTableRow row, int index) { @@ -5780,16 +5782,39 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Hey IE, are you really sure about this? availW = scrollBody.getAvailableWidth(); int visibleCellCount = tHead.getVisibleCellCount(); - availW -= scrollBody.getCellExtraWidth() * visibleCellCount; + int totalExtraWidth = scrollBody.getCellExtraWidth() + * visibleCellCount; if (willHaveScrollbars()) { - availW -= Util.getNativeScrollbarSize(); + totalExtraWidth += Util.getNativeScrollbarSize(); } + availW -= totalExtraWidth; + int forceScrollBodyWidth = -1; int extraSpace = availW - usedMinimumWidth; if (extraSpace < 0) { + if (getTotalRows() == 0) { + /* + * Too wide header combined with no rows in the table. + * + * No horizontal scrollbars would be displayed because + * there's no rows that grows too wide causing the + * scrollBody container div to overflow. Must explicitely + * force a width to a scrollbar. (see #9187) + */ + forceScrollBodyWidth = usedMinimumWidth + totalExtraWidth; + } extraSpace = 0; } + if (forceScrollBodyWidth > 0) { + scrollBody.container.getStyle().setWidth(forceScrollBodyWidth, + Unit.PX); + } else { + // Clear width that might have been set to force horizontal + // scrolling if there are no rows + scrollBody.container.getStyle().clearWidth(); + } + int totalUndefinedNaturalWidths = usedMinimumWidth - totalExplicitColumnsWidths; diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java index e061cda1fa..e1df1ba0db 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/VTextArea.java @@ -19,6 +19,10 @@ package com.vaadin.terminal.gwt.client.ui.textarea; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Style.Overflow; import com.google.gwt.dom.client.TextAreaElement; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; +import com.google.gwt.event.dom.client.KeyUpEvent; +import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; @@ -38,10 +42,17 @@ import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; public class VTextArea extends VTextField { public static final String CLASSNAME = "v-textarea"; private boolean wordwrap = true; + private MaxLengthHandler maxLengthHandler = new MaxLengthHandler(); + private boolean browserSupportsMaxLengthAttribute = browserSupportsMaxLengthAttribute(); public VTextArea() { super(DOM.createTextArea()); setStyleName(CLASSNAME); + if (!browserSupportsMaxLengthAttribute) { + addKeyUpHandler(maxLengthHandler); + addChangeHandler(maxLengthHandler); + sinkEvents(Event.ONPASTE); + } } public TextAreaElement getTextAreaElement() { @@ -52,22 +63,28 @@ public class VTextArea extends VTextField { getTextAreaElement().setRows(rows); } - @Override - protected void setMaxLength(int newMaxLength) { - super.setMaxLength(newMaxLength); + private class MaxLengthHandler implements KeyUpHandler, ChangeHandler { - boolean hasMaxLength = (newMaxLength >= 0); + @Override + public void onKeyUp(KeyUpEvent event) { + enforceMaxLength(); + } - if (hasMaxLength) { - sinkEvents(Event.ONKEYUP); - } else { - unsinkEvents(Event.ONKEYUP); + public void onPaste(Event event) { + enforceMaxLength(); } + + @Override + public void onChange(ChangeEvent event) { + // Opera does not support paste events so this enforces max length + // for Opera. + enforceMaxLength(); + } + } - @Override - public void onBrowserEvent(Event event) { - if (getMaxLength() >= 0 && event.getTypeInt() == Event.ONKEYUP) { + protected void enforceMaxLength() { + if (getMaxLength() >= 0) { Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { @@ -77,9 +94,45 @@ public class VTextArea extends VTextField { } }); } + } + + protected boolean browserSupportsMaxLengthAttribute() { + BrowserInfo info = BrowserInfo.get(); + if (info.isFirefox() && info.isBrowserVersionNewerOrEqual(4, 0)) { + return true; + } + if (info.isSafari() && info.isBrowserVersionNewerOrEqual(5, 0)) { + return true; + } + if (info.isIE() && info.isBrowserVersionNewerOrEqual(10, 0)) { + return true; + } + if (info.isAndroid() && info.isBrowserVersionNewerOrEqual(2, 3)) { + return true; + } + return false; + } + + @Override + protected void updateMaxLength(int maxLength) { + if (browserSupportsMaxLengthAttribute) { + super.updateMaxLength(maxLength); + } else { + // Events handled by MaxLengthHandler. This call enforces max length + // when the max length value has changed + enforceMaxLength(); + } + } + + @Override + public void onBrowserEvent(Event event) { super.onBrowserEvent(event); + if (event.getTypeInt() == Event.ONPASTE) { + maxLengthHandler.onPaste(event); + } } + @Override public int getCursorPos() { // This is needed so that TextBoxImplIE6 is used to return the correct diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java b/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java index b00210cdd2..8f07c67c96 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/textfield/VTextField.java @@ -44,7 +44,7 @@ import com.vaadin.terminal.gwt.client.ui.Field; * */ public class VTextField extends TextBoxBase implements Field, ChangeHandler, - FocusHandler, BlurHandler, KeyDownHandler { +FocusHandler, BlurHandler, KeyDownHandler { /** * The input node CSS classname. @@ -114,7 +114,7 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler, if (listenTextChangeEvents && (event.getTypeInt() & TEXTCHANGE_EVENTS) == event - .getTypeInt()) { + .getTypeInt()) { deferTextChangeEvent(); } @@ -261,12 +261,32 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler, } protected void setMaxLength(int newMaxLength) { - if (newMaxLength >= 0) { + if (newMaxLength >= 0 && newMaxLength != maxLength) { maxLength = newMaxLength; - } else { + updateMaxLength(maxLength); + } else if (maxLength != -1) { maxLength = -1; + updateMaxLength(maxLength); + } + + } + + /** + * This method is reponsible for updating the DOM or otherwise ensuring that + * the given max length is enforced. Called when the max length for the + * field has changed. + * + * @param maxLength + * The new max length + */ + protected void updateMaxLength(int maxLength) { + if (maxLength >= 0) { + getElement().setPropertyInt("maxLength", maxLength); + } else { + getElement().removeAttribute("maxLength"); + } - setMaxLengthToElement(newMaxLength); + setMaxLengthToElement(maxLength); } protected void setMaxLengthToElement(int newMaxLength) { diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java b/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java index 9fbaa1d8bf..40c5e4b8af 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/tree/VTree.java @@ -79,8 +79,8 @@ import com.vaadin.terminal.gwt.client.ui.dd.VTransferable; * */ public class VTree extends FocusElementPanel implements VHasDropHandler, - FocusHandler, BlurHandler, KeyPressHandler, KeyDownHandler, - SubPartAware, ActionOwner { +FocusHandler, BlurHandler, KeyPressHandler, KeyDownHandler, +SubPartAware, ActionOwner { public static final String CLASSNAME = "v-tree"; @@ -137,12 +137,12 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, public VLazyExecutor iconLoaded = new VLazyExecutor(50, new ScheduledCommand() { - @Override - public void execute() { - Util.notifyParentOfSizeChange(VTree.this, true); - } + @Override + public void execute() { + Util.notifyParentOfSizeChange(VTree.this, true); + } - }); + }); public VTree() { super(); @@ -601,7 +601,8 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, focus(); } - ScheduledCommand command = new ScheduledCommand() { + executeEventCommand(new ScheduledCommand() { + @Override public void execute() { @@ -636,17 +637,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, } } } - }; - - if (BrowserInfo.get().isWebkit() && !treeHasFocus) { - /* - * Safari may need to wait for focus. See FocusImplSafari. - */ - // VConsole.log("Deferring click handling to let webkit gain focus..."); - Scheduler.get().scheduleDeferred(command); - } else { - command.execute(); - } + }); return true; } @@ -677,7 +668,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, && client.hasEventListeners(VTree.this, TreeConstants.ITEM_CLICK_EVENT_ID) - && (type == Event.ONDBLCLICK || type == Event.ONMOUSEUP)) { + && (type == Event.ONDBLCLICK || type == Event.ONMOUSEUP)) { fireClick(event); } if (type == Event.ONCLICK) { @@ -709,7 +700,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, .getEventTarget().cast())) { if (dragMode > 0 && (type == Event.ONTOUCHSTART || event - .getButton() == NativeEvent.BUTTON_LEFT)) { + .getButton() == NativeEvent.BUTTON_LEFT)) { mouseDownEvent = event; // save event for possible // dd operation if (type == Event.ONMOUSEDOWN) { @@ -790,9 +781,12 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, focus(); } } + final MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(evt); - ScheduledCommand command = new ScheduledCommand() { + + executeEventCommand(new ScheduledCommand() { + @Override public void execute() { // Determine if we should send the event immediately to the @@ -820,14 +814,18 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, client.updateVariable(paintableId, "clickEvent", details.toString(), sendClickEventNow); } - }; - if (treeHasFocus) { - command.execute(); - } else { - /* - * Webkits need a deferring due to FocusImplSafari uses timeout - */ + }); + } + + /* + * Must wait for Safari to focus before sending click and value change + * events (see #6373, #6374) + */ + private void executeEventCommand(ScheduledCommand command) { + if (BrowserInfo.get().isWebkit() && !treeHasFocus) { Scheduler.get().scheduleDeferred(command); + } else { + command.execute(); } } @@ -1723,7 +1721,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, selectNode( focusedNode, (!isMultiselect || multiSelectMode == MULTISELECT_MODE_SIMPLE) - && selectable); + && selectable); } else { deselectNode(focusedNode); } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java b/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java index a8621190ae..909acdf85f 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/treetable/VTreeTable.java @@ -188,8 +188,7 @@ public class VTreeTable extends VScrollTable { if (isTreeCellAdded) { return false; } - return curColIndex == colIndexOfHierarchy - + (showRowHeaders ? 1 : 0); + return curColIndex == getHierarchyColumnIndex(); } @Override @@ -227,6 +226,23 @@ public class VTreeTable extends VScrollTable { super.onAttach(); if (getIndentWidth() < 0) { detectIndent(this); + // If we detect indent here then the size of the hierarchy + // column is still wrong as it has been set when the indent + // was not known. + int w = getCellWidthFromDom(getHierarchyColumnIndex()); + if (w >= 0) { + setColWidth(getHierarchyColumnIndex(), w); + } + } + } + + private int getCellWidthFromDom(int cellIndex) { + final Element cell = DOM.getChild(getElement(), cellIndex); + String w = cell.getStyle().getProperty("width"); + if (w == null || "".equals(w) || !w.endsWith("px")) { + return -1; + } else { + return Integer.parseInt(w.substring(0, w.length() - 2)); } } @@ -242,14 +258,21 @@ public class VTreeTable extends VScrollTable { @Override protected void setCellWidth(int cellIx, int width) { - if (cellIx == colIndexOfHierarchy + (showRowHeaders ? 1 : 0)) { + if (cellIx == getHierarchyColumnIndex()) { // take indentation padding into account if this is the // hierarchy column - width = Math.max(width - getIndent(), 0); + int indent = getIndent(); + if (indent != -1) { + width = Math.max(width - getIndent(), 0); + } } super.setCellWidth(cellIx, width); } + private int getHierarchyColumnIndex() { + return colIndexOfHierarchy + (showRowHeaders ? 1 : 0); + } + private int getIndent() { return (depth + 1) * getIndentWidth(); } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java index a1bab91618..3ee266b944 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java @@ -46,8 +46,8 @@ import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren; @Connect(value = com.vaadin.ui.Window.class) public class WindowConnector extends AbstractComponentContainerConnector - implements Paintable, BeforeShortcutActionListener, - SimpleManagedLayout, PostLayoutListener, MayScrollChildren { +implements Paintable, BeforeShortcutActionListener, +SimpleManagedLayout, PostLayoutListener, MayScrollChildren { private ClickEventHandler clickEventHandler = new ClickEventHandler(this) { @Override @@ -102,7 +102,7 @@ public class WindowConnector extends AbstractComponentContainerConnector } if (!getWidget().isAttached()) { getWidget().setVisible(false); // hide until - // possible centering + // possible centering getWidget().show(); } if (getState().isResizable() != getWidget().resizable) { @@ -299,7 +299,7 @@ public class WindowConnector extends AbstractComponentContainerConnector if (window.centered) { window.center(); } - window.sizeOrPositionUpdated(); + window.positionOrSizeUpdated(); } @Override diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index d4768abfb4..c832645405 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -57,6 +58,7 @@ import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.CombinedRequest; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.RequestHandler; +import com.vaadin.terminal.RootProvider; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.WrappedRequest; @@ -504,6 +506,8 @@ public class Application implements Terminal.ErrorListener, Serializable { */ private Set<Integer> initedRoots = new HashSet<Integer>(); + private List<RootProvider> rootProviders = new LinkedList<RootProvider>(); + /** * Gets the user of the application. * @@ -1874,55 +1878,21 @@ public class Application implements Terminal.ErrorListener, Serializable { */ protected Root getRoot(WrappedRequest request) throws RootRequiresMoreInformationException { - String rootClassName = getRootClassName(request); - try { - ClassLoader classLoader = request.getDeploymentConfiguration() - .getClassLoader(); - if (classLoader == null) { - classLoader = getClass().getClassLoader(); - } - Class<? extends Root> rootClass = Class.forName(rootClassName, - true, classLoader).asSubclass(Root.class); - try { - Root root = rootClass.newInstance(); - return root; - } catch (Exception e) { - throw new RuntimeException("Could not instantiate root class " - + rootClassName, e); + + // Iterate in reverse order - test check newest provider first + for (int i = rootProviders.size() - 1; i >= 0; i--) { + RootProvider provider = rootProviders.get(i); + + Class<? extends Root> rootClass = provider.getRootClass(this, + request); + + if (rootClass != null) { + return provider.instantiateRoot(this, rootClass, request); } - } catch (ClassNotFoundException e) { - throw new RuntimeException("Could not load root class " - + rootClassName, e); } - } - /** - * Provides the name of the <code>Root</code> class that should be used for - * a request. The class must have an accessible no-args constructor. - * <p> - * The default implementation uses the {@value #ROOT_PARAMETER} parameter - * from web.xml. - * </p> - * <p> - * This method is mainly used by the default implementation of - * {@link #getRoot(WrappedRequest)}. If you override that method with your - * own functionality, the results of this method might not be used. - * </p> - * - * @param request - * the request for which a new root is required - * @return the name of the root class to use - * - * @since 7.0 - */ - protected String getRootClassName(WrappedRequest request) { - Object rootClassNameObj = getProperties().get(ROOT_PARAMETER); - if (rootClassNameObj instanceof String) { - return (String) rootClassNameObj; - } else { - throw new RuntimeException("No " + ROOT_PARAMETER - + " defined in web.xml"); - } + throw new RuntimeException( + "No root providers available or providers are not able to find root instance"); } /** @@ -2170,6 +2140,14 @@ public class Application implements Terminal.ErrorListener, Serializable { return configuration.isProductionMode(); } + public void addRootProvider(RootProvider rootProvider) { + rootProviders.add(rootProvider); + } + + public void removeRootProvider(RootProvider rootProvider) { + rootProviders.remove(rootProvider); + } + /** * Finds the {@link Root} to which a particular request belongs. If the * request originates from an existing Root, that root is returned. In other diff --git a/server/src/com/vaadin/data/Buffered.java b/server/src/com/vaadin/data/Buffered.java index 5461d34fbd..2472524bbc 100644 --- a/server/src/com/vaadin/data/Buffered.java +++ b/server/src/com/vaadin/data/Buffered.java @@ -83,8 +83,8 @@ public interface Buffered extends Serializable { * * @return <code>true</code> if the object is in write-through mode, * <code>false</code> if it's not. - * @deprecated Use {@link #setBuffered(boolean)} instead. Note that - * setReadThrough(true), setWriteThrough(true) equals + * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note + * that setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ @Deprecated @@ -105,8 +105,8 @@ public interface Buffered extends Serializable { * If the implicit commit operation fails because of a * validation error. * - * @deprecated Use {@link #setBuffered(boolean)} instead. Note that - * setReadThrough(true), setWriteThrough(true) equals + * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note + * that setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ @Deprecated @@ -126,8 +126,8 @@ public interface Buffered extends Serializable { * * @return <code>true</code> if the object is in read-through mode, * <code>false</code> if it's not. - * @deprecated Use {@link #isBuffered(boolean)} instead. Note that - * setReadThrough(true), setWriteThrough(true) equals + * @deprecated As of 7.0, use {@link #isBuffered(boolean)} instead. Note + * that setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ @Deprecated @@ -145,8 +145,8 @@ public interface Buffered extends Serializable { * @throws SourceException * If the operation fails because of an exception is thrown by * the data source. The cause is included in the exception. - * @deprecated Use {@link #setBuffered(boolean)} instead. Note that - * setReadThrough(true), setWriteThrough(true) equals + * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note + * that setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ @Deprecated diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java index 3e55633574..0146c92b5c 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java @@ -20,6 +20,7 @@ import java.sql.Time; import java.sql.Timestamp; import com.vaadin.data.Property; +import com.vaadin.data.util.converter.Converter.ConversionException; /** * ColumnProperty represents the value of one column in a RowItem. In addition @@ -47,6 +48,7 @@ final public class ColumnProperty implements Property { private boolean modified; private boolean versionColumn; + private boolean primaryKey = false; /** * Prevent instantiation without required parameters. @@ -55,9 +57,50 @@ final public class ColumnProperty implements Property { private ColumnProperty() { } + /** + * Deprecated constructor for ColumnProperty. If this is used the primary + * keys are not identified correctly in some cases for some databases (i.e. + * Oracle). See http://dev.vaadin.com/ticket/9145. + * + * @param propertyId + * @param readOnly + * @param allowReadOnlyChange + * @param nullable + * @param value + * @param type + * + * @deprecated + */ + @Deprecated public ColumnProperty(String propertyId, boolean readOnly, boolean allowReadOnlyChange, boolean nullable, Object value, Class<?> type) { + this(propertyId, readOnly, allowReadOnlyChange, nullable, false, value, + type); + } + + /** + * Creates a new ColumnProperty instance. + * + * @param propertyId + * The ID of this property. + * @param readOnly + * Whether this property is read-only. + * @param allowReadOnlyChange + * Whether the read-only status of this property can be changed. + * @param nullable + * Whether this property accepts null values. + * @param primaryKey + * Whether this property corresponds to a database primary key. + * @param value + * The value of this property. + * @param type + * The type of this property. + */ + public ColumnProperty(String propertyId, boolean readOnly, + boolean allowReadOnlyChange, boolean nullable, boolean primaryKey, + Object value, Class<?> type) { + if (propertyId == null) { throw new IllegalArgumentException("Properties must be named."); } @@ -71,8 +114,15 @@ final public class ColumnProperty implements Property { this.allowReadOnlyChange = allowReadOnlyChange; this.nullable = nullable; this.readOnly = readOnly; + this.primaryKey = primaryKey; } + /** + * Returns the current value for this property. To get the previous value + * (if one exists) for a modified property use {@link #getOldValue()}. + * + * @return + */ @Override public Object getValue() { if (isModified()) { @@ -81,8 +131,20 @@ final public class ColumnProperty implements Property { return value; } + /** + * Returns the original non-modified value of this property if it has been + * modified. + * + * @return The original value if <code>isModified()</code> is true, + * <code>getValue()</code> otherwise. + */ + public Object getOldValue() { + return value; + } + @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(Object newValue) throws ReadOnlyException, + ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); @@ -158,6 +220,17 @@ final public class ColumnProperty implements Property { return readOnly; } + /** + * Returns whether the read-only status of this property can be changed + * using {@link #setReadOnly(boolean)}. + * <p> + * Used to prevent setting to read/write mode a property that is not allowed + * to be written by the underlying database. Also used for values like + * VERSION and AUTO_INCREMENT fields that might be set to read-only by the + * container but the database still allows writes. + * + * @return true if the read-only status can be changed, false otherwise. + */ public boolean isReadOnlyChangeAllowed() { return allowReadOnlyChange; } @@ -169,6 +242,10 @@ final public class ColumnProperty implements Property { } } + public boolean isPrimaryKey() { + return primaryKey; + } + public String getPropertyId() { return propertyId; } @@ -214,6 +291,32 @@ final public class ColumnProperty implements Property { } /** + * Return whether the value of this property should be persisted to the + * database. + * + * @return true if the value should be written to the database, false + * otherwise. + */ + public boolean isPersistent() { + if (isVersionColumn()) { + return false; + } else if (isReadOnlyChangeAllowed() && !isReadOnly()) { + return true; + } else { + return false; + } + } + + /** + * Returns whether or not this property is used as a row identifier. + * + * @return true if the property is a row identifier, false otherwise. + */ + public boolean isRowIdentifier() { + return isPrimaryKey() || isVersionColumn(); + } + + /** * An exception that signals that a <code>null</code> value was passed to * the <code>setValue</code> method, but the value of this property can not * be set to <code>null</code>. diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index 78700caee9..f772e2701c 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -68,7 +68,9 @@ public class SQLContainer implements Container, Container.Filterable, private final List<String> propertyIds = new ArrayList<String>(); private final Map<String, Class<?>> propertyTypes = new HashMap<String, Class<?>>(); private final Map<String, Boolean> propertyReadOnly = new HashMap<String, Boolean>(); + private final Map<String, Boolean> propertyPersistable = new HashMap<String, Boolean>(); private final Map<String, Boolean> propertyNullable = new HashMap<String, Boolean>(); + private final Map<String, Boolean> propertyPrimaryKey = new HashMap<String, Boolean>(); /** Filters (WHERE) and sorters (ORDER BY) */ private final List<Filter> filters = new ArrayList<Filter>(); @@ -150,11 +152,14 @@ public class SQLContainer implements Container, Container.Filterable, List<ColumnProperty> itemProperties = new ArrayList<ColumnProperty>(); for (String propertyId : propertyIds) { /* Default settings for new item properties. */ - itemProperties - .add(new ColumnProperty(propertyId, propertyReadOnly - .get(propertyId), - !propertyReadOnly.get(propertyId), propertyNullable - .get(propertyId), null, getType(propertyId))); + ColumnProperty cp = new ColumnProperty(propertyId, + propertyReadOnly.get(propertyId), + propertyPersistable.get(propertyId), + propertyNullable.get(propertyId), + propertyPrimaryKey.get(propertyId), null, + getType(propertyId)); + + itemProperties.add(cp); } RowItem newRowItem = new RowItem(this, itemId, itemProperties); @@ -546,7 +551,9 @@ public class SQLContainer implements Container, Container.Filterable, @Override public void removeContainerFilter(Filter filter) { filters.remove(filter); - refresh(); + // TODO this cannot be added before ComboBox is fixed + // (Select.requestRepaint() must not affect filter string) + // refresh(); } /** @@ -1141,14 +1148,22 @@ public class SQLContainer implements Container, Container.Filterable, */ boolean readOnly = rsmd.isAutoIncrement(i) || rsmd.isReadOnly(i); - if (delegate instanceof TableQuery - && rsmd.getColumnLabel(i).equals( - ((TableQuery) delegate).getVersionColumn())) { - readOnly = true; + + boolean persistable = !rsmd.isReadOnly(i); + + if (delegate instanceof TableQuery) { + if (rsmd.getColumnLabel(i).equals( + ((TableQuery) delegate).getVersionColumn())) { + readOnly = true; + } } + propertyReadOnly.put(colName, readOnly); + propertyPersistable.put(colName, persistable); propertyNullable.put(colName, rsmd.isNullable(i) == ResultSetMetaData.columnNullable); + propertyPrimaryKey.put(colName, delegate.getPrimaryKeyColumns() + .contains(rsmd.getColumnLabel(i))); propertyTypes.put(colName, type); } rs.getStatement().close(); @@ -1248,10 +1263,13 @@ public class SQLContainer implements Container, Container.Filterable, * column. */ if (propertiesToAdd.contains(colName)) { + cp = new ColumnProperty(colName, propertyReadOnly.get(colName), - !propertyReadOnly.get(colName), - propertyNullable.get(colName), value, type); + propertyPersistable.get(colName), + propertyNullable.get(colName), + propertyPrimaryKey.get(colName), value, + type); itemProperties.add(cp); propertiesToAdd.remove(colName); } diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java b/server/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java index c4b640e274..6ebefcd85c 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java @@ -327,10 +327,8 @@ public class DefaultSQLGenerator implements SQLGenerator { && cp.getPropertyId().equalsIgnoreCase("rownum")) { continue; } - Object value = cp.getValue() == null ? null : cp.getValue(); - /* Only include properties whose read-only status can be altered */ - if (cp.isReadOnlyChangeAllowed() && !cp.isVersionColumn()) { - columnToValueMap.put(cp.getPropertyId(), value); + if (cp.isPersistent()) { + columnToValueMap.put(cp.getPropertyId(), cp.getValue()); } } return columnToValueMap; @@ -345,8 +343,16 @@ public class DefaultSQLGenerator implements SQLGenerator { && cp.getPropertyId().equalsIgnoreCase("rownum")) { continue; } - Object value = cp.getValue() == null ? null : cp.getValue(); - if (!cp.isReadOnlyChangeAllowed() || cp.isVersionColumn()) { + + if (cp.isRowIdentifier()) { + Object value; + if (cp.isPrimaryKey()) { + // If the value of a primary key has changed, its old value + // should be used to identify the row (#9145) + value = cp.getOldValue(); + } else { + value = cp.getValue(); + } rowIdentifiers.put(cp.getPropertyId(), value); } } diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index 0eb38a3d13..bc1cd2af1a 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -518,4 +518,9 @@ public abstract class AbstractClientConnector implements ClientConnector { return getParent().isConnectorEnabled(); } } + + @Override + public void beforeClientResponse(boolean initial) { + // Do nothing by default + } } diff --git a/server/src/com/vaadin/terminal/AbstractRootProvider.java b/server/src/com/vaadin/terminal/AbstractRootProvider.java new file mode 100644 index 0000000000..0b63003440 --- /dev/null +++ b/server/src/com/vaadin/terminal/AbstractRootProvider.java @@ -0,0 +1,35 @@ +/*
+ * Copyright 2011 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.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Root;
+
+public abstract class AbstractRootProvider implements RootProvider {
+
+ @Override
+ public Root instantiateRoot(Application application,
+ Class<? extends Root> type, WrappedRequest request) {
+ try {
+ return type.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Could not instantiate root class", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Could not access root class", e);
+ }
+ }
+}
diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java new file mode 100644 index 0000000000..cbf8c98828 --- /dev/null +++ b/server/src/com/vaadin/terminal/DefaultRootProvider.java @@ -0,0 +1,51 @@ +/*
+ * Copyright 2011 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.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.ui.Root;
+
+public class DefaultRootProvider extends AbstractRootProvider {
+
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request) throws RootRequiresMoreInformationException {
+ Object rootClassNameObj = application
+ .getProperty(Application.ROOT_PARAMETER);
+
+ if (rootClassNameObj instanceof String) {
+ String rootClassName = rootClassNameObj.toString();
+
+ ClassLoader classLoader = request.getDeploymentConfiguration()
+ .getClassLoader();
+ if (classLoader == null) {
+ classLoader = getClass().getClassLoader();
+ }
+ try {
+ Class<? extends Root> rootClass = Class.forName(rootClassName,
+ true, classLoader).asSubclass(Root.class);
+
+ return rootClass;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not find root class", e);
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java index d5d474e2e3..8eb77b7d0d 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/terminal/Page.java @@ -24,6 +24,7 @@ import java.util.LinkedList; import java.util.List; import com.vaadin.event.EventRouter; +import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.root.PageClientRpc; import com.vaadin.shared.ui.root.RootConstants; import com.vaadin.terminal.WrappedRequest.BrowserDetails; @@ -128,7 +129,7 @@ public class Page implements Serializable { /** * The border style of the target window */ - private final int border; + private final BorderStyle border; /** * Creates a new open resource. @@ -145,7 +146,7 @@ public class Page implements Serializable { * The border style of the target window */ private OpenResource(Resource resource, String name, int width, - int height, int border) { + int height, BorderStyle border) { this.resource = resource; this.name = name; this.width = width; @@ -174,10 +175,10 @@ public class Page implements Serializable { target.addAttribute("height", height); } switch (border) { - case BORDER_MINIMAL: + case MINIMAL: target.addAttribute("border", "minimal"); break; - case BORDER_NONE: + case NONE: target.addAttribute("border", "none"); break; } @@ -193,19 +194,20 @@ public class Page implements Serializable { /** * A border style used for opening resources in a window without a border. */ - public static final int BORDER_NONE = 0; + @Deprecated + public static final BorderStyle BORDER_NONE = BorderStyle.NONE; /** * A border style used for opening resources in a window with a minimal * border. */ - public static final int BORDER_MINIMAL = 1; + public static final BorderStyle BORDER_MINIMAL = BorderStyle.MINIMAL; /** * A border style that indicates that the default border style should be * used when opening resources. */ - public static final int BORDER_DEFAULT = 2; + public static final BorderStyle BORDER_DEFAULT = BorderStyle.DEFAULT; /** * Listener that listens changes in URI fragment. @@ -376,23 +378,17 @@ public class Page implements Serializable { .getBrowser(); } - public void setBrowserWindowSize(Integer width, Integer height) { + public void setBrowserWindowSize(int width, int height) { boolean fireEvent = false; - if (width != null) { - int newWidth = width.intValue(); - if (newWidth != browserWindowWidth) { - browserWindowWidth = newWidth; - fireEvent = true; - } + if (width != browserWindowWidth) { + browserWindowWidth = width; + fireEvent = true; } - if (height != null) { - int newHeight = height.intValue(); - if (newHeight != browserWindowHeight) { - browserWindowHeight = newHeight; - fireEvent = true; - } + if (height != browserWindowHeight) { + browserWindowHeight = height; + fireEvent = true; } if (fireEvent) { @@ -587,11 +583,10 @@ public class Page implements Serializable { * @param height * the height of the window in pixels * @param border - * the border style of the window. See {@link #BORDER_NONE - * Window.BORDER_* constants} + * the border style of the window. */ public void open(Resource resource, String windowName, int width, - int height, int border) { + int height, BorderStyle border) { openList.add(new OpenResource(resource, windowName, width, height, border)); root.requestRepaint(); diff --git a/server/src/com/vaadin/terminal/RootProvider.java b/server/src/com/vaadin/terminal/RootProvider.java new file mode 100644 index 0000000000..476cf1bd78 --- /dev/null +++ b/server/src/com/vaadin/terminal/RootProvider.java @@ -0,0 +1,29 @@ +/*
+ * Copyright 2011 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.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.ui.Root;
+
+public interface RootProvider {
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request) throws RootRequiresMoreInformationException;
+
+ public Root instantiateRoot(Application application,
+ Class<? extends Root> type, WrappedRequest request);
+}
diff --git a/server/src/com/vaadin/terminal/Terminal.java b/server/src/com/vaadin/terminal/Terminal.java index 29cb649d54..a02bcb50bb 100644 --- a/server/src/com/vaadin/terminal/Terminal.java +++ b/server/src/com/vaadin/terminal/Terminal.java @@ -25,44 +25,12 @@ import java.io.Serializable; * * @author Vaadin Ltd. * @since 3.0 + * @deprecated Currently only a container for ErrorEvent and ErrorListener */ +@Deprecated public interface Terminal extends Serializable { /** - * Gets the name of the default theme for this terminal. - * - * @return the name of the theme that is used by default by this terminal. - */ - public String getDefaultTheme(); - - /** - * Gets the width of the terminal screen in pixels. This is the width of the - * screen and not the width available for the application. - * <p> - * Note that the screen width is typically not available in the - * {@link com.vaadin.Application#init()} method as this is called before the - * browser has a chance to report the screen size to the server. - * </p> - * - * @return the width of the terminal screen. - */ - public int getScreenWidth(); - - /** - * Gets the height of the terminal screen in pixels. This is the height of - * the screen and not the height available for the application. - * - * <p> - * Note that the screen height is typically not available in the - * {@link com.vaadin.Application#init()} method as this is called before the - * browser has a chance to report the screen size to the server. - * </p> - * - * @return the height of the terminal screen. - */ - public int getScreenHeight(); - - /** * An error event implementation for Terminal. */ public interface ErrorEvent extends Serializable { diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 3099903454..8bb14af45f 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -68,7 +68,9 @@ import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Connector; +import com.vaadin.shared.JavaScriptConnectorState; import com.vaadin.shared.Version; +import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.UidlValue; @@ -822,6 +824,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (repaintAll) { getClientCache(root).clear(); rootConnectorTracker.markAllConnectorsDirty(); + rootConnectorTracker.markAllClientSidesUninitialized(); // Reset sent locales locales = null; @@ -836,9 +839,9 @@ public abstract class AbstractCommunicationManager implements Serializable { "Found " + dirtyVisibleConnectors.size() + " dirty connectors to paint"); for (ClientConnector connector : dirtyVisibleConnectors) { - if (connector instanceof Component) { - ((Component) connector).updateState(); - } + boolean initialized = rootConnectorTracker + .isClientSideInitialized(connector); + connector.beforeClientResponse(!initialized); } rootConnectorTracker.markAllConnectorsClean(); @@ -887,23 +890,36 @@ public abstract class AbstractCommunicationManager implements Serializable { try { Class<? extends SharedState> stateType = connector .getStateType(); - SharedState referenceState = null; - if (repaintAll) { + Object diffState = rootConnectorTracker + .getDiffState(connector); + if (diffState == null) { + diffState = new JSONObject(); // Use an empty state object as reference for full // repaints - try { - referenceState = stateType.newInstance(); - } catch (Exception e) { - getLogger().log( - Level.WARNING, - "Error creating reference object for state of type " - + stateType.getName()); + boolean emptyInitialState = JavaScriptConnectorState.class + .isAssignableFrom(stateType); + if (!emptyInitialState) { + try { + SharedState referenceState = stateType + .newInstance(); + diffState = JsonCodec.encode(referenceState, + null, stateType, + root.getConnectorTracker()); + } catch (Exception e) { + getLogger().log( + Level.WARNING, + "Error creating reference object for state of type " + + stateType.getName()); + } } + rootConnectorTracker.setDiffState(connector, diffState); } - Object stateJson = JsonCodec.encode(state, referenceState, - stateType, root.getConnectorTracker()); + JSONObject stateJson = (JSONObject) JsonCodec.encode(state, + diffState, stateType, root.getConnectorTracker()); - sharedStates.put(connector.getConnectorId(), stateJson); + if (stateJson.length() != 0) { + sharedStates.put(connector.getConnectorId(), stateJson); + } } catch (JSONException e) { throw new PaintException( "Failed to serialize shared state for connector " @@ -1254,6 +1270,10 @@ public abstract class AbstractCommunicationManager implements Serializable { dragAndDropService.printJSONResponse(outWriter); } + for (ClientConnector connector : dirtyVisibleConnectors) { + rootConnectorTracker.markClientSideInitialized(connector); + } + writePerformanceData(outWriter); } diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java index 06bc70872d..52885f3fbb 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java @@ -20,6 +20,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; +import com.vaadin.terminal.DefaultRootProvider; import com.vaadin.terminal.gwt.server.ServletPortletHelper.ApplicationClassException; /** @@ -69,6 +70,7 @@ public class ApplicationServlet extends AbstractApplicationServlet { // Creates a new application instance try { final Application application = getApplicationClass().newInstance(); + application.addRootProvider(new DefaultRootProvider()); return application; } catch (final IllegalAccessException e) { diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index eef4e240ec..c9fe2563f9 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -157,4 +157,24 @@ public interface ClientConnector extends Connector, RpcTarget { * attached to any Root */ public Root getRoot(); + + /** + * Called before the shared state and RPC invocations are sent to the + * client. Gives the connector an opportunity to set computed/dynamic state + * values or to invoke last minute RPC methods depending on other component + * features. + * <p> + * This method must not alter the component hierarchy in any way. Calling + * requestRepaint() from this method will have no effect. + * </p> + * + * @param initial + * <code>true</code> if the client-side connector will be created + * and initialized after this method has been invoked. + * <code>false</code> if there is already an initialized + * client-side connector. + * + * @since 7.0 + */ + public void beforeClientResponse(boolean initial); } diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index bb96c6e53e..56d5ed1393 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -322,4 +322,9 @@ public class DragAndDropService implements VariableOwner, ClientConnector { public Root getRoot() { return null; } + + @Override + public void beforeClientResponse(boolean initial) { + // Nothing to do + } } diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java index 60197b0b3a..892f7ec526 100644 --- a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java +++ b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java @@ -165,6 +165,10 @@ public class JsonCodec implements Serializable { } else if (targetType == JSONObject.class || targetType == JSONArray.class) { return value; + } else if (Enum.class.isAssignableFrom(getClassForType(targetType))) { + Class<?> classForType = getClassForType(targetType); + return decodeEnum(classForType.asSubclass(Enum.class), + (String) value); } else { return decodeObject(targetType, (JSONObject) value, connectorTracker); @@ -420,9 +424,8 @@ public class JsonCodec implements Serializable { } } - private static Object decodeEnum(Class<? extends Enum> cls, JSONObject value) { - String enumIdentifier = String.valueOf(value); - return Enum.valueOf(cls, enumIdentifier); + private static Object decodeEnum(Class<? extends Enum> cls, String value) { + return Enum.valueOf(cls, value); } private static String[] decodeStringArray(JSONArray jsonArray) @@ -491,10 +494,6 @@ public class JsonCodec implements Serializable { throws JSONException { Class<?> targetClass = getClassForType(targetType); - if (Enum.class.isAssignableFrom(targetClass)) { - return decodeEnum(targetClass.asSubclass(Enum.class), - serializedObject); - } try { Object decodedObject = targetClass.newInstance(); @@ -527,9 +526,8 @@ public class JsonCodec implements Serializable { } } - public static Object encode(Object value, Object referenceValue, - Type valueType, ConnectorTracker connectorTracker) - throws JSONException { + public static Object encode(Object value, Object diffState, Type valueType, + ConnectorTracker connectorTracker) throws JSONException { if (valueType == null) { throw new IllegalArgumentException("type must be defined"); @@ -596,7 +594,7 @@ public class JsonCodec implements Serializable { } else { // Any object that we do not know how to encode we encode by looping // through fields - return encodeObject(value, referenceValue, connectorTracker); + return encodeObject(value, (JSONObject) diffState, connectorTracker); } } @@ -604,7 +602,7 @@ public class JsonCodec implements Serializable { return JSONObject.NULL; } - private static Object encodeObject(Object value, Object referenceValue, + private static Object encodeObject(Object value, JSONObject diffState, ConnectorTracker connectorTracker) throws JSONException { JSONObject jsonMap = new JSONObject(); @@ -621,10 +619,14 @@ public class JsonCodec implements Serializable { Type fieldType = getterMethod.getGenericReturnType(); Object fieldValue = getterMethod.invoke(value, (Object[]) null); boolean equals = false; - Object referenceFieldValue = null; - if (referenceValue != null) { - referenceFieldValue = getterMethod.invoke(referenceValue, - (Object[]) null); + Object diffStateValue = null; + if (diffState != null && diffState.has(fieldName)) { + diffStateValue = diffState.get(fieldName); + Object referenceFieldValue = decodeInternalOrCustomType( + fieldType, diffStateValue, connectorTracker); + if (JSONObject.NULL.equals(diffStateValue)) { + diffStateValue = null; + } equals = equals(fieldValue, referenceFieldValue); } if (!equals) { @@ -638,8 +640,15 @@ public class JsonCodec implements Serializable { } jsonMap.put( fieldName, - encode(fieldValue, referenceFieldValue, fieldType, + encode(fieldValue, diffStateValue, fieldType, connectorTracker)); + if (diffState != null) { + diffState.put( + fieldName, + encode(fieldValue, null, fieldType, + connectorTracker)); + } + // } else { // System.out.println("Skipping field " + fieldName // + " of type " + fieldType.getName() diff --git a/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java index 90aef4283d..37bc81cfcf 100644 --- a/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java +++ b/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java @@ -20,7 +20,6 @@ import java.util.Date; import java.util.Locale; import com.vaadin.shared.VBrowserDetails; -import com.vaadin.terminal.Terminal; import com.vaadin.terminal.WrappedRequest; /** @@ -30,7 +29,7 @@ import com.vaadin.terminal.WrappedRequest; * * @author Vaadin Ltd. */ -public class WebBrowser implements Terminal { +public class WebBrowser { private int screenHeight = 0; private int screenWidth = 0; @@ -48,34 +47,21 @@ public class WebBrowser implements Terminal { private long clientServerTimeDelta; /** - * There is no default-theme for this terminal type. + * Gets the height of the screen in pixels. This is the full screen + * resolution and not the height available for the application. * - * @return Always returns null. + * @return the height of the screen in pixels. */ - - @Override - public String getDefaultTheme() { - return null; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.terminal.Terminal#getScreenHeight() - */ - - @Override public int getScreenHeight() { return screenHeight; } - /* - * (non-Javadoc) + /** + * Gets the width of the screen in pixels. This is the full screen + * resolution and not the width available for the application. * - * @see com.vaadin.terminal.Terminal#getScreenWidth() + * @return the width of the screen in pixels. */ - - @Override public int getScreenWidth() { return screenWidth; } diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index 9851a79bcd..a3bc577fe3 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -169,8 +169,8 @@ public class AbsoluteLayout extends AbstractLayout implements } @Override - public void updateState() { - super.updateState(); + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); // This could be in internalRemoveComponent and internalSetComponent if // Map<Connector,String> was supported. We cannot get the child diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index fb3993d0cf..cde5217ca1 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -717,13 +717,9 @@ public abstract class AbstractComponent extends AbstractClientConnector return (ComponentState) super.getState(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Component#updateState() - */ @Override - public void updateState() { + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); // TODO This logic should be on the client side and the state should // simply be a data object with "width" and "height". if (getHeight() >= 0 diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 2d14acf442..b914fb4c46 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -394,8 +394,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @throws InvalidValueException * If the implicit commit operation fails because of a * validation error. - * @deprecated Use {@link #setBuffered(boolean)} instead. Note that - * setReadThrough(true), setWriteThrough(true) equals + * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note + * that setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ @Override @@ -435,8 +435,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @throws SourceException * If the operation fails because of an exception is thrown by * the data source. The cause is included in the exception. - * @deprecated Use {@link #setBuffered(boolean)} instead. Note that - * setReadThrough(true), setWriteThrough(true) equals + * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note + * that setReadThrough(true), setWriteThrough(true) equals * setBuffered(false) */ @Override @@ -1620,8 +1620,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements } @Override - public void updateState() { - super.updateState(); + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); // Hide the error indicator if needed getState().setHideErrors(shouldHideErrors()); diff --git a/server/src/com/vaadin/ui/AbstractLayout.java b/server/src/com/vaadin/ui/AbstractLayout.java index c26812f3fc..dd1d5eab12 100644 --- a/server/src/com/vaadin/ui/AbstractLayout.java +++ b/server/src/com/vaadin/ui/AbstractLayout.java @@ -17,7 +17,6 @@ package com.vaadin.ui; import com.vaadin.shared.ui.AbstractLayoutState; -import com.vaadin.ui.Layout.MarginHandler; /** * An abstract class that defines default implementation for the {@link Layout} @@ -26,62 +25,12 @@ import com.vaadin.ui.Layout.MarginHandler; * @author Vaadin Ltd. * @since 5.0 */ -@SuppressWarnings("serial") public abstract class AbstractLayout extends AbstractComponentContainer - implements Layout, MarginHandler { - - protected MarginInfo margins = new MarginInfo(false); + implements Layout { @Override public AbstractLayoutState getState() { return (AbstractLayoutState) super.getState(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout#setMargin(boolean) - */ - @Override - public void setMargin(boolean enabled) { - margins.setMargins(enabled); - getState().setMarginsBitmask(margins.getBitMask()); - requestRepaint(); - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout.MarginHandler#getMargin() - */ - @Override - public MarginInfo getMargin() { - return margins; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo) - */ - @Override - public void setMargin(MarginInfo marginInfo) { - margins.setMargins(marginInfo); - getState().setMarginsBitmask(margins.getBitMask()); - requestRepaint(); - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout#setMargin(boolean, boolean, boolean, boolean) - */ - @Override - public void setMargin(boolean topEnabled, boolean rightEnabled, - boolean bottomEnabled, boolean leftEnabled) { - margins.setMargins(topEnabled, rightEnabled, bottomEnabled, leftEnabled); - getState().setMarginsBitmask(margins.getBitMask()); - requestRepaint(); - } - } diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index a7cc780414..3ac4e76bdb 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -25,6 +25,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState; import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState.ChildComponentData; @@ -32,7 +33,8 @@ import com.vaadin.terminal.Sizeable; @SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements - Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier { + Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier, + Layout.MarginHandler { private AbstractOrderedLayoutServerRpc rpc = new AbstractOrderedLayoutServerRpc() { @@ -392,4 +394,26 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements return components.get(index); } + public void setMargin(boolean enabled) { + setMargin(new MarginInfo(enabled)); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Layout.MarginHandler#getMargin() + */ + public MarginInfo getMargin() { + return new MarginInfo(getState().getMarginsBitmask()); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo) + */ + public void setMargin(MarginInfo marginInfo) { + getState().setMarginsBitmask(marginInfo.getBitMask()); + requestRepaint(); + } } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index c8bbadd0ab..86315f801f 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -97,8 +97,8 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - public void updateState() { - super.updateState(); + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); String value = getValue(); if (value == null) { diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index ac668168f2..ff7ed47930 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -637,18 +637,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable { public ComponentState getState(); /** - * Called before the shared state is sent to the client. Gives the component - * an opportunity to set computed/dynamic state values e.g. state values - * that depend on other component features. - * <p> - * This method must not alter the component hierarchy in any way. - * </p> - * - * @since 7.0 - */ - public void updateState(); - - /** * Adds an unique id for component that get's transferred to terminal for * testing purposes. Keeping identifiers unique is the responsibility of the * programmer. diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index 12ad377b62..2afe7f9025 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -39,7 +40,8 @@ import com.vaadin.terminal.gwt.server.ClientConnector; * Tracks which {@link ClientConnector}s are dirty so they can be updated to the * client when the following response is sent. A connector is dirty when an * operation has been performed on it on the server and as a result of this - * operation new information needs to be sent to its {@link ServerConnector}. + * operation new information needs to be sent to its + * {@link com.vaadin.terminal.gwt.client.ServerConnector}. * </p> * * @author Vaadin Ltd @@ -50,8 +52,10 @@ public class ConnectorTracker implements Serializable { private final HashMap<String, ClientConnector> connectorIdToConnector = new HashMap<String, ClientConnector>(); private Set<ClientConnector> dirtyConnectors = new HashSet<ClientConnector>(); + private Set<ClientConnector> uninitializedConnectors = new HashSet<ClientConnector>(); private Root root; + private Map<ClientConnector, Object> diffStates = new HashMap<ClientConnector, Object>(); /** * Gets a logger for this class @@ -91,6 +95,7 @@ public class ConnectorTracker implements Serializable { .get(connectorId); if (previouslyRegistered == null) { connectorIdToConnector.put(connectorId, connector); + uninitializedConnectors.add(connector); getLogger().fine( "Registered " + connector.getClass().getSimpleName() + " (" + connectorId + ")"); @@ -136,6 +141,49 @@ public class ConnectorTracker implements Serializable { "Unregistered " + connector.getClass().getSimpleName() + " (" + connectorId + ")"); connectorIdToConnector.remove(connectorId); + uninitializedConnectors.remove(connector); + diffStates.remove(connector); + } + + /** + * Checks whether the given connector has already been initialized in the + * browser. The given connector should be registered with this connector + * tracker. + * + * @param connector + * the client connector to check + * @return <code>true</code> if the initial state has previously been sent + * to the browser, <code>false</code> if the client-side doesn't + * already know anything about the connector. + */ + public boolean isClientSideInitialized(ClientConnector connector) { + assert connectorIdToConnector.get(connector.getConnectorId()) == connector : "Connector should be registered with this ConnectorTracker"; + return !uninitializedConnectors.contains(connector); + } + + /** + * Marks the given connector as initialized, meaning that the client-side + * state has been initialized for the connector. + * + * @see #isClientSideInitialized(ClientConnector) + * + * @param connector + * the connector that should be marked as initialized + */ + public void markClientSideInitialized(ClientConnector connector) { + uninitializedConnectors.remove(connector); + } + + /** + * Marks all currently registered connectors as uninitialized. This should + * be done when the client-side has been reset but the server-side state is + * retained. + * + * @see #isClientSideInitialized(ClientConnector) + */ + public void markAllClientSidesUninitialized() { + uninitializedConnectors.addAll(connectorIdToConnector.values()); + diffStates.clear(); } /** @@ -175,6 +223,8 @@ public class ConnectorTracker implements Serializable { "cleanConnectorMap unregistered connector " + getConnectorAndParentInfo(connector) + "). This should have been done when the connector was detached."); + uninitializedConnectors.remove(connector); + diffStates.remove(connector); iterator.remove(); } } @@ -327,4 +377,12 @@ public class ConnectorTracker implements Serializable { return dirtyConnectors; } + public Object getDiffState(ClientConnector connector) { + return diffStates.get(connector); + } + + public void setDiffState(ClientConnector connector, Object diffState) { + diffStates.put(connector, diffState); + } + } diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index c43f347e68..0192debc4a 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -197,8 +197,8 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } @Override - public void updateState() { - super.updateState(); + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); getState().getChildCss().clear(); for (Iterator<Component> ci = getComponentIterator(); ci.hasNext();) { Component child = ci.next(); diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index 2da443bfa5..d47b2f92b3 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -291,33 +291,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { requestRepaint(); } - /** - * Although most layouts support margins, CustomLayout does not. The - * behaviour of this layout is determined almost completely by the actual - * template. - * - * @throws UnsupportedOperationException - */ - @Override - public void setMargin(boolean enabled) { - throw new UnsupportedOperationException( - "CustomLayout does not support margins."); - } - - /** - * Although most layouts support margins, CustomLayout does not. The - * behaviour of this layout is determined almost completely by the actual - * template. - * - * @throws UnsupportedOperationException - */ - @Override - public void setMargin(boolean topEnabled, boolean rightEnabled, - boolean bottomEnabled, boolean leftEnabled) { - throw new UnsupportedOperationException( - "CustomLayout does not support margins."); - } - @Override public void changeVariables(Object source, Map<String, Object> variables) { // Nothing to see here diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java index 5130d665eb..790f3568d5 100644 --- a/server/src/com/vaadin/ui/DateField.java +++ b/server/src/com/vaadin/ui/DateField.java @@ -131,7 +131,7 @@ public class DateField extends AbstractField<Date> implements /** * Resolution identifier: seconds. * - * @deprecated Use {@link Resolution#SECOND} + * @deprecated As of 7.0, use {@link Resolution#SECOND} */ @Deprecated public static final Resolution RESOLUTION_SEC = Resolution.SECOND; @@ -139,7 +139,7 @@ public class DateField extends AbstractField<Date> implements /** * Resolution identifier: minutes. * - * @deprecated Use {@link Resolution#MINUTE} + * @deprecated As of 7.0, use {@link Resolution#MINUTE} */ @Deprecated public static final Resolution RESOLUTION_MIN = Resolution.MINUTE; @@ -147,7 +147,7 @@ public class DateField extends AbstractField<Date> implements /** * Resolution identifier: hours. * - * @deprecated Use {@link Resolution#HOUR} + * @deprecated As of 7.0, use {@link Resolution#HOUR} */ @Deprecated public static final Resolution RESOLUTION_HOUR = Resolution.HOUR; @@ -155,7 +155,7 @@ public class DateField extends AbstractField<Date> implements /** * Resolution identifier: days. * - * @deprecated Use {@link Resolution#DAY} + * @deprecated As of 7.0, use {@link Resolution#DAY} */ @Deprecated public static final Resolution RESOLUTION_DAY = Resolution.DAY; @@ -163,7 +163,7 @@ public class DateField extends AbstractField<Date> implements /** * Resolution identifier: months. * - * @deprecated Use {@link Resolution#MONTH} + * @deprecated As of 7.0, use {@link Resolution#MONTH} */ @Deprecated public static final Resolution RESOLUTION_MONTH = Resolution.MONTH; @@ -171,7 +171,7 @@ public class DateField extends AbstractField<Date> implements /** * Resolution identifier: years. * - * @deprecated Use {@link Resolution#YEAR} + * @deprecated As of 7.0, use {@link Resolution#YEAR} */ @Deprecated public static final Resolution RESOLUTION_YEAR = Resolution.YEAR; diff --git a/server/src/com/vaadin/ui/FormLayout.java b/server/src/com/vaadin/ui/FormLayout.java index c4ba4665ea..15ea478597 100644 --- a/server/src/com/vaadin/ui/FormLayout.java +++ b/server/src/com/vaadin/ui/FormLayout.java @@ -16,6 +16,8 @@ package com.vaadin.ui; +import com.vaadin.shared.ui.MarginInfo; + /** * FormLayout is used by {@link Form} to layout fields. It may also be used * separately without {@link Form}. @@ -36,7 +38,7 @@ public class FormLayout extends AbstractOrderedLayout { public FormLayout() { super(); setSpacing(true); - setMargin(true, false, true, false); + setMargin(new MarginInfo(true, false, true, false)); setWidth(100, UNITS_PERCENTAGE); } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 5a748c04f6..b31ab82741 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -30,6 +30,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc; import com.vaadin.shared.ui.gridlayout.GridLayoutState; import com.vaadin.terminal.LegacyPaint; @@ -63,8 +64,8 @@ import com.vaadin.terminal.Vaadin6Component; */ @SuppressWarnings("serial") public class GridLayout extends AbstractLayout implements - Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier, - Vaadin6Component { + Layout.AlignmentHandler, Layout.SpacingHandler, Layout.MarginHandler, + LayoutClickNotifier, Vaadin6Component { private GridLayoutServerRpc rpc = new GridLayoutServerRpc() { @@ -1416,4 +1417,37 @@ public class GridLayout extends AbstractLayout implements LayoutClickEvent.class, listener); } + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Layout.MarginHandler#setMargin(boolean) + */ + @Override + public void setMargin(boolean enabled) { + setMargin(new MarginInfo(enabled)); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.Layout.MarginHandler#setMargin(com.vaadin.shared.ui.MarginInfo + * ) + */ + @Override + public void setMargin(MarginInfo marginInfo) { + getState().setMarginsBitmask(marginInfo.getBitMask()); + requestRepaint(); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Layout.MarginHandler#getMargin() + */ + @Override + public MarginInfo getMargin() { + return new MarginInfo(getState().getMarginsBitmask()); + } + } diff --git a/server/src/com/vaadin/ui/Layout.java b/server/src/com/vaadin/ui/Layout.java index 6a95d23f8c..9c7cd2b477 100644 --- a/server/src/com/vaadin/ui/Layout.java +++ b/server/src/com/vaadin/ui/Layout.java @@ -18,8 +18,8 @@ package com.vaadin.ui; import java.io.Serializable; -import com.vaadin.shared.ui.VMarginInfo; import com.vaadin.shared.ui.AlignmentInfo.Bits; +import com.vaadin.shared.ui.MarginInfo; /** * Extension to the {@link ComponentContainer} interface which adds the @@ -33,30 +33,6 @@ import com.vaadin.shared.ui.AlignmentInfo.Bits; public interface Layout extends ComponentContainer, Serializable { /** - * Enable layout margins. Affects all four sides of the layout. This will - * tell the client-side implementation to leave extra space around the - * layout. The client-side implementation decides the actual amount, and it - * can vary between themes. - * - * @param enabled - */ - public void setMargin(boolean enabled); - - /** - * Enable specific layout margins. This will tell the client-side - * implementation to leave extra space around the layout in specified edges, - * clockwise from top (top, right, bottom, left). The client-side - * implementation decides the actual amount, and it can vary between themes. - * - * @param top - * @param right - * @param bottom - * @param left - */ - public void setMargin(boolean top, boolean right, boolean bottom, - boolean left); - - /** * AlignmentHandler is most commonly an advanced {@link Layout} that can * align its components. */ @@ -197,6 +173,19 @@ public interface Layout extends ComponentContainer, Serializable { * its components). */ public interface MarginHandler extends Serializable { + + /** + * Enable layout margins. Affects all four sides of the layout. This + * will tell the client-side implementation to leave extra space around + * the layout. The client-side implementation decides the actual amount, + * and it can vary between themes. + * + * @param enabled + * true if margins should be enabled on all sides, false to + * disable all margins + */ + public void setMargin(boolean enabled); + /** * Enable margins for this layout. * @@ -224,16 +213,4 @@ public interface Layout extends ComponentContainer, Serializable { public MarginInfo getMargin(); } - @SuppressWarnings("serial") - public static class MarginInfo extends VMarginInfo implements Serializable { - - public MarginInfo(boolean enabled) { - super(enabled, enabled, enabled, enabled); - } - - public MarginInfo(boolean top, boolean right, boolean bottom, - boolean left) { - super(top, right, bottom, left); - } - } } diff --git a/server/src/com/vaadin/ui/Link.java b/server/src/com/vaadin/ui/Link.java index 57f2088054..ae2934f878 100644 --- a/server/src/com/vaadin/ui/Link.java +++ b/server/src/com/vaadin/ui/Link.java @@ -18,7 +18,7 @@ package com.vaadin.ui; import java.util.Map; -import com.vaadin.terminal.Page; +import com.vaadin.shared.ui.BorderStyle; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; @@ -34,19 +34,22 @@ import com.vaadin.terminal.Vaadin6Component; public class Link extends AbstractComponent implements Vaadin6Component { /* Target window border type constant: No window border */ - public static final int TARGET_BORDER_NONE = Page.BORDER_NONE; + @Deprecated + public static final BorderStyle TARGET_BORDER_NONE = BorderStyle.NONE; /* Target window border type constant: Minimal window border */ - public static final int TARGET_BORDER_MINIMAL = Page.BORDER_MINIMAL; + @Deprecated + public static final BorderStyle TARGET_BORDER_MINIMAL = BorderStyle.MINIMAL; /* Target window border type constant: Default window border */ - public static final int TARGET_BORDER_DEFAULT = Page.BORDER_DEFAULT; + @Deprecated + public static final BorderStyle TARGET_BORDER_DEFAULT = BorderStyle.DEFAULT; private Resource resource = null; private String targetName; - private int targetBorder = TARGET_BORDER_DEFAULT; + private BorderStyle targetBorder = BorderStyle.DEFAULT; private int targetWidth = -1; @@ -89,7 +92,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { * */ public Link(String caption, Resource resource, String targetName, - int width, int height, int border) { + int width, int height, BorderStyle border) { setCaption(caption); this.resource = resource; setTargetName(targetName); @@ -131,10 +134,10 @@ public class Link extends AbstractComponent implements Vaadin6Component { // Target window border switch (getTargetBorder()) { - case TARGET_BORDER_MINIMAL: + case MINIMAL: target.addAttribute("border", "minimal"); break; - case TARGET_BORDER_NONE: + case NONE: target.addAttribute("border", "none"); break; } @@ -145,7 +148,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { * * @return the target window border. */ - public int getTargetBorder() { + public BorderStyle getTargetBorder() { return targetBorder; } @@ -183,13 +186,9 @@ public class Link extends AbstractComponent implements Vaadin6Component { * @param targetBorder * the targetBorder to set. */ - public void setTargetBorder(int targetBorder) { - if (targetBorder == TARGET_BORDER_DEFAULT - || targetBorder == TARGET_BORDER_MINIMAL - || targetBorder == TARGET_BORDER_NONE) { - this.targetBorder = targetBorder; - requestRepaint(); - } + public void setTargetBorder(BorderStyle targetBorder) { + this.targetBorder = targetBorder; + requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java index dd3f016fc9..14abf0f24f 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/Root.java @@ -36,6 +36,7 @@ import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.root.RootConstants; import com.vaadin.shared.ui.root.RootServerRpc; import com.vaadin.shared.ui.root.RootState; @@ -285,13 +286,12 @@ public abstract class Root extends AbstractComponentContainer implements * @param height * the height of the window in pixels * @param border - * the border style of the window. See {@link #BORDER_NONE - * Window.BORDER_* constants} + * the border style of the window. * @deprecated As of 7.0, use getPage().open instead */ @Deprecated public void open(Resource resource, String windowName, int width, - int height, int border) { + int height, BorderStyle border) { getPage().open(resource, windowName, width, height, border); } @@ -472,6 +472,13 @@ public abstract class Root extends AbstractComponentContainer implements public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(Root.this, mouseDetails)); } + + @Override + public void resize(int viewWidth, int viewHeight, int windowWidth, + int windowHeight) { + // TODO We're not doing anything with the view dimensions + getPage().setBrowserWindowSize(windowWidth, windowHeight); + } }; /** @@ -637,12 +644,6 @@ public abstract class Root extends AbstractComponentContainer implements .get(RootConstants.FRAGMENT_VARIABLE); getPage().setFragment(fragment, true); } - - if (variables.containsKey("height") || variables.containsKey("width")) { - getPage().setBrowserWindowSize((Integer) variables.get("width"), - (Integer) variables.get("height")); - } - } /* diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 6f7f88f883..2bbb69beaf 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -4470,7 +4470,7 @@ public class Table extends AbstractSelect implements Action.Container, * would support this. * * @return True iff sorting is disabled. - * @deprecated Use {@link #isSortEnabled()} instead + * @deprecated As of 7.0, use {@link #isSortEnabled()} instead */ @Deprecated public boolean isSortDisabled() { @@ -4491,7 +4491,7 @@ public class Table extends AbstractSelect implements Action.Container, * * @param sortDisabled * True iff sorting is disabled. - * @deprecated Use {@link #setSortEnabled(boolean)} instead + * @deprecated As of 7.0, use {@link #setSortEnabled(boolean)} instead */ @Deprecated public void setSortDisabled(boolean sortDisabled) { diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 13ef7e5784..d1d2c25d8b 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -32,7 +32,6 @@ import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; import com.vaadin.shared.MouseEventDetails; -import com.vaadin.shared.ui.root.RootConstants; import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowState; import com.vaadin.terminal.PaintException; @@ -76,10 +75,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } }; - private int browserWindowWidth = -1; - - private int browserWindowHeight = -1; - /** * Creates a new unnamed window with a default layout. */ @@ -170,20 +165,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, .get("width") != getWidth())) { sizeHasChanged = true; } - Integer browserHeightVar = (Integer) variables - .get(RootConstants.BROWSER_HEIGHT_VAR); - if (browserHeightVar != null - && browserHeightVar.intValue() != browserWindowHeight) { - browserWindowHeight = browserHeightVar.intValue(); - sizeHasChanged = true; - } - Integer browserWidthVar = (Integer) variables - .get(RootConstants.BROWSER_WIDTH_VAR); - if (browserWidthVar != null - && browserWidthVar.intValue() != browserWindowWidth) { - browserWindowWidth = browserWidthVar.intValue(); - sizeHasChanged = true; - } super.changeVariables(source, variables); diff --git a/shared/src/com/vaadin/shared/annotations/Delayed.java b/shared/src/com/vaadin/shared/annotations/Delayed.java new file mode 100644 index 0000000000..706ffc1c53 --- /dev/null +++ b/shared/src/com/vaadin/shared/annotations/Delayed.java @@ -0,0 +1,54 @@ +/* + * Copyright 2011 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.shared.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * Invoking a method in a {@link ServerRpc} interface marked with this + * annotation will only add the invocation to a queue of outgoing RPC + * invocations, but it will not cause the queue to be purged and sent to the + * server. The queue will instead be sent when any RPC method not marked as @Delayed + * has been invoked. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +@Target(ElementType.METHOD) +@Documented +public @interface Delayed { + /** + * By setting lastonly to <code>true</code>, any previous invocations of the + * same method will be removed from the queue when a new invocation is + * added. This can be used in cases where only the last value is of + * interest. + * <p> + * The default value is <code>false</code> which means that invoking the + * method multiple times will cause multiple invocations to be enqueued and + * eventually sent to the server. + * + * @return <code>true</code> if only the last invocation of the annotated + * method should be sent to the server, <code>false</code> if all + * enqueued invocations should be sent. + */ + public boolean lastonly() default false; +} diff --git a/server/src/com/vaadin/terminal/gwt/server/LegacyChangeVariablesInvocation.java b/shared/src/com/vaadin/shared/communication/LegacyChangeVariablesInvocation.java index fc3fbd6c00..2ffc56dd71 100644 --- a/server/src/com/vaadin/terminal/gwt/server/LegacyChangeVariablesInvocation.java +++ b/shared/src/com/vaadin/shared/communication/LegacyChangeVariablesInvocation.java @@ -13,13 +13,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.terminal.gwt.server; +package com.vaadin.shared.communication; import java.util.HashMap; import java.util.Map; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.shared.communication.MethodInvocation; public class LegacyChangeVariablesInvocation extends MethodInvocation { private Map<String, Object> variableChanges = new HashMap<String, Object>(); @@ -27,7 +26,8 @@ public class LegacyChangeVariablesInvocation extends MethodInvocation { public LegacyChangeVariablesInvocation(String connectorId, String variableName, Object value) { super(connectorId, ApplicationConstants.UPDATE_VARIABLE_INTERFACE, - ApplicationConstants.UPDATE_VARIABLE_METHOD); + ApplicationConstants.UPDATE_VARIABLE_METHOD, new Object[] { + variableName, new UidlValue(value) }); setVariableChange(variableName, value); } @@ -47,4 +47,11 @@ public class LegacyChangeVariablesInvocation extends MethodInvocation { return variableChanges; } + @Override + public String getLastonlyTag() { + assert variableChanges.size() == 1; + return super.getLastonlyTag() + + variableChanges.keySet().iterator().next(); + } + } diff --git a/shared/src/com/vaadin/shared/communication/MethodInvocation.java b/shared/src/com/vaadin/shared/communication/MethodInvocation.java index 720ce09fcb..c4da937c27 100644 --- a/shared/src/com/vaadin/shared/communication/MethodInvocation.java +++ b/shared/src/com/vaadin/shared/communication/MethodInvocation.java @@ -71,4 +71,18 @@ public class MethodInvocation implements Serializable { + Arrays.toString(parameters) + ")"; } + /** + * Gets a String tag that is used to uniquely identify previous method + * invocations that should be purged from the queue if + * <code>{@literal @}Delay(lastonly = true)</code> is used. + * <p> + * The returned string should contain at least one non-number char to ensure + * it doesn't collide with the keys used for invocations without lastonly. + * + * @return a string identifying this method invocation + */ + public String getLastonlyTag() { + return connectorId + "-" + getInterfaceName() + "-" + getMethodName(); + } + }
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java index 675d11d0b7..4fc865626c 100644 --- a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java @@ -18,14 +18,5 @@ package com.vaadin.shared.ui; import com.vaadin.shared.ComponentState; public class AbstractLayoutState extends ComponentState { - private int marginsBitmask; - - public int getMarginsBitmask() { - return marginsBitmask; - } - - public void setMarginsBitmask(int marginsBitmask) { - this.marginsBitmask = marginsBitmask; - } }
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/BorderStyle.java b/shared/src/com/vaadin/shared/ui/BorderStyle.java new file mode 100755 index 0000000000..786d340f1c --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/BorderStyle.java @@ -0,0 +1,20 @@ +/* + * Copyright 2011 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.shared.ui; + +public enum BorderStyle { + NONE, MINIMAL, DEFAULT; +} diff --git a/shared/src/com/vaadin/shared/ui/VMarginInfo.java b/shared/src/com/vaadin/shared/ui/MarginInfo.java index 9e9e0a4bb4..21e52f258a 100644 --- a/shared/src/com/vaadin/shared/ui/VMarginInfo.java +++ b/shared/src/com/vaadin/shared/ui/MarginInfo.java @@ -18,8 +18,7 @@ package com.vaadin.shared.ui; import java.io.Serializable; -@SuppressWarnings("serial") -public class VMarginInfo implements Serializable { +public class MarginInfo implements Serializable { private static final int TOP = 1; private static final int RIGHT = 2; @@ -28,11 +27,15 @@ public class VMarginInfo implements Serializable { private int bitMask; - public VMarginInfo(int bitMask) { + public MarginInfo(boolean enabled) { + this(enabled, enabled, enabled, enabled); + } + + public MarginInfo(int bitMask) { this.bitMask = bitMask; } - public VMarginInfo(boolean top, boolean right, boolean bottom, boolean left) { + public MarginInfo(boolean top, boolean right, boolean bottom, boolean left) { setMargins(top, right, bottom, left); } @@ -44,7 +47,7 @@ public class VMarginInfo implements Serializable { bitMask += left ? LEFT : 0; } - public void setMargins(VMarginInfo marginInfo) { + public void setMargins(MarginInfo marginInfo) { bitMask = marginInfo.bitMask; } @@ -78,11 +81,11 @@ public class VMarginInfo implements Serializable { @Override public boolean equals(Object obj) { - if (!(obj instanceof VMarginInfo)) { + if (!(obj instanceof MarginInfo)) { return false; } - return ((VMarginInfo) obj).bitMask == bitMask; + return ((MarginInfo) obj).bitMask == bitMask; } @Override diff --git a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java index d2e685d8cb..381a6a7f85 100644 --- a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java @@ -21,6 +21,7 @@ public class GridLayoutState extends AbstractLayoutState { private boolean spacing = false; private int rows = 0; private int columns = 0; + private int marginsBitmask = 0; public boolean isSpacing() { return spacing; @@ -30,6 +31,14 @@ public class GridLayoutState extends AbstractLayoutState { this.spacing = spacing; } + public int getMarginsBitmask() { + return marginsBitmask; + } + + public void setMarginsBitmask(int marginsBitmask) { + this.marginsBitmask = marginsBitmask; + } + public int getRows() { return rows; } diff --git a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java index 235c9eab13..3fa2ad771c 100644 --- a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java @@ -27,6 +27,8 @@ public class AbstractOrderedLayoutState extends AbstractLayoutState { public HashMap<Connector, ChildComponentData> childData = new HashMap<Connector, ChildComponentData>(); + private int marginsBitmask = 0; + public static class ChildComponentData implements Serializable { private int alignmentBitmask = AlignmentInfo.TOP_LEFT.getBitMask(); private float expandRatio = 0.0f; @@ -65,4 +67,12 @@ public class AbstractOrderedLayoutState extends AbstractLayoutState { this.spacing = spacing; } + public int getMarginsBitmask() { + return marginsBitmask; + } + + public void setMarginsBitmask(int marginsBitmask) { + this.marginsBitmask = marginsBitmask; + } + }
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/RootConstants.java b/shared/src/com/vaadin/shared/ui/root/RootConstants.java index bc4f6017f6..34c17ac71f 100644 --- a/shared/src/com/vaadin/shared/ui/root/RootConstants.java +++ b/shared/src/com/vaadin/shared/ui/root/RootConstants.java @@ -21,12 +21,8 @@ public class RootConstants { */ @Deprecated public static final String RESIZE_LAZY = "rL"; - @Deprecated - public static final String BROWSER_HEIGHT_VAR = "browserHeight"; @Deprecated - public static final String BROWSER_WIDTH_VAR = "browserWidth"; - @Deprecated public static final String NOTIFICATION_HTML_CONTENT_NOT_ALLOWED = "useplain"; @Deprecated diff --git a/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java index f074a8d3cc..df2031f7d5 100644 --- a/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java @@ -15,9 +15,12 @@ */ package com.vaadin.shared.ui.root; +import com.vaadin.shared.annotations.Delayed; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.ClickRpc; public interface RootServerRpc extends ClickRpc, ServerRpc { - + @Delayed(lastonly = true) + public void resize(int viewWidth, int viewHeight, int windowWidth, + int windowHeight); }
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/RootState.java b/shared/src/com/vaadin/shared/ui/root/RootState.java index 07c71c8167..b7c2c88ce5 100644 --- a/shared/src/com/vaadin/shared/ui/root/RootState.java +++ b/shared/src/com/vaadin/shared/ui/root/RootState.java @@ -20,7 +20,6 @@ import com.vaadin.shared.Connector; public class RootState extends ComponentState { private Connector content; - private int heartbeatInterval; public Connector getContent() { return content; @@ -30,11 +29,4 @@ public class RootState extends ComponentState { this.content = content; } - public int getHeartbeatInterval() { - return heartbeatInterval; - } - - public void setHeartbeatInterval(int heartbeatInterval) { - this.heartbeatInterval = heartbeatInterval; - } }
\ No newline at end of file diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java index b9621d518a..09f620cc2a 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/ColumnPropertyTest.java @@ -4,46 +4,48 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; +import java.util.ArrayList; import java.util.Arrays; -import com.vaadin.data.Property.ReadOnlyException; -import com.vaadin.data.util.sqlcontainer.ColumnProperty.NotNullableException; -import com.vaadin.data.util.sqlcontainer.query.QueryDelegate; - import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; +import com.vaadin.data.Property.ReadOnlyException; +import com.vaadin.data.util.sqlcontainer.ColumnProperty.NotNullableException; +import com.vaadin.data.util.sqlcontainer.query.QueryDelegate; + public class ColumnPropertyTest { @Test public void constructor_legalParameters_shouldSucceed() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertNotNull(cp); } @Test(expected = IllegalArgumentException.class) public void constructor_missingPropertyId_shouldFail() { - new ColumnProperty(null, false, true, true, "Ville", String.class); + new ColumnProperty(null, false, true, true, false, "Ville", + String.class); } @Test(expected = IllegalArgumentException.class) public void constructor_missingType_shouldFail() { - new ColumnProperty("NAME", false, true, true, "Ville", null); + new ColumnProperty("NAME", false, true, true, false, "Ville", null); } @Test public void getValue_defaultValue_returnsVille() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertEquals("Ville", cp.getValue()); } @Test public void setValue_readWriteNullable_returnsKalle() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); RowItem owner = new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); @@ -57,7 +59,7 @@ public class ColumnPropertyTest { @Test(expected = ReadOnlyException.class) public void setValue_readOnlyNullable_shouldFail() { ColumnProperty cp = new ColumnProperty("NAME", true, true, true, - "Ville", String.class); + false, "Ville", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); EasyMock.replay(container); @@ -68,7 +70,7 @@ public class ColumnPropertyTest { @Test public void setValue_readWriteNullable_nullShouldWork() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); RowItem owner = new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); @@ -82,7 +84,7 @@ public class ColumnPropertyTest { @Test(expected = NotNullableException.class) public void setValue_readWriteNotNullable_nullShouldFail() { ColumnProperty cp = new ColumnProperty("NAME", false, true, false, - "Ville", String.class); + false, "Ville", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); RowItem owner = new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); @@ -96,28 +98,28 @@ public class ColumnPropertyTest { @Test public void getType_normal_returnsStringClass() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertSame(String.class, cp.getType()); } @Test public void isReadOnly_readWriteNullable_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertFalse(cp.isReadOnly()); } @Test public void isReadOnly_readOnlyNullable_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", true, true, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertTrue(cp.isReadOnly()); } @Test public void setReadOnly_readOnlyChangeAllowed_shouldSucceed() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); cp.setReadOnly(true); Assert.assertTrue(cp.isReadOnly()); } @@ -125,7 +127,7 @@ public class ColumnPropertyTest { @Test public void setReadOnly_readOnlyChangeDisallowed_shouldFail() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, - "Ville", String.class); + false, "Ville", String.class); cp.setReadOnly(true); Assert.assertFalse(cp.isReadOnly()); } @@ -133,14 +135,14 @@ public class ColumnPropertyTest { @Test public void getPropertyId_normal_returnsNAME() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertEquals("NAME", cp.getPropertyId()); } @Test public void isModified_valueModified_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); RowItem owner = new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); @@ -155,14 +157,14 @@ public class ColumnPropertyTest { @Test public void isModified_valueNotModified_returnsFalse() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, - "Ville", String.class); + false, "Ville", String.class); Assert.assertFalse(cp.isModified()); } @Test public void setValue_nullOnNullable_shouldWork() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, - "asdf", String.class); + false, "asdf", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); cp.setValue(null); @@ -171,8 +173,8 @@ public class ColumnPropertyTest { @Test public void setValue_resetTonullOnNullable_shouldWork() { - ColumnProperty cp = new ColumnProperty("NAME", false, true, true, null, - String.class); + ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, + null, String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); cp.setValue("asdf"); @@ -202,7 +204,7 @@ public class ColumnPropertyTest { } ColumnProperty property = new ColumnProperty("NAME", false, true, true, - "Ville", String.class); + false, "Ville", String.class); Statement statement = EasyMock.createNiceMock(Statement.class); EasyMock.replay(statement); @@ -229,4 +231,85 @@ public class ColumnPropertyTest { Assert.assertEquals("Kalle", container.value); Assert.assertTrue(container.modified); } + + @Test + public void versionColumnsShouldNotBeInValueMap_shouldReturnFalse() { + ColumnProperty property = new ColumnProperty("NAME", false, true, true, + false, "Ville", String.class); + property.setVersionColumn(true); + + Assert.assertFalse(property.isPersistent()); + } + + @Test + public void neverWritableColumnsShouldNotBeInValueMap_shouldReturnFalse() { + ColumnProperty property = new ColumnProperty("NAME", true, false, true, + false, "Ville", String.class); + + Assert.assertFalse(property.isPersistent()); + } + + @Test + public void writableColumnsShouldBeInValueMap_shouldReturnTrue() { + ColumnProperty property = new ColumnProperty("NAME", false, true, true, + false, "Ville", String.class); + + Assert.assertTrue(property.isPersistent()); + } + + @Test + public void writableButReadOnlyColumnsShouldNotBeInValueMap_shouldReturnFalse() { + ColumnProperty property = new ColumnProperty("NAME", true, true, true, + false, "Ville", String.class); + + Assert.assertFalse(property.isPersistent()); + } + + @Test + public void primKeysShouldBeRowIdentifiers_shouldReturnTrue() { + ColumnProperty property = new ColumnProperty("NAME", false, true, true, + true, "Ville", String.class); + + Assert.assertTrue(property.isRowIdentifier()); + } + + @Test + public void versionColumnsShouldBeRowIdentifiers_shouldReturnTrue() { + ColumnProperty property = new ColumnProperty("NAME", false, true, true, + false, "Ville", String.class); + property.setVersionColumn(true); + + Assert.assertTrue(property.isRowIdentifier()); + } + + @Test + public void nonPrimKeyOrVersionColumnsShouldBeNotRowIdentifiers_shouldReturnFalse() { + ColumnProperty property = new ColumnProperty("NAME", false, true, true, + false, "Ville", String.class); + + Assert.assertFalse(property.isRowIdentifier()); + } + + @Test + public void getOldValueShouldReturnPreviousValue_shouldReturnVille() { + ColumnProperty property = new ColumnProperty("NAME", false, true, true, + false, "Ville", String.class); + + // Here we really don't care about the container management, but in + // order to set the value for a column the owner (RowItem) must be set + // and to create the owner we must have a container... + ArrayList<ColumnProperty> properties = new ArrayList<ColumnProperty>(); + properties.add(property); + + SQLContainer container = EasyMock.createNiceMock(SQLContainer.class); + RowItem rowItem = new RowItem(container, new RowId(new Object[] { 1 }), + Arrays.asList(property)); + + property.setValue("Kalle"); + // Just check that the new value was actually set... + Assert.assertEquals("Kalle", property.getValue()); + // Assert that old value is the original value... + Assert.assertEquals("Ville", property.getOldValue()); + } + } diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java index 657f06ae5e..e135894013 100644 --- a/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java +++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java @@ -18,15 +18,13 @@ import com.vaadin.data.Container.Filter; import com.vaadin.data.util.filter.Compare.Equal; import com.vaadin.data.util.filter.Like; import com.vaadin.data.util.sqlcontainer.AllTests; +import com.vaadin.data.util.sqlcontainer.AllTests.DB; import com.vaadin.data.util.sqlcontainer.DataGenerator; import com.vaadin.data.util.sqlcontainer.OptimisticLockException; import com.vaadin.data.util.sqlcontainer.RowItem; import com.vaadin.data.util.sqlcontainer.SQLContainer; -import com.vaadin.data.util.sqlcontainer.AllTests.DB; import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool; import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool; -import com.vaadin.data.util.sqlcontainer.query.OrderBy; -import com.vaadin.data.util.sqlcontainer.query.TableQuery; import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator; public class TableQueryTest { @@ -281,7 +279,9 @@ public class TableQueryTest { AllTests.sqlGen); try { tQuery.containsRowWithKey(new Object[] { null }); - } catch (SQLException e) { + org.junit.Assert + .fail("null should throw an IllegalArgumentException from StatementHelper"); + } catch (IllegalArgumentException e) { // We should now be able to reserve two connections connectionPool.reserveConnection(); connectionPool.reserveConnection(); diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java index fa730515a2..74770f8652 100644 --- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java +++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java @@ -6,15 +6,16 @@ import java.util.Properties; import junit.framework.TestCase; +import org.easymock.EasyMock; + import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.terminal.DefaultRootProvider; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Root; -import org.easymock.EasyMock; - public class CustomRootClassLoader extends TestCase { /** @@ -111,10 +112,17 @@ public class CustomRootClassLoader extends TestCase { private Application createStubApplication() { return new Application() { + { + addRootProvider(new DefaultRootProvider()); + } + @Override - protected String getRootClassName(WrappedRequest request) { - // Always use the same root class - return MyRoot.class.getName(); + public String getProperty(String name) { + if (name.equals(ROOT_PARAMETER)) { + return MyRoot.class.getName(); + } else { + return super.getProperty(name); + } } @Override diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java index 6b7b36c3f3..bb37082d30 100644 --- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -30,6 +30,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; +import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; import com.vaadin.terminal.gwt.server.WrappedHttpServletRequest; @@ -40,23 +42,6 @@ import com.vaadin.ui.Root; public class ApplicationRunnerServlet extends AbstractApplicationServlet { /** - * Internal implementation of an application with a dynamically selected - * Root implementation; - */ - private static class RootRunnerApplication extends Application { - private final Class<?> runnableClass; - - private RootRunnerApplication(Class<?> runnableClass) { - this.runnableClass = runnableClass; - } - - @Override - protected String getRootClassName(WrappedRequest request) { - return runnableClass.getCanonicalName(); - } - } - - /** * The name of the application class currently used. Only valid within one * request. */ @@ -126,7 +111,17 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { try { final Class<?> classToRun = getClassToRun(); if (Root.class.isAssignableFrom(classToRun)) { - return new RootRunnerApplication(classToRun); + Application application = new Application(); + application.addRootProvider(new AbstractRootProvider() { + + @Override + public Class<? extends Root> getRootClass( + Application application, WrappedRequest request) + throws RootRequiresMoreInformationException { + return (Class<? extends Root>) classToRun; + } + }); + return application; } else if (Application.class.isAssignableFrom(classToRun)) { return (Application) classToRun.newInstance(); } else { @@ -221,7 +216,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { throws ClassNotFoundException { Class<?> classToRun = getClassToRun(); if (Root.class.isAssignableFrom(classToRun)) { - return RootRunnerApplication.class; + return Application.class; } else if (Application.class.isAssignableFrom(classToRun)) { return classToRun.asSubclass(Application.class); } else { diff --git a/tests/testbench/com/vaadin/tests/Parameters.java b/tests/testbench/com/vaadin/tests/Parameters.java index 4fb224eb19..e9824d9c40 100644 --- a/tests/testbench/com/vaadin/tests/Parameters.java +++ b/tests/testbench/com/vaadin/tests/Parameters.java @@ -27,7 +27,7 @@ import com.vaadin.terminal.RequestHandler; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; import com.vaadin.ui.Root.LegacyWindow; @@ -90,7 +90,7 @@ public class Parameters extends com.vaadin.Application.LegacyApplication final Panel panel2 = new Panel("Parameter Handler"); params.setSizeFull(); panel2.setContent(new VerticalLayout()); - ((Layout) panel2.getContent()).setMargin(true); + ((MarginHandler) panel2.getContent()).setMargin(true); params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID); panel2.addComponent(params); diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java index 36a793bd6d..bd2aea3756 100644 --- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java +++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java @@ -1,5 +1,8 @@ package com.vaadin.tests.application; +import com.vaadin.Application; +import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; @@ -20,11 +23,14 @@ public class RefreshStatePreserve extends AbstractTestApplication { public void init() { super.init(); setRootPreserved(true); - } - - @Override - protected String getRootClassName(WrappedRequest request) { - return RefreshStateRoot.class.getName(); + addRootProvider(new AbstractRootProvider() { + @Override + public Class<? extends Root> getRootClass(Application application, + WrappedRequest request) + throws RootRequiresMoreInformationException { + return RefreshStateRoot.class; + } + }); } @Override diff --git a/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java b/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java index af62e5e4a4..c04be3d724 100644 --- a/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java +++ b/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java @@ -2,11 +2,12 @@ package com.vaadin.tests.components; import java.util.LinkedHashMap; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.ui.AbstractLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Component; import com.vaadin.ui.Layout.AlignmentHandler; -import com.vaadin.ui.Layout.MarginInfo; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Layout.SpacingHandler; public abstract class AbstractLayoutTest<T extends AbstractLayout> extends @@ -17,7 +18,7 @@ public abstract class AbstractLayoutTest<T extends AbstractLayout> extends @Override public void execute(T c, MarginInfo value, Object data) { - c.setMargin(value); + ((MarginHandler) c).setMargin(value); } }; @@ -42,7 +43,9 @@ public abstract class AbstractLayoutTest<T extends AbstractLayout> extends @Override protected void createActions() { super.createActions(); - createMarginsSelect(CATEGORY_LAYOUT_FEATURES); + if (MarginHandler.class.isAssignableFrom(getTestClass())) { + createMarginsSelect(CATEGORY_LAYOUT_FEATURES); + } if (SpacingHandler.class.isAssignableFrom(getTestClass())) { createSpacingSelect(CATEGORY_LAYOUT_FEATURES); } diff --git a/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java b/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java index 0bc4f45545..0655c09102 100644 --- a/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java +++ b/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java @@ -4,6 +4,7 @@ import java.util.Arrays; import com.vaadin.data.Item; import com.vaadin.data.util.BeanItem; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.tests.util.Person; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; @@ -13,6 +14,7 @@ import com.vaadin.ui.DefaultFieldFactory; import com.vaadin.ui.Field; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Layout.MarginHandler; /** * Example of nested forms @@ -37,7 +39,8 @@ public class NestedPersonForm extends Form { setItemDataSource(beanItem, Arrays.asList("firstName", "lastName", "address", "email", "phoneNumber")); getFooter().addComponent(getButtonsLayout()); - getFooter().setMargin(false, false, true, true); + ((MarginHandler) getFooter()).setMargin(new MarginInfo(false, false, + true, true)); } /** diff --git a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html index 64fe8e2952..2783ed2aa3 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html +++ b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html @@ -24,7 +24,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup1-01-2011</td> </tr> <tr> <td>mouseClick</td> @@ -34,7 +34,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup1-12-2010</td> </tr> <tr> <td>mouseClick</td> @@ -44,7 +44,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup1-12-2009</td> </tr> <tr> <td>mouseClick</td> @@ -64,7 +64,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup2-02-2010</td> </tr> <tr> <td>pressSpecialKey</td> @@ -79,7 +79,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup2-03-2010</td> </tr> <tr> <td>pressSpecialKey</td> @@ -94,7 +94,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup2-02-2010-again</td> </tr> <tr> <td>mouseClick</td> @@ -114,7 +114,7 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup3-01-2010</td> </tr> <tr> <td>pressSpecialKey</td> @@ -124,14 +124,13 @@ <tr> <td>screenCapture</td> <td></td> - <td></td> + <td>popup3-01-2009</td> </tr> <tr> <td>mouseClick</td> <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> <td>10,8</td> </tr> - </tbody></table> </body> </html> diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.html b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.html new file mode 100644 index 0000000000..d8fb0593d1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.html @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>EmbeddedClickListenerRelativeCoordinates</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">EmbeddedClickListenerRelativeCoordinates</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.embedded.EmbeddedApplet?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>with-applet</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedApplet::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>without-applet</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java new file mode 100644 index 0000000000..1bb3e7abe2 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java @@ -0,0 +1,43 @@ +package com.vaadin.tests.components.embedded; + +import com.vaadin.terminal.ExternalResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Embedded; +import com.vaadin.ui.Label; +import com.vaadin.ui.Window; + +public class EmbeddedApplet extends TestBase { + + @Override + protected String getDescription() { + return "The sub window should be shown on top of the embedded applet"; + } + + @Override + protected Integer getTicketNumber() { + return 8399; + } + + @Override + public void setup() { + final Embedded applet = new Embedded(); + applet.setType(Embedded.TYPE_BROWSER); + applet.setWidth("400px"); + applet.setHeight("300px"); + applet.setSource(new ExternalResource("/statictestfiles/applet.html")); + addComponent(applet); + + addComponent(new Button("Remove applet", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + removeComponent(applet); + } + })); + + Window window = new Window("Testwindow"); + window.addComponent(new Label("I am inside the window")); + applet.getRoot().addWindow(window); + } +} diff --git a/tests/testbench/com/vaadin/tests/components/embedded/TestApplet.java b/tests/testbench/com/vaadin/tests/components/embedded/TestApplet.java new file mode 100644 index 0000000000..3cf7cf888b --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/embedded/TestApplet.java @@ -0,0 +1,11 @@ +package com.vaadin.tests.components.embedded; + +import java.applet.Applet; +import java.awt.Graphics; + +public class TestApplet extends Applet { + @Override + public void paint(Graphics g) { + g.drawString("Hello, I am an applet! Look at me!", 10, 20); + } +} diff --git a/tests/testbench/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html b/tests/testbench/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html index 288fd65c66..1ab75e1176 100644 --- a/tests/testbench/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html +++ b/tests/testbench/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html @@ -34,7 +34,7 @@ <tr> <td>keyDown</td> <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]</td> - <td>\\27</td> + <td>\27</td> </tr> <!-- Fade delay is 400 ms by default - VNotification --> <tr> diff --git a/tests/testbench/com/vaadin/tests/components/notification/SemiTransparentNotification.java b/tests/testbench/com/vaadin/tests/components/notification/SemiTransparentNotification.java new file mode 100755 index 0000000000..8fefac16a1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/notification/SemiTransparentNotification.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.components.notification; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.LoremIpsum; +import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; + +public class SemiTransparentNotification extends TestBase { + + @Override + protected void setup() { + Label l = new Label(LoremIpsum.get(10000)); + getLayout().setSizeFull(); + addComponent(l); + Notification.show(" This should be a <br/><b>SEMI-TRANSPARENT</b><br/> notification", + Notification.TYPE_WARNING_MESSAGE); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/notification/SemitransparentNotification.html b/tests/testbench/com/vaadin/tests/components/notification/SemitransparentNotification.html new file mode 100755 index 0000000000..f125b98ee1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/notification/SemitransparentNotification.html @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.notification.SemiTransparentNotification</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>semitransparent-warning</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.html b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.html new file mode 100644 index 0000000000..c52bfa634d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.html @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8068/" /> +<title>PopupViewClickShortcut</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">PopupViewClickShortcut</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.popupview.PopupViewClickShortcut?restartApplication=</td> + <td></td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::</td> + <td>ctrl alt M</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[5]/domChild[0]/domChild[0]</td> + <td>added 5</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_0</td> + <td>1. Submitted from Main window</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupView[0]</td> + <td>57,6</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::</td> + <td>ctrl alt P</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupView[0]/VPopupView$CustomPopup[0]/VCaptionWrapper[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>159,142</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupView[0]/VPopupView$CustomPopup[0]/VCaptionWrapper[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>ctrl alt P</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupView[0]/VPopupView$CustomPopup[0]/VCaptionWrapper[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[0]</td> + <td>added 6</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_1</td> + <td>2. Submitted from Popup</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_0</td> + <td>3. Submitted from Popup</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>83,151</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>ctrl alt S</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[5]/domChild[0]/domChild[0]</td> + <td>added 5</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_0</td> + <td>4. Submitted from Subwindow</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupView[0]</td> + <td>76,4</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]</td> + <td>ctrl alt U</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupView[0]/VPopupView$CustomPopup[0]/VCaptionWrapper[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[5]/domChild[0]/domChild[0]</td> + <td>132,11</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupView[0]/VPopupView$CustomPopup[0]/VCaptionWrapper[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>ctrl alt U</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupView[0]/VPopupView$CustomPopup[0]/VCaptionWrapper[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[0]</td> + <td>added 6</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_1</td> + <td>5. Submitted from Subwindow popup</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_0</td> + <td>6. Submitted from Subwindow popup</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::/VVerticalLayout[0]/domChild[0]/domChild[1]</td> + <td>279,482</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::</td> + <td>ctrl alt P</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::</td> + <td>ctrl alt U</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::</td> + <td>ctrl alt S</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentspopupviewPopupViewClickShortcut::PID_SLog_row_0</td> + <td>6. Submitted from Subwindow popup</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java index 6461d10277..ba4fe93b68 100644 --- a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java +++ b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java @@ -46,17 +46,17 @@ public class PopupViewClickShortcut extends TestBase { l.setWidth(null); Button b = new Button("Submit " + caption + " (Ctrl+Alt+" - + String.valueOf(Character.toChars(keyCode)) + ")", - new Button.ClickListener() { - private int i = 5; + + (char) keyCode + ")", new Button.ClickListener() { + private int i = 5; + + @Override + public void buttonClick(ClickEvent event) { + log.log("Submitted from " + + event.getButton().getParent().getCaption()); + t.addItem(new String[] { "added " + i++ }, i); + } + }); - @Override - public void buttonClick(ClickEvent event) { - log.log("Submitted from " - + event.getButton().getParent().getCaption()); - t.addItem(new String[] { "added " + i++ }, i); - } - }); b.setClickShortcut(keyCode, ModifierKey.CTRL, ModifierKey.ALT); l.addComponent(t); diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java index c3b20c5e7c..ae3182401d 100644 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java +++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java @@ -1,5 +1,8 @@ package com.vaadin.tests.components.root; +import com.vaadin.Application; +import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; @@ -19,9 +22,15 @@ public class RootsInMultipleTabs extends AbstractTestApplication { } } - @Override - protected String getRootClassName(WrappedRequest request) { - return TabRoot.class.getName(); + public RootsInMultipleTabs() { + addRootProvider(new AbstractRootProvider() { + @Override + public Class<? extends Root> getRootClass(Application application, + WrappedRequest request) + throws RootRequiresMoreInformationException { + return TabRoot.class; + } + }); } @Override diff --git a/tests/testbench/com/vaadin/tests/components/table/EmptyTable.html b/tests/testbench/com/vaadin/tests/components/table/EmptyTable.html index 58f26cf607..7196771f56 100644 --- a/tests/testbench/com/vaadin/tests/components/table/EmptyTable.html +++ b/tests/testbench/com/vaadin/tests/components/table/EmptyTable.html @@ -65,7 +65,7 @@ <tr> <td>screenCapture</td> <td></td> - <td>empty-table</td> + <td>empty-table-after-reload</td> </tr> </tbody></table> </body> diff --git a/tests/testbench/com/vaadin/tests/components/table/HorizontalScrollWithNoRows.html b/tests/testbench/com/vaadin/tests/components/table/HorizontalScrollWithNoRows.html new file mode 100644 index 0000000000..98629252d9 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/table/HorizontalScrollWithNoRows.html @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td> + <td></td> +</tr> +<!--Remove all rows--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td> + <td>23,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item5</td> + <td>33,5</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item1</td> + <td>50,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item0</td> + <td>54,10</td> +</tr> +<!--Remove log--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item1</td> + <td>28,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item0</td> + <td>29,5</td> +</tr> +<!--Resize column, should get scrollbar--> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>0,7</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>150,7</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>1-wide-header</td> +</tr> +<!--Resize back, scrollbar should disappear--> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>0,7</td> +</tr> +<!-- Overcompensate by 2px because of off-by-one bug in testbench --> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>-152,7</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>2-narrow-header</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/textarea/TextAreaMaxLength.html b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaMaxLength.html new file mode 100755 index 0000000000..5fe43b7b7a --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaMaxLength.html @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://arturwin.office.itmill.com:9999/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.textarea.TextAreaTest?debug&restartApplication</td> + <td></td> +</tr> +<!--max length 5--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextareaTextAreaTest::PID_Smenu#item0</td> + <td>20,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextareaTextAreaTest::Root/VOverlay[0]/VMenuBar[0]#item5</td> + <td>43,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextareaTextAreaTest::Root/VOverlay[1]/VMenuBar[0]#item2</td> + <td>70,13</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextareaTextAreaTest::Root/VOverlay[2]/VMenuBar[0]#item5</td> + <td>40,9</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestscomponentstextareaTextAreaTest::PID_StestComponent</td> + <td>0123456789</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentstextareaTextAreaTest::PID_StestComponent</td> + <td>01234</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html b/tests/testbench/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html new file mode 100644 index 0000000000..bf83a1acdb --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>TreeItemClickAndValueChange</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TreeItemClickAndValueChange</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/Trees?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::PID_Smenu#item0</td> + <td>19,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::Root/VOverlay[0]/VMenuBar[0]#item3</td> + <td>23,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::Root/VOverlay[1]/VMenuBar[0]#item0</td> + <td>38,6</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::PID_Smenu#item0</td> + <td>52,12</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::Root/VOverlay[0]/VMenuBar[0]#item3</td> + <td>53,12</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::Root/VOverlay[1]/VMenuBar[0]#item4</td> + <td>50,4</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::PID_StestComponent#n[0]</td> + <td>22,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTrees::PID_StestComponent#n[1]</td> + <td>20,6</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTrees::PID_SLog_row_0</td> + <td>5. ValueChangeEvent, new value: '[Item 2]'</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTrees::PID_SLog_row_1</td> + <td>4. left click on source: [Item 1], client: [*];, relative: [-1,-1], itemId: Item 2, propertyId: null</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTrees::PID_SLog_row_2</td> + <td>3. ValueChangeEvent, new value: '[Item 1]'</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTrees::PID_SLog_row_3</td> + <td>2. left click on source: [], client: [*];, relative: [-1,-1], itemId: Item 1, propertyId: null</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html b/tests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html new file mode 100755 index 0000000000..15dc0e074d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/treetable/AddItemToEmptyTreeTable.html @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.treetable.TreeTableTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::PID_Smenu#item0</td> + <td>38,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[0]/VMenuBar[0]#item5</td> + <td>52,6</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[1]/VMenuBar[0]#item1</td> + <td>68,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[2]/VMenuBar[0]#item0</td> + <td>12,4</td> +</tr> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.treetable.TreeTableTest</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::PID_Smenu#item0</td> + <td>33,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[0]/VMenuBar[0]#item5</td> + <td>52,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[1]/VMenuBar[0]#item1</td> + <td>39,5</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstreetableTreeTableTest::Root/VOverlay[2]/VMenuBar[0]#item1</td> + <td>23,3</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>item-added-to-empty-treetable</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java index 1ea800821b..a35b78c219 100644 --- a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java +++ b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java @@ -8,6 +8,7 @@ import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.event.Action; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.Page; @@ -103,7 +104,6 @@ public class LiferayThemeDemo extends Application.LegacyApplication { mainLayout.addComponent(getTopMenu()); CssLayout margin = new CssLayout(); - margin.setMargin(false, true, true, true); margin.setSizeFull(); tabs = new TabSheet(); tabs.setSizeFull(); @@ -239,7 +239,7 @@ public class LiferayThemeDemo extends Application.LegacyApplication { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); - hl.setMargin(true, false, false, false); + hl.setMargin(new MarginInfo(true, false, false, false)); l.addComponent(hl); AbstractSelect cb = new ComboBox(); @@ -270,7 +270,7 @@ public class LiferayThemeDemo extends Application.LegacyApplication { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); - hl.setMargin(true, false, false, false); + hl.setMargin(new MarginInfo(true, false, false, false)); l.addComponent(hl); DateField df = new DateField(); diff --git a/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java b/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java index 792bcb1aab..ed35d39ef7 100644 --- a/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java +++ b/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java @@ -12,6 +12,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.NativeButton; public class CssLayoutCustomCss extends TestBase implements ClickListener { @@ -48,7 +49,7 @@ public class CssLayoutCustomCss extends TestBase implements ClickListener { @Override public void valueChange(ValueChangeEvent event) { - layout.setMargin(cb.getValue()); + ((MarginHandler) layout).setMargin(cb.getValue()); } }); diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java index 1c864fdb47..e200c40744 100644 --- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java +++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java @@ -3,7 +3,7 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Panel; public class GridLayoutInsidePanel extends TestBase { @@ -27,7 +27,7 @@ public class GridLayoutInsidePanel extends TestBase { "A label which defines the size of the GL")); Panel p = new Panel("Panel 1"); - ((Layout) p.getContent()).setMargin(false); + ((MarginHandler) p.getContent()).setMargin(false); p.setSizeUndefined(); p.getContent().setSizeUndefined(); @@ -41,7 +41,7 @@ public class GridLayoutInsidePanel extends TestBase { "A label which defines the size of the GL")); Panel p = new Panel("Panel 2", gl); - ((Layout) p.getContent()).setMargin(false); + ((MarginHandler) p.getContent()).setMargin(false); p.setSizeUndefined(); p.getContent().setSizeUndefined(); diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java new file mode 100644 index 0000000000..6a873a6be3 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 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.serialization; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.widgetset.server.DummyLabel; +import com.vaadin.ui.Label; + +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class SerializerNamespaceTest extends AbstractTestRoot { + + @Override + protected void setup(WrappedRequest request) { + addComponent(new Label("The real label")); + addComponent(new DummyLabel("The dummy label")); + } + + @Override + protected String getTestDescription() { + return "Using connectors with different state classes having the same simple name should not cause any clietn-side exceptions"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8683); + } + +} diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.html b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.html index 3d52356cab..4417fabf14 100644 --- a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.html +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.html @@ -18,90 +18,94 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[16]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[17]</td> <td>1. sendBoolean: false, false, [false, false, true, false, true, true]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[15]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[16]</td> <td>2. sendByte: 5, -12, [3, 1, 2]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[14]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[15]</td> <td>3. sendChar: Å, ∫, [a, b, c, d]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[13]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[14]</td> <td>4. sendInt: 2, 5, [2147483647, 0]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[12]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[13]</td> <td>5. sendLong: -57841235865, 577431841358, [57, 0]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[11]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[12]</td> <td>6. sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[10]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[11]</td> <td>7. sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[9]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[10]</td> <td>8. sendString: Taegghiiiinnrsssstt‡</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[8]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[9]</td> <td>9. sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[7]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[8]</td> <td>10. sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[6]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[7]</td> <td>11. sendNull: null, Not null</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[5]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[6]</td> <td>12. sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[4]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[5]</td> <td>13. sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[3]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[4]</td> <td>14. sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[2]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[3]</td> <td>15. sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[2]</td> <td>16. sendMap: {a=null}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=false], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]</td> <td>17. sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}</td> </tr> - +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]</td> + <td>18. sendEnum: PREFORMATTED, [XHTML, RAW], [PREFORMATTED, XML]</td> +</tr> </tbody></table> </body> </html> diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java index da4b5dd7d9..a301ecf828 100644 --- a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java @@ -28,6 +28,7 @@ import java.util.Set; import com.vaadin.annotations.Widgetset; import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestRoot; import com.vaadin.tests.util.Log; @@ -122,6 +123,10 @@ public class SerializerTest extends AbstractTestRoot { } }); + rpc.sendEnum(ContentMode.TEXT, new ContentMode[] { + ContentMode.PREFORMATTED, ContentMode.XML }, + Arrays.asList(ContentMode.XHTML, ContentMode.RAW)); + testExtension.registerRpc(new SerializerTestRpc() { @Override public void sendBoolean(boolean value, Boolean boxedValue, @@ -288,6 +293,13 @@ public class SerializerTest extends AbstractTestRoot { log.log("sendWrappedGenerics: " + generics.toString()); } + @Override + public void sendEnum(ContentMode contentMode, ContentMode[] array, + List<ContentMode> list) { + log.log("sendEnum: " + contentMode + ", " + + Arrays.toString(array) + ", " + list); + } + }); } diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java index 438f7e2d5f..d6d3b132c3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java @@ -10,6 +10,7 @@ import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Panel; import com.vaadin.ui.Root.LegacyWindow; import com.vaadin.ui.Table; @@ -159,7 +160,7 @@ public class Ticket1435 extends Application.LegacyApplication { private void initContainer() { container.setStyleName("custompanel"); container.setSizeFull(); - ((Layout) container.getContent()).setMargin(false); + ((MarginHandler) container.getContent()).setMargin(false); container.getContent().setSizeFull(); root.addComponent(container); root.setExpandRatio(container, 1); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java index b9fd2debd5..87ea7e86a8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java @@ -1,5 +1,6 @@ package com.vaadin.tests.tickets; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; @@ -82,19 +83,19 @@ public class Ticket1572 extends com.vaadin.Application.LegacyApplication { state.setValue("Margin on"); break; case 2: - gl.setMargin(true, false, false, false); + gl.setMargin(new MarginInfo(true, false, false, false)); state.setValue("Margin top"); break; case 3: - gl.setMargin(false, true, false, false); + gl.setMargin(new MarginInfo(false, true, false, false)); state.setValue("Margin right"); break; case 4: - gl.setMargin(false, false, true, false); + gl.setMargin(new MarginInfo(false, false, true, false)); state.setValue("Margin bottom"); break; case 5: - gl.setMargin(false, false, false, true); + gl.setMargin(new MarginInfo(false, false, false, true)); state.setValue("Margin left"); break; default: diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java index 01792aeb89..1f2c9624c3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java @@ -5,6 +5,7 @@ import java.util.Iterator; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.util.MethodProperty; +import com.vaadin.shared.ui.MarginInfo; import com.vaadin.terminal.SystemError; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.AbstractComponent; @@ -393,10 +394,13 @@ public class Ticket1710 extends com.vaadin.Application.LegacyApplication { } private void updateMarginsAndSpacing() { - testedLayout.setMargin(marginTop.getValue().booleanValue(), - marginRight.getValue().booleanValue(), marginBottom - .getValue().booleanValue(), marginLeft.getValue() - .booleanValue()); + if (testedLayout instanceof Layout.MarginHandler) { + ((Layout.MarginHandler) testedLayout).setMargin(new MarginInfo( + marginTop.getValue().booleanValue(), marginRight + .getValue().booleanValue(), marginBottom + .getValue().booleanValue(), marginLeft + .getValue().booleanValue())); + } if (testedLayout instanceof Layout.SpacingHandler) { ((Layout.SpacingHandler) testedLayout).setSpacing(spacing .getValue().booleanValue()); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java index a40f5b25b9..e5fcf59db8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Root.LegacyWindow; import com.vaadin.ui.TextField; @@ -17,7 +17,7 @@ public class Ticket1805 extends com.vaadin.Application.LegacyApplication { final LegacyWindow main = new LegacyWindow(getClass().getName() .substring(getClass().getName().lastIndexOf(".") + 1)); setMainWindow(main); - ((Layout) main.getContent()).setMargin(false); + ((MarginHandler) main.getContent()).setMargin(false); Label description = new Label( "GridLayout with 100% (no height), is wanted to " diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java index c36bb5c25e..f6d8ce5e01 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java @@ -9,6 +9,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Panel; import com.vaadin.ui.Root.LegacyWindow; import com.vaadin.ui.TextArea; @@ -78,7 +79,7 @@ public class Ticket2021 extends Application.LegacyApplication { p3.setHeight("500px"); // p3.setContent(new GridLayout()); p3.getContent().setSizeFull(); - ((Layout) p3.getContent()).setMargin(false); + ((MarginHandler) p3.getContent()).setMargin(false); GridLayout gl = new GridLayout(); gl.setSizeFull(); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java index ac8928d110..d98656b9ca 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Accordion; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Root.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; @@ -17,7 +17,7 @@ public class Ticket2040 extends com.vaadin.Application.LegacyApplication { setMainWindow(main); main.getContent().setSizeFull(); - ((Layout) main.getContent()).setMargin(true); + ((MarginHandler) main.getContent()).setMargin(true); setTheme("tests-tickets"); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java index 16a552e37a..c5ef9ec0b0 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Root.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -31,7 +31,7 @@ public class Ticket2405 extends Application.LegacyApplication { setMainWindow(root); root.getContent().setSizeFull(); - ((Layout) root.getContent()).setMargin(false); + ((MarginHandler) root.getContent()).setMargin(false); // Top area, containing playback and volume controls, play status, view // modes and search diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java index ee60c0ce7e..2d2970d36e 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java @@ -19,6 +19,7 @@ import com.vaadin.ui.DefaultFieldFactory; import com.vaadin.ui.Field; import com.vaadin.ui.FormLayout; import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.ListSelect; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; @@ -252,7 +253,7 @@ public class Ticket2998 extends Application.LegacyApplication { // set theme and some layout stuff setMainWindow(w); w.getContent().setSizeFull(); - ((Layout) w.getContent()).setMargin(false); + ((MarginHandler) w.getContent()).setMargin(false); Panel p = new Panel("Workout Log"); p.setStyleName(Reindeer.PANEL_LIGHT); diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DummyLabelConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/DummyLabelConnector.java new file mode 100644 index 0000000000..bf3a472b33 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/DummyLabelConnector.java @@ -0,0 +1,50 @@ +/* + * Copyright 2011 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.widgetset.client; + +import com.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; +import com.vaadin.terminal.gwt.client.ui.label.VLabel; +import com.vaadin.tests.widgetset.server.DummyLabel; + +/** + * Dummy connector just to cause {@link LabelState} to be used to test #8683 + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +@Connect(DummyLabel.class) +public class DummyLabelConnector extends AbstractComponentConnector { + @Override + public LabelState getState() { + return (LabelState) super.getState(); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + + getWidget().setText(getState().getText()); + } + + @Override + public VLabel getWidget() { + return (VLabel) super.getWidget(); + } +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/LabelState.java b/tests/testbench/com/vaadin/tests/widgetset/client/LabelState.java new file mode 100644 index 0000000000..91a269e33f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/LabelState.java @@ -0,0 +1,41 @@ +/* + * Copyright 2011 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.widgetset.client; + +import com.vaadin.shared.ComponentState; + +/** + * State class with the same simple name as + * {@link com.vaadin.shared.ui.label.LabelState} to test #8683 + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public class LabelState extends ComponentState { + + private String text; + + public void setText(String text) { + this.text = text; + } + + public String getText() { + return text; + } + +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 3977ff7f71..9fb6807bb7 100644 --- a/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -28,6 +28,7 @@ import java.util.Set; import com.vaadin.shared.Connector; import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.gwt.client.communication.RpcProxy; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector; @@ -231,6 +232,16 @@ public class SerializerTestConnector extends AbstractExtensionConnector { objectListArray[0] }, new List[] { Collections .singletonList(beanListArray[0].get(0)) }); } + + @Override + public void sendEnum(ContentMode contentMode, ContentMode[] array, + List<ContentMode> list) { + ContentMode nextContentMode = ContentMode.values()[contentMode + .ordinal() + 1]; + rpc.sendEnum(nextContentMode, + list.toArray(new ContentMode[list.size()]), + Arrays.asList(array)); + } }); } diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java index 47a26b7408..eb3a20e90e 100644 --- a/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java +++ b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java @@ -23,6 +23,7 @@ import java.util.Set; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.label.ContentMode; @SuppressWarnings("javadoc") public interface SerializerTestRpc extends ServerRpc, ClientRpc { @@ -73,4 +74,6 @@ public interface SerializerTestRpc extends ServerRpc, ClientRpc { public void sendWrappedGenerics( Map<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>> generics); + public void sendEnum(ContentMode contentMode, ContentMode[] array, List<ContentMode> list); + } diff --git a/tests/testbench/com/vaadin/tests/widgetset/server/DummyLabel.java b/tests/testbench/com/vaadin/tests/widgetset/server/DummyLabel.java new file mode 100644 index 0000000000..bda36d64a8 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/server/DummyLabel.java @@ -0,0 +1,38 @@ +/* + * Copyright 2011 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.widgetset.server; + +import com.vaadin.tests.widgetset.client.LabelState; +import com.vaadin.ui.AbstractComponent; + +/** + * Dummy component to cause {@link LabelState} to be used to test #8683 + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + */ +public class DummyLabel extends AbstractComponent { + public DummyLabel(String text) { + getState().setText(text); + } + + @Override + public LabelState getState() { + return (LabelState) super.getState(); + } +} |