From bbc73481afdaac08234c9402ac12e9fea2a1a696 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Wed, 23 Dec 2009 11:50:57 +0000 Subject: [PATCH] Fuxes #3904: VSplitPanel sends unnecessary split position events svn changeset:10541/svn branch:6.2 --- .../terminal/gwt/client/ui/VSplitPanel.java | 13 +++++----- src/com/vaadin/ui/SplitPanel.java | 26 ++++++++++++++++--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index 82839f2f31..ffada53252 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -434,7 +434,6 @@ public class VSplitPanel extends ComplexPanel implements Container, newX = getOffsetWidth() - getSplitterSize(); } DOM.setStyleAttribute(splitter, "left", newX + "px"); - updateSplitPosition(newX); if (origX != newX) { resized = true; } @@ -450,7 +449,6 @@ public class VSplitPanel extends ComplexPanel implements Container, newY = getOffsetHeight() - getSplitterSize(); } DOM.setStyleAttribute(splitter, "top", newY + "px"); - updateSplitPosition(newY); if (origY != newY) { resized = true; } @@ -463,6 +461,7 @@ public class VSplitPanel extends ComplexPanel implements Container, } resizing = false; onMouseMove(event); + updateSplitPositionToServer(); } /** @@ -593,12 +592,14 @@ public class VSplitPanel extends ComplexPanel implements Container, /** * Updates the new split position back to server. - * - * @param pos - * The new position of the split handle. */ - private void updateSplitPosition(int pos) { + private void updateSplitPositionToServer() { // We always send pixel values to server + final String position = orientation == ORIENTATION_HORIZONTAL ? splitter + .getStyle().getProperty("left") + : splitter.getStyle().getProperty("top"); + final int pos = Integer.parseInt(position.substring(0, position + .length() - 2)); client.updateVariable(id, "position", pos, immediate); } diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java index 916c8bb5cc..5e67b93369 100644 --- a/src/com/vaadin/ui/SplitPanel.java +++ b/src/com/vaadin/ui/SplitPanel.java @@ -284,7 +284,7 @@ public class SplitPanel extends AbstractLayout { * the new size of the first region in percentage */ public void setSplitPosition(int pos) { - setSplitPosition(pos, UNITS_PERCENTAGE); + setSplitPosition(pos, UNITS_PERCENTAGE, true); } /** @@ -296,9 +296,27 @@ public class SplitPanel extends AbstractLayout { * the unit (from {@link Sizeable}) in which the size is given. */ public void setSplitPosition(int pos, int unit) { + setSplitPosition(pos, unit, true); + } + + /** + * Moves the position of the splitter. + * + * @param pos + * the new size of the first region in percentage + * @param unit + * the unit (from {@link Sizeable}) in which the size is given. + * @param repaintNotNeeded + * true if client side needs to be updated. Use false if the + * position info has come from the client side, thus it already + * knows the position. + */ + private void setSplitPosition(int pos, int unit, boolean repaintNeeded) { this.pos = pos; posUnit = unit; - requestRepaint(); + if (repaintNeeded) { + requestRepaint(); + } } /** @@ -335,8 +353,8 @@ public class SplitPanel extends AbstractLayout { if (variables.containsKey("position") && !isLocked()) { Integer newPos = (Integer) variables.get("position"); - // Client always sends pixel values - setSplitPosition(newPos, UNITS_PIXELS); + // Client always sends pixel values. Repaint is not needed. + setSplitPosition(newPos, UNITS_PIXELS, false); } if (variables.containsKey(SPLITTER_CLICK_EVENT)) { -- 2.39.5