summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-04-10 22:54:17 +0300
committerArtur Signell <artur@vaadin.com>2012-04-10 22:54:17 +0300
commit0e693b208afad7af3eb2a63ec78edb988a18456a (patch)
treecc2fd919a4e1ae00a281a01f851b6734299ff71d
parent64f452f0aa3c3f104e363ac4d39cf62a8a832445 (diff)
parent7691b19584d06dd78fc094bb23cfe10df8ad2cde (diff)
downloadvaadin-framework-0e693b208afad7af3eb2a63ec78edb988a18456a.tar.gz
vaadin-framework-0e693b208afad7af3eb2a63ec78edb988a18456a.zip
Merge remote-tracking branch 'origin/6.8'
Conflicts: src/com/vaadin/terminal/gwt/client/ui/VAbstractSplitPanel.java src/com/vaadin/ui/AbstractSplitPanel.java
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/AbstractSplitPanelConnector.java21
-rw-r--r--src/com/vaadin/ui/AbstractSplitPanel.java28
2 files changed, 30 insertions, 19 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractSplitPanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractSplitPanelConnector.java
index 3942cc2471..59c524bd1f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/AbstractSplitPanelConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractSplitPanelConnector.java
@@ -36,7 +36,7 @@ public abstract class AbstractSplitPanelConnector extends
* The new position in % if the current unit is %, in px
* otherwise
*/
- public void setSplitterPosition(int position);
+ public void setSplitterPosition(float position);
/**
* Called when a click event has occurred on the splitter.
@@ -49,16 +49,16 @@ public abstract class AbstractSplitPanelConnector extends
}
public static class SplitterState {
- private int position;
+ private float position;
private String positionUnit;
- private boolean positionReversed;
- private boolean locked;
+ private boolean positionReversed = false;
+ private boolean locked = false;
- public int getPosition() {
+ public float getPosition() {
return position;
}
- public void setPosition(int position) {
+ public void setPosition(float position) {
this.position = position;
}
@@ -140,10 +140,13 @@ public abstract class AbstractSplitPanelConnector extends
public void splitterMoved(SplitterMoveEvent event) {
String position = getWidget().getSplitterPosition();
- int pos = 0;
+ float pos = 0;
if (position.indexOf("%") > 0) {
- pos = Math.round(Float.valueOf(position.substring(0,
- position.length() - 1)));
+ // Send % values as a fraction to avoid that the splitter
+ // "jumps" when server responds with the integer pct value
+ // (e.g. dragged 16.6% -> should not jump to 17%)
+ pos = Float.valueOf(position.substring(0,
+ position.length() - 1));
} else {
pos = Integer.parseInt(position.substring(0,
position.length() - 2));
diff --git a/src/com/vaadin/ui/AbstractSplitPanel.java b/src/com/vaadin/ui/AbstractSplitPanel.java
index 3ab80444c2..166467ca24 100644
--- a/src/com/vaadin/ui/AbstractSplitPanel.java
+++ b/src/com/vaadin/ui/AbstractSplitPanel.java
@@ -40,7 +40,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
mouseDetails));
}
- public void setSplitterPosition(int position) {
+ public void setSplitterPosition(float position) {
getState().getSplitterState().setPosition(position);
}
};
@@ -241,9 +241,10 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
*
* @param pos
* the new size of the first region in the unit that was last
- * used (default is percentage)
+ * used (default is percentage). Fractions are only allowed when
+ * unit is percentage.
*/
- public void setSplitPosition(int pos) {
+ public void setSplitPosition(float pos) {
setSplitPosition(pos, posUnit, false);
}
@@ -252,12 +253,14 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
*
* @param pos
* the new size of the region in the unit that was last used
- * (default is percentage)
+ * (default is percentage). Fractions are only allowed when unit
+ * is percentage.
+ *
* @param reverse
* if set to true the split splitter position is measured by the
* second region else it is measured by the first region
*/
- public void setSplitPosition(int pos, boolean reverse) {
+ public void setSplitPosition(float pos, boolean reverse) {
setSplitPosition(pos, posUnit, reverse);
}
@@ -265,11 +268,12 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* Moves the position of the splitter with given position and unit.
*
* @param pos
- * size of the first region
+ * the new size of the first region. Fractions are only allowed
+ * when unit is percentage.
* @param unit
* the unit (from {@link Sizeable}) in which the size is given.
*/
- public void setSplitPosition(int pos, Unit unit) {
+ public void setSplitPosition(float pos, Unit unit) {
setSplitPosition(pos, unit, false);
}
@@ -277,7 +281,8 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* Moves the position of the splitter with given position and unit.
*
* @param pos
- * size of the first region
+ * the new size of the first region. Fractions are only allowed
+ * when unit is percentage.
* @param unit
* the unit (from {@link Sizeable}) in which the size is given.
* @param reverse
@@ -285,11 +290,14 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* second region else it is measured by the first region
*
*/
- public void setSplitPosition(int pos, Unit unit, boolean reverse) {
+ public void setSplitPosition(float pos, Unit unit, boolean reverse) {
if (unit != Unit.PERCENTAGE && unit != Unit.PIXELS) {
throw new IllegalArgumentException(
"Only percentage and pixel units are allowed");
}
+ if (unit != Unit.PERCENTAGE) {
+ pos = Math.round(pos);
+ }
SplitterState splitterState = getState().getSplitterState();
splitterState.setPosition(pos);
splitterState.setPositionUnit(unit.getSymbol());
@@ -305,7 +313,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
*
* @return position of the splitter
*/
- public int getSplitPosition() {
+ public float getSplitPosition() {
return getState().getSplitterState().getPosition();
}