summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-05-11 14:26:52 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-05-11 14:26:52 +0000
commitf560e8e20bdcc8035d17c494d31d961d440a60c2 (patch)
tree13fbc380fcaccc3cbebfd1f17a20d73357d409d8
parent239aad4885931b6e7913ca4c86409b7b6997642f (diff)
downloadvaadin-framework-f560e8e20bdcc8035d17c494d31d961d440a60c2.tar.gz
vaadin-framework-f560e8e20bdcc8035d17c494d31d961d440a60c2.zip
#8725 Use TouchScrollDelegate.enableTouchScrolling() instead of TouchScrollDelegate instance directly; rewrite CSS class handling a bit to prevent overwriting v-scrollable
svn changeset:23719/svn branch:6.8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java72
1 files changed, 23 insertions, 49 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
index 51e378cc0c..173bd02151 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
@@ -122,7 +122,7 @@ public class VSplitPanel extends ComplexPanel implements Container,
private boolean positionReversed = false;
- private String[] componentStyleNames;
+ private String[] componentStyleNames = new String[0];
private Element draggingCurtain;
@@ -150,8 +150,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
protected int origScrollTop;
- private TouchScrollDelegate touchScrollDelegate;
-
public VSplitPanel() {
this(ORIENTATION_HORIZONTAL);
}
@@ -175,6 +173,9 @@ public class VSplitPanel extends ComplexPanel implements Container,
setOrientation(orientation);
sinkEvents(Event.MOUSEEVENTS);
+ TouchScrollDelegate.enableTouchScrolling(this, firstContainer,
+ secondContainer);
+
addDomHandler(new TouchCancelHandler() {
public void onTouchCancel(TouchCancelEvent event) {
// TODO When does this actually happen??
@@ -186,11 +187,8 @@ public class VSplitPanel extends ComplexPanel implements Container,
Node target = event.getTouches().get(0).getTarget().cast();
if (splitter.isOrHasChild(target)) {
onMouseDown(Event.as(event.getNativeEvent()));
- } else {
- getTouchScrollDelegate().onTouchStart(event);
}
}
-
}, TouchStartEvent.getType());
addDomHandler(new TouchMoveHandler() {
public void onTouchMove(TouchMoveEvent event) {
@@ -209,14 +207,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
}
- private TouchScrollDelegate getTouchScrollDelegate() {
- if (touchScrollDelegate == null) {
- touchScrollDelegate = new TouchScrollDelegate(firstContainer,
- secondContainer);
- }
- return touchScrollDelegate;
- }
-
protected void constructDom() {
DOM.appendChild(splitter, DOM.createDiv()); // for styling
DOM.appendChild(getElement(), wrapper);
@@ -231,9 +221,7 @@ public class VSplitPanel extends ComplexPanel implements Container,
DOM.setStyleAttribute(splitter, "position", "absolute");
DOM.setStyleAttribute(secondContainer, "position", "absolute");
- DOM.setStyleAttribute(firstContainer, "overflow", "auto");
- DOM.setStyleAttribute(secondContainer, "overflow", "auto");
-
+ setStylenames();
}
private void setOrientation(int orientation) {
@@ -249,11 +237,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
DOM.setStyleAttribute(firstContainer, "width", "100%");
DOM.setStyleAttribute(secondContainer, "width", "100%");
}
-
- DOM.setElementProperty(firstContainer, "className", CLASSNAME
- + "-first-container");
- DOM.setElementProperty(secondContainer, "className", CLASSNAME
- + "-second-container");
}
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
@@ -320,7 +303,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
client.runDescendentsLayout(this);
rendering = false;
-
}
@Override
@@ -475,7 +457,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
// fixes scrollbars issues on webkit based browsers
Util.runWebkitOverflowAutoFix(secondContainer);
Util.runWebkitOverflowAutoFix(firstContainer);
-
}
private void setFirstWidget(Widget w) {
@@ -815,31 +796,24 @@ public class VSplitPanel extends ComplexPanel implements Container,
}
private void setStylenames() {
- final String splitterSuffix = (orientation == ORIENTATION_HORIZONTAL ? "-hsplitter"
- : "-vsplitter");
- final String firstContainerSuffix = "-first-container";
- final String secondContainerSuffix = "-second-container";
- String lockedSuffix = "";
-
- String splitterStyle = CLASSNAME + splitterSuffix;
- String firstStyle = CLASSNAME + firstContainerSuffix;
- String secondStyle = CLASSNAME + secondContainerSuffix;
-
- if (locked) {
- splitterStyle = CLASSNAME + splitterSuffix + "-locked";
- lockedSuffix = "-locked";
- }
- for (int i = 0; i < componentStyleNames.length; i++) {
- splitterStyle += " " + CLASSNAME + splitterSuffix + "-"
- + componentStyleNames[i] + lockedSuffix;
- firstStyle += " " + CLASSNAME + firstContainerSuffix + "-"
- + componentStyleNames[i];
- secondStyle += " " + CLASSNAME + secondContainerSuffix + "-"
- + componentStyleNames[i];
- }
- DOM.setElementProperty(splitter, "className", splitterStyle);
- DOM.setElementProperty(firstContainer, "className", firstStyle);
- DOM.setElementProperty(secondContainer, "className", secondStyle);
+ final String splitterClass = CLASSNAME
+ + (orientation == ORIENTATION_HORIZONTAL ? "-hsplitter"
+ : "-vsplitter");
+ final String firstContainerClass = CLASSNAME + "-first-container";
+ final String secondContainerClass = CLASSNAME + "-second-container";
+ final String lockedSuffix = locked ? "-locked" : "";
+
+ splitter.addClassName(splitterClass);
+ firstContainer.addClassName(firstContainerClass);
+ secondContainer.addClassName(secondContainerClass);
+
+ for (String styleName : componentStyleNames) {
+ splitter.addClassName(splitterClass + "-" + styleName
+ + lockedSuffix);
+ firstContainer.addClassName(firstContainerClass + "-" + styleName);
+ secondContainer
+ .addClassName(secondContainerClass + "-" + styleName);
+ }
}
public void setEnabled(boolean enabled) {