aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-12 19:09:14 +0200
committerArtur Signell <artur@vaadin.com>2012-11-14 15:20:43 +0200
commit386b7ed018f23794b4232163ec29b1d4e37b78e9 (patch)
tree514971db8a4f89b76e30b62513a20efec0b31212
parent2374a69e98201b6c34d4b8ab981a66aba4b61b19 (diff)
downloadvaadin-framework-386b7ed018f23794b4232163ec29b1d4e37b78e9.tar.gz
vaadin-framework-386b7ed018f23794b4232163ec29b1d4e37b78e9.zip
Updated Form to use hierarchy change event (#9923)
Change-Id: I33475b5445b4f4724d5af84206d22d0c8e71dad1
-rw-r--r--client/src/com/vaadin/client/ui/VForm.java20
-rw-r--r--client/src/com/vaadin/client/ui/form/FormConnector.java75
-rw-r--r--server/src/com/vaadin/ui/Form.java14
3 files changed, 64 insertions, 45 deletions
diff --git a/client/src/com/vaadin/client/ui/VForm.java b/client/src/com/vaadin/client/ui/VForm.java
index 14dc574f71..82e2f7d3aa 100644
--- a/client/src/com/vaadin/client/ui/VForm.java
+++ b/client/src/com/vaadin/client/ui/VForm.java
@@ -117,6 +117,26 @@ public class VForm extends ComplexPanel implements KeyDownHandler {
shortcutHandler.handleKeyboardEvent(Event.as(event.getNativeEvent()));
}
+ void setFooterWidget(Widget footerWidget) {
+ if (footer != null) {
+ remove(footer);
+ }
+ if (footerWidget != null) {
+ super.add(footerWidget, footerContainer);
+ }
+ footer = footerWidget;
+ }
+
+ public void setLayoutWidget(Widget newLayoutWidget) {
+ if (lo != null) {
+ remove(lo);
+ }
+ if (newLayoutWidget != null) {
+ super.add(newLayoutWidget, fieldContainer);
+ }
+ lo = newLayoutWidget;
+ }
+
/** For internal use only. May be removed or replaced in the future. */
@Override
public void add(Widget child, Element container) {
diff --git a/client/src/com/vaadin/client/ui/form/FormConnector.java b/client/src/com/vaadin/client/ui/form/FormConnector.java
index bd7ab6ff6e..7516d49e6c 100644
--- a/client/src/com/vaadin/client/ui/form/FormConnector.java
+++ b/client/src/com/vaadin/client/ui/form/FormConnector.java
@@ -128,50 +128,6 @@ public class FormConnector extends AbstractComponentContainerConnector
}
}
- // first render footer so it will be easier to handle relative height of
- // main layout
- if (getState().footer != null) {
- // render footer
- ComponentConnector newFooter = (ComponentConnector) getState().footer;
- Widget newFooterWidget = newFooter.getWidget();
- if (getWidget().footer == null) {
- getLayoutManager().addElementResizeListener(
- newFooterWidget.getElement(), footerResizeListener);
- getWidget().add(newFooter.getWidget(),
- getWidget().footerContainer);
- getWidget().footer = newFooterWidget;
- } else if (newFooter != getWidget().footer) {
- getLayoutManager().removeElementResizeListener(
- getWidget().footer.getElement(), footerResizeListener);
- getLayoutManager().addElementResizeListener(
- newFooterWidget.getElement(), footerResizeListener);
- getWidget().remove(getWidget().footer);
- getWidget().add(newFooter.getWidget(),
- getWidget().footerContainer);
- }
- getWidget().footer = newFooterWidget;
- } else {
- if (getWidget().footer != null) {
- getLayoutManager().removeElementResizeListener(
- getWidget().footer.getElement(), footerResizeListener);
- getWidget().remove(getWidget().footer);
- getWidget().footer = null;
- }
- }
-
- ComponentConnector newLayout = (ComponentConnector) getState().layout;
- Widget newLayoutWidget = newLayout.getWidget();
- if (getWidget().lo == null) {
- // Layout not rendered before
- getWidget().lo = newLayoutWidget;
- getWidget().add(newLayoutWidget, getWidget().fieldContainer);
- } else if (getWidget().lo != newLayoutWidget) {
- // Layout has changed
- getWidget().remove(getWidget().lo);
- getWidget().lo = newLayoutWidget;
- getWidget().add(newLayoutWidget, getWidget().fieldContainer);
- }
-
// also recalculates size of the footer if undefined size form - see
// #3710
client.runDescendentsLayout(getWidget());
@@ -216,9 +172,38 @@ public class FormConnector extends AbstractComponentContainerConnector
return (FormState) super.getState();
}
+ private ComponentConnector getFooter() {
+ return (ComponentConnector) getState().footer;
+ }
+
+ private ComponentConnector getLayout() {
+ return (ComponentConnector) getState().layout;
+ }
+
@Override
public void onConnectorHierarchyChange(
ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
- // TODO Move code from updateFromUIDL to this method
+ Widget newFooterWidget = null;
+ ComponentConnector footer = getFooter();
+
+ if (footer != null) {
+ newFooterWidget = footer.getWidget();
+ Widget currentFooter = getWidget().footer;
+ if (currentFooter != null) {
+ // Remove old listener
+ getLayoutManager().removeElementResizeListener(
+ currentFooter.getElement(), footerResizeListener);
+ }
+ getLayoutManager().addElementResizeListener(
+ newFooterWidget.getElement(), footerResizeListener);
+ }
+ getWidget().setFooterWidget(newFooterWidget);
+
+ Widget newLayoutWidget = null;
+ ComponentConnector newLayout = getLayout();
+ if (newLayout != null) {
+ newLayoutWidget = newLayout.getWidget();
+ }
+ getWidget().setLayoutWidget(newLayoutWidget);
}
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 9668eaf914..94a9f9b73a 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -1378,4 +1378,18 @@ public class Form extends AbstractField<Object> implements Item.Editor,
public boolean isComponentVisible(Component childComponent) {
return true;
};
+
+ @Override
+ public void setVisible(boolean visible) {
+ if (isVisible() == visible) {
+ return;
+ }
+
+ super.setVisible(visible);
+ // If the visibility state is toggled it might affect all children
+ // aswell, e.g. make container visible should make children visible if
+ // they were only hidden because the container was hidden.
+ markAsDirtyRecursive();
+ }
+
}