From 79bb29e85510c08390add7fd7b39a5160dbdd87a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 7 May 2012 16:49:33 +0300 Subject: [PATCH] State is now created using generators, removed setState (#8502) --- .../terminal/gwt/DefaultWidgetSet.gwt.xml | 14 +- .../gwt/client/ApplicationConnection.java | 7 +- .../terminal/gwt/client/ServerConnector.java | 16 -- .../client/ui/AbstractComponentConnector.java | 41 ++--- .../gwt/client/ui/AbstractConnector.java | 31 ++++ .../client/ui/ConnectorClassBasedFactory.java | 40 +++++ .../gwt/client/ui/ConnectorStateFactory.java | 28 ++++ .../gwt/client/ui/ConnectorWidgetFactory.java | 39 +++++ .../client/ui/UnknownComponentConnector.java | 7 - .../AbsoluteLayoutConnector.java | 6 - .../ui/accordion/AccordionConnector.java | 7 - .../gwt/client/ui/button/ButtonConnector.java | 7 - .../client/ui/checkbox/CheckBoxConnector.java | 7 - .../client/ui/combobox/ComboBoxConnector.java | 7 - .../ui/csslayout/CssLayoutConnector.java | 6 - .../CustomComponentConnector.java | 7 - .../ui/customfield/CustomFieldConnector.java | 12 -- .../customlayout/CustomLayoutConnector.java | 6 - .../datefield/AbstractDateFieldConnector.java | 7 - .../datefield/InlineDateFieldConnector.java | 7 - .../ui/datefield/PopupDateFieldConnector.java | 7 - .../ui/datefield/TextualDateConnector.java | 7 - .../DragAndDropWrapperConnector.java | 7 - .../client/ui/embedded/EmbeddedConnector.java | 7 - .../gwt/client/ui/form/FormConnector.java | 6 - .../ui/formlayout/FormLayoutConnector.java | 6 - .../ui/gridlayout/GridLayoutConnector.java | 6 - .../gwt/client/ui/label/LabelConnector.java | 8 +- .../gwt/client/ui/link/LinkConnector.java | 7 - .../ui/listselect/ListSelectConnector.java | 7 - .../client/ui/menubar/MenuBarConnector.java | 6 - .../nativebutton/NativeButtonConnector.java | 7 - .../nativeselect/NativeSelectConnector.java | 7 - .../ui/optiongroup/OptionGroupConnector.java | 6 - .../HorizontalLayoutConnector.java | 6 - .../VerticalLayoutConnector.java | 6 - .../gwt/client/ui/panel/PanelConnector.java | 6 - .../passwordfield/PasswordFieldConnector.java | 7 - .../ui/popupview/PopupViewConnector.java | 7 - .../ProgressIndicatorConnector.java | 7 - .../richtextarea/RichTextAreaConnector.java | 7 - .../gwt/client/ui/root/RootConnector.java | 6 - .../gwt/client/ui/slider/SliderConnector.java | 7 - .../AbstractSplitPanelConnector.java | 3 - .../HorizontalSplitPanelConnector.java | 5 +- .../VerticalSplitPanelConnector.java | 4 +- .../gwt/client/ui/table/TableConnector.java | 6 - .../client/ui/tabsheet/TabsheetConnector.java | 5 - .../client/ui/textarea/TextAreaConnector.java | 7 - .../ui/textfield/TextFieldConnector.java | 7 - .../gwt/client/ui/tree/TreeConnector.java | 7 - .../ui/treetable/TreeTableConnector.java | 7 - .../twincolselect/TwinColSelectConnector.java | 7 - .../gwt/client/ui/upload/UploadConnector.java | 7 - .../gwt/client/ui/video/VideoConnector.java | 7 - .../gwt/client/ui/window/WindowConnector.java | 6 - ...ctConnectorClassBasedFactoryGenerator.java | 145 ++++++++++++++++++ .../ConnectorStateFactoryGenerator.java | 29 ++++ .../ConnectorWidgetFactoryGenerator.java | 29 ++++ .../tests/dd/MyDragSourceConnector.java | 6 +- .../tests/dd/MyDropTargetConnector.java | 7 - 61 files changed, 375 insertions(+), 374 deletions(-) create mode 100644 src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java create mode 100644 src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java create mode 100644 src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java create mode 100644 src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java create mode 100644 src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java create mode 100644 src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml index f65b4c51e7..74dc78d9b8 100644 --- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml +++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml @@ -37,7 +37,7 @@ + class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator"> @@ -68,6 +68,18 @@ class="com.vaadin.terminal.gwt.client.communication.RpcManager" /> + + + + + + + + diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 8285e956e6..cc1615d4c7 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -1414,11 +1414,10 @@ public class ApplicationConnection { JSONArray stateDataAndType = new JSONArray( states.getJavaScriptObject(connectorId)); - Object state = JsonDecoder.decodeValue( - stateDataAndType, connector.getState(), - connectorMap, ApplicationConnection.this); + JsonDecoder.decodeValue(stateDataAndType, + connector.getState(), connectorMap, + ApplicationConnection.this); - connector.setState((SharedState) state); StateChangeEvent event = GWT .create(StateChangeEvent.class); event.setConnector(connector); diff --git a/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/src/com/vaadin/terminal/gwt/client/ServerConnector.java index b331f1f07d..44f65fc6a7 100644 --- a/src/com/vaadin/terminal/gwt/client/ServerConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ServerConnector.java @@ -8,7 +8,6 @@ import java.util.Collection; import com.google.gwt.event.shared.GwtEvent; import com.google.web.bindery.event.shared.HandlerRegistration; import com.vaadin.terminal.gwt.client.communication.ClientRpc; -import com.vaadin.terminal.gwt.client.communication.SharedState; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; /** @@ -22,21 +21,6 @@ import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChange */ public interface ServerConnector extends Connector { - /** - * Sets a new state for the connector. - * - * @param state - * The new state - * @deprecated This should be removed. Framework should update what is - * returned by getState() instead of setting a new state object. - * Note that this must be done either so that setState accepts a - * state object once (first time received from the server) or - * getState() in AbstractConnector uses a generated class to - * create the state object (like RpcProy.craete()) - */ - @Deprecated - public void setState(SharedState state); - /** * Gets ApplicationConnection instance that created this connector. * diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java index fdb04f0ddf..d690bdded1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java @@ -18,7 +18,6 @@ import com.vaadin.terminal.gwt.client.TooltipInfo; 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.communication.SharedState; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.ui.root.RootConnector; @@ -29,9 +28,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector private Widget widget; - // shared state from the server to the client - private ComponentState state; - private String lastKnownWidth = ""; private String lastKnownHeight = ""; @@ -47,7 +43,9 @@ public abstract class AbstractComponentConnector extends AbstractConnector * * @return */ - protected abstract Widget createWidget(); + protected Widget createWidget() { + return ConnectorWidgetFactory.createWidget(getClass()); + } /** * Returns the widget associated with this paintable. The widget returned by @@ -63,23 +61,16 @@ public abstract class AbstractComponentConnector extends AbstractConnector return widget; } - /** - * Returns the shared state object for this connector. - * - * If overriding this method to return a more specific type, also - * {@link #createState()} must be overridden. - * - * @return current shared state (not null) - */ - public ComponentState getState() { - return state; - } - @Deprecated public static boolean isRealUpdate(UIDL uidl) { return !uidl.hasAttribute("cached"); } + @Override + public ComponentState getState() { + return (ComponentState) super.getState(); + } + @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); @@ -97,8 +88,9 @@ public abstract class AbstractComponentConnector extends AbstractConnector * Disabled state may affect (override) tabindex so the order must be * first setting tabindex, then enabled state. */ - if (state instanceof TabIndexState && getWidget() instanceof Focusable) { - ((Focusable) getWidget()).setTabIndex(((TabIndexState) state) + if (getState() instanceof TabIndexState + && getWidget() instanceof Focusable) { + ((Focusable) getWidget()).setTabIndex(((TabIndexState) getState()) .getTabIndex()); } @@ -288,17 +280,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector return getState().isReadOnly(); } - /** - * Sets the shared state for the paintable widget. - * - * @param new shared state (must be compatible with the return value of - * {@link #getState()} - {@link ComponentState} if - * {@link #getState()} is not overridden - */ - public final void setState(SharedState state) { - this.state = (ComponentState) state; - } - public LayoutManager getLayoutManager() { return LayoutManager.get(getConnection()); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index ef74228ae8..dc960f90a5 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -17,6 +17,7 @@ import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VConsole; import com.vaadin.terminal.gwt.client.communication.ClientRpc; +import com.vaadin.terminal.gwt.client.communication.SharedState; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; @@ -38,6 +39,8 @@ public abstract class AbstractConnector implements ServerConnector, private Map> rpcImplementations; private final boolean debugLogging = false; + private SharedState state; + /* * (non-Javadoc) * @@ -183,4 +186,32 @@ public abstract class AbstractConnector implements ServerConnector, } } + + /** + * Returns the shared state object for this connector. + * + * Override this method to define the shared state type for your connector. + * + * @return the current shared state (never null) + */ + public SharedState getState() { + if (state == null) { + state = createState(); + } + + return state; + } + + /** + * Creates a state object with default values for this connector. The + * created state object must be compatible with the return type of + * {@link #getState()}. The default implementation creates a state object + * using GWT.create() using the defined return type of {@link #getState()}. + * + * @return A new state object + */ + protected SharedState createState() { + return ConnectorStateFactory.createState(getClass()); + } + } diff --git a/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java b/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java new file mode 100644 index 0000000000..051ebdc6df --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java @@ -0,0 +1,40 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.terminal.gwt.client.ui; + +import java.util.HashMap; +import java.util.Map; + +import com.vaadin.terminal.gwt.client.Connector; + +public abstract class ConnectorClassBasedFactory { + public interface Creator { + public T create(); + } + + private Map, Creator> creators = new HashMap, Creator>(); + + protected void addCreator(Class cls, + Creator creator) { + creators.put(cls, creator); + } + + /** + * Creates a widget using GWT.create for the given connector, based on its + * {@link AbstractComponentConnector#getWidget()} return type. + * + * @param connector + * @return + */ + public T create(Class connector) { + Creator foo = creators.get(connector); + if (foo == null) { + throw new RuntimeException(getClass().getName() + + " could not find a creator for connector of type " + + connector.getName()); + } + return foo.create(); + } + +} diff --git a/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java b/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java new file mode 100644 index 0000000000..6fb132db57 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java @@ -0,0 +1,28 @@ +package com.vaadin.terminal.gwt.client.ui; + +import com.google.gwt.core.client.GWT; +import com.vaadin.terminal.gwt.client.Connector; +import com.vaadin.terminal.gwt.client.communication.SharedState; + +public abstract class ConnectorStateFactory extends + ConnectorClassBasedFactory { + private static ConnectorStateFactory impl = null; + + /** + * Creates a SharedState using GWT.create for the given connector, based on + * its {@link AbstractComponentConnector#getSharedState ()} return type. + * + * @param connector + * @return + */ + public static SharedState createState(Class connector) { + return getImpl().create(connector); + } + + private static ConnectorStateFactory getImpl() { + if (impl == null) { + impl = GWT.create(ConnectorStateFactory.class); + } + return impl; + } +} diff --git a/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java b/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java new file mode 100644 index 0000000000..61b54f5383 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java @@ -0,0 +1,39 @@ +package com.vaadin.terminal.gwt.client.ui; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector; +import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; + +public abstract class ConnectorWidgetFactory extends + ConnectorClassBasedFactory { + private static ConnectorWidgetFactory impl = null; + + // TODO Move to generator + { + addCreator(TextFieldConnector.class, new Creator() { + public Widget create() { + return GWT.create(VTextField.class); + } + }); + } + + /** + * Creates a widget using GWT.create for the given connector, based on its + * {@link AbstractComponentConnector#getWidget()} return type. + * + * @param connector + * @return + */ + public static Widget createWidget( + Class connector) { + return getImpl().create(connector); + } + + private static ConnectorWidgetFactory getImpl() { + if (impl == null) { + impl = GWT.create(ConnectorWidgetFactory.class); + } + return impl; + } +} diff --git a/src/com/vaadin/terminal/gwt/client/ui/UnknownComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ui/UnknownComponentConnector.java index 94eff44eee..0cccec6481 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/UnknownComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/UnknownComponentConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; public class UnknownComponentConnector extends AbstractComponentConnector { @@ -14,11 +12,6 @@ public class UnknownComponentConnector extends AbstractComponentConnector { return false; } - @Override - protected Widget createWidget() { - return GWT.create(VUnknownComponent.class); - } - @Override public VUnknownComponent getWidget() { return (VUnknownComponent) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/absolutelayout/AbsoluteLayoutConnector.java index 80b6254e02..b42c0acea7 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.absolutelayout; import java.util.HashMap; import java.util.Map; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.user.client.Element; @@ -93,11 +92,6 @@ public class AbsoluteLayoutConnector extends } - @Override - protected Widget createWidget() { - return GWT.create(VAbsoluteLayout.class); - } - @Override public VAbsoluteLayout getWidget() { return (VAbsoluteLayout) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/accordion/AccordionConnector.java b/src/com/vaadin/terminal/gwt/client/ui/accordion/AccordionConnector.java index a03fa37214..f022e97973 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/accordion/AccordionConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/accordion/AccordionConnector.java @@ -5,8 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.accordion; import java.util.Iterator; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.UIDL; @@ -59,11 +57,6 @@ public class AccordionConnector extends TabsheetBaseConnector implements return (VAccordion) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VAccordion.class); - } - public void updateCaption(ComponentConnector component) { /* Accordion does not render its children's captions */ } diff --git a/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java b/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java index a555ecd392..d79aa96ac6 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/button/ButtonConnector.java @@ -4,7 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.button; -import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -13,7 +12,6 @@ import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.EventHelper; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; @@ -95,11 +93,6 @@ public class ButtonConnector extends AbstractComponentConnector implements getWidget().clickShortcut = getState().getClickShortcutKeyCode(); } - @Override - protected Widget createWidget() { - return GWT.create(VButton.class); - } - @Override public VButton getWidget() { return (VButton) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/checkbox/CheckBoxConnector.java b/src/com/vaadin/terminal/gwt/client/ui/checkbox/CheckBoxConnector.java index 731838371f..bc405b793b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/checkbox/CheckBoxConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/checkbox/CheckBoxConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.checkbox; -import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -13,7 +12,6 @@ import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.EventHelper; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder; @@ -116,11 +114,6 @@ public class CheckBoxConnector extends AbstractFieldConnector implements return (VCheckBox) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VCheckBox.class); - } - public void onFocus(FocusEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side diff --git a/src/com/vaadin/terminal/gwt/client/ui/combobox/ComboBoxConnector.java b/src/com/vaadin/terminal/gwt/client/ui/combobox/ComboBoxConnector.java index ee16d90b12..ff153d30c9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/combobox/ComboBoxConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/combobox/ComboBoxConnector.java @@ -5,8 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.combobox; import java.util.Iterator; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -227,11 +225,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().initDone = true; } - @Override - protected Widget createWidget() { - return GWT.create(VFilterSelect.class); - } - @Override public VFilterSelect getWidget() { return (VFilterSelect) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java index 7df31a8593..71d670fe9d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java @@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.csslayout; import java.util.HashMap; import java.util.Map; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; @@ -138,11 +137,6 @@ public class CssLayoutConnector extends AbstractLayoutConnector { return (VCssLayout) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VCssLayout.class); - } - public void updateCaption(ComponentConnector child) { Widget childWidget = child.getWidget(); FlowPane cssLayoutWidgetContainer = getWidget().panel; diff --git a/src/com/vaadin/terminal/gwt/client/ui/customcomponent/CustomComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ui/customcomponent/CustomComponentConnector.java index a65187a461..981818fc69 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/customcomponent/CustomComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/customcomponent/CustomComponentConnector.java @@ -3,8 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.customcomponent; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent; import com.vaadin.terminal.gwt.client.ui.AbstractComponentContainerConnector; @@ -16,11 +14,6 @@ import com.vaadin.ui.CustomComponent; public class CustomComponentConnector extends AbstractComponentContainerConnector { - @Override - protected Widget createWidget() { - return GWT.create(VCustomComponent.class); - } - @Override public VCustomComponent getWidget() { return (VCustomComponent) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/customfield/CustomFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/customfield/CustomFieldConnector.java index a2ba09da43..b2801390da 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/customfield/CustomFieldConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/customfield/CustomFieldConnector.java @@ -3,23 +3,11 @@ */ package com.vaadin.terminal.gwt.client.ui.customfield; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.customcomponent.CustomComponentConnector; -import com.vaadin.terminal.gwt.client.ui.customcomponent.VCustomComponent; import com.vaadin.ui.CustomField; @Connect(value = CustomField.class) public class CustomFieldConnector extends CustomComponentConnector { - @Override - protected Widget createWidget() { - return GWT.create(VCustomComponent.class); - } - - @Override - public VCustomComponent getWidget() { - return super.getWidget(); - } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/customlayout/CustomLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/customlayout/CustomLayoutConnector.java index 5e8f01258f..ca24cfc91a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/customlayout/CustomLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/customlayout/CustomLayoutConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.customlayout; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ComponentConnector; @@ -103,11 +102,6 @@ public class CustomLayoutConnector extends AbstractLayoutConnector implements return (VCustomLayout) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VCustomLayout.class); - } - public void updateCaption(ComponentConnector paintable) { getWidget().updateCaption(paintable); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/datefield/AbstractDateFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/datefield/AbstractDateFieldConnector.java index e19d9b996f..b55f480bac 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/datefield/AbstractDateFieldConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/datefield/AbstractDateFieldConnector.java @@ -5,8 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.datefield; import java.util.Date; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.LocaleNotLoadedException; import com.vaadin.terminal.gwt.client.Paintable; @@ -97,11 +95,6 @@ public class AbstractDateFieldConnector extends AbstractFieldConnector } } - @Override - protected Widget createWidget() { - return GWT.create(VDateField.class); - } - @Override public VDateField getWidget() { return (VDateField) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/datefield/InlineDateFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/datefield/InlineDateFieldConnector.java index 8a4840a088..7cd9c110ba 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/datefield/InlineDateFieldConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/datefield/InlineDateFieldConnector.java @@ -5,8 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.datefield; import java.util.Date; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.DateTimeService; import com.vaadin.terminal.gwt.client.UIDL; @@ -92,11 +90,6 @@ public class InlineDateFieldConnector extends AbstractDateFieldConnector { getWidget().calendarPanel.renderCalendar(); } - @Override - protected Widget createWidget() { - return GWT.create(VDateFieldCalendar.class); - } - @Override public VDateFieldCalendar getWidget() { return (VDateFieldCalendar) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/datefield/PopupDateFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/datefield/PopupDateFieldConnector.java index 1bcb40d549..e169d83b48 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/datefield/PopupDateFieldConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/datefield/PopupDateFieldConnector.java @@ -6,8 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.datefield; import java.util.Date; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.DateTimeService; import com.vaadin.terminal.gwt.client.UIDL; @@ -112,11 +110,6 @@ public class PopupDateFieldConnector extends TextualDateConnector { getWidget().calendarToggle.setEnabled(true); } - @Override - protected Widget createWidget() { - return GWT.create(VPopupCalendar.class); - } - @Override public VPopupCalendar getWidget() { return (VPopupCalendar) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/datefield/TextualDateConnector.java b/src/com/vaadin/terminal/gwt/client/ui/datefield/TextualDateConnector.java index 90679f5705..32af4024cb 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/datefield/TextualDateConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/datefield/TextualDateConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.datefield; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.UIDL; @@ -44,11 +42,6 @@ public class TextualDateConnector extends AbstractDateFieldConnector { } - @Override - protected Widget createWidget() { - return GWT.create(VTextualDate.class); - } - @Override public VTextualDate getWidget() { return (VTextualDate) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java b/src/com/vaadin/terminal/gwt/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java index db531ac70f..57f6835bcc 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java @@ -6,8 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.draganddropwrapper; import java.util.HashMap; import java.util.Set; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -62,11 +60,6 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector } } - @Override - protected Widget createWidget() { - return GWT.create(VDragAndDropWrapper.class); - } - @Override public VDragAndDropWrapper getWidget() { return (VDragAndDropWrapper) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/embedded/EmbeddedConnector.java b/src/com/vaadin/terminal/gwt/client/ui/embedded/EmbeddedConnector.java index 81ac195c8e..af3ad67db4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/embedded/EmbeddedConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/embedded/EmbeddedConnector.java @@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.embedded; import java.util.Map; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; @@ -16,7 +15,6 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.Paintable; @@ -181,11 +179,6 @@ public class EmbeddedConnector extends AbstractComponentConnector implements } } - @Override - protected Widget createWidget() { - return GWT.create(VEmbedded.class); - } - @Override public VEmbedded getWidget() { return (VEmbedded) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/form/FormConnector.java b/src/com/vaadin/terminal/gwt/client/ui/form/FormConnector.java index 82cbc95b2d..981c753dd1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/form/FormConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/form/FormConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.form; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.user.client.ui.Widget; @@ -191,11 +190,6 @@ public class FormConnector extends AbstractComponentContainerConnector return (VForm) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VForm.class); - } - @Override public boolean isReadOnly() { return super.isReadOnly() || getState().isPropertyReadOnly(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java index d7774b66ef..cdac73a771 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.formlayout; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent; @@ -97,9 +96,4 @@ public class FormLayoutConnector extends AbstractLayoutConnector { return (VFormLayout) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VFormLayout.class); - } - } diff --git a/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java index e4a31b96ef..50afbc5913 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java @@ -5,7 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.gridlayout; import java.util.Iterator; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -224,11 +223,6 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector return (VGridLayout) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VGridLayout.class); - } - public void layoutVertically() { getWidget().updateHeight(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java index 2285fca267..e64f9fffea 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java @@ -3,10 +3,8 @@ */ package com.vaadin.terminal.gwt.client.ui.label; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.PreElement; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; @@ -17,6 +15,7 @@ import com.vaadin.ui.Label; @Connect(value = Label.class, loadStyle = LoadStyle.EAGER) public class LabelConnector extends AbstractComponentConnector { + @Override public LabelState getState() { return (LabelState) super.getState(); } @@ -61,11 +60,6 @@ public class LabelConnector extends AbstractComponentConnector { } } - @Override - protected Widget createWidget() { - return GWT.create(VLabel.class); - } - @Override public VLabel getWidget() { return (VLabel) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java b/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java index f74a851d03..c002d2dd50 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java @@ -4,9 +4,7 @@ package com.vaadin.terminal.gwt.client.ui.link; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -87,11 +85,6 @@ public class LinkConnector extends AbstractComponentConnector implements } - @Override - protected Widget createWidget() { - return GWT.create(VLink.class); - } - @Override public VLink getWidget() { return (VLink) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/listselect/ListSelectConnector.java b/src/com/vaadin/terminal/gwt/client/ui/listselect/ListSelectConnector.java index ddaa959560..8a4553d983 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/listselect/ListSelectConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/listselect/ListSelectConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.listselect; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.optiongroup.OptionGroupBaseConnector; import com.vaadin.ui.ListSelect; @@ -13,11 +11,6 @@ import com.vaadin.ui.ListSelect; @Connect(ListSelect.class) public class ListSelectConnector extends OptionGroupBaseConnector { - @Override - protected Widget createWidget() { - return GWT.create(VListSelect.class); - } - @Override public VListSelect getWidget() { return (VListSelect) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/menubar/MenuBarConnector.java b/src/com/vaadin/terminal/gwt/client/ui/menubar/MenuBarConnector.java index d063c89ca9..d1f77aa0ff 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/menubar/MenuBarConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/menubar/MenuBarConnector.java @@ -8,7 +8,6 @@ import java.util.Stack; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -153,11 +152,6 @@ public class MenuBarConnector extends AbstractComponentConnector implements }// updateFromUIDL - @Override - protected Widget createWidget() { - return GWT.create(VMenuBar.class); - } - @Override public VMenuBar getWidget() { return (VMenuBar) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/nativebutton/NativeButtonConnector.java b/src/com/vaadin/terminal/gwt/client/ui/nativebutton/NativeButtonConnector.java index 84d3b73285..c010fba711 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/nativebutton/NativeButtonConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/nativebutton/NativeButtonConnector.java @@ -3,14 +3,12 @@ */ package com.vaadin.terminal.gwt.client.ui.nativebutton; -import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.EventHelper; import com.vaadin.terminal.gwt.client.communication.FieldRpc.FocusAndBlurServerRpc; import com.vaadin.terminal.gwt.client.communication.RpcProxy; @@ -99,11 +97,6 @@ public class NativeButtonConnector extends AbstractComponentConnector implements } - @Override - protected Widget createWidget() { - return GWT.create(VNativeButton.class); - } - @Override public VNativeButton getWidget() { return (VNativeButton) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/nativeselect/NativeSelectConnector.java b/src/com/vaadin/terminal/gwt/client/ui/nativeselect/NativeSelectConnector.java index e6264e492f..8f57e0c37f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/nativeselect/NativeSelectConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/nativeselect/NativeSelectConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.nativeselect; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.optiongroup.OptionGroupBaseConnector; import com.vaadin.ui.NativeSelect; @@ -13,11 +11,6 @@ import com.vaadin.ui.NativeSelect; @Connect(NativeSelect.class) public class NativeSelectConnector extends OptionGroupBaseConnector { - @Override - protected Widget createWidget() { - return GWT.create(VNativeSelect.class); - } - @Override public VNativeSelect getWidget() { return (VNativeSelect) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/optiongroup/OptionGroupConnector.java b/src/com/vaadin/terminal/gwt/client/ui/optiongroup/OptionGroupConnector.java index 06552a2812..e6064bd03f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/optiongroup/OptionGroupConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/optiongroup/OptionGroupConnector.java @@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui.optiongroup; import java.util.ArrayList; -import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.Widget; @@ -61,11 +60,6 @@ public class OptionGroupConnector extends OptionGroupBaseConnector { } } - @Override - protected Widget createWidget() { - return GWT.create(VOptionGroup.class); - } - @Override public VOptionGroup getWidget() { return (VOptionGroup) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/HorizontalLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/HorizontalLayoutConnector.java index a12b41ade7..3b0014c0f0 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/HorizontalLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/HorizontalLayoutConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.orderedlayout; -import com.google.gwt.core.client.GWT; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.Connect.LoadStyle; import com.vaadin.ui.HorizontalLayout; @@ -16,9 +15,4 @@ public class HorizontalLayoutConnector extends AbstractOrderedLayoutConnector { return (VHorizontalLayout) super.getWidget(); } - @Override - protected VHorizontalLayout createWidget() { - return GWT.create(VHorizontalLayout.class); - } - } diff --git a/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VerticalLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VerticalLayoutConnector.java index 1e5651ce38..42a762864e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VerticalLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VerticalLayoutConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.orderedlayout; -import com.google.gwt.core.client.GWT; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.Connect.LoadStyle; import com.vaadin.ui.VerticalLayout; @@ -16,9 +15,4 @@ public class VerticalLayoutConnector extends AbstractOrderedLayoutConnector { return (VVerticalLayout) super.getWidget(); } - @Override - protected VVerticalLayout createWidget() { - return GWT.create(VVerticalLayout.class); - } - } diff --git a/src/com/vaadin/terminal/gwt/client/ui/panel/PanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/panel/PanelConnector.java index 9555c38a36..35a0ede390 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/panel/PanelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/panel/PanelConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.panel; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; @@ -172,11 +171,6 @@ public class PanelConnector extends AbstractComponentContainerConnector return (VPanel) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VPanel.class); - } - public void layout() { updateSizes(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java index 29a1aeef79..c4c5954c33 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/passwordfield/PasswordFieldConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.passwordfield; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector; import com.vaadin.ui.PasswordField; @@ -13,11 +11,6 @@ import com.vaadin.ui.PasswordField; @Connect(PasswordField.class) public class PasswordFieldConnector extends TextFieldConnector { - @Override - protected Widget createWidget() { - return GWT.create(VPasswordField.class); - } - @Override public VPasswordField getWidget() { return (VPasswordField) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/popupview/PopupViewConnector.java b/src/com/vaadin/terminal/gwt/client/ui/popupview/PopupViewConnector.java index 4faa6cec86..c5117fdddb 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/popupview/PopupViewConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/popupview/PopupViewConnector.java @@ -3,8 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.popupview; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.Paintable; @@ -106,11 +104,6 @@ public class PopupViewConnector extends AbstractComponentContainerConnector return (VPopupView) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VPopupView.class); - } - public void postLayout() { if (centerAfterLayout) { centerAfterLayout = false; diff --git a/src/com/vaadin/terminal/gwt/client/ui/progressindicator/ProgressIndicatorConnector.java b/src/com/vaadin/terminal/gwt/client/ui/progressindicator/ProgressIndicatorConnector.java index 09fa5fb44e..9d0532fae3 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/progressindicator/ProgressIndicatorConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/progressindicator/ProgressIndicatorConnector.java @@ -4,9 +4,7 @@ package com.vaadin.terminal.gwt.client.ui.progressindicator; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -54,11 +52,6 @@ public class ProgressIndicatorConnector extends AbstractFieldConnector } } - @Override - protected Widget createWidget() { - return GWT.create(VProgressIndicator.class); - } - @Override public VProgressIndicator getWidget() { return (VProgressIndicator) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/RichTextAreaConnector.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/RichTextAreaConnector.java index 01e79bc1c3..db52640088 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/RichTextAreaConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/RichTextAreaConnector.java @@ -3,9 +3,7 @@ */ package com.vaadin.terminal.gwt.client.ui.richtextarea; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -70,9 +68,4 @@ public class RichTextAreaConnector extends AbstractFieldConnector implements return (VRichTextArea) super.getWidget(); }; - @Override - protected Widget createWidget() { - return GWT.create(VRichTextArea.class); - } - } diff --git a/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java index 46f82d60b7..e02bcc9330 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; @@ -299,11 +298,6 @@ public class RootConnector extends AbstractComponentContainerConnector return (VRoot) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VRoot.class); - } - protected ComponentConnector getContent() { return (ComponentConnector) getState().getContent(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java b/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java index 9cd3c35fee..6fd7f8b6aa 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java @@ -3,10 +3,8 @@ */ package com.vaadin.terminal.gwt.client.ui.slider; -import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -69,9 +67,4 @@ public class SliderConnector extends AbstractFieldConnector implements return (VSlider) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VSlider.class); - } - } diff --git a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java index b3921204dc..a2f1f26c15 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -171,9 +171,6 @@ public abstract class AbstractSplitPanelConnector extends return (VAbstractSplitPanel) super.getWidget(); } - @Override - protected abstract VAbstractSplitPanel createWidget(); - @Override public AbstractSplitPanelState getState() { return (AbstractSplitPanelState) super.getState(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/HorizontalSplitPanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/HorizontalSplitPanelConnector.java index 7814ab8e13..92c942e04b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/HorizontalSplitPanelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/HorizontalSplitPanelConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.splitpanel; -import com.google.gwt.core.client.GWT; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.Connect.LoadStyle; import com.vaadin.ui.HorizontalSplitPanel; @@ -12,8 +11,8 @@ import com.vaadin.ui.HorizontalSplitPanel; public class HorizontalSplitPanelConnector extends AbstractSplitPanelConnector { @Override - protected VAbstractSplitPanel createWidget() { - return GWT.create(VSplitPanelHorizontal.class); + public VSplitPanelHorizontal getWidget() { + return (VSplitPanelHorizontal) super.getWidget(); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VerticalSplitPanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VerticalSplitPanelConnector.java index 83404177c0..5015fcc60c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VerticalSplitPanelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VerticalSplitPanelConnector.java @@ -12,8 +12,8 @@ import com.vaadin.ui.VerticalSplitPanel; public class VerticalSplitPanelConnector extends AbstractSplitPanelConnector { @Override - protected VAbstractSplitPanel createWidget() { - return GWT.create(VSplitPanelVertical.class); + public VSplitPanelVertical getWidget() { + return (VSplitPanelVertical) super.getWidget(); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/table/TableConnector.java b/src/com/vaadin/terminal/gwt/client/ui/table/TableConnector.java index f16ee3463f..73bc5da83f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/table/TableConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/table/TableConnector.java @@ -5,7 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.table; import java.util.Iterator; -import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style.Position; @@ -260,11 +259,6 @@ public class TableConnector extends AbstractComponentContainerConnector } - @Override - protected Widget createWidget() { - return GWT.create(VScrollTable.class); - } - @Override public VScrollTable getWidget() { return (VScrollTable) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/tabsheet/TabsheetConnector.java b/src/com/vaadin/terminal/gwt/client/ui/tabsheet/TabsheetConnector.java index 7829934f70..08d4679dc5 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/tabsheet/TabsheetConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/tabsheet/TabsheetConnector.java @@ -62,11 +62,6 @@ public class TabsheetConnector extends TabsheetBaseConnector implements getWidget().waitingForResponse = false; } - @Override - protected Widget createWidget() { - return GWT.create(VTabsheet.class); - } - @Override public VTabsheet getWidget() { return (VTabsheet) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java b/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java index ea32ae49c6..a235ca5389 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.textarea; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.ui.Connect; import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector; @@ -27,11 +25,6 @@ public class TextAreaConnector extends TextFieldConnector { getWidget().setWordwrap(getState().isWordwrap()); } - @Override - protected Widget createWidget() { - return GWT.create(VTextArea.class); - } - @Override public VTextArea getWidget() { return (VTextArea) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java b/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java index 069dd1fb0d..04bf029b05 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/textfield/TextFieldConnector.java @@ -4,11 +4,9 @@ package com.vaadin.terminal.gwt.client.ui.textfield; -import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -92,11 +90,6 @@ public class TextFieldConnector extends AbstractFieldConnector implements } } - @Override - protected Widget createWidget() { - return GWT.create(VTextField.class); - } - @Override public VTextField getWidget() { return (VTextField) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/tree/TreeConnector.java b/src/com/vaadin/terminal/gwt/client/ui/tree/TreeConnector.java index ebe5d22e99..e4afa32143 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/tree/TreeConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/tree/TreeConnector.java @@ -5,8 +5,6 @@ package com.vaadin.terminal.gwt.client.ui.tree; import java.util.Iterator; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.AbstractFieldState; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; @@ -129,11 +127,6 @@ public class TreeConnector extends AbstractComponentConnector implements } - @Override - protected Widget createWidget() { - return GWT.create(VTree.class); - } - @Override public VTree getWidget() { return (VTree) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/treetable/TreeTableConnector.java b/src/com/vaadin/terminal/gwt/client/ui/treetable/TreeTableConnector.java index f81771781b..59910c1b3e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/treetable/TreeTableConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/treetable/TreeTableConnector.java @@ -3,8 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.treetable; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.ui.Connect; @@ -90,11 +88,6 @@ public class TreeTableConnector extends TableConnector { } } - @Override - protected Widget createWidget() { - return GWT.create(VTreeTable.class); - } - @Override public VTreeTable getWidget() { return (VTreeTable) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/twincolselect/TwinColSelectConnector.java b/src/com/vaadin/terminal/gwt/client/ui/twincolselect/TwinColSelectConnector.java index 328d0fc18b..a77319920c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/twincolselect/TwinColSelectConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/twincolselect/TwinColSelectConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.twincolselect; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.DirectionalManagedLayout; import com.vaadin.terminal.gwt.client.UIDL; @@ -41,11 +39,6 @@ public class TwinColSelectConnector extends OptionGroupBaseConnector implements getWidget().captionWrapper.getElement()); } - @Override - protected Widget createWidget() { - return GWT.create(VTwinColSelect.class); - } - @Override public VTwinColSelect getWidget() { return (VTwinColSelect) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/upload/UploadConnector.java b/src/com/vaadin/terminal/gwt/client/ui/upload/UploadConnector.java index 0a2c0b241e..153d99229b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/upload/UploadConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/upload/UploadConnector.java @@ -4,8 +4,6 @@ package com.vaadin.terminal.gwt.client.ui.upload; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -55,11 +53,6 @@ public class UploadConnector extends AbstractComponentConnector implements } } - @Override - protected Widget createWidget() { - return GWT.create(VUpload.class); - } - @Override public VUpload getWidget() { return (VUpload) super.getWidget(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/video/VideoConnector.java b/src/com/vaadin/terminal/gwt/client/ui/video/VideoConnector.java index da1631c44d..ddf8df66ff 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/video/VideoConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/video/VideoConnector.java @@ -3,8 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.video; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.communication.URLReference; import com.vaadin.terminal.gwt.client.ui.Connect; @@ -35,11 +33,6 @@ public class VideoConnector extends MediaBaseConnector { return (VVideo) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VVideo.class); - } - @Override protected String getDefaultAltHtml() { return "Your browser does not support the video element."; diff --git a/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java index 6979982a9c..3a37baafbb 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java @@ -3,7 +3,6 @@ */ package com.vaadin.terminal.gwt.client.ui.window; -import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; @@ -195,11 +194,6 @@ public class WindowConnector extends AbstractComponentContainerConnector return (VWindow) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VWindow.class); - } - @Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { super.onConnectorHierarchyChange(event); diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java new file mode 100644 index 0000000000..3a13fceece --- /dev/null +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java @@ -0,0 +1,145 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils; + +import java.io.PrintWriter; +import java.util.Date; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.ext.Generator; +import com.google.gwt.core.ext.GeneratorContext; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.TreeLogger.Type; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; +import com.google.gwt.core.ext.typeinfo.TypeOracle; +import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; +import com.google.gwt.user.rebind.SourceWriter; +import com.vaadin.terminal.gwt.client.ServerConnector; +import com.vaadin.terminal.gwt.client.ui.ConnectorClassBasedFactory; +import com.vaadin.terminal.gwt.client.ui.ConnectorClassBasedFactory.Creator; + +/** + * GWT generator that creates a lookup method for + * {@link ConnectorClassBasedFactory} instances. + * + * @since 7.0 + */ +public abstract class AbstractConnectorClassBasedFactoryGenerator extends + Generator { + + @Override + public String generate(TreeLogger logger, GeneratorContext context, + String typeName) throws UnableToCompleteException { + + try { + // get classType and save instance variables + return generateConnectorClassBasedFactory(typeName, logger, context); + } catch (Exception e) { + logger.log(TreeLogger.ERROR, typeName + " creation failed", e); + throw new UnableToCompleteException(); + } + } + + private String generateConnectorClassBasedFactory(String typeName, + TreeLogger logger, GeneratorContext context) + throws NotFoundException { + TypeOracle typeOracle = context.getTypeOracle(); + + JClassType classType = typeOracle.getType(typeName); + String superName = classType.getSimpleSourceName(); + String packageName = classType.getPackage().getName(); + String className = superName + "Impl"; + + // get print writer that receives the source code + PrintWriter printWriter = null; + printWriter = context.tryCreate(logger, packageName, className); + // print writer if null, source code has ALREADY been generated + if (printWriter == null) { + return packageName + "." + className; + } + + Date date = new Date(); + + // init composer, set class properties, create source writer + ClassSourceFileComposerFactory composer = null; + composer = new ClassSourceFileComposerFactory(packageName, className); + composer.addImport(GWT.class.getName()); + composer.addImport(Creator.class.getCanonicalName()); + composer.setSuperclass(superName); + + SourceWriter sourceWriter = composer.createSourceWriter(context, + printWriter); + sourceWriter.indent(); + + // public ConnectorStateFactoryImpl() { + sourceWriter.println("public " + className + "() {"); + sourceWriter.indent(); + + JClassType serverConnectorType = typeOracle.getType(getConnectorType() + .getCanonicalName()); + for (JClassType connector : serverConnectorType.getSubtypes()) { + // addCreator(TextAreaConnector.class, new Creator() { + if (connector.isInterface() != null || connector.isAbstract()) { + continue; + } + + JClassType targetType = getTargetType(connector); + if (targetType.isAbstract()) { + continue; + } + + sourceWriter.println("addCreator(" + + connector.getQualifiedSourceName() + + ".class, new Creator<" + + targetType.getQualifiedSourceName() + ">() {"); + // public SharedState create() { + sourceWriter.println("public " + + targetType.getQualifiedSourceName() + " create() {"); + // return GWT.create(TextAreaState.class); + sourceWriter.println("return GWT.create(" + + targetType.getQualifiedSourceName() + ".class);"); + // } + sourceWriter.println("}"); + // }); + sourceWriter.println("});"); + } + + // End of constructor + sourceWriter.outdent(); + sourceWriter.println("}"); + + // close generated class + sourceWriter.outdent(); + sourceWriter.println("}"); + + // commit generated class + context.commit(logger, printWriter); + logger.log(Type.INFO, + "Done. (" + (new Date().getTime() - date.getTime()) / 1000 + + "seconds)"); + return packageName + "." + className; + + } + + protected abstract Class getConnectorType(); + + protected abstract JClassType getTargetType(JClassType connectorType); + + protected JClassType getGetterReturnType(JClassType connector, + String getterName) { + try { + JMethod getMethod = connector.getMethod(getterName, new JType[] {}); + return (JClassType) getMethod.getReturnType(); + } catch (NotFoundException e) { + return getGetterReturnType(connector.getSuperclass(), getterName); + } + + } + +} diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java new file mode 100644 index 0000000000..33406ef85f --- /dev/null +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java @@ -0,0 +1,29 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils; + +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.vaadin.terminal.gwt.client.ServerConnector; + +/** + * GWT generator that creates a SharedState class for a given Connector class, + * based on the return type of getState() + * + * @since 7.0 + */ +public class ConnectorStateFactoryGenerator extends + AbstractConnectorClassBasedFactoryGenerator { + + @Override + protected JClassType getTargetType(JClassType connectorType) { + return getGetterReturnType(connectorType, "getState"); + } + + @Override + protected Class getConnectorType() { + return ServerConnector.class; + } + +} diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java new file mode 100644 index 0000000000..55a2857ce0 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java @@ -0,0 +1,29 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils; + +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.vaadin.terminal.gwt.client.ComponentConnector; +import com.vaadin.terminal.gwt.client.ServerConnector; + +/** + * GWT generator that creates a Widget class for a given Connector class, based + * on the return type of getWidget() + * + * @since 7.0 + */ +public class ConnectorWidgetFactoryGenerator extends + AbstractConnectorClassBasedFactoryGenerator { + @Override + protected JClassType getTargetType(JClassType connectorType) { + return getGetterReturnType(connectorType, "getWidget"); + } + + @Override + protected Class getConnectorType() { + return ComponentConnector.class; + } + +} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/dd/MyDragSourceConnector.java b/tests/testbench/com/vaadin/tests/dd/MyDragSourceConnector.java index c94ac05ea2..2b01bad2cf 100644 --- a/tests/testbench/com/vaadin/tests/dd/MyDragSourceConnector.java +++ b/tests/testbench/com/vaadin/tests/dd/MyDragSourceConnector.java @@ -3,8 +3,6 @@ */ package com.vaadin.tests.dd; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -23,8 +21,8 @@ public class MyDragSourceConnector extends AbstractComponentConnector implements } @Override - protected Widget createWidget() { - return GWT.create(VMyDragSource.class); + public VMyDragSource getWidget() { + return (VMyDragSource) super.getWidget(); } } diff --git a/tests/testbench/com/vaadin/tests/dd/MyDropTargetConnector.java b/tests/testbench/com/vaadin/tests/dd/MyDropTargetConnector.java index 0021cbf7ea..5671efa236 100644 --- a/tests/testbench/com/vaadin/tests/dd/MyDropTargetConnector.java +++ b/tests/testbench/com/vaadin/tests/dd/MyDropTargetConnector.java @@ -3,8 +3,6 @@ */ package com.vaadin.tests.dd; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; @@ -28,9 +26,4 @@ public class MyDropTargetConnector extends AbstractComponentConnector implements return (VMyDropTarget) super.getWidget(); } - @Override - protected Widget createWidget() { - return GWT.create(VMyDropTarget.class); - } - } -- 2.39.5