summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-04-23 23:44:19 +0300
committerVaadin Code Review <review@vaadin.com>2014-06-24 13:38:20 +0000
commit0f38151da3e89a65e4403d8f53402906fe8dcc37 (patch)
tree943b29162c5ff2e217f78e72e526a53126d2cf6f /client
parent82aad1f9ce26ae9cd0822df0dda5e8805adf7138 (diff)
downloadvaadin-framework-0f38151da3e89a65e4403d8f53402906fe8dcc37.tar.gz
vaadin-framework-0f38151da3e89a65e4403d8f53402906fe8dcc37.zip
Fix moving a single component inside a split panel (#11920)
Change-Id: Ib9b3625e4104763143906eb1b7986ef7b3b80737
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VAbstractSplitPanel.java8
-rw-r--r--client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java33
2 files changed, 41 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
index 269db23366..6ee88d51dd 100644
--- a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
+++ b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
@@ -511,6 +511,10 @@ public class VAbstractSplitPanel extends ComplexPanel {
firstChild = w;
}
+ public Widget getFirstWidget() {
+ return firstChild;
+ }
+
/** For internal use only. May be removed or replaced in the future. */
public void setSecondWidget(Widget w) {
if (secondChild == w) {
@@ -525,6 +529,10 @@ public class VAbstractSplitPanel extends ComplexPanel {
secondChild = w;
}
+ public Widget getSecondWidget() {
+ return secondChild;
+ }
+
@Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
diff --git a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java
index ce8b3c8fea..6bf03ad880 100644
--- a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java
+++ b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java
@@ -161,6 +161,35 @@ public abstract class AbstractSplitPanelConnector extends
getLayoutManager().setNeedsLayout(this);
getWidget().makeScrollable();
+
+ handleSingleComponentMove();
+ }
+
+ /**
+ * Handles the case when there is only one child component and that
+ * component is moved between first <-> second. This does not trigger a
+ * hierarchy change event as the list of children contains the same
+ * component in both cases.
+ */
+ private void handleSingleComponentMove() {
+ if (getChildComponents().size() == 1) {
+ Widget stateFirstChild = null;
+ Widget stateSecondChild = null;
+ if (getState().firstChild != null) {
+ stateFirstChild = ((ComponentConnector) getState().firstChild)
+ .getWidget();
+ }
+ if (getState().secondChild != null) {
+ stateSecondChild = ((ComponentConnector) getState().secondChild)
+ .getWidget();
+ }
+
+ if (stateFirstChild == getWidget().getSecondWidget()
+ || stateSecondChild == getWidget().getFirstWidget()) {
+ handleHierarchyChange();
+ }
+ }
+
}
@Override
@@ -212,6 +241,10 @@ public abstract class AbstractSplitPanelConnector extends
@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
+ handleHierarchyChange();
+ }
+
+ private void handleHierarchyChange() {
/*
* When the connector gets detached, the state isn't updated but there's
* still a hierarchy change -> verify that the child from the state is