From 780c5d6be068cad400e39df6d6b3f5b533d0366c Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 12 Apr 2012 15:22:21 +0000 Subject: Fixed #8653: addTab(index) should not throw if index is out of bounds svn changeset:23503/svn branch:6.8 --- src/com/vaadin/ui/TabSheet.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index cb89c5e0c8..334c4c886b 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -569,14 +569,15 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * * @param position * the position of the tab - * @return + * @return The tab in the given position, or null if the position is out of + * bounds. */ public Tab getTab(int position) { - Component c = components.get(position); - if (c != null) { - return tabs.get(c); + if (position >= 0 && position < getComponentCount()) { + return getTab(components.get(position)); + } else { + return null; } - return null; } /** -- cgit v1.2.3 From 6a1c4b4b348112a2f176403780b0e4dd6160df91 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 12 Apr 2012 15:26:30 +0000 Subject: #8203 Improved javadoc, added null check svn changeset:23504/svn branch:6.8 --- src/com/vaadin/ui/TabSheet.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index 334c4c886b..09d1002b48 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -557,7 +557,8 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * * @param c * the component - * @return + * @return The tab instance associated with the given component, or null if + * the tabsheet does not contain the component. */ public Tab getTab(Component c) { return tabs.get(c); @@ -603,17 +604,19 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, * @param tab */ public void setSelectedTab(Tab tab) { - setSelectedTab(tab.getComponent()); + if (tab != null) { + setSelectedTab(tab.getComponent()); + } } /** - * Sets the selected tab, identified by its position. Does nothing if - * index < 0 || index > {@link #getComponentCount()}. + * Sets the selected tab, identified by its position. Does nothing if the + * position is out of bounds. * - * @param index + * @param position */ - public void setSelectedTab(int index) { - setSelectedTab(getTab(index)); + public void setSelectedTab(int position) { + setSelectedTab(getTab(position)); } /** -- cgit v1.2.3 From 1e07642a6f7931855ccfc54560369a10ce4ff0df Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 13 Apr 2012 08:17:48 +0000 Subject: Blocked merge of revisions related to 6.7.7 release svn changeset:23522/svn branch:6.8 --- .../vaadin/terminal/gwt/client/BrowserInfo.java | 15 +++++-- .../vaadin/terminal/gwt/client/VDebugConsole.java | 13 +++--- .../gwt/client/ui/TouchScrollDelegate.java | 8 +++- src/com/vaadin/terminal/gwt/client/ui/VPanel.java | 51 ++++++++++++++++++---- .../terminal/gwt/client/ui/VScrollTable.java | 14 +++--- .../vaadin/terminal/gwt/client/ui/VSplitPanel.java | 21 +++++---- .../terminal/gwt/client/ui/VTabsheetPanel.java | 36 ++++++++------- .../abstractfield/RemoveListenersOnDetach.java | 22 +++++++--- 8 files changed, 124 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index 844b4f2e96..4434e9471e 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -68,12 +68,12 @@ public class BrowserInfo { } if (browserDetails.isChrome()) { - touchDevice = detectChromeTouchDevice(); + touchDevice = detectChromeTouchDevice(); } else { - touchDevice = detectTouchDevice(); + touchDevice = detectTouchDevice(); } } - + private native boolean detectTouchDevice() /*-{ try { document.createEvent("TouchEvent");return true;} catch(e){return false;}; @@ -409,4 +409,13 @@ public class BrowserInfo { return touchDevice; } + /** + * @return true if browser needs TouchScrollDelegate javascript scrolling + * handler + */ + public boolean requiresTouchScrollDelegate() { + return !(isTouchDevice() && isWebkit() && getWebkitVersion() >= 534 && getBrowserString() + .contains("Android")); + } + } diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java index c43581b000..27479559b2 100644 --- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java +++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java @@ -14,7 +14,6 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.dom.client.Style.Overflow; -import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -291,10 +290,10 @@ public class VDebugConsole extends VOverlay implements Console { height = Integer.parseInt(split[3]); autoScrollValue = Boolean.valueOf(split[4]); } else { - width = 400; - height = 150; - top = Window.getClientHeight() - 160; - left = Window.getClientWidth() - 410; + width = 500; + height = 500; + top = Window.getClientHeight() - 510; + left = Window.getClientWidth() - 510; } setPixelSize(width, height); setPopupPosition(left, top); @@ -637,7 +636,7 @@ public class VDebugConsole extends VOverlay implements Console { actions = new HorizontalPanel(); Style style = actions.getElement().getStyle(); - style.setPosition(Position.ABSOLUTE); + // style.setPosition(Position.ABSOLUTE); style.setBackgroundColor("#666"); style.setLeft(135, Unit.PX); style.setHeight(25, Unit.PX); @@ -670,7 +669,7 @@ public class VDebugConsole extends VOverlay implements Console { private void addHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.setParameter("gwt.codesvr", - "localhost:9997"); + Location.getHostName() + ":9997"); Location.assign(createUrlBuilder.buildString()); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java b/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java index 3c08741de5..4242178440 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java +++ b/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java @@ -119,7 +119,7 @@ public class TouchScrollDelegate implements NativePreviewHandler { Touch touch = event.getTouches().get(0); if (detectScrolledElement(touch)) { - VConsole.log("TouchDelegate takes over"); + VConsole.log("
TouchDelegate takes over"); event.stopPropagation(); handlerRegistration = Event.addNativePreviewHandler(this); activeScrollDelegate = this; @@ -166,6 +166,7 @@ public class TouchScrollDelegate implements NativePreviewHandler { }-*/; private void onTransitionEnd() { + VConsole.log("transitionEnd"); if (finalScrollTop < 0) { animateToScrollPosition(0, finalScrollTop); finalScrollTop = 0; @@ -310,11 +311,13 @@ public class TouchScrollDelegate implements NativePreviewHandler { private void onTouchEnd(NativeEvent event) { if (!moved) { + VConsole.log("TouchEnd - not moved"); activeScrollDelegate = null; handlerRegistration.removeHandler(); handlerRegistration = null; return; } + VConsole.log("TouchEnd - moved"); int currentY = origScrollTop + deltaScrollPos; @@ -412,6 +415,7 @@ public class TouchScrollDelegate implements NativePreviewHandler { * @param translateY */ private void translateTo(int duration, int translateY) { + // VConsole.log("translateTo " + duration + "ms " + translateY + "px"); for (Element el : layers) { final Style style = el.getStyle(); if (duration > 0) { @@ -441,6 +445,8 @@ public class TouchScrollDelegate implements NativePreviewHandler { } public void onPreviewNativeEvent(NativePreviewEvent event) { + VConsole.log("previewNativeEvent " + + Integer.toHexString(event.getTypeInt())); if (transitionOn) { /* * TODO allow starting new events. See issue in onTouchStart diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java index 036f4f0600..de40001636 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java @@ -9,10 +9,10 @@ import java.util.Set; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.DomEvent.Type; -import com.google.gwt.event.dom.client.TouchStartEvent; -import com.google.gwt.event.dom.client.TouchStartHandler; +import com.google.gwt.event.dom.client.TouchEvent; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.touch.client.TouchScroller; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -92,6 +92,36 @@ public class VPanel extends SimplePanel implements Container, }; private TouchScrollDelegate touchScrollDelegate; + private TouchScroller touchScroller = new TouchScroller() { + @Override + protected void onTouchStart(TouchEvent event) { + if (event.getEventTarget() == contentNode) { + super.onTouchStart(event); + } + } + + @Override + protected void onTouchMove(TouchEvent event) { + if (event.getSource() == contentNode) { + super.onTouchMove(event); + } + } + + @Override + protected void onTouchEnd(TouchEvent event) { + if (event.getSource() == contentNode) { + super.onTouchEnd(event); + } + } + + @Override + protected void onTouchCancel(TouchEvent event) { + if (event.getSource() == contentNode) { + super.onTouchCancel(event); + } + } + }; + public VPanel() { super(); DivElement captionWrap = Document.get().createDivElement(); @@ -117,14 +147,19 @@ public class VPanel extends SimplePanel implements Container, getElement().appendChild(bottomDecoration); setStyleName(CLASSNAME); DOM.sinkEvents(getElement(), Event.ONKEYDOWN); - DOM.sinkEvents(contentNode, Event.ONSCROLL | Event.TOUCHEVENTS); + DOM.sinkEvents(contentNode, Event.ONSCROLL); contentNode.getStyle().setProperty("position", "relative"); getElement().getStyle().setProperty("overflow", "hidden"); - addHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - getTouchScrollDelegate().onTouchStart(event); - } - }, TouchStartEvent.getType()); + + // if (BrowserInfo.get().requiresTouchScrollDelegate()) { + // + // DOM.sinkEvents(contentNode, Event.TOUCHEVENTS); + // addHandler(new TouchStartHandler() { + // public void onTouchStart(TouchStartEvent event) { + // getTouchScrollDelegate().onTouchStart(event); + // } + // }, TouchStartEvent.getType()); + // } } /** diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 43908d474a..8203f909aa 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -485,12 +485,14 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } scrollBodyPanel.addKeyUpHandler(navKeyUpHandler); - scrollBodyPanel.sinkEvents(Event.TOUCHEVENTS); - scrollBodyPanel.addDomHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - getTouchScrollDelegate().onTouchStart(event); - } - }, TouchStartEvent.getType()); + if (BrowserInfo.get().requiresTouchScrollDelegate()) { + scrollBodyPanel.sinkEvents(Event.TOUCHEVENTS); + scrollBodyPanel.addDomHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + getTouchScrollDelegate().onTouchStart(event); + } + }, TouchStartEvent.getType()); + } scrollBodyPanel.sinkEvents(Event.ONCONTEXTMENU); scrollBodyPanel.addDomHandler(new ContextMenuHandler() { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index 51e378cc0c..61595c8e1d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -181,17 +181,20 @@ public class VSplitPanel extends ComplexPanel implements Container, VConsole.log("TOUCH CANCEL"); } }, TouchCancelEvent.getType()); - addDomHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - Node target = event.getTouches().get(0).getTarget().cast(); - if (splitter.isOrHasChild(target)) { - onMouseDown(Event.as(event.getNativeEvent())); - } else { - getTouchScrollDelegate().onTouchStart(event); + + if (BrowserInfo.get().requiresTouchScrollDelegate()) { + addDomHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + Node target = event.getTouches().get(0).getTarget().cast(); + if (splitter.isOrHasChild(target)) { + onMouseDown(Event.as(event.getNativeEvent())); + } else { + getTouchScrollDelegate().onTouchStart(event); + } } - } - }, TouchStartEvent.getType()); + }, TouchStartEvent.getType()); + } addDomHandler(new TouchMoveHandler() { public void onTouchMove(TouchMoveEvent event) { if (resizing) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java index 126b0ebea1..6c8fb942f8 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java @@ -13,6 +13,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.Util; /** @@ -34,23 +35,26 @@ public class VTabsheetPanel extends ComplexPanel { */ public VTabsheetPanel() { setElement(DOM.createDiv()); - sinkEvents(Event.TOUCHEVENTS); - addDomHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - /* - * All container elements needs to be scrollable by one finger. - * Update the scrollable element list of touch delegate on each - * touch start. - */ - NodeList childNodes = getElement().getChildNodes(); - Element[] elements = new Element[childNodes.getLength()]; - for (int i = 0; i < elements.length; i++) { - elements[i] = (Element) childNodes.getItem(i); + + if (BrowserInfo.get().requiresTouchScrollDelegate()) { + sinkEvents(Event.TOUCHEVENTS); + addDomHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + /* + * All container elements needs to be scrollable by one + * finger. Update the scrollable element list of touch + * delegate on each touch start. + */ + NodeList childNodes = getElement().getChildNodes(); + Element[] elements = new Element[childNodes.getLength()]; + for (int i = 0; i < elements.length; i++) { + elements[i] = (Element) childNodes.getItem(i); + } + getTouchScrollDelegate().setElements(elements); + getTouchScrollDelegate().onTouchStart(event); } - getTouchScrollDelegate().setElements(elements); - getTouchScrollDelegate().onTouchStart(event); - } - }, TouchStartEvent.getType()); + }, TouchStartEvent.getType()); + } } protected TouchScrollDelegate getTouchScrollDelegate() { diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index 32b80e0bcd..c5bd688b3d 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -16,7 +16,7 @@ public class RemoveListenersOnDetach { AbstractField field = new AbstractField() { @Override public Class getType() { - return null; + return int.class; } @Override @@ -34,17 +34,20 @@ public class RemoveListenersOnDetach { }; Property property = new AbstractProperty() { + private int value; + public Object getValue() { - return null; + return value; } public void setValue(Object newValue) throws ReadOnlyException, ConversionException { + value = (Integer) newValue; fireValueChange(); } public Class getType() { - return null; + return int.class; } }; @@ -52,21 +55,28 @@ public class RemoveListenersOnDetach { public void testAttachDetach() { field.setPropertyDataSource(property); - property.setValue(null); + property.setValue(1); property.setReadOnly(true); + assertEquals(1, field.getValue()); assertEquals(1, numValueChanges); assertEquals(1, numReadOnlyChanges); field.attach(); - property.setValue(null); + property.setValue(2); property.setReadOnly(false); + assertEquals(2, field.getValue()); assertEquals(2, numValueChanges); assertEquals(2, numReadOnlyChanges); field.detach(); - property.setValue(null); + property.setValue(3); property.setReadOnly(true); + assertEquals(3, field.getValue()); assertEquals(2, numValueChanges); assertEquals(2, numReadOnlyChanges); + + field.attach(); + assertEquals(3, field.getValue()); + assertEquals(3, numValueChanges); } } -- cgit v1.2.3 From ed20ba59aa3adb63118a3d6cd6ae986c4902793c Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 13 Apr 2012 08:26:32 +0000 Subject: Reverted accidental commit svn changeset:23523/svn branch:6.8 --- .../vaadin/terminal/gwt/client/BrowserInfo.java | 15 ++----- .../vaadin/terminal/gwt/client/VDebugConsole.java | 13 +++--- .../gwt/client/ui/TouchScrollDelegate.java | 8 +--- src/com/vaadin/terminal/gwt/client/ui/VPanel.java | 51 ++++------------------ .../terminal/gwt/client/ui/VScrollTable.java | 14 +++--- .../vaadin/terminal/gwt/client/ui/VSplitPanel.java | 21 ++++----- .../terminal/gwt/client/ui/VTabsheetPanel.java | 36 +++++++-------- .../abstractfield/RemoveListenersOnDetach.java | 22 +++------- 8 files changed, 56 insertions(+), 124 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java index 4434e9471e..844b4f2e96 100644 --- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java +++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java @@ -68,12 +68,12 @@ public class BrowserInfo { } if (browserDetails.isChrome()) { - touchDevice = detectChromeTouchDevice(); + touchDevice = detectChromeTouchDevice(); } else { - touchDevice = detectTouchDevice(); + touchDevice = detectTouchDevice(); } } - + private native boolean detectTouchDevice() /*-{ try { document.createEvent("TouchEvent");return true;} catch(e){return false;}; @@ -409,13 +409,4 @@ public class BrowserInfo { return touchDevice; } - /** - * @return true if browser needs TouchScrollDelegate javascript scrolling - * handler - */ - public boolean requiresTouchScrollDelegate() { - return !(isTouchDevice() && isWebkit() && getWebkitVersion() >= 534 && getBrowserString() - .contains("Android")); - } - } diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java index 27479559b2..c43581b000 100644 --- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java +++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java @@ -14,6 +14,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.dom.client.Style.Overflow; +import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -290,10 +291,10 @@ public class VDebugConsole extends VOverlay implements Console { height = Integer.parseInt(split[3]); autoScrollValue = Boolean.valueOf(split[4]); } else { - width = 500; - height = 500; - top = Window.getClientHeight() - 510; - left = Window.getClientWidth() - 510; + width = 400; + height = 150; + top = Window.getClientHeight() - 160; + left = Window.getClientWidth() - 410; } setPixelSize(width, height); setPopupPosition(left, top); @@ -636,7 +637,7 @@ public class VDebugConsole extends VOverlay implements Console { actions = new HorizontalPanel(); Style style = actions.getElement().getStyle(); - // style.setPosition(Position.ABSOLUTE); + style.setPosition(Position.ABSOLUTE); style.setBackgroundColor("#666"); style.setLeft(135, Unit.PX); style.setHeight(25, Unit.PX); @@ -669,7 +670,7 @@ public class VDebugConsole extends VOverlay implements Console { private void addHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.setParameter("gwt.codesvr", - Location.getHostName() + ":9997"); + "localhost:9997"); Location.assign(createUrlBuilder.buildString()); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java b/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java index 4242178440..3c08741de5 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java +++ b/src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java @@ -119,7 +119,7 @@ public class TouchScrollDelegate implements NativePreviewHandler { Touch touch = event.getTouches().get(0); if (detectScrolledElement(touch)) { - VConsole.log("
TouchDelegate takes over"); + VConsole.log("TouchDelegate takes over"); event.stopPropagation(); handlerRegistration = Event.addNativePreviewHandler(this); activeScrollDelegate = this; @@ -166,7 +166,6 @@ public class TouchScrollDelegate implements NativePreviewHandler { }-*/; private void onTransitionEnd() { - VConsole.log("transitionEnd"); if (finalScrollTop < 0) { animateToScrollPosition(0, finalScrollTop); finalScrollTop = 0; @@ -311,13 +310,11 @@ public class TouchScrollDelegate implements NativePreviewHandler { private void onTouchEnd(NativeEvent event) { if (!moved) { - VConsole.log("TouchEnd - not moved"); activeScrollDelegate = null; handlerRegistration.removeHandler(); handlerRegistration = null; return; } - VConsole.log("TouchEnd - moved"); int currentY = origScrollTop + deltaScrollPos; @@ -415,7 +412,6 @@ public class TouchScrollDelegate implements NativePreviewHandler { * @param translateY */ private void translateTo(int duration, int translateY) { - // VConsole.log("translateTo " + duration + "ms " + translateY + "px"); for (Element el : layers) { final Style style = el.getStyle(); if (duration > 0) { @@ -445,8 +441,6 @@ public class TouchScrollDelegate implements NativePreviewHandler { } public void onPreviewNativeEvent(NativePreviewEvent event) { - VConsole.log("previewNativeEvent " - + Integer.toHexString(event.getTypeInt())); if (transitionOn) { /* * TODO allow starting new events. See issue in onTouchStart diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java index de40001636..036f4f0600 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java @@ -9,10 +9,10 @@ import java.util.Set; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.DomEvent.Type; -import com.google.gwt.event.dom.client.TouchEvent; +import com.google.gwt.event.dom.client.TouchStartEvent; +import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.touch.client.TouchScroller; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -92,36 +92,6 @@ public class VPanel extends SimplePanel implements Container, }; private TouchScrollDelegate touchScrollDelegate; - private TouchScroller touchScroller = new TouchScroller() { - @Override - protected void onTouchStart(TouchEvent event) { - if (event.getEventTarget() == contentNode) { - super.onTouchStart(event); - } - } - - @Override - protected void onTouchMove(TouchEvent event) { - if (event.getSource() == contentNode) { - super.onTouchMove(event); - } - } - - @Override - protected void onTouchEnd(TouchEvent event) { - if (event.getSource() == contentNode) { - super.onTouchEnd(event); - } - } - - @Override - protected void onTouchCancel(TouchEvent event) { - if (event.getSource() == contentNode) { - super.onTouchCancel(event); - } - } - }; - public VPanel() { super(); DivElement captionWrap = Document.get().createDivElement(); @@ -147,19 +117,14 @@ public class VPanel extends SimplePanel implements Container, getElement().appendChild(bottomDecoration); setStyleName(CLASSNAME); DOM.sinkEvents(getElement(), Event.ONKEYDOWN); - DOM.sinkEvents(contentNode, Event.ONSCROLL); + DOM.sinkEvents(contentNode, Event.ONSCROLL | Event.TOUCHEVENTS); contentNode.getStyle().setProperty("position", "relative"); getElement().getStyle().setProperty("overflow", "hidden"); - - // if (BrowserInfo.get().requiresTouchScrollDelegate()) { - // - // DOM.sinkEvents(contentNode, Event.TOUCHEVENTS); - // addHandler(new TouchStartHandler() { - // public void onTouchStart(TouchStartEvent event) { - // getTouchScrollDelegate().onTouchStart(event); - // } - // }, TouchStartEvent.getType()); - // } + addHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + getTouchScrollDelegate().onTouchStart(event); + } + }, TouchStartEvent.getType()); } /** diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 8203f909aa..43908d474a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -485,14 +485,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } scrollBodyPanel.addKeyUpHandler(navKeyUpHandler); - if (BrowserInfo.get().requiresTouchScrollDelegate()) { - scrollBodyPanel.sinkEvents(Event.TOUCHEVENTS); - scrollBodyPanel.addDomHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - getTouchScrollDelegate().onTouchStart(event); - } - }, TouchStartEvent.getType()); - } + scrollBodyPanel.sinkEvents(Event.TOUCHEVENTS); + scrollBodyPanel.addDomHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + getTouchScrollDelegate().onTouchStart(event); + } + }, TouchStartEvent.getType()); scrollBodyPanel.sinkEvents(Event.ONCONTEXTMENU); scrollBodyPanel.addDomHandler(new ContextMenuHandler() { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index 61595c8e1d..51e378cc0c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -181,20 +181,17 @@ public class VSplitPanel extends ComplexPanel implements Container, VConsole.log("TOUCH CANCEL"); } }, TouchCancelEvent.getType()); - - if (BrowserInfo.get().requiresTouchScrollDelegate()) { - addDomHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - Node target = event.getTouches().get(0).getTarget().cast(); - if (splitter.isOrHasChild(target)) { - onMouseDown(Event.as(event.getNativeEvent())); - } else { - getTouchScrollDelegate().onTouchStart(event); - } + addDomHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + Node target = event.getTouches().get(0).getTarget().cast(); + if (splitter.isOrHasChild(target)) { + onMouseDown(Event.as(event.getNativeEvent())); + } else { + getTouchScrollDelegate().onTouchStart(event); } + } - }, TouchStartEvent.getType()); - } + }, TouchStartEvent.getType()); addDomHandler(new TouchMoveHandler() { public void onTouchMove(TouchMoveEvent event) { if (resizing) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java index 6c8fb942f8..126b0ebea1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java @@ -13,7 +13,6 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.ComplexPanel; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.Util; /** @@ -35,26 +34,23 @@ public class VTabsheetPanel extends ComplexPanel { */ public VTabsheetPanel() { setElement(DOM.createDiv()); - - if (BrowserInfo.get().requiresTouchScrollDelegate()) { - sinkEvents(Event.TOUCHEVENTS); - addDomHandler(new TouchStartHandler() { - public void onTouchStart(TouchStartEvent event) { - /* - * All container elements needs to be scrollable by one - * finger. Update the scrollable element list of touch - * delegate on each touch start. - */ - NodeList childNodes = getElement().getChildNodes(); - Element[] elements = new Element[childNodes.getLength()]; - for (int i = 0; i < elements.length; i++) { - elements[i] = (Element) childNodes.getItem(i); - } - getTouchScrollDelegate().setElements(elements); - getTouchScrollDelegate().onTouchStart(event); + sinkEvents(Event.TOUCHEVENTS); + addDomHandler(new TouchStartHandler() { + public void onTouchStart(TouchStartEvent event) { + /* + * All container elements needs to be scrollable by one finger. + * Update the scrollable element list of touch delegate on each + * touch start. + */ + NodeList childNodes = getElement().getChildNodes(); + Element[] elements = new Element[childNodes.getLength()]; + for (int i = 0; i < elements.length; i++) { + elements[i] = (Element) childNodes.getItem(i); } - }, TouchStartEvent.getType()); - } + getTouchScrollDelegate().setElements(elements); + getTouchScrollDelegate().onTouchStart(event); + } + }, TouchStartEvent.getType()); } protected TouchScrollDelegate getTouchScrollDelegate() { diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index c5bd688b3d..32b80e0bcd 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -16,7 +16,7 @@ public class RemoveListenersOnDetach { AbstractField field = new AbstractField() { @Override public Class getType() { - return int.class; + return null; } @Override @@ -34,20 +34,17 @@ public class RemoveListenersOnDetach { }; Property property = new AbstractProperty() { - private int value; - public Object getValue() { - return value; + return null; } public void setValue(Object newValue) throws ReadOnlyException, ConversionException { - value = (Integer) newValue; fireValueChange(); } public Class getType() { - return int.class; + return null; } }; @@ -55,28 +52,21 @@ public class RemoveListenersOnDetach { public void testAttachDetach() { field.setPropertyDataSource(property); - property.setValue(1); + property.setValue(null); property.setReadOnly(true); - assertEquals(1, field.getValue()); assertEquals(1, numValueChanges); assertEquals(1, numReadOnlyChanges); field.attach(); - property.setValue(2); + property.setValue(null); property.setReadOnly(false); - assertEquals(2, field.getValue()); assertEquals(2, numValueChanges); assertEquals(2, numReadOnlyChanges); field.detach(); - property.setValue(3); + property.setValue(null); property.setReadOnly(true); - assertEquals(3, field.getValue()); assertEquals(2, numValueChanges); assertEquals(2, numReadOnlyChanges); - - field.attach(); - assertEquals(3, field.getValue()); - assertEquals(3, numValueChanges); } } -- cgit v1.2.3 From f87be1cf342b23cf048b5c0e77559be3d7eed2b3 Mon Sep 17 00:00:00 2001 From: Automerge Date: Fri, 13 Apr 2012 09:13:41 +0000 Subject: [merge from 6.7] VConsole.error() instead of throwing in startRequest() and endRequest() sanity checks svn changeset:23527/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ApplicationConnection.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index a452cfff2d..7a3a28495a 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -738,8 +738,7 @@ public class ApplicationConnection { protected void startRequest() { if (hasActiveRequest) { - throw new IllegalStateException( - "Trying to start a new request while another is active"); + VConsole.error("Trying to start a new request while another is active"); } hasActiveRequest = true; requestStartTime = new Date(); @@ -766,7 +765,7 @@ public class ApplicationConnection { protected void endRequest() { if (!hasActiveRequest) { - throw new IllegalStateException("No active request"); + VConsole.error("No active request"); } // After checkForPendingVariableBursts() there may be a new active // request, so we must set hasActiveRequest to false before, not after, -- cgit v1.2.3 From 1cf2e8e1bf024cdc60c3b06f08cf249bca95ebc8 Mon Sep 17 00:00:00 2001 From: Automerge Date: Fri, 13 Apr 2012 09:13:47 +0000 Subject: [merge from 6.7] Fixed #8639: Table context menu was broken on touch devices svn changeset:23528/svn branch:6.8 --- .../terminal/gwt/client/ui/VScrollTable.java | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 43908d474a..a28aebae68 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -5229,21 +5229,24 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, public void run() { TouchScrollDelegate activeScrollDelegate = TouchScrollDelegate .getActiveScrollDelegate(); - if (activeScrollDelegate != null - && !activeScrollDelegate.isMoved()) { - /* - * scrolling hasn't started. Cancel - * scrolling and let row handle this as - * drag start or context menu. - */ - activeScrollDelegate.stopScrolling(); - } else { - /* - * Scrolled or scrolling, clear touch - * start to indicate that row shouldn't - * handle touch move/end events. - */ - touchStart = null; + if (activeScrollDelegate != null) { + if (!activeScrollDelegate.isMoved()) { + /* + * scrolling hasn't started. Cancel + * scrolling and let row handle this + * as drag start or context menu. + */ + activeScrollDelegate + .stopScrolling(); + } else { + /* + * Scrolled or scrolling, clear + * touch start to indicate that row + * shouldn't handle touch move/end + * events. + */ + touchStart = null; + } } } }.schedule(TOUCHSCROLL_TIMEOUT); -- cgit v1.2.3 From c5095d2981e34cd857c04767a2fcf3a8b5c7f309 Mon Sep 17 00:00:00 2001 From: Automerge Date: Fri, 13 Apr 2012 09:13:52 +0000 Subject: [merge from 6.7] #8639 Improved comments svn changeset:23529/svn branch:6.8 --- .../terminal/gwt/client/ui/VScrollTable.java | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index a28aebae68..ee33f33758 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -5229,23 +5229,32 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, public void run() { TouchScrollDelegate activeScrollDelegate = TouchScrollDelegate .getActiveScrollDelegate(); + /* + * If there's a scroll delegate, check if + * we're actually scrolling and handle it. + * If no delegate, do nothing here and let + * the row handle potential drag'n'drop or + * context menu. + */ if (activeScrollDelegate != null) { - if (!activeScrollDelegate.isMoved()) { + if (activeScrollDelegate.isMoved()) { /* - * scrolling hasn't started. Cancel - * scrolling and let row handle this - * as drag start or context menu. + * Prevent the row from handling + * touch move/end events (the + * delegate handles those) and from + * doing drag'n'drop or opening a + * context menu. */ - activeScrollDelegate - .stopScrolling(); + touchStart = null; } else { /* - * Scrolled or scrolling, clear - * touch start to indicate that row - * shouldn't handle touch move/end - * events. + * Scrolling hasn't started, so + * cancel delegate and let the row + * handle potential drag'n'drop or + * context menu. */ - touchStart = null; + activeScrollDelegate + .stopScrolling(); } } } -- cgit v1.2.3 From c3e10ebbbc48d124a88d6e92e16faccdebe43223 Mon Sep 17 00:00:00 2001 From: Automerge Date: Tue, 17 Apr 2012 17:06:08 +0000 Subject: [merge from 6.7] Reverted #7607 fixes and removed the test for now because they cause the #8662 regression. svn changeset:23566/svn branch:6.8 --- .../terminal/gwt/client/ui/VScrollTable.java | 15 ++++-- src/com/vaadin/ui/Table.java | 11 ++-- .../table/SetCurrentPageFirstItemId.html | 62 ---------------------- 3 files changed, 19 insertions(+), 69 deletions(-) delete mode 100644 tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index ee33f33758..6bbc2a6ceb 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -2065,9 +2065,18 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, isNewBody = false; if (firstvisible > 0) { - scrollBodyPanel - .setScrollPosition(measureRowHeightOffset(firstvisible)); - firstRowInViewPort = firstvisible; + // FIXME #7607 + // Originally deferred due to Firefox oddities which should not + // occur any more. Currently deferring breaks Webkit scrolling with + // relative-height tables, but not deferring instead breaks tables + // with explicit page length. + Scheduler.get().scheduleDeferred(new Command() { + public void execute() { + scrollBodyPanel + .setScrollPosition(measureRowHeightOffset(firstvisible)); + firstRowInViewPort = firstvisible; + } + }); } if (enabled) { diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 88961e610a..e605ec4f6b 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -1261,11 +1261,14 @@ public class Table extends AbstractSelect implements Action.Container, maxIndex = 0; } - // Assume that we want to scroll to the very bottom (so that the bottom - // row is completely visible even if (table height) / (row height) is - // not an integer.) + /* + * FIXME #7607 Take somehow into account the case where we want to + * scroll to the bottom so that the last row is completely visible even + * if (table height) / (row height) is not an integer. Reverted the + * original fix because of #8662 regression. + */ if (newIndex > maxIndex) { - newIndex = maxIndex + 1; + newIndex = maxIndex; } // Refresh first item id diff --git a/tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html b/tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html deleted file mode 100644 index 8881c0d2f5..0000000000 --- a/tests/testbench/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - -SetCurrentPageFirstItemId - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SetCurrentPageFirstItemId
open/run/SetCurrentPageFirstItemId?restartApplication
clickvaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
pause300
assertTextvaadin=runSetCurrentPageFirstItemId::/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[24]/domChild[0]/domChild[0]24
screenCapturescrolled-to-bottom
- - -- cgit v1.2.3