diff options
78 files changed, 1401 insertions, 227 deletions
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 46ace4520b..820eb2cbce 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -49,6 +49,8 @@ </servlet> <servlet> + <servlet-name>VaadinApplicationRunner</servlet-name> + <servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class> <!-- Non-default values for testing purposes --> <init-param> <param-name>heartbeatInterval</param-name> @@ -66,8 +68,6 @@ <param-name>testParam</param-name> <param-value>42</param-value> </init-param> - <servlet-name>VaadinApplicationRunner</servlet-name> - <servlet-class>com.vaadin.launcher.ApplicationRunnerServlet</servlet-class> </servlet> <!-- For testing GAE - the deployment script changes this to use GAEVaadinServlet --> diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html index cefd29f665..313ed85a9e 100644 --- a/WebContent/release-notes.html +++ b/WebContent/release-notes.html @@ -418,7 +418,7 @@ <ul> <li>Apache Tomcat, version 5.0 or newer</li> - <li>Oracle WebLogic® Server, version 9.2 or newer</li> + <li>Oracle WebLogic® Server, version 10.3 or newer</li> <li>IBM WebSphere® Application Server, version 6.1 or newer</li> <li>JBoss Application Server, 4.0.0 or newer</li> <li>Jetty, version 5.0 or newer</li> diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index fab393eedc..2f8c70e183 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -229,6 +229,10 @@ public class BrowserInfo { return isIE() && getBrowserMajorVersion() == 9; } + public boolean isIE10() { + return isIE() && getBrowserMajorVersion() == 10; + } + public boolean isChrome() { return browserDetails.isChrome(); } diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index e69c55d445..47fb29777c 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -332,6 +332,11 @@ public class ComponentLocator { } catch (Exception e) { return null; } + + if (element == null) { + return null; + } + } } diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 7aea69a61d..bf4dca7712 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -25,11 +25,13 @@ import java.util.List; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.AnchorElement; +import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Touch; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; @@ -1207,8 +1209,23 @@ public class Util { * @return the corresponding absolute URL as a string */ public static String getAbsoluteUrl(String url) { - AnchorElement a = Document.get().createAnchorElement(); - a.setHref(url); - return a.getHref(); + if (BrowserInfo.get().isIE8()) { + // The hard way - must use innerHTML and attach to DOM in IE8 + DivElement divElement = Document.get().createDivElement(); + divElement.getStyle().setDisplay(Display.NONE); + + RootPanel.getBodyElement().appendChild(divElement); + divElement.setInnerHTML("<a href='" + escapeHTML(url) + "' ></a>"); + + AnchorElement a = divElement.getChild(0).cast(); + String href = a.getHref(); + + RootPanel.getBodyElement().removeChild(divElement); + return href; + } else { + AnchorElement a = Document.get().createAnchorElement(); + a.setHref(url); + return a.getHref(); + } } } diff --git a/client/src/com/vaadin/client/extensions/BrowserPopupOpenerConnector.java b/client/src/com/vaadin/client/extensions/BrowserPopupOpenerConnector.java new file mode 100644 index 0000000000..2615444832 --- /dev/null +++ b/client/src/com/vaadin/client/extensions/BrowserPopupOpenerConnector.java @@ -0,0 +1,58 @@ +/* + * Copyright 2012 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.extensions; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ServerConnector; +import com.vaadin.server.BrowserPopupOpener; +import com.vaadin.shared.ui.BrowserPopupExtensionState; +import com.vaadin.shared.ui.Connect; + +/** + * Client-side code for {@link BrowserPopupOpener} + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +@Connect(BrowserPopupOpener.class) +public class BrowserPopupOpenerConnector extends AbstractExtensionConnector + implements ClickHandler { + + @Override + protected void extend(ServerConnector target) { + final Widget targetWidget = ((ComponentConnector) target).getWidget(); + + targetWidget.addDomHandler(this, ClickEvent.getType()); + } + + @Override + public BrowserPopupExtensionState getState() { + return (BrowserPopupExtensionState) super.getState(); + } + + @Override + public void onClick(ClickEvent event) { + String url = getResourceUrl("popup"); + if (url != null) { + Window.open(url, getState().target, getState().features); + } + } +} diff --git a/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java b/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java new file mode 100644 index 0000000000..6308de9c05 --- /dev/null +++ b/client/src/com/vaadin/client/extensions/FileDownloaderConnector.java @@ -0,0 +1,77 @@ +/* + * Copyright 2012 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.extensions; + +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.IFrameElement; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.dom.client.Style.Visibility; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ServerConnector; +import com.vaadin.server.FileDownloader; +import com.vaadin.shared.ui.Connect; + +@Connect(FileDownloader.class) +public class FileDownloaderConnector extends AbstractExtensionConnector + implements ClickHandler { + + private IFrameElement iframe; + + @Override + protected void extend(ServerConnector target) { + final Widget downloadWidget = ((ComponentConnector) target).getWidget(); + + downloadWidget.addDomHandler(this, ClickEvent.getType()); + } + + @Override + public void onClick(ClickEvent event) { + final String url = getResourceUrl("dl"); + if (url != null && !url.isEmpty()) { + if (iframe != null) { + // make sure it is not on dom tree already, might start + // multiple downloads at once + iframe.removeFromParent(); + } + iframe = Document.get().createIFrameElement(); + + Style style = iframe.getStyle(); + style.setVisibility(Visibility.HIDDEN); + style.setHeight(0, Unit.PX); + style.setWidth(0, Unit.PX); + + iframe.setFrameBorder(0); + iframe.setTabIndex(-1); + iframe.setSrc(url); + RootPanel.getBodyElement().appendChild(iframe); + } + } + + @Override + public void setParent(ServerConnector parent) { + super.setParent(parent); + if (parent == null) { + iframe.removeFromParent(); + } + } + +} diff --git a/client/src/com/vaadin/client/metadata/TypeDataBundle.java b/client/src/com/vaadin/client/metadata/TypeDataBundle.java index 158672e3a6..96f4884d52 100644 --- a/client/src/com/vaadin/client/metadata/TypeDataBundle.java +++ b/client/src/com/vaadin/client/metadata/TypeDataBundle.java @@ -22,7 +22,10 @@ public abstract class TypeDataBundle implements RunAsyncCallback { @Override public void onFailure(Throwable reason) { - ConnectorBundleLoader.get().setLoadFailure(getName(), reason); + ConnectorBundleLoader.get().setLoadFailure( + getName(), + new RuntimeException("Failed to load bundle " + getName() + + ": " + reason.getMessage(), reason)); } public abstract void load(); diff --git a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java index 0877b563a0..e4b2440ef7 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -15,6 +15,8 @@ */ package com.vaadin.client.ui.absolutelayout; +import java.util.List; + import com.google.gwt.user.client.Element; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; @@ -23,6 +25,7 @@ import com.vaadin.client.Util; import com.vaadin.client.VCaption; import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; +import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.LayoutClickEventHandler; import com.vaadin.shared.ui.Connect; @@ -53,6 +56,22 @@ public class AbsoluteLayoutConnector extends }; }; + private StateChangeHandler childStateChangeHandler = new StateChangeHandler() { + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + ComponentConnector child = (ComponentConnector) stateChangeEvent + .getConnector(); + List<String> childStyles = child.getState().styles; + if (childStyles == null) { + getWidget().setWidgetWrapperStyleNames(child.getWidget(), + (String[]) null); + } else { + getWidget().setWidgetWrapperStyleNames(child.getWidget(), + childStyles.toArray(new String[childStyles.size()])); + } + } + }; + private AbsoluteLayoutServerRpc rpc; /* @@ -160,11 +179,13 @@ public class AbsoluteLayoutConnector extends for (ComponentConnector child : getChildComponents()) { if (!getWidget().contains(child.getWidget())) { getWidget().add(child.getWidget()); + child.addStateChangeHandler(childStateChangeHandler); } } for (ComponentConnector oldChild : event.getOldChildren()) { if (oldChild.getParent() != this) { getWidget().remove(oldChild.getWidget()); + oldChild.removeStateChangeHandler(childStateChangeHandler); } } } diff --git a/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java b/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java index 6c58933dd3..fbf534a5b5 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/VAbsoluteLayout.java @@ -62,7 +62,7 @@ public class VAbsoluteLayout extends ComplexPanel { @Override public void add(Widget child) { AbsoluteWrapper wrapper = new AbsoluteWrapper(child); - wrapper.setStyleName(getStylePrimaryName() + "-wrapper"); + wrapper.updateStyleNames(); super.add(wrapper, canvas); } @@ -292,7 +292,7 @@ public class VAbsoluteLayout extends ComplexPanel { for (Widget w : getChildren()) { if (w instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) w; - wrapper.setStyleName(getStylePrimaryName() + "-wrapper"); + wrapper.updateStyleNames(); } } } @@ -305,6 +305,23 @@ public class VAbsoluteLayout extends ComplexPanel { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) widget; + + /* + * Cleanup old wrappers which have been left empty by other + * inner layouts moving the widget from the wrapper into their + * own hierarchy. This usually happens when a call to + * setWidget(widget) is done in an inner layout which + * automatically detaches the widget from the parent, in this + * case the wrapper, and re-attaches it somewhere else. This has + * to be done in the layout phase since the order of the + * hierarchy events are not defined. + */ + if (wrapper.getWidget() == null) { + wrapper.destroy(); + super.remove(wrapper); + continue; + } + Style wrapperStyle = wrapper.getElement().getStyle(); Style widgetStyle = wrapper.getWidget().getElement().getStyle(); if (widgetStyle.getHeight() != null @@ -341,6 +358,23 @@ public class VAbsoluteLayout extends ComplexPanel { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { AbsoluteWrapper wrapper = (AbsoluteWrapper) widget; + + /* + * Cleanup old wrappers which have been left empty by other + * inner layouts moving the widget from the wrapper into their + * own hierarchy. This usually happens when a call to + * setWidget(widget) is done in an inner layout which + * automatically detaches the widget from the parent, in this + * case the wrapper, and re-attaches it somewhere else. This has + * to be done in the layout phase since the order of the + * hierarchy events are not defined. + */ + if (wrapper.getWidget() == null) { + wrapper.destroy(); + super.remove(wrapper); + continue; + } + Style wrapperStyle = wrapper.getElement().getStyle(); Style widgetStyle = wrapper.getWidget().getElement().getStyle(); @@ -372,6 +406,24 @@ public class VAbsoluteLayout extends ComplexPanel { } /** + * Sets style names for the wrapper wrapping the widget in the layout. The + * style names will be prefixed with v-absolutelayout-wrapper. + * + * @param widget + * The widget which wrapper we want to add the stylenames to + * @param stylenames + * The style names that should be added to the wrapper + */ + public void setWidgetWrapperStyleNames(Widget widget, String... stylenames) { + AbsoluteWrapper wrapper = getChildWrapper(widget); + if (wrapper == null) { + throw new IllegalArgumentException( + "No wrapper for widget found, has the widget been added to the layout?"); + } + wrapper.setWrapperStyleNames(stylenames); + } + + /** * Internal wrapper for wrapping widgets in the Absolute layout */ protected class AbsoluteWrapper extends SimplePanel { @@ -383,6 +435,7 @@ public class VAbsoluteLayout extends ComplexPanel { private String zIndex; private VCaption caption; + private String[] extraStyleNames; /** * Constructor @@ -486,5 +539,30 @@ public class VAbsoluteLayout extends ComplexPanel { - caption.getHeight()); } } + + /** + * Sets the style names of the wrapper. Will be prefixed with the + * v-absolutelayout-wrapper prefix + * + * @param stylenames + * The wrapper style names + */ + public void setWrapperStyleNames(String... stylenames) { + extraStyleNames = stylenames; + updateStyleNames(); + } + + /** + * Updates the style names using the primary style name as prefix + */ + protected void updateStyleNames() { + setStyleName(VAbsoluteLayout.this.getStylePrimaryName() + + "-wrapper"); + if(extraStyleNames != null){ + for (String stylename : extraStyleNames) { + addStyleDependentName(stylename); + } + } + } } } diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java index 12ebb6a375..cfdda3dd1c 100644 --- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java @@ -93,6 +93,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector { @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); + clickEventHandler.handleEventHandlerRegistration(); for (ComponentConnector child : getChildComponents()) { if (!getState().childCss.containsKey(child)) { @@ -123,8 +124,6 @@ public class CssLayoutConnector extends AbstractLayoutConnector { */ @Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { - clickEventHandler.handleEventHandlerRegistration(); - int index = 0; for (ComponentConnector child : getChildComponents()) { VCaption childCaption = childToCaption.get(child); diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 7da2e17cbe..9707db610e 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -83,8 +83,18 @@ public abstract class AbstractOrderedLayoutConnector extends slot.setRelativeWidth(child.isRelativeWidth()); slot.setRelativeHeight(child.isRelativeHeight()); + // Update slot style names + List<String> childStyles = child.getState().styles; + if (childStyles == null) { + getWidget().setSlotStyleNames(child.getWidget(), + (String[]) null); + } else { + getWidget().setSlotStyleNames(child.getWidget(), + childStyles.toArray(new String[childStyles + .size()])); + } + updateSlotListeners(child); - // updateAllSlotListeners(); updateLayoutHeight(); } diff --git a/client/src/com/vaadin/client/ui/orderedlayout/VOrderedLayout.java b/client/src/com/vaadin/client/ui/orderedlayout/VOrderedLayout.java index e9cdc42b86..99fd681d63 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/VOrderedLayout.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/VOrderedLayout.java @@ -149,6 +149,8 @@ public class VOrderedLayout extends FlowPanel { */ public static final class Slot extends SimplePanel { + public static final String SLOT_CLASSNAME = "v-slot"; + private Element spacer; private Element captionWrap; private Element caption; @@ -177,8 +179,8 @@ public class VOrderedLayout extends FlowPanel { */ private Slot(Widget widget, VOrderedLayout layout) { this.layout = layout; + setStyleName(SLOT_CLASSNAME); setWidget(widget); - setStylePrimaryName("v-slot"); } /** @@ -190,6 +192,24 @@ public class VOrderedLayout extends FlowPanel { } /** + * Sets the style names for the slot containing the widget + * + * @param stylenames + * The style names for the slot + */ + protected void setStyleNames(String... stylenames) { + setStyleName(SLOT_CLASSNAME); + if (stylenames != null) { + for (String stylename : stylenames) { + addStyleDependentName(stylename); + } + } + + // Ensure alignment style names are correct + setAlignment(alignment); + } + + /** * Sets how the widget is aligned inside the slot * * @param alignment @@ -198,20 +218,21 @@ public class VOrderedLayout extends FlowPanel { public void setAlignment(AlignmentInfo alignment) { this.alignment = alignment; - if (alignment.isHorizontalCenter()) { + if (alignment != null && alignment.isHorizontalCenter()) { addStyleName(ALIGN_CLASS_PREFIX + "center"); removeStyleName(ALIGN_CLASS_PREFIX + "right"); - } else if (alignment.isRight()) { + } else if (alignment != null && alignment.isRight()) { addStyleName(ALIGN_CLASS_PREFIX + "right"); removeStyleName(ALIGN_CLASS_PREFIX + "center"); } else { removeStyleName(ALIGN_CLASS_PREFIX + "right"); removeStyleName(ALIGN_CLASS_PREFIX + "center"); } - if (alignment.isVerticalCenter()) { + + if (alignment != null && alignment.isVerticalCenter()) { addStyleName(ALIGN_CLASS_PREFIX + "middle"); removeStyleName(ALIGN_CLASS_PREFIX + "bottom"); - } else if (alignment.isBottom()) { + } else if (alignment != null && alignment.isBottom()) { addStyleName(ALIGN_CLASS_PREFIX + "bottom"); removeStyleName(ALIGN_CLASS_PREFIX + "middle"); } else { @@ -970,4 +991,20 @@ public class VOrderedLayout extends FlowPanel { super.setHeight(height); definedHeight = (height != null && !"".equals(height)); } + + /** + * Sets the slots style names. The style names will be prefixed with the + * v-slot prefix. + * + * @param stylenames + * The style names of the slot. + */ + public void setSlotStyleNames(Widget widget, String... stylenames) { + Slot slot = getSlot(widget); + if (slot == null) { + throw new IllegalArgumentException( + "A slot for the widget could not be found. Has the widget been added to the layout?"); + } + slot.setStyleNames(stylenames); + } } diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java index b1d60f50b5..4ce03d885d 100644 --- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java +++ b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java @@ -26,6 +26,8 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String IE9_BETA_IN_IE8_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"; private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; + private static final String IE10_WINDOWS_8 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"; + // "Version/" was added in 10.00 private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1"; private static final String OPERA1010_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.10"; @@ -353,6 +355,15 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertWindows(bd); } + public void testIE10() { + VBrowserDetails bd = new VBrowserDetails(IE10_WINDOWS_8); + assertEngineVersion(bd, 6); + assertIE(bd); + assertBrowserMajorVersion(bd, 10); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + /* * Helper methods below */ diff --git a/scripts/merge-check.sh b/scripts/merge-check.sh index ef52cd44f4..9e0d5e1e75 100755 --- a/scripts/merge-check.sh +++ b/scripts/merge-check.sh @@ -20,12 +20,19 @@ then echo "No unmerged commits" else command="$command --format=short" - message="There are $change_count commits that have not been merged from $UNTIL to $SINCE" + message="There are $change_count commits in $UNTIL that are missing from $SINCE" echo $message echo "" $command - details=`$command|perl -p -e 's/\n/|n/' | sed "s/['\|\[\]]/|\&/g"` + # Escape []|' and newline with | to make teamcity happy + details=`$command|sed "s/[]['\|]/|&/g"|perl -p -e 's/\n/|n/'` echo "##teamcity[testFailed name='$testname' message='$message' details='|n$details']" fi echo "##teamcity[testFinished name='$testname']" + +# Give non-ok exit status +if [ "$change_count" != "0" ] +then + exit 1 +fi diff --git a/server/src/com/vaadin/data/Container.java b/server/src/com/vaadin/data/Container.java index 47a0f9e7c8..1a453c7cd6 100644 --- a/server/src/com/vaadin/data/Container.java +++ b/server/src/com/vaadin/data/Container.java @@ -132,7 +132,7 @@ public interface Container extends Serializable { * ID of the Property to retrieve * @return Property with the given ID or <code>null</code> */ - public Property<?> getContainerProperty(Object itemId, Object propertyId); + public Property getContainerProperty(Object itemId, Object propertyId); /** * Gets the data type of all Properties identified by the given Property ID. diff --git a/server/src/com/vaadin/data/Item.java b/server/src/com/vaadin/data/Item.java index 8bdf963835..bff046bd38 100644 --- a/server/src/com/vaadin/data/Item.java +++ b/server/src/com/vaadin/data/Item.java @@ -40,7 +40,7 @@ public interface Item extends Serializable { * identifier of the Property to get * @return the Property with the given ID or <code>null</code> */ - public Property<?> getItemProperty(Object id); + public Property getItemProperty(Object id); /** * Gets the collection of IDs of all Properties stored in the Item. diff --git a/server/src/com/vaadin/data/Property.java b/server/src/com/vaadin/data/Property.java index 7e46af09b7..146355cb48 100644 --- a/server/src/com/vaadin/data/Property.java +++ b/server/src/com/vaadin/data/Property.java @@ -76,7 +76,7 @@ public interface Property<T> extends Serializable { * @throws Property.ReadOnlyException * if the object is in read-only mode */ - public void setValue(Object newValue) throws Property.ReadOnlyException; + public void setValue(T newValue) throws Property.ReadOnlyException; /** * Returns the type of the Property. The methods <code>getValue</code> and diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index 5d0c23e779..6bef69fe5b 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -274,8 +274,7 @@ public class FieldGroup implements Serializable { * If the property was not found in the item or no item has been * set */ - protected Property<?> getItemProperty(Object propertyId) - throws BindException { + protected Property getItemProperty(Object propertyId) throws BindException { Item item = getItemDataSource(); if (item == null) { throw new BindException("Could not lookup property with id " diff --git a/server/src/com/vaadin/data/util/AbstractBeanContainer.java b/server/src/com/vaadin/data/util/AbstractBeanContainer.java index cb09cdad46..3767f816e9 100644 --- a/server/src/com/vaadin/data/util/AbstractBeanContainer.java +++ b/server/src/com/vaadin/data/util/AbstractBeanContainer.java @@ -274,7 +274,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends * java.lang.Object) */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { Item item = getItem(itemId); if (item == null) { return null; diff --git a/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java b/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java index fdfb296186..ade8c22745 100644 --- a/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java @@ -671,7 +671,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * documentation from implemented interface. */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { return container.getContainerProperty(itemId, propertyId); } diff --git a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java index ad1eda9a8d..a44da84ae8 100644 --- a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java @@ -463,7 +463,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, * documentation from implemented interface. */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { return container.getContainerProperty(itemId, propertyId); } diff --git a/server/src/com/vaadin/data/util/FilesystemContainer.java b/server/src/com/vaadin/data/util/FilesystemContainer.java index 4c27169409..dbfe3bb6e8 100644 --- a/server/src/com/vaadin/data/util/FilesystemContainer.java +++ b/server/src/com/vaadin/data/util/FilesystemContainer.java @@ -481,7 +481,7 @@ public class FilesystemContainer implements Container.Hierarchical { * @return the requested property's value, or <code>null</code> */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { if (!(itemId instanceof File)) { return null; @@ -633,7 +633,7 @@ public class FilesystemContainer implements Container.Hierarchical { * here, we use the default documentation from implemented interface. */ @Override - public Property<?> getItemProperty(Object id) { + public Property getItemProperty(Object id) { return getContainerProperty(file, id); } diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java index 7273b28b66..6326d494b2 100644 --- a/server/src/com/vaadin/data/util/IndexedContainer.java +++ b/server/src/com/vaadin/data/util/IndexedContainer.java @@ -163,7 +163,7 @@ public class IndexedContainer extends * java.lang.Object) */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { if (!containsId(itemId)) { return null; } @@ -734,7 +734,7 @@ public class IndexedContainer extends * @see com.vaadin.data.Item#getItemProperty(java.lang.Object) */ @Override - public Property<?> getItemProperty(Object id) { + public Property getItemProperty(Object id) { return new IndexedContainerProperty(itemId, id); } @@ -841,7 +841,7 @@ public class IndexedContainer extends * * @since 3.0 */ - private class IndexedContainerProperty implements Property<Object>, + private class IndexedContainerProperty<T> implements Property<T>, Property.ValueChangeNotifier { /** @@ -881,8 +881,8 @@ public class IndexedContainer extends * @see com.vaadin.data.Property#getType() */ @Override - public Class<?> getType() { - return types.get(propertyId); + public Class<T> getType() { + return (Class<T>) types.get(propertyId); } /* @@ -891,8 +891,8 @@ public class IndexedContainer extends * @see com.vaadin.data.Property#getValue() */ @Override - public Object getValue() { - return items.get(itemId).get(propertyId); + public T getValue() { + return (T) items.get(itemId).get(propertyId); } /* diff --git a/server/src/com/vaadin/data/util/MethodProperty.java b/server/src/com/vaadin/data/util/MethodProperty.java index 1ae60daac0..52ea2b0347 100644 --- a/server/src/com/vaadin/data/util/MethodProperty.java +++ b/server/src/com/vaadin/data/util/MethodProperty.java @@ -651,21 +651,14 @@ public class MethodProperty<T> extends AbstractProperty<T> { * @see #invokeSetMethod(Object) */ @Override - @SuppressWarnings("unchecked") - public void setValue(Object newValue) throws Property.ReadOnlyException { + public void setValue(T newValue) throws Property.ReadOnlyException { // Checks the mode if (isReadOnly()) { throw new Property.ReadOnlyException(); } - // Checks the type of the value - if (newValue != null && !type.isAssignableFrom(newValue.getClass())) { - throw new IllegalArgumentException( - "Invalid value type for ObjectProperty."); - } - - invokeSetMethod((T) newValue); + invokeSetMethod(newValue); fireValueChange(); } diff --git a/server/src/com/vaadin/data/util/NestedMethodProperty.java b/server/src/com/vaadin/data/util/NestedMethodProperty.java index 692e6a085f..3961358c4b 100644 --- a/server/src/com/vaadin/data/util/NestedMethodProperty.java +++ b/server/src/com/vaadin/data/util/NestedMethodProperty.java @@ -217,19 +217,13 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { * @see #invokeSetMethod(Object) */ @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(T newValue) throws ReadOnlyException { // Checks the mode if (isReadOnly()) { throw new Property.ReadOnlyException(); } - // Checks the type of the value - if (newValue != null && !type.isAssignableFrom(newValue.getClass())) { - throw new IllegalArgumentException( - "Invalid value type for NestedMethodProperty."); - } - - invokeSetMethod((T) newValue); + invokeSetMethod(newValue); fireValueChange(); } diff --git a/server/src/com/vaadin/data/util/ObjectProperty.java b/server/src/com/vaadin/data/util/ObjectProperty.java index 9e9687b2d5..b0ab18eec2 100644 --- a/server/src/com/vaadin/data/util/ObjectProperty.java +++ b/server/src/com/vaadin/data/util/ObjectProperty.java @@ -128,23 +128,14 @@ public class ObjectProperty<T> extends AbstractProperty<T> { * read-only mode */ @Override - @SuppressWarnings("unchecked") - public void setValue(Object newValue) throws Property.ReadOnlyException { + public void setValue(T newValue) throws Property.ReadOnlyException { // Checks the mode if (isReadOnly()) { throw new Property.ReadOnlyException(); } - // Checks the type of the value - if (newValue != null && !type.isAssignableFrom(newValue.getClass())) { - throw new IllegalArgumentException("Invalid value type " - + newValue.getClass().getName() - + " for ObjectProperty of type " + type.getName() + "."); - } - - // the cast is safe after an isAssignableFrom check - this.value = (T) newValue; + this.value = newValue; fireValueChange(); } diff --git a/server/src/com/vaadin/data/util/PropertyFormatter.java b/server/src/com/vaadin/data/util/PropertyFormatter.java index 26f93b9582..58a53cd7da 100644 --- a/server/src/com/vaadin/data/util/PropertyFormatter.java +++ b/server/src/com/vaadin/data/util/PropertyFormatter.java @@ -212,7 +212,7 @@ public abstract class PropertyFormatter<T> extends AbstractProperty<String> } @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(String newValue) throws ReadOnlyException { if (dataSource == null) { return; } diff --git a/server/src/com/vaadin/data/util/PropertysetItem.java b/server/src/com/vaadin/data/util/PropertysetItem.java index b423c72f43..7ca0fc6973 100644 --- a/server/src/com/vaadin/data/util/PropertysetItem.java +++ b/server/src/com/vaadin/data/util/PropertysetItem.java @@ -68,7 +68,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, * @return the Property with the given ID or <code>null</code> */ @Override - public Property<?> getItemProperty(Object id) { + public Property getItemProperty(Object id) { return map.get(id); } diff --git a/server/src/com/vaadin/data/util/TextFileProperty.java b/server/src/com/vaadin/data/util/TextFileProperty.java index 05d0c6f683..9c93a75c82 100644 --- a/server/src/com/vaadin/data/util/TextFileProperty.java +++ b/server/src/com/vaadin/data/util/TextFileProperty.java @@ -129,7 +129,7 @@ public class TextFileProperty extends AbstractProperty<String> { * @see com.vaadin.data.Property#setValue(java.lang.Object) */ @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(String newValue) throws ReadOnlyException { if (isReadOnly()) { throw new ReadOnlyException(); } diff --git a/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java b/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java index c03a4ce959..d8d27ae4c8 100644 --- a/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java +++ b/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java @@ -74,7 +74,7 @@ public class TransactionalPropertyWrapper<T> extends AbstractProperty<T> } @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(T newValue) throws ReadOnlyException { // Causes a value change to be sent to this listener which in turn fires // a new value change event for this property wrappedProperty.setValue(newValue); diff --git a/server/src/com/vaadin/data/util/sqlcontainer/RowItem.java b/server/src/com/vaadin/data/util/sqlcontainer/RowItem.java index ed256b2b5a..461900b27b 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/RowItem.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/RowItem.java @@ -61,7 +61,7 @@ public final class RowItem implements Item { } @Override - public Property<?> getItemProperty(Object id) { + public Property getItemProperty(Object id) { if (id instanceof String && id != null) { for (ColumnProperty cp : properties) { if (id.equals(cp.getPropertyId())) { diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index 64014cd254..69186fc310 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -248,7 +248,7 @@ public class SQLContainer implements Container, Container.Filterable, */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { Item item = getItem(itemId); if (item == null) { return null; diff --git a/server/src/com/vaadin/server/BrowserPopupOpener.java b/server/src/com/vaadin/server/BrowserPopupOpener.java new file mode 100644 index 0000000000..c55fa65931 --- /dev/null +++ b/server/src/com/vaadin/server/BrowserPopupOpener.java @@ -0,0 +1,168 @@ +/* + * Copyright 2012 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 com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.ui.BrowserPopupExtensionState; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.UI; + +/** + * Component extension that opens a browser popup window when the extended + * component is clicked. + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class BrowserPopupOpener extends AbstractExtension { + + private final BrowserPopupUIProvider uiProvider; + + /** + * Creates a popup opener that will open popups containing the provided UI + * class + * + * @param uiClass + * the UI class that should be opened when the extended component + * is clicked + */ + public BrowserPopupOpener(Class<? extends UI> uiClass) { + this(uiClass, generateUIClassUrl(uiClass)); + } + + /** + * Creates a popup opener that will open popups containing the provided UI + * using the provided path + * + * @param uiClass + * the UI class that should be opened when the extended component + * is clicked + * @param path + * the path that the UI should be bound to + */ + public BrowserPopupOpener(Class<? extends UI> uiClass, String path) { + // Create a Resource with a translated URL going to the VaadinService + this(new ExternalResource(ApplicationConstants.APP_PROTOCOL_PREFIX + + path), new BrowserPopupUIProvider(uiClass, path)); + } + + /** + * Creates a popup opener that will open popups to the provided URL + * + * @param url + * the URL to open in the popup + */ + public BrowserPopupOpener(String url) { + this(new ExternalResource(url)); + } + + /** + * Creates a popup opener that will open popups to the provided resource + * + * @param resource + * the resource to open in the popup + */ + public BrowserPopupOpener(Resource resource) { + this(resource, null); + } + + private BrowserPopupOpener(Resource resource, + BrowserPopupUIProvider uiProvider) { + this.uiProvider = uiProvider; + setResource("popup", resource); + } + + public void extend(AbstractComponent target) { + super.extend(target); + } + + /** + * Sets the target window name that will be used when opening the popup. If + * a popup has already been opened with the same name, the contents of that + * window will be replaced instead of opening a new window. If the name is + * <code>null</code> or <code>"blank"</code>, the popup will always be + * opened in a new window. + * + * @param popupName + * the target name for the popups + */ + public void setPopupName(String popupName) { + getState().target = popupName; + } + + /** + * Gets the popup target name. + * + * @see #setPopupName(String) + * + * @return the popup target string + */ + public String getPopupName() { + return getState().target; + } + + // Avoid breaking url to multiple lines + // @formatter:off + /** + * Sets the features for opening the popup. See e.g. + * {@link https://developer.mozilla.org/en-US/docs/DOM/window.open#Position_and_size_features} + * for a description of the commonly supported features. + * + * @param features a string with popup features, or <code>null</code> to use the default features. + */ + // @formatter:on + public void setFeatures(String features) { + getState().features = features; + } + + /** + * Gets the popup features. + * + * @see #setFeatures(String) + * @return + */ + public String getFeatures() { + return getState().features; + } + + @Override + protected BrowserPopupExtensionState getState() { + return (BrowserPopupExtensionState) super.getState(); + } + + @Override + public void attach() { + super.attach(); + if (uiProvider != null + && !getSession().getUIProviders().contains(uiProvider)) { + getSession().addUIProvider(uiProvider); + } + } + + @Override + public void detach() { + if (uiProvider != null) { + getSession().removeUIProvider(uiProvider); + } + super.detach(); + } + + private static String generateUIClassUrl(Class<? extends UI> uiClass) { + return "popup/" + uiClass.getSimpleName(); + } + +} diff --git a/server/src/com/vaadin/server/BrowserPopupUIProvider.java b/server/src/com/vaadin/server/BrowserPopupUIProvider.java new file mode 100644 index 0000000000..23036dabed --- /dev/null +++ b/server/src/com/vaadin/server/BrowserPopupUIProvider.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012 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 com.vaadin.ui.UI; + +public class BrowserPopupUIProvider extends UIProvider { + + private final String path; + private final Class<? extends UI> uiClass; + + public BrowserPopupUIProvider(Class<? extends UI> uiClass, String path) { + this.path = ensureInitialSlash(path); + this.uiClass = uiClass; + } + + private static String ensureInitialSlash(String path) { + if (path == null) { + return null; + } else if (!path.startsWith("/")) { + return '/' + path; + } else { + return path; + } + } + + @Override + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + String requestPathInfo = event.getRequest().getRequestPathInfo(); + if (path.equals(requestPathInfo)) { + return uiClass; + } else { + return null; + } + } +} diff --git a/server/src/com/vaadin/server/FileDownloader.java b/server/src/com/vaadin/server/FileDownloader.java new file mode 100644 index 0000000000..a5f450c28b --- /dev/null +++ b/server/src/com/vaadin/server/FileDownloader.java @@ -0,0 +1,143 @@ +/* + * Copyright 2012 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 java.io.IOException; + +import com.vaadin.ui.AbstractComponent; + +/** + * Extension that starts a download when the extended component is clicked. This + * is used to overcome two challenges: + * <ul> + * <li>Resource should be bound to a component to allow it to be garbage + * collected when there are no longer any ways of reaching the resource.</li> + * <li>Download should be started directly when the user clicks e.g. a Button + * without going through a server-side click listener to avoid triggering + * security warnings in some browsers.</li> + * </ul> + * <p> + * Please note that the download will be started in an iframe, which means that + * care should be taken to avoid serving content types that might make the + * browser attempt to show the content using a plugin instead of downloading it. + * Connector resources (e.g. {@link FileResource} and {@link ClassResource}) + * will automatically be served using a + * <code>Content-Type: application/octet-stream</code> header unless + * {@link #setOverrideContentType(boolean)} has been set to <code>false</code> + * while files served in other ways, (e.g. {@link ExternalResource} or + * {@link ThemeResource}) will not automatically get this treatment. + * </p> + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class FileDownloader extends AbstractExtension { + + private boolean overrideContentType = true; + + /** + * Creates a new file downloader for the given resource. To use the + * downloader, you should also {@link #extend(AbstractClientConnector)} the + * component. + * + * @param resource + * the resource to download when the user clicks the extended + * component. + */ + public FileDownloader(Resource resource) { + if (resource == null) { + throw new IllegalArgumentException("resource may not be null"); + } + setResource("dl", resource); + } + + public void extend(AbstractComponent target) { + super.extend(target); + } + + /** + * Gets the resource set for download. + * + * @return the resource that will be downloaded if clicking the extended + * component + */ + public Resource getFileDownloadResource() { + return getResource("dl"); + } + + /** + * Sets whether the content type of served resources should be overriden to + * <code>application/octet-stream</code> to reduce the risk of a browser + * plugin choosing to display the resource instead of downloading it. This + * is by default set to <code>true</code>. + * <p> + * Please note that this only affects Connector resources (e.g. + * {@link FileResource} and {@link ClassResource}) but not other resource + * types (e.g. {@link ExternalResource} or {@link ThemeResource}). + * </p> + * + * @param overrideContentType + * <code>true</code> to override the content type if possible; + * <code>false</code> to use the original content type. + */ + public void setOverrideContentType(boolean overrideContentType) { + this.overrideContentType = overrideContentType; + } + + /** + * Checks whether the content type should be overridden. + * + * @see #setOverrideContentType(boolean) + * + * @return <code>true</code> if the content type will be overridden when + * possible; <code>false</code> if the original content type will be + * used. + */ + public boolean isOverrideContentType() { + return overrideContentType; + } + + @Override + public boolean handleConnectorRequest(VaadinRequest request, + VaadinResponse response, String path) throws IOException { + if (!path.matches("dl(/.*)?")) { + // Ignore if it isn't for us + return false; + } + + Resource resource = getFileDownloadResource(); + if (resource instanceof ConnectorResource) { + DownloadStream stream = ((ConnectorResource) resource).getStream(); + + if (stream.getParameter("Content-Disposition") == null) { + // Content-Disposition: attachment generally forces download + stream.setParameter("Content-Disposition", + "attachment; filename=\"" + stream.getFileName() + "\""); + } + + // Content-Type to block eager browser plug-ins from hijacking the + // file + if (isOverrideContentType()) { + stream.setContentType("application/octet-stream;charset=UTF-8"); + } + stream.writeResponse(request, response); + return true; + } else { + return false; + } + } +} diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 44e82b5898..05e79500bb 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -423,6 +423,8 @@ public abstract class VaadinService implements Serializable { throws ServiceException { VaadinServiceSession session = createVaadinSession(request); + VaadinServiceSession.setCurrent(session); + session.storeInSession(this, request.getWrappedSession()); // Initial locale comes from the request diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index d6dd03c171..53301f093a 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -427,17 +427,9 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @throws Property.ReadOnlyException */ @Override - public void setValue(Object newFieldValue) - throws Property.ReadOnlyException, Converter.ConversionException { - // This check is needed as long as setValue accepts Object instead of T - if (newFieldValue != null) { - if (!getType().isAssignableFrom(newFieldValue.getClass())) { - throw new Converter.ConversionException("Value of type " - + newFieldValue.getClass() + " cannot be assigned to " - + getType().getName()); - } - } - setValue((T) newFieldValue, false); + public void setValue(T newFieldValue) throws Property.ReadOnlyException, + Converter.ConversionException { + setValue(newFieldValue, false); } /** @@ -695,19 +687,18 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ private Object convertToModel(T fieldValue) throws Converter.ConversionException { + Class<?> modelType = null; + Property pd = getPropertyDataSource(); + if (pd != null) { + modelType = pd.getType(); + } else if (getConverter() != null) { + modelType = getConverter().getModelType(); + } try { - Class<?> modelType = null; - Property pd = getPropertyDataSource(); - if (pd != null) { - modelType = pd.getType(); - } else if (getConverter() != null) { - modelType = getConverter().getModelType(); - } return ConverterUtil.convertToModel(fieldValue, (Class<Object>) modelType, getConverter(), getLocale()); } catch (ConversionException e) { - throw new ConversionException( - getConversionError(converter.getModelType()), e); + throw new ConversionException(getConversionError(modelType), e); } } diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 78fab068dd..d2092ceb2c 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -784,7 +784,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements * @see com.vaadin.data.Container#getContainerProperty(Object, Object) */ @Override - public Property<?> getContainerProperty(Object itemId, Object propertyId) { + public Property getContainerProperty(Object itemId, Object propertyId) { return items.getContainerProperty(itemId, propertyId); } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 3dd2b4dae8..e8618a33ee 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -429,7 +429,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(String newValue) throws ReadOnlyException { super.setValue(newValue); /* * Make sure w reset lastKnownTextContent field on value change. The diff --git a/server/src/com/vaadin/ui/DefaultFieldFactory.java b/server/src/com/vaadin/ui/DefaultFieldFactory.java index 28a5b6c669..5072503428 100644 --- a/server/src/com/vaadin/ui/DefaultFieldFactory.java +++ b/server/src/com/vaadin/ui/DefaultFieldFactory.java @@ -57,9 +57,9 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory } @Override - public Field<?> createField(Container container, Object itemId, + public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) { - Property<?> containerProperty = container.getContainerProperty(itemId, + Property containerProperty = container.getContainerProperty(itemId, propertyId); Class<?> type = containerProperty.getType(); Field<?> field = createFieldByPropertyType(type); diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index dd804ef67a..4b7782e0a9 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -572,7 +572,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @see com.vaadin.data.Item#getItemProperty(Object) */ @Override - public Property<?> getItemProperty(Object id) { + public Property getItemProperty(Object id) { final Field<?> field = fields.get(id); if (field == null) { // field does not exist or it is not (yet) created for this property @@ -593,7 +593,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @param propertyId * the id of the property. */ - public Field<?> getField(Object propertyId) { + public Field getField(Object propertyId) { return fields.get(propertyId); } diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 89281e0c27..27145946d8 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -192,14 +192,9 @@ public class Label extends AbstractComponent implements Property<String>, * the New value of the label. */ @Override - public void setValue(Object newStringValue) { - if (newStringValue != null && newStringValue.getClass() != String.class) { - throw new Converter.ConversionException("Value of type " - + newStringValue.getClass() + " cannot be assigned to " - + String.class.getName()); - } + public void setValue(String newStringValue) { if (getPropertyDataSource() == null) { - getState().text = (String) newStringValue; + getState().text = newStringValue; } else { throw new IllegalStateException( "Label is only a Property.Viewer and cannot update its data source"); diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java index fa51197a8b..1c35d3d1d8 100644 --- a/server/src/com/vaadin/ui/ProgressIndicator.java +++ b/server/src/com/vaadin/ui/ProgressIndicator.java @@ -153,7 +153,7 @@ public class ProgressIndicator extends AbstractField<Number> implements * @see com.vaadin.ui.AbstractField#setValue() */ @Override - public void setValue(Object newValue) { + public void setValue(Number newValue) { if (dataSource == null) { throw new IllegalStateException("Datasource must be set"); } diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index fe913f6b2c..4c829a7cb4 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -289,14 +289,9 @@ public class Slider extends AbstractField<Double> { } @Override - public void setValue(Object newFieldValue) { - if (newFieldValue instanceof Number) { - // Support setting all types of Numbers - newFieldValue = ((Number) newFieldValue).doubleValue(); - } + public void setValue(Double newFieldValue) { super.setValue(newFieldValue); - // The cast is safe if the above call returned without throwing - getState().value = (Double) newFieldValue; + getState().value = newFieldValue; } /** diff --git a/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTest.java b/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTest.java index 6f96c3a51a..96673ff608 100644 --- a/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTest.java +++ b/server/tests/src/com/vaadin/data/util/filter/AbstractFilterTest.java @@ -30,7 +30,7 @@ public abstract class AbstractFilterTest<FILTERTYPE extends Filter> extends } @Override - public void setValue(Object newValue) throws ReadOnlyException { + public void setValue(String newValue) throws ReadOnlyException { throw new ReadOnlyException(); } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java index 8d4cdc3c7c..83224861b6 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java @@ -2,10 +2,15 @@ package com.vaadin.tests.server.component.abstractfield; import java.util.Locale; +import junit.framework.Assert; import junit.framework.TestCase; +import org.junit.Test; + import com.vaadin.data.util.MethodProperty; +import com.vaadin.data.util.ObjectProperty; import com.vaadin.data.util.converter.Converter; +import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.StringToIntegerConverter; import com.vaadin.server.VaadinServiceSession; import com.vaadin.tests.data.bean.Address; @@ -67,40 +72,6 @@ public class AbstractFieldValueConversions extends TestCase { assertEquals("abc", paulaBean.getFirstName()); } - public void testFailingConversion() { - TextField tf = new TextField(); - tf.setConverter(new Converter<String, Integer>() { - - @Override - public Integer convertToModel(String value, Locale locale) { - throw new ConversionException("Failed"); - } - - @Override - public String convertToPresentation(Integer value, Locale locale) { - throw new ConversionException("Failed"); - } - - @Override - public Class<Integer> getModelType() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Class<String> getPresentationType() { - // TODO Auto-generated method stub - return null; - } - }); - try { - tf.setValue(1); - fail("setValue(Integer) should throw an exception"); - } catch (Converter.ConversionException e) { - // OK, expected - } - } - public void testIntegerStringConversion() { TextField tf = new TextField(); @@ -213,4 +184,19 @@ public class AbstractFieldValueConversions extends TestCase { } + @Test + public void testNullConverter() { + TextField tf = new TextField("foo"); + tf.setPropertyDataSource(new ObjectProperty<Integer>(12)); + tf.setConverter((Converter) null); + try { + Object v = tf.getConvertedValue(); + System.out.println(v); + Assert.fail("Trying to convert String -> Integer should fail when there is no converter"); + } catch (ConversionException e) { + // ok, should happen when there is no converter but conversion is + // needed + } + } + } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index 83bb7c4613..e81f4ac6f7 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -63,20 +63,20 @@ public class RemoveListenersOnDetach { }; }; - Property property = new AbstractProperty() { + Property<String> property = new AbstractProperty<String>() { @Override - public Object getValue() { + public String getValue() { return null; } @Override - public void setValue(Object newValue) throws ReadOnlyException, + public void setValue(String newValue) throws ReadOnlyException, ConversionException { fireValueChange(); } @Override - public Class<?> getType() { + public Class<String> getType() { return String.class; } }; diff --git a/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java b/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java index b969bf5e53..d1dd87d923 100644 --- a/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/slider/SliderTest.java @@ -10,12 +10,12 @@ public class SliderTest extends TestCase { public void testOutOfBounds() { Slider s = new Slider(0, 10); - s.setValue(0); + s.setValue(0.0); Assert.assertEquals(0.0, s.getValue()); - s.setValue(10); + s.setValue(10.0); Assert.assertEquals(10.0, s.getValue()); try { - s.setValue(20); + s.setValue(20.0); fail("Should throw out of bounds exception"); } catch (ValueOutOfBoundsException e) { // TODO: handle exception diff --git a/server/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/server/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java index f2de4f3c04..c8d6ecce9c 100644 --- a/server/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java +++ b/server/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java @@ -123,7 +123,7 @@ public abstract class AbstractTestFieldValueChange<T> extends TestCase { * Override in subclasses to set value with changeVariables(). */ protected void setValue(AbstractField<T> field) { - field.setValue("newValue"); + field.setValue((T) "newValue"); } } diff --git a/shared/src/com/vaadin/shared/ui/BrowserPopupExtensionState.java b/shared/src/com/vaadin/shared/ui/BrowserPopupExtensionState.java new file mode 100644 index 0000000000..a9ca6841d8 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/BrowserPopupExtensionState.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012 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; + +import com.vaadin.shared.ComponentState; + +public class BrowserPopupExtensionState extends ComponentState { + + public String target = "_blank"; + + public String features; + +} diff --git a/uitest/integration_tests.xml b/uitest/integration_tests.xml index 15c54830d3..5587fe26b8 100644 --- a/uitest/integration_tests.xml +++ b/uitest/integration_tests.xml @@ -236,14 +236,6 @@ </antcall> </target> - <target name="integration-test-weblogic9"> - <antcall target="run-generic-integration-test"> - <param name="startDelay" value="600" /> - <param name="target-port" value="7001" /> - <param name="target-server" value="weblogic9" /> - </antcall> - </target> - <target name="integration-test-websphere8"> <antcall target="run-generic-integration-test"> <param name="startDelay" value="600" /> @@ -317,7 +309,6 @@ <antcall target="integration-test-exo3" /> <antcall target="integration-test-weblogicPortal" /> <antcall target="integration-test-liferay5" /> - <antcall target="integration-test-weblogic9" /> <antcall target="integration-test-weblogic10" /> <antcall target="integration-test-weblogic12" /> <antcall target="integration-test-gatein3" /> diff --git a/uitest/src/com/vaadin/tests/TestMethodProperty.java b/uitest/src/com/vaadin/tests/TestMethodProperty.java index 49a3c110fa..ab9c416a5c 100644 --- a/uitest/src/com/vaadin/tests/TestMethodProperty.java +++ b/uitest/src/com/vaadin/tests/TestMethodProperty.java @@ -15,7 +15,7 @@ public class TestMethodProperty { Integer.TYPE, myTest, "getInt", "setInt", new Object[0], new Object[] { null }, 0); - methodProperty2.setValue("3"); + methodProperty2.setValue(3); System.out.println("Succeeded"); diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html index f5313c7bec..93f102097a 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html +++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html @@ -60,9 +60,9 @@ <td></td> </tr> <tr> - <td>assertLocation</td> - <td>https://www.google.*/</td> - <td>https://www.google.*/</td> + <td>assertText</td> + <td>//h1</td> + <td>Index of /download/nightly</td> </tr> <!--Open again and verify we get a Session Expired error if doing something after closing the session--> <tr> diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java index 0278190084..6f1c05b9c8 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java @@ -62,7 +62,8 @@ public class CloseSession extends AbstractTestUI { new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - getPage().setLocation("https://www.google.com"); + getPage().setLocation( + "http://vaadin.com/download/nightly/"); getSession().close(); } })); diff --git a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html index 70bb8cc8f3..6ed410fdb6 100644 --- a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html +++ b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html @@ -18,8 +18,8 @@ </tr> <tr> <td>assertText</td> - <td>//pre[1]</td> - <td>java.lang.InstantiationException: Failed to load application class: ClassThatIsNotPresent</td> + <td>//pre[2]</td> + <td>*java.lang.InstantiationException: Failed to load application class: ClassThatIsNotPresent*</td> </tr> </tbody></table> </body> diff --git a/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java b/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java new file mode 100644 index 0000000000..e773c8c75b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/FileDownloaderTest.java @@ -0,0 +1,194 @@ +/* + * Copyright 2012 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; + +import java.awt.image.BufferedImage; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import javax.imageio.ImageIO; + +import com.vaadin.server.ClassResource; +import com.vaadin.server.ConnectorResource; +import com.vaadin.server.FileDownloader; +import com.vaadin.server.FileResource; +import com.vaadin.server.StreamResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinResponse; +import com.vaadin.tests.components.embedded.EmbeddedPdf; +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; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeButton; + +public class FileDownloaderTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + List<Class<? extends Component>> components = new ArrayList<Class<? extends Component>>(); + components.add(Button.class); + components.add(NativeButton.class); + components.add(CssLayout.class); + components.add(Label.class); + + // Resource resource = new ExternalResource( + // "https://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.beta1/vaadin-all-7.0.0.beta1.zip"); + // addComponents(resource, components); + // resource = new ExternalResource( + // "https://vaadin.com/download/book-of-vaadin/current/pdf/book-of-vaadin.pdf"); + // addComponents(resource, components); + ConnectorResource resource; + resource = new StreamResource(new StreamResource.StreamSource() { + + @Override + public InputStream getStream() { + try { + BufferedImage img = getImage2("demo.png"); + ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream(); + ImageIO.write(img, "png", imagebuffer); + Thread.sleep(5000); + + return new ByteArrayInputStream(imagebuffer.toByteArray()); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + }, "demo.png"); + addComponents("Dynamic image", resource, components); + try { + File hugeFile = File.createTempFile("huge", ".txt"); + hugeFile.deleteOnExit(); + BufferedOutputStream os = new BufferedOutputStream( + new FileOutputStream(hugeFile)); + int writeAtOnce = 1024 * 1024; + byte[] b = new byte[writeAtOnce]; + for (int i = 0; i < 5l * 1024l * 1024l; i += writeAtOnce) { + os.write(b); + } + os.close(); + resource = new FileResource(hugeFile); + addComponents("Huge text file", resource, components); + } catch (IOException e) { + e.printStackTrace(); + } + // resource = new DynamicConnectorResource(this, "requestImage.png"); + // addComponents(resource, components); + // resource = new ThemeResource("favicon.ico"); + // addComponents(resource, components); + resource = new ClassResource(new EmbeddedPdf().getClass(), "test.pdf"); + addComponents("Class resource pdf", resource, components); + } + + public void addComponents(String caption, ConnectorResource resource, + List<Class<? extends Component>> components) { + HorizontalLayout layout = new HorizontalLayout(); + layout.setCaption(caption); + for (Class<? extends Component> cls : components) { + try { + AbstractComponent c = (AbstractComponent) cls.newInstance(); + c.setId(cls.getName()); + c.setCaption(cls.getName()); + c.setDescription(resource.getMIMEType() + " / " + + resource.getClass()); + c.setWidth("100px"); + c.setHeight("100px"); + + layout.addComponent(c); + + new FileDownloader(resource).extend(c); + + if (c instanceof Button) { + ((Button) c).addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + } + }); + } + } catch (Exception e) { + System.err.println("Could not instatiate " + cls.getName()); + } + } + addComponent(layout); + } + + private static final String DYNAMIC_IMAGE_NAME = "requestImage.png"; + + @Override + public boolean handleConnectorRequest(VaadinRequest request, + VaadinResponse response, String path) throws IOException { + if (DYNAMIC_IMAGE_NAME.equals(path)) { + // Create an image, draw the "text" parameter to it and output it to + // the browser. + String text = request.getParameter("text"); + if (text == null) { + text = DYNAMIC_IMAGE_NAME; + } + BufferedImage bi = getImage(text); + response.setContentType("image/png"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + + path + "\""); + ImageIO.write(bi, "png", response.getOutputStream()); + + return true; + } else { + return super.handleConnectorRequest(request, response, path); + } + } + + private BufferedImage getImage(String text) { + BufferedImage bi = new BufferedImage(150, 30, + BufferedImage.TYPE_3BYTE_BGR); + bi.getGraphics() + .drawChars(text.toCharArray(), 0, text.length(), 10, 20); + return bi; + } + + private BufferedImage getImage2(String text) { + BufferedImage bi = new BufferedImage(200, 200, + BufferedImage.TYPE_INT_RGB); + bi.getGraphics() + .drawChars(text.toCharArray(), 0, text.length(), 10, 20); + return bi; + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutWrapperStyles.html b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutWrapperStyles.html new file mode 100644 index 0000000000..1b92e3cdc5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutWrapperStyles.html @@ -0,0 +1,52 @@ +<?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.absolutelayout.AbsoluteLayoutWrapperStyles?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutWrapperStyles::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]</td> + <td>v-absolutelayout-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutWrapperStyles::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]</td> + <td>v-absolutelayout-wrapper-my-label</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutWrapperStyles::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[0]</td> + <td>v-absolutelayout-wrapper-my-second-label</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutWrapperStyles::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[1]</td> + <td>v-absolutelayout-wrapper</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutWrapperStyles::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[1]</td> + <td>v-absolutelayout-wrapper-my-button</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutWrapperStyles::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAbsoluteLayout[0]/VAbsoluteLayout$AbsoluteWrapper[1]</td> + <td>v-absolutelayout-wrapper-my-second-button</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutWrapperStyles.java b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutWrapperStyles.java new file mode 100644 index 0000000000..11d9f9c850 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutWrapperStyles.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.absolutelayout; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbsoluteLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; + +public class AbsoluteLayoutWrapperStyles extends TestBase { + + @Override + protected void setup() { + AbsoluteLayout layout = new AbsoluteLayout(); + layout.setWidth("500px"); + layout.setHeight("500px"); + + Label lbl = new Label("Label"); + lbl.setStyleName("my-label"); + lbl.addStyleName("my-second-label"); + layout.addComponent(lbl); + + Button btn = new Button("Button"); + btn.setStyleName("my-button"); + btn.addStyleName("my-second-button"); + layout.addComponent(btn, "top:50px;"); + + addComponent(layout); + } + + @Override + protected String getDescription() { + return "Absolutelayout wrapper should get child stylenames"; + } + + @Override + protected Integer getTicketNumber() { + return 9051; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java index efba67199d..7b2b945f23 100644 --- a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java +++ b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java @@ -20,7 +20,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.MenuItem; -public abstract class AbstractFieldTest<T extends AbstractField<?>> extends +public abstract class AbstractFieldTest<T extends AbstractField> extends AbstractComponentTest<T> implements ValueChangeListener, ReadOnlyStatusChangeListener { diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html index aa6c536af3..266a1a379d 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html @@ -28,7 +28,7 @@ </tr> <tr> <td>assertText</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-4</td> <td>27</td> </tr> <tr> @@ -48,7 +48,7 @@ </tr> <tr> <td>assertText</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-5</td> <td>26</td> </tr> <tr> @@ -68,7 +68,7 @@ </tr> <tr> <td>assertText</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-4</td> <td>27</td> </tr> <tr> @@ -78,7 +78,7 @@ </tr> <tr> <td>assertText</td> - <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#day-4</td> <td>27</td> </tr> <tr> @@ -88,7 +88,7 @@ </tr> <tr> <td>assertText</td> - <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[4]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#day-5</td> <td>26</td> </tr> <tr> @@ -98,7 +98,7 @@ </tr> <tr> <td>assertText</td> - <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[6]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#day-4</td> <td>27</td> </tr> <tr> @@ -113,7 +113,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-4</td> <td>12,9</td> </tr> <tr> @@ -128,7 +128,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-5</td> <td>14,7</td> </tr> <tr> @@ -143,7 +143,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-4</td> <td>6,11</td> </tr> <tr> @@ -153,7 +153,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#day-4</td> <td>11,7</td> </tr> <tr> @@ -163,7 +163,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[4]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#day-5</td> <td>13,4</td> </tr> <tr> @@ -173,7 +173,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[6]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#day-4</td> <td>11,8</td> </tr> <tr> @@ -293,7 +293,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-4</td> <td>12,8</td> </tr> <tr> @@ -308,7 +308,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-5</td> <td>14,9</td> </tr> <tr> @@ -323,7 +323,7 @@ </tr> <tr> <td>mouseClick</td> - <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day-4</td> <td>8,12</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldResolutions.html b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldResolutions.html index 8ecf9a4731..d799c776d0 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldResolutions.html +++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldResolutions.html @@ -390,7 +390,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]</td> <td>129,26</td> </tr> <!--Check resolution month functionality--> @@ -481,7 +481,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[1]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[1]</td> <td>174,3</td> </tr> <tr> @@ -557,7 +557,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[1]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]</td> <td>193,12</td> </tr> <tr> @@ -797,7 +797,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[1]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]</td> <td>185,8</td> </tr> <tr> @@ -863,7 +863,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[7]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFields::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]</td> <td>286,10</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/image/ImageClicks.java b/uitest/src/com/vaadin/tests/components/image/ImageClicks.java index e50b8c3a4f..397e31c39c 100644 --- a/uitest/src/com/vaadin/tests/components/image/ImageClicks.java +++ b/uitest/src/com/vaadin/tests/components/image/ImageClicks.java @@ -7,7 +7,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Random; +import java.util.Date; import javax.imageio.ImageIO; @@ -20,8 +20,6 @@ import com.vaadin.ui.Label; public class ImageClicks extends TestBase { - private final Random rng = new Random(0); - private int clickCounter = 0; @Override @@ -30,7 +28,7 @@ public class ImageClicks extends TestBase { final Label label = new Label(labelText()); addComponent(label); - Image image = new Image(); + final Image image = new Image(); final MyImageSource imageSource = new MyImageSource(); final StreamResource imageResource = new StreamResource(imageSource, "testimage.png"); @@ -40,6 +38,9 @@ public class ImageClicks extends TestBase { @Override public void click(ClickEvent event) { ++clickCounter; + imageResource.setFilename("testimage.png?" + + new Date().getTime()); + image.markAsDirty(); label.setValue(labelText()); } @@ -58,7 +59,7 @@ public class ImageClicks extends TestBase { @Override protected String getDescription() { - return "Test click event handling of images"; + return "Each click on the dynamically generated image should update the image and add another black square"; } @Override @@ -110,11 +111,13 @@ public class ImageClicks extends TestBase { } // Cell - if (rng.nextFloat() < 0.5f) { - drawable.setColor(Color.white); - } else { + int cellIndex = col + row * cols; + if (clickCounter > cellIndex) { drawable.setColor(Color.black); + } else { + drawable.setColor(Color.white); } + drawable.fillRect(gridx + 1, gridy + 1, gridxnext - gridx - 1, gridynext - gridy - 1); } diff --git a/uitest/src/com/vaadin/tests/components/link/LinkToPercentage.html b/uitest/src/com/vaadin/tests/components/link/LinkToPercentage.html index 7dff317288..328b884478 100644 --- a/uitest/src/com/vaadin/tests/components/link/LinkToPercentage.html +++ b/uitest/src/com/vaadin/tests/components/link/LinkToPercentage.html @@ -19,9 +19,8 @@ <tr> <td>assertAttribute</td> <td>vaadin=runcomvaadintestscomponentslinkLinkToPercentage::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLink[0]/domChild[0]@href</td> - <td>*/run/com.vaadin.tests.components.link.LinkToPercentage/APP/1/110%25+Vaadin</td> + <td>*/run/*APP/*/110%25+Vaadin</td> </tr> - </tbody></table> </body> </html> diff --git a/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html b/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html index 9a80ce6013..3c0a50d11d 100755 --- a/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html +++ b/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html @@ -37,7 +37,7 @@ <td></td> </tr> <tr> - <td>pauseAndWait</td> + <td>pause</td> <td>1000</td> <td></td> </tr> diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutSlotStyleNames.html b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutSlotStyleNames.html new file mode 100644 index 0000000000..adfc8fb7c7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutSlotStyleNames.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="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.orderedlayout.OrderedLayoutSlotStyleNames?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[0]</td> + <td>v-slot</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[0]</td> + <td>v-slot-my-label</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[0]</td> + <td>v-slot-my-second-label</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[1]</td> + <td>v-slot</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[1]</td> + <td>v-slot-my-button</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VVerticalLayout[0]/VOrderedLayout$Slot[1]</td> + <td>v-slot-my-second-button</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[0]</td> + <td>v-slot</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[0]</td> + <td>v-slot-my-label</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[0]</td> + <td>v-slot-my-second-label</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[1]</td> + <td>v-slot</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[1]</td> + <td>v-slot-my-button</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutSlotStyleNames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VHorizontalLayout[0]/VOrderedLayout$Slot[1]</td> + <td>v-slot-my-second-button</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutSlotStyleNames.java b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutSlotStyleNames.java new file mode 100644 index 0000000000..3bfc5bb5e0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/OrderedLayoutSlotStyleNames.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class OrderedLayoutSlotStyleNames extends TestBase { + + @Override + protected void setup() { + VerticalLayout vl = new VerticalLayout(); + + Label lbl = new Label("A label"); + lbl.setStyleName("my-label"); + lbl.addStyleName("my-second-label"); + vl.addComponent(lbl); + + Button btn = new Button("A Button"); + btn.setStyleName("my-button"); + btn.addStyleName("my-second-button"); + vl.addComponent(btn); + + addComponent(vl); + + + HorizontalLayout hl = new HorizontalLayout(); + + lbl = new Label("A label"); + lbl.setStyleName("my-label"); + lbl.addStyleName("my-second-label"); + hl.addComponent(lbl); + + btn = new Button("A Button"); + btn.setStyleName("my-button"); + btn.addStyleName("my-second-button"); + hl.addComponent(btn); + + addComponent(hl); + } + + @Override + protected String getDescription() { + return "Vertical/HorizontalLayout slots should get child dependant name"; + } + + @Override + protected Integer getTicketNumber() { + return 9051; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithManyColumns.java b/uitest/src/com/vaadin/tests/components/table/TableWithManyColumns.java index e0ae38a8b9..c73409838a 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableWithManyColumns.java +++ b/uitest/src/com/vaadin/tests/components/table/TableWithManyColumns.java @@ -20,7 +20,7 @@ public class TableWithManyColumns extends TestBase { for (int row = 0; row < ROWS; row++) { Item i = t.addItem(String.valueOf(row)); for (int col = 0; col < COLS; col++) { - Property<?> p = i.getItemProperty("COLUMN_" + col); + Property<String> p = i.getItemProperty("COLUMN_" + col); p.setValue("item " + row + "/" + col); } } diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java b/uitest/src/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java index 4184892545..6960fed2fe 100644 --- a/uitest/src/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java +++ b/uitest/src/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java @@ -34,15 +34,8 @@ public class TextFieldWithPropertyFormatter extends TestBase { } @Override - public void setValue(Object newValue) throws ReadOnlyException { - if (newValue == null) { - value = null; - } else if (newValue instanceof BigDecimal) { - value = (BigDecimal) newValue; - } else { - throw new IllegalArgumentException( - "Value must be of type BigDecimal"); - } + public void setValue(BigDecimal newValue) throws ReadOnlyException { + value = newValue; } @Override diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.html b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.html index d7e1544026..f2650ce1c2 100644 --- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.html +++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.html @@ -18,8 +18,8 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuilazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>NormalUI<br />pathInfo: /normalPath<br />parameters: [restartApplication]<br />uri fragment: normalFragment</td> + <td>vaadin=runcomvaadintestscomponentsuiLazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> + <td>NormalUI<br />pathInfo: /com.vaadin.tests.components.ui.LazyInitUIs/normalPath<br />parameters: [*restartApplication*]<br />uri fragment: normalFragment</td> </tr> <tr> <td>open</td> @@ -28,9 +28,10 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuilazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>LazyCreateUI<br />pathInfo: /lazyCreatePath<br />parameters: [lazyCreate]<br />uri fragment: lazyCreateFragment</td> + <td>vaadin=runcomvaadintestscomponentsuiLazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> + <td>LazyCreateUI<br />pathInfo: /com.vaadin.tests.components.ui.LazyInitUIs/lazyCreatePath<br />parameters: [*lazyCreate*]<br />uri fragment: lazyCreateFragment</td> </tr> +<!-- The last part does not really test anything as EagerInit is not working --> <tr> <td>open</td> <td>/run/com.vaadin.tests.components.ui.LazyInitUIs/eagerPath/?eagerInit#eagerFragment</td> @@ -39,7 +40,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsuiLazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>EagerInitUI<br />pathInfo: /eagerPath/<br />parameters: [eagerInit]<br />uri fragment: null</td> + <td>EagerInitUI<br />pathInfo: /com.vaadin.tests.components.ui.LazyInitUIs/eagerPath/<br />parameters: [*eagerInit*]<br />uri fragment: eagerFragment</td> </tr> </tbody></table> </body> diff --git a/uitest/src/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java b/uitest/src/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java index eba8ded705..b1e080fc16 100644 --- a/uitest/src/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java +++ b/uitest/src/com/vaadin/tests/containers/HierarchicalWrapperOrdering.java @@ -99,7 +99,7 @@ public class HierarchicalWrapperOrdering extends TestBase { // Get first item Object itemId = indexedContainer.getIdByIndex(0); Item item = indexedContainer.getItem(itemId); - Property<String> property = (Property<String>) item + Property<String> property = item .getItemProperty("name"); // Prepend with Z so item should get sorted later property.setValue("Z " + property.getValue()); diff --git a/uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java b/uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java new file mode 100644 index 0000000000..d69ebfab56 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java @@ -0,0 +1,107 @@ +/* + * Copyright 2012 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.extensions; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.server.BrowserPopupOpener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.components.popupview.ReopenPopupView; +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; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.NativeButton; + +public class BrowserPopupExtensionTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + List<Class<? extends Component>> components = new ArrayList<Class<? extends Component>>(); + components.add(Button.class); + components.add(NativeButton.class); + components.add(Link.class); + components.add(CssLayout.class); + components.add(Label.class); + addComponents(components, "http://vaadin.com/download/nightly/"); + + Button uiClassButton = new Button("Open UI class"); + new BrowserPopupOpener(ReopenPopupView.class).extend(uiClassButton); + addComponent(uiClassButton); + + Button uiWithPath = new Button("Open UI class with path"); + new BrowserPopupOpener(ReopenPopupView.class, "foobar") + .extend(uiWithPath); + addComponent(uiWithPath); + + Button withPopupFeaturesButton = new Button("Open with features"); + BrowserPopupOpener featuresPopup = new BrowserPopupOpener( + "http://vaadin.com/download/nightly/"); + featuresPopup.setFeatures("width=400,height=400"); + featuresPopup.extend(withPopupFeaturesButton); + addComponent(withPopupFeaturesButton); + } + + public void addComponents(List<Class<? extends Component>> components, + String URL) { + final HorizontalLayout hl = new HorizontalLayout(); + for (Class<? extends Component> cls : components) { + try { + AbstractComponent c = (AbstractComponent) cls.newInstance(); + c.setId(cls.getName()); + c.setCaption(cls.getName()); + c.setDescription(URL); + c.setWidth("100px"); + c.setHeight("100px"); + hl.addComponent(c); + + new BrowserPopupOpener(URL).extend(c); + + if (c instanceof Button) { + ((Button) c).addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + } + }); + } + } catch (Exception e) { + System.err.println("Could not instatiate " + cls.getName()); + } + } + addComponent(hl); + } + + @Override + protected String getTestDescription() { + return "Test for " + BrowserPopupOpener.class.getSimpleName() + + " features"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9513); + } + +} diff --git a/uitest/src/com/vaadin/tests/integration/LiferayThemeDemo.java b/uitest/src/com/vaadin/tests/integration/LiferayThemeDemo.java index df36ca4e58..5b0195f202 100644 --- a/uitest/src/com/vaadin/tests/integration/LiferayThemeDemo.java +++ b/uitest/src/com/vaadin/tests/integration/LiferayThemeDemo.java @@ -526,7 +526,7 @@ public class LiferayThemeDemo extends LegacyApplication { Slider s = new Slider(); s.setWidth("200px"); try { - s.setValue(50); + s.setValue(50.0); } catch (ValueOutOfBoundsException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -538,7 +538,7 @@ public class LiferayThemeDemo extends LegacyApplication { s.setOrientation(SliderOrientation.VERTICAL); s.setHeight("200px"); try { - s.setValue(50); + s.setValue(50.0); } catch (ValueOutOfBoundsException e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java index 0d5f187136..9ad7c46b90 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java @@ -514,7 +514,7 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { fields[0].setRequiredError("required error"); fields[1] = new TextField(); - fields[1].setValue("TEXTFIELD2"); + ((TextField) fields[1]).setValue("TEXTFIELD2"); fields[1] .setComponentError(new UserError("component error, user error")); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java index bd3f2b2543..5eb11aea0d 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java @@ -542,7 +542,7 @@ public class VerticalLayoutTests extends AbstractLayoutTests { fields[0].setRequiredError("required error"); fields[1] = new TextField(); - fields[1].setValue("TEXTFIELD2"); + ((TextField) fields[1]).setValue("TEXTFIELD2"); fields[1] .setComponentError(new UserError("component error, user error")); diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1245.java b/uitest/src/com/vaadin/tests/tickets/Ticket1245.java index eba9514241..4b7c5705ac 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket1245.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket1245.java @@ -80,9 +80,7 @@ class TreeExample extends CustomComponent { // get the created item final Item item = tree.getItem(id); // set our "caption" property - @SuppressWarnings("unchecked") - final Property<String> p = (Property<String>) item - .getItemProperty(CAPTION_PROPERTY); + final Property<String> p = item.getItemProperty(CAPTION_PROPERTY); p.setValue(caption); if (parent != null) { tree.setChildrenAllowed(parent, true); diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2998.java b/uitest/src/com/vaadin/tests/tickets/Ticket2998.java index ca1929cf1c..ab263e54ea 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2998.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2998.java @@ -165,7 +165,7 @@ public class Ticket2998 extends LegacyApplication { return getSecondaryTypesList(itemId); } - final Field<?> f = super.createField(container, itemId, propertyId, + final Field f = super.createField(container, itemId, propertyId, uiContext); if (f != null) { if (f instanceof TextField) { diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket677.java b/uitest/src/com/vaadin/tests/tickets/Ticket677.java index 588d16daec..1f72291c4a 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket677.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket677.java @@ -133,7 +133,7 @@ public class Ticket677 extends LegacyApplication { table.addContainerProperty("Text", String.class, null); for (int i = 0; i < 150; i++) { Item item = table.addItem("Item" + i); - Property<?> p = item.getItemProperty("Text"); + Property<String> p = item.getItemProperty("Text"); p.setValue(i % 5 == 0 ? "enabled" : "disabled"); } |