newX = getOffsetWidth() - getSplitterSize();
}
DOM.setStyleAttribute(splitter, "left", newX + "px");
- updateSplitPosition(newX);
if (origX != newX) {
resized = true;
}
newY = getOffsetHeight() - getSplitterSize();
}
DOM.setStyleAttribute(splitter, "top", newY + "px");
- updateSplitPosition(newY);
if (origY != newY) {
resized = true;
}
}
resizing = false;
onMouseMove(event);
+ updateSplitPositionToServer();
}
/**
/**
* 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);
}
* the new size of the first region in percentage
*/
public void setSplitPosition(int pos) {
- setSplitPosition(pos, UNITS_PERCENTAGE);
+ setSplitPosition(pos, UNITS_PERCENTAGE, true);
}
/**
* 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();
+ }
}
/**
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)) {