diff options
47 files changed, 1594 insertions, 318 deletions
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; @@ -28,21 +29,93 @@ public interface LayoutEvents { } /** + * The interface for adding and removing <code>LayoutClickEvent</code> + * listeners. By implementing this interface a class explicitly announces + * that it will generate a <code>LayoutClickEvent</code> when a component + * inside it is clicked and a <code>LayoutClickListener</code> is + * registered. + * <p> + * Note: The general Java convention is not to explicitly declare that a + * class generates events, but to directly define the + * <code>addListener</code> and <code>removeListener</code> 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. + * </p> + * + * @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 { * <literal>element</literal> 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 @@ -855,6 +860,56 @@ public class Util { } /** + * Locates the nested child component of <literal>parent</literal> which + * contains the element <literal>element</literal>. The child component is + * also returned if "element" is part of its caption. If + * <literal>element</literal> is not part of any child component, null is + * returned. + * + * This method returns the deepest nested 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 <literal>element</literal>. + * @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. * * @param el 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: * <ul> - * <li> {@link #setAjaxPageHeaders(HttpServletResponse)} - * <li> {@link #writeAjaxPageHtmlHeadStart(BufferedWriter)} - * <li> {@link #writeAjaxPageHtmlHeader(BufferedWriter, String, String)} - * <li> {@link #writeAjaxPageHtmlBodyStart(BufferedWriter)} + * <li> {@link #setAjaxPageHeaders(HttpServletResponse) + * <li> {@link #writeAjaxPageHtmlHeadStart(BufferedWriter, HttpServletRequest) + * <li> {@link #writeAjaxPageHtmlHeader(BufferedWriter, String, String, HttpServletRequest) + * <li> {@link #writeAjaxPageHtmlBodyStart(BufferedWriter, HttpServletRequest) * <li> - * {@link #writeAjaxPageHtmlVaadinScripts(Window, String, Application, BufferedWriter, String, String, String, String, String, String)} + * {@link #writeAjaxPageHtmlVaadinScripts(Window, String, Application, BufferedWriter, String, String, String, HttpServletRequest) * <li> - * {@link #writeAjaxPageHtmlMainDiv(BufferedWriter, String, String, String)} + * {@link #writeAjaxPageHtmlMainDiv(BufferedWriter, String, String, String, HttpServletRequest) * <li> {@link #writeAjaxPageHtmlBodyEnd(BufferedWriter)} * </ul> * @@ -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("</body>\n</html>\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("<div id=\"" + appId + "\" class=\"" + classNames + "\" " + (divStyle != null ? divStyle : "") + "></div>\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</head>\n<body scroll=\"auto\" class=\"" + ApplicationConnection.GENERATED_BODY_CLASSNAME + "\">\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("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"); - // Force IE9 into IE8 mode. Remove when IE 9 mode works (#5546), chrome - // frame if available #5261 - page.write("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8,chrome=1\"/>\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("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8,chrome=1\"/>\n"); + } else { + page.write("<meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\"/>\n"); + } + } page.write("<style type=\"text/css\">" + "html, body {height:100%;margin:0;}</style>"); @@ -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("<!DOCTYPE html PUBLIC \"-//W3C//DTD " + "XHTML 1.0 Transitional//EN\" " diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index d9d31f0951..4cad1cc8e6 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -85,6 +85,8 @@ import com.vaadin.ui.Window; public abstract class AbstractCommunicationManager implements Paintable.RepaintRequestListener, Serializable { + private static final String DASHDASH = "--"; + private static final Logger logger = Logger .getLogger(AbstractCommunicationManager.class.getName()); @@ -382,8 +384,6 @@ public abstract class AbstractCommunicationManager implements Response response, StreamVariable streamVariable, String variableName, VariableOwner owner, String boundary) throws IOException { - boundary = CRLF + "--" + boundary + "--"; - // multipart parsing, supports only one file for request, but that is // fine for our current terminal @@ -417,7 +417,8 @@ public abstract class AbstractCommunicationManager implements } } - contentLength -= (boundary.length() + 2); // 2 == CRLF + contentLength -= (boundary.length() + CRLF.length() + 2 + * DASHDASH.length() + 2); // 2 == CRLF /* * Reads bytes from the underlying stream. Compares the read bytes to @@ -2167,7 +2168,14 @@ public abstract class AbstractCommunicationManager implements abstract protected void cleanStreamVariable(VariableOwner owner, String name); - private static class SimpleMultiPartInputStream extends InputStream { + /** + * Stream that extracts content from another stream until the boundary + * string is encountered. + * + * Public only for unit tests, should be considered private for all other + * purposes. + */ + public static class SimpleMultiPartInputStream extends InputStream { /** * Counter of how many characters have been matched to boundary string @@ -2192,7 +2200,8 @@ public abstract class AbstractCommunicationManager implements public SimpleMultiPartInputStream(InputStream realInputStream, String boundaryString) { - boundary = boundaryString.toCharArray(); + boundary = (CRLF + DASHDASH + boundaryString + DASHDASH) + .toCharArray(); this.realInputStream = realInputStream; } diff --git a/src/com/vaadin/ui/AbsoluteLayout.java b/src/com/vaadin/ui/AbsoluteLayout.java index 538cc26c77..3b0239af7b 100644 --- a/src/com/vaadin/ui/AbsoluteLayout.java +++ b/src/com/vaadin/ui/AbsoluteLayout.java @@ -12,10 +12,11 @@ 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.EventId; import com.vaadin.terminal.gwt.client.ui.VAbsoluteLayout; /** @@ -25,9 +26,10 @@ import com.vaadin.terminal.gwt.client.ui.VAbsoluteLayout; */ @SuppressWarnings("serial") @ClientWidget(VAbsoluteLayout.class) -public class AbsoluteLayout extends AbstractLayout { +public class AbsoluteLayout extends AbstractLayout implements + LayoutClickNotifier { - private static final String CLICK_EVENT = VAbsoluteLayout.CLICK_EVENT_IDENTIFIER; + private static final String CLICK_EVENT = EventId.LAYOUT_CLICK; // The components in the layout private Collection<Component> components = new LinkedHashSet<Component>(); @@ -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<String, Object> variables) { - super.changeVariables(source, variables); - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map<String, Object>) 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<String, Object> 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<String, Object> variables) { + super.changeVariables(source, variables); + // not all subclasses use these events + if (this instanceof LayoutClickNotifier + && variables.containsKey(CLICK_EVENT)) { + fireClick((Map<String, Object>) 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<String, Object> 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<String, Object> variables) { - super.changeVariables(source, variables); - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map<String, Object>) variables.get(CLICK_EVENT)); - } - - } - - private void fireClick(Map<String, Object> 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<String, Object> parameters) { + @Override + protected void fireClick(Map<String, Object> 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<String, Object> variables) { - super.changeVariables(source, variables); - - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map<String, Object>) variables.get(CLICK_EVENT)); - } - - } - - private void fireClick(Map<String, Object> 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<String, Object> variables) { - super.changeVariables(source, variables); - - if (variables.containsKey(CLICK_EVENT)) { - fireClick((Map<String, Object>) variables.get(CLICK_EVENT)); - } - - } - - private void fireClick(Map<String, Object> 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<Object> 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 @@ -27,6 +27,11 @@ <td></td>
</tr>
<tr>
+ <td>pause</td>
+ <td>2000</td>
+ <td></td>
+</tr>
+<tr>
<td>screenCapture</td>
<td></td>
<td>samplelayouts-medialibrary</td>
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<? extends AbstractComponentTest<?>> cls = (Class<? extends AbstractComponentTest<?>>) 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<? extends AbstractComponentTest<?>> cls = (Class<? extends AbstractComponentTest<?>>) 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<? extends AbstractComponentTest<?>> cls) {
+ protected boolean isAbstract(Class<?> cls) {
return Modifier.isAbstract(cls.getModifiers());
}
+ @SuppressWarnings("unchecked")
private void addTreeItem(Class<? extends AbstractComponentTest<?>> cls) {
String name = tests.get(cls);
if (name == null) {
@@ -250,7 +251,7 @@ public class Components extends Application { protected Component createTestComponent(
Class<? extends AbstractComponentTest<?>> 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<Class<? extends AbstractComponentTest<?>>> 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 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1</td> - <td>1. DateField value is now 1973-03-03</td> + <td>1. DateField value is now March 3, 1973 11:46:40 AM</td> </tr> <tr> <td>assertValue</td> @@ -74,7 +74,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1</td> - <td>4. DateField value is now Thu Mar 15 11:46:40 GMT+02:00 1973</td> + <td>4. DateField value is now March 15, 1973 11:46:40 AM</td> </tr> <tr> <td>assertValue</td> @@ -185,7 +185,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1</td> - <td>21. DateField value is now 1990-05-04</td> + <td>21. DateField value is now May 4, 1990 12:00:00 AM</td> </tr> <tr> <td>assertValue</td> @@ -205,7 +205,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1</td> - <td>25. DateField value is now 2000-06-05</td> + <td>25. DateField value is now June 5, 2000 12:00:00 AM</td> </tr> <tr> <td>click</td> @@ -230,7 +230,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1</td> - <td>33. DateField value is now 2000-06-05</td> + <td>33. DateField value is now June 5, 2000 12:00:00 AM</td> </tr> <tr> <td>click</td> @@ -240,14 +240,13 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_1</td> - <td>40. DateField value is now 2005-08-27</td> + <td>40. DateField value is now August 27, 2005 12:00:00 AM</td> </tr> <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDateFieldEmptyValid::PID_SLog_row_0</td> <td>41. isEmpty: false, isValid: true</td> </tr> - </tbody></table> </body> </html> 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 @@ <td>/run/com.vaadin.tests.components.datefield.InlineDateFieldTest?restartApplication</td> <td></td> </tr> -<!--Use FI locale as DATE functions on the test clients use FI locale (for some reason...)--> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_Smenu#item0</td> - <td>36,14</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::Root/VOverlay[0]/VMenuBar[0]#item0</td> - <td>37,10</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::Root/VOverlay[1]/VMenuBar[0]#item5</td> - <td>45,5</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::Root/VOverlay[2]/VMenuBar[0]#item1</td> - <td>34,10</td> -</tr> <!--Day resolution--> <tr> <td>mouseClick</td> @@ -104,7 +83,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> - <td>4. ValueChangeEvent, new value: Dec 14, 2010 12:00:00.000</td> + <td>3. ValueChangeEvent, new value: Dec 14, 2010 12:00:00.000</td> </tr> <tr> <td>mouseClick</td> @@ -114,7 +93,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> - <td>5. ValueChangeEvent, new value: Dec 13, 2010 12:00:00.000</td> + <td>4. ValueChangeEvent, new value: Dec 13, 2010 12:00:00.000</td> </tr> <tr> <td>mouseClick</td> @@ -134,7 +113,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> - <td>6. ValueChangeEvent, new value: Dec 14, 2009 12:00:00.000</td> + <td>5. ValueChangeEvent, new value: Dec 14, 2009 12:00:00.000</td> </tr> <tr> <td>mouseClick</td> @@ -149,7 +128,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> - <td>7. ValueChangeEvent, new value: Jan 12, 2010 12:00:00.000</td> + <td>6. ValueChangeEvent, new value: Jan 12, 2010 12:00:00.000</td> </tr> <!--Set value to null and ensure nothing is selected--> <tr> @@ -178,6 +157,7 @@ <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]</td> <td>DATE(MMMM YYYY)</td> </tr> +<!--Show value--> <tr> <td>mouseClick</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_Smenu#item1</td> @@ -197,7 +177,7 @@ <tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> - <td>10. InlineDateField value: null</td> + <td>9. InlineDateField value: null</td> </tr> <tr> <td>assertCSSClass</td> @@ -212,19 +192,39 @@ </tr> <tr> <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day1</td> + <td>v-datefield-calendarpanel-day-selected</td> +</tr> +<tr> + <td>assertCSSClass</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#dayDATE(D)</td> <td>today</td> </tr> -<!--select today and assert that the value changes (today should still be the same)--> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> + <td>10. ValueChangeEvent, new value: DATE(MMM) 1, DATE(YYYY) *</td> +</tr> +<!--select 2nd and assert that the value changes (today should still be the same)--> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day1</td> - <td>11,10</td> -<!-- Cannot validate month here as we use FI locale and this is printed in EN locale (#6409)... --> -</tr><tr> + <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day2</td> + <td>0,0</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#dayDATE(D)</td> + <td>today</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_StestComponent/VCalendarPanel[0]#day2</td> + <td>v-datefield-calendarpanel-day-selected</td> +</tr> +<tr> <td>assertText</td> <td>vaadin=runcomvaadintestscomponentsdatefieldInlineDateFieldTest::PID_SLog_row_0</td> - <td>11. ValueChangeEvent, new value: * 1, DATE(YYYY) *</td> + <td>11. ValueChangeEvent, new value: DATE(MMM) 2, DATE(YYYY) *</td> </tr> </tbody></table> </body> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>CloseErrorNotificationWithEscape</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">CloseErrorNotificationWithEscape</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.notification.Notifications?restartApplication</td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VNativeSelect[0]/domChild[0]</td> + <td>label=Error</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>Hello world</td> +</tr> +<tr> + <td>keyDown</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>\\27</td> +</tr> +<!-- Fade delay is 400 ms by default - VNotification --> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>LayoutClickListenerTest</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">LayoutClickListenerTest</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.orderedlayout.LayoutClickListenerTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VLink[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=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]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsorderedlayoutLayoutClickListenerTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>everything_clicked</td> +</tr> + +</tbody></table> +</body> +</html> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>HorizontalSplitPanelSplitterClick</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">HorizontalSplitPanelSplitterClick</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.splitpanel.HorizontalSplitPanels?restartApplication</td> + <td></td> +</tr> +<!--Add splitter click listener--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_Smenu#item0</td> + <td>9,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item4</td> + <td>105,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item2</td> + <td>36,11</td> +</tr> +<!--Click splitter--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_SLog_row_0</td> + <td>1. SplitterClickEvent: left at -1,-1</td> +</tr> +<!--Reverse orientation--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_Smenu#item0</td> + <td>51,5</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item6</td> + <td>73,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item0</td> + <td>50,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::Root/VOverlay[2]/VMenuBar[0]#item7</td> + <td>92,10</td> +</tr> +<!--Click splitter--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelHorizontalSplitPanels::PID_SLog_row_0</td> + <td>3. SplitterClickEvent: left at -1,-1</td> +</tr> + +</tbody></table> +</body> +</html> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>VerticalSplitPanelSplitterClick</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">VerticalSplitPanelSplitterClick</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.splitpanel.VerticalSplitPanels?restartApplication</td> + <td></td> +</tr> +<!--Add splitter click listener--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_Smenu#item0</td> + <td>9,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item4</td> + <td>105,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item2</td> + <td>36,11</td> +</tr> +<!--Click splitter--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_SLog_row_0</td> + <td>1. SplitterClickEvent: left at -1,-1</td> +</tr> +<!--Reverse orientation--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_Smenu#item0</td> + <td>51,5</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[0]/VMenuBar[0]#item6</td> + <td>73,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[1]/VMenuBar[0]#item0</td> + <td>50,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::Root/VOverlay[2]/VMenuBar[0]#item7</td> + <td>92,10</td> +</tr> +<!--Click splitter--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_StestComponent/domChild[0]/domChild[2]/domChild[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelVerticalSplitPanels::PID_SLog_row_0</td> + <td>3. SplitterClickEvent: left at -1,-1</td> +</tr> + +</tbody></table> +</body> +</html> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td> + <td></td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]</td> + <td>0,11</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]</td> + <td>100,0</td> +</tr> +<tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]</td> + <td>101</td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]/domChild[0]</td> + <td>0,11</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]/domChild[0]</td> + <td>-50,0</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>resized-after-scrolling</td> +</tr> + +</tbody></table> +</body> +</html> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://arturwin.office.itmill.com:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.TableToggleVisibility?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>trucks-trailers-drivers</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>drivers</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>trailers</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>trailers-drivers</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableToggleVisibility::/VVerticalLayout[0]/ChildComponentContainer[0]/VSplitPanelHorizontal[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>trucks-trailers-drivers-2</td> +</tr> +</tbody></table> +</body> +</html> 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 @@ <target name="create-tests" depends="remove-temp-testclasses" if="server.start.succeeded"> <pathconvert pathsep=" " property="testfiles" refid="html-test-files" /> - <java classname="com.vaadin.testbench.util.TestConverter" classpathref="classpath"> + <java classname="com.vaadin.testbench.util.TestConverter" classpathref="classpath" fork="true"> + <jvmarg value="-Duser.language=en"/> + <jvmarg value="-Duser.country=US"/> <arg value="${test-output-dir}" /> <arg value="${browsers}" /> <arg line="${testfiles}" /> |