RenderInformation renderInformation = new RenderInformation();
+ private String id;
+
+ private boolean immediate;
+
public ISplitPanel() {
this(ORIENTATION_HORIZONTAL);
}
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
this.client = client;
+ id = uidl.getId();
+
+ immediate = uidl.hasAttribute("immediate");
if (client.updateComponent(this, uidl, true)) {
return;
secondChild = w;
}
+ @Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEMOVE:
newX = getOffsetWidth() - getSplitterSize();
}
DOM.setStyleAttribute(splitter, "left", newX + "px");
+ updateSplitPosition(newX);
}
private void onVerticalMouseMove(int y) {
newY = getOffsetHeight() - getSplitterSize();
}
DOM.setStyleAttribute(splitter, "top", newY + "px");
+ updateSplitPosition(newY);
}
public void onMouseUp(Event event) {
}
+ /**
+ * Updates the new split position back to server.
+ *
+ * @param pos
+ * The new position of the split handle.
+ */
+ private void updateSplitPosition(int pos) {
+ // We always send pixel values to server
+ client.updateVariable(id, "position", pos, immediate);
+ }
+
}
package com.itmill.toolkit.ui;
import java.util.Iterator;
+import java.util.Map;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
+import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size;
/**
* SplitPanel.
*
* @return the Component UIDL tag as string.
*/
+ @Override
public String getTag() {
if (orientation == ORIENTATION_HORIZONTAL) {
return "hsplitpanel";
* @param c
* the component to be added.
*/
+ @Override
public void addComponent(Component c) {
if (firstComponent == null) {
firstComponent = c;
* @param c
* the component to be removed.
*/
+ @Override
public void removeComponent(Component c) {
super.removeComponent(c);
if (c == firstComponent) {
* @throws PaintException
* if the paint operation failed.
*/
+ @Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
return locked;
}
+ /*
+ * Invoked when a variable of the component changes. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
+ */
+ @Override
+ public void changeVariables(Object source, Map variables) {
+
+ super.changeVariables(source, variables);
+
+ if (variables.containsKey("position") && !isLocked()) {
+ Integer newPos = (Integer) variables.get("position");
+ // Client always sends pixel values
+ setSplitPosition(newPos, UNITS_PIXELS);
+ }
+
+ }
+
}