summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-04-13 08:17:48 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-04-13 08:17:48 +0000
commit1e07642a6f7931855ccfc54560369a10ce4ff0df (patch)
treea4d09298d359fe4e4466ddf3f84c032b94d752c5
parent97cc8e525a3c691093168fba7129e91b62e3b7b6 (diff)
downloadvaadin-framework-1e07642a6f7931855ccfc54560369a10ce4ff0df.tar.gz
vaadin-framework-1e07642a6f7931855ccfc54560369a10ce4ff0df.zip
Blocked merge of revisions related to 6.7.7 release
svn changeset:23522/svn branch:6.8
-rw-r--r--src/com/vaadin/terminal/gwt/client/BrowserInfo.java15
-rw-r--r--src/com/vaadin/terminal/gwt/client/VDebugConsole.java13
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/TouchScrollDelegate.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPanel.java51
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java14
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java21
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheetPanel.java36
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java22
8 files changed, 124 insertions, 56 deletions
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("<hr>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<Node> 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<Node> 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);
}
}