package com.vaadin.terminal.gwt.client.ui;
-import java.util.Set;
-
import com.google.gwt.dom.client.Node;
+import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.TouchCancelEvent;
import com.google.gwt.event.dom.client.TouchCancelHandler;
import com.google.gwt.event.dom.client.TouchEndEvent;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.Container;
-import com.vaadin.terminal.gwt.client.ContainerResizedListener;
-import com.vaadin.terminal.gwt.client.RenderInformation;
-import com.vaadin.terminal.gwt.client.RenderSpace;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
-public class VAbstractSplitPanel extends ComplexPanel implements Container,
- ContainerResizedListener {
+public class VAbstractSplitPanel extends ComplexPanel {
private boolean enabled = false;
ApplicationConnection client;
- private String width = "";
-
- private String height = "";
-
- private RenderSpace firstRenderSpace = new RenderSpace(0, 0, true);
- private RenderSpace secondRenderSpace = new RenderSpace(0, 0, true);
-
- RenderInformation renderInformation = new RenderInformation();
-
String id;
boolean immediate;
- boolean rendering = false;
-
/* The current position of the split handle in either percentages or pixels */
String position;
: getOffsetHeight()) + "px";
}
+ String attributeName;
if (orientation == ORIENTATION_HORIZONTAL) {
if (positionReversed) {
- DOM.setStyleAttribute(splitter, "right", pos);
+ attributeName = "right";
} else {
- DOM.setStyleAttribute(splitter, "left", pos);
+ attributeName = "left";
}
} else {
if (positionReversed) {
- DOM.setStyleAttribute(splitter, "bottom", pos);
+ attributeName = "bottom";
} else {
- DOM.setStyleAttribute(splitter, "top", pos);
+ attributeName = "top";
}
}
- iLayout();
- client.runDescendentsLayout(this);
+ Style style = splitter.getStyle();
+ if (!pos.equals(style.getProperty(attributeName))) {
+ style.setProperty(attributeName, pos);
+ updateSizes();
+ }
}
- /*
- * Calculates absolutely positioned container places/sizes (non-Javadoc)
- *
- * @see com.vaadin.terminal.gwt.client.NeedsLayout#layout()
- */
- public void iLayout() {
+ void updateSizes() {
if (!isAttached()) {
return;
}
- renderInformation.updateSize(getElement());
-
int wholeSize;
int pixelPosition;
DOM.setStyleAttribute(secondContainer, "left",
(pixelPosition + getSplitterSize()) + "px");
- int contentHeight = renderInformation.getRenderedSize().getHeight();
- firstRenderSpace.setHeight(contentHeight);
- firstRenderSpace.setWidth(pixelPosition);
- secondRenderSpace.setHeight(contentHeight);
- secondRenderSpace.setWidth(secondContainerWidth);
-
break;
case ORIENTATION_VERTICAL:
wholeSize = DOM.getElementPropertyInt(wrapper, "clientHeight");
DOM.setStyleAttribute(secondContainer, "top",
(pixelPosition + getSplitterSize()) + "px");
- int contentWidth = renderInformation.getRenderedSize().getWidth();
- firstRenderSpace.setHeight(pixelPosition);
- firstRenderSpace.setWidth(contentWidth);
- secondRenderSpace.setHeight(secondContainerHeight);
- secondRenderSpace.setWidth(contentWidth);
-
break;
}
return splitterSize;
}
- @Override
- public void setHeight(String height) {
- if (this.height.equals(height)) {
- return;
- }
-
- this.height = height;
- super.setHeight(height);
-
- if (!rendering && client != null) {
- setSplitPosition(position);
- }
- }
-
- @Override
- public void setWidth(String width) {
- if (this.width.equals(width)) {
- return;
- }
-
- this.width = width;
- super.setWidth(width);
-
- if (!rendering && client != null) {
- setSplitPosition(position);
- }
- }
-
- public RenderSpace getAllocatedSpace(Widget child) {
- if (child == firstChild) {
- return firstRenderSpace;
- } else if (child == secondChild) {
- return secondRenderSpace;
- }
-
- return null;
- }
-
- public boolean hasChildComponent(Widget component) {
- return (component != null && (component == firstChild || component == secondChild));
- }
-
- public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
- if (oldComponent == firstChild) {
- setFirstWidget(newComponent);
- } else if (oldComponent == secondChild) {
- setSecondWidget(newComponent);
- }
- }
-
- public boolean requestLayout(Set<Widget> children) {
- // content size change might cause change to its available space
- // (scrollbars)
- for (Widget widget : children) {
- client.handleComponentRelativeSize(widget);
- }
- if (height != null && width != null) {
- /*
- * If the height and width has been specified the child components
- * cannot make the size of the layout change
- */
-
- return true;
- }
-
- if (renderInformation.updateSize(getElement())) {
- return false;
- } else {
- return true;
- }
-
- }
-
/**
* Updates the new split position back to server.
*/
import com.vaadin.terminal.gwt.client.VPaintableWidget;
public abstract class VAbstractSplitPanelPaintable extends
- VAbstractPaintableWidgetContainer {
+ VAbstractPaintableWidgetContainer implements ResizeRequired {
public static final String SPLITTER_CLICK_EVENT_IDENTIFIER = "sp_click";
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
getWidgetForPaintable().client = client;
getWidgetForPaintable().id = uidl.getId();
- getWidgetForPaintable().rendering = true;
getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");
super.updateFromUIDL(uidl, client);
if (!isRealUpdate(uidl)) {
- getWidgetForPaintable().rendering = false;
return;
}
getWidgetForPaintable().setEnabled(
newFirstChildPaintable.updateFromUIDL(uidl.getChildUIDL(0), client);
newSecondChildPaintable.updateFromUIDL(uidl.getChildUIDL(1), client);
- getWidgetForPaintable().renderInformation
- .updateSize(getWidgetForPaintable().getElement());
-
// This is needed at least for cases like #3458 to take
// appearing/disappearing scrollbars into account.
client.runDescendentsLayout(getWidgetForPaintable());
+ }
- getWidgetForPaintable().rendering = false;
-
+ public void onResize() {
+ VAbstractSplitPanel splitPanel = getWidgetForPaintable();
+ splitPanel.setSplitPosition(splitPanel.position);
+ splitPanel.updateSizes();
}
@Override