</replace-with>
<generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator">
+ class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator">
<when-type-is class="com.vaadin.terminal.gwt.client.WidgetMap" />
</generate-with>
class="com.vaadin.terminal.gwt.client.communication.RpcManager" />
</generate-with>
+ <generate-with
+ class="com.vaadin.terminal.gwt.widgetsetutils.ConnectorWidgetFactoryGenerator">
+ <when-type-assignable
+ class="com.vaadin.terminal.gwt.client.ui.ConnectorWidgetFactory" />
+ </generate-with>
+
+ <generate-with
+ class="com.vaadin.terminal.gwt.widgetsetutils.ConnectorStateFactoryGenerator">
+ <when-type-assignable
+ class="com.vaadin.terminal.gwt.client.ui.ConnectorStateFactory" />
+ </generate-with>
+
<entry-point class="com.vaadin.terminal.gwt.client.ApplicationConfiguration" />
<!-- Use the new cross site linker to get a nocache.js without document.write -->
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);
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;
/**
*/
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.
*
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;
private Widget widget;
- // shared state from the server to the client
- private ComponentState state;
-
private String lastKnownWidth = "";
private String lastKnownHeight = "";
*
* @return
*/
- protected abstract Widget createWidget();
+ protected Widget createWidget() {
+ return ConnectorWidgetFactory.createWidget(getClass());
+ }
/**
* Returns the widget associated with this paintable. The widget returned by
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);
* 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());
}
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());
}
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;
private Map<String, Collection<ClientRpc>> rpcImplementations;
private final boolean debugLogging = false;
+ private SharedState state;
+
/*
* (non-Javadoc)
*
}
}
+
+ /**
+ * 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());
+ }
+
}
--- /dev/null
+/*
+@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<T> {
+ public interface Creator<T> {
+ public T create();
+ }
+
+ private Map<Class<? extends Connector>, Creator<? extends T>> creators = new HashMap<Class<? extends Connector>, Creator<? extends T>>();
+
+ protected void addCreator(Class<? extends Connector> cls,
+ Creator<? extends T> 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<? extends Connector> connector) {
+ Creator<? extends T> 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();
+ }
+
+}
--- /dev/null
+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<SharedState> {
+ 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<? extends Connector> connector) {
+ return getImpl().create(connector);
+ }
+
+ private static ConnectorStateFactory getImpl() {
+ if (impl == null) {
+ impl = GWT.create(ConnectorStateFactory.class);
+ }
+ return impl;
+ }
+}
--- /dev/null
+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<Widget> {
+ private static ConnectorWidgetFactory impl = null;
+
+ // TODO Move to generator
+ {
+ addCreator(TextFieldConnector.class, new Creator<Widget>() {
+ 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<? extends AbstractComponentConnector> connector) {
+ return getImpl().create(connector);
+ }
+
+ private static ConnectorWidgetFactory getImpl() {
+ if (impl == null) {
+ impl = GWT.create(ConnectorWidgetFactory.class);
+ }
+ return impl;
+ }
+}
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 {
return false;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VUnknownComponent.class);
- }
-
@Override
public VUnknownComponent getWidget() {
return (VUnknownComponent) super.getWidget();
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;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VAbsoluteLayout.class);
- }
-
@Override
public VAbsoluteLayout getWidget() {
return (VAbsoluteLayout) super.getWidget();
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;
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 */
}
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;
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;
getWidget().clickShortcut = getState().getClickShortcutKeyCode();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VButton.class);
- }
-
@Override
public VButton getWidget() {
return (VButton) super.getWidget();
*/
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;
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;
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
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;
getWidget().initDone = true;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VFilterSelect.class);
- }
-
@Override
public VFilterSelect getWidget() {
return (VFilterSelect) super.getWidget();
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;
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;
*/
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;
public class CustomComponentConnector extends
AbstractComponentContainerConnector {
- @Override
- protected Widget createWidget() {
- return GWT.create(VCustomComponent.class);
- }
-
@Override
public VCustomComponent getWidget() {
return (VCustomComponent) super.getWidget();
*/
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();
- }
}
*/
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;
return (VCustomLayout) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VCustomLayout.class);
- }
-
public void updateCaption(ComponentConnector paintable) {
getWidget().updateCaption(paintable);
}
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VDateField.class);
- }
-
@Override
public VDateField getWidget() {
return (VDateField) super.getWidget();
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;
getWidget().calendarPanel.renderCalendar();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VDateFieldCalendar.class);
- }
-
@Override
public VDateFieldCalendar getWidget() {
return (VDateFieldCalendar) super.getWidget();
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;
getWidget().calendarToggle.setEnabled(true);
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VPopupCalendar.class);
- }
-
@Override
public VPopupCalendar getWidget() {
return (VPopupCalendar) super.getWidget();
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;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTextualDate.class);
- }
-
@Override
public VTextualDate getWidget() {
return (VTextualDate) super.getWidget();
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VDragAndDropWrapper.class);
- }
-
@Override
public VDragAndDropWrapper getWidget() {
return (VDragAndDropWrapper) super.getWidget();
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;
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VEmbedded.class);
- }
-
@Override
public VEmbedded getWidget() {
return (VEmbedded) super.getWidget();
*/
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;
return (VForm) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VForm.class);
- }
-
@Override
public boolean isReadOnly() {
return super.isReadOnly() || getState().isPropertyReadOnly();
*/
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;
return (VFormLayout) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VFormLayout.class);
- }
-
}
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;
return (VGridLayout) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VGridLayout.class);
- }
-
public void layoutVertically() {
getWidget().updateHeight();
}
*/
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;
@Connect(value = Label.class, loadStyle = LoadStyle.EAGER)
public class LabelConnector extends AbstractComponentConnector {
+ @Override
public LabelState getState() {
return (LabelState) super.getState();
}
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VLabel.class);
- }
-
@Override
public VLabel getWidget() {
return (VLabel) super.getWidget();
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;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VLink.class);
- }
-
@Override
public VLink getWidget() {
return (VLink) super.getWidget();
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;
@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();
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;
}// updateFromUIDL
- @Override
- protected Widget createWidget() {
- return GWT.create(VMenuBar.class);
- }
-
@Override
public VMenuBar getWidget() {
return (VMenuBar) super.getWidget();
*/
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;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VNativeButton.class);
- }
-
@Override
public VNativeButton getWidget() {
return (VNativeButton) super.getWidget();
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;
@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();
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VOptionGroup.class);
- }
-
@Override
public VOptionGroup getWidget() {
return (VOptionGroup) super.getWidget();
*/
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;
return (VHorizontalLayout) super.getWidget();
}
- @Override
- protected VHorizontalLayout createWidget() {
- return GWT.create(VHorizontalLayout.class);
- }
-
}
*/
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;
return (VVerticalLayout) super.getWidget();
}
- @Override
- protected VVerticalLayout createWidget() {
- return GWT.create(VVerticalLayout.class);
- }
-
}
*/
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;
return (VPanel) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VPanel.class);
- }
-
public void layout() {
updateSizes();
}
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;
@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();
*/
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;
return (VPopupView) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VPopupView.class);
- }
-
public void postLayout() {
if (centerAfterLayout) {
centerAfterLayout = false;
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VProgressIndicator.class);
- }
-
@Override
public VProgressIndicator getWidget() {
return (VProgressIndicator) super.getWidget();
*/
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;
return (VRichTextArea) super.getWidget();
};
- @Override
- protected Widget createWidget() {
- return GWT.create(VRichTextArea.class);
- }
-
}
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;
return (VRoot) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VRoot.class);
- }
-
protected ComponentConnector getContent() {
return (ComponentConnector) getState().getContent();
}
*/
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;
return (VSlider) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VSlider.class);
- }
-
}
return (VAbstractSplitPanel) super.getWidget();
}
- @Override
- protected abstract VAbstractSplitPanel createWidget();
-
@Override
public AbstractSplitPanelState getState() {
return (AbstractSplitPanelState) super.getState();
*/
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;
public class HorizontalSplitPanelConnector extends AbstractSplitPanelConnector {
@Override
- protected VAbstractSplitPanel createWidget() {
- return GWT.create(VSplitPanelHorizontal.class);
+ public VSplitPanelHorizontal getWidget() {
+ return (VSplitPanelHorizontal) super.getWidget();
}
}
public class VerticalSplitPanelConnector extends AbstractSplitPanelConnector {
@Override
- protected VAbstractSplitPanel createWidget() {
- return GWT.create(VSplitPanelVertical.class);
+ public VSplitPanelVertical getWidget() {
+ return (VSplitPanelVertical) super.getWidget();
}
}
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;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VScrollTable.class);
- }
-
@Override
public VScrollTable getWidget() {
return (VScrollTable) super.getWidget();
getWidget().waitingForResponse = false;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTabsheet.class);
- }
-
@Override
public VTabsheet getWidget() {
return (VTabsheet) super.getWidget();
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;
getWidget().setWordwrap(getState().isWordwrap());
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTextArea.class);
- }
-
@Override
public VTextArea getWidget() {
return (VTextArea) super.getWidget();
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTextField.class);
- }
-
@Override
public VTextField getWidget() {
return (VTextField) super.getWidget();
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;
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTree.class);
- }
-
@Override
public VTree getWidget() {
return (VTree) super.getWidget();
*/
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTreeTable.class);
- }
-
@Override
public VTreeTable getWidget() {
return (VTreeTable) super.getWidget();
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;
getWidget().captionWrapper.getElement());
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VTwinColSelect.class);
- }
-
@Override
public VTwinColSelect getWidget() {
return (VTwinColSelect) super.getWidget();
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;
}
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VUpload.class);
- }
-
@Override
public VUpload getWidget() {
return (VUpload) super.getWidget();
*/
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;
return (VVideo) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VVideo.class);
- }
-
@Override
protected String getDefaultAltHtml() {
return "Your browser does not support the <code>video</code> element.";
*/
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;
return (VWindow) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VWindow.class);
- }
-
@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
super.onConnectorHierarchyChange(event);
--- /dev/null
+/*
+@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<SharedState>() {
+ 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<? extends ServerConnector> 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);
+ }
+
+ }
+
+}
--- /dev/null
+/*
+@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<? extends ServerConnector> getConnectorType() {
+ return ServerConnector.class;
+ }
+
+}
--- /dev/null
+/*
+@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<? extends ServerConnector> getConnectorType() {
+ return ComponentConnector.class;
+ }
+
+}
\ No newline at end of file
*/
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;
}
@Override
- protected Widget createWidget() {
- return GWT.create(VMyDragSource.class);
+ public VMyDragSource getWidget() {
+ return (VMyDragSource) super.getWidget();
}
}
*/
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;
return (VMyDropTarget) super.getWidget();
}
- @Override
- protected Widget createWidget() {
- return GWT.create(VMyDropTarget.class);
- }
-
}