From 6fcd994f1af440fd276c23d2b0f7e9f3e7ec37e8 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 28 Feb 2011 11:17:41 +0000 Subject: Merged changes from 6.5 branch svn changeset:17493/svn branch:6.6 --- WebContent/VAADIN/themes/reindeer/table/table.css | 2 +- WebContent/VAADIN/themes/tests-tickets/styles.css | 1 + src/com/vaadin/event/LayoutEvents.java | 79 +++++++++- src/com/vaadin/event/ShortcutAction.java | 2 + .../vaadin/terminal/gwt/client/BrowserInfo.java | 9 ++ src/com/vaadin/terminal/gwt/client/EventId.java | 1 + src/com/vaadin/terminal/gwt/client/Util.java | 55 +++++++ .../gwt/client/ui/ShortcutActionHandler.java | 5 + .../terminal/gwt/client/ui/VAbsoluteLayout.java | 15 +- .../vaadin/terminal/gwt/client/ui/VCssLayout.java | 8 +- .../vaadin/terminal/gwt/client/ui/VGridLayout.java | 15 +- .../vaadin/terminal/gwt/client/ui/VMenuBar.java | 25 +-- .../terminal/gwt/client/ui/VNotification.java | 5 + .../terminal/gwt/client/ui/VOrderedLayout.java | 15 +- .../terminal/gwt/client/ui/VScrollTable.java | 3 +- .../vaadin/terminal/gwt/client/ui/VSplitPanel.java | 16 +- .../gwt/server/AbstractApplicationServlet.java | 52 ++++--- .../gwt/server/AbstractCommunicationManager.java | 19 ++- src/com/vaadin/ui/AbsoluteLayout.java | 59 +------ src/com/vaadin/ui/AbstractLayout.java | 49 ++++++ src/com/vaadin/ui/AbstractOrderedLayout.java | 47 +----- src/com/vaadin/ui/AbstractSplitPanel.java | 3 +- src/com/vaadin/ui/CssLayout.java | 49 +----- src/com/vaadin/ui/GridLayout.java | 47 +----- src/com/vaadin/ui/Table.java | 2 +- src/com/vaadin/ui/Upload.java | 9 +- tests/scripts/runo-demo.html | 5 + tests/src/com/vaadin/tests/Components.java | 15 +- tests/src/com/vaadin/tests/VaadinClasses.java | 2 +- .../components/datefield/DateFieldEmptyValid.html | 13 +- .../components/datefield/DateFieldEmptyValid.java | 14 +- .../datefield/InlineDateFieldValueChange.html | 64 ++++---- .../CloseErrorNotificationWithEscape.html | 47 ++++++ .../orderedlayout/LayoutClickListenerTest.html | 92 +++++++++++ .../orderedlayout/LayoutClickListenerTest.java | 97 ++++++++++++ .../HorizontalSplitPanelSplitterClick.html | 81 ++++++++++ .../VerticalSplitPanelSplitterClick.html | 81 ++++++++++ .../tests/components/table/EditableModeChange.java | 21 ++- .../table/ResizeColumnAfterScrolling.html | 57 +++++++ .../components/table/TableToggleVisibility.html | 116 ++++++++++++++ .../components/table/TableToggleVisibility.java | 169 +++++++++++++++++++++ .../tests/server/BrowserUserAgentParser.java | 22 +++ .../server/TestSimpleMultiPartInputStream.java | 138 +++++++++++++++++ .../component/table/TableColumnAlignments.java | 165 ++++++++++++++++++++ .../server/component/table/TableGenerator.java | 42 +++++ .../component/table/TableVisibleColumns.java | 75 +++++++++ tests/test.xml | 4 +- 47 files changed, 1594 insertions(+), 318 deletions(-) create mode 100644 tests/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html create mode 100644 tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html create mode 100644 tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java create mode 100644 tests/src/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelSplitterClick.html create mode 100644 tests/src/com/vaadin/tests/components/splitpanel/VerticalSplitPanelSplitterClick.html create mode 100644 tests/src/com/vaadin/tests/components/table/ResizeColumnAfterScrolling.html create mode 100644 tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html create mode 100644 tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java create mode 100644 tests/src/com/vaadin/tests/server/TestSimpleMultiPartInputStream.java create mode 100644 tests/src/com/vaadin/tests/server/component/table/TableColumnAlignments.java create mode 100644 tests/src/com/vaadin/tests/server/component/table/TableGenerator.java create mode 100644 tests/src/com/vaadin/tests/server/component/table/TableVisibleColumns.java diff --git a/WebContent/VAADIN/themes/reindeer/table/table.css b/WebContent/VAADIN/themes/reindeer/table/table.css index fa1359912f..6061f7ee03 100644 --- a/WebContent/VAADIN/themes/reindeer/table/table.css +++ b/WebContent/VAADIN/themes/reindeer/table/table.css @@ -173,9 +173,9 @@ -webkit-border-bottom-right-radius: 4px; height: 13px; padding: 4px 30px; + white-space: nowrap; color: #222; text-shadow: #fff 0 1px 0; - width: 100px; position: relative; top: 1px; -webkit-box-shadow: rgba(0,0,0,.5) 0 1px 2px; diff --git a/WebContent/VAADIN/themes/tests-tickets/styles.css b/WebContent/VAADIN/themes/tests-tickets/styles.css index 7654f4663f..e63a5767b3 100644 --- a/WebContent/VAADIN/themes/tests-tickets/styles.css +++ b/WebContent/VAADIN/themes/tests-tickets/styles.css @@ -329,6 +329,7 @@ } .styled-twincol-captions .v-select-twincol-caption-right { font-size: 30px; + line-height: normal; color: blue; } diff --git a/src/com/vaadin/event/LayoutEvents.java b/src/com/vaadin/event/LayoutEvents.java index e35d527347..5c7fc0db28 100644 --- a/src/com/vaadin/event/LayoutEvents.java +++ b/src/com/vaadin/event/LayoutEvents.java @@ -3,6 +3,7 @@ */ package com.vaadin.event; +import java.io.Serializable; import java.lang.reflect.Method; import com.vaadin.event.MouseEvents.ClickEvent; @@ -27,22 +28,94 @@ public interface LayoutEvents { public void layoutClick(LayoutClickEvent event); } + /** + * The interface for adding and removing LayoutClickEvent + * listeners. By implementing this interface a class explicitly announces + * that it will generate a LayoutClickEvent when a component + * inside it is clicked and a LayoutClickListener is + * registered. + *

+ * Note: The general Java convention is not to explicitly declare that a + * class generates events, but to directly define the + * addListener and removeListener methods. That + * way the caller of these methods has no real way of finding out if the + * class really will send the events, or if it just defines the methods to + * be able to implement an interface. + *

+ * + * @since 6.5.2 + * @see LayoutClickListener + * @see LayoutClickEvent + */ + public interface LayoutClickNotifier extends Serializable { + /** + * Add a click listener to the layout. The listener is called whenever + * the user clicks inside the layout. An event is also triggered when + * the click targets a component inside a nested layout or Panel, + * provided the targeted component does not prevent the click event from + * propagating. A caption is not considered part of a component. + * + * The child component that was clicked is included in the + * {@link LayoutClickEvent}. + * + * Use {@link #removeListener(LayoutClickListener)} to remove the + * listener. + * + * @param listener + * The listener to add + */ + public void addListener(LayoutClickListener listener); + + /** + * Removes an LayoutClickListener. + * + * @param listener + * LayoutClickListener to be removed + */ + public void removeListener(LayoutClickListener listener); + } + /** * An event fired when the layout has been clicked. The event contains * information about the target layout (component) and the child component * that was clicked. If no child component was found it is set to null. - * */ public static class LayoutClickEvent extends ClickEvent { - private Component childComponent; + private final Component clickedComponent; + private final Component childComponent; public LayoutClickEvent(Component source, - MouseEventDetails mouseEventDetails, Component childComponent) { + MouseEventDetails mouseEventDetails, + Component clickedComponent, Component childComponent) { super(source, mouseEventDetails); + this.clickedComponent = clickedComponent; this.childComponent = childComponent; } + /** + * Returns the component that was clicked, which is somewhere inside the + * parent layout on which the listener was registered. + * + * For the direct child component of the layout, see + * {@link #getChildComponent()}. + * + * @return clicked {@link Component}, null if none found + */ + public Component getClickedComponent() { + return clickedComponent; + } + + /** + * Returns the direct child component of the layout which contains the + * clicked component. + * + * For the clicked component inside that child component of the layout, + * see {@link #getClickedComponent()}. + * + * @return direct child {@link Component} of the layout which contains + * the clicked Component, null if none found + */ public Component getChildComponent() { return childComponent; } diff --git a/src/com/vaadin/event/ShortcutAction.java b/src/com/vaadin/event/ShortcutAction.java index cd426d2f72..c722d2e80e 100644 --- a/src/com/vaadin/event/ShortcutAction.java +++ b/src/com/vaadin/event/ShortcutAction.java @@ -367,5 +367,7 @@ public class ShortcutAction extends Action { public static final int CTRL = 17; public static final int ALT = 18; + + public static final int META = 91; } } diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index 1ac060c29f..5981c2cfed 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -169,6 +169,10 @@ public class BrowserInfo { return browserDetails.isIE(); } + public boolean isFirefox() { + return browserDetails.isFirefox(); + } + public boolean isSafari() { return browserDetails.isSafari(); } @@ -213,6 +217,11 @@ public class BrowserInfo { && browserDetails.getBrowserEngineVersion() == 1.9; } + public boolean isFF4() { + return browserDetails.isFirefox() + && browserDetails.getBrowserMajorVersion() == 4; + } + /** * Returns the Gecko version if the browser is Gecko based. The Gecko * version for Firefox 2 is 1.8 and 1.9 for Firefox 3. diff --git a/src/com/vaadin/terminal/gwt/client/EventId.java b/src/com/vaadin/terminal/gwt/client/EventId.java index c6b725a562..077564e846 100644 --- a/src/com/vaadin/terminal/gwt/client/EventId.java +++ b/src/com/vaadin/terminal/gwt/client/EventId.java @@ -3,4 +3,5 @@ package com.vaadin.terminal.gwt.client; public interface EventId { public static final String BLUR = "blur"; public static final String FOCUS = "focus"; + public static final String LAYOUT_CLICK = "layout_click"; } diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index 6095c35c85..2ee4ba8cbd 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -816,6 +816,11 @@ public class Util { * element is not part of any child component, null is * returned. * + * This method returns the immediate child of the parent that contains the + * element. See + * {@link #getPaintableForElement(ApplicationConnection, Container, Element)} + * for the deepest nested paintable of parent that contains the element. + * * @param client * A reference to ApplicationConnection * @param parent @@ -854,6 +859,56 @@ public class Util { return null; } + /** + * Locates the nested child component of parent which + * contains the element element. The child component is + * also returned if "element" is part of its caption. If + * element is not part of any child component, null is + * returned. + * + * This method returns the deepest nested Paintable. See + * {@link #getChildPaintableForElement(ApplicationConnection, Container, Element)} + * for the immediate child component of parent that contains the element. + * + * @param client + * A reference to ApplicationConnection + * @param parent + * The widget that contains element. + * @param element + * An element that is a sub element of the parent + * @return The Paintable which the element is a part of. Null if the element + * does not belong to a child. + */ + public static Paintable getPaintableForElement( + ApplicationConnection client, Container parent, Element element) { + Element rootElement = ((Widget) parent).getElement(); + while (element != null && element != rootElement) { + Paintable paintable = client.getPaintable(element); + if (paintable == null) { + String ownerPid = VCaption.getCaptionOwnerPid(element); + if (ownerPid != null) { + paintable = client.getPaintable(ownerPid); + } + } + + if (paintable != null) { + // check that inside the rootElement + while (element != null && element != rootElement) { + element = (Element) element.getParentElement(); + } + if (element != rootElement) { + return null; + } else { + return paintable; + } + } + + element = (Element) element.getParentElement(); + } + + return null; + } + /** * Will (attempt) to focus the given DOM Element. * diff --git a/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java b/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java index 77210caa63..01f7187aa1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java +++ b/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java @@ -224,6 +224,7 @@ class ShortcutKeyCombination { public static final int SHIFT = 16; public static final int CTRL = 17; public static final int ALT = 18; + public static final int META = 91; char keyCode = 0; private int modifiersMask; @@ -255,6 +256,10 @@ class ShortcutKeyCombination { modifiersMask = modifiersMask | KeyboardListener.MODIFIER_SHIFT; break; + case META: + modifiersMask = modifiersMask + | KeyboardListener.MODIFIER_META; + break; default: break; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java index 50e33c4c19..b0590ce5a0 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java @@ -24,6 +24,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.Container; +import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.UIDL; @@ -39,8 +40,6 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { /** Class name, prefix in styling */ public static final String CLASSNAME = "v-absolutelayout"; - public static final String CLICK_EVENT_IDENTIFIER = "click"; - private DivElement marginElement; protected final Element canvas = DOM.createDiv(); @@ -58,7 +57,7 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { private boolean rendering; private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( - this, CLICK_EVENT_IDENTIFIER) { + this, EventId.LAYOUT_CLICK) { @Override protected Paintable getChildComponent(Element element) { @@ -427,17 +426,17 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { } /** - * Returns the child component which contains "element". The child component - * is also returned if "element" is part of its caption. + * Returns the deepest nested child component which contains "element". The + * child component is also returned if "element" is part of its caption. * * @param element - * An element that is a sub element of the root element in this - * layout + * An element that is a nested sub element of the root element in + * this layout * @return The Paintable which the element is a part of. Null if the element * belongs to the layout and not to a child. */ private Paintable getComponent(Element element) { - return Util.getChildPaintableForElement(client, this, element); + return Util.getPaintableForElement(client, this, element); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java index e0a74735b7..213651ab89 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java @@ -21,6 +21,7 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.Container; +import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.StyleConstants; @@ -33,14 +34,13 @@ import com.vaadin.terminal.gwt.client.ValueMap; public class VCssLayout extends SimplePanel implements Paintable, Container { public static final String TAGNAME = "csslayout"; public static final String CLASSNAME = "v-" + TAGNAME; - public static final String CLICK_EVENT_IDENTIFIER = "click"; private FlowPane panel = new FlowPane(); private Element margin = DOM.createDiv(); private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( - this, CLICK_EVENT_IDENTIFIER) { + this, EventId.LAYOUT_CLICK) { @Override protected Paintable getChildComponent(Element element) { @@ -253,8 +253,8 @@ public class VCssLayout extends SimplePanel implements Paintable, Container { } private Paintable getComponent(Element element) { - return Util.getChildPaintableForElement(client, VCssLayout.this, - element); + return Util + .getPaintableForElement(client, VCssLayout.this, element); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java index e5e3efd7c8..1d26103ae2 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java @@ -23,6 +23,7 @@ import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Container; +import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.RenderSpace; import com.vaadin.terminal.gwt.client.StyleConstants; @@ -35,8 +36,6 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { public static final String CLASSNAME = "v-gridlayout"; - public static final String CLICK_EVENT_IDENTIFIER = "click"; - private DivElement margin = Document.get().createDivElement(); private final AbsolutePanel canvas = new AbsolutePanel(); @@ -72,7 +71,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { private boolean sizeChangedDuringRendering = false; private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( - this, CLICK_EVENT_IDENTIFIER) { + this, EventId.LAYOUT_CLICK) { @Override protected Paintable getChildComponent(Element element) { @@ -1111,17 +1110,17 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { } /** - * Returns the child component which contains "element". The child component - * is also returned if "element" is part of its caption. + * Returns the deepest nested child component which contains "element". The + * child component is also returned if "element" is part of its caption. * * @param element - * An element that is a sub element of the root element in this - * layout + * An element that is a nested sub element of the root element in + * this layout * @return The Paintable which the element is a part of. Null if the element * belongs to the layout and not to a child. */ private Paintable getComponent(Element element) { - return Util.getChildPaintableForElement(client, this, element); + return Util.getPaintableForElement(client, this, element); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 60610556c9..2b996d5792 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -77,8 +77,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, private String width = "notinited"; - private VLazyExecutor iconLoadedExecutioner = new VLazyExecutor( - 100, new ScheduledCommand() { + private VLazyExecutor iconLoadedExecutioner = new VLazyExecutor(100, + new ScheduledCommand() { public void execute() { iLayout(true); @@ -578,13 +578,6 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, * @param item */ public void showChildMenu(CustomMenuItem item) { - final int shadowSpace = 10; - - popup = new VOverlay(true, false, true); - popup.setStyleName(CLASSNAME + "-popup"); - popup.setWidget(item.getSubMenu()); - popup.addCloseHandler(this); - popup.addAutoHidePartner(item.getElement()); int left = 0; int top = 0; @@ -597,6 +590,18 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, top = item.getParentMenu().getAbsoluteTop() + item.getParentMenu().getOffsetHeight(); } + showChildMenuAt(item, top, left); + } + + protected void showChildMenuAt(CustomMenuItem item, int top, int left) { + final int shadowSpace = 10; + + popup = new VOverlay(true, false, true); + popup.setStyleName(CLASSNAME + "-popup"); + popup.setWidget(item.getSubMenu()); + popup.addCloseHandler(this); + popup.addAutoHidePartner(item.getElement()); + popup.setPopupPosition(left, top); item.getSubMenu().onShow(); @@ -758,7 +763,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, * A class to hold information on menu items * */ - private class CustomMenuItem extends Widget implements HasHTML { + protected static class CustomMenuItem extends Widget implements HasHTML { private ApplicationConnection client; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java index 7e7ccf1791..bc0b0367bd 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNotification.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNotification.java @@ -9,6 +9,7 @@ import java.util.Date; import java.util.EventObject; import java.util.Iterator; +import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -255,6 +256,10 @@ public class VNotification extends VOverlay { fade(); return false; } + } else if (type == Event.ONKEYDOWN + && event.getKeyCode() == KeyCodes.KEY_ESCAPE) { + fade(); + return false; } if (temporaryStyle == STYLE_SYSTEM) { return true; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java index bf64219a7b..fe8f6ab6b3 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOrderedLayout.java @@ -16,6 +16,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; +import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; import com.vaadin.terminal.gwt.client.RenderInformation.Size; @@ -30,8 +31,6 @@ public class VOrderedLayout extends CellBasedLayout { public static final String CLASSNAME = "v-orderedlayout"; - public static final String CLICK_EVENT_IDENTIFIER = "click"; - private int orientation; // Can be removed once OrderedLayout is removed @@ -57,7 +56,7 @@ public class VOrderedLayout extends CellBasedLayout { private ValueMap alignments; private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler( - this, CLICK_EVENT_IDENTIFIER) { + this, EventId.LAYOUT_CLICK) { @Override protected Paintable getChildComponent(Element element) { @@ -954,17 +953,17 @@ public class VOrderedLayout extends CellBasedLayout { } /** - * Returns the child component which contains "element". The child component - * is also returned if "element" is part of its caption. + * Returns the deepest nested child component which contains "element". The + * child component is also returned if "element" is part of its caption. * * @param element - * An element that is a sub element of the root element in this - * layout + * An element that is a nested sub element of the root element in + * this layout * @return The Paintable which the element is a part of. Null if the element * belongs to the layout and not to a child. */ private Paintable getComponent(Element element) { - return Util.getChildPaintableForElement(client, this, element); + return Util.getPaintableForElement(client, this, element); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 1cdd9c16e1..00a711c389 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -2224,6 +2224,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, RowHeadersHeaderCell() { super("0", ""); + this.setStyleName(CLASSNAME + "-header-cell-rowheader"); } @Override @@ -3798,7 +3799,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, if (showRowHeaders) { boolean sorted = tHead.getHeaderCell(col).isSorted(); addCell(uidl, buildCaptionHtmlSnippet(uidl), aligns[col++], - "", true, sorted); + "rowheader", true, sorted); visibleColumnIndex++; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index 422f48b2a7..33b97d16cf 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -536,16 +536,16 @@ public class VSplitPanel extends ComplexPanel implements Container, } } + if (origX != newX) { + resized = true; + } + // Reversed position if (positionReversed) { newX = getOffsetWidth() - newX - getSplitterSize(); } setSplitPosition(newX + "px"); - - if (origX != newX) { - resized = true; - } } private void onVerticalMouseMove(int y) { @@ -579,16 +579,16 @@ public class VSplitPanel extends ComplexPanel implements Container, } } + if (origY != newY) { + resized = true; + } + // Reversed position if (positionReversed) { newY = getOffsetHeight() - newY - getSplitterSize(); } setSplitPosition(newY + "px"); - - if (origY != newY) { - resized = true; - } } public void onMouseUp(Event event) { diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index bf3ba8f759..5f06285b1f 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -1564,14 +1564,14 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * If one needs to override parts of the host page, it is suggested that one * overrides on of several submethods which are called by this method: * * @@ -1622,9 +1622,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements if (!fragment) { setAjaxPageHeaders(response); - writeAjaxPageHtmlHeadStart(page); - writeAjaxPageHtmlHeader(page, title, themeUri); - writeAjaxPageHtmlBodyStart(page); + writeAjaxPageHtmlHeadStart(page, request); + writeAjaxPageHtmlHeader(page, title, themeUri, request); + writeAjaxPageHtmlBodyStart(page, request); } String appId = appUrl; @@ -1669,7 +1669,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements + "\""; } - writeAjaxPageHtmlMainDiv(page, appId, classNames, divStyle); + writeAjaxPageHtmlMainDiv(page, appId, classNames, divStyle, request); if (!fragment) { page.write("\n\n"); @@ -1737,10 +1737,11 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * @param appId * @param classNames * @param divStyle + * @param request * @throws IOException */ protected void writeAjaxPageHtmlMainDiv(final BufferedWriter page, - String appId, String classNames, String divStyle) + String appId, String classNames, String divStyle, HttpServletRequest request) throws IOException { page.write("
\n"); @@ -1913,10 +1914,11 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * Override this method if you want to add some custom html to the page. * * @param page + * @param request * @throws IOException */ - protected void writeAjaxPageHtmlBodyStart(final BufferedWriter page) - throws IOException { + protected void writeAjaxPageHtmlBodyStart(final BufferedWriter page, + final HttpServletRequest request) throws IOException { page.write("\n\n\n"); } @@ -1930,15 +1932,26 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * @param page * @param title * @param themeUri + * @param request * @throws IOException */ protected void writeAjaxPageHtmlHeader(final BufferedWriter page, - String title, String themeUri) throws IOException { + String title, String themeUri, final HttpServletRequest request) + throws IOException { page.write("\n"); - // Force IE9 into IE8 mode. Remove when IE 9 mode works (#5546), chrome - // frame if available #5261 - page.write("\n"); + WebBrowser browser = getApplicationContext(request.getSession()) + .getBrowser(); + if (browser.isIE()) { + // Chrome frame in all versions of IE (only if Chrome frame is + // installed) + if (browser.getBrowserMajorVersion() == 9) { + // Force IE9 into IE8 mode. Remove when IE 9 mode works (#5546) + page.write("\n"); + } else { + page.write("\n"); + } + } page.write(""); @@ -1962,10 +1975,11 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * beginning of the page. * * @param page + * @param request * @throws IOException */ - protected void writeAjaxPageHtmlHeadStart(final BufferedWriter page) - throws IOException { + protected void writeAjaxPageHtmlHeadStart(final BufferedWriter page, + final HttpServletRequest request) throws IOException { // write html header page.write(" components = new LinkedHashSet(); @@ -560,62 +562,11 @@ public class AbsoluteLayout extends AbstractLayout { } } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, - * java.util.Map) - */ - @SuppressWarnings("unchecked") - @Override - public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map) variables.get(CLICK_EVENT)); - } - - } - - /** - * Fires a click event when the layout is clicked - * - * @param parameters - * The parameters recieved from the client side implementation - */ - private void fireClick(Map parameters) { - MouseEventDetails mouseDetails = MouseEventDetails - .deSerialize((String) parameters.get("mouseDetails")); - Component childComponent = (Component) parameters.get("component"); - - fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent)); - } - - /** - * Add a click listener to the layout. The listener is called whenever the - * user clicks inside the layout. Also when the click targets a component - * inside the Panel, provided the targeted component does not prevent the - * click event from propagating. - * - * The child component that was clicked is included in the - * {@link LayoutClickEvent}. - * - * Use {@link #removeListener(LayoutClickListener)} to remove the listener. - * - * @param listener - * The listener to add - */ public void addListener(LayoutClickListener listener) { addListener(CLICK_EVENT, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } - /** - * Remove a click listener from the layout. The listener should earlier have - * been added using {@link #addListener(LayoutClickListener)}. - * - * @param listener - * The listener to remove - */ public void removeListener(LayoutClickListener listener) { removeListener(CLICK_EVENT, LayoutClickEvent.class, listener); } diff --git a/src/com/vaadin/ui/AbstractLayout.java b/src/com/vaadin/ui/AbstractLayout.java index 5cb698e688..d0cc549138 100644 --- a/src/com/vaadin/ui/AbstractLayout.java +++ b/src/com/vaadin/ui/AbstractLayout.java @@ -4,8 +4,14 @@ package com.vaadin.ui; +import java.util.Map; + +import com.vaadin.event.LayoutEvents.LayoutClickEvent; +import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.gwt.client.EventId; +import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.ui.Layout.MarginHandler; /** @@ -21,6 +27,8 @@ import com.vaadin.ui.Layout.MarginHandler; public abstract class AbstractLayout extends AbstractComponentContainer implements Layout, MarginHandler { + private static final String CLICK_EVENT = EventId.LAYOUT_CLICK; + protected MarginInfo margins = new MarginInfo(false); /* @@ -77,4 +85,45 @@ public abstract class AbstractLayout extends AbstractComponentContainer } + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, + * java.util.Map) + */ + @SuppressWarnings("unchecked") + @Override + public void changeVariables(Object source, Map variables) { + super.changeVariables(source, variables); + // not all subclasses use these events + if (this instanceof LayoutClickNotifier + && variables.containsKey(CLICK_EVENT)) { + fireClick((Map) variables.get(CLICK_EVENT)); + } + + } + + /** + * Fire a layout click event. + * + * Note that this method is only used by the subclasses that implement + * {@link LayoutClickNotifier}, and can be overridden for custom click event + * firing. + * + * @param parameters + * The parameters received from the client side implementation + */ + protected void fireClick(Map parameters) { + MouseEventDetails mouseDetails = MouseEventDetails + .deSerialize((String) parameters.get("mouseDetails")); + Component clickedComponent = (Component) parameters.get("component"); + Component childComponent = clickedComponent; + while (childComponent != null && childComponent.getParent() != this) { + childComponent = childComponent.getParent(); + } + + fireEvent(new LayoutClickEvent(this, mouseDetails, clickedComponent, + childComponent)); + } + } diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java index 7bd52f8feb..8dfbe07b18 100644 --- a/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -11,17 +11,17 @@ import java.util.Map; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Sizeable; -import com.vaadin.terminal.gwt.client.MouseEventDetails; -import com.vaadin.terminal.gwt.client.ui.VOrderedLayout; +import com.vaadin.terminal.gwt.client.EventId; @SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements - Layout.AlignmentHandler, Layout.SpacingHandler { + Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier { - private static final String CLICK_EVENT = VOrderedLayout.CLICK_EVENT_IDENTIFIER; + private static final String CLICK_EVENT = EventId.LAYOUT_CLICK; private static final Alignment ALIGNMENT_DEFAULT = Alignment.TOP_LEFT; @@ -350,50 +350,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements AlignmentUtils.setComponentAlignment(this, component, alignment); } - @SuppressWarnings("unchecked") - @Override - public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map) variables.get(CLICK_EVENT)); - } - - } - - private void fireClick(Map parameters) { - MouseEventDetails mouseDetails = MouseEventDetails - .deSerialize((String) parameters.get("mouseDetails")); - Component childComponent = (Component) parameters.get("component"); - - fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent)); - } - - /** - * Add a click listener to the layout. The listener is called whenever the - * user clicks inside the layout. Also when the click targets a component - * inside the Panel, provided the targeted component does not prevent the - * click event from propagating. - * - * The child component that was clicked is included in the - * {@link LayoutClickEvent}. - * - * Use {@link #removeListener(LayoutClickListener)} to remove the listener. - * - * @param listener - * The listener to add - */ public void addListener(LayoutClickListener listener) { addListener(CLICK_EVENT, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } - /** - * Remove a click listener from the layout. The listener should earlier have - * been added using {@link #addListener(LayoutClickListener)}. - * - * @param listener - * The listener to remove - */ public void removeListener(LayoutClickListener listener) { removeListener(CLICK_EVENT, LayoutClickEvent.class, listener); } diff --git a/src/com/vaadin/ui/AbstractSplitPanel.java b/src/com/vaadin/ui/AbstractSplitPanel.java index f81e62aab0..9be8564432 100644 --- a/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/src/com/vaadin/ui/AbstractSplitPanel.java @@ -387,7 +387,8 @@ public abstract class AbstractSplitPanel extends AbstractLayout { } - private void fireClick(Map parameters) { + @Override + protected void fireClick(Map parameters) { MouseEventDetails mouseDetails = MouseEventDetails .deSerialize((String) parameters.get("mouseDetails")); diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java index db5bae678b..5789a65ed3 100644 --- a/src/com/vaadin/ui/CssLayout.java +++ b/src/com/vaadin/ui/CssLayout.java @@ -6,14 +6,14 @@ package com.vaadin.ui; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; -import java.util.Map; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Paintable; -import com.vaadin.terminal.gwt.client.MouseEventDetails; +import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.ui.VCssLayout; /** @@ -58,9 +58,9 @@ import com.vaadin.terminal.gwt.client.ui.VCssLayout; * */ @ClientWidget(VCssLayout.class) -public class CssLayout extends AbstractLayout { +public class CssLayout extends AbstractLayout implements LayoutClickNotifier { - private static final String CLICK_EVENT = VCssLayout.CLICK_EVENT_IDENTIFIER; + private static final String CLICK_EVENT = EventId.LAYOUT_CLICK; /** * Custom layout slots containing the components. @@ -250,52 +250,11 @@ public class CssLayout extends AbstractLayout { } } - @SuppressWarnings("unchecked") - @Override - public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map) variables.get(CLICK_EVENT)); - } - - } - - private void fireClick(Map parameters) { - MouseEventDetails mouseDetails = MouseEventDetails - .deSerialize((String) parameters.get("mouseDetails")); - Component childComponent = (Component) parameters.get("component"); - - fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent)); - } - - /** - * Add a click listener to the layout. The listener is called whenever the - * user clicks inside the layout. Also when the click targets a component - * inside the Panel, provided the targeted component does not prevent the - * click event from propagating. A caption is not considered part of a - * component. - * - * The child component that was clicked is included in the - * {@link LayoutClickEvent}. - * - * Use {@link #removeListener(LayoutClickListener)} to remove the listener. - * - * @param listener - * The listener to add - */ public void addListener(LayoutClickListener listener) { addListener(CLICK_EVENT, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } - /** - * Remove a click listener from the layout. The listener should earlier have - * been added using {@link #addListener(LayoutClickListener)}. - * - * @param listener - * The listener to remove - */ public void removeListener(LayoutClickListener listener) { removeListener(CLICK_EVENT, LayoutClickEvent.class, listener); } diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java index fc16daa7c7..40b0ca9a6c 100644 --- a/src/com/vaadin/ui/GridLayout.java +++ b/src/com/vaadin/ui/GridLayout.java @@ -14,9 +14,10 @@ import java.util.Map.Entry; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.gwt.client.MouseEventDetails; +import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.terminal.gwt.client.ui.VGridLayout; /** @@ -42,9 +43,9 @@ import com.vaadin.terminal.gwt.client.ui.VGridLayout; @SuppressWarnings("serial") @ClientWidget(VGridLayout.class) public class GridLayout extends AbstractLayout implements - Layout.AlignmentHandler, Layout.SpacingHandler { + Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier { - private static final String CLICK_EVENT = VGridLayout.CLICK_EVENT_IDENTIFIER; + private static final String CLICK_EVENT = EventId.LAYOUT_CLICK; /** * Initial grid columns. @@ -1378,51 +1379,11 @@ public class GridLayout extends AbstractLayout implements AlignmentUtils.setComponentAlignment(this, component, alignment); } - @SuppressWarnings("unchecked") - @Override - public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map) variables.get(CLICK_EVENT)); - } - - } - - private void fireClick(Map parameters) { - MouseEventDetails mouseDetails = MouseEventDetails - .deSerialize((String) parameters.get("mouseDetails")); - Component childComponent = (Component) parameters.get("component"); - - fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent)); - } - - /** - * Add a click listener to the layout. The listener is called whenever the - * user clicks inside the layout. Also when the click targets a component - * inside the Panel, provided the targeted component does not prevent the - * click event from propagating. - * - * The child component that was clicked is included in the - * {@link LayoutClickEvent}. - * - * Use {@link #removeListener(LayoutClickListener)} to remove the listener. - * - * @param listener - * The listener to add - */ public void addListener(LayoutClickListener listener) { addListener(CLICK_EVENT, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); } - /** - * Remove a click listener from the layout. The listener should earlier have - * been added using {@link #addListener(LayoutClickListener)}. - * - * @param listener - * The listener to remove - */ public void removeListener(LayoutClickListener listener) { removeListener(CLICK_EVENT, LayoutClickEvent.class, listener); } diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 7a114fb021..89f50f01ab 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -659,7 +659,7 @@ public class Table extends AbstractSelect implements Action.Container, int i = 0; for (final Iterator it = visibleColumns.iterator(); it .hasNext(); i++) { - alignments[i++] = getColumnAlignment(it.next()); + alignments[i] = getColumnAlignment(it.next()); } return alignments; diff --git a/src/com/vaadin/ui/Upload.java b/src/com/vaadin/ui/Upload.java index 9023e8ed75..053e1897fc 100644 --- a/src/com/vaadin/ui/Upload.java +++ b/src/com/vaadin/ui/Upload.java @@ -218,7 +218,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { } /** - * Upload.Received event is sent when the upload receives a file, regardless + * Upload.FinishedEvent is sent when the upload receives a file, regardless * of whether the reception was successful or failed. If you wish to * distinguish between the two cases, use either SucceededEvent or * FailedEvent, which are both subclasses of the FinishedEvent. @@ -303,7 +303,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { } /** - * Upload.Interrupted event is sent when the upload is received, but the + * Upload.FailedEvent event is sent when the upload is received, but the * reception is interrupted for some reason. * * @author IT Mill Ltd. @@ -391,7 +391,8 @@ public class Upload extends AbstractComponent implements Component.Focusable { } /** - * Upload.Success event is sent when the upload is received successfully. + * Upload.SucceededEvent event is sent when the upload is received + * successfully. * * @author IT Mill Ltd. * @version @@ -415,7 +416,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { } /** - * Upload.Started event is sent when the upload is started to received. + * Upload.StartedEvent event is sent when the upload is started to received. * * @author IT Mill Ltd. * @version diff --git a/tests/scripts/runo-demo.html b/tests/scripts/runo-demo.html index f10f3fb316..c509cfd159 100644 --- a/tests/scripts/runo-demo.html +++ b/tests/scripts/runo-demo.html @@ -26,6 +26,11 @@ vaadin=RunoTheme::/VVerticalLayout[0]/ChildComponentContainer[3]/VSplitPanelHorizontal[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0] + + pause + 2000 + + screenCapture diff --git a/tests/src/com/vaadin/tests/Components.java b/tests/src/com/vaadin/tests/Components.java index 7449f01a21..6987c04a54 100644 --- a/tests/src/com/vaadin/tests/Components.java +++ b/tests/src/com/vaadin/tests/Components.java @@ -138,7 +138,7 @@ public class Components extends Application { naviTree.setItemStyleGenerator(new ItemStyleGenerator() { public String getStyle(Object itemId) { - Class> cls = (Class>) itemId; + Class cls = (Class) itemId; if (!isAbstract(cls)) { return "blue"; } @@ -148,12 +148,13 @@ public class Components extends Application { HierarchicalContainer hc = new HierarchicalContainer(); naviTree.setContainerDataSource(hc); DefaultItemSorter sorter = new DefaultItemSorter() { + @SuppressWarnings("rawtypes") @Override public int compare(Object o1, Object o2) { if (o1 instanceof Class && o2 instanceof Class && o1 != null && o2 != null) { - Class c1 = (Class) o1; - Class c2 = (Class) o2; + Class c1 = (Class) o1; + Class c2 = (Class) o2; boolean a1 = isAbstract(c1); boolean a2 = isAbstract(c2); @@ -182,8 +183,7 @@ public class Components extends Application { naviTree.addListener(new ItemClickListener() { public void itemClick(ItemClickEvent event) { - Class> cls = (Class>) event - .getItemId(); + Class cls = (Class) event.getItemId(); if (!isAbstract(cls)) { String url = baseUrl + cls.getName() + "?restartApplication"; @@ -221,10 +221,11 @@ public class Components extends Application { } - protected boolean isAbstract(Class> cls) { + protected boolean isAbstract(Class cls) { return Modifier.isAbstract(cls.getModifiers()); } + @SuppressWarnings("unchecked") private void addTreeItem(Class> cls) { String name = tests.get(cls); if (name == null) { @@ -250,7 +251,7 @@ public class Components extends Application { protected Component createTestComponent( Class> cls) { try { - AbstractComponentTest t = cls.newInstance(); + AbstractComponentTest t = cls.newInstance(); t.init(); ComponentContainer c = t.getMainWindow().getContent(); t.getMainWindow().setContent(null); diff --git a/tests/src/com/vaadin/tests/VaadinClasses.java b/tests/src/com/vaadin/tests/VaadinClasses.java index 9313fb9880..3508f84059 100644 --- a/tests/src/com/vaadin/tests/VaadinClasses.java +++ b/tests/src/com/vaadin/tests/VaadinClasses.java @@ -68,7 +68,7 @@ public class VaadinClasses { return classes; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public static List>> getBasicComponentTests() { try { return (List) findClasses(AbstractComponentTest.class, diff --git a/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.html b/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.html index 7acd33234e..751c7ba9bd 100644 --- a/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.html +++ b/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.html @@ -24,7 +24,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1 - 1. DateField value is now 1973-03-03 + 1. DateField value is now March 3, 1973 11:46:40 AM assertValue @@ -74,7 +74,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1 - 4. DateField value is now Thu Mar 15 11:46:40 GMT+02:00 1973 + 4. DateField value is now March 15, 1973 11:46:40 AM assertValue @@ -185,7 +185,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1 - 21. DateField value is now 1990-05-04 + 21. DateField value is now May 4, 1990 12:00:00 AM assertValue @@ -205,7 +205,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1 - 25. DateField value is now 2000-06-05 + 25. DateField value is now June 5, 2000 12:00:00 AM click @@ -230,7 +230,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1 - 33. DateField value is now 2000-06-05 + 33. DateField value is now June 5, 2000 12:00:00 AM click @@ -240,14 +240,13 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1 - 40. DateField value is now 2005-08-27 + 40. DateField value is now August 27, 2005 12:00:00 AM assertText vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_0 41. isEmpty: false, isValid: true - diff --git a/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java b/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java index 736fdc87a6..7bcfeab324 100644 --- a/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java +++ b/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.datefield; -import java.sql.Date; +import java.text.DateFormat; +import java.util.Date; import java.util.Locale; import com.vaadin.data.Property.ValueChangeEvent; @@ -22,6 +23,9 @@ public class DateFieldEmptyValid extends TestBase { private MyDateField df; + private DateFormat formatter = DateFormat.getDateTimeInstance( + DateFormat.LONG, DateFormat.MEDIUM, new Locale("en", "US")); + public class MyDateField extends PopupDateField { @Override public boolean isEmpty() { @@ -115,7 +119,13 @@ public class DateFieldEmptyValid extends TestBase { } private void checkEmpty() { - log.log("DateField value is now " + df.getValue()); + Object value = df.getValue(); + if (value instanceof Date) { + value = formatter.format(df.getValue()); + } + + log.log("DateField value is now " + value); + // log.log("DateField value is now " + df.getValue()); log.log("isEmpty: " + df.isEmpty() + ", isValid: " + df.isValid()); } diff --git a/tests/src/com/vaadin/tests/components/datefield/InlineDateFieldValueChange.html b/tests/src/com/vaadin/tests/components/datefield/InlineDateFieldValueChange.html index 6464750e72..e5b3bc0835 100644 --- a/tests/src/com/vaadin/tests/components/datefield/InlineDateFieldValueChange.html +++ b/tests/src/com/vaadin/tests/components/datefield/InlineDateFieldValueChange.html @@ -16,27 +16,6 @@ /run/com.vaadin.tests.components.datefield.InlineDateFieldTest?restartApplication - - - mouseClick - vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_Smenu#item0 - 36,14 - - - mouseClick - vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::Root/VOverlay[0]/VMenuBar[0]#item0 - 37,10 - - - mouseClick - vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::Root/VOverlay[1]/VMenuBar[0]#item5 - 45,5 - - - mouseClick - vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::Root/VOverlay[2]/VMenuBar[0]#item1 - 34,10 - mouseClick @@ -104,7 +83,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 - 4. ValueChangeEvent, new value: Dec 14, 2010 12:00:00.000 + 3. ValueChangeEvent, new value: Dec 14, 2010 12:00:00.000 mouseClick @@ -114,7 +93,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 - 5. ValueChangeEvent, new value: Dec 13, 2010 12:00:00.000 + 4. ValueChangeEvent, new value: Dec 13, 2010 12:00:00.000 mouseClick @@ -134,7 +113,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 - 6. ValueChangeEvent, new value: Dec 14, 2009 12:00:00.000 + 5. ValueChangeEvent, new value: Dec 14, 2009 12:00:00.000 mouseClick @@ -149,7 +128,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 - 7. ValueChangeEvent, new value: Jan 12, 2010 12:00:00.000 + 6. ValueChangeEvent, new value: Jan 12, 2010 12:00:00.000 @@ -178,6 +157,7 @@ vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0] DATE(MMMM YYYY) + mouseClick vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_Smenu#item1 @@ -197,7 +177,7 @@ assertText vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 - 10. InlineDateField value: null + 9. InlineDateField value: null assertCSSClass @@ -210,21 +190,41 @@ vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day1 11,10 + + assertCSSClass + vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day1 + v-datefield-calendarpanel-day-selected + assertCSSClass vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#dayDATE(D) today - + + assertText + vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 + 10. ValueChangeEvent, new value: DATE(MMM) 1, DATE(YYYY) * + + mouseClick - vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day1 - 11,10 - - + vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day2 + 0,0 + + + assertCSSClass + vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#dayDATE(D) + today + + + assertCSSClass + vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day2 + v-datefield-calendarpanel-day-selected + + assertText vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0 - 11. ValueChangeEvent, new value: * 1, DATE(YYYY) * + 11. ValueChangeEvent, new value: DATE(MMM) 2, DATE(YYYY) * diff --git a/tests/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html b/tests/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html new file mode 100644 index 0000000000..288fd65c66 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html @@ -0,0 +1,47 @@ + + + + + + +CloseErrorNotificationWithEscape + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CloseErrorNotificationWithEscape
open/run/com.vaadin.tests.components.notification.Notifications?restartApplication
selectvaadin=runcomvaadintestscomponentsnotificationNotifications::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VNativeSelect[0]/domChild[0]label=Error
clickvaadin=runcomvaadintestscomponentsnotificationNotifications::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]Hello world
keyDownvaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]\\27
waitForElementNotPresentvaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]
+ + diff --git a/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html b/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html new file mode 100644 index 0000000000..6b850fb52a --- /dev/null +++ b/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.html @@ -0,0 +1,92 @@ + + + + + + +LayoutClickListenerTest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LayoutClickListenerTest
open/run/com.vaadin.tests.components.orderedlayout.LayoutClickListenerTest?restartApplication
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VLink[0]/domChild[0]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VLink[0]/domChild[0]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/domChild[0]/domChild[1]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[2]/VLink[0]/domChild[0]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[3]/VHorizontalLayout[0]/ChildComponentContainer[0]/VLabel[0]
mouseClickvaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/domChild[0]/domChild[0]
screenCaptureeverything_clicked
+ + diff --git a/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java b/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java new file mode 100644 index 0000000000..4f4faf15bb --- /dev/null +++ b/tests/src/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java @@ -0,0 +1,97 @@ +package com.vaadin.tests.components.orderedlayout; + +import java.util.Arrays; + +import com.vaadin.event.LayoutEvents.LayoutClickEvent; +import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Component; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.Select; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class LayoutClickListenerTest extends TestBase { + + @Override + protected void setup() { + + // Create a grid layout with click events + final GridLayout layout = new GridLayout(3, 2); + layout.addStyleName("border"); + layout.setSpacing(true); + layout.setSizeFull(); + + // Add some components to the layout + layout.addComponent(new TextField(null, "Click here")); + layout.addComponent(new Link("Click here", null)); + + Select select = new Select(null, Arrays.asList("Click here")); + select.select("Click here"); + layout.addComponent(select); + + // Tab content + VerticalLayout l1 = new VerticalLayout(); + l1.setMargin(true); + l1.addComponent(new Label("This is a label.")); + l1.addComponent(new TextField(null, "Click here")); + l1.addComponent(new Link("Click here", null)); + + TabSheet t = new TabSheet(); + t.setHeight("200px"); + t.addTab(l1, "Tab", null); + layout.addComponent(t); + + VerticalLayout nestedLayout = new VerticalLayout(); + nestedLayout.addComponent(new Label("This is a label.")); + nestedLayout.addComponent(new TextField(null, "Click here")); + nestedLayout.addComponent(new Link("Click here", null)); + + HorizontalLayout nestedLayout2 = new HorizontalLayout(); + nestedLayout2.addComponent(new Label("Deeply nested label")); + nestedLayout.addComponent(nestedLayout2); + + layout.addComponent(nestedLayout); + + // Listen for layout click events + layout.addListener(new LayoutClickListener() { + public void layoutClick(LayoutClickEvent event) { + + // Get the deepest nested component which was clicked + Component clickedComponent = event.getClickedComponent(); + + if (clickedComponent == null) { + // Not over any child component + LayoutClickListenerTest.this.addComponent(new Label( + "The click was not over any component.")); + } else { + // Over a child component + String message = "The click was over a " + + clickedComponent.getClass().getCanonicalName() + + " in an immediate child component of type " + + event.getChildComponent().getClass() + .getCanonicalName(); + LayoutClickListenerTest.this + .addComponent(new Label(message)); + } + } + }); + + addComponent(layout); + } + + @Override + protected String getDescription() { + return "Layout click listeners should provide access to the deepest nested component clicked - click anywhere in the layout."; + } + + @Override + protected Integer getTicketNumber() { + return 6493; + } + +} diff --git a/tests/src/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelSplitterClick.html b/tests/src/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelSplitterClick.html new file mode 100644 index 0000000000..ad546fac7c --- /dev/null +++ b/tests/src/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelSplitterClick.html @@ -0,0 +1,81 @@ + + + + + + +HorizontalSplitPanelSplitterClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
HorizontalSplitPanelSplitterClick
open/run/com.vaadin.tests.components.splitpanel.HorizontalSplitPanels?restartApplication
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_Smenu#item09,9
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item4105,7
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item236,11
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]0,0
assertTextvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_SLog_row_01. SplitterClickEvent: left at -1,-1
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_Smenu#item051,5
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item673,7
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item050,8
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[2]/VMenuBar[0]#item792,10
mouseClickvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]0,0
assertTextvaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_SLog_row_03. SplitterClickEvent: left at -1,-1
+ + diff --git a/tests/src/com/vaadin/tests/components/splitpanel/VerticalSplitPanelSplitterClick.html b/tests/src/com/vaadin/tests/components/splitpanel/VerticalSplitPanelSplitterClick.html new file mode 100644 index 0000000000..f53a3f9cd1 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/splitpanel/VerticalSplitPanelSplitterClick.html @@ -0,0 +1,81 @@ + + + + + + +VerticalSplitPanelSplitterClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
VerticalSplitPanelSplitterClick
open/run/com.vaadin.tests.components.splitpanel.VerticalSplitPanels?restartApplication
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_Smenu#item09,9
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item4105,7
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item236,11
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]0,0
assertTextvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_SLog_row_01. SplitterClickEvent: left at -1,-1
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_Smenu#item051,5
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item673,7
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item050,8
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[2]/VMenuBar[0]#item792,10
mouseClickvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]0,0
assertTextvaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_SLog_row_03. SplitterClickEvent: left at -1,-1
+ + diff --git a/tests/src/com/vaadin/tests/components/table/EditableModeChange.java b/tests/src/com/vaadin/tests/components/table/EditableModeChange.java index f3cd53642d..f2163f6df3 100644 --- a/tests/src/com/vaadin/tests/components/table/EditableModeChange.java +++ b/tests/src/com/vaadin/tests/components/table/EditableModeChange.java @@ -1,7 +1,9 @@ package com.vaadin.tests.components.table; +import java.text.DateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import com.vaadin.data.Container; import com.vaadin.event.ItemClickEvent; @@ -32,12 +34,12 @@ public class EditableModeChange extends TestBase { Calendar cal = Calendar.getInstance(); cal.set(2010, 7, 12, 12, 7, 54); - Date date = cal.getTime(); for (String name : names) { items.addItem(name); items.getItem(name).getItemProperty("name").setValue(name); - items.getItem(name).getItemProperty("birthday").setValue(date); + items.getItem(name).getItemProperty("birthday") + .setValue(new FormattedDate(cal.getTime().getTime())); } items.addListener(new ItemClickEvent.ItemClickListener() { @@ -55,6 +57,21 @@ public class EditableModeChange extends TestBase { addComponent(items); } + private class FormattedDate extends Date { + + private DateFormat formatter = DateFormat.getDateTimeInstance( + DateFormat.MEDIUM, DateFormat.MEDIUM, new Locale("en", "US")); + + public FormattedDate(long time) { + super(time); + } + + @Override + public String toString() { + return formatter.format(this); + } + } + private class ItemFieldFactory extends DefaultFieldFactory { @Override public Field createField(Container container, Object itemId, diff --git a/tests/src/com/vaadin/tests/components/table/ResizeColumnAfterScrolling.html b/tests/src/com/vaadin/tests/components/table/ResizeColumnAfterScrolling.html new file mode 100644 index 0000000000..7e7536d63a --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/ResizeColumnAfterScrolling.html @@ -0,0 +1,57 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
dragvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]0,11
dropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]100,0
scrollLeftvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]101
pause300
dragvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]/domChild[0]0,11
dropvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]/domChild[0]-50,0
screenCaptureresized-after-scrolling
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html new file mode 100644 index 0000000000..e9c57203c0 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.html @@ -0,0 +1,116 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.TableToggleVisibility?restartApplication
screenCapturetrucks-trailers-drivers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturedrivers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]
screenCapturetrailers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]
screenCapturetrailers-drivers
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
screenCapturetrucks-trailers-drivers-2
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java new file mode 100644 index 0000000000..5c456ab230 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableToggleVisibility.java @@ -0,0 +1,169 @@ +package com.vaadin.tests.components.table; + +import java.text.DecimalFormat; + +import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class TableToggleVisibility extends AbstractTestCase { + + private static final int[] LENGTHS = new int[] { 20, 22, 10 }; + + @Override + public void init() { + + DecimalFormat format = new DecimalFormat("000"); + Table[] tables = new Table[3]; + Button[] buttons = new Button[3]; + + VerticalLayout leftComponent = new VerticalLayout(); + leftComponent.setMargin(true); + leftComponent.setSpacing(true); + + // Toolbar with buttons to hide or show lists + + HorizontalLayout toolBar = new HorizontalLayout(); + toolBar.setSpacing(true); + toolBar.setMargin(true); + + leftComponent.addComponent(toolBar); + leftComponent.setExpandRatio(toolBar, 0.0f); + + // List of trucks ----------------------- + + tables[0] = new Table("Trucks"); + tables[0].addContainerProperty("Brand", String.class, null); + tables[0].addContainerProperty("Model", String.class, null); + tables[0].addContainerProperty("License Plate", String.class, null); + + for (int i = 1; i < LENGTHS[0]; i++) { + tables[0].addItem( + new Object[] { "MAN", "XYZ", "1-ABC-" + format.format(i) }, + Integer.valueOf(i)); + } + tables[0].setPageLength(LENGTHS[0]); + + tables[0].setWidth("100%"); + tables[0].setHeight("100%"); + tables[0].setSelectable(true); + + leftComponent.addComponent(tables[0]); + leftComponent.setExpandRatio(tables[0], 1.0f); + + // List of trailers ---------------------- + + tables[1] = new Table("Trailers"); + tables[1].addContainerProperty("Type", String.class, null); + tables[1].addContainerProperty("License Plate", String.class, null); + for (int i = 1; i < LENGTHS[1]; i++) { + tables[1].addItem( + new Object[] { "Cooler", "1-QQQ-" + format.format(i) }, + Integer.valueOf(i)); + } + tables[1].setPageLength(LENGTHS[1]); + + tables[1].setWidth("100%"); + tables[1].setHeight("100%"); + tables[1].setSelectable(true); + + leftComponent.addComponent(tables[1]); + leftComponent.setExpandRatio(tables[1], 1.0f); + + // List of drivers ------------------------ + + tables[2] = new Table("Drivers"); + tables[2].addContainerProperty("First Name", String.class, null); + tables[2].addContainerProperty("Last Name", String.class, null); + tables[2].addContainerProperty("HR ID", String.class, null); + for (int i = 1; i < LENGTHS[2]; i++) { + tables[2].addItem( + new Object[] { "King", "Vabis", "HR-" + format.format(i) }, + Integer.valueOf(i)); + } + tables[2].setPageLength(LENGTHS[2]); + + tables[2].setWidth("100%"); + tables[2].setHeight("100%"); + tables[2].setSelectable(true); + + leftComponent.addComponent(tables[2]); + leftComponent.setExpandRatio(tables[2], 1.0f); + + leftComponent.setWidth("100%"); + + HorizontalSplitPanel split = new HorizontalSplitPanel(); + split.setFirstComponent(leftComponent); + + VerticalLayout rightComponent = new VerticalLayout(); + rightComponent.setMargin(true); + rightComponent.addComponent(new Label("Left blank!")); + split.setSecondComponent(rightComponent); + + split.setSizeFull(); + + VerticalLayout mainLayout = new VerticalLayout(); + mainLayout.setSizeFull(); + mainLayout.addComponent(split); + mainLayout.setExpandRatio(split, 1.0f); + + Window mainWindow = new Window("Visibilitybug Application", mainLayout); + mainWindow.setSizeFull(); + + setMainWindow(mainWindow); + + // complete toolbar + + for (int i = 0; i < buttons.length; i++) { + buttons[i] = new ToggleButton(tables[i]); + toolBar.addComponent(buttons[i]); + } + + } + + // Button to switch the visibility of a table. + + private static class ToggleButton extends Button { + + private Table table; + + private ToggleButton(Table table) { + this.table = table; + + setCaption("- " + table.getCaption()); + + addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + + boolean wasVisible = ToggleButton.this.table.isVisible(); + + ToggleButton.this.table.setVisible(!wasVisible); + setCaption((wasVisible ? "+ " : "- ") + + ToggleButton.this.table.getCaption()); + setDescription((wasVisible ? "Show " : "Hide ") + + "the list with " + + ToggleButton.this.table.getCaption()); + + } + }); + } + + } + + @Override + protected String getDescription() { + return "Test for hiding and showing tables. Click a button to show/hide one of the tables. The tables are all 100% wide and should be rendered the same way after being hidden and shown again."; + } + + @Override + protected Integer getTicketNumber() { + return 6494; + } + +} \ No newline at end of file diff --git a/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java b/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java index 2f3d663eaa..97d8143038 100644 --- a/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java +++ b/tests/src/com/vaadin/tests/server/BrowserUserAgentParser.java @@ -12,6 +12,8 @@ public class BrowserUserAgentParser extends TestCase { private static final String FIREFOX36_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)"; private static final String FIREFOX36B_MAC = "UAString mozilla/5.0 (macintosh; u; intel mac os x 10.6; en-us; rv:1.9.2) gecko/20100115 firefox/3.6"; private static final String FIREFOX_30B5_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5"; + private static final String FIREFOX_40B7_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7"; + private static final String FIREFOX_40B11_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b11) Gecko/20100101 Firefox/4.0b11"; private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)"; private static final String IE6_WINDOWS = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"; @@ -123,6 +125,26 @@ public class BrowserUserAgentParser extends TestCase { assertMacOSX(bd); } + public void testFirefox40b11() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B11_WIN); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 2.0f); + assertWindows(bd); + } + + public void testFirefox40b7() { + VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B7_WIN); + assertGecko(bd); + assertFirefox(bd); + assertBrowserMajorVersion(bd, 4); + assertBrowserMinorVersion(bd, 0); + assertEngineVersion(bd, 2.0f); + assertWindows(bd); + } + public void testKonquerorLinux() { // Just ensure detection does not crash VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX); diff --git a/tests/src/com/vaadin/tests/server/TestSimpleMultiPartInputStream.java b/tests/src/com/vaadin/tests/server/TestSimpleMultiPartInputStream.java new file mode 100644 index 0000000000..65455eba37 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/TestSimpleMultiPartInputStream.java @@ -0,0 +1,138 @@ +package com.vaadin.tests.server; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import junit.framework.TestCase; + +import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.SimpleMultiPartInputStream; + +public class TestSimpleMultiPartInputStream extends TestCase { + + /** + * Check that the output for a given stream until boundary is as expected. + * + * @param input + * @param boundary + * @param expected + * @throws Exception + */ + protected void checkBoundaryDetection(byte[] input, String boundary, + byte[] expected) throws Exception { + ByteArrayInputStream bais = new ByteArrayInputStream(input); + SimpleMultiPartInputStream smpis = new SimpleMultiPartInputStream(bais, + boundary); + ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); + int outbyte; + try { + while ((outbyte = smpis.read()) != -1) { + resultStream.write(outbyte); + } + } catch (IOException e) { + throw new IOException(e.getMessage() + "; expected " + + new String(expected) + " but got " + + resultStream.toString()); + } + if (!Arrays.equals(expected, resultStream.toByteArray())) { + throw new Exception("Mismatch: expected " + new String(expected) + + " but got " + resultStream.toString()); + } + } + + protected void checkBoundaryDetection(String input, String boundary, + String expected) throws Exception { + checkBoundaryDetection(input.getBytes(), boundary, expected.getBytes()); + } + + public void testSingleByteBoundaryAtEnd() throws Exception { + checkBoundaryDetection("xyz123" + getFullBoundary("a"), "a", "xyz123"); + } + + public void testSingleByteBoundaryInMiddle() throws Exception { + checkBoundaryDetection("xyz" + getFullBoundary("a") + "123", "a", "xyz"); + } + + public void testCorrectBoundaryAtEnd() throws Exception { + checkBoundaryDetection("xyz123" + getFullBoundary("abc"), "abc", + "xyz123"); + } + + public void testCorrectBoundaryNearEnd() throws Exception { + checkBoundaryDetection("xyz123" + getFullBoundary("abc") + "de", "abc", + "xyz123"); + } + + public void testCorrectBoundaryAtBeginning() throws Exception { + checkBoundaryDetection(getFullBoundary("abc") + "xyz123", "abc", ""); + } + + public void testRepeatingCharacterBoundary() throws Exception { + checkBoundaryDetection(getFullBoundary("aa") + "xyz123", "aa", ""); + checkBoundaryDetection("axyz" + getFullBoundary("aa") + "123", "aa", + "axyz"); + checkBoundaryDetection("xyz123" + getFullBoundary("aa"), "aa", "xyz123"); + } + + /** + * Note, the boundary in this test is invalid. Boundary strings don't + * contain CR/LF. + * + */ + // public void testRepeatingNewlineBoundary() throws Exception { + // checkBoundaryDetection("1234567890" + getFullBoundary("\n\n") + // + "1234567890", "\n\n", ""); + // } + + public void testRepeatingStringBoundary() throws Exception { + checkBoundaryDetection(getFullBoundary("abab") + "xyz123", "abab", ""); + checkBoundaryDetection("abaxyz" + getFullBoundary("abab") + "123", + "abab", "abaxyz"); + checkBoundaryDetection("xyz123" + getFullBoundary("abab"), "abab", + "xyz123"); + } + + public void testOverlappingBoundary() throws Exception { + checkBoundaryDetection("abc" + getFullBoundary("abcabd") + "xyz123", + "abcabd", "abc"); + checkBoundaryDetection("xyzabc" + getFullBoundary("abcabd") + "123", + "abcabd", "xyzabc"); + checkBoundaryDetection("xyz123abc" + getFullBoundary("abcabd"), + "abcabd", "xyz123abc"); + } + + /* + * TODO fix these tests, they don't do what their method name says. + */ + + // public void testNoBoundaryInInput() throws Exception { + // try { + // checkBoundaryDetection("xyz123", "abc", "xyz123"); + // fail(); + // } catch (IOException e) { + // } + // } + // + // public void testPartialBoundaryAtInputEnd() throws Exception { + // try { + // // This should lead to IOException (stream end), not AIOOBE + // checkBoundaryDetection("xyz123ab", "abc", "xyz123ab"); + // fail(); + // } catch (IOException e) { + // } + // } + // + // public void testPartialBoundaryAtInputBeginning() throws Exception { + // try { + // checkBoundaryDetection("abxyz123", "abc", "abxyz123"); + // fail(); + // } catch (IOException e) { + // } + // } + + public static String getFullBoundary(String str) { + return "\r\n--" + str + "--"; + } + +} diff --git a/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignments.java b/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignments.java new file mode 100644 index 0000000000..04f436f5c4 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/table/TableColumnAlignments.java @@ -0,0 +1,165 @@ +package com.vaadin.tests.server.component.table; + +import static org.junit.Assert.assertArrayEquals; + +import org.junit.Test; + +import com.vaadin.ui.Table; + +public class TableColumnAlignments { + + @Test + public void defaultColumnAlignments() { + for (int properties = 0; properties < 10; properties++) { + Table t = TableGenerator.createTableWithDefaultContainer( + properties, 10); + Object[] expected = new Object[properties]; + for (int i = 0; i < properties; i++) { + expected[i] = Table.ALIGN_LEFT; + } + org.junit.Assert.assertArrayEquals("getColumnAlignments", expected, + t.getColumnAlignments()); + } + } + + @Test + public void explicitColumnAlignments() { + int properties = 5; + Table t = TableGenerator + .createTableWithDefaultContainer(properties, 10); + String[] explicitAlignments = new String[] { Table.ALIGN_CENTER, + Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, + Table.ALIGN_LEFT }; + + t.setColumnAlignments(explicitAlignments); + + assertArrayEquals("Explicit visible columns, 5 properties", + explicitAlignments, t.getColumnAlignments()); + } + + @Test + public void invalidColumnAlignmentStrings() { + Table t = TableGenerator.createTableWithDefaultContainer(3, 7); + String[] defaultAlignments = new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT }; + try { + t.setColumnAlignments(new String[] { "a", "b", "c" }); + junit.framework.Assert + .fail("No exception thrown for invalid array length"); + } catch (IllegalArgumentException e) { + // Ok, expected + } + + assertArrayEquals("Invalid change affected alignments", + defaultAlignments, t.getColumnAlignments()); + + } + + @Test + public void invalidColumnAlignmentString() { + Table t = TableGenerator.createTableWithDefaultContainer(3, 7); + String[] defaultAlignments = new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT }; + try { + t.setColumnAlignment("Property 1", "a"); + junit.framework.Assert + .fail("No exception thrown for invalid array length"); + } catch (IllegalArgumentException e) { + // Ok, expected + } + + assertArrayEquals("Invalid change affected alignments", + defaultAlignments, t.getColumnAlignments()); + + } + + @Test + public void columnAlignmentForPropertyNotInContainer() { + Table t = TableGenerator.createTableWithDefaultContainer(3, 7); + String[] defaultAlignments = new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT }; + try { + t.setColumnAlignment("Property 1200", Table.ALIGN_LEFT); + // FIXME: Uncomment as there should be an exception (#6475) + // junit.framework.Assert + // .fail("No exception thrown for property not in container"); + } catch (IllegalArgumentException e) { + // Ok, expected + } + + assertArrayEquals("Invalid change affected alignments", + defaultAlignments, t.getColumnAlignments()); + + // FIXME: Uncomment as null should be returned (#6474) + // junit.framework.Assert.assertEquals( + // "Column alignment for property not in container returned", + // null, t.getColumnAlignment("Property 1200")); + + } + + @Test + public void invalidColumnAlignmentsLength() { + Table t = TableGenerator.createTableWithDefaultContainer(7, 7); + String[] defaultAlignments = new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT }; + + try { + t.setColumnAlignments(new String[] { Table.ALIGN_LEFT }); + junit.framework.Assert + .fail("No exception thrown for invalid array length"); + } catch (IllegalArgumentException e) { + // Ok, expected + } + assertArrayEquals("Invalid change affected alignments", + defaultAlignments, t.getColumnAlignments()); + + try { + t.setColumnAlignments(new String[] {}); + junit.framework.Assert + .fail("No exception thrown for invalid array length"); + } catch (IllegalArgumentException e) { + // Ok, expected + } + assertArrayEquals("Invalid change affected alignments", + defaultAlignments, t.getColumnAlignments()); + + try { + t.setColumnAlignments(new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT, + Table.ALIGN_LEFT }); + junit.framework.Assert + .fail("No exception thrown for invalid array length"); + } catch (IllegalArgumentException e) { + // Ok, expected + } + assertArrayEquals("Invalid change affected alignments", + defaultAlignments, t.getColumnAlignments()); + + } + + @Test + public void explicitColumnAlignmentOneByOne() { + int properties = 5; + Table t = TableGenerator + .createTableWithDefaultContainer(properties, 10); + String[] explicitAlignments = new String[] { Table.ALIGN_CENTER, + Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT, + Table.ALIGN_LEFT }; + + String[] currentAlignments = new String[] { Table.ALIGN_LEFT, + Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT, + Table.ALIGN_LEFT }; + + for (int i = 0; i < properties; i++) { + t.setColumnAlignment("Property " + i, explicitAlignments[i]); + currentAlignments[i] = explicitAlignments[i]; + + assertArrayEquals("Explicit visible columns, " + i + + " alignments set", currentAlignments, + t.getColumnAlignments()); + } + + } +} diff --git a/tests/src/com/vaadin/tests/server/component/table/TableGenerator.java b/tests/src/com/vaadin/tests/server/component/table/TableGenerator.java new file mode 100644 index 0000000000..0e63049944 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/table/TableGenerator.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.server.component.table; + +import org.junit.Test; + +import com.vaadin.data.Item; +import com.vaadin.ui.Table; + +public class TableGenerator { + public static Table createTableWithDefaultContainer(int properties, + int items) { + Table t = new Table(); + + for (int i = 0; i < properties; i++) { + t.addContainerProperty("Property " + i, String.class, null); + } + + for (int j = 0; j < items; j++) { + Item item = t.addItem("Item " + j); + for (int i = 0; i < properties; i++) { + item.getItemProperty("Property " + i).setValue( + "Item " + j + "/Property " + i); + } + } + + return t; + } + + @Test + public void testTableGenerator() { + Table t = createTableWithDefaultContainer(1, 1); + junit.framework.Assert.assertEquals(t.size(), 1); + junit.framework.Assert.assertEquals(t.getContainerPropertyIds().size(), + 1); + + t = createTableWithDefaultContainer(100, 50); + junit.framework.Assert.assertEquals(t.size(), 50); + junit.framework.Assert.assertEquals(t.getContainerPropertyIds().size(), + 100); + + } + +} diff --git a/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumns.java b/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumns.java new file mode 100644 index 0000000000..be312044db --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/table/TableVisibleColumns.java @@ -0,0 +1,75 @@ +package com.vaadin.tests.server.component.table; + +import static org.junit.Assert.assertArrayEquals; + +import org.junit.Test; + +import com.vaadin.ui.Table; + +public class TableVisibleColumns { + + String[] defaultColumns3 = new String[] { "Property 0", "Property 1", + "Property 2" }; + + @Test + public void defaultVisibleColumns() { + for (int properties = 0; properties < 10; properties++) { + Table t = TableGenerator.createTableWithDefaultContainer( + properties, 10); + Object[] expected = new Object[properties]; + for (int i = 0; i < properties; i++) { + expected[i] = "Property " + i; + } + org.junit.Assert.assertArrayEquals("getVisibleColumns", expected, + t.getVisibleColumns()); + } + } + + @Test + public void explicitVisibleColumns() { + Table t = TableGenerator.createTableWithDefaultContainer(5, 10); + Object[] newVisibleColumns = new Object[] { "Property 1", "Property 2" }; + t.setVisibleColumns(newVisibleColumns); + assertArrayEquals("Explicit visible columns, 5 properties", + newVisibleColumns, t.getVisibleColumns()); + + } + + @Test + public void invalidVisibleColumnIds() { + Table t = TableGenerator.createTableWithDefaultContainer(3, 10); + + try { + t.setVisibleColumns(new Object[] { "a", "Property 2", "Property 3" }); + junit.framework.Assert.fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + // OK, expected + } + assertArrayEquals(defaultColumns3, t.getVisibleColumns()); + } + + @Test + public void duplicateVisibleColumnIds() { + Table t = TableGenerator.createTableWithDefaultContainer(3, 10); + try { + t.setVisibleColumns(new Object[] { "Property 0", "Property 1", + "Property 2", "Property 1" }); + // FIXME: Multiple properties in the Object array should be detected + // (#6476) + // junit.framework.Assert.fail("IllegalArgumentException expected"); + } catch (IllegalArgumentException e) { + // OK, expected + } + // FIXME: Multiple properties in the Object array should be detected + // (#6476) + // assertArrayEquals(defaultColumns3, t.getVisibleColumns()); + } + + @Test + public void noVisibleColumns() { + Table t = TableGenerator.createTableWithDefaultContainer(3, 10); + t.setVisibleColumns(new Object[] {}); + assertArrayEquals(new Object[] {}, t.getVisibleColumns()); + + } +} diff --git a/tests/test.xml b/tests/test.xml index 2068f25ccb..c7ee860840 100644 --- a/tests/test.xml +++ b/tests/test.xml @@ -52,7 +52,9 @@ - + + + -- cgit v1.2.3