From: Henri Sara Date: Thu, 16 Jun 2011 07:19:43 +0000 (+0000) Subject: Merge from 6.6 X-Git-Tag: 6.7.0.beta1~193 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=79c52ac3d4756a6f8cbb94b9e7dc264ba61c5430;p=vaadin-framework.git Merge from 6.6 svn changeset:19412/svn branch:6.7 --- 79c52ac3d4756a6f8cbb94b9e7dc264ba61c5430 diff --cc WebContent/VAADIN/themes/base/menubar/img/check.gif index 0000000000,0000000000..0a89195168 new file mode 100644 Binary files differ diff --cc WebContent/VAADIN/themes/base/menubar/menubar.css index d1972ac4ec,1ce42ce657..042ec15d1d --- a/WebContent/VAADIN/themes/base/menubar/menubar.css +++ b/WebContent/VAADIN/themes/base/menubar/menubar.css @@@ -79,4 -78,4 +79,15 @@@ .v-menubar-popup .popupContent:focus, .v-menubar-popup .popupContent .v-menubar-submenu:focus{ outline: none; --} ++} ++/* Checkboxes for checkable/checked menu items */ ++/* Checked/unchecked requires combined style selected-(un)checked for IE6 */ ++.v-menubar-submenu-check-column .v-menubar-menuitem { ++ padding-left: 6px; ++} ++.v-menubar-submenu-check-column .v-menubar-menuitem-caption { ++ padding-left: 18px; ++} ++.v-menubar-submenu .v-menubar-menuitem-checked .v-menubar-menuitem-caption { ++ background: transparent url(img/check.gif) no-repeat left; ++} diff --cc WebContent/VAADIN/themes/reindeer/button/img/black-button-sprites-ie6.png index 90a73be23f,90a73be23f..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/button/img/black-button-sprites.png index 744ca30d64,744ca30d64..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/button/img/button-sprites-ie6.png index 8ccaa56edd,8ccaa56edd..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/button/img/button-sprites.png index 5087e8e957,5087e8e957..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/common/img/black-vertical-sprites-ie6.png index 84c52dbf4c,84c52dbf4c..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/common/img/black-vertical-sprites.png index 387abf2d4b,387abf2d4b..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/common/img/horizontal-sprites.png index 7980a5aa18,7980a5aa18..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/common/img/vertical-sprites-ie6.png index a7ace8b131,a7ace8b131..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/common/img/vertical-sprites.png index 31571144df,31571144df..0000000000 deleted file mode 100644,100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/menubar/img/checked-selected.png index 0000000000,0000000000..192c404617 new file mode 100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/menubar/img/checked.png index 0000000000,0000000000..418e951166 new file mode 100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/menubar/img/unchecked-selected.png index 0000000000,0000000000..bac6587c20 new file mode 100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/menubar/img/unchecked.png index 0000000000,0000000000..92a2b582c5 new file mode 100644 Binary files differ diff --cc WebContent/VAADIN/themes/reindeer/menubar/menubar.css index f3e620353a,f3e620353a..e5e337725e --- a/WebContent/VAADIN/themes/reindeer/menubar/menubar.css +++ b/WebContent/VAADIN/themes/reindeer/menubar/menubar.css @@@ -49,4 -49,4 +49,24 @@@ } .v-menubar-submenu .v-menubar-menuitem-selected .v-menubar-submenu-indicator { background-image: url(img/submenu-icon-hover.png); --} ++} ++ ++/* Checkboxes for checkable/checked menu items */ ++.v-menubar-submenu-check-column .v-menubar-menuitem { ++ padding-left: 6px; ++} ++.v-menubar-submenu-check-column .v-menubar-menuitem-caption { ++ padding-left: 18px; ++} ++.v-menubar-submenu .v-menubar-menuitem-checked .v-menubar-menuitem-caption { ++ background: transparent url(img/checked.png) no-repeat left; ++} ++.v-menubar-submenu .v-menubar-menuitem-unchecked .v-menubar-menuitem-caption { ++ background: transparent url(img/unchecked.png) no-repeat left; ++} ++.v-menubar-submenu .v-menubar-menuitem-selected-checked .v-menubar-menuitem-caption { ++ background: transparent url(img/checked-selected.png) no-repeat left; ++} ++.v-menubar-submenu .v-menubar-menuitem-selected-unchecked .v-menubar-menuitem-caption { ++ background: transparent url(img/unchecked-selected.png) no-repeat left; ++} diff --cc WebContent/VAADIN/themes/runo/select/select.css index e00e033017,e00e033017..ad1744288a --- a/WebContent/VAADIN/themes/runo/select/select.css +++ b/WebContent/VAADIN/themes/runo/select/select.css @@@ -24,7 -24,7 +24,7 @@@ border: none; height: 20px; margin: 0; -- padding: 3px 0 0 2px; ++ padding: 2px 0 1px 2px; font-size: 13px; } .v-filterselect-prompt .v-filterselect-input { diff --cc WebContent/VAADIN/themes/sampler/icons/sampleicons/75-MenuBarSelectableItems.gif index 0000000000,0000000000..f59714cc62 new file mode 100644 Binary files differ diff --cc build/build.xml index 928bfdc638,66bac3d0da..ad90bc083b --- a/build/build.xml +++ b/build/build.xml @@@ -812,6 -806,6 +812,7 @@@ ++ diff --cc src/com/vaadin/data/util/HierarchicalContainer.java index d671dbc833,2b434224ac..99de7a1352 --- a/src/com/vaadin/data/util/HierarchicalContainer.java +++ b/src/com/vaadin/data/util/HierarchicalContainer.java @@@ -471,6 -470,6 +471,9 @@@ public class HierarchicalContainer exte if (filteredChildren != null) { filteredChildren = null; } ++ if (filteredParent != null) { ++ filteredParent = null; ++ } } enableAndFireContentsChangeEvents(); return success; @@@ -516,18 -515,18 +519,30 @@@ if (c != null) { c.remove(itemId); ++ if (c.isEmpty()) { ++ children.remove(parentItemId); ++ } ++ // Found in the children list so might also be in the // filteredChildren list if (filteredChildren != null) { LinkedList f = filteredChildren .get(parentItemId); if (f != null) { -- f.remove(parentItemId); ++ f.remove(itemId); ++ if (f.isEmpty()) { ++ filteredChildren.remove(parentItemId); ++ } } } } } parent.remove(itemId); ++ if (filteredParent != null) { ++ // Item id no longer has a parent as the item id is not in the ++ // container. ++ filteredParent.remove(itemId); ++ } noChildrenAllowed.remove(itemId); } @@@ -642,6 -641,6 +657,7 @@@ // All filters removed filteredRoots = null; filteredChildren = null; ++ filteredParent = null; return super.doFilterContainer(hasFilters); } diff --cc src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 5f808ea8cd,b0cf4945f0..056428881f --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@@ -364,10 -356,7 +364,11 @@@ public class ApplicationConnection // values currently only via transaction listener. String parameters = "repaintAll=1&" + "sh=" + screenHeight + "&sw=" + screenWidth + "&cw=" + clientWidth + "&ch=" + clientHeight - + "&vw=" + offsetWidth + "&vh=" + offsetHeight + "&fr=" + token; + + "&vw=" + offsetWidth + "&vh=" + offsetHeight + "&fr=" + token + + "&tzo=" + tzOffset + "&rtzo=" + rtzOffset + "&dstd=" + + dstDiff + "&dston=" + dstInEffect + "&curdate=" + curDate - + "&wsver=" + widgetsetVersion; ++ + "&wsver=" + widgetsetVersion ++ + (BrowserInfo.get().isTouchDevice() ? "&td=1" : ""); return parameters; } diff --cc src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 996b719e33,56b7d198e0..4d43b7c346 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@@ -8,6 -8,6 +8,7 @@@ import java.util.Iterator import java.util.List; import java.util.Stack; ++import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.NodeList; @@@ -64,8 -63,6 +65,10 @@@ public class VMenuBar extends SimpleFoc // associated protected static final Command emptyCommand = null; + public static final String OPEN_ROOT_MENU_ON_HOWER = "ormoh"; + ++ public static final String ATTRIBUTE_CHECKED = "checked"; ++ /** Widget fields **/ protected boolean subMenu; protected ArrayList items; @@@ -228,9 -220,9 +231,12 @@@ } itemHTML.append(moreItemText); -- moreItem = new CustomMenuItem(itemHTML.toString(), emptyCommand); - collapsedRootItems = new VMenuBar(true, (VMenuBar) client - .getPaintable(uidlId)); ++ moreItem = GWT.create(CustomMenuItem.class); ++ moreItem.setHTML(itemHTML.toString()); ++ moreItem.setCommand(emptyCommand); ++ + collapsedRootItems = new VMenuBar(true, + (VMenuBar) client.getPaintable(uidlId)); moreItem.setSubMenu(collapsedRootItems); moreItem.addStyleName(CLASSNAME + "-more-menuitem"); } @@@ -245,45 -237,43 +251,16 @@@ UIDL item = (UIDL) itr.next(); CustomMenuItem currentItem = null; -- String itemText = item.getStringAttribute("text"); final int itemId = item.getIntAttribute("id"); boolean itemHasCommand = item.hasAttribute("command"); ++ boolean itemIsCheckable = item.hasAttribute(ATTRIBUTE_CHECKED); -- // Construct html from the text and the optional icon -- StringBuffer itemHTML = new StringBuffer(); -- Command cmd = null; -- -- if (item.hasAttribute("separator")) { -- itemHTML.append("---"); -- } else { -- // Add submenu indicator -- if (item.getChildCount() > 0) { -- // FIXME For compatibility reasons: remove in version 7 -- String bgStyle = ""; -- if (submenuIcon != null) { -- bgStyle = " style=\"background-image: url(" -- + submenuIcon -- + "); text-indent: -999px; width: 1em;\""; -- } -- itemHTML.append(""); -- } -- -- itemHTML.append(""); -- if (item.hasAttribute("icon")) { - itemHTML - .append("\"\""); - itemHTML.append("\"\""); -- } -- itemHTML.append(Util.escapeHTML(itemText) + ""); ++ String itemHTML = buildItemHTML(item); -- if (itemHasCommand) { ++ Command cmd = null; ++ if (!item.hasAttribute("separator")) { ++ if (itemHasCommand || itemIsCheckable) { // Construct a command that fires onMenuClick(int) with the // item's id-number cmd = new Command() { @@@ -312,6 -302,6 +289,17 @@@ } while (!itr.hasNext() && !iteratorStack.empty()) { ++ boolean hasCheckableItem = false; ++ for (CustomMenuItem menuItem : currentMenu.getItems()) { ++ hasCheckableItem = hasCheckableItem ++ || menuItem.isCheckable(); ++ } ++ if (hasCheckableItem) { ++ currentMenu.addStyleDependentName("check-column"); ++ } else { ++ currentMenu.removeStyleDependentName("check-column"); ++ } ++ itr = iteratorStack.pop(); currentMenu = menuStack.pop(); } @@@ -321,6 -311,6 +309,45 @@@ }// updateFromUIDL ++ /** ++ * Build the HTML content for a menu item. ++ * ++ * @param item ++ * @return ++ */ ++ protected String buildItemHTML(UIDL item) { ++ // Construct html from the text and the optional icon ++ StringBuffer itemHTML = new StringBuffer(); ++ if (item.hasAttribute("separator")) { ++ itemHTML.append("---"); ++ } else { ++ // Add submenu indicator ++ if (item.getChildCount() > 0) { ++ // FIXME For compatibility reasons: remove in version 7 ++ String bgStyle = ""; ++ if (submenuIcon != null) { ++ bgStyle = " style=\"background-image: url(" + submenuIcon ++ + "); text-indent: -999px; width: 1em;\""; ++ } ++ itemHTML.append(""); ++ } ++ ++ itemHTML.append(""); ++ if (item.hasAttribute("icon")) { ++ itemHTML.append("\"\""); ++ } ++ String itemText = item.getStringAttribute("text"); ++ itemHTML.append(Util.escapeHTML(itemText)); ++ itemHTML.append(""); ++ } ++ return itemHTML.toString(); ++ } ++ /** * This is called by the items in the menu and it communicates the * information to the server @@@ -379,7 -369,7 +406,10 @@@ * @return the item created */ public CustomMenuItem addItem(String html, Command cmd) { -- CustomMenuItem item = new CustomMenuItem(html, cmd); ++ CustomMenuItem item = GWT.create(CustomMenuItem.class); ++ item.setHTML(html); ++ item.setCommand(cmd); ++ addItem(item); return item; } @@@ -835,7 -773,7 +864,28 @@@ protected VMenuBar parentMenu = null; protected boolean enabled = true; protected boolean isSeparator = false; ++ protected boolean checkable = false; ++ protected boolean checked = false; ++ ++ /** ++ * Default menu item {@link Widget} constructor for GWT.create(). ++ * ++ * Use {@link #setHTML(String)} and {@link #setCommand(Command)} after ++ * constructing a menu item. ++ */ ++ public CustomMenuItem() { ++ this("", null); ++ } ++ /** ++ * Creates a menu item {@link Widget}. ++ * ++ * @param html ++ * @param cmd ++ * @deprecated use the default constructor and {@link #setHTML(String)} ++ * and {@link #setCommand(Command)} instead ++ */ ++ @Deprecated public CustomMenuItem(String html, Command cmd) { // We need spans to allow inline-block in IE setElement(DOM.createSpan()); @@@ -846,20 -784,20 +896,64 @@@ setStyleName(CLASSNAME + "-menuitem"); sinkEvents(VTooltip.TOOLTIP_EVENTS); -- -- // Sink the onload event for any icons. The onload -- // events are handled by the parent VMenuBar. -- Util.sinkOnloadForImages(getElement()); } public void setSelected(boolean selected) { if (selected && !isSeparator) { addStyleDependentName("selected"); ++ // needed for IE6 to have a single style name to match for an ++ // element ++ if (checkable) { ++ if (checked) { ++ removeStyleDependentName("selected-unchecked"); ++ addStyleDependentName("selected-checked"); ++ } else { ++ removeStyleDependentName("selected-checked"); ++ addStyleDependentName("selected-unchecked"); ++ } ++ } } else { removeStyleDependentName("selected"); ++ // needed for IE6 to have a single style name to match for an ++ // element ++ removeStyleDependentName("selected-checked"); ++ removeStyleDependentName("selected-unchecked"); + } + } + ++ public void setChecked(boolean checked) { ++ if (checkable && !isSeparator) { ++ this.checked = checked; ++ ++ if (checked) { ++ addStyleDependentName("checked"); ++ removeStyleDependentName("unchecked"); ++ } else { ++ addStyleDependentName("unchecked"); ++ removeStyleDependentName("checked"); ++ } ++ } else { ++ this.checked = false; ++ } ++ } ++ ++ public boolean isChecked() { ++ return checked; ++ } ++ ++ public void setCheckable(boolean checkable) { ++ if (checkable && !isSeparator) { ++ this.checkable = true; ++ } else { ++ setChecked(false); ++ this.checkable = false; + } + } + ++ public boolean isCheckable() { ++ return checkable; ++ } ++ /* * setters and getters for the fields */ @@@ -895,6 -833,6 +989,10 @@@ public void setHTML(String html) { this.html = html; DOM.setInnerHTML(getElement(), html); ++ ++ // Sink the onload event for any icons. The onload ++ // events are handled by the parent VMenuBar. ++ Util.sinkOnloadForImages(getElement()); } public String getText() { @@@ -937,6 -875,6 +1035,15 @@@ setSeparator(uidl.hasAttribute("separator")); setEnabled(!uidl.hasAttribute("disabled")); ++ if (!isSeparator() && uidl.hasAttribute(ATTRIBUTE_CHECKED)) { ++ // if the selected attribute is present (either true or false), ++ // the item is selectable ++ setCheckable(true); ++ setChecked(uidl.getBooleanAttribute(ATTRIBUTE_CHECKED)); ++ } else { ++ setCheckable(false); ++ } ++ if (uidl.hasAttribute("style")) { String itemStyle = uidl.getStringAttribute("style"); addStyleDependentName(itemStyle); @@@ -1435,9 -1373,6 +1542,7 @@@ * .dom.client.FocusEvent) */ public void onFocus(FocusEvent event) { - // Focus the first element directly, so the keyboard focus becomes - // visible - setSelected(items.get(0)); ++ } private final String SUBPART_PREFIX = "item"; diff --cc src/com/vaadin/terminal/gwt/client/ui/VOverlay.java index aba7ccf217,9e4e167060..a277b4c42d --- a/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOverlay.java @@@ -22,7 -20,7 +22,7 @@@ import com.vaadin.terminal.gwt.client.U * temporary float over other components like context menus etc. This is to deal * stacking order correctly with VWindow objects. */ --public class VOverlay extends PopupPanel { ++public class VOverlay extends PopupPanel implements CloseHandler { /* * The z-index value from where all overlays live. This can be overridden in @@@ -84,23 -78,23 +84,43 @@@ public VOverlay(boolean autoHide, boolean modal, boolean showShadow) { super(autoHide, modal); -- if (showShadow) { -- shadow = DOM.createDiv(); -- shadow.setClassName(CLASSNAME_SHADOW); -- shadow.setInnerHTML(SHADOW_HTML); -- DOM.setStyleAttribute(shadow, "position", "absolute"); -- -- addCloseHandler(new CloseHandler() { -- public void onClose(CloseEvent event) { -- if (shadow.getParentElement() != null) { -- shadow.getParentElement().removeChild(shadow); -- } -- } -- }); -- } ++ setShadowEnabled(showShadow); adjustZIndex(); } ++ /** ++ * Method to controle whether DOM elements for shadow are added. With this ++ * method subclasses can control displaying of shadow also after the ++ * constructor. ++ * ++ * @param enabled ++ * true if shadow should be displayed ++ */ ++ protected void setShadowEnabled(boolean enabled) { ++ if (enabled != isShadowEnabled()) { ++ if (enabled) { ++ shadow = DOM.createDiv(); ++ shadow.setClassName(CLASSNAME_SHADOW); ++ shadow.setInnerHTML(SHADOW_HTML); ++ DOM.setStyleAttribute(shadow, "position", "absolute"); ++ addCloseHandler(this); ++ } else { ++ removeShadowIfPresent(); ++ shadow = null; ++ } ++ } ++ } ++ ++ protected boolean isShadowEnabled() { ++ return shadow != null; ++ } ++ ++ private void removeShadowIfPresent() { ++ if (isShadowEnabled() && shadow.getParentElement() != null) { ++ shadow.getParentElement().removeChild(shadow); ++ } ++ } ++ private void adjustZIndex() { setZIndex(Z_INDEX); } @@@ -113,56 -107,23 +133,71 @@@ */ protected void setZIndex(int zIndex) { DOM.setStyleAttribute(getElement(), "zIndex", "" + zIndex); -- if (shadow != null) { ++ if (isShadowEnabled()) { DOM.setStyleAttribute(shadow, "zIndex", "" + zIndex); } } @Override public void setPopupPosition(int left, int top) { + // TODO, this should in fact be part of + // Document.get().getBodyOffsetLeft/Top(). Would require overriding DOM + // for all permutations. Now adding fix as margin instead of fixing + // left/top because parent class saves the position. + Style style = getElement().getStyle(); + style.setMarginLeft(-adjustByRelativeLeftBodyMargin(), Unit.PX); + style.setMarginTop(-adjustByRelativeTopBodyMargin(), Unit.PX); super.setPopupPosition(left, top); -- if (shadow != null) { -- updateShadowSizeAndPosition(isAnimationEnabled() ? 0 : 1); - } ++ updateShadowSizeAndPosition(isAnimationEnabled() ? 0 : 1); + } + + private static int adjustByRelativeTopBodyMargin() { + if (topFix == -1) { - topFix = detectRelativeBodyFixes("top"); ++ boolean ie6OrIe7 = BrowserInfo.get().isIE() ++ && BrowserInfo.get().getIEVersion() <= 7; ++ topFix = detectRelativeBodyFixes("top", ie6OrIe7); } + return topFix; + } + - private native static int detectRelativeBodyFixes(String axis) ++ private native static int detectRelativeBodyFixes(String axis, ++ boolean removeClientLeftOrTop) + /*-{ + try { + var b = $wnd.document.body; + var cstyle = b.currentStyle ? b.currentStyle : getComputedStyle(b); + if(cstyle && cstyle.position == 'relative') { - return b.getBoundingClientRect()[axis]; ++ var offset = b.getBoundingClientRect()[axis]; ++ if (removeClientLeftOrTop) { ++ // IE6 and IE7 include the top left border of the client area into the boundingClientRect ++ var clientTopOrLeft = 0; ++ if (axis == "top") ++ clientTopOrLeft = $wnd.document.documentElement.clientTop; ++ else ++ clientTopOrLeft = $wnd.document.documentElement.clientLeft; ++ ++ offset -= clientTopOrLeft; ++ } ++ return offset; + } + } catch(e){} + return 0; + }-*/; + + private static int adjustByRelativeLeftBodyMargin() { + if (leftFix == -1) { - leftFix = detectRelativeBodyFixes("left"); ++ boolean ie6OrIe7 = BrowserInfo.get().isIE() ++ && BrowserInfo.get().getIEVersion() <= 7; ++ leftFix = detectRelativeBodyFixes("left", ie6OrIe7); ++ + } + return leftFix; } @Override public void show() { super.show(); -- if (shadow != null) { ++ if (isShadowEnabled()) { if (isAnimationEnabled()) { ShadowAnimation sa = new ShadowAnimation(); sa.run(200); @@@ -179,10 -140,10 +214,18 @@@ Util.runIE7ZeroSizedBodyFix(); } ++ @Override ++ protected void onDetach() { ++ super.onDetach(); ++ ++ // Always ensure shadow is removed when the overlay is removed. ++ removeShadowIfPresent(); ++ } ++ @Override public void setVisible(boolean visible) { super.setVisible(visible); -- if (shadow != null) { ++ if (isShadowEnabled()) { shadow.getStyle().setProperty("visibility", visible ? "visible" : "hidden"); } @@@ -191,17 -152,17 +234,13 @@@ @Override public void setWidth(String width) { super.setWidth(width); -- if (shadow != null) { -- updateShadowSizeAndPosition(1.0); -- } ++ updateShadowSizeAndPosition(1.0); } @Override public void setHeight(String height) { super.setHeight(height); -- if (shadow != null) { -- updateShadowSizeAndPosition(1.0); -- } ++ updateShadowSizeAndPosition(1.0); } /** @@@ -215,7 -176,7 +254,7 @@@ * name=='v-shadow-foobar'. */ protected void setShadowStyle(String style) { -- if (shadow != null) { ++ if (isShadowEnabled()) { shadow.setClassName(CLASSNAME_SHADOW + "-" + style); } } @@@ -241,7 -202,7 +280,7 @@@ */ private void updateShadowSizeAndPosition(final double progress) { // Don't do anything if overlay element is not attached -- if (!isAttached()) { ++ if (!isAttached() || shadow == null) { return; } // Calculate proper z-index @@@ -336,9 -295,9 +375,11 @@@ protected class ShadowAnimation extends Animation { @Override protected void onUpdate(double progress) { -- if (shadow != null) { -- updateShadowSizeAndPosition(progress); -- } ++ updateShadowSizeAndPosition(progress); } } ++ ++ public void onClose(CloseEvent event) { ++ removeShadowIfPresent(); ++ } } diff --cc src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index c1d674a367,0f755c6737..d36c2137d8 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@@ -835,15 -766,8 +835,19 @@@ public class VScrollTable extends FlowP tabIndex = uidl.hasAttribute("tabindex") ? uidl .getIntAttribute("tabindex") : 0; - multiselectmode = uidl.hasAttribute("multiselectmode") ? uidl - .getIntAttribute("multiselectmode") : MULTISELECT_MODE_DEFAULT; + if (!BrowserInfo.get().isTouchDevice()) { + multiselectmode = uidl.hasAttribute("multiselectmode") ? uidl + .getIntAttribute("multiselectmode") + : MULTISELECT_MODE_DEFAULT; + } + + if (uidl.hasAttribute("alb")) { + bodyActionKeys = uidl.getStringArrayAttribute("alb"); ++ } else { ++ // Need to clear the actions if the action handlers have been ++ // removed ++ bodyActionKeys = null; + } setCacheRate(uidl.hasAttribute("cr") ? uidl.getDoubleAttribute("cr") : CACHE_RATE_DEFAULT); diff --cc src/com/vaadin/terminal/gwt/client/ui/VTextField.java index 3df2e356d1,e275d7a9ac..a05cef3984 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java @@@ -12,6 -12,6 +12,9 @@@ import com.google.gwt.event.dom.client. import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; ++import com.google.gwt.event.dom.client.KeyCodes; ++import com.google.gwt.event.dom.client.KeyDownEvent; ++import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@@ -35,7 -34,7 +37,8 @@@ import com.vaadin.terminal.gwt.client.u * */ public class VTextField extends TextBoxBase implements Paintable, Field, -- ChangeHandler, FocusHandler, BlurHandler, BeforeShortcutActionListener { ++ ChangeHandler, FocusHandler, BlurHandler, BeforeShortcutActionListener, ++ KeyDownHandler { public static final String VAR_CUR_TEXT = "curText"; /** @@@ -85,6 -84,6 +88,11 @@@ } setStyleName(CLASSNAME); addChangeHandler(this); ++ if (BrowserInfo.get().isIE()) { ++ // IE does not send change events when pressing enter in a text ++ // input so we handle it using a key listener instead ++ addKeyDownHandler(this); ++ } addFocusHandler(this); addBlurHandler(this); sinkEvents(VTooltip.TOOLTIP_EVENTS); @@@ -590,4 -588,4 +598,10 @@@ } wordwrap = enabled; } ++ ++ public void onKeyDown(KeyDownEvent event) { ++ if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { ++ valueChange(false); ++ } ++ } } diff --cc src/com/vaadin/terminal/gwt/client/ui/VWindow.java index 98ebf73b77,67d90d3564..e2fe47cc2c --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@@ -11,9 -11,9 +11,10 @@@ import java.util.Iterator import java.util.Set; import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; + import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.KeyDownEvent; @@@ -310,14 -292,8 +308,14 @@@ public class VWindow extends VOverlay i if (uidl.getBooleanAttribute("resizable") != resizable) { setResizable(!resizable); } + resizeLazy = uidl.hasAttribute(VView.RESIZE_LAZY); setDraggable(!uidl.hasAttribute("fixedposition")); - } + - if (uidl.hasAttribute("caption")) { - setCaption(uidl.getStringAttribute("caption"), uidl - .getStringAttribute("icon")); ++ // Caption must be set before required header size is measured. If ++ // the caption attribute is missing the caption should be cleared. ++ setCaption(uidl.getStringAttribute("caption"), ++ uidl.getStringAttribute("icon")); } visibilityChangesDisabled = true; @@@ -777,19 -761,20 +775,20 @@@ private void showModalityCurtain() { if (BrowserInfo.get().isFF2()) { - DOM.setStyleAttribute(getModalityCurtain(), "height", DOM - .getElementPropertyInt(RootPanel.getBodyElement(), - "offsetHeight") - + "px"); + DOM.setStyleAttribute( - modalityCurtain, ++ getModalityCurtain(), + "height", + DOM.getElementPropertyInt(RootPanel.getBodyElement(), + "offsetHeight") + "px"); - DOM.setStyleAttribute(modalityCurtain, "position", "absolute"); + DOM.setStyleAttribute(getModalityCurtain(), "position", "absolute"); } - DOM.setStyleAttribute(getModalityCurtain(), "zIndex", "" - + (windowOrder.indexOf(this) + Z_INDEX)); - DOM.setStyleAttribute(modalityCurtain, "zIndex", ++ DOM.setStyleAttribute(getModalityCurtain(), "zIndex", + "" + (windowOrder.indexOf(this) + Z_INDEX)); if (isShowing()) { - RootPanel.getBodyElement().insertBefore(modalityCurtain, + RootPanel.getBodyElement().insertBefore(getModalityCurtain(), getElement()); } else { - DOM.appendChild(RootPanel.getBodyElement(), modalityCurtain); + DOM.appendChild(RootPanel.getBodyElement(), getModalityCurtain()); } } diff --cc src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index cb4ba16f65,e64cd6f243..b4f194c7f7 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@@ -561,15 -542,10 +561,19 @@@ public abstract class AbstractApplicati private void updateBrowserProperties(WebBrowser browser, PortletRequest request) { String userAgent = getHTTPHeader(request, "user-agent"); -- browser.updateBrowserProperties(request.getLocale(), null, -- request.isSecure(), userAgent, -- getHTTPRequestParameter(request, "sw"), - getHTTPRequestParameter(request, "sh"), - getHTTPRequestParameter(request, "tzo"), - getHTTPRequestParameter(request, "rtzo"), - getHTTPRequestParameter(request, "dstd"), - getHTTPRequestParameter(request, "dstActive"), - getHTTPRequestParameter(request, "curdate")); - getHTTPRequestParameter(request, "sh")); ++ browser.updateRequestDetails(request.getLocale(), null, ++ request.isSecure(), userAgent); ++ if (getHTTPRequestParameter(request, "repaintAll") != null) { ++ browser.updateClientSideDetails( ++ getHTTPRequestParameter(request, "sw"), ++ getHTTPRequestParameter(request, "sh"), ++ getHTTPRequestParameter(request, "tzo"), ++ getHTTPRequestParameter(request, "rtzo"), ++ getHTTPRequestParameter(request, "dstd"), ++ getHTTPRequestParameter(request, "dstActive"), ++ getHTTPRequestParameter(request, "curdate"), ++ getHTTPRequestParameter(request, "td") != null); ++ } } @Override diff --cc src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index f274a474dd,d6b6c840db..c394e8ae6a --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@@ -589,12 -571,10 +589,18 @@@ public abstract class AbstractApplicati private void updateBrowserProperties(WebBrowser browser, HttpServletRequest request) { -- browser.updateBrowserProperties(request.getLocale(), ++ // request based details updated always ++ browser.updateRequestDetails(request.getLocale(), request.getRemoteAddr(), request.isSecure(), -- request.getHeader("user-agent"), request.getParameter("sw"), - request.getParameter("sh"), request.getParameter("tzo"), - request.getParameter("rtzo"), request.getParameter("dstd"), - request.getParameter("dston"), request.getParameter("curdate")); - request.getParameter("sh")); ++ request.getHeader("user-agent")); ++ if (request.getParameter("repaintAll") != null) { ++ browser.updateClientSideDetails(request.getParameter("sw"), ++ request.getParameter("sh"), request.getParameter("tzo"), ++ request.getParameter("rtzo"), request.getParameter("dstd"), ++ request.getParameter("dston"), ++ request.getParameter("curdate"), ++ request.getParameter("td") != null); ++ } } protected ClassLoader getClassLoader() throws ServletException { diff --cc src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 152fa81bb5,152fa81bb5..74b7a27a96 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@@ -392,6 -392,6 +392,7 @@@ public abstract class AbstractCommunica int contentLength = request.getContentLength(); boolean atStart = false; ++ boolean firstFileFieldFound = false; String rawfilename = "unknown"; String rawMimeType = "application/octet-stream"; @@@ -410,7 -410,7 +411,8 @@@ rawfilename = rawfilename.substring(1); rawfilename = rawfilename.substring(0, rawfilename.indexOf(parenthesis)); -- } else if (readLine.equals("")) { ++ firstFileFieldFound = true; ++ } else if (firstFileFieldFound && readLine.equals("")) { atStart = true; } else if (readLine.startsWith("Content-Type")) { rawMimeType = readLine.split(": ")[1]; diff --cc src/com/vaadin/terminal/gwt/server/WebBrowser.java index 1b0d7fe986,1d6881a836..4835b3c55b --- a/src/com/vaadin/terminal/gwt/server/WebBrowser.java +++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java @@@ -26,13 -25,8 +26,14 @@@ public class WebBrowser implements Term private Locale locale; private String address; private boolean secureConnection; + private int timezoneOffset = 0; + private int rawTimezoneOffset = 0; + private int dstSavings; + private boolean dstInEffect; - private Date currentDate; ++ private boolean touchDevice; private VBrowserDetails browserDetails; ++ private long clientServerTimeDelta; /** * There is no default-theme for this terminal type. @@@ -70,91 -64,44 +71,6 @@@ return browserApplication; } -- /** -- * For internal use by AbstractApplicationServlet/AbstractApplicationPortlet -- * only. Updates all properties in the class according to the given -- * information. -- * -- * @param locale -- * The browser primary locale -- * @param address -- * The browser ip address -- * @param secureConnection -- * true if using an https connection -- * @param agent -- * Raw userAgent string from the browser -- * @param sw -- * Screen width -- * @param sh -- * Screen height - * @param tzo - * TimeZone offset in minutes from GMT - * @param rtzo - * raw TimeZone offset in minutes from GMT (w/o DST adjustment) - * @param dstSavings - * the difference between the raw TimeZone and DST in minutes - * @param dstInEffect - * is DST currently active in the region or not? - * @param curDate - * the current date in milliseconds since the epoch -- */ -- void updateBrowserProperties(Locale locale, String address, - boolean secureConnection, String agent, String sw, String sh, - String tzo, String rtzo, String dstSavings, String dstInEffect, - String curDate) { - boolean secureConnection, String agent, String sw, String sh) { -- this.locale = locale; -- this.address = address; -- this.secureConnection = secureConnection; -- if (agent != null) { -- browserApplication = agent; -- browserDetails = new VBrowserDetails(agent); -- } -- -- if (sw != null) { -- try { -- screenHeight = Integer.parseInt(sh); -- screenWidth = Integer.parseInt(sw); -- } catch (final NumberFormatException e) { -- screenHeight = screenWidth = 0; - } - } - if (tzo != null) { - try { - // browser->java conversion: min->ms, reverse sign - timezoneOffset = -Integer.parseInt(tzo) * 60 * 1000; - } catch (final NumberFormatException e) { - timezoneOffset = 0; // default gmt+0 - } - } - if (rtzo != null) { - try { - // browser->java conversion: min->ms, reverse sign - rawTimezoneOffset = -Integer.parseInt(rtzo) * 60 * 1000; - } catch (final NumberFormatException e) { - rawTimezoneOffset = 0; // default gmt+0 - } - } - if (dstSavings != null) { - try { - // browser->java conversion: min->ms - this.dstSavings = Integer.parseInt(dstSavings) * 60 * 1000; - } catch (final NumberFormatException e) { - this.dstSavings = 0; // default no savings - } - } - if (dstInEffect != null) { - this.dstInEffect = Boolean.parseBoolean(dstInEffect); - } - if (curDate != null) { - try { - long curTime = Long.parseLong(curDate); - currentDate = new Date(curTime); - } catch (final NumberFormatException e) { - currentDate = new Date(); -- } -- } -- } -- /** * Gets the IP-address of the web browser. If the application is running * inside a portlet, this method will return null. @@@ -309,71 -256,4 +225,179 @@@ return browserDetails.isWindows(); } + /** + * Returns the browser-reported TimeZone offset in milliseconds from GMT. + * This includes possible daylight saving adjustments, to figure out which + * TimeZone the user actually might be in, see + * {@link #getRawTimezoneOffset()}. + * + * @see WebBrowser#getRawTimezoneOffset() + * @return timezone offset in milliseconds, 0 if not available + */ + public Integer getTimezoneOffset() { + return timezoneOffset; + } + + /** + * Returns the browser-reported TimeZone offset in milliseconds from GMT + * ignoring possible daylight saving adjustments that may be in effect in + * the browser. + *

+ * You can use this to figure out which TimeZones the user could actually be + * in by calling {@link TimeZone#getAvailableIDs(int)}. + *

+ *

+ * If {@link #getRawTimezoneOffset()} and {@link #getTimezoneOffset()} + * returns the same value, the browser is either in a zone that does not + * currently have daylight saving time, or in a zone that never has daylight + * saving time. + *

+ * + * @return timezone offset in milliseconds excluding DST, 0 if not available + */ + public Integer getRawTimezoneOffset() { + return rawTimezoneOffset; + } + + /** + * Gets the difference in minutes between the browser's GMT TimeZone and + * DST. + * + * @return the amount of minutes that the TimeZone shifts when DST is in + * effect + */ + public int getDSTSavings() { + return dstSavings; + } + + /** + * Determines whether daylight savings time (DST) is currently in effect in + * the region of the browser or not. + * + * @return true if the browser resides at a location that currently is in + * DST + */ + public boolean isDSTInEffect() { + return dstInEffect; + } + + /** + * Returns the current date and time of the browser. This will not be + * entirely accurate due to varying network latencies, but should provide a - * close-enough value for most cases. ++ * close-enough value for most cases. Also note that the returned Date ++ * object uses servers default time zone, not the clients. + * + * @return the current date and time of the browser. ++ * @see #isDSTInEffect() ++ * @see #getDSTSavings() ++ * @see #getTimezoneOffset() + */ + public Date getCurrentDate() { - return currentDate; ++ return new Date(new Date().getTime() + clientServerTimeDelta); ++ } ++ ++ /** ++ * @return true if the browser is detected to support touch events ++ */ ++ public boolean isTouchDevice() { ++ return touchDevice; ++ } ++ ++ /** ++ * For internal use by AbstractApplicationServlet/AbstractApplicationPortlet ++ * only. Updates all properties in the class according to the given ++ * information. ++ * ++ * @param sw ++ * Screen width ++ * @param sh ++ * Screen height ++ * @param tzo ++ * TimeZone offset in minutes from GMT ++ * @param rtzo ++ * raw TimeZone offset in minutes from GMT (w/o DST adjustment) ++ * @param dstSavings ++ * the difference between the raw TimeZone and DST in minutes ++ * @param dstInEffect ++ * is DST currently active in the region or not? ++ * @param curDate ++ * the current date in milliseconds since the epoch ++ * @param touchDevice ++ */ ++ void updateClientSideDetails(String sw, String sh, String tzo, String rtzo, ++ String dstSavings, String dstInEffect, String curDate, ++ boolean touchDevice) { ++ if (sw != null) { ++ try { ++ screenHeight = Integer.parseInt(sh); ++ screenWidth = Integer.parseInt(sw); ++ } catch (final NumberFormatException e) { ++ screenHeight = screenWidth = 0; ++ } ++ } ++ if (tzo != null) { ++ try { ++ // browser->java conversion: min->ms, reverse sign ++ timezoneOffset = -Integer.parseInt(tzo) * 60 * 1000; ++ } catch (final NumberFormatException e) { ++ timezoneOffset = 0; // default gmt+0 ++ } ++ } ++ if (rtzo != null) { ++ try { ++ // browser->java conversion: min->ms, reverse sign ++ rawTimezoneOffset = -Integer.parseInt(rtzo) * 60 * 1000; ++ } catch (final NumberFormatException e) { ++ rawTimezoneOffset = 0; // default gmt+0 ++ } ++ } ++ if (dstSavings != null) { ++ try { ++ // browser->java conversion: min->ms ++ this.dstSavings = Integer.parseInt(dstSavings) * 60 * 1000; ++ } catch (final NumberFormatException e) { ++ this.dstSavings = 0; // default no savings ++ } ++ } ++ if (dstInEffect != null) { ++ this.dstInEffect = Boolean.parseBoolean(dstInEffect); ++ } ++ if (curDate != null) { ++ try { ++ long curTime = Long.parseLong(curDate); ++ clientServerTimeDelta = curTime - new Date().getTime(); ++ } catch (final NumberFormatException e) { ++ clientServerTimeDelta = 0; ++ } ++ } ++ this.touchDevice = touchDevice; ++ ++ } ++ ++ /** ++ * For internal use by AbstractApplicationServlet/AbstractApplicationPortlet ++ * only. Updates all properties in the class according to the given ++ * information. ++ * ++ * @param locale ++ * The browser primary locale ++ * @param address ++ * The browser ip address ++ * @param secureConnection ++ * true if using an https connection ++ * @param agent ++ * Raw userAgent string from the browser ++ */ ++ void updateRequestDetails(Locale locale, String address, ++ boolean secureConnection, String agent) { ++ this.locale = locale; ++ this.address = address; ++ this.secureConnection = secureConnection; ++ if (agent != null) { ++ browserApplication = agent; ++ browserDetails = new VBrowserDetails(agent); ++ } ++ + } + } diff --cc src/com/vaadin/ui/AbstractOrderedLayout.java index 8dfbe07b18,8dfbe07b18..0b0fff2a34 --- a/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/src/com/vaadin/ui/AbstractOrderedLayout.java @@@ -23,7 -23,7 +23,7 @@@ public abstract class AbstractOrderedLa private static final String CLICK_EVENT = EventId.LAYOUT_CLICK; -- private static final Alignment ALIGNMENT_DEFAULT = Alignment.TOP_LEFT; ++ public static final Alignment ALIGNMENT_DEFAULT = Alignment.TOP_LEFT; /** * Custom layout slots containing the components. diff --cc src/com/vaadin/ui/Button.java index c64cd386ce,cf354750a8..122d155e0f --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@@ -176,15 -175,13 +176,29 @@@ public class Button extends AbstractFie if (newValue != null && !newValue.equals(oldValue) && !isReadOnly()) { setValue(newValue); - fireClick(MouseEventDetails.deSerialize((String) variables - .get("mousedetails"))); - fireClick(); ++ if (variables.containsKey("mousedetails")) { ++ fireClick(MouseEventDetails ++ .deSerialize((String) variables ++ .get("mousedetails"))); ++ } else { ++ // for compatibility with custom implementations which ++ // don't send mouse details ++ fireClick(); ++ } } } else { // Only send click event if the button is pushed if (newValue.booleanValue()) { - fireClick(MouseEventDetails.deSerialize((String) variables - .get("mousedetails"))); - fireClick(); ++ if (variables.containsKey("mousedetails")) { ++ fireClick(MouseEventDetails ++ .deSerialize((String) variables ++ .get("mousedetails"))); ++ } else { ++ // for compatibility with custom implementations which ++ // don't send mouse details ++ fireClick(); ++ } } // If the button is true for some reason, release it @@@ -298,8 -300,6 +312,8 @@@ */ public class ClickEvent extends Component.Event { - private MouseEventDetails details; ++ private final MouseEventDetails details; + /** * New instance of text change event. * @@@ -308,19 -308,6 +322,20 @@@ */ public ClickEvent(Component source) { super(source); ++ details = null; + } + + /** + * Constructor with mouse details + * + * @param source + * The source where the click took place + * @param details + * Details about the mouse click + */ + public ClickEvent(Component source, MouseEventDetails details) { + super(source); + this.details = details; } /** @@@ -331,87 -318,6 +346,120 @@@ public Button getButton() { return (Button) getSource(); } + + /** + * Returns the mouse position (x coordinate) when the click took place. + * The position is relative to the browser client area. + * - * @return The mouse cursor x position ++ * @return The mouse cursor x position or -1 if unknown + */ + public int getClientX() { - return details.getClientX(); ++ if (null != details) { ++ return details.getClientX(); ++ } else { ++ return -1; ++ } + } + + /** + * Returns the mouse position (y coordinate) when the click took place. + * The position is relative to the browser client area. + * - * @return The mouse cursor y position ++ * @return The mouse cursor y position or -1 if unknown + */ + public int getClientY() { - return details.getClientY(); ++ if (null != details) { ++ return details.getClientY(); ++ } else { ++ return -1; ++ } + } + + /** + * Returns the relative mouse position (x coordinate) when the click + * took place. The position is relative to the clicked component. + * + * @return The mouse cursor x position relative to the clicked layout + * component or -1 if no x coordinate available + */ + public int getRelativeX() { - return details.getRelativeX(); ++ if (null != details) { ++ return details.getRelativeX(); ++ } else { ++ return -1; ++ } + } + + /** + * Returns the relative mouse position (y coordinate) when the click + * took place. The position is relative to the clicked component. + * + * @return The mouse cursor y position relative to the clicked layout + * component or -1 if no y coordinate available + */ + public int getRelativeY() { - return details.getRelativeY(); ++ if (null != details) { ++ return details.getRelativeY(); ++ } else { ++ return -1; ++ } + } + + /** + * Checks if the Alt key was down when the mouse event took place. + * + * @return true if Alt was down when the event occured, false otherwise ++ * or if unknown + */ + public boolean isAltKey() { - return details.isAltKey(); ++ if (null != details) { ++ return details.isAltKey(); ++ } else { ++ return false; ++ } + } + + /** + * Checks if the Ctrl key was down when the mouse event took place. + * + * @return true if Ctrl was pressed when the event occured, false - * otherwise ++ * otherwise or if unknown + */ + public boolean isCtrlKey() { - return details.isCtrlKey(); ++ if (null != details) { ++ return details.isCtrlKey(); ++ } else { ++ return false; ++ } + } + + /** + * Checks if the Meta key was down when the mouse event took place. + * + * @return true if Meta was pressed when the event occured, false - * otherwise ++ * otherwise or if unknown + */ + public boolean isMetaKey() { - return details.isMetaKey(); ++ if (null != details) { ++ return details.isMetaKey(); ++ } else { ++ return false; ++ } + } + + /** + * Checks if the Shift key was down when the mouse event took place. + * + * @return true if Shift was pressed when the event occured, false - * otherwise ++ * otherwise or if unknown + */ + public boolean isShiftKey() { - return details.isShiftKey(); ++ if (null != details) { ++ return details.isShiftKey(); ++ } else { ++ return false; ++ } + } } /** @@@ -457,16 -362,12 +505,28 @@@ } /** -- * Emits the options change event. ++ * Fires a click event to all listeners without any event details. ++ * ++ * In subclasses, override {@link #fireClick(MouseEventDetails)} instead of ++ * this method. */ protected void fireClick() { fireEvent(new Button.ClickEvent(this)); } - private void fireClick(MouseEventDetails details) { ++ /** ++ * Fires a click event to all listeners. ++ * ++ * @param details ++ * MouseEventDetails from which keyboard modifiers and other ++ * information about the mouse click can be obtained. If the ++ * button was clicked by a keyboard event, some of the fields may ++ * be empty/undefined. ++ */ ++ protected void fireClick(MouseEventDetails details) { + fireEvent(new Button.ClickEvent(this, details)); + } + @Override protected void setInternalValue(Object newValue) { // Make sure only booleans get through diff --cc src/com/vaadin/ui/MenuBar.java index d79e070fca,b7da82675e..f8fbf91712 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@@ -123,7 -119,7 +123,12 @@@ public class MenuBar extends AbstractCo if (description != null && description.length() > 0) { target.addAttribute("description", description); } -- ++ if (item.isCheckable()) { ++ // if the "checked" attribute is present (either true or false), ++ // the item is checkable ++ target.addAttribute(VMenuBar.ATTRIBUTE_CHECKED, ++ item.isChecked()); ++ } if (item.hasChildren()) { for (MenuItem child : item.getChildren()) { paintItem(target, child); @@@ -167,7 -163,7 +172,12 @@@ // If we got the clicked item, launch the command. if (found && tmpItem.isEnabled()) { -- tmpItem.getCommand().menuSelected(tmpItem); ++ if (tmpItem.isCheckable()) { ++ tmpItem.setChecked(!tmpItem.isChecked()); ++ } ++ if (null != tmpItem.getCommand()) { ++ tmpItem.getCommand().menuSelected(tmpItem); ++ } } }// if }// changeVariables @@@ -431,6 -396,6 +441,8 @@@ private boolean isSeparator = false; private String styleName; private String description; ++ private boolean checkable = false; ++ private boolean checked = false; /** * Constructs a new menu item that can optionally have an icon and a @@@ -505,13 -470,13 +517,19 @@@ * the icon for the menu item * @param command * the command for the menu item ++ * @throws IllegalStateException ++ * If the item is checkable and thus cannot have children. */ public MenuBar.MenuItem addItem(String caption, Resource icon, -- MenuBar.Command command) { ++ MenuBar.Command command) throws IllegalStateException { if (isSeparator()) { throw new UnsupportedOperationException( "Cannot add items to a separator"); } ++ if (isCheckable()) { ++ throw new IllegalStateException( ++ "A checkable item cannot have children"); ++ } if (caption == null) { throw new IllegalArgumentException("Caption cannot be null"); } @@@ -544,11 -509,11 +562,16 @@@ * the command for the menu item * @param itemToAddBefore * the item that will be after the new item -- * ++ * @throws IllegalStateException ++ * If the item is checkable and thus cannot have children. */ public MenuBar.MenuItem addItemBefore(String caption, Resource icon, -- MenuBar.Command command, MenuBar.MenuItem itemToAddBefore) { -- ++ MenuBar.Command command, MenuBar.MenuItem itemToAddBefore) ++ throws IllegalStateException { ++ if (isCheckable()) { ++ throw new IllegalStateException( ++ "A checkable item cannot have children"); ++ } MenuItem newItem = null; if (hasChildren() && itsChildren.contains(itemToAddBefore)) { @@@ -814,6 -779,6 +837,93 @@@ return description; } ++ /** ++ * Gets the checkable state of the item - whether the item has checked ++ * and unchecked states. If an item is checkable its checked state (as ++ * returned by {@link #isChecked()}) is indicated in the UI. ++ * ++ *

++ * An item is not checkable by default. ++ *

++ * ++ * @return true if the item is checkable, false otherwise ++ * @since 6.6.2 ++ */ ++ public boolean isCheckable() { ++ return checkable; ++ } ++ ++ /** ++ * Sets the checkable state of the item. If an item is checkable its ++ * checked state (as returned by {@link #isChecked()}) is indicated in ++ * the UI. ++ * ++ *

++ * An item is not checkable by default. ++ *

++ * ++ *

++ * Items with sub items cannot be checkable. ++ *

++ * ++ * @param checkable ++ * true if the item should be checkable, false otherwise ++ * @throws IllegalStateException ++ * If the item has children ++ * @since 6.6.2 ++ */ ++ public void setCheckable(boolean checkable) ++ throws IllegalStateException { ++ if (hasChildren()) { ++ throw new IllegalStateException( ++ "A menu item with children cannot be checkable"); ++ } ++ this.checkable = checkable; ++ requestRepaint(); ++ } ++ ++ /** ++ * Gets the checked state of the item (checked or unchecked). Only used ++ * if the item is checkable (as indicated by {@link #isCheckable()}). ++ * The checked state is indicated in the UI with the item, if the item ++ * is checkable. ++ * ++ *

++ * An item is not checked by default. ++ *

++ * ++ *

++ * The CSS style corresponding to the checked state is "-checked". ++ *

++ * ++ * @return true if the item is checked, false otherwise ++ * @since 6.6.2 ++ */ ++ public boolean isChecked() { ++ return checked; ++ } ++ ++ /** ++ * Sets the checked state of the item. Only used if the item is ++ * checkable (indicated by {@link #isCheckable()}). The checked state is ++ * indicated in the UI with the item, if the item is checkable. ++ * ++ *

++ * An item is not checked by default. ++ *

++ * ++ *

++ * The CSS style corresponding to the checked state is "-checked". ++ *

++ * ++ * @return true if the item is checked, false otherwise ++ * @since 6.6.2 ++ */ ++ public void setChecked(boolean checked) { ++ this.checked = checked; ++ requestRepaint(); ++ } ++ }// class MenuItem }// class MenuBar diff --cc tests/src/com/vaadin/tests/components/LongTooltip.html index 0000000000,0000000000..ac317380b8 new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/LongTooltip.html @@@ -1,0 -1,0 +1,325 @@@ ++ ++ ++ ++ ++ ++ ++New Test ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
New Test
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-right-1
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-right-2
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-right-3
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-right-1
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-right-2
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-right-3
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-left-1
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-left-2
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-left-3
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-left-1
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-left-2
mouseOutvaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-left-3
++ ++ diff --cc tests/src/com/vaadin/tests/components/LongTooltip.java index 0000000000,0000000000..87adaa673b new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/LongTooltip.java @@@ -1,0 -1,0 +1,49 @@@ ++package com.vaadin.tests.components; ++ ++import com.vaadin.tests.util.LoremIpsum; ++import com.vaadin.ui.Alignment; ++import com.vaadin.ui.GridLayout; ++import com.vaadin.ui.TextField; ++ ++public class LongTooltip extends TestBase { ++ ++ @Override ++ public void setup() { ++ ++ GridLayout gl = new GridLayout(2, 2); ++ gl.setSizeFull(); ++ TextField f1 = createField(); ++ TextField f2 = createField(); ++ TextField f3 = createField(); ++ TextField f4 = createField(); ++ gl.addComponent(f1); ++ gl.addComponent(f2); ++ gl.addComponent(f3); ++ gl.addComponent(f4); ++ ++ gl.setComponentAlignment(f1, Alignment.TOP_LEFT); ++ gl.setComponentAlignment(f2, Alignment.TOP_RIGHT); ++ gl.setComponentAlignment(f3, Alignment.BOTTOM_LEFT); ++ gl.setComponentAlignment(f4, Alignment.BOTTOM_RIGHT); ++ ++ getLayout().setSizeFull(); ++ getLayout().addComponent(gl); ++ ++ } ++ ++ private TextField createField() { ++ final TextField field = new TextField(); ++ field.setDescription(LoremIpsum.get(1000)); ++ return field; ++ } ++ ++ @Override ++ protected String getDescription() { ++ return "For a given cursor position the tooltip should always appear with the same size in the same position. The tooltip should also always be completely on screen and not cause any scrollbars to appear."; ++ } ++ ++ @Override ++ protected Integer getTicketNumber() { ++ return 7100; ++ } ++} diff --cc tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java index 48212b2fdc,48212b2fdc..387ec7857f --- a/tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java +++ b/tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java @@@ -21,7 -21,7 +21,8 @@@ public class AccordionInactiveTabSize e @Override protected void setup() { HorizontalSplitPanel sp = new HorizontalSplitPanel(); -- sp.setSizeFull(); ++ sp.setWidth("100%"); ++ sp.setHeight("70px"); Accordion acc = new Accordion(); diff --cc tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.html index a398f7a17c,a398f7a17c..cab8bbc996 --- a/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.html +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.html @@@ -54,7 -54,7 +54,7 @@@ screenCapture -- combo should have ds1-3 text ++ combo-should-have-ds1-3-text click diff --cc tests/src/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.html index 0000000000,0000000000..ae0dfec828 new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.html @@@ -1,0 -1,0 +1,85 @@@ ++ ++ open ++ /run/com.vaadin.tests.components.combobox.ComboBoxUndefinedWidthAndIcon?restartApplication ++ ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]/domChild[1] ++ 13,14 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item1 ++ 32,5 ++ ++ ++ screenCapture ++ ++ item1-selected ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]/domChild[2] ++ 12,5 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0] ++ 81,6 ++ ++ ++ screenCapture ++ ++ page2 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0] ++ 78,6 ++ ++ ++ screenCapture ++ ++ page3 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0] ++ 78,6 ++ ++ ++ screenCapture ++ ++ page4 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item3 ++ 68,8 ++ ++ ++ screenCapture ++ ++ item33-selected ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]/domChild[2] ++ 8,7 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0] ++ 116,3 ++ ++ ++ mouseClick ++ vaadin=runcomvaadintestscomponentscomboboxComboBoxUndefinedWidthAndIcon:: ++ 338,241 ++ ++ ++ screenCapture ++ ++ item33-selected-after-popup-opened-and-closed ++ diff --cc tests/src/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java index 0000000000,0000000000..fd5f7d47f8 new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java @@@ -1,0 -1,0 +1,36 @@@ ++package com.vaadin.tests.components.combobox; ++ ++import com.vaadin.data.Item; ++import com.vaadin.terminal.Resource; ++import com.vaadin.terminal.ThemeResource; ++import com.vaadin.tests.components.TestBase; ++import com.vaadin.ui.ComboBox; ++ ++public class ComboBoxUndefinedWidthAndIcon extends TestBase { ++ @Override ++ protected void setup() { ++ ComboBox cb = new ComboBox(); ++ cb.addContainerProperty("caption", String.class, null); ++ cb.addContainerProperty("icon", Resource.class, null); ++ for (int i = 1; i < 200 + 1; i++) { ++ Item item = cb.addItem(i); ++ item.getItemProperty("caption").setValue("Item " + i); ++ item.getItemProperty("icon").setValue( ++ new ThemeResource("../runo/icons/16/users.png")); ++ } ++ cb.setItemIconPropertyId("icon"); ++ cb.setItemCaptionPropertyId("caption"); ++ ++ addComponent(cb); ++ } ++ ++ @Override ++ protected String getDescription() { ++ return "The width of the ComboBox should be fixed even though it is set to undefined width. The width should not change when changing pages in the dropdown."; ++ } ++ ++ @Override ++ protected Integer getTicketNumber() { ++ return 7013; ++ } ++} diff --cc tests/src/com/vaadin/tests/components/menubar/MenuBarItemsCheckable.html index 0000000000,0000000000..ebdfa81f20 new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarItemsCheckable.html @@@ -1,0 -1,0 +1,141 @@@ ++ ++ ++ ++ ++ ++ ++MenuBarItemsCheckable ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
MenuBarItemsCheckable
open/run/com.vaadin.tests.components.menubar.MenuBarTest?restartApplication
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::PID_Smenu#item130,7
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[0]/VMenuBar[0]#item027,3
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::PID_Smenu#item043,12
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[0]/VMenuBar[0]#item547,9
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[1]/VMenuBar[0]#item448,5
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[2]/VMenuBar[0]#item290,11
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::PID_Smenu#item013,1
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[0]/VMenuBar[0]#item547,3
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[1]/VMenuBar[0]#item026,4
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[2]/VMenuBar[0]#item339,7
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::PID_Smenu#item023,9
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[0]/VMenuBar[0]#item236,6
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[1]/VMenuBar[0]#item027,7
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[2]/VMenuBar[0]#item223,3
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::PID_StestComponent#item051,10
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[0]/VMenuBar[0]#item051,10
pause3000
screenCapturesubmenu-1-1-checkable-items
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[1]/VMenuBar[0]#item051,10
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::PID_StestComponent#item051,10
mouseClickvaadin=runcomvaadintestscomponentsmenubarMenuBarTest::Root/VOverlay[0]/VMenuBar[0]#item051,10
screenCapturesubmenu-1-1-checked-items
++ ++ diff --cc tests/src/com/vaadin/tests/components/menubar/MenuBarTest.java index 31121a8d37,1b11c24f78..e41652126d --- a/tests/src/com/vaadin/tests/components/menubar/MenuBarTest.java +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarTest.java @@@ -24,6 -23,6 +24,7 @@@ public class MenuBarTest extends Abstra private Integer iconSize; private Integer disabledDensity; private Integer invisibleDensity; ++ private Integer checkableDensity; @Override protected Class getTestClass() { @@@ -46,6 -42,6 +47,7 @@@ createMenuIconsSizeSelect(CATEGORY_MENU_ITEM_STATES); createMenuItemDisabledDensitySelect(CATEGORY_MENU_ITEM_STATES); createMenuItemInvisibleDensitySelect(CATEGORY_MENU_ITEM_STATES); ++ createMenuItemCheckableDensitySelect(CATEGORY_MENU_ITEM_STATES); } @@@ -125,6 -121,6 +127,17 @@@ setMenuItemInvisibleDensity); } ++ private void createMenuItemCheckableDensitySelect(String category) { ++ LinkedHashMap options = new LinkedHashMap(); ++ options.put("No items checkable", null); ++ options.put("All checkable", 1); ++ options.put("Every second", 2); ++ options.put("Every third", 3); ++ ++ createSelectAction("Checkable", category, options, ++ "No items checkable", setMenuItemCheckableDensity); ++ } ++ /* COMMANDS */ Command createRootMenuItems = new Command() { @@@ -181,6 -177,6 +194,14 @@@ } }; ++ private Command setMenuItemCheckableDensity = new Command() { ++ ++ public void execute(MenuBar c, Integer value, Object data) { ++ checkableDensity = value; ++ createRootItems(c); ++ } ++ }; ++ private Command setSubMenuSeparatorDensity = new Command() { public void execute(MenuBar c, Integer value, Object data) { @@@ -250,6 -237,6 +271,11 @@@ subMenuItem.setCommand(null); createSubItems(subMenuItem, level + 1); } ++ ++ if (!subMenuItem.hasChildren() && level > 0 ++ && checkableDensity != null && i % checkableDensity == 0) { ++ subMenuItem.setCheckable(true); ++ } } } diff --cc tests/src/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.html index edbdd72258,edbdd72258..eb40765d03 --- a/tests/src/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.html +++ b/tests/src/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.html @@@ -39,7 -39,7 +39,7 @@@ screenCapture -- click-287,25 ++ click-287-25 mouseClick diff --cc tests/src/com/vaadin/tests/components/panel/PanelTest.java index 0000000000,0000000000..29d93ce86c new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/panel/PanelTest.java @@@ -1,0 -1,0 +1,15 @@@ ++package com.vaadin.tests.components.panel; ++ ++import com.vaadin.tests.components.AbstractComponentContainerTest; ++import com.vaadin.ui.Panel; ++ ++public class PanelTest extends ++ AbstractComponentContainerTest { ++ ++ @SuppressWarnings("unchecked") ++ @Override ++ protected Class getTestClass() { ++ return (Class) Panel.class; ++ } ++ ++} diff --cc tests/src/com/vaadin/tests/components/slider/SliderTest.java index 9b6d964f44,9b6d964f44..65a2fdd1b5 --- a/tests/src/com/vaadin/tests/components/slider/SliderTest.java +++ b/tests/src/com/vaadin/tests/components/slider/SliderTest.java @@@ -55,7 -55,7 +55,7 @@@ public class SliderTest extends Abstrac LinkedHashMap options = new LinkedHashMap(); options.put("Horizontal", Slider.ORIENTATION_HORIZONTAL); options.put("Vertical", Slider.ORIENTATION_VERTICAL); -- createSelectAction("Resolution", category, options, "Horizontal", ++ createSelectAction("Orientation", category, options, "Horizontal", orientationCommand); } diff --cc tests/src/com/vaadin/tests/components/table/TableRemoveActionHandlers.html index 0000000000,0000000000..a363f6980e new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableRemoveActionHandlers.html @@@ -1,0 -1,0 +1,161 @@@ ++ ++ ++ ++ ++ ++ ++New Test ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item025,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item550,2
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item186,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item553,6
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item021,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item861,1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item268,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item569,12
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]
assertVisiblevaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option0
assertTextvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option0Edit Item 1
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option052,12
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]
assertVisiblevaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option0
assertTextvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option0New...
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option035,12
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item020,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item867,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item271,7
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item016,3
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]
assertElementNotPresent//div[@id='PID_VAADIN_CM']
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]
assertElementNotPresent//div[@id='PID_VAADIN_CM']
++ ++ diff --cc tests/src/com/vaadin/tests/components/window/SubWindowOrder.html index a8030a9604,a8030a9604..c59e831582 --- a/tests/src/com/vaadin/tests/components/window/SubWindowOrder.html +++ b/tests/src/com/vaadin/tests/components/window/SubWindowOrder.html @@@ -29,7 -29,7 +29,7 @@@ screenCapture -- dialog1 should be on top ++ dialog1-should-be-on-top mouseClick @@@ -44,7 -44,7 +44,7 @@@ screenCapture -- dialog 3 modal ++ dialog-3-modal mouseClick @@@ -84,7 -84,7 +84,7 @@@ screenCapture -- window5closed window 5 modal ++ window5closed-window-5-modal mouseClick @@@ -129,7 -129,7 +129,7 @@@ screenCapture -- window2 on top of window1, others closed ++ window2-on-top-of-window1-others-closed diff --cc tests/src/com/vaadin/tests/components/window/SubWindows-runo.html index 2109a53273,2109a53273..5cbd350174 --- a/tests/src/com/vaadin/tests/components/window/SubWindows-runo.html +++ b/tests/src/com/vaadin/tests/components/window/SubWindows-runo.html @@@ -54,7 -54,7 +54,7 @@@ screenCapture -- add+2 remove ++ add+2-remove click @@@ -79,7 -79,7 +79,7 @@@ screenCapture -- add-button only ++ add-button-only diff --cc tests/src/com/vaadin/tests/components/window/SubWindows.html index 7279a10b9c,7279a10b9c..3b2109e3f1 --- a/tests/src/com/vaadin/tests/components/window/SubWindows.html +++ b/tests/src/com/vaadin/tests/components/window/SubWindows.html @@@ -54,7 -54,7 +54,7 @@@ screenCapture -- add+2 remove ++ add+2-remove click @@@ -79,7 -79,7 +79,7 @@@ screenCapture -- add-button only ++ add-button-only diff --cc tests/src/com/vaadin/tests/components/window/WindowCaptionTest.html index 0000000000,0000000000..83889aedb8 new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/WindowCaptionTest.html @@@ -1,0 -1,0 +1,77 @@@ ++ ++ ++ ++ ++ ++ ++New Test ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
New Test
open/run/com.vaadin.tests.components.window.WindowTest?restartApplication
assertTextvaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Short
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::PID_Smenu#item052,19
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::Root/VOverlay[0]/VMenuBar[0]#item185,4
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::Root/VOverlay[1]/VMenuBar[0]#item267,9
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::Root/VOverlay[2]/VMenuBar[0]#item223,11
assertTextvaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]This is a semi-long text that might wrap.
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::PID_Smenu#item052,19
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::Root/VOverlay[0]/VMenuBar[0]#item185,4
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::Root/VOverlay[1]/VMenuBar[0]#item267,9
mouseClickvaadin=runcomvaadintestscomponentswindowWindowTest::Root/VOverlay[2]/VMenuBar[0]#item023,11
assertTextvaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]
++ ++ diff --cc tests/src/com/vaadin/tests/components/window/WindowTest.java index 0000000000,0000000000..ae3b0f22df new file mode 100644 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/WindowTest.java @@@ -1,0 -1,0 +1,19 @@@ ++package com.vaadin.tests.components.window; ++ ++import com.vaadin.tests.components.panel.PanelTest; ++import com.vaadin.ui.Window; ++ ++public class WindowTest extends PanelTest { ++ ++ @Override ++ protected Class getTestClass() { ++ return Window.class; ++ } ++ ++ @Override ++ protected void addTestComponent(Window c) { ++ getMainWindow().addWindow(c); ++ getTestComponents().add(c); ++ } ++ ++} diff --cc tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java index 67ad4fe45f,67ad4fe45f..5ca8194646 --- a/tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java +++ b/tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java @@@ -1,5 -1,5 +1,7 @@@ package com.vaadin.tests.server.container; ++import com.vaadin.data.Container.Filter; ++import com.vaadin.data.Item; import com.vaadin.data.util.HierarchicalContainer; public class TestHierarchicalContainer extends @@@ -29,6 -29,6 +31,69 @@@ testContainerSortingAndFiltering(new HierarchicalContainer()); } ++ public void testRemovingItemsFromFilteredContainer() { ++ HierarchicalContainer container = new HierarchicalContainer(); ++ initializeContainer(container); ++ container.setIncludeParentsWhenFiltering(true); ++ container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false); ++ Object p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertEquals("com.vaadin.ui", p1); ++ ++ container.removeItem("com.vaadin.ui.TabSheet"); ++ // Parent for the removed item must be null because the item is no ++ // longer in the container ++ p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertNull("Parent should be null, is " + p1, p1); ++ ++ container.removeAllItems(); ++ p1 = container.getParent("com.vaadin.terminal.gwt.client.Focusable"); ++ assertNull("Parent should be null, is " + p1, p1); ++ ++ } ++ ++ public void testParentWhenRemovingFilterFromContainer() { ++ HierarchicalContainer container = new HierarchicalContainer(); ++ initializeContainer(container); ++ container.setIncludeParentsWhenFiltering(true); ++ container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false); ++ Object p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertEquals("com.vaadin.ui", p1); ++ p1 = container ++ .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar"); ++ assertNull(p1); ++ container.removeAllContainerFilters(); ++ p1 = container ++ .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar"); ++ assertEquals("com.vaadin.terminal.gwt.client.ui", p1); ++ ++ } ++ ++ public void testChangeParentInFilteredContainer() { ++ HierarchicalContainer container = new HierarchicalContainer(); ++ initializeContainer(container); ++ container.setIncludeParentsWhenFiltering(true); ++ container.addContainerFilter(FULLY_QUALIFIED_NAME, "Tab", false, false); ++ ++ // Change parent of filtered item ++ Object p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertEquals("com.vaadin.ui", p1); ++ container.setParent("com.vaadin.ui.TabSheet", "com.vaadin"); ++ p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertEquals("com.vaadin", p1); ++ container.setParent("com.vaadin.ui.TabSheet", "com"); ++ p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertEquals("com", p1); ++ container.setParent("com.vaadin.ui.TabSheet", null); ++ p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertNull(p1); ++ ++ // root -> non-root ++ container.setParent("com.vaadin.ui.TabSheet", "com"); ++ p1 = container.getParent("com.vaadin.ui.TabSheet"); ++ assertEquals("com", p1); ++ ++ } ++ public void testHierarchicalFilteringWithParents() { HierarchicalContainer container = new HierarchicalContainer(); initializeContainer(container); @@@ -80,6 -80,6 +145,55 @@@ } ++ public void testRemoveLastChild() { ++ HierarchicalContainer c = new HierarchicalContainer(); ++ ++ c.addItem("root"); ++ assertEquals(false, c.hasChildren("root")); ++ ++ c.addItem("child"); ++ c.setParent("child", "root"); ++ assertEquals(true, c.hasChildren("root")); ++ ++ c.removeItem("child"); ++ assertFalse(c.containsId("child")); ++ assertNull(c.getChildren("root")); ++ assertNull(c.getChildren("child")); ++ assertFalse(c.hasChildren("child")); ++ assertFalse(c.hasChildren("root")); ++ } ++ ++ public void testRemoveLastChildFromFiltered() { ++ HierarchicalContainer c = new HierarchicalContainer(); ++ ++ c.addItem("root"); ++ assertEquals(false, c.hasChildren("root")); ++ ++ c.addItem("child"); ++ c.setParent("child", "root"); ++ assertEquals(true, c.hasChildren("root")); ++ ++ // Dummy filter that does not remove any items ++ c.addContainerFilter(new Filter() { ++ ++ public boolean passesFilter(Object itemId, Item item) ++ throws UnsupportedOperationException { ++ return true; ++ } ++ ++ public boolean appliesToProperty(Object propertyId) { ++ return true; ++ } ++ }); ++ c.removeItem("child"); ++ ++ assertFalse(c.containsId("child")); ++ assertNull(c.getChildren("root")); ++ assertNull(c.getChildren("child")); ++ assertFalse(c.hasChildren("child")); ++ assertFalse(c.hasChildren("root")); ++ } ++ public void testHierarchicalFilteringWithoutParents() { HierarchicalContainer container = new HierarchicalContainer();