svn changeset:23522/svn branch:6.8tags/7.0.0.alpha2
@@ -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")); | |||
} | |||
} |
@@ -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()); | |||
} | |||
@@ -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 |
@@ -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()); | |||
// } | |||
} | |||
/** |
@@ -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() { |
@@ -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) { |
@@ -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() { |
@@ -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); | |||
} | |||
} |