diff options
author | Marc Englund <marc@vaadin.com> | 2012-10-04 09:34:37 +0300 |
---|---|---|
committer | Marc Englund <marc@vaadin.com> | 2012-10-04 09:34:37 +0300 |
commit | 0f5606dace38d575efcd2e0109390b34aebb05d3 (patch) | |
tree | 5d0a032ebecbec80a33f90971ae2d0a37ab43956 | |
parent | 76b0655b29ed8aa4b1287f2b68322ed1f9c58faa (diff) | |
parent | 7fbe0ffd7c967728a1e437d0cbe03722ed9f1b6e (diff) | |
download | vaadin-framework-0f5606dace38d575efcd2e0109390b34aebb05d3.tar.gz vaadin-framework-0f5606dace38d575efcd2e0109390b34aebb05d3.zip |
Merge branch 'master' into sass
Conflicts:
WebContent/VAADIN/themes/base/formlayout/formlayout.scss
WebContent/VAADIN/themes/reindeer/formlayout/formlayout.scss
Change-Id: Ie895a1bbafdcf2fe79d500efb04c6eef3f5a812e
52 files changed, 1390 insertions, 324 deletions
diff --git a/WebContent/VAADIN/themes/base/formlayout/formlayout.scss b/WebContent/VAADIN/themes/base/formlayout/formlayout.scss index 48a1bf0fde..6bfe112254 100644 --- a/WebContent/VAADIN/themes/base/formlayout/formlayout.scss +++ b/WebContent/VAADIN/themes/base/formlayout/formlayout.scss @@ -23,30 +23,30 @@ .#{$name}-captioncell .v-caption { overflow: visible; } -.#{$name}-spacing .#{$name}-row .#{$name}-captioncell, -.#{$name}-spacing .#{$name}-row .#{$name}-contentcell, -.#{$name}-spacing .#{$name}-row .#{$name}-errorcell { +.#{$name}-spacing > tbody > .#{$name}-row > .#{$name}-captioncell, +.#{$name}-spacing > tbody > .#{$name}-row > .#{$name}-contentcell, +.#{$name}-spacing > tbody > .#{$name}-row > .#{$name}-errorcell { padding-top: 6px; } -.#{$name}-spacing .#{$name}-firstrow .#{$name}-captioncell, -.#{$name}-spacing .#{$name}-firstrow .#{$name}-contentcell, -.#{$name}-spacing .#{$name}-firstrow .#{$name}-errorcell { +.#{$name}-spacing > tbody > .#{$name}-firstrow > .#{$name}-captioncell, +.#{$name}-spacing > tbody > .#{$name}-firstrow > .#{$name}-contentcell, +.#{$name}-spacing > tbody > .#{$name}-firstrow > .#{$name}-errorcell { padding-top: 0; } -.#{$name}-margin-top .#{$name}-firstrow .#{$name}-captioncell, -.#{$name}-margin-top .#{$name}-firstrow .#{$name}-contentcell, -.#{$name}-margin-top .#{$name}-firstrow .#{$name}-errorcell { +.#{$name}-margin-top > tbody > .#{$name}-firstrow > .#{$name}-captioncell, +.#{$name}-margin-top > tbody > .#{$name}-firstrow > .#{$name}-contentcell, +.#{$name}-margin-top > tbody > .#{$name}-firstrow > .#{$name}-errorcell { padding-top: 12px; } -.#{$name}-margin-bottom .#{$name}-lastrow .#{$name}-captioncell, -.#{$name}-margin-bottom .#{$name}-lastrow .#{$name}-contentcell, -.#{$name}-margin-bottom .#{$name}-lastrow .#{$name}-errorcell { +.#{$name}-margin-bottom > tbody > .#{$name}-lastrow > .#{$name}-captioncell, +.#{$name}-margin-bottom > tbody > .#{$name}-lastrow > .#{$name}-contentcell, +.#{$name}-margin-bottom > tbody > .#{$name}-lastrow > .#{$name}-errorcell { padding-bottom: 12px; } -.#{$name}-margin-left .#{$name}-captioncell { +.#{$name}-margin-left > tbody > .#{$name}-row > .#{$name}-captioncell { padding-left: 12px; } -.#{$name}-margin-right .#{$name}-contentcell { +.#{$name}-margin-right > tbody > .#{$name}-row > .#{$name}-contentcell { padding-right: 12px; } .#{$name}-captioncell .v-caption .v-required-field-indicator { diff --git a/WebContent/VAADIN/themes/reindeer/formlayout/formlayout.scss b/WebContent/VAADIN/themes/reindeer/formlayout/formlayout.scss index 010d6e7db2..cecc439b09 100644 --- a/WebContent/VAADIN/themes/reindeer/formlayout/formlayout.scss +++ b/WebContent/VAADIN/themes/reindeer/formlayout/formlayout.scss @@ -12,25 +12,25 @@ text-align: right; white-space: nowrap; } -.#{$name}-spacing .#{$name}-row .#{$name}-captioncell, -.#{$name}-spacing .#{$name}-row .#{$name}-contentcell, -.#{$name}-spacing .#{$name}-row .#{$name}-errorcell { +.#{$name}-spacing > tbody > .#{$name}-row > .#{$name}-captioncell, +.#{$name}-spacing > tbody > .#{$name}-row > .#{$name}-contentcell, +.#{$name}-spacing > tbody > .#{$name}-row > .#{$name}-errorcell { padding-top: 8px; } -.#{$name}-margin-top .#{$name}-firstrow .#{$name}-captioncell, -.#{$name}-margin-top .#{$name}-firstrow .#{$name}-contentcell, -.#{$name}-margin-top .#{$name}-firstrow .#{$name}-errorcell { +.#{$name}-margin-top > tbody > .#{$name}-firstrow > .#{$name}-captioncell, +.#{$name}-margin-top > tbody > .#{$name}-firstrow > .#{$name}-contentcell, +.#{$name}-margin-top > tbody > .#{$name}-firstrow > .#{$name}-errorcell { padding-top: 15px; } -.#{$name}-margin-bottom .#{$name}-lastrow .#{$name}-captioncell, -.#{$name}-margin-bottom .#{$name}-lastrow .#{$name}-contentcell, -.#{$name}-margin-bottom .#{$name}-lastrow .#{$name}-errorcell { +.#{$name}-margin-bottom > tbody > .#{$name}-lastrow > .#{$name}-captioncell, +.#{$name}-margin-bottom > tbody > .#{$name}-lastrow > .#{$name}-contentcell, +.#{$name}-margin-bottom > tbody > .#{$name}-lastrow > .#{$name}-errorcell { padding-bottom: 15px; } -.#{$name}-margin-left .#{$name}-captioncell { +.#{$name}-margin-left > tbody > .#{$name}-row > .#{$name}-captioncell { padding-left: 18px; } -.#{$name}-margin-right .#{$name}-contentcell { +.#{$name}-margin-right > tbody > .#{$name}-row > .#{$name}-contentcell { padding-right: 18px; } /* form */ diff --git a/WebContent/VAADIN/themes/runo/formlayout/formlayout.scss b/WebContent/VAADIN/themes/runo/formlayout/formlayout.scss index 0766269d8b..bb27da1d5b 100644 --- a/WebContent/VAADIN/themes/runo/formlayout/formlayout.scss +++ b/WebContent/VAADIN/themes/runo/formlayout/formlayout.scss @@ -9,25 +9,25 @@ text-align:right; white-space: nowrap; } -.v-formlayout-spacing .v-formlayout-row .v-formlayout-captioncell, -.v-formlayout-spacing .v-formlayout-row .v-formlayout-contentcell, -.v-formlayout-spacing .v-formlayout-row .v-formlayout-errorcell { +.v-formlayout-spacing > tbody > .v-formlayout-row > .v-formlayout-captioncell, +.v-formlayout-spacing > tbody > .v-formlayout-row > .v-formlayout-contentcell, +.v-formlayout-spacing > tbody > .v-formlayout-row > .v-formlayout-errorcell { padding-top: 8px; } -.v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-captioncell, -.v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-contentcell, -.v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-errorcell { +.v-formlayout-margin-top > tbody > .v-formlayout-firstrow > .v-formlayout-captioncell, +.v-formlayout-margin-top > tbody > .v-formlayout-firstrow > .v-formlayout-contentcell, +.v-formlayout-margin-top > tbody > .v-formlayout-firstrow > .v-formlayout-errorcell { padding-top: 15px; } -.v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-captioncell, -.v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-contentcell, -.v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-errorcell { +.v-formlayout-margin-bottom > tbody > .v-formlayout-lastrow > .v-formlayout-captioncell, +.v-formlayout-margin-bottom > tbody > .v-formlayout-lastrow > .v-formlayout-contentcell, +.v-formlayout-margin-bottom > tbody > .v-formlayout-lastrow > .v-formlayout-errorcell { padding-bottom: 15px; } -.v-formlayout-margin-left .v-formlayout-captioncell { +.v-formlayout-margin-left > tbody > .v-formlayout-row > .v-formlayout-captioncell { padding-left: 18px; } -.v-formlayout-margin-right .v-formlayout-contentcell { +.v-formlayout-margin-right > tbody > .v-formlayout-row > .v-formlayout-contentcell { padding-right: 18px; } /* form */ diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index ed798ea146..c6a7b7ed5d 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -100,7 +100,7 @@ url += '/'; } } - url += ((/\?/).test(url) ? "&" : "?") + "browserDetails"; + url += ((/\?/).test(url) ? "&" : "?") + "browserDetails=1"; var rootId = getConfig("rootId"); if (rootId !== undefined) { url += "&rootId=" + rootId; diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 67eaba0cca..ea15e2d2a1 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -18,7 +18,7 @@ <context-param> <param-name>resourceCacheTime</param-name> <param-value>3600</param-value> - </context-param> + </context-param> <servlet> <servlet-name>Embed App 1</servlet-name> <servlet-class>com.vaadin.server.LegacyVaadinServlet</servlet-class> @@ -58,8 +58,8 @@ <servlet-name>IntegrationTest</servlet-name> <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> <init-param> - <param-name>application</param-name> - <param-value>com.vaadin.tests.integration.IntegrationTestApplication</param-value> + <param-name>UI</param-name> + <param-value>com.vaadin.tests.integration.IntegrationTestUI</param-value> </init-param> </servlet> <servlet-mapping> @@ -71,12 +71,12 @@ <servlet-name>Embed App 2</servlet-name> <url-pattern>/embed2/*</url-pattern> </servlet-mapping> - + <servlet-mapping> <servlet-name>UI provider app</servlet-name> <url-pattern>/uiprovider/*</url-pattern> </servlet-mapping> - + <servlet-mapping> <servlet-name>VaadinApplicationRunner</servlet-name> <url-pattern>/run/*</url-pattern> diff --git a/all/build.xml b/all/build.xml index d8bc535bb4..8f60703be6 100644 --- a/all/build.xml +++ b/all/build.xml @@ -10,7 +10,7 @@ <!-- global properties --> <property name="module.name" value="vaadin-all" /> <property name="result.dir" value="result" /> - <property name="javadoc.jar" location="${result.dir}/vaadin-all-${vaadin.version}-javadoc.jar" /> + <property name="javadoc.jar" location="${result.dir}/lib/vaadin-all-${vaadin.version}-javadoc.jar" /> <property name="temp.dir" location="${result.dir}/temp" /> <property name="temp.deps.dir" value="${temp.dir}/lib" /> <property name="javadoc.temp.dir" location="${result.dir}/javadoc-temp" /> @@ -75,7 +75,7 @@ </target> - <target name="zip" depends="copy-jars"> + <target name="zip" depends="copy-jars, javadoc"> <zip destfile="${zip.file}"> <fileset dir="${temp.dir}"> <!-- Avoid conflicts with servlet and portlet API. They are provided by the container --> diff --git a/all/ivy.xml b/all/ivy.xml index aebba5ba35..103d65e812 100644 --- a/all/ivy.xml +++ b/all/ivy.xml @@ -11,6 +11,7 @@ </configurations> <publications> <artifact type="zip" ext="zip" /> + <artifact type="javadoc" ext="jar" m:classifier="javadoc" /> </publications> <dependencies defaultconf="build"> <!-- API DEPENDENCIES --> diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index e32e9b65f0..fab393eedc 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -327,7 +327,7 @@ public class BrowserInfo { * otherwise <code>false</code> */ public boolean requiresOverflowAutoFix() { - return (getWebkitVersion() > 0 || getOperaVersion() >= 11) + return (getWebkitVersion() > 0 || getOperaVersion() >= 11 || isFirefox()) && Util.getNativeScrollbarSize() > 0; } diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index 3338147465..e69c55d445 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -436,8 +436,10 @@ public class ComponentLocator { if (w == null) { return null; } - - if (w instanceof VUI) { + String elementId = w.getElement().getId(); + if (elementId != null && !elementId.isEmpty()) { + return "PID_S" + elementId; + } else if (w instanceof VUI) { return ""; } else if (w instanceof VWindow) { Connector windowConnector = ConnectorMap.get(client) diff --git a/client/src/com/vaadin/client/ui/ShortcutAction.java b/client/src/com/vaadin/client/ui/ShortcutAction.java new file mode 100644 index 0000000000..3209c02203 --- /dev/null +++ b/client/src/com/vaadin/client/ui/ShortcutAction.java @@ -0,0 +1,108 @@ +/* + * 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.client.ui; + +import com.vaadin.client.ApplicationConnection; +import com.vaadin.server.KeyMapper; + +public class ShortcutAction { + + private final ShortcutKeyCombination sc; + private final String caption; + private final String key; + private String targetCID; + private String targetAction; + + /** + * Constructor + * + * @param key + * The @link {@link KeyMapper} key of the action. + * @param sc + * The key combination that triggers the action + * @param caption + * The caption of the action + */ + public ShortcutAction(String key, ShortcutKeyCombination sc, String caption) { + this(key, sc, caption, null, null); + } + + /** + * Constructor + * + * @param key + * The @link {@link KeyMapper} key of the action. + * @param sc + * The key combination that triggers the action + * @param caption + * The caption of the action + * @param targetPID + * The pid of the component the action is targeting. We use the + * pid, instead of the actual Paintable here, so we can delay the + * fetching of the Paintable in cases where the Paintable does + * not yet exist when the action is painted. + * @param targetAction + * The target string of the action. The target string is given to + * the targeted Paintable if the paintable implements the + * {@link ShortcutActionTarget} interface. + */ + public ShortcutAction(String key, ShortcutKeyCombination sc, + String caption, String targetCID, String targetAction) { + this.sc = sc; + this.key = key; + this.caption = caption; + this.targetCID = targetCID; + this.targetAction = targetAction; + } + + /** + * Get the key combination that triggers the action + */ + public ShortcutKeyCombination getShortcutCombination() { + return sc; + } + + /** + * Get the caption of the action + */ + public String getCaption() { + return caption; + } + + /** + * Get the {@link KeyMapper} key for the action + */ + public String getKey() { + return key; + } + + /** + * Get the pid of the target of the action. Use + * {@link ApplicationConnection#getPaintable(String)} to get the actual + * Paintable + */ + public String getTargetCID() { + return targetCID; + } + + /** + * Get the target string of the action + */ + public String getTargetAction() { + return targetAction; + } + +}
\ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java index 8dc0d9def7..cd14f14585 100644 --- a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java +++ b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java @@ -30,9 +30,12 @@ import com.google.gwt.user.client.ui.KeyboardListenerCollection; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ConnectorMap; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.ui.richtextarea.VRichTextArea; +import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.ShortCutConstants; /** * A helper class to implement keyboard shorcut handling. Keeps a list of owners @@ -108,15 +111,25 @@ public class ShortcutActionHandler { final UIDL action = (UIDL) it.next(); int[] modifiers = null; - if (action.hasAttribute("mk")) { - modifiers = action.getIntArrayAttribute("mk"); + if (action + .hasAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE)) { + modifiers = action + .getIntArrayAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE); } final ShortcutKeyCombination kc = new ShortcutKeyCombination( - action.getIntAttribute("kc"), modifiers); - final String key = action.getStringAttribute("key"); - final String caption = action.getStringAttribute("caption"); - actions.add(new ShortcutAction(key, kc, caption)); + action.getIntAttribute(ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE), + modifiers); + final String key = action + .getStringAttribute(ShortCutConstants.ACTION_KEY_ATTRIBUTE); + final String caption = action + .getStringAttribute(ShortCutConstants.ACTION_CAPTION_ATTRIBUTE); + final String targetPID = action + .getStringAttribute(ShortCutConstants.ACTION_TARGET_ATTRIBUTE); + final String targetAction = action + .getStringAttribute(ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE); + actions.add(new ShortcutAction(key, kc, caption, targetPID, + targetAction)); } } @@ -171,11 +184,24 @@ public class ShortcutActionHandler { Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { - if (finalTarget != null) { - client.updateVariable(paintableId, "actiontarget", - finalTarget, false); + Connector shortcutTarget = ConnectorMap.get(client) + .getConnector(a.getTargetCID()); + + boolean handledClientSide = false; + if (shortcutTarget instanceof ShortcutActionTarget) { + handledClientSide = ((ShortcutActionTarget) shortcutTarget) + .handleAction(a); + } + if (!handledClientSide) { + if (finalTarget != null) { + client.updateVariable(paintableId, + ShortCutConstants.ACTION_TARGET_VARIABLE, + finalTarget, false); + } + client.updateVariable(paintableId, + ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE, + a.getKey(), true); } - client.updateVariable(paintableId, "action", a.getKey(), true); } }); } @@ -282,29 +308,3 @@ class ShortcutKeyCombination { return false; } } - -class ShortcutAction { - - private final ShortcutKeyCombination sc; - private final String caption; - private final String key; - - public ShortcutAction(String key, ShortcutKeyCombination sc, String caption) { - this.sc = sc; - this.key = key; - this.caption = caption; - } - - public ShortcutKeyCombination getShortcutCombination() { - return sc; - } - - public String getCaption() { - return caption; - } - - public String getKey() { - return key; - } - -} diff --git a/client/src/com/vaadin/client/ui/ShortcutActionTarget.java b/client/src/com/vaadin/client/ui/ShortcutActionTarget.java new file mode 100644 index 0000000000..617334600e --- /dev/null +++ b/client/src/com/vaadin/client/ui/ShortcutActionTarget.java @@ -0,0 +1,24 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.client.ui; + +/** + * Widgets who wish to be notificed when a shortcut action has been triggered + * with the widget as a target should implement this interface. The + * {@link #handleAction(ShortcutAction)} method will be called just before the + * action is communicated to the server + * + */ +public interface ShortcutActionTarget { + + /** + * Called by the {@link ShortcutActionHandler} just before the shortcut + * action is sent to the server side + * + * @param action + * The action which will be performed on the server side + * @return Returns true if the shortcut was handled + */ + boolean handleAction(ShortcutAction action); +} diff --git a/client/src/com/vaadin/client/ui/button/ButtonConnector.java b/client/src/com/vaadin/client/ui/button/ButtonConnector.java index b15813c99e..546bdecb61 100644 --- a/client/src/com/vaadin/client/ui/button/ButtonConnector.java +++ b/client/src/com/vaadin/client/ui/button/ButtonConnector.java @@ -33,6 +33,8 @@ import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.Icon; +import com.vaadin.client.ui.ShortcutAction; +import com.vaadin.client.ui.ShortcutActionTarget; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc; import com.vaadin.shared.ui.Connect; @@ -43,7 +45,7 @@ import com.vaadin.ui.Button; @Connect(value = Button.class, loadStyle = LoadStyle.EAGER) public class ButtonConnector extends AbstractComponentConnector implements - BlurHandler, FocusHandler, ClickHandler { + BlurHandler, FocusHandler, ClickHandler, ShortcutActionTarget { private ButtonServerRpc rpc = RpcProxy.create(ButtonServerRpc.class, this); private FocusAndBlurServerRpc focusBlurProxy = RpcProxy.create( @@ -165,4 +167,20 @@ public class ButtonConnector extends AbstractComponentConnector implements rpc.click(details); } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.ShortcutActionTarget#handleAction(com + * .vaadin.terminal.gwt.client.ui.ShortcutAction) + */ + public boolean handleAction(ShortcutAction action) { + if ("click".equals(action.getTargetAction())) { + getWidget().onClick(); + return true; + } + return false; + } + } diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 15407a16f4..e0863512b4 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -115,7 +115,7 @@ public abstract class AbstractOrderedLayoutConnector extends if (captionElement == widgetElement) { // Caption element already detached - rmeoveResizeListener(captionElement, slotCaptionResizeListener); + removeResizeListener(captionElement, slotCaptionResizeListener); childCaptionElementHeight.remove(widgetElement); return; } @@ -460,14 +460,14 @@ public abstract class AbstractOrderedLayoutConnector extends Slot slot = getWidget().getSlot(child.getWidget()); // Clear all possible listeners first - rmeoveResizeListener(slot.getWidget().getElement(), + removeResizeListener(slot.getWidget().getElement(), childComponentResizeListener); if (slot.hasCaption()) { - rmeoveResizeListener(slot.getCaptionElement(), + removeResizeListener(slot.getCaptionElement(), slotCaptionResizeListener); } if (slot.hasSpacing()) { - rmeoveResizeListener(slot.getSpacingElement(), + removeResizeListener(slot.getSpacingElement(), spacingResizeListener); } @@ -579,16 +579,16 @@ public abstract class AbstractOrderedLayoutConnector extends for (ComponentConnector child : getChildComponents()) { Slot slot = getWidget().getSlot(child.getWidget()); if (slot.hasCaption()) { - rmeoveResizeListener(slot.getCaptionElement(), + removeResizeListener(slot.getCaptionElement(), slotCaptionResizeListener); } if (slot.getSpacingElement() != null) { - rmeoveResizeListener(slot.getSpacingElement(), + removeResizeListener(slot.getSpacingElement(), spacingResizeListener); } - rmeoveResizeListener(slot.getWidget().getElement(), + removeResizeListener(slot.getWidget().getElement(), childComponentResizeListener); } @@ -613,9 +613,9 @@ public abstract class AbstractOrderedLayoutConnector extends * @param el * The element from where the resize listener should be removed * @param listener - * THe listener to remove + * The listener to remove */ - private void rmeoveResizeListener(Element el, ElementResizeListener listener) { + private void removeResizeListener(Element el, ElementResizeListener listener) { getLayoutManager().removeElementResizeListener(el, listener); } diff --git a/client/src/com/vaadin/client/ui/ui/VUI.java b/client/src/com/vaadin/client/ui/ui/VUI.java index 8d534053ed..096b0b60ba 100644 --- a/client/src/com/vaadin/client/ui/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/ui/VUI.java @@ -37,6 +37,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorMap; import com.vaadin.client.Focusable; +import com.vaadin.client.LayoutManager; import com.vaadin.client.VConsole; import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; @@ -286,7 +287,12 @@ public class VUI extends SimplePanel implements ResizeHandler, sendClientResized(); - connector.getLayoutManager().layoutNow(); + LayoutManager layoutManager = connector.getLayoutManager(); + if (layoutManager.isLayoutRunning()) { + layoutManager.layoutLater(); + } else { + layoutManager.layoutNow(); + } } } diff --git a/server/src/com/vaadin/data/util/AbstractProperty.java b/server/src/com/vaadin/data/util/AbstractProperty.java index 76d47039d0..aefe00ad32 100644 --- a/server/src/com/vaadin/data/util/AbstractProperty.java +++ b/server/src/com/vaadin/data/util/AbstractProperty.java @@ -18,6 +18,7 @@ package com.vaadin.data.util; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; +import java.util.logging.Logger; import com.vaadin.data.Property; @@ -78,9 +79,17 @@ public abstract class AbstractProperty<T> implements Property<T>, @Deprecated @Override public String toString() { - throw new UnsupportedOperationException( - "Use Property.getValue() instead of " + getClass() - + ".toString()"); + getLogger() + .warning( + "You are using Property.toString() instead of getValue() to get the value for a " + + getClass().getSimpleName() + + ". This will not be supported starting from Vaadin 7.1 " + + "(your debugger might call toString() and cause this message to appear)."); + T v = getValue(); + if (v == null) { + return null; + } + return v.toString(); } /* Events */ @@ -277,4 +286,7 @@ public abstract class AbstractProperty<T> implements Property<T>, return Collections.EMPTY_LIST; } + private static Logger getLogger() { + return Logger.getLogger(AbstractProperty.class.getName()); + } } diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java index e957d958a9..7273b28b66 100644 --- a/server/src/com/vaadin/data/util/IndexedContainer.java +++ b/server/src/com/vaadin/data/util/IndexedContainer.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.logging.Logger; import com.vaadin.data.Container; import com.vaadin.data.Item; @@ -961,8 +962,21 @@ public class IndexedContainer extends @Deprecated @Override public String toString() { - throw new UnsupportedOperationException( - "Use Property.getValue() instead of IndexedContainerProperty.toString()"); + getLogger() + .warning( + "You are using IndexedContainerProperty.toString() instead of getValue() to get the value for a " + + getClass().getSimpleName() + + ". This will not be supported starting from Vaadin 7.1 " + + "(your debugger might call toString() and cause this message to appear)."); + Object v = getValue(); + if (v == null) { + return null; + } + return v.toString(); + } + + private Logger getLogger() { + return Logger.getLogger(IndexedContainerProperty.class.getName()); } /** diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java index 6e5ba0dc57..bd6b1a75bf 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java @@ -18,6 +18,7 @@ package com.vaadin.data.util.sqlcontainer; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; +import java.util.logging.Logger; import com.vaadin.data.Property; import com.vaadin.data.util.converter.Converter.ConversionException; @@ -261,8 +262,21 @@ final public class ColumnProperty implements Property { @Deprecated @Override public String toString() { - throw new UnsupportedOperationException( - "Use ColumnProperty.getValue() instead of ColumnProperty.toString()"); + getLogger() + .warning( + "You are using ColumnProperty.toString() instead of getValue() to get the value for a " + + getClass().getSimpleName() + + ". This will not be supported starting from Vaadin 7.1 " + + "(your debugger might call toString() and cause this message to appear)."); + Object v = getValue(); + if (v == null) { + return null; + } + return v.toString(); + } + + private static Logger getLogger() { + return Logger.getLogger(ColumnProperty.class.getName()); } public void setOwner(RowItem owner) { diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 85a1bf0f12..50bb2f8dad 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -24,6 +24,7 @@ import com.vaadin.server.KeyMapper; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.VariableOwner; +import com.vaadin.shared.ui.ShortCutConstants; import com.vaadin.ui.Component; /** @@ -187,14 +188,28 @@ public class ActionManager implements Action.Container, Action.Handler, } if (a instanceof ShortcutAction) { final ShortcutAction sa = (ShortcutAction) a; - paintTarget.addAttribute("kc", sa.getKeyCode()); + paintTarget.addAttribute( + ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE, + sa.getKeyCode()); final int[] modifiers = sa.getModifiers(); if (modifiers != null) { final String[] smodifiers = new String[modifiers.length]; for (int i = 0; i < modifiers.length; i++) { smodifiers[i] = String.valueOf(modifiers[i]); } - paintTarget.addAttribute("mk", smodifiers); + paintTarget + .addAttribute( + ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE, + smodifiers); + } + if (sa.getTarget() != null) { + paintTarget.addAttribute( + ShortCutConstants.ACTION_TARGET_ATTRIBUTE, + sa.getTarget()); + paintTarget + .addAttribute( + ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE, + sa.getTargetAction()); } } paintTarget.endTag("action"); @@ -212,10 +227,14 @@ public class ActionManager implements Action.Container, Action.Handler, } public void handleActions(Map<String, Object> variables, Container sender) { - if (variables.containsKey("action") && actionMapper != null) { - final String key = (String) variables.get("action"); + if (variables + .containsKey(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE) + && actionMapper != null) { + final String key = (String) variables + .get(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE); final Action action = actionMapper.get(key); - final Object target = variables.get("actiontarget"); + final Object target = variables + .get(ShortCutConstants.ACTION_TARGET_VARIABLE); if (action != null) { handleAction(action, sender, target); } diff --git a/server/src/com/vaadin/event/ShortcutAction.java b/server/src/com/vaadin/event/ShortcutAction.java index b1d14b15fe..9d13d41b9f 100644 --- a/server/src/com/vaadin/event/ShortcutAction.java +++ b/server/src/com/vaadin/event/ShortcutAction.java @@ -21,6 +21,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vaadin.server.Resource; +import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Panel; import com.vaadin.ui.Window; @@ -57,6 +58,10 @@ public class ShortcutAction extends Action { private final int[] modifiers; + private Component target; + + private String targetAction; + /** * Creates a shortcut that reacts to the given {@link KeyCode} and * (optionally) {@link ModifierKey}s. <br/> @@ -237,6 +242,46 @@ public class ShortcutAction extends Action { } /** + * Set the target for the shortcut action. If the target widget on the + * client side implements {@link ShortcutActionTarget} it will be notified + * of the action before the action is communicated to the server side + * + * @param target + * The component which will be thet target of the action + */ + public void setTarget(Component target) { + this.target = target; + } + + /** + * Get the target of the shortcut action + */ + public Component getTarget() { + return target; + } + + /** + * Get the action string that is given to the {@link ShortcutActionTarget} + * on the client side + * + * @return + */ + public String getTargetAction() { + return targetAction; + } + + /** + * Set the action string that is give to the {@link ShortcutActionTarget} on + * the client side + * + * @param targetAction + * The target action string + */ + public void setTargetAction(String targetAction) { + this.targetAction = targetAction; + } + + /** * Key codes that can be used for shortcuts * */ diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index eb59cbe5fc..1f0d3049b5 100644 --- a/server/src/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -290,6 +290,11 @@ public abstract class AbstractClientConnector implements ClientConnector { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if (method.getDeclaringClass() == Object.class) { + // Don't add Object methods such as toString and hashCode as + // invocations + return method.invoke(this, args); + } addMethodInvocationToQueue(rpcInterfaceName, method, args); return null; } diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java index f876e748f8..5f61079261 100644 --- a/server/src/com/vaadin/server/CommunicationManager.java +++ b/server/src/com/vaadin/server/CommunicationManager.java @@ -110,8 +110,9 @@ public class CommunicationManager extends AbstractCommunicationManager { @Override protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - VaadinServletSession session = (VaadinServletSession) uI.getSession(); - ServletContext servletContext = session.getHttpSession() + VaadinServletService service = (VaadinServletService) uI.getSession() + .getService(); + ServletContext servletContext = service.getServlet() .getServletContext(); return servletContext.getResourceAsStream("/" + VaadinServlet.THEME_DIRECTORY_PATH + themeName + "/" diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java index 1652d39c3a..e02e5dc860 100644 --- a/server/src/com/vaadin/server/DefaultUIProvider.java +++ b/server/src/com/vaadin/server/DefaultUIProvider.java @@ -24,9 +24,11 @@ public class DefaultUIProvider extends UIProvider { public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { VaadinRequest request = event.getRequest(); - Object uiClassNameObj = request.getService() - .getDeploymentConfiguration().getInitParameters() - .getProperty(VaadinServiceSession.UI_PARAMETER); + Object uiClassNameObj = request + .getService() + .getDeploymentConfiguration() + .getApplicationOrSystemProperty( + VaadinServiceSession.UI_PARAMETER, null); if (uiClassNameObj instanceof String) { String uiClassName = uiClassNameObj.toString(); diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index 6c9c1882ea..c68f25a282 100644 --- a/server/src/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -361,11 +361,18 @@ public class GAEVaadinServlet extends VaadinServlet { * * @param request */ - private void cleanSession(HttpServletRequest request) { - HttpSession session = request.getSession(false); - if (session != null) { - session.removeAttribute(VaadinServletSession.class.getName()); + private void cleanSession(VaadinServletRequest request) { + // Should really be replaced with a session storage API... + WrappedSession wrappedSession = request.getWrappedSession(false); + if (wrappedSession == null) { + return; + } + VaadinServiceSession serviceSession = VaadinServiceSession + .getForSession(getService(), wrappedSession); + if (serviceSession == null) { + return; } + serviceSession.removeFromSession(getService()); } /** diff --git a/server/src/com/vaadin/server/GlobalResourceHandler.java b/server/src/com/vaadin/server/GlobalResourceHandler.java index c968dba066..ad276dc77a 100644 --- a/server/src/com/vaadin/server/GlobalResourceHandler.java +++ b/server/src/com/vaadin/server/GlobalResourceHandler.java @@ -59,7 +59,7 @@ public class GlobalResourceHandler implements RequestHandler { private int nextLegacyId = 0; // APP/global/[uiid]/[type]/[id] - private final Matcher matcher = Pattern.compile( + private static final Matcher matcher = Pattern.compile( "^/?" + ApplicationConstants.APP_REQUEST_PATH + RESOURCE_REQUEST_PATH + "(\\d+)/(([^/]+)(/.*))").matcher( ""); diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index add32bf57b..c56d6caeb5 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -437,8 +437,10 @@ public abstract class VaadinService implements Serializable { * @throws ServletException * @throws MalformedURLException */ - protected abstract VaadinServiceSession createVaadinSession( - VaadinRequest request) throws ServiceException; + protected VaadinServiceSession createVaadinSession(VaadinRequest request) + throws ServiceException { + return new VaadinServiceSession(this); + } private void onVaadinSessionStarted(VaadinRequest request, VaadinServiceSession session) throws ServiceException { diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 7f664be6fb..0620035274 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -232,7 +232,7 @@ public class VaadinServlet extends HttpServlet implements Constants { return; } - VaadinServletSession vaadinSession = null; + VaadinServiceSession vaadinSession = null; try { // If a duplicate "close application" URL is received for an @@ -254,8 +254,7 @@ public class VaadinServlet extends HttpServlet implements Constants { } // Find out the service session this request is related to - vaadinSession = (VaadinServletSession) getService() - .findVaadinSession(request); + vaadinSession = getService().findVaadinSession(request); if (vaadinSession == null) { return; } @@ -289,6 +288,11 @@ public class VaadinServlet extends HttpServlet implements Constants { // Handles AJAX UIDL requests communicationManager.handleUidlRequest(request, response, servletWrapper, uI); + + // Ensure that the browser does not cache UIDL responses. + // iOS 6 Safari requires this (#9732) + response.setHeader("Cache-Control", "no-cache"); + return; } else if (requestType == RequestType.BROWSER_DETAILS) { // Browser details - not related to a specific UI @@ -1173,26 +1177,6 @@ public class VaadinServlet extends HttpServlet implements Constants { return request.getPathInfo(); } - /** - * Gets relative location of a theme resource. - * - * @param theme - * the Theme name. - * @param resource - * the Theme resource. - * @return External URI specifying the resource - * - * @deprecated might be refactored or removed before 7.0.0 - */ - @Deprecated - public String getResourceLocation(String theme, ThemeResource resource) { - - if (resourcePath == null) { - return resource.getResourceId(); - } - return resourcePath + theme + "/" + resource.getResourceId(); - } - public class RequestError implements Terminal.ErrorEvent, Serializable { private final Throwable throwable; diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index ca894b8a4f..d746ee2303 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -186,12 +186,6 @@ public class VaadinServletService extends VaadinService { } @Override - protected VaadinServiceSession createVaadinSession(VaadinRequest request) - throws ServiceException { - return new VaadinServletSession(this); - } - - @Override public String getServiceName() { return getServlet().getServletName(); } diff --git a/server/src/com/vaadin/server/VaadinServletSession.java b/server/src/com/vaadin/server/VaadinServletSession.java deleted file mode 100644 index aa31a19c1b..0000000000 --- a/server/src/com/vaadin/server/VaadinServletSession.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.server; - -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpSessionBindingListener; - -/** - * Web application context for Vaadin applications. - * - * This is automatically added as a {@link HttpSessionBindingListener} when - * added to a {@link HttpSession}. - * - * @author Vaadin Ltd. - * @since 3.1 - * - * @deprecated might be refactored or removed before 7.0.0 - */ -@Deprecated -@SuppressWarnings("serial") -public class VaadinServletSession extends VaadinServiceSession { - - /** - * Create a servlet service session for the given servlet service - * - * @param service - * the servlet service to which the new session belongs - */ - public VaadinServletSession(VaadinServletService service) { - super(service); - } - - /** - * Gets the http-session application is running in. - * - * @return HttpSession this application context resides in. - */ - public HttpSession getHttpSession() { - WrappedSession session = getSession(); - return ((WrappedHttpSession) session).getHttpSession(); - } - -} diff --git a/server/src/com/vaadin/server/WrappedHttpSession.java b/server/src/com/vaadin/server/WrappedHttpSession.java index e13a63635b..65db010ba9 100644 --- a/server/src/com/vaadin/server/WrappedHttpSession.java +++ b/server/src/com/vaadin/server/WrappedHttpSession.java @@ -88,4 +88,9 @@ public class WrappedHttpSession implements WrappedSession { session.invalidate(); } + @Override + public String getId() { + return session.getId(); + } + } diff --git a/server/src/com/vaadin/server/WrappedPortletSession.java b/server/src/com/vaadin/server/WrappedPortletSession.java index 03c1d7ba1f..f4a6003ed5 100644 --- a/server/src/com/vaadin/server/WrappedPortletSession.java +++ b/server/src/com/vaadin/server/WrappedPortletSession.java @@ -74,4 +74,9 @@ public class WrappedPortletSession implements WrappedSession { public void invalidate() { session.invalidate(); } + + @Override + public String getId() { + return session.getId(); + } } diff --git a/server/src/com/vaadin/server/WrappedSession.java b/server/src/com/vaadin/server/WrappedSession.java index 34443239c7..cf0b1a2fbd 100644 --- a/server/src/com/vaadin/server/WrappedSession.java +++ b/server/src/com/vaadin/server/WrappedSession.java @@ -86,4 +86,11 @@ public interface WrappedSession { * @see PortletSession#invalidate() */ public void invalidate(); + + /** + * Gets a string with a unique identifier for the session. + * + * @return a unique session id string + */ + public String getId(); } diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index 02b7689259..d248efd570 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -463,7 +463,6 @@ public class Button extends AbstractComponent implements * */ public static class ClickShortcut extends ShortcutListener { - protected Button button; /** * Creates a keyboard shortcut for clicking the given button using the @@ -476,7 +475,8 @@ public class Button extends AbstractComponent implements */ public ClickShortcut(Button button, String shorthandCaption) { super(shorthandCaption); - this.button = button; + setTarget(button); + setTargetAction("click"); } /** @@ -492,7 +492,8 @@ public class Button extends AbstractComponent implements */ public ClickShortcut(Button button, int keyCode, int... modifiers) { super(null, keyCode, modifiers); - this.button = button; + setTarget(button); + setTargetAction("click"); } /** @@ -510,7 +511,7 @@ public class Button extends AbstractComponent implements @Override public void handleAction(Object sender, Object target) { - button.click(); + // Action handled on the client side } } diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 9434e92186..89281e0c27 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -219,7 +219,7 @@ public class Label extends AbstractComponent implements Property<String>, public String toString() { logger.warning("You are using Label.toString() to get the value for a " + getClass().getSimpleName() - + ". This is not recommended and will not be supported in future versions."); + + ". This will not be supported starting from Vaadin 7.1 (your debugger might call toString() and cause this message to appear)."); return getValue(); } diff --git a/shared/src/com/vaadin/shared/ui/ShortCutConstants.java b/shared/src/com/vaadin/shared/ui/ShortCutConstants.java new file mode 100644 index 0000000000..1de9ba65da --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ShortCutConstants.java @@ -0,0 +1,28 @@ +/* + * 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 class ShortCutConstants { + public static final String ACTION_TARGET_ATTRIBUTE = "sat"; + public static final String ACTION_TARGET_ACTION_ATTRIBUTE = "sata"; + public static final String ACTION_CAPTION_ATTRIBUTE = "caption"; + public static final String ACTION_KEY_ATTRIBUTE = "key"; + public static final String ACTION_SHORTCUT_KEY_ATTRIBUTE = "kc"; + public static final String ACTION_MODIFIER_KEYS_ATTRIBUTE = "mk"; + public static final String ACTION_TARGET_VARIABLE = "actiontarget"; + public static final String ACTION_TARGET_ACTION_VARIABLE = "action"; + +} diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java b/tests/testbench/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java new file mode 100644 index 0000000000..0fdb579997 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java @@ -0,0 +1,38 @@ +package com.vaadin.tests.components.tabsheet; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; + +public class HiddenTabSheetBrowserResize extends TestBase { + + @Override + public void setup() { + final TabSheet tabSheet = new TabSheet(); + + tabSheet.addTab(new Label("Label1"), "Tab1"); + tabSheet.addTab(new Label("Label2"), "Tab2"); + + Button toggleButton = new Button("Toggle TabSheet", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tabSheet.setVisible(!tabSheet.isVisible()); + } + }); + addComponent(toggleButton); + addComponent(tabSheet); + } + + @Override + protected String getDescription() { + return "TabSheet content disappears if browser window resized when the TabSheet is hidden"; + } + + @Override + protected Integer getTicketNumber() { + return 9508; + } + +} diff --git a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java index 4495b343d0..fa0f13e172 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java @@ -1,7 +1,6 @@ package com.vaadin.tests.applicationcontext; import com.vaadin.server.VaadinService; -import com.vaadin.server.VaadinServletSession; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; @@ -30,15 +29,13 @@ public class ChangeSessionId extends AbstractTestCase { })); setMainWindow(mainWindow); - loginButton.addListener(new ClickListener() { + loginButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { - VaadinServletSession context = ((VaadinServletSession) getContext()); - - String oldSessionId = context.getHttpSession().getId(); - context.getService().reinitializeSession( - VaadinService.getCurrentRequest()); - String newSessionId = context.getHttpSession().getId(); + String oldSessionId = getSessionId(); + VaadinService.reinitializeSession(VaadinService + .getCurrentRequest()); + String newSessionId = getSessionId(); if (oldSessionId.equals(newSessionId)) { log.log("FAILED! Both old and new session id is " + newSessionId); @@ -57,7 +54,7 @@ public class ChangeSessionId extends AbstractTestCase { } protected String getSessionId() { - return ((VaadinServletSession) getContext()).getHttpSession().getId(); + return getContext().getSession().getId(); } @Override diff --git a/uitest/src/com/vaadin/tests/components/formlayout/NestedFormLayouts.html b/uitest/src/com/vaadin/tests/components/formlayout/NestedFormLayouts.html new file mode 100644 index 0000000000..a95aecac80 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/formlayout/NestedFormLayouts.html @@ -0,0 +1,56 @@ +<?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>NestedFormLayouts</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">NestedFormLayouts</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.formlayout.NestedFormLayouts?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsformlayoutNestedFormLayouts::PID_Sspacings/domChild[0]</td> + <td>8,8</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>spacings</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsformlayoutNestedFormLayouts::PID_Smargins/domChild[0]</td> + <td>5,4</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>spacings_margins</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsformlayoutNestedFormLayouts::PID_Sspacings/domChild[0]</td> + <td>8,5</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>margins</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/formlayout/NestedFormLayouts.java b/uitest/src/com/vaadin/tests/components/formlayout/NestedFormLayouts.java new file mode 100644 index 0000000000..147f2dcec7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/formlayout/NestedFormLayouts.java @@ -0,0 +1,117 @@ +package com.vaadin.tests.components.formlayout; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.Label; + +public class NestedFormLayouts extends AbstractTestUI { + + private FormLayout outer; + private FormLayout inner1; + private FormLayout inner2; + private FormLayout inner21; + private FormLayout inner3; + private FormLayout inner31; + private FormLayout inner4; + + @Override + protected void setup(VaadinRequest request) { + outer = new FormLayout(); + outer.setSizeUndefined(); + outer.setWidth("100%"); + + inner1 = new FormLayout(); + inner1.addComponent(new Label("Test")); + inner1.addComponent(new Label("Test2")); + outer.addComponent(inner1); + + outer.addComponent(new Label("Test")); + outer.addComponent(new Label("Test2")); + + inner2 = new FormLayout(); + inner2.addComponent(new Label("Test")); + inner2.addComponent(new Label("Test2")); + inner21 = new FormLayout(); + inner21.addComponent(new Label("Test")); + inner21.addComponent(new Label("Test2")); + inner2.addComponent(inner21); + outer.addComponent(inner2); + + inner3 = new FormLayout(); + inner3.addComponent(new Label("Test")); + inner3.addComponent(new Label("Test2")); + // this layout never gets spacing or margin + inner31 = new FormLayout(); + inner31.addComponent(new Label("Test")); + inner31.addComponent(new Label("Test2")); + inner31.setSpacing(false); + inner31.setMargin(false); + inner3.addComponent(inner31); + outer.addComponent(inner3); + + inner4 = new FormLayout(); + inner4.addComponent(new Label("Test")); + inner4.addComponent(new Label("Test2")); + outer.addComponent(inner4); + + addComponent(outer); + + final CheckBox spacingCheckBox = new CheckBox("Spacings", false); + spacingCheckBox.setId("spacings"); + spacingCheckBox.setImmediate(true); + spacingCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + setLayoutSpacing(spacingCheckBox.getValue()); + } + }); + addComponent(spacingCheckBox); + + final CheckBox marginCheckBox = new CheckBox("Margins", false); + marginCheckBox.setId("margins"); + marginCheckBox.setImmediate(true); + marginCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + setLayoutMargin(marginCheckBox.getValue()); + } + }); + addComponent(marginCheckBox); + + setLayoutSpacing(false); + setLayoutMargin(false); + } + + private void setLayoutSpacing(boolean value) { + outer.setSpacing(value); + inner1.setSpacing(value); + inner2.setSpacing(value); + inner21.setSpacing(value); + inner3.setSpacing(value); + inner4.setSpacing(value); + } + + private void setLayoutMargin(boolean value) { + outer.setMargin(value); + inner1.setMargin(value); + inner2.setMargin(value); + inner21.setMargin(value); + inner3.setMargin(value); + inner4.setMargin(value); + } + + @Override + protected String getTestDescription() { + return "Excess padding applied in FormLayouts nested as first or last rows in a FormLayout"; + } + + @Override + protected Integer getTicketNumber() { + return 9427; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/label/LabelPropertySourceValue.java b/uitest/src/com/vaadin/tests/components/label/LabelPropertySourceValue.java index d4ec16da4e..c1965ff92b 100644 --- a/uitest/src/com/vaadin/tests/components/label/LabelPropertySourceValue.java +++ b/uitest/src/com/vaadin/tests/components/label/LabelPropertySourceValue.java @@ -1,58 +1,58 @@ -package com.vaadin.tests.components.label;
-
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-
-public class LabelPropertySourceValue extends AbstractTestUI {
- private Label label;
-
- @Override
- public void setup(VaadinRequest request) {
- label = new Label("Hello Vaadin user");
- addComponent(label);
- Button button = new Button("Give label a new property data source...");
- button.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- ObjectProperty<String> p = new ObjectProperty<String>(
- "This text should appear on the label after clicking the button.");
-
- label.setPropertyDataSource(p);
- }
- });
- addComponent(button);
- button = new Button("Remove data source", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- label.setPropertyDataSource(null);
- }
- });
- addComponent(button);
-
- button = new Button("Set label value to 'foo'", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- label.setValue("foo");
- }
- });
- addComponent(button);
- }
-
- @Override
- protected String getTestDescription() {
- return "The value should change by clicking the button";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 9618;
- }
-
+package com.vaadin.tests.components.label; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; + +public class LabelPropertySourceValue extends AbstractTestUI { + private Label label; + + @Override + public void setup(VaadinRequest request) { + label = new Label("Hello Vaadin user"); + addComponent(label); + Button button = new Button("Give label a new property data source..."); + button.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + ObjectProperty<String> p = new ObjectProperty<String>( + "This text should appear on the label after clicking the button."); + + label.setPropertyDataSource(p); + } + }); + addComponent(button); + button = new Button("Remove data source", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + label.setPropertyDataSource(null); + } + }); + addComponent(button); + + button = new Button("Set label value to 'foo'", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + label.setValue("foo"); + } + }); + addComponent(button); + } + + @Override + protected String getTestDescription() { + return "The value should change by clicking the button"; + } + + @Override + protected Integer getTicketNumber() { + return 9618; + } + }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html b/uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html new file mode 100644 index 0000000000..8276f0fd89 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/ChangeFragmentOnServerToMatchClient.html @@ -0,0 +1,37 @@ +<?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.ui.InitialFragmentEvent?restartApplication#foo</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td></td> +</tr> +<!--Changing the fragment to the initial fragment should not cause an event--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html b/uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html new file mode 100644 index 0000000000..972d3d6143 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/FragmentChangeEvents.html @@ -0,0 +1,79 @@ +<?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.ui.InitialFragmentEvent?restartApplication#initial</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td></td> +</tr> +<!--Reloading with the same fragment but without restartApplication should not cause any event--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.ui.InitialFragmentEvent#initial</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td></td> +</tr> +<!--Changing the fragment should cause an event--> +<tr> + <td>runScript</td> + <td>window.location.hash='second'</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>500</td> + <td></td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td>1. Fragment changed from "no event received" to second</td> +</tr> +<!--Clearing the fragment should cause an event--> +<tr> + <td>runScript</td> + <td>window.location.hash=''</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>500</td> + <td></td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td>2. Fragment changed from second to</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java b/uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java new file mode 100644 index 0000000000..b4a7d4e181 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/InitialFragmentEvent.java @@ -0,0 +1,60 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.server.Page.FragmentChangedEvent; +import com.vaadin.server.Page.FragmentChangedListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class InitialFragmentEvent extends AbstractTestUI { + + private String lastKnownFragment = "\"no event received\""; + private Log log = new Log(5); + + @Override + protected void setup(VaadinRequest request) { + getPage().addFragmentChangedListener(new FragmentChangedListener() { + + public void fragmentChanged(FragmentChangedEvent source) { + String newFragment = source.getFragment(); + log.log("Fragment changed from " + lastKnownFragment + " to " + + newFragment); + lastKnownFragment = newFragment; + } + }); + addComponent(log); + addComponent(new Button("Set fragment to 'foo'", + new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + setFragment("foo"); + } + })); + addComponent(new Button("Set fragment to 'bar'", + new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + setFragment("bar"); + } + })); + } + + protected void setFragment(String fragment) { + getPage().setFragment(fragment); + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html b/uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html new file mode 100644 index 0000000000..933274eae6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/InitiallyEmptyFragment.html @@ -0,0 +1,47 @@ +<?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.ui.InitialFragmentEvent?restartApplication</td> + <td></td> +</tr> +<!--There is no fragment change event when the fragment is initially empty--> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td></td> +</tr> +<tr> + <td>runScript</td> + <td>window.location.hash='bar'</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>500</td> + <td></td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsuiInitialFragmentEvent::PID_SLog_row_0</td> + <td>1. Fragment changed from "no event received" to bar</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html new file mode 100644 index 0000000000..c9d5aa303d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html @@ -0,0 +1,51 @@ +<?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:8888/" /> +<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.ui.RpcInvocationHandlerToString?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::Root/VNotification[0]/HTML[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::Root/VNotification[0]/HTML[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::Root/VNotification[0]/HTML[0]</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java new file mode 100644 index 0000000000..38f971f840 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java @@ -0,0 +1,74 @@ +/* + * 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.components.ui; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.PageClientRpc; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class RpcInvocationHandlerToString extends AbstractTestUI { + + private Log log = new Log(5); + PageClientRpc dummyProxy = getRpcProxy(PageClientRpc.class); + + @Override + protected void setup(VaadinRequest request) { + addComponent(log); + Button b = new Button("Exec toString() for an invocation proxy", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log("An invoation proxy: " + dummyProxy.toString()); + } + }); + addComponent(b); + b = new Button("Exec hashCode() for an invocation proxy", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log("Invocation proxy.hashCode(): " + + dummyProxy.hashCode()); + } + }); + addComponent(b); + b = new Button("Exec equals(false) for an invocation proxy", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log("Invocation proxy.equals(false): " + + dummyProxy.equals(false)); + } + }); + addComponent(b); + } + + @Override + protected String getTestDescription() { + return "Clicking on the buttons invokes Object methods on a dummy proxy instance. They should only cause log rows to appear and no client rpc to be sent"; + } + + @Override + protected Integer getTicketNumber() { + return 9802; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/UISerialization.html b/uitest/src/com/vaadin/tests/components/ui/UISerialization.html index 1eb6dffcc0..2379882a2c 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UISerialization.html +++ b/uitest/src/com/vaadin/tests/components/ui/UISerialization.html @@ -18,7 +18,7 @@ </tr> <tr> <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUISerialization::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsuiUISerialization::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> <td></td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/ui/UISerialization.java b/uitest/src/com/vaadin/tests/components/ui/UISerialization.java index 927d00a388..2f72166b11 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UISerialization.java +++ b/uitest/src/com/vaadin/tests/components/ui/UISerialization.java @@ -24,14 +24,11 @@ import java.io.Serializable; import java.util.Date; import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.VaadinClasses; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; -import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Component; public class UISerialization extends AbstractTestUI { @@ -40,28 +37,6 @@ public class UISerialization extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { addComponent(log); - for (Class<? extends Component> cls : VaadinClasses.getComponents()) { - try { - AbstractComponent c = (AbstractComponent) cls.newInstance(); - if (c instanceof LegacyWindow) { - continue; - } - if (!(c instanceof Button)) { - continue; - } - - c.setId(cls.getName()); - c.setCaption(cls.getName()); - c.setDescription(cls.getName()); - c.setWidth("100px"); - c.setHeight("100px"); - addComponent(c); - System.out.println("Added " + cls.getName()); - } catch (Exception e) { - System.err.println("Could not instatiate " + cls.getName()); - } - } - addComponent(new Button("Serialize UI", new ClickListener() { @Override @@ -86,27 +61,6 @@ public class UISerialization extends AbstractTestUI { } })); - addComponent(new Button( - "Instantiate and serialize server classes with no-arg constructors", - new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - for (Class<?> cls : VaadinClasses - .getAllServerSideClasses()) { - try { - serializeInstance(cls); - } catch (InstantiationException e) { - // No no-arg constructor probably, ignore - } catch (Throwable t) { - log.log("Failed to create and serialize instance of " - + cls.getName()); - } - } - log.log("Serialization done"); - - } - })); } protected void serializeInstance(Class<?> cls) diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java index 41b7b020f5..916af7129e 100644 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java @@ -38,7 +38,7 @@ public class IntegrationTestApplication extends LegacyApplication { table.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - selectedLabel.setValue(table.getValue().toString()); + selectedLabel.setValue(String.valueOf(table.getValue())); } }); window.addComponent(selectedLabel); diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java new file mode 100755 index 0000000000..61214ede8c --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.integration; + +import com.vaadin.data.Item; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.ClassResource; +import com.vaadin.server.Resource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.UI; + +public class IntegrationTestUI extends UI { + @Override + protected void init(VaadinRequest request) { + final Table table = new Table(); + table.addContainerProperty("icon", Resource.class, null); + table.setItemIconPropertyId("icon"); + table.addContainerProperty("country", String.class, null); + table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY); + table.setImmediate(true); + table.setSelectable(true); + table.setVisibleColumns(new Object[] { "country" }); + addComponent(table); + + Item item = table.addItem("FI"); + item.getItemProperty("icon").setValue(new ClassResource("fi.gif")); + item.getItemProperty("country").setValue("Finland"); + item = table.addItem("SE"); + item.getItemProperty("icon").setValue(new FlagSeResource()); + item.getItemProperty("country").setValue("Sweden"); + + final Label selectedLabel = new Label(); + table.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + selectedLabel.setValue(String.valueOf(table.getValue())); + } + }); + addComponent(selectedLabel); + } +} diff --git a/uitest/src/com/vaadin/tests/util/LargeContainer.java b/uitest/src/com/vaadin/tests/util/LargeContainer.java new file mode 100644 index 0000000000..9d02cfa53c --- /dev/null +++ b/uitest/src/com/vaadin/tests/util/LargeContainer.java @@ -0,0 +1,219 @@ +package com.vaadin.tests.util; + +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.vaadin.data.Container; +import com.vaadin.data.ContainerHelpers; +import com.vaadin.data.Item; +import com.vaadin.data.Property; +import com.vaadin.data.util.AbstractContainer; +import com.vaadin.data.util.ObjectProperty; + +public class LargeContainer extends AbstractContainer implements + Container.Indexed { + + public class TestItem implements Item { + + private final Object itemId; + + public TestItem(Object itemId) { + this.itemId = itemId; + } + + public Property<?> getItemProperty(Object propertyId) { + ObjectProperty<String> property = new ObjectProperty<String>( + containerPropertyIdDefaults.get(propertyId) + " (item " + + itemId + ")"); + return property; + + } + + public Collection<?> getItemPropertyIds() { + return getContainerPropertyIds(); + } + + @SuppressWarnings("rawtypes") + public boolean addItemProperty(Object id, Property property) + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Cannot add item property"); + } + + public boolean removeItemProperty(Object id) + throws UnsupportedOperationException { + throw new UnsupportedOperationException( + "Cannot remove item property"); + } + + } + + private int size = 1000; + + private Map<Object, Class<?>> containerPropertyIdTypes = new HashMap<Object, Class<?>>(); + private Map<Object, Object> containerPropertyIdDefaults = new HashMap<Object, Object>(); + + public Object nextItemId(Object itemId) { + Integer id = (Integer) itemId; + if (id >= size() - 1) { + return null; + } + return (id + 1); + } + + public Object prevItemId(Object itemId) { + Integer id = (Integer) itemId; + if (id <= 0) { + return null; + } + return (id - 1); + } + + public Object firstItemId() { + if (0 == size()) { + return null; + } + return 0; + } + + public Object lastItemId() { + if (0 == size()) { + return null; + } + return (size() - 1); + } + + public boolean isFirstId(Object itemId) { + if (null == itemId) { + return false; + } + return itemId.equals(firstItemId()); + } + + public boolean isLastId(Object itemId) { + if (null == itemId) { + return false; + } + return itemId.equals(lastItemId()); + } + + public TestItem getItem(Object itemId) { + if (!containsId(itemId)) { + return null; + } + return new TestItem(itemId); + } + + public Collection<?> getItemIds() { + return new RangeCollection(size()); + } + + @Override + public List<?> getItemIds(int startIndex, int numberOfIds) { + // TODO use a lazy list for better performance + return ContainerHelpers.getItemIdsUsingGetIdByIndex(startIndex, + numberOfIds, this); + } + + public Property<?> getContainerProperty(Object itemId, Object propertyId) { + TestItem item = getItem(itemId); + if (null == item) { + return null; + } + return item.getItemProperty(propertyId); + } + + public int size() { + return size; + } + + public boolean containsId(Object itemId) { + if (!(itemId instanceof Integer)) { + return false; + } + Integer id = (Integer) itemId; + return (id >= 0 && id < (size() - 1)); + } + + public int indexOfId(Object itemId) { + if (!containsId(itemId)) { + return -1; + } + return (Integer) itemId; + } + + public Object getIdByIndex(int index) { + return index; + } + + public void setSize(int newSize) { + size = newSize; + } + + public boolean removeAllItems() throws UnsupportedOperationException { + setSize(0); + return true; + } + + public Class<?> getType(Object propertyId) { + return containerPropertyIdTypes.get(propertyId); + } + + public Collection<?> getContainerPropertyIds() { + return containerPropertyIdTypes.keySet(); + } + + public boolean addContainerProperty(Object propertyId, Class<?> type, + Object defaultValue) throws UnsupportedOperationException { + if (containerPropertyIdTypes.containsKey(propertyId) || null == type) { + return false; + } + containerPropertyIdTypes.put(propertyId, type); + containerPropertyIdDefaults.put(propertyId, defaultValue); + return true; + } + + public boolean removeContainerProperty(Object propertyId) + throws UnsupportedOperationException { + if (!containerPropertyIdTypes.containsKey(propertyId)) { + return false; + } + containerPropertyIdTypes.remove(propertyId); + containerPropertyIdDefaults.remove(propertyId); + return true; + } + + public Item addItem(Object itemId) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + + public Object addItem() throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + + public boolean removeItem(Object itemId) + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + + public Object addItemAt(int index) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + + public Item addItemAt(int index, Object newItemId) + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + + public Object addItemAfter(Object previousItemId) + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + + public Item addItemAfter(Object previousItemId, Object newItemId) + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not supported"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/util/RangeCollection.java b/uitest/src/com/vaadin/tests/util/RangeCollection.java new file mode 100644 index 0000000000..f26e3cfb15 --- /dev/null +++ b/uitest/src/com/vaadin/tests/util/RangeCollection.java @@ -0,0 +1,48 @@ +package com.vaadin.tests.util; + +import java.util.AbstractCollection; +import java.util.Iterator; + +public class RangeCollection extends AbstractCollection<Integer> { + + public static class RangeIterator implements Iterator<Integer> { + + private int value; + private int max; + + public RangeIterator(int max) { + this.max = max; + value = 0; + } + + public boolean hasNext() { + return (value < max - 1); + } + + public Integer next() { + return value++; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + } + + private int size = 0; + + public RangeCollection(int size) { + this.size = size; + } + + @Override + public Iterator<Integer> iterator() { + return new RangeIterator(size - 1); + } + + @Override + public int size() { + return size; + } + +}
\ No newline at end of file |