import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.RenderInformation;
import com.vaadin.terminal.gwt.client.RenderSpace;
-import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.VErrorMessage;
-import com.vaadin.terminal.gwt.client.VPaintableMap;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
public class VForm extends ComplexPanel implements Container, KeyDownHandler {
public static final String CLASSNAME = "v-form";
- private Container lo;
- private Element legend = DOM.createLegend();
- private Element caption = DOM.createSpan();
+ Widget lo;
+ Element legend = DOM.createLegend();
+ Element caption = DOM.createSpan();
private Element errorIndicatorElement = DOM.createDiv();
- private Element desc = DOM.createDiv();
- private Icon icon;
- private VErrorMessage errorMessage = new VErrorMessage();
+ Element desc = DOM.createDiv();
+ Icon icon;
+ VErrorMessage errorMessage = new VErrorMessage();
- private Element fieldContainer = DOM.createDiv();
+ Element fieldContainer = DOM.createDiv();
- private Element footerContainer = DOM.createDiv();
+ Element footerContainer = DOM.createDiv();
- private Element fieldSet = DOM.createFieldSet();
+ Element fieldSet = DOM.createFieldSet();
- private Container footer;
+ Widget footer;
- private ApplicationConnection client;
+ ApplicationConnection client;
private RenderInformation renderInformation = new RenderInformation();
private int borderPaddingHorizontal = -1;
- private boolean rendering = false;
+ boolean rendering = false;
ShortcutActionHandler shortcutHandler;
- private HandlerRegistration keyDownRegistration;
+ HandlerRegistration keyDownRegistration;
public VForm() {
setElement(DOM.createDiv());
fieldSet.appendChild(footerContainer);
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- rendering = true;
- this.client = client;
- id = uidl.getId();
-
- if (client.updateComponent(this, uidl, false)) {
- rendering = false;
- return;
- }
-
- boolean legendEmpty = true;
- if (uidl.hasAttribute("caption")) {
- caption.setInnerText(uidl.getStringAttribute("caption"));
- legendEmpty = false;
- } else {
- caption.setInnerText("");
- }
- if (uidl.hasAttribute("icon")) {
- if (icon == null) {
- icon = new Icon(client);
- legend.insertFirst(icon.getElement());
- }
- icon.setUri(uidl.getStringAttribute("icon"));
- legendEmpty = false;
- } else {
- if (icon != null) {
- legend.removeChild(icon.getElement());
- }
- }
- if (legendEmpty) {
- addStyleDependentName("nocaption");
- } else {
- removeStyleDependentName("nocaption");
- }
-
- if (uidl.hasAttribute("error")) {
- final UIDL errorUidl = uidl.getErrors();
- errorMessage.updateFromUIDL(errorUidl);
- errorMessage.setVisible(true);
-
- } else {
- errorMessage.setVisible(false);
- }
-
- if (uidl.hasAttribute("description")) {
- desc.setInnerHTML(uidl.getStringAttribute("description"));
- if (desc.getParentElement() == null) {
- fieldSet.insertAfter(desc, legend);
- }
- } else {
- desc.setInnerHTML("");
- if (desc.getParentElement() != null) {
- fieldSet.removeChild(desc);
- }
- }
-
- updateSize();
-
- // first render footer so it will be easier to handle relative height of
- // main layout
- if (uidl.getChildCount() > 1
- && !uidl.getChildUIDL(1).getTag().equals("actions")) {
- // render footer
- Container newFooter = (Container) client.getPaintable(uidl
- .getChildUIDL(1));
- if (footer == null) {
- add(newFooter.getWidgetForPaintable(), footerContainer);
- footer = newFooter;
- } else if (newFooter != footer) {
- remove(footer.getWidgetForPaintable());
- client.unregisterPaintable(footer);
- add(newFooter.getWidgetForPaintable(), footerContainer);
- }
- footer = newFooter;
- footer.updateFromUIDL(uidl.getChildUIDL(1), client);
- // needed for the main layout to know the space it has available
- updateSize();
- } else {
- if (footer != null) {
- remove(footer.getWidgetForPaintable());
- client.unregisterPaintable(footer);
- // needed for the main layout to know the space it has available
- updateSize();
- }
- }
-
- final UIDL layoutUidl = uidl.getChildUIDL(0);
- Container newLo = (Container) client.getPaintable(layoutUidl);
- if (lo == null) {
- lo = newLo;
- add(lo.getWidgetForPaintable(), fieldContainer);
- } else if (lo != newLo) {
- client.unregisterPaintable(lo);
- remove(lo.getWidgetForPaintable());
- lo = newLo;
- add(lo.getWidgetForPaintable(), fieldContainer);
- }
- lo.updateFromUIDL(layoutUidl, client);
-
- // also recalculates size of the footer if undefined size form - see
- // #3710
- updateSize();
- client.runDescendentsLayout(this);
-
- // We may have actions attached
- if (uidl.getChildCount() > 1) {
- UIDL childUidl = uidl.getChildByTagName("actions");
- if (childUidl != null) {
- if (shortcutHandler == null) {
- shortcutHandler = new ShortcutActionHandler(id, client);
- keyDownRegistration = addDomHandler(this,
- KeyDownEvent.getType());
- }
- shortcutHandler.updateActionMap(childUidl);
- }
- } else if (shortcutHandler != null) {
- keyDownRegistration.removeHandler();
- shortcutHandler = null;
- keyDownRegistration = null;
- }
-
- rendering = false;
- }
-
public void updateSize() {
renderInformation.updateSize(getElement());
}
remove(oldComponent);
if (oldComponent == lo) {
- lo = (Container) VPaintableMap.get(client).getPaintable(
- newComponent);
+ lo = newComponent;
add(newComponent, fieldContainer);
} else {
- footer = (Container) VPaintableMap.get(client).getPaintable(
- newComponent);
+ footer = newComponent;
add(newComponent, footerContainer);
}
}
- public void updateCaption(VPaintableWidget component, UIDL uidl) {
- // NOP form don't render caption for neither field layout nor footer
- // layout
- }
-
@Override
public void setHeight(String height) {
if (this.height.equals(height)) {
public Widget getWidgetForPaintable() {
return this;
}
+
+ @Override
+ protected void add(Widget child, Element container) {
+ // Overridden to allow VFormPaintable to call this. Should be removed
+ // once functionality from VFormPaintable is moved to VForm.
+ super.add(child, container);
+ }
}
private final static String CLASSNAME = "v-formlayout";
- private ApplicationConnection client;
- private VFormLayoutTable table;
+ ApplicationConnection client;
+ VFormLayoutTable table;
private String width = "";
private String height = "";
- private boolean rendering = false;
+ boolean rendering = false;
public VFormLayout() {
super();
}
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- rendering = true;
-
- this.client = client;
-
- if (client.updateComponent(this, uidl, true)) {
- rendering = false;
- return;
- }
-
- table.updateFromUIDL(uidl, client);
-
- rendering = false;
- }
-
public boolean isDynamicWidth() {
return width.equals("");
}
table.replaceChildComponent(oldComponent, newComponent);
}
- public void updateCaption(VPaintableWidget component, UIDL uidl) {
- table.updateCaption(component, uidl);
- }
-
public class Caption extends HTML {
public static final String CLASSNAME = "v-caption";
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
+\r
+public class VFormLayoutPaintable extends VAbstractPaintableWidgetContainer {\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ getWidgetForPaintable().rendering = true;\r
+\r
+ getWidgetForPaintable().client = client;\r
+\r
+ if (client.updateComponent(this, uidl, true)) {\r
+ getWidgetForPaintable().rendering = false;\r
+ return;\r
+ }\r
+\r
+ getWidgetForPaintable().table.updateFromUIDL(uidl, client);\r
+\r
+ getWidgetForPaintable().rendering = false;\r
+ }\r
+\r
+ public void updateCaption(VPaintableWidget component, UIDL uidl) {\r
+ getWidgetForPaintable().table.updateCaption(component, uidl);\r
+ }\r
+\r
+ @Override\r
+ public VFormLayout getWidgetForPaintable() {\r
+ return (VFormLayout) super.getWidgetForPaintable();\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VFormLayout.class);\r
+ }\r
+\r
+}\r
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.event.dom.client.KeyDownEvent;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VPaintableMap;\r
+import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
+\r
+public class VFormPaintable extends VAbstractPaintableWidgetContainer {\r
+\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ getWidgetForPaintable().rendering = true;\r
+ getWidgetForPaintable().client = client;\r
+ getWidgetForPaintable().id = uidl.getId();\r
+\r
+ if (client.updateComponent(this, uidl, false)) {\r
+ getWidgetForPaintable().rendering = false;\r
+ return;\r
+ }\r
+\r
+ boolean legendEmpty = true;\r
+ if (uidl.hasAttribute("caption")) {\r
+ getWidgetForPaintable().caption.setInnerText(uidl\r
+ .getStringAttribute("caption"));\r
+ legendEmpty = false;\r
+ } else {\r
+ getWidgetForPaintable().caption.setInnerText("");\r
+ }\r
+ if (uidl.hasAttribute("icon")) {\r
+ if (getWidgetForPaintable().icon == null) {\r
+ getWidgetForPaintable().icon = new Icon(client);\r
+ getWidgetForPaintable().legend\r
+ .insertFirst(getWidgetForPaintable().icon.getElement());\r
+ }\r
+ getWidgetForPaintable().icon\r
+ .setUri(uidl.getStringAttribute("icon"));\r
+ legendEmpty = false;\r
+ } else {\r
+ if (getWidgetForPaintable().icon != null) {\r
+ getWidgetForPaintable().legend\r
+ .removeChild(getWidgetForPaintable().icon.getElement());\r
+ }\r
+ }\r
+ if (legendEmpty) {\r
+ getWidgetForPaintable().addStyleDependentName("nocaption");\r
+ } else {\r
+ getWidgetForPaintable().removeStyleDependentName("nocaption");\r
+ }\r
+\r
+ if (uidl.hasAttribute("error")) {\r
+ final UIDL errorUidl = uidl.getErrors();\r
+ getWidgetForPaintable().errorMessage.updateFromUIDL(errorUidl);\r
+ getWidgetForPaintable().errorMessage.setVisible(true);\r
+ } else {\r
+ getWidgetForPaintable().errorMessage.setVisible(false);\r
+ }\r
+\r
+ if (uidl.hasAttribute("description")) {\r
+ getWidgetForPaintable().desc.setInnerHTML(uidl\r
+ .getStringAttribute("description"));\r
+ if (getWidgetForPaintable().desc.getParentElement() == null) {\r
+ getWidgetForPaintable().fieldSet.insertAfter(\r
+ getWidgetForPaintable().desc,\r
+ getWidgetForPaintable().legend);\r
+ }\r
+ } else {\r
+ getWidgetForPaintable().desc.setInnerHTML("");\r
+ if (getWidgetForPaintable().desc.getParentElement() != null) {\r
+ getWidgetForPaintable().fieldSet\r
+ .removeChild(getWidgetForPaintable().desc);\r
+ }\r
+ }\r
+\r
+ getWidgetForPaintable().updateSize();\r
+\r
+ // first render footer so it will be easier to handle relative height of\r
+ // main layout\r
+ if (uidl.getChildCount() > 1\r
+ && !uidl.getChildUIDL(1).getTag().equals("actions")) {\r
+ // render footer\r
+ VPaintableWidget newFooter = client.getPaintable(uidl\r
+ .getChildUIDL(1));\r
+ Widget newFooterWidget = newFooter.getWidgetForPaintable();\r
+ if (getWidgetForPaintable().footer == null) {\r
+ getWidgetForPaintable().add(newFooter.getWidgetForPaintable(),\r
+ getWidgetForPaintable().footerContainer);\r
+ getWidgetForPaintable().footer = newFooterWidget;\r
+ } else if (newFooter != getWidgetForPaintable().footer) {\r
+ getWidgetForPaintable().remove(getWidgetForPaintable().footer);\r
+ client.unregisterPaintable(VPaintableMap.get(getConnection())\r
+ .getPaintable(getWidgetForPaintable().footer));\r
+ getWidgetForPaintable().add(newFooter.getWidgetForPaintable(),\r
+ getWidgetForPaintable().footerContainer);\r
+ }\r
+ getWidgetForPaintable().footer = newFooterWidget;\r
+ newFooter.updateFromUIDL(uidl.getChildUIDL(1), client);\r
+ // needed for the main layout to know the space it has available\r
+ getWidgetForPaintable().updateSize();\r
+ } else {\r
+ if (getWidgetForPaintable().footer != null) {\r
+ getWidgetForPaintable().remove(getWidgetForPaintable().footer);\r
+ client.unregisterPaintable(VPaintableMap.get(getConnection())\r
+ .getPaintable(getWidgetForPaintable().footer));\r
+ // needed for the main layout to know the space it has available\r
+ getWidgetForPaintable().updateSize();\r
+ }\r
+ }\r
+\r
+ final UIDL layoutUidl = uidl.getChildUIDL(0);\r
+ VPaintableWidget newLayout = client.getPaintable(layoutUidl);\r
+ Widget newLayoutWidget = newLayout.getWidgetForPaintable();\r
+ if (getWidgetForPaintable().lo == null) {\r
+ // Layout not rendered before\r
+ getWidgetForPaintable().lo = newLayoutWidget;\r
+ getWidgetForPaintable().add(newLayoutWidget,\r
+ getWidgetForPaintable().fieldContainer);\r
+ } else if (getWidgetForPaintable().lo != newLayoutWidget) {\r
+ // Layout has changed\r
+ client.unregisterPaintable(VPaintableMap.get(getConnection())\r
+ .getPaintable(getWidgetForPaintable().lo));\r
+ getWidgetForPaintable().remove(getWidgetForPaintable().lo);\r
+ getWidgetForPaintable().lo = newLayoutWidget;\r
+ getWidgetForPaintable().add(newLayoutWidget,\r
+ getWidgetForPaintable().fieldContainer);\r
+ }\r
+ newLayout.updateFromUIDL(layoutUidl, client);\r
+\r
+ // also recalculates size of the footer if undefined size form - see\r
+ // #3710\r
+ getWidgetForPaintable().updateSize();\r
+ client.runDescendentsLayout(getWidgetForPaintable());\r
+\r
+ // We may have actions attached\r
+ if (uidl.getChildCount() > 1) {\r
+ UIDL childUidl = uidl.getChildByTagName("actions");\r
+ if (childUidl != null) {\r
+ if (getWidgetForPaintable().shortcutHandler == null) {\r
+ getWidgetForPaintable().shortcutHandler = new ShortcutActionHandler(\r
+ getId(), client);\r
+ getWidgetForPaintable().keyDownRegistration = getWidgetForPaintable()\r
+ .addDomHandler(getWidgetForPaintable(),\r
+ KeyDownEvent.getType());\r
+ }\r
+ getWidgetForPaintable().shortcutHandler\r
+ .updateActionMap(childUidl);\r
+ }\r
+ } else if (getWidgetForPaintable().shortcutHandler != null) {\r
+ getWidgetForPaintable().keyDownRegistration.removeHandler();\r
+ getWidgetForPaintable().shortcutHandler = null;\r
+ getWidgetForPaintable().keyDownRegistration = null;\r
+ }\r
+\r
+ getWidgetForPaintable().rendering = false;\r
+ }\r
+\r
+ public void updateCaption(VPaintableWidget component, UIDL uidl) {\r
+ // NOP form don't render caption for neither field layout nor footer\r
+ // layout\r
+ }\r
+\r
+ @Override\r
+ public VForm getWidgetForPaintable() {\r
+ return (VForm) super.getWidgetForPaintable();\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VForm.class);\r
+ }\r
+\r
+}\r
import com.vaadin.terminal.ErrorMessage;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.gwt.client.ui.VForm;
+import com.vaadin.terminal.gwt.client.ui.VFormPaintable;
/**
* Form component provides easy way of creating and managing sets fields.
* @deprecated Use {@link FieldGroup} instead of {@link Form} for more
* flexibility.
*/
-@SuppressWarnings("serial")
-@ClientWidget(VForm.class)
+@ClientWidget(VFormPaintable.class)
@Deprecated
public class Form extends AbstractField<Object> implements Item.Editor,
Buffered, Item, Validatable, Action.Notifier {
package com.vaadin.ui;
-import com.vaadin.terminal.gwt.client.ui.VFormLayout;
+import com.vaadin.terminal.gwt.client.ui.VFormLayoutPaintable;
/**
* FormLayout is used by {@link Form} to layout fields. It may also be used
* bottom are by default on.
*
*/
-@ClientWidget(VFormLayout.class)
+@ClientWidget(VFormLayoutPaintable.class)
public class FormLayout extends AbstractOrderedLayout {
public FormLayout() {