summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-08-27 12:40:41 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2012-08-27 12:40:41 +0300
commita67ca492c18451c0f286e90b3a5fb34bde2d3c47 (patch)
tree77f8879242385bfa6f970bfb129531dd32ce242a /client
parentc8cee295021dcd33982217e3ad1c374bfca63a29 (diff)
parentfc3f7f62b05ae69b242d64084f676d7733962c60 (diff)
downloadvaadin-framework-a67ca492c18451c0f286e90b3a5fb34bde2d3c47.tar.gz
vaadin-framework-a67ca492c18451c0f286e90b3a5fb34bde2d3c47.zip
Merge branch 'master' into root-cleanup
Rename Root -> UI in root cleanup code Conflicts: client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java server/src/com/vaadin/ui/UI.java
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/Vaadin.gwt.xml46
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java151
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java157
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ServerConnector.java10
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/WidgetSet.java65
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java1
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java39
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java1
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java49
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java34
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java54
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java46
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java51
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java44
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/Type.java52
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java1
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java86
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java11
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java99
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java21
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java9
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Method.java71
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java (renamed from client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java)21
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Property.java69
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java (renamed from client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java)25
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Type.java97
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java20
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java33
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java226
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java22
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java18
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java52
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java43
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java55
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java3
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java (renamed from client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java)40
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java (renamed from client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java)10
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java33
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java8
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java38
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java120
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java44
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java228
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java67
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java10
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java8
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java60
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java89
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java251
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java3
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java9
53 files changed, 1899 insertions, 909 deletions
diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml
index 07d7c941e6..44357b24a0 100644
--- a/client/src/com/vaadin/Vaadin.gwt.xml
+++ b/client/src/com/vaadin/Vaadin.gwt.xml
@@ -23,60 +23,18 @@
<when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" />
</replace-with>
- <!-- Generators for serializators for classes used in communication between
- server and client -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.SerializerMapGenerator">
- <when-type-is
- class="com.vaadin.terminal.gwt.client.communication.SerializerMap" />
- </generate-with>
-
<replace-with class="com.vaadin.terminal.gwt.client.VDebugConsole">
<when-type-is class="com.vaadin.terminal.gwt.client.Console" />
</replace-with>
<generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator">
- <when-type-is class="com.vaadin.terminal.gwt.client.WidgetMap" />
- </generate-with>
-
- <generate-with
class="com.vaadin.terminal.gwt.widgetsetutils.AcceptCriteriaFactoryGenerator">
<when-type-is
class="com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory" />
</generate-with>
- <!-- Generate client side proxies for client to server RPC interfaces -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.RpcProxyGenerator">
- <when-type-assignable
- class="com.vaadin.shared.communication.ServerRpc" />
- </generate-with>
-
- <!-- Generate client side proxies for client to server RPC interfaces -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.RpcProxyCreatorGenerator">
- <when-type-assignable
- class="com.vaadin.terminal.gwt.client.communication.RpcProxy.RpcProxyCreator" />
- </generate-with>
-
- <!-- Generate client side RPC manager for server to client RPC -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.GeneratedRpcMethodProviderGenerator">
- <when-type-assignable
- class="com.vaadin.terminal.gwt.client.communication.GeneratedRpcMethodProvider" />
- </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 class="com.vaadin.terminal.gwt.widgetsetutils.ConnectorBundleLoaderFactory">
+ <when-type-assignable class="com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader" />
</generate-with>
<!-- Use the new cross site linker to get a nocache.js without document.write -->
diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
index 2771871653..2eccd9bb8c 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
@@ -29,9 +29,13 @@ import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.vaadin.shared.ApplicationConstants;
+import com.vaadin.shared.ui.ui.UIConstants;
+import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector;
public class ApplicationConfiguration implements EntryPoint {
@@ -199,7 +203,7 @@ public class ApplicationConfiguration implements EntryPoint {
private String id;
private String themeUri;
private String appUri;
- private int rootId;
+ private int uiId;
private boolean standalone;
private ErrorMessage communicationError;
private ErrorMessage authorizationError;
@@ -208,7 +212,7 @@ public class ApplicationConfiguration implements EntryPoint {
private HashMap<Integer, String> unknownComponents;
- private Class<? extends ServerConnector>[] classes = new Class[1024];
+ private Map<Integer, Class<? extends ServerConnector>> classes = new HashMap<Integer, Class<? extends ServerConnector>>();
private boolean browserDetailsSent = false;
private boolean widgetsetVersionSent = false;
@@ -282,12 +286,12 @@ public class ApplicationConfiguration implements EntryPoint {
/**
* Gets the root if of this application instance. The root id should be
* included in every request originating from this instance in order to
- * associate it with the right Root instance on the server.
+ * associate it with the right UI instance on the server.
*
* @return the root id
*/
- public int getRootId() {
- return rootId;
+ public int getUIId() {
+ return uiId;
}
/**
@@ -320,7 +324,8 @@ public class ApplicationConfiguration implements EntryPoint {
appUri += '/';
}
themeUri = jsoConfiguration.getConfigString("themeUri");
- rootId = jsoConfiguration.getConfigInteger("rootId").intValue();
+ uiId = jsoConfiguration.getConfigInteger(UIConstants.UI_ID_PARAMETER)
+ .intValue();
// null -> true
useDebugIdInDom = jsoConfiguration.getConfigBoolean("useDebugIdInDom") != Boolean.FALSE;
@@ -402,12 +407,32 @@ public class ApplicationConfiguration implements EntryPoint {
public Class<? extends ServerConnector> getConnectorClassByEncodedTag(
int tag) {
- try {
- return classes[tag];
- } catch (Exception e) {
- // component was not present in mappings
- return UnknownComponentConnector.class;
+ Class<? extends ServerConnector> type = classes.get(tag);
+ if (type == null && !classes.containsKey(tag)) {
+ // Initialize if not already loaded
+ Integer currentTag = Integer.valueOf(tag);
+ while (type == null && currentTag != null) {
+ String serverSideClassNameForTag = getServerSideClassNameForTag(currentTag);
+ if (TypeData.hasIdentifier(serverSideClassNameForTag)) {
+ try {
+ type = (Class<? extends ServerConnector>) TypeData
+ .getClass(serverSideClassNameForTag);
+ } catch (NoDataException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ currentTag = getParentTag(currentTag.intValue());
+ }
+ if (type == null) {
+ type = UnknownComponentConnector.class;
+ if (unknownComponents == null) {
+ unknownComponents = new HashMap<Integer, String>();
+ }
+ unknownComponents.put(tag, getServerSideClassNameForTag(tag));
+ }
+ classes.put(tag, type);
}
+ return type;
}
public void addComponentInheritanceInfo(ValueMap valueMap) {
@@ -430,13 +455,7 @@ public class ApplicationConfiguration implements EntryPoint {
for (int i = 0; i < keyArray.length(); i++) {
String key = keyArray.get(i).intern();
int value = valueMap.getInt(key);
- classes[value] = widgetSet.getConnectorClassByTag(value, this);
- if (classes[value] == UnknownComponentConnector.class) {
- if (unknownComponents == null) {
- unknownComponents = new HashMap<Integer, String>();
- }
- unknownComponents.put(value, key);
- }
+ widgetSet.ensureConnectorLoaded(value, this);
}
}
@@ -478,86 +497,25 @@ public class ApplicationConfiguration implements EntryPoint {
cmd.execute();
}
callbacks.clear();
- } else if (dependenciesLoading == 0 && deferredWidgetLoader != null) {
- deferredWidgetLoader.trigger();
- }
-
- }
-
- /*
- * This loop loads widget implementation that should be loaded deferred.
- */
- static class DeferredWidgetLoader extends Timer {
- private static final int FREE_LIMIT = 4;
- private static final int FREE_CHECK_TIMEOUT = 100;
-
- int communicationFree = 0;
- int nextWidgetIndex = 0;
- private boolean pending;
-
- public DeferredWidgetLoader() {
- schedule(5000);
- }
-
- public void trigger() {
- if (!pending) {
- schedule(FREE_CHECK_TIMEOUT);
- }
- }
-
- @Override
- public void schedule(int delayMillis) {
- super.schedule(delayMillis);
- pending = true;
- }
-
- @Override
- public void run() {
- pending = false;
- if (!isBusy()) {
- Class<? extends ServerConnector> nextType = getNextType();
- if (nextType == null) {
- // ensured that all widgets are loaded
- deferredWidgetLoader = null;
- } else {
- communicationFree = 0;
- widgetSet.loadImplementation(nextType);
- }
- } else {
- schedule(FREE_CHECK_TIMEOUT);
- }
- }
-
- private Class<? extends ServerConnector> getNextType() {
- Class<? extends ServerConnector>[] deferredLoadedConnectors = widgetSet
- .getDeferredLoadedConnectors();
- if (deferredLoadedConnectors.length <= nextWidgetIndex) {
- return null;
- } else {
- return deferredLoadedConnectors[nextWidgetIndex++];
- }
- }
-
- private boolean isBusy() {
- if (dependenciesLoading > 0) {
- communicationFree = 0;
- return true;
- }
- for (ApplicationConnection app : runningApplications) {
- if (app.hasActiveRequest()) {
- // if an UIDL request or widget loading is active, mark as
- // busy
- communicationFree = 0;
- return true;
- }
- }
- communicationFree++;
- return communicationFree < FREE_LIMIT;
+ } else if (dependenciesLoading == 0
+ && !ConnectorBundleLoader.get().isBundleLoaded(
+ ConnectorBundleLoader.DEFERRED_BUNDLE_NAME)) {
+ ConnectorBundleLoader.get().loadBundle(
+ ConnectorBundleLoader.DEFERRED_BUNDLE_NAME,
+ new BundleLoadCallback() {
+ @Override
+ public void loaded() {
+ // Nothing to do
+ }
+
+ @Override
+ public void failed(Throwable reason) {
+ VConsole.error(reason);
+ }
+ });
}
}
- private static DeferredWidgetLoader deferredWidgetLoader;
-
@Override
public void onModuleLoad() {
@@ -594,7 +552,6 @@ public class ApplicationConfiguration implements EntryPoint {
return;
}
registerCallback(GWT.getModuleName());
- deferredWidgetLoader = new DeferredWidgetLoader();
}
/**
diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 299278269c..450972ddc6 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -58,6 +58,7 @@ import com.vaadin.shared.Version;
import com.vaadin.shared.communication.LegacyChangeVariablesInvocation;
import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.communication.SharedState;
+import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage;
import com.vaadin.terminal.gwt.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.terminal.gwt.client.ResourceLoader.ResourceLoadListener;
@@ -65,16 +66,19 @@ import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper
import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
import com.vaadin.terminal.gwt.client.communication.RpcManager;
-import com.vaadin.terminal.gwt.client.communication.SerializerMap;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
-import com.vaadin.terminal.gwt.client.communication.Type;
import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Property;
+import com.vaadin.terminal.gwt.client.metadata.Type;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
+import com.vaadin.terminal.gwt.client.ui.UI.UIConnector;
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
import com.vaadin.terminal.gwt.client.ui.notification.VNotification;
import com.vaadin.terminal.gwt.client.ui.notification.VNotification.HideEvent;
-import com.vaadin.terminal.gwt.client.ui.root.RootConnector;
import com.vaadin.terminal.gwt.client.ui.window.WindowConnector;
/**
@@ -105,8 +109,6 @@ public class ApplicationConnection {
public static final char VAR_ESCAPE_CHARACTER = '\u001b';
- private static SerializerMap serializerMap;
-
/**
* A string that, if found in a non-JSON response to a UIDL request, will
* cause the browser to refresh the page. If followed by a colon, optional
@@ -155,7 +157,7 @@ public class ApplicationConnection {
private Timer loadTimer3;
private Element loadElement;
- private final RootConnector rootConnector;
+ private final UIConnector uIConnector;
protected boolean applicationRunning = false;
@@ -207,11 +209,13 @@ public class ApplicationConnection {
}
public ApplicationConnection() {
- rootConnector = GWT.create(RootConnector.class);
+ // Assuming UI data is eagerly loaded
+ ConnectorBundleLoader.get().loadBundle(
+ ConnectorBundleLoader.EAGER_BUNDLE_NAME, null);
+ uIConnector = GWT.create(UIConnector.class);
rpcManager = GWT.create(RpcManager.class);
layoutManager = GWT.create(LayoutManager.class);
layoutManager.setConnection(this);
- serializerMap = GWT.create(SerializerMap.class);
}
public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) {
@@ -240,7 +244,7 @@ public class ApplicationConnection {
initializeClientHooks();
- rootConnector.init(cnf.getRootPanelId(), this);
+ uIConnector.init(cnf.getRootPanelId(), this);
showLoadingIndicator();
scheduleHeartbeat();
@@ -398,32 +402,6 @@ public class ApplicationConnection {
}-*/;
/**
- * Get the active Console for writing debug messages. May return an actual
- * logging console, or the NullConsole if debugging is not turned on.
- *
- * @deprecated Developers should use {@link VConsole} since 6.4.5
- *
- * @return the active Console
- */
- @Deprecated
- public static Console getConsole() {
- return VConsole.getImplementation();
- }
-
- /**
- * Checks if client side is in debug mode. Practically this is invoked by
- * adding ?debug parameter to URI.
- *
- * @deprecated use ApplicationConfiguration isDebugMode instead.
- *
- * @return true if client side is currently been debugged
- */
- @Deprecated
- public static boolean isDebugMode() {
- return ApplicationConfiguration.isDebugMode();
- }
-
- /**
* Gets the application base URI. Using this other than as the download
* action URI can cause problems in Portlet 2.0 deployments.
*
@@ -520,8 +498,8 @@ public class ApplicationConnection {
if (extraParams != null && extraParams.length() > 0) {
uri = addGetParameters(uri, extraParams);
}
- uri = addGetParameters(uri, ApplicationConstants.ROOT_ID_PARAMETER
- + "=" + configuration.getRootId());
+ uri = addGetParameters(uri, UIConstants.UI_ID_PARAMETER + "="
+ + configuration.getUIId());
doUidlRequest(uri, payload, forceSync);
@@ -934,7 +912,7 @@ public class ApplicationConnection {
if (loadElement == null) {
loadElement = DOM.createDiv();
DOM.setStyleAttribute(loadElement, "position", "absolute");
- DOM.appendChild(rootConnector.getWidget().getElement(), loadElement);
+ DOM.appendChild(uIConnector.getWidget().getElement(), loadElement);
VConsole.log("inserting load indicator");
}
DOM.setElementProperty(loadElement, "className", "v-loading-indicator");
@@ -1118,7 +1096,7 @@ public class ApplicationConnection {
meta = json.getValueMap("meta");
if (meta.containsKey("repaintAll")) {
repaintAll = true;
- rootConnector.getWidget().clear();
+ uIConnector.getWidget().clear();
getConnectorMap().clear();
if (meta.containsKey("invalidLayouts")) {
validatingLayouts = true;
@@ -1176,6 +1154,8 @@ public class ApplicationConnection {
" * Hierarchy state change event processing completed",
10);
+ delegateToWidget(pendingStateChangeEvents);
+
// Fire state change events.
sendStateChangeEvents(pendingStateChangeEvents);
@@ -1292,6 +1272,62 @@ public class ApplicationConnection {
}
+ private void delegateToWidget(
+ Collection<StateChangeEvent> pendingStateChangeEvents) {
+ VConsole.log(" * Running @DelegateToWidget");
+
+ for (StateChangeEvent sce : pendingStateChangeEvents) {
+ ServerConnector connector = sce.getConnector();
+ if (connector instanceof ComponentConnector) {
+ ComponentConnector component = (ComponentConnector) connector;
+ Type type = TypeData.getType(component.getClass());
+
+ Type stateType;
+ try {
+ stateType = type.getMethod("getState")
+ .getReturnType();
+ } catch (NoDataException e) {
+ throw new RuntimeException(
+ "Can not find the state type for "
+ + type.getSignature(), e);
+ }
+
+ Set<String> changedProperties = sce
+ .getChangedProperties();
+ for (String propertyName : changedProperties) {
+ Property property = stateType
+ .getProperty(propertyName);
+ String method = property
+ .getDelegateToWidgetMethodName();
+ if (method != null) {
+ doDelegateToWidget(component, property, method);
+ }
+ }
+
+ }
+ }
+ }
+
+ private void doDelegateToWidget(ComponentConnector component,
+ Property property, String methodName) {
+ Type type = TypeData.getType(component.getClass());
+ try {
+ Type widgetType = type.getMethod("getWidget")
+ .getReturnType();
+ Widget widget = component.getWidget();
+
+ Object propertyValue = property.getValue(component
+ .getState());
+
+ widgetType.getMethod(methodName).invoke(widget,
+ propertyValue);
+ } catch (NoDataException e) {
+ throw new RuntimeException(
+ "Missing data needed to invoke @DelegateToWidget for "
+ + Util.getSimpleName(component), e);
+ }
+ }
+
/**
* Sends the state change events created while updating the state
* information.
@@ -1328,17 +1364,17 @@ public class ApplicationConnection {
if (!c.getParent().getChildren().contains(c)) {
VConsole.error("ERROR: Connector is connected to a parent but the parent does not contain the connector");
}
- } else if ((c instanceof RootConnector && c == getRootConnector())) {
- // RootConnector for this connection, leave as-is
+ } else if ((c instanceof UIConnector && c == getRootConnector())) {
+ // UIConnector for this connection, leave as-is
} else if (c instanceof WindowConnector
&& getRootConnector().hasSubWindow(
(WindowConnector) c)) {
- // Sub window attached to this RootConnector, leave
+ // Sub window attached to this UIConnector, leave
// as-is
} else {
// The connector has been detached from the
// hierarchy, unregister it and any possible
- // children. The RootConnector should never be
+ // children. The UIConnector should never be
// unregistered even though it has no parent.
connectorMap.unregisterConnector(c);
unregistered++;
@@ -1373,17 +1409,17 @@ public class ApplicationConnection {
.getConnectorClassByEncodedTag(connectorType);
// Connector does not exist so we must create it
- if (connectorClass != RootConnector.class) {
+ if (connectorClass != UIConnector.class) {
// create, initialize and register the paintable
getConnector(connectorId, connectorType);
} else {
- // First RootConnector update. Before this the
- // RootConnector has been created but not
+ // First UIConnector update. Before this the
+ // UIConnector has been created but not
// initialized as the connector id has not been
// known
connectorMap.registerConnector(connectorId,
- rootConnector);
- rootConnector.doInit(connectorId,
+ uIConnector);
+ uIConnector.doInit(connectorId,
ApplicationConnection.this);
}
} catch (final Throwable e) {
@@ -2444,8 +2480,8 @@ public class ApplicationConnection {
*
* @return the main view
*/
- public RootConnector getRootConnector() {
- return rootConnector;
+ public UIConnector getRootConnector() {
+ return uIConnector;
}
/**
@@ -2470,7 +2506,8 @@ public class ApplicationConnection {
* The identifier for the event
* @return true if at least one listener has been registered on server side
* for the event identified by eventIdentifier.
- * @deprecated Use {@link ComponentState#hasEventListener(String)} instead
+ * @deprecated as of Vaadin 7. Use
+ * {@link ComponentState#hasEventListener(String)} instead
*/
@Deprecated
public boolean hasEventListeners(ComponentConnector paintable,
@@ -2523,11 +2560,13 @@ public class ApplicationConnection {
return connectorMap;
}
+ /**
+ * @deprecated No longer needed in Vaadin 7
+ */
@Deprecated
public void unregisterPaintable(ServerConnector p) {
- System.out.println("unregisterPaintable (unnecessarily) called for "
+ VConsole.log("unregisterPaintable (unnecessarily) called for "
+ Util.getConnectorString(p));
- // connectorMap.unregisterConnector(p);
}
/**
@@ -2566,6 +2605,10 @@ public class ApplicationConnection {
return false;
}
+ /**
+ * @deprecated as of Vaadin 7. Use
+ * {@link ComponentState#hasEventListener(String)} instead
+ */
@Deprecated
public boolean hasEventListeners(Widget widget, String eventIdentifier) {
return hasEventListeners(getConnectorMap().getConnector(widget),
@@ -2576,10 +2619,6 @@ public class ApplicationConnection {
return layoutManager;
}
- public SerializerMap getSerializerMap() {
- return serializerMap;
- }
-
/**
* Schedules a heartbeat request to occur after the configured heartbeat
* interval elapses if the interval is a positive number. Otherwise, does
@@ -2616,8 +2655,8 @@ public class ApplicationConnection {
final String uri = addGetParameters(
translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX
+ ApplicationConstants.HEARTBEAT_REQUEST_PATH),
- ApplicationConstants.ROOT_ID_PARAMETER + "="
- + getConfiguration().getRootId());
+ UIConstants.UI_ID_PARAMETER + "="
+ + getConfiguration().getUIId());
final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java b/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java
index 959f03e46d..f1a2b9b925 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java
@@ -28,9 +28,9 @@ import com.vaadin.shared.ComponentState;
import com.vaadin.shared.Connector;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.terminal.gwt.client.ui.SubPartAware;
+import com.vaadin.terminal.gwt.client.ui.UI.VUI;
import com.vaadin.terminal.gwt.client.ui.gridlayout.VGridLayout;
import com.vaadin.terminal.gwt.client.ui.orderedlayout.VMeasuringOrderedLayout;
-import com.vaadin.terminal.gwt.client.ui.root.VRoot;
import com.vaadin.terminal.gwt.client.ui.tabsheet.VTabsheetPanel;
import com.vaadin.terminal.gwt.client.ui.window.VWindow;
import com.vaadin.terminal.gwt.client.ui.window.WindowConnector;
@@ -385,7 +385,7 @@ public class ComponentLocator {
return null;
}
- if (w instanceof VRoot) {
+ if (w instanceof VUI) {
return "";
} else if (w instanceof VWindow) {
Connector windowConnector = ConnectorMap.get(client)
diff --git a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
index 8788de74bf..d988c5f4a2 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
@@ -22,6 +22,7 @@ import com.google.gwt.event.shared.GwtEvent;
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.shared.Connector;
import com.vaadin.shared.communication.ClientRpc;
+import com.vaadin.shared.communication.SharedState;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
/**
@@ -142,4 +143,13 @@ public interface ServerConnector extends Connector {
public void setChildren(List<ServerConnector> children);
public List<ServerConnector> getChildren();
+
+ /**
+ * Gets the current shared state of the connector.
+ *
+ * @since 7.0.
+ * @return state The shared state object. Can be any sub type of
+ * {@link SharedState}. Never null.
+ */
+ public SharedState getState();
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
index 1e2a3062f1..022171f2bb 100644
--- a/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
+++ b/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
@@ -70,8 +70,8 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.Version;
import com.vaadin.terminal.gwt.client.ui.VLazyExecutor;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
+import com.vaadin.terminal.gwt.client.ui.UI.UIConnector;
import com.vaadin.terminal.gwt.client.ui.notification.VNotification;
-import com.vaadin.terminal.gwt.client.ui.root.RootConnector;
import com.vaadin.terminal.gwt.client.ui.window.WindowConnector;
/**
@@ -924,7 +924,7 @@ public class VDebugConsole extends VOverlay implements Console {
}
protected void dumpConnectorInfo(ApplicationConnection a) {
- RootConnector root = a.getRootConnector();
+ UIConnector root = a.getRootConnector();
log("================");
log("Connector hierarchy for Root: " + root.getState().getCaption()
+ " (" + root.getConnectorId() + ")");
diff --git a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java
index fbcfbb68d9..8245371161 100644
--- a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java
+++ b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java
@@ -18,17 +18,13 @@ package com.vaadin.terminal.gwt.client;
import com.google.gwt.core.client.GWT;
import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper;
+import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector;
public class WidgetSet {
-
- /**
- * WidgetSet (and its extensions) delegate instantiation of widgets and
- * client-server matching to WidgetMap. The actual implementations are
- * generated with gwts generators/deferred binding.
- */
- private WidgetMap widgetMap = GWT.create(WidgetMap.class);
-
/**
* Create an uninitialized connector that best matches given UIDL. The
* connector must implement {@link ServerConnector}.
@@ -65,12 +61,21 @@ public class WidgetSet {
/*
* let the auto generated code instantiate this type
*/
- ServerConnector connector = widgetMap.instantiate(classType);
- if (connector instanceof HasJavaScriptConnectorHelper) {
- ((HasJavaScriptConnectorHelper) connector)
- .getJavascriptConnectorHelper().setTag(tag);
+ try {
+ ServerConnector connector = (ServerConnector) TypeData.getType(
+ classType).createInstance();
+ if (connector instanceof HasJavaScriptConnectorHelper) {
+ ((HasJavaScriptConnectorHelper) connector)
+ .getJavascriptConnectorHelper().setTag(tag);
+ }
+ return connector;
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about "
+ + classType
+ + ". Did you remember to compile the right widgetset?",
+ e);
}
- return connector;
}
}
@@ -102,26 +107,32 @@ public class WidgetSet {
* @param applicationConfiguration
* @return
*/
- public Class<? extends ServerConnector> getConnectorClassByTag(int tag,
- ApplicationConfiguration conf) {
- Class<? extends ServerConnector> connectorClass = null;
+ public void ensureConnectorLoaded(int tag, ApplicationConfiguration conf) {
+ ConnectorBundleLoader loader = ConnectorBundleLoader.get();
+ String bundleName = null;
Integer t = tag;
do {
String serverSideClassName = conf.getServerSideClassNameForTag(t);
- connectorClass = widgetMap
- .getConnectorClassForServerSideClassName(serverSideClassName);
- t = conf.getParentTag(t);
- } while (connectorClass == UnknownComponentConnector.class && t != null);
+ bundleName = loader.getBundleForIdentifier(serverSideClassName);
- return connectorClass;
- }
+ t = conf.getParentTag(t);
+ } while (bundleName == null && t != null);
- public Class<? extends ServerConnector>[] getDeferredLoadedConnectors() {
- return widgetMap.getDeferredLoadedConnectors();
- }
+ if (bundleName != null && !loader.isBundleLoaded(bundleName)) {
+ ApplicationConfiguration.startDependencyLoading();
+ loader.loadBundle(bundleName, new BundleLoadCallback() {
+ @Override
+ public void loaded() {
+ ApplicationConfiguration.endDependencyLoading();
+ }
- public void loadImplementation(Class<? extends ServerConnector> nextType) {
- widgetMap.ensureInstantiator(nextType);
+ @Override
+ public void failed(Throwable reason) {
+ VConsole.error(reason);
+ ApplicationConfiguration.endDependencyLoading();
+ }
+ });
+ }
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java
index a3b96a6cb2..1d5415263f 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java
@@ -17,6 +17,7 @@ package com.vaadin.terminal.gwt.client.communication;
import com.google.gwt.json.client.JSONValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.metadata.Type;
public interface DiffJSONSerializer<T> extends JSONSerializer<T> {
/**
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java b/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java
deleted file mode 100644
index 65887bf62e..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.communication;
-
-import com.vaadin.shared.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-
-/**
- * Initialization support for client to server RPC interfaces.
- *
- * This is in a separate interface used by the GWT generator class. The init
- * method is not in {@link ServerRpc} because then also server side proxies
- * would have to implement the initialization method.
- *
- * @since 7.0
- */
-public interface InitializableServerRpc extends ServerRpc {
- /**
- * Associates the RPC proxy with a connector. Called by generated code.
- * Should never be called manually.
- *
- * @param connector
- * The connector the ServerRPC instance is assigned to.
- */
- public void initRpc(ServerConnector connector);
-} \ No newline at end of file
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
index a8fe2c7ccc..c6b814a5c1 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
@@ -20,6 +20,7 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ConnectorMap;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Implementors of this interface knows how to serialize an Object of a given
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
index 7d2046982c..a98d08c368 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
@@ -31,6 +31,9 @@ import com.google.gwt.json.client.JSONValue;
import com.vaadin.shared.Connector;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ConnectorMap;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Property;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Client side decoder for decodeing shared state and other values from JSON
@@ -105,18 +108,42 @@ public class JsonDecoder {
private static Object decodeObject(Type type, JSONValue jsonValue,
Object target, ApplicationConnection connection) {
- JSONSerializer<Object> serializer = connection.getSerializerMap()
- .getSerializer(type.getBaseTypeName());
- // TODO handle case with no serializer found
- // Currently getSerializer throws exception if not found
-
- if (target != null && serializer instanceof DiffJSONSerializer<?>) {
- DiffJSONSerializer<Object> diffSerializer = (DiffJSONSerializer<Object>) serializer;
- diffSerializer.update(target, type, jsonValue, connection);
- return target;
+ JSONSerializer<Object> serializer = (JSONSerializer<Object>) type
+ .findSerializer();
+ if (serializer != null) {
+ if (target != null && serializer instanceof DiffJSONSerializer<?>) {
+ DiffJSONSerializer<Object> diffSerializer = (DiffJSONSerializer<Object>) serializer;
+ diffSerializer.update(target, type, jsonValue, connection);
+ return target;
+ } else {
+ Object object = serializer.deserialize(type, jsonValue,
+ connection);
+ return object;
+ }
} else {
- Object object = serializer.deserialize(type, jsonValue, connection);
- return object;
+ try {
+ Collection<Property> properties = type.getProperties();
+ if (target == null) {
+ target = type.createInstance();
+ }
+ JSONObject jsonObject = jsonValue.isObject();
+
+ for (Property property : properties) {
+ JSONValue encodedPropertyValue = jsonObject.get(property
+ .getName());
+ if (encodedPropertyValue == null) {
+ continue;
+ }
+ Object propertyReference = property.getValue(target);
+ Object decodedValue = decodeValue(property.getType(),
+ encodedPropertyValue, propertyReference, connection);
+ property.setValue(target, decodedValue);
+ }
+ return target;
+ } catch (NoDataException e) {
+ throw new RuntimeException("Can not deserialize "
+ + type.getSignature(), e);
+ }
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
index 3730cad4c3..9b28da8b34 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
@@ -33,6 +33,9 @@ import com.vaadin.shared.Connector;
import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.communication.UidlValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Property;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Encoder for converting RPC parameters and other values to JSON for transfer
@@ -99,12 +102,33 @@ public class JsonEncoder {
} else {
// Try to find a generated serializer object, class name is the
// type
- transportType = value.getClass().getName();
- JSONSerializer serializer = connection.getSerializerMap()
- .getSerializer(transportType);
+ Type type = new Type(value.getClass());
+
+ JSONSerializer<Object> serializer = (JSONSerializer<Object>) type
+ .findSerializer();
+ if (serializer != null) {
+ return serializer.serialize(value, connection);
+ } else {
+ try {
+ Collection<Property> properties = type.getProperties();
+
+ JSONObject jsonObject = new JSONObject();
+ for (Property property : properties) {
+ Object propertyValue = property.getValue(value);
+ JSONValue encodedPropertyValue = encode(
+ propertyValue, restrictToInternalTypes,
+ connection);
+ jsonObject.put(property.getName(),
+ encodedPropertyValue);
+ }
+ return jsonObject;
+
+ } catch (NoDataException e) {
+ throw new RuntimeException("Can not encode "
+ + type.getSignature(), e);
+ }
+ }
- // TODO handle case with no serializer found
- return serializer.serialize(value, connection);
}
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java
index 04d0e3f56f..5b9bcff6a4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java
@@ -17,10 +17,7 @@
package com.vaadin.terminal.gwt.client.communication;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONString;
import com.vaadin.shared.communication.ClientRpc;
@@ -29,6 +26,9 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ConnectorMap;
import com.vaadin.terminal.gwt.client.ServerConnector;
import com.vaadin.terminal.gwt.client.VConsole;
+import com.vaadin.terminal.gwt.client.metadata.Method;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Client side RPC manager that can invoke methods based on RPC calls received
@@ -41,19 +41,6 @@ import com.vaadin.terminal.gwt.client.VConsole;
*/
public class RpcManager {
- private final Map<String, RpcMethod> methodMap = new HashMap<String, RpcMethod>();
-
- public RpcManager() {
- GeneratedRpcMethodProvider provider = GWT
- .create(GeneratedRpcMethodProvider.class);
- Collection<RpcMethod> methods = provider.getGeneratedRpcMethods();
- for (RpcMethod rpcMethod : methods) {
- methodMap.put(
- rpcMethod.getInterfaceName() + "."
- + rpcMethod.getMethodName(), rpcMethod);
- }
- }
-
/**
* Perform server to client RPC invocation.
*
@@ -62,24 +49,25 @@ public class RpcManager {
*/
public void applyInvocation(MethodInvocation invocation,
ServerConnector connector) {
- String signature = getSignature(invocation);
+ Method method = getMethod(invocation);
- RpcMethod rpcMethod = getRpcMethod(signature);
Collection<ClientRpc> implementations = connector
.getRpcImplementations(invocation.getInterfaceName());
- for (ClientRpc clientRpc : implementations) {
- rpcMethod.applyInvocation(clientRpc, invocation.getParameters());
+ try {
+ for (ClientRpc clientRpc : implementations) {
+ method.invoke(clientRpc, invocation.getParameters());
+ }
+ } catch (NoDataException e) {
+ throw new IllegalStateException("There is no information about "
+ + method.getSignature()
+ + ". Did you remember to compile the right widgetset?", e);
}
}
- private RpcMethod getRpcMethod(String signature) {
- RpcMethod rpcMethod = methodMap.get(signature);
- if (rpcMethod == null) {
- throw new IllegalStateException("There is no information about "
- + signature
- + ". Did you remember to compile the right widgetset?");
- }
- return rpcMethod;
+ private Method getMethod(MethodInvocation invocation) {
+ Type type = new Type(invocation.getInterfaceName(), null);
+ Method method = type.getMethod(invocation.getMethodName());
+ return method;
}
private static String getSignature(MethodInvocation invocation) {
@@ -87,7 +75,15 @@ public class RpcManager {
}
public Type[] getParameterTypes(MethodInvocation invocation) {
- return getRpcMethod(getSignature(invocation)).getParameterTypes();
+ Method method = getMethod(invocation);
+ try {
+ Type[] parameterTypes = method.getParameterTypes();
+ return parameterTypes;
+ } catch (NoDataException e) {
+ throw new IllegalStateException("There is no information about "
+ + method.getSignature()
+ + ". Did you remember to compile the right widgetset?", e);
+ }
}
public void parseAndApplyInvocation(JSONArray rpcCall,
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java
deleted file mode 100644
index a47fa5eab2..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.communication;
-
-import com.vaadin.shared.communication.ClientRpc;
-
-public abstract class RpcMethod {
- private String interfaceName;
- private String methodName;
- private Type[] parameterTypes;
-
- public RpcMethod(String interfaceName, String methodName,
- Type... parameterTypes) {
- this.interfaceName = interfaceName;
- this.methodName = methodName;
- this.parameterTypes = parameterTypes;
- }
-
- public String getInterfaceName() {
- return interfaceName;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public Type[] getParameterTypes() {
- return parameterTypes;
- }
-
- public abstract void applyInvocation(ClientRpc target, Object... parameters);
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java
index 226594adc6..e9dc6ab7fd 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java
@@ -15,9 +15,13 @@
*/
package com.vaadin.terminal.gwt.client.communication;
-import com.google.gwt.core.client.GWT;
+import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.metadata.InvokationHandler;
+import com.vaadin.terminal.gwt.client.metadata.Method;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
/**
* Class for creating proxy instances for Client to Server RPC.
@@ -26,25 +30,38 @@ import com.vaadin.terminal.gwt.client.ServerConnector;
*/
public class RpcProxy {
- private static RpcProxyCreator impl = GWT.create(RpcProxyCreator.class);
-
- /**
- * Create a proxy class for the given Rpc interface and assign it to the
- * given connector.
- *
- * @param rpcInterface
- * The rpc interface to construct a proxy for
- * @param connector
- * The connector this proxy is connected to
- * @return A proxy class used for calling Rpc methods.
- */
public static <T extends ServerRpc> T create(Class<T> rpcInterface,
ServerConnector connector) {
- return impl.create(rpcInterface, connector);
+ try {
+ return (T) TypeData.getType(rpcInterface).createProxy(
+ new RpcInvokationHandler(rpcInterface, connector));
+ } catch (NoDataException e) {
+ throw new IllegalStateException("There is no information about "
+ + rpcInterface
+ + ". Did you forget to compile the widgetset?");
+ }
}
- public interface RpcProxyCreator {
- <T extends ServerRpc> T create(Class<T> rpcInterface,
- ServerConnector connector);
+ private static final class RpcInvokationHandler implements
+ InvokationHandler {
+ private final Class<?> rpcInterface;
+ private final ServerConnector connector;
+
+ private RpcInvokationHandler(Class<?> rpcInterface,
+ ServerConnector connector) {
+ this.rpcInterface = rpcInterface;
+ this.connector = connector;
+ }
+
+ @Override
+ public Object invoke(Object target, Method method, Object[] params) {
+ MethodInvocation invocation = new MethodInvocation(
+ connector.getConnectorId(), rpcInterface.getName(),
+ method.getName(), params);
+ connector.getConnection().addMethodInvocationToQueue(invocation,
+ method.isDelayed(), method.isLastonly());
+ // No RPC iface should have a return value
+ return null;
+ }
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java b/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java
deleted file mode 100644
index 77df4c7b08..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.client.communication;
-
-/**
- * Provide a mapping from a type (communicated between the server and the
- * client) and a {@link JSONSerializer} instance.
- *
- * An implementation of this class is created at GWT compilation time by
- * SerializerMapGenerator, so this interface can be instantiated with
- * GWT.create().
- *
- * @since 7.0
- */
-public interface SerializerMap {
-
- /**
- * Returns a serializer instance for a given type.
- *
- * @param type
- * type communicated on between the server and the client
- * (currently fully qualified class name)
- * @return serializer instance, not null
- * @throws RuntimeException
- * if no serializer is found
- */
- // TODO better error handling in javadoc and in generator
- public JSONSerializer getSerializer(String type);
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/Type.java b/client/src/com/vaadin/terminal/gwt/client/communication/Type.java
deleted file mode 100644
index ff93234a1d..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/Type.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.communication;
-
-public class Type {
- private final String baseTypeName;
- private final Type[] parameterTypes;
-
- public Type(String baseTypeName, Type[] parameterTypes) {
- this.baseTypeName = baseTypeName;
- this.parameterTypes = parameterTypes;
- }
-
- public String getBaseTypeName() {
- return baseTypeName;
- }
-
- public Type[] getParameterTypes() {
- return parameterTypes;
- }
-
- @Override
- public String toString() {
- String string = baseTypeName;
- if (parameterTypes != null) {
- string += '<';
- for (int i = 0; i < parameterTypes.length; i++) {
- if (i != 0) {
- string += ',';
- }
- string += parameterTypes[i].toString();
- }
- string += '>';
- }
-
- return string;
- }
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java
index f77553d3c0..3d2e4f3804 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java
@@ -20,6 +20,7 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.vaadin.shared.communication.URLReference;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.metadata.Type;
public class URLReference_Serializer implements JSONSerializer<URLReference> {
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java
new file mode 100644
index 0000000000..e92e51b40d
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java
@@ -0,0 +1,86 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class AsyncBundleLoader {
+ public enum State {
+ NOT_STARTED, LOADING, LOADED, ERROR;
+ }
+
+ private State state = State.NOT_STARTED;
+
+ private Throwable error = null;
+
+ private List<BundleLoadCallback> callbacks = new ArrayList<BundleLoadCallback>();
+
+ private final String packageName;
+
+ private final String[] indentifiers;
+
+ public AsyncBundleLoader(String packageName, String[] indentifiers) {
+ this.packageName = packageName;
+ this.indentifiers = indentifiers;
+ }
+
+ protected abstract void load(TypeDataStore store);
+
+ public List<BundleLoadCallback> setError(Throwable error) {
+ assert state == State.LOADING;
+ state = State.ERROR;
+ this.error = error;
+
+ return clearCallbacks();
+ }
+
+ public Throwable getError() {
+ return error;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public List<BundleLoadCallback> getCallback() {
+ return Collections.unmodifiableList(callbacks);
+ }
+
+ public void load(BundleLoadCallback callback, TypeDataStore store) {
+ assert state == State.NOT_STARTED;
+ state = State.LOADING;
+ callbacks.add(callback);
+ load(store);
+ }
+
+ public void addCallback(BundleLoadCallback callback) {
+ assert state == State.LOADING;
+ callbacks.add(callback);
+ }
+
+ public List<BundleLoadCallback> setLoaded() {
+ assert state == State.LOADING;
+ state = State.LOADED;
+
+ return clearCallbacks();
+ }
+
+ private List<BundleLoadCallback> clearCallbacks() {
+ List<BundleLoadCallback> callbacks = this.callbacks;
+ this.callbacks = null;
+ return callbacks;
+ }
+
+ public String getName() {
+ return packageName;
+ }
+
+ public String[] getIndentifiers() {
+ return indentifiers;
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java b/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java
new file mode 100644
index 0000000000..c7fc735829
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java
@@ -0,0 +1,11 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface BundleLoadCallback {
+ public void loaded();
+
+ public void failed(Throwable reason);
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java
new file mode 100644
index 0000000000..ab1462efc1
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java
@@ -0,0 +1,99 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.core.shared.GWT;
+import com.vaadin.terminal.gwt.client.metadata.AsyncBundleLoader.State;
+
+public abstract class ConnectorBundleLoader {
+ public static final String EAGER_BUNDLE_NAME = "__eager";
+ public static final String DEFERRED_BUNDLE_NAME = "__deferred";
+
+ private static ConnectorBundleLoader impl;
+
+ private Map<String, AsyncBundleLoader> asyncBlockLoaders = new HashMap<String, AsyncBundleLoader>();
+ private Map<String, String> identifierToBundle = new HashMap<String, String>();
+
+ private final TypeDataStore datStore = new TypeDataStore();
+
+ public ConnectorBundleLoader() {
+ init();
+ }
+
+ public TypeDataStore getTypeDataStore() {
+ return datStore;
+ }
+
+ public static ConnectorBundleLoader get() {
+ if (impl == null) {
+ impl = GWT.create(ConnectorBundleLoader.class);
+ }
+ return impl;
+ }
+
+ public void loadBundle(String packageName, BundleLoadCallback callback) {
+ AsyncBundleLoader loader = asyncBlockLoaders.get(packageName);
+ switch (loader.getState()) {
+ case NOT_STARTED:
+ loader.load(callback, getTypeDataStore());
+ break;
+ case LOADING:
+ loader.addCallback(callback);
+ break;
+ case LOADED:
+ callback.loaded();
+ break;
+ case ERROR:
+ callback.failed(loader.getError());
+ }
+ }
+
+ public boolean isBundleLoaded(String bundleName) {
+ AsyncBundleLoader loader = asyncBlockLoaders.get(bundleName);
+ if (loader == null) {
+ throw new IllegalArgumentException("Bundle " + bundleName
+ + " not recognized");
+ }
+ return loader.getState() == State.LOADED;
+ }
+
+ public void setLoaded(String packageName) {
+ List<BundleLoadCallback> callbacks = asyncBlockLoaders.get(packageName)
+ .setLoaded();
+ for (BundleLoadCallback callback : callbacks) {
+ if (callback != null) {
+ callback.loaded();
+ }
+ }
+ }
+
+ public void setLoadFailure(String bundleName, Throwable reason) {
+ List<BundleLoadCallback> callbacks = asyncBlockLoaders.get(bundleName)
+ .setError(reason);
+ for (BundleLoadCallback callback : callbacks) {
+ callback.failed(reason);
+ }
+ }
+
+ public String getBundleForIdentifier(String identifier) {
+ return identifierToBundle.get(identifier);
+ }
+
+ protected void addAsyncBlockLoader(AsyncBundleLoader loader) {
+ String name = loader.getName();
+ asyncBlockLoaders.put(name, loader);
+ String[] indentifiers = loader.getIndentifiers();
+ for (String identifier : indentifiers) {
+ identifierToBundle.put(identifier, name);
+ }
+ }
+
+ public abstract void init();
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java
new file mode 100644
index 0000000000..2b1153ad97
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface InvokationHandler {
+ public Object invoke(Object target, Method method, Object[] params);
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java
new file mode 100644
index 0000000000..33e8776429
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java
@@ -0,0 +1,9 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface Invoker {
+ public Object invoke(Object target, Object... params);
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java
new file mode 100644
index 0000000000..527e8a29d2
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java
@@ -0,0 +1,71 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public class Method {
+
+ private final Type type;
+ private final String name;
+
+ public Method(Type type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Type getReturnType() throws NoDataException {
+ return TypeDataStore.getReturnType(this);
+ }
+
+ public void invoke(Object target, Object... params) throws NoDataException {
+ TypeDataStore.getInvoker(this).invoke(target, params);
+ }
+
+ public String getSignature() {
+ return type.toString() + "." + name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Method) {
+ Method other = (Method) obj;
+ return other.getSignature().equals(getSignature());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getSignature();
+ }
+
+ @Override
+ public int hashCode() {
+ return getSignature().hashCode();
+ }
+
+ public Type[] getParameterTypes() throws NoDataException {
+ return TypeDataStore.getParamTypes(this);
+ }
+
+ public boolean isDelayed() {
+ return TypeDataStore.isDelayed(this);
+ }
+
+ public boolean isLastonly() {
+ return TypeDataStore.isLastonly(this);
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java b/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java
index e865dbc1b1..717b92edaf 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -13,20 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.terminal.gwt.client.communication;
-import java.util.Collection;
+package com.vaadin.terminal.gwt.client.metadata;
-/**
- * Provides runtime data about client side RPC calls received from the server to
- * the client-side code.
- *
- * A GWT generator is used to create an implementation of this class at
- * run-time.
- *
- * @since 7.0
- */
-public interface GeneratedRpcMethodProvider {
+public class NoDataException extends Exception {
+
+ public NoDataException(String message) {
+ super(message);
+ }
- public Collection<RpcMethod> getGeneratedRpcMethods();
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
new file mode 100644
index 0000000000..69e41ce75d
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
@@ -0,0 +1,69 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import com.vaadin.shared.annotations.DelegateToWidget;
+
+public class Property {
+ private final Type bean;
+ private final String name;
+
+ public Property(Type bean, String name) {
+ this.bean = bean;
+ this.name = name;
+ }
+
+ public Object getValue(Object bean) throws NoDataException {
+ return TypeDataStore.getGetter(this).invoke(bean);
+ }
+
+ public void setValue(Object bean, Object value) throws NoDataException {
+ TypeDataStore.getSetter(this).invoke(bean, value);
+ }
+
+ public String getDelegateToWidgetMethodName() {
+ String value = TypeDataStore.getDelegateToWidget(this);
+ if (value == null) {
+ return null;
+ } else {
+ return DelegateToWidget.Helper.getDelegateTarget(getName(), value);
+ }
+ }
+
+ public Type getType() throws NoDataException {
+ return TypeDataStore.getType(this);
+ }
+
+ public String getSignature() {
+ return bean.toString() + "." + name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ } else if (obj instanceof Property) {
+ Property other = (Property) obj;
+ return getSignature().equals(other.getSignature());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return getSignature().hashCode();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return getSignature();
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java
index d8c7e67638..cc8168a8ff 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java
@@ -13,30 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.terminal.gwt.client;
-import com.google.gwt.core.client.GWT;
+package com.vaadin.terminal.gwt.client.metadata;
-@Deprecated
-public class ClientExceptionHandler {
+public interface ProxyHandler {
- public static void displayError(Throwable e) {
- displayError(e.getClass().getName() + ": " + e.getMessage());
-
- GWT.log(e.getMessage(), e);
- }
-
- @Deprecated
- public static void displayError(String msg) {
- VConsole.error(msg);
- GWT.log(msg);
- }
-
- @Deprecated
- public static void displayError(String msg, Throwable e) {
- displayError(msg);
- displayError(e);
-
- }
+ Object createProxy(InvokationHandler invokationHandler);
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java
new file mode 100644
index 0000000000..d869cc2599
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java
@@ -0,0 +1,97 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.Collection;
+
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
+
+public class Type {
+ private final String name;
+ private final Type[] parameterTypes;
+
+ public Type(Class<?> clazz) {
+ name = clazz.getName();
+ parameterTypes = null;
+ }
+
+ public Type(String baseTypeName, Type[] parameterTypes) {
+ name = baseTypeName;
+ this.parameterTypes = parameterTypes;
+ }
+
+ public String getBaseTypeName() {
+ return name;
+ }
+
+ public Type[] getParameterTypes() {
+ return parameterTypes;
+ }
+
+ public Object createInstance() throws NoDataException {
+ Invoker invoker = TypeDataStore.getConstructor(this);
+ return invoker.invoke(null);
+ }
+
+ public Method getMethod(String name) {
+ return new Method(this, name);
+ }
+
+ public Collection<Property> getProperties() throws NoDataException {
+ return TypeDataStore.getProperties(this);
+ }
+
+ public Property getProperty(String propertyName) {
+ return new Property(this, propertyName);
+ }
+
+ public String getSignature() {
+ String string = name;
+ if (parameterTypes != null && parameterTypes.length != 0) {
+ string += '<';
+ for (int i = 0; i < parameterTypes.length; i++) {
+ if (i != 0) {
+ string += ',';
+ }
+ string += parameterTypes[i].toString();
+ }
+ string += '>';
+ }
+
+ return string;
+ }
+
+ @Override
+ public String toString() {
+ return getSignature();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Type) {
+ Type other = (Type) obj;
+ return other.getSignature().equals(getSignature());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return getSignature().hashCode();
+ }
+
+ public Object createProxy(InvokationHandler invokationHandler)
+ throws NoDataException {
+ return TypeDataStore.get().getProxyHandler(this)
+ .createProxy(invokationHandler);
+ }
+
+ public JSONSerializer<?> findSerializer() {
+ return TypeDataStore.findSerializer(this);
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java
new file mode 100644
index 0000000000..ec2a8f191c
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java
@@ -0,0 +1,20 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public class TypeData {
+
+ public static Type getType(Class<?> type) {
+ return TypeDataStore.getType(type);
+ }
+
+ public static Class<?> getClass(String identifier) throws NoDataException {
+ return TypeDataStore.getClass(identifier);
+ }
+
+ public static boolean hasIdentifier(String identifier) {
+ return TypeDataStore.hasIdentifier(identifier);
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java
new file mode 100644
index 0000000000..cbde338ff2
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java
@@ -0,0 +1,33 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import com.google.gwt.core.client.RunAsyncCallback;
+
+public abstract class TypeDataBundle implements RunAsyncCallback {
+ private final String name;
+
+ public TypeDataBundle(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public void onSuccess() {
+ ConnectorBundleLoader loader = ConnectorBundleLoader.get();
+ load();
+ loader.setLoaded(getName());
+ }
+
+ @Override
+ public void onFailure(Throwable reason) {
+ ConnectorBundleLoader.get().setLoadFailure(getName(), reason);
+ }
+
+ public abstract void load();
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
new file mode 100644
index 0000000000..9c19410c88
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
@@ -0,0 +1,226 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
+
+public class TypeDataStore {
+ private static final String CONSTRUCTOR_NAME = "!new";
+
+ private final Map<String, Class<?>> identifiers = new HashMap<String, Class<?>>();
+
+ private final Map<Type, Invoker> serializerFactories = new HashMap<Type, Invoker>();
+ private final Map<Type, ProxyHandler> proxyHandlers = new HashMap<Type, ProxyHandler>();
+ private final Map<Type, Collection<Property>> properties = new HashMap<Type, Collection<Property>>();
+
+ private final Set<Method> delayedMethods = new HashSet<Method>();
+ private final Set<Method> lastonlyMethods = new HashSet<Method>();
+
+ private final Map<Method, Type> returnTypes = new HashMap<Method, Type>();
+ private final Map<Method, Invoker> invokers = new HashMap<Method, Invoker>();
+ private final Map<Method, Type[]> paramTypes = new HashMap<Method, Type[]>();
+
+ private final Map<Property, Type> propertyTypes = new HashMap<Property, Type>();
+ private final Map<Property, Invoker> setters = new HashMap<Property, Invoker>();
+ private final Map<Property, Invoker> getters = new HashMap<Property, Invoker>();
+ private final Map<Property, String> delegateToWidget = new HashMap<Property, String>();
+
+ public static TypeDataStore get() {
+ return ConnectorBundleLoader.get().getTypeDataStore();
+ }
+
+ public void setClass(String identifier, Class<?> type) {
+ identifiers.put(identifier, type);
+ }
+
+ public static Class<?> getClass(String identifier) throws NoDataException {
+ Class<?> class1 = get().identifiers.get(identifier);
+ if (class1 == null) {
+ throw new NoDataException("There is not class for identifier "
+ + identifier);
+ }
+ return class1;
+ }
+
+ public static Type getType(Class<?> clazz) {
+ return new Type(clazz);
+ }
+
+ public static Type getReturnType(Method method) throws NoDataException {
+ Type type = get().returnTypes.get(method);
+ if (type == null) {
+ throw new NoDataException("There is return type for "
+ + method.getSignature());
+ }
+ return type;
+ }
+
+ public static Invoker getInvoker(Method method) throws NoDataException {
+ Invoker invoker = get().invokers.get(method);
+ if (invoker == null) {
+ throw new NoDataException("There is invoker for "
+ + method.getSignature());
+ }
+ return invoker;
+ }
+
+ public static Invoker getConstructor(Type type) throws NoDataException {
+ Invoker invoker = get().invokers
+ .get(new Method(type, CONSTRUCTOR_NAME));
+ if (invoker == null) {
+ throw new NoDataException("There is constructor for "
+ + type.getSignature());
+ }
+ return invoker;
+ }
+
+ public static Invoker getGetter(Property property) throws NoDataException {
+ Invoker getter = get().getters.get(property);
+ if (getter == null) {
+ throw new NoDataException("There is getter for "
+ + property.getSignature());
+ }
+
+ return getter;
+ }
+
+ public void setGetter(Class<?> clazz, String propertyName, Invoker invoker) {
+ getters.put(new Property(getType(clazz), propertyName), invoker);
+ }
+
+ public static String getDelegateToWidget(Property property) {
+ return get().delegateToWidget.get(property);
+ }
+
+ public void setDelegateToWidget(Class<?> clazz, String propertyName,
+ String delegateValue) {
+ delegateToWidget.put(new Property(getType(clazz), propertyName),
+ delegateValue);
+ }
+
+ public void setReturnType(Class<?> type, String methodName, Type returnType) {
+ returnTypes.put(new Method(getType(type), methodName), returnType);
+ }
+
+ public void setConstructor(Class<?> type, Invoker constructor) {
+ setInvoker(type, CONSTRUCTOR_NAME, constructor);
+ }
+
+ public void setInvoker(Class<?> type, String methodName, Invoker invoker) {
+ invokers.put(new Method(getType(type), methodName), invoker);
+ }
+
+ public static Type[] getParamTypes(Method method) throws NoDataException {
+ Type[] types = get().paramTypes.get(method);
+ if (types == null) {
+ throw new NoDataException("There are no parameter type data for "
+ + method.getSignature());
+ }
+ return types;
+ }
+
+ public void setParamTypes(Class<?> type, String methodName,
+ Type[] paramTypes) {
+ this.paramTypes.put(new Method(getType(type), methodName), paramTypes);
+ }
+
+ public static boolean hasIdentifier(String identifier) {
+ return get().identifiers.containsKey(identifier);
+ }
+
+ public static ProxyHandler getProxyHandler(Type type)
+ throws NoDataException {
+ ProxyHandler proxyHandler = get().proxyHandlers.get(type);
+ if (proxyHandler == null) {
+ throw new NoDataException("No proxy handler for "
+ + type.getSignature());
+ }
+ return proxyHandler;
+ }
+
+ public void setProxyHandler(Class<?> type, ProxyHandler proxyHandler) {
+ proxyHandlers.put(getType(type), proxyHandler);
+ }
+
+ public static boolean isDelayed(Method method) {
+ return get().delayedMethods.contains(method);
+ }
+
+ public void setDelayed(Class<?> type, String methodName) {
+ delayedMethods.add(getType(type).getMethod(methodName));
+ }
+
+ public static boolean isLastonly(Method method) {
+ return get().lastonlyMethods.contains(method);
+ }
+
+ public void setLastonly(Class<?> clazz, String methodName) {
+ lastonlyMethods.add(getType(clazz).getMethod(methodName));
+ }
+
+ public static Collection<Property> getProperties(Type type)
+ throws NoDataException {
+ Collection<Property> properties = get().properties.get(type);
+ if (properties == null) {
+ throw new NoDataException("No property list for "
+ + type.getSignature());
+ }
+ return properties;
+ }
+
+ public void setProperties(Class<?> clazz, String[] propertyNames) {
+ Set<Property> properties = new HashSet<Property>();
+ Type type = getType(clazz);
+ for (String name : propertyNames) {
+ properties.add(new Property(type, name));
+ }
+ this.properties.put(type, Collections.unmodifiableSet(properties));
+ }
+
+ public static Type getType(Property property) throws NoDataException {
+ Type type = get().propertyTypes.get(property);
+ if (type == null) {
+ throw new NoDataException("No return type for "
+ + property.getSignature());
+ }
+ return type;
+ }
+
+ public void setPropertyType(Class<?> clazz, String propertName, Type type) {
+ propertyTypes.put(new Property(getType(clazz), propertName), type);
+ }
+
+ public static Invoker getSetter(Property property) throws NoDataException {
+ Invoker setter = get().setters.get(property);
+ if (setter == null) {
+ throw new NoDataException("No setter for "
+ + property.getSignature());
+ }
+ return setter;
+ }
+
+ public void setSetter(Class<?> clazz, String propertyName, Invoker setter) {
+ setters.put(new Property(getType(clazz), propertyName), setter);
+ }
+
+ public void setSerializerFactory(Class<?> clazz, Invoker factory) {
+ serializerFactories.put(getType(clazz), factory);
+ }
+
+ public static JSONSerializer<?> findSerializer(Type type) {
+ Invoker factoryCreator = get().serializerFactories.get(type);
+ if (factoryCreator == null) {
+ return null;
+ }
+ return (JSONSerializer<?>) factoryCreator.invoke(null);
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
index 48842e29a0..f36107e947 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
@@ -37,8 +37,11 @@ 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.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Type;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
+import com.vaadin.terminal.gwt.client.ui.UI.UIConnector;
import com.vaadin.terminal.gwt.client.ui.datefield.PopupDateFieldConnector;
-import com.vaadin.terminal.gwt.client.ui.root.RootConnector;
public abstract class AbstractComponentConnector extends AbstractConnector
implements ComponentConnector {
@@ -77,7 +80,18 @@ public abstract class AbstractComponentConnector extends AbstractConnector
* @return
*/
protected Widget createWidget() {
- return ConnectorWidgetFactory.createWidget(getClass());
+ Type type = TypeData.getType(getClass());
+ try {
+ Type widgetType = type.getMethod("getWidget").getReturnType();
+ Object instance = widgetType.createInstance();
+ return (Widget) instance;
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about the widget for "
+ + Util.getSimpleName(this)
+ + ". Did you remember to compile the right widgetset?",
+ e);
+ }
}
/**
@@ -137,7 +151,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector
ServerConnector parent = getParent();
if (parent instanceof ComponentContainerConnector) {
((ComponentContainerConnector) parent).updateCaption(this);
- } else if (parent == null && !(this instanceof RootConnector)) {
+ } else if (parent == null && !(this instanceof UIConnector)) {
VConsole.error("Parent of connector "
+ Util.getConnectorString(this)
+ " is null. This is typically an indication of a broken component hierarchy");
@@ -167,7 +181,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector
ServerConnector parent = getParent();
if (parent instanceof ComponentContainerConnector) {
((ComponentContainerConnector) parent).updateCaption(this);
- } else if (parent == null && !(this instanceof RootConnector)) {
+ } else if (parent == null && !(this instanceof UIConnector)) {
VConsole.error("Parent of connector "
+ Util.getConnectorString(this)
+ " is null. This is typically an indication of a broken component hierarchy");
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java
index 435fff8a5b..b861ade0bf 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java
@@ -33,6 +33,9 @@ import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Type;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
/**
* An abstract implementation of Connector.
@@ -265,7 +268,20 @@ public abstract class AbstractConnector implements ServerConnector,
* @return A new state object
*/
protected SharedState createState() {
- return ConnectorStateFactory.createState(getClass());
+ Type connectorType = TypeData.getType(getClass());
+ try {
+ Type stateType = connectorType.getMethod("getState")
+ .getReturnType();
+ Object stateInstance = stateType.createInstance();
+ return (SharedState) stateInstance;
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about the state for "
+ + Util.getSimpleName(this)
+ + ". Did you remember to compile the right widgetset?",
+ e);
+ }
+
}
@Override
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java
deleted file mode 100644
index 698d8e6e61..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.shared.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();
- }
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java
deleted file mode 100644
index b04daa6910..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.ui;
-
-import com.google.gwt.core.client.GWT;
-import com.vaadin.shared.Connector;
-import com.vaadin.shared.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;
- }
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java
deleted file mode 100644
index 073e36cabb..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-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>() {
- @Override
- 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;
- }
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java
index 2f52971aeb..33d97f4ed8 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java
@@ -49,9 +49,6 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector {
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- getWidget().setControls(getState().isShowControls());
- getWidget().setAutoplay(getState().isAutoplay());
- getWidget().setMuted(getState().isMuted());
for (int i = 0; i < getState().getSources().size(); i++) {
URLReference source = getState().getSources().get(i);
String sourceType = getState().getSourceTypes().get(i);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java
index 1759889a1b..4e1bed1aa8 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.terminal.gwt.client.ui.root;
+package com.vaadin.terminal.gwt.client.ui.UI;
import java.util.ArrayList;
import java.util.Iterator;
@@ -36,10 +36,10 @@ import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
-import com.vaadin.shared.ui.root.PageClientRpc;
-import com.vaadin.shared.ui.root.RootConstants;
-import com.vaadin.shared.ui.root.RootServerRpc;
-import com.vaadin.shared.ui.root.RootState;
+import com.vaadin.shared.ui.ui.PageClientRpc;
+import com.vaadin.shared.ui.ui.UIConstants;
+import com.vaadin.shared.ui.ui.UIServerRpc;
+import com.vaadin.shared.ui.ui.UIState;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
@@ -58,13 +58,13 @@ import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler;
import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren;
import com.vaadin.terminal.gwt.client.ui.notification.VNotification;
import com.vaadin.terminal.gwt.client.ui.window.WindowConnector;
-import com.vaadin.ui.Root;
+import com.vaadin.ui.UI;
-@Connect(value = Root.class, loadStyle = LoadStyle.EAGER)
-public class RootConnector extends AbstractComponentContainerConnector
+@Connect(value = UI.class, loadStyle = LoadStyle.EAGER)
+public class UIConnector extends AbstractComponentContainerConnector
implements Paintable, MayScrollChildren {
- private RootServerRpc rpc = RpcProxy.create(RootServerRpc.class, this);
+ private UIServerRpc rpc = RpcProxy.create(UIServerRpc.class, this);
private HandlerRegistration childStateChangeHandlerRegistration;
@@ -107,7 +107,7 @@ public class RootConnector extends AbstractComponentContainerConnector
getWidget().connection = client;
getWidget().immediate = getState().isImmediate();
- getWidget().resizeLazy = uidl.hasAttribute(RootConstants.RESIZE_LAZY);
+ getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY);
String newTheme = uidl.getStringAttribute("theme");
if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) {
// Complete page refresh is needed due css can affect layout
@@ -151,14 +151,14 @@ public class RootConnector extends AbstractComponentContainerConnector
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
- VRoot.goTo(url);
+ VUI.goTo(url);
}
});
} else if ("_self".equals(target)) {
// This window is closing (for sure). Only other opens are
// relevant in this change. See #3558, #2144
isClosed = true;
- VRoot.goTo(url);
+ VUI.goTo(url);
} else {
String options;
if (open.hasAttribute("border")) {
@@ -263,9 +263,9 @@ public class RootConnector extends AbstractComponentContainerConnector
scrollIntoView(connector);
}
- if (uidl.hasAttribute(RootConstants.FRAGMENT_VARIABLE)) {
+ if (uidl.hasAttribute(UIConstants.FRAGMENT_VARIABLE)) {
getWidget().currentFragment = uidl
- .getStringAttribute(RootConstants.FRAGMENT_VARIABLE);
+ .getStringAttribute(UIConstants.FRAGMENT_VARIABLE);
if (!getWidget().currentFragment.equals(History.getToken())) {
History.newItem(getWidget().currentFragment, true);
}
@@ -276,7 +276,7 @@ public class RootConnector extends AbstractComponentContainerConnector
// Include current fragment in the next request
client.updateVariable(getWidget().id,
- RootConstants.FRAGMENT_VARIABLE,
+ UIConstants.FRAGMENT_VARIABLE,
getWidget().currentFragment, false);
}
@@ -333,8 +333,8 @@ public class RootConnector extends AbstractComponentContainerConnector
}
@Override
- public VRoot getWidget() {
- return (VRoot) super.getWidget();
+ public VUI getWidget() {
+ return (VUI) super.getWidget();
}
protected ComponentConnector getContent() {
@@ -359,7 +359,7 @@ public class RootConnector extends AbstractComponentContainerConnector
}
/**
- * Checks if the given sub window is a child of this Root Connector
+ * Checks if the given sub window is a child of this UI Connector
*
* @deprecated Should be replaced by a more generic mechanism for getting
* non-ComponentConnector children
@@ -388,8 +388,8 @@ public class RootConnector extends AbstractComponentContainerConnector
}
@Override
- public RootState getState() {
- return (RootState) super.getState();
+ public UIState getState() {
+ return (UIState) super.getState();
}
@Override
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java b/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java
index 162e7c55a8..1c4b69a3b9 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java
@@ -14,7 +14,7 @@
* the License.
*/
-package com.vaadin.terminal.gwt.client.ui.root;
+package com.vaadin.terminal.gwt.client.ui.UI;
import java.util.ArrayList;
@@ -33,7 +33,7 @@ import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.SimplePanel;
import com.vaadin.shared.ApplicationConstants;
-import com.vaadin.shared.ui.root.RootConstants;
+import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
@@ -50,7 +50,7 @@ import com.vaadin.terminal.gwt.client.ui.textfield.VTextField;
/**
*
*/
-public class VRoot extends SimplePanel implements ResizeHandler,
+public class VUI extends SimplePanel implements ResizeHandler,
Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable,
HasResizeHandlers {
@@ -130,7 +130,7 @@ public class VRoot extends SimplePanel implements ResizeHandler,
// Send the new fragment to the server if it has changed
if (!newFragment.equals(currentFragment) && connection != null) {
currentFragment = newFragment;
- connection.updateVariable(id, RootConstants.FRAGMENT_VARIABLE,
+ connection.updateVariable(id, UIConstants.FRAGMENT_VARIABLE,
newFragment, true);
}
}
@@ -146,7 +146,7 @@ public class VRoot extends SimplePanel implements ResizeHandler,
});
- public VRoot() {
+ public VUI() {
super();
setStyleName(CLASSNAME);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java b/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
index b6012eded1..a4d00f59de 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
@@ -24,23 +24,6 @@ import com.vaadin.terminal.gwt.client.Util;
public class DDUtil {
- /**
- * @deprecated use the version with the actual event instead of detected
- * clientY value
- *
- * @param element
- * @param clientY
- * @param topBottomRatio
- * @return
- */
- @Deprecated
- public static VerticalDropLocation getVerticalDropLocation(Element element,
- int clientY, double topBottomRatio) {
- int offsetHeight = element.getOffsetHeight();
- return getVerticalDropLocation(element, offsetHeight, clientY,
- topBottomRatio);
- }
-
public static VerticalDropLocation getVerticalDropLocation(Element element,
NativeEvent event, double topBottomRatio) {
int offsetHeight = element.getOffsetHeight();
@@ -76,21 +59,7 @@ public class DDUtil {
public static HorizontalDropLocation getHorizontalDropLocation(
Element element, NativeEvent event, double leftRightRatio) {
- int touchOrMouseClientX = Util.getTouchOrMouseClientX(event);
- return getHorizontalDropLocation(element, touchOrMouseClientX,
- leftRightRatio);
- }
-
- /**
- * @deprecated use the version with the actual event
- * @param element
- * @param clientX
- * @param leftRightRatio
- * @return
- */
- @Deprecated
- public static HorizontalDropLocation getHorizontalDropLocation(
- Element element, int clientX, double leftRightRatio) {
+ int clientX = Util.getTouchOrMouseClientX(event);
// Event coordinates are relative to the viewport, element absolute
// position is relative to the document. Make element position relative
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java b/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java
index 32abc787da..34bdb28c91 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java
@@ -53,14 +53,6 @@ public class VHtml5DragEvent extends NativeEvent {
return null;
}-*/;
- /**
- * @deprecated As of Vaadin 6.8, replaced by {@link #setDropEffect(String)}.
- */
- @Deprecated
- public final void setDragEffect(String effect) {
- setDropEffect(effect);
- }
-
public final native void setDropEffect(String effect)
/*-{
try {
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java
new file mode 100644
index 0000000000..61231c4fba
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java
@@ -0,0 +1,38 @@
+package com.vaadin.terminal.gwt.client.ui.embeddedbrowser;
+
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.embeddedbrowser.EmbeddedBrowserState;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+
+@Connect(com.vaadin.ui.EmbeddedBrowser.class)
+public class EmbeddedBrowserConnector extends AbstractComponentConnector {
+
+ @Override
+ protected void init() {
+ super.init();
+ }
+
+ @Override
+ public VEmbeddedBrowser getWidget() {
+ return (VEmbeddedBrowser) super.getWidget();
+ }
+
+ @Override
+ public EmbeddedBrowserState getState() {
+ return (EmbeddedBrowserState) super.getState();
+ }
+
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+
+ super.onStateChanged(stateChangeEvent);
+
+ getWidget().setAlternateText(getState().getAlternateText());
+ getWidget().setSource(
+ getState().getSource() != null ? getState().getSource()
+ .getURL() : null);
+ getWidget().setName(getConnectorId());
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java
new file mode 100644
index 0000000000..fffbff049e
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java
@@ -0,0 +1,120 @@
+package com.vaadin.terminal.gwt.client.ui.embeddedbrowser;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.IFrameElement;
+import com.google.gwt.user.client.ui.Widget;
+
+public class VEmbeddedBrowser extends Widget {
+
+ protected IFrameElement iframe;
+ protected Element altElement;
+ protected String altText;
+
+ public VEmbeddedBrowser() {
+ Element root = Document.get().createDivElement();
+ setElement(root);
+
+ setStylePrimaryName("v-embeddedbrowser");
+
+ createAltTextElement();
+ }
+
+ /**
+ * Always creates new iframe inside widget. Will replace previous iframe.
+ *
+ * @return
+ */
+ protected IFrameElement createIFrameElement(String src) {
+ String name = null;
+
+ // Remove alt text
+ if (altElement != null) {
+ getElement().removeChild(altElement);
+ altElement = null;
+ }
+
+ // Remove old iframe
+ if (iframe != null) {
+ name = iframe.getAttribute("name");
+ getElement().removeChild(iframe);
+ iframe = null;
+ }
+
+ iframe = Document.get().createIFrameElement();
+ iframe.setSrc(src);
+ iframe.setFrameBorder(0);
+ iframe.setAttribute("width", "100%");
+ iframe.setAttribute("height", "100%");
+ iframe.setAttribute("allowTransparency", "true");
+
+ getElement().appendChild(iframe);
+
+ // Reset old attributes (except src)
+ if (name != null) {
+ iframe.setName(name);
+ }
+
+ return iframe;
+ }
+
+ protected void createAltTextElement() {
+ if (iframe != null) {
+ return;
+ }
+
+ if (altElement == null) {
+ altElement = Document.get().createSpanElement();
+ getElement().appendChild(altElement);
+ }
+
+ if (altText != null) {
+ altElement.setInnerText(altText);
+ } else {
+ altElement.setInnerText("");
+ }
+ }
+
+ public void setAlternateText(String altText) {
+ if (this.altText != altText) {
+ this.altText = altText;
+ if (altElement != null) {
+ if (altText != null) {
+ altElement.setInnerText(altText);
+ } else {
+ altElement.setInnerText("");
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the source (the "src" attribute) of iframe. Will replace old iframe
+ * with new.
+ *
+ * @param source
+ * Source of iframe.
+ */
+ public void setSource(String source) {
+
+ if (source == null) {
+ if (iframe != null) {
+ getElement().removeChild(iframe);
+ iframe = null;
+ }
+ createAltTextElement();
+ setAlternateText(altText);
+ return;
+ }
+
+ if (iframe == null || iframe.getSrc() != source) {
+ createIFrameElement(source);
+ }
+ }
+
+ public void setName(String name) {
+ if (iframe != null) {
+ iframe.setName(name);
+ }
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java
new file mode 100644
index 0000000000..a9e7a71013
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java
@@ -0,0 +1,44 @@
+package com.vaadin.terminal.gwt.client.ui.flash;
+
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.flash.FlashState;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+
+@Connect(com.vaadin.ui.Flash.class)
+public class FlashConnector extends AbstractComponentConnector {
+
+ @Override
+ protected void init() {
+ super.init();
+ }
+
+ @Override
+ public VFlash getWidget() {
+ return (VFlash) super.getWidget();
+ }
+
+ @Override
+ public FlashState getState() {
+ return (FlashState) super.getState();
+ }
+
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+
+ super.onStateChanged(stateChangeEvent);
+
+ getWidget().setSource(
+ getState().getSource() != null ? getState().getSource()
+ .getURL() : null);
+ getWidget().setArchive(getState().getArchive());
+ getWidget().setClassId(getState().getClassId());
+ getWidget().setCodebase(getState().getCodebase());
+ getWidget().setCodetype(getState().getCodetype());
+ getWidget().setStandby(getState().getStandby());
+ getWidget().setAlternateText(getState().getAlternateText());
+ getWidget().setEmbedParams(getState().getEmbedParams());
+
+ getWidget().rebuildIfNeeded();
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java b/client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java
new file mode 100644
index 0000000000..5d60dc66aa
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java
@@ -0,0 +1,228 @@
+package com.vaadin.terminal.gwt.client.ui.flash;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.google.gwt.user.client.ui.HTML;
+import com.vaadin.terminal.gwt.client.Util;
+
+public class VFlash extends HTML {
+
+ protected String source;
+ protected String altText;
+ protected String classId;
+ protected String codebase;
+ protected String codetype;
+ protected String standby;
+ protected String archive;
+ protected Map<String, String> embedParams = new HashMap<String, String>();
+ protected boolean needsRebuild = false;
+ protected String width;
+ protected String height;
+
+ public VFlash() {
+ setStylePrimaryName("v-flash");
+ }
+
+ public void setSource(String source) {
+ if (this.source != source) {
+ this.source = source;
+ needsRebuild = true;
+ }
+ }
+
+ public void setAlternateText(String altText) {
+ if (this.altText != altText) {
+ this.altText = altText;
+ needsRebuild = true;
+ }
+ }
+
+ public void setClassId(String classId) {
+ if (this.classId != classId) {
+ this.classId = classId;
+ needsRebuild = true;
+ }
+ }
+
+ public void setCodebase(String codebase) {
+ if (this.codebase != codebase) {
+ this.codebase = codebase;
+ needsRebuild = true;
+ }
+ }
+
+ public void setCodetype(String codetype) {
+ if (this.codetype != codetype) {
+ this.codetype = codetype;
+ needsRebuild = true;
+ }
+ }
+
+ public void setStandby(String standby) {
+ if (this.standby != standby) {
+ this.standby = standby;
+ needsRebuild = true;
+ }
+ }
+
+ public void setArchive(String archive) {
+ if (this.archive != archive) {
+ this.archive = archive;
+ needsRebuild = true;
+ }
+ }
+
+ /**
+ * Call this after changing values of widget. It will rebuild embedding
+ * structure if needed.
+ */
+ public void rebuildIfNeeded() {
+ if (needsRebuild) {
+ needsRebuild = false;
+ this.setHTML(createFlashEmbed());
+ }
+ }
+
+ @Override
+ public void setWidth(String width) {
+ // super.setWidth(height);
+
+ if (this.width != width) {
+ this.width = width;
+ needsRebuild = true;
+ }
+ }
+
+ @Override
+ public void setHeight(String height) {
+ // super.setHeight(height);
+
+ if (this.height != height) {
+ this.height = height;
+ needsRebuild = true;
+ }
+ }
+
+ public void setEmbedParams(Map<String, String> params) {
+ if (params == null) {
+ if (!embedParams.isEmpty()) {
+ embedParams.clear();
+ needsRebuild = true;
+ }
+ return;
+ }
+
+ if (!embedParams.equals(params)) {
+ embedParams = new HashMap<String, String>(params);
+ needsRebuild = true;
+ }
+ }
+
+ protected String createFlashEmbed() {
+ /*
+ * To ensure cross-browser compatibility we are using the twice-cooked
+ * method to embed flash i.e. we add a OBJECT tag for IE ActiveX and
+ * inside it a EMBED for all other browsers.
+ */
+
+ StringBuilder html = new StringBuilder();
+
+ // Start the object tag
+ html.append("<object ");
+
+ /*
+ * Add classid required for ActiveX to recognize the flash. This is a
+ * predefined value which ActiveX recognizes and must be the given
+ * value. More info can be found on
+ * http://kb2.adobe.com/cps/415/tn_4150.html. Allow user to override
+ * this by setting his own classid.
+ */
+ if (classId != null) {
+ html.append("classid=\"" + Util.escapeAttribute(classId) + "\" ");
+ } else {
+ html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ");
+ }
+
+ /*
+ * Add codebase required for ActiveX and must be exactly this according
+ * to http://kb2.adobe.com/cps/415/tn_4150.html to work with the above
+ * given classid. Again, see more info on
+ * http://kb2.adobe.com/cps/415/tn_4150.html. Limiting Flash version to
+ * 6.0.0.0 and above. Allow user to override this by setting his own
+ * codebase
+ */
+ if (codebase != null) {
+ html.append("codebase=\"" + Util.escapeAttribute(codebase) + "\" ");
+ } else {
+ html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" ");
+ }
+
+ // Add width and height
+ html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
+ html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
+ html.append("type=\"application/x-shockwave-flash\" ");
+
+ // Codetype
+ if (codetype != null) {
+ html.append("codetype=\"" + Util.escapeAttribute(codetype) + "\" ");
+ }
+
+ // Standby
+ if (standby != null) {
+ html.append("standby=\"" + Util.escapeAttribute(standby) + "\" ");
+ }
+
+ // Archive
+ if (archive != null) {
+ html.append("archive=\"" + Util.escapeAttribute(archive) + "\" ");
+ }
+
+ // End object tag
+ html.append(">");
+
+ // Ensure we have an movie parameter
+ if (embedParams.get("movie") == null) {
+ embedParams.put("movie", source);
+ }
+
+ // Add parameters to OBJECT
+ for (String name : embedParams.keySet()) {
+ html.append("<param ");
+ html.append("name=\"" + Util.escapeAttribute(name) + "\" ");
+ html.append("value=\""
+ + Util.escapeAttribute(embedParams.get(name)) + "\" ");
+ html.append("/>");
+ }
+
+ // Build inner EMBED tag
+ html.append("<embed ");
+ html.append("src=\"" + Util.escapeAttribute(source) + "\" ");
+ html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
+ html.append("height=\"" + Util.escapeAttribute(height) + "\" ");
+ html.append("type=\"application/x-shockwave-flash\" ");
+
+ // Add the parameters to the Embed
+ for (String name : embedParams.keySet()) {
+ html.append(Util.escapeAttribute(name));
+ html.append("=");
+ html.append("\"" + Util.escapeAttribute(embedParams.get(name))
+ + "\"");
+ }
+
+ // End embed tag
+ html.append("></embed>");
+
+ if (altText != null) {
+ html.append("<noembed>");
+ html.append(altText);
+ html.append("</noembed>");
+ }
+
+ // End object tag
+ html.append("</object>");
+
+ return html.toString();
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java
new file mode 100644
index 0000000000..d36e224a03
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java
@@ -0,0 +1,67 @@
+package com.vaadin.terminal.gwt.client.ui.image;
+
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.event.dom.client.LoadEvent;
+import com.google.gwt.event.dom.client.LoadHandler;
+import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.image.ImageServerRpc;
+import com.vaadin.shared.ui.image.ImageState;
+import com.vaadin.terminal.gwt.client.communication.RpcProxy;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+import com.vaadin.terminal.gwt.client.ui.ClickEventHandler;
+
+@Connect(com.vaadin.ui.Image.class)
+public class ImageConnector extends AbstractComponentConnector {
+
+ ImageServerRpc rpc;
+
+ @Override
+ protected void init() {
+ super.init();
+ rpc = RpcProxy.create(ImageServerRpc.class, this);
+ getWidget().addHandler(new LoadHandler() {
+
+ @Override
+ public void onLoad(LoadEvent event) {
+ getLayoutManager().setNeedsMeasure(ImageConnector.this);
+ }
+
+ }, LoadEvent.getType());
+ }
+
+ @Override
+ public VImage getWidget() {
+ return (VImage) super.getWidget();
+ }
+
+ @Override
+ public ImageState getState() {
+ return (ImageState) super.getState();
+ }
+
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
+
+ clickEventHandler.handleEventHandlerRegistration();
+
+ getWidget().setUrl(
+ getState().getSource() != null ? getState().getSource()
+ .getURL() : null);
+ getWidget().setAltText(getState().getAlternateText());
+ }
+
+ protected final ClickEventHandler clickEventHandler = new ClickEventHandler(
+ this) {
+
+ @Override
+ protected void fireClick(NativeEvent event,
+ MouseEventDetails mouseDetails) {
+ rpc.click(mouseDetails);
+ }
+
+ };
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java b/client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java
new file mode 100644
index 0000000000..7e6b77ed4a
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java
@@ -0,0 +1,10 @@
+package com.vaadin.terminal.gwt.client.ui.image;
+
+import com.google.gwt.user.client.ui.Image;
+
+public class VImage extends Image {
+
+ public VImage() {
+ setStylePrimaryName("v-image");
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java
index 4280db8bc9..57f8c16952 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java
@@ -43,10 +43,10 @@ public class LabelConnector extends AbstractComponentConnector {
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
boolean sinkOnloads = false;
- switch (getState().getContentMode()) {
+ switch (getState().contentMode) {
case PREFORMATTED:
PreElement preElement = Document.get().createPreElement();
- preElement.setInnerText(getState().getText());
+ preElement.setInnerText(getState().text);
// clear existing content
getWidget().setHTML("");
// add preformatted text to dom
@@ -54,14 +54,14 @@ public class LabelConnector extends AbstractComponentConnector {
break;
case TEXT:
- getWidget().setText(getState().getText());
+ getWidget().setText(getState().text);
break;
case XHTML:
case RAW:
sinkOnloads = true;
case XML:
- getWidget().setHTML(getState().getText());
+ getWidget().setHTML(getState().text);
break;
default:
getWidget().setText("");
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
index 6e253c9137..b668c9a88c 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
@@ -29,7 +29,8 @@ import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.shared.ui.root.RootConstants;
+import com.vaadin.shared.Position;
+import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.UIDL;
@@ -38,13 +39,13 @@ import com.vaadin.terminal.gwt.client.ui.VOverlay;
public class VNotification extends VOverlay {
- public static final int CENTERED = 1;
- public static final int CENTERED_TOP = 2;
- public static final int CENTERED_BOTTOM = 3;
- public static final int TOP_LEFT = 4;
- public static final int TOP_RIGHT = 5;
- public static final int BOTTOM_LEFT = 6;
- public static final int BOTTOM_RIGHT = 7;
+ public static final Position CENTERED = Position.MIDDLE_CENTER;
+ public static final Position CENTERED_TOP = Position.TOP_CENTER;
+ public static final Position CENTERED_BOTTOM = Position.BOTTOM_CENTER;
+ public static final Position TOP_LEFT = Position.TOP_LEFT;
+ public static final Position TOP_RIGHT = Position.TOP_RIGHT;
+ public static final Position BOTTOM_LEFT = Position.BOTTOM_LEFT;
+ public static final Position BOTTOM_RIGHT = Position.BOTTOM_RIGHT;
public static final int DELAY_FOREVER = -1;
public static final int DELAY_NONE = 0;
@@ -144,21 +145,21 @@ public class VNotification extends VOverlay {
show(CENTERED, style);
}
- public void show(int position) {
+ public void show(com.vaadin.shared.Position position) {
show(position, null);
}
- public void show(Widget widget, int position, String style) {
+ public void show(Widget widget, Position position, String style) {
setWidget(widget);
show(position, style);
}
- public void show(String html, int position, String style) {
+ public void show(String html, Position position, String style) {
setWidget(new HTML(html));
show(position, style);
}
- public void show(int position, String style) {
+ public void show(Position position, String style) {
setOpacity(getElement(), startOpacity);
if (style != null) {
temporaryStyle = style;
@@ -231,7 +232,7 @@ public class VNotification extends VOverlay {
}
}
- public void setPosition(int position) {
+ public void setPosition(com.vaadin.shared.Position position) {
final Element el = getElement();
DOM.setStyleAttribute(el, "top", "");
DOM.setStyleAttribute(el, "left", "");
@@ -260,17 +261,17 @@ public class VNotification extends VOverlay {
DOM.setStyleAttribute(el, "bottom", "0px");
DOM.setStyleAttribute(el, "left", "0px");
break;
- case CENTERED_TOP:
+ case TOP_CENTER:
center();
DOM.setStyleAttribute(el, "top", "0px");
break;
- case CENTERED_BOTTOM:
+ case BOTTOM_CENTER:
center();
DOM.setStyleAttribute(el, "top", "");
DOM.setStyleAttribute(el, "bottom", "0px");
break;
default:
- case CENTERED:
+ case MIDDLE_CENTER:
center();
break;
}
@@ -383,19 +384,19 @@ public class VNotification extends VOverlay {
public static void showNotification(ApplicationConnection client,
final UIDL notification) {
boolean onlyPlainText = notification
- .hasAttribute(RootConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED);
+ .hasAttribute(UIConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED);
String html = "";
if (notification
- .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_ICON)) {
+ .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_ICON)) {
final String parsedUri = client
.translateVaadinUri(notification
- .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_ICON));
+ .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_ICON));
html += "<img src=\"" + Util.escapeAttribute(parsedUri) + "\" />";
}
if (notification
- .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_CAPTION)) {
+ .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION)) {
String caption = notification
- .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_CAPTION);
+ .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION);
if (onlyPlainText) {
caption = Util.escapeHTML(caption);
caption = caption.replaceAll("\\n", "<br />");
@@ -403,9 +404,9 @@ public class VNotification extends VOverlay {
html += "<h1>" + caption + "</h1>";
}
if (notification
- .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_MESSAGE)) {
+ .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE)) {
String message = notification
- .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_MESSAGE);
+ .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE);
if (onlyPlainText) {
message = Util.escapeHTML(message);
message = message.replaceAll("\\n", "<br />");
@@ -414,13 +415,16 @@ public class VNotification extends VOverlay {
}
final String style = notification
- .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification
- .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE)
+ .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification
+ .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_STYLE)
: null;
- final int position = notification
- .getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_POSITION);
+
+ final int pos = notification
+ .getIntAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_POSITION);
+ Position position = Position.values()[pos];
+
final int delay = notification
- .getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY);
+ .getIntAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_DELAY);
createNotification(delay).show(html, position, style);
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java
index 7e0617b7dc..53f3b8874b 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java
@@ -15,70 +15,61 @@
*/
package com.vaadin.terminal.gwt.client.ui.slider;
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.user.client.Command;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.vaadin.shared.ui.Connect;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.Paintable;
-import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.shared.ui.slider.SliderServerRpc;
+import com.vaadin.shared.ui.slider.SliderState;
+import com.vaadin.terminal.gwt.client.communication.RpcProxy;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.ui.AbstractFieldConnector;
import com.vaadin.ui.Slider;
@Connect(Slider.class)
public class SliderConnector extends AbstractFieldConnector implements
- Paintable {
+ ValueChangeHandler<Double> {
- @Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- getWidget().client = client;
- getWidget().id = uidl.getId();
-
- if (!isRealUpdate(uidl)) {
- return;
- }
+ protected SliderServerRpc rpc = RpcProxy
+ .create(SliderServerRpc.class, this);
- getWidget().immediate = getState().isImmediate();
- getWidget().disabled = !isEnabled();
- getWidget().readonly = isReadOnly();
+ @Override
+ public void init() {
+ super.init();
+ getWidget().setConnection(getConnection());
+ getWidget().addValueChangeHandler(this);
+ }
- getWidget().vertical = uidl.hasAttribute("vertical");
+ @Override
+ public VSlider getWidget() {
+ return (VSlider) super.getWidget();
+ }
- // TODO should style names be used?
+ @Override
+ public SliderState getState() {
+ return (SliderState) super.getState();
+ }
- if (getWidget().vertical) {
- getWidget().addStyleName(VSlider.CLASSNAME + "-vertical");
- } else {
- getWidget().removeStyleName(VSlider.CLASSNAME + "-vertical");
- }
+ @Override
+ public void onValueChange(ValueChangeEvent<Double> event) {
+ rpc.valueChanged(event.getValue());
+ }
- getWidget().min = uidl.getDoubleAttribute("min");
- getWidget().max = uidl.getDoubleAttribute("max");
- getWidget().resolution = uidl.getIntAttribute("resolution");
- getWidget().value = new Double(uidl.getDoubleVariable("value"));
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
- getWidget().setFeedbackValue(getWidget().value);
+ getWidget().setId(getConnectorId());
+ getWidget().setImmediate(getState().isImmediate());
+ getWidget().setDisabled(!isEnabled());
+ getWidget().setReadOnly(isReadOnly());
+ getWidget().setOrientation(getState().getOrientation());
+ getWidget().setMinValue(getState().getMinValue());
+ getWidget().setMaxValue(getState().getMaxValue());
+ getWidget().setResolution(getState().getResolution());
+ getWidget().setValue(getState().getValue(), false);
+ getWidget().setFeedbackValue(getState().getValue());
getWidget().buildBase();
-
- if (!getWidget().vertical) {
- // Draw handle with a delay to allow base to gain maximum width
- Scheduler.get().scheduleDeferred(new Command() {
- @Override
- public void execute() {
- getWidget().buildHandle();
- getWidget().setValue(getWidget().value, false);
- }
- });
- } else {
- getWidget().buildHandle();
- getWidget().setValue(getWidget().value, false);
- }
- }
-
- @Override
- public VSlider getWidget() {
- return (VSlider) super.getWidget();
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java b/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java
index 9667522eb3..d9801626b4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java
@@ -19,12 +19,17 @@ package com.vaadin.terminal.gwt.client.ui.slider;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Command;
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.Window;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasValue;
+import com.vaadin.shared.ui.slider.SliderOrientation;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ContainerResizedListener;
@@ -36,7 +41,7 @@ import com.vaadin.terminal.gwt.client.ui.VLazyExecutor;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
public class VSlider extends SimpleFocusablePanel implements Field,
- ContainerResizedListener {
+ ContainerResizedListener, HasValue<Double> {
public static final String CLASSNAME = "v-slider";
@@ -46,20 +51,22 @@ public class VSlider extends SimpleFocusablePanel implements Field,
*/
private static final int MIN_SIZE = 50;
- ApplicationConnection client;
+ protected ApplicationConnection client;
- String id;
+ protected String id;
- boolean immediate;
- boolean disabled;
- boolean readonly;
+ protected boolean immediate;
+ protected boolean disabled;
+ protected boolean readonly;
private int acceleration = 1;
- double min;
- double max;
- int resolution;
- Double value;
- boolean vertical;
+ protected double min;
+ protected double max;
+ protected int resolution;
+ protected Double value;
+ protected SliderOrientation orientation = SliderOrientation.HORIZONTAL;
+
+ private boolean valueChangeHandlerInitialized = false;
private final HTML feedback = new HTML("", false);
private final VOverlay feedbackPopup = new VOverlay(true, false, true) {
@@ -92,7 +99,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
@Override
public void execute() {
- updateValueToServer();
+ fireValueChanged();
acceleration = 1;
}
});
@@ -137,7 +144,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
}
private void updateFeedbackPosition() {
- if (vertical) {
+ if (isVertical()) {
feedbackPopup.setPopupPosition(
DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth(),
DOM.getAbsoluteTop(handle) + handle.getOffsetHeight() / 2
@@ -152,16 +159,17 @@ public class VSlider extends SimpleFocusablePanel implements Field,
}
void buildBase() {
- final String styleAttribute = vertical ? "height" : "width";
- final String oppositeStyleAttribute = vertical ? "width" : "height";
- final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
+ final String styleAttribute = isVertical() ? "height" : "width";
+ final String oppositeStyleAttribute = isVertical() ? "width" : "height";
+ final String domProperty = isVertical() ? "offsetHeight"
+ : "offsetWidth";
// clear unnecessary opposite style attribute
DOM.setStyleAttribute(base, oppositeStyleAttribute, "");
final Element p = DOM.getParent(getElement());
if (DOM.getElementPropertyInt(p, domProperty) > 50) {
- if (vertical) {
+ if (isVertical()) {
setHeight();
} else {
DOM.setStyleAttribute(base, styleAttribute, "");
@@ -176,7 +184,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
public void execute() {
final Element p = DOM.getParent(getElement());
if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) {
- if (vertical) {
+ if (isVertical()) {
setHeight();
} else {
DOM.setStyleAttribute(base, styleAttribute, "");
@@ -188,12 +196,27 @@ public class VSlider extends SimpleFocusablePanel implements Field,
});
}
+ if (!isVertical()) {
+ // Draw handle with a delay to allow base to gain maximum width
+ Scheduler.get().scheduleDeferred(new Command() {
+ @Override
+ public void execute() {
+ buildHandle();
+ setValue(value, false);
+ }
+ });
+ } else {
+ buildHandle();
+ setValue(value, false);
+ }
+
// TODO attach listeners for focusing and arrow keys
}
void buildHandle() {
- final String handleAttribute = vertical ? "marginTop" : "marginLeft";
- final String oppositeHandleAttribute = vertical ? "marginLeft"
+ final String handleAttribute = isVertical() ? "marginTop"
+ : "marginLeft";
+ final String oppositeHandleAttribute = isVertical() ? "marginLeft"
: "marginTop";
DOM.setStyleAttribute(handle, handleAttribute, "0");
@@ -206,59 +229,6 @@ public class VSlider extends SimpleFocusablePanel implements Field,
}
- void setValue(Double value, boolean updateToServer) {
- if (value == null) {
- return;
- }
-
- if (value < min) {
- value = min;
- } else if (value > max) {
- value = max;
- }
-
- // Update handle position
- final String styleAttribute = vertical ? "marginTop" : "marginLeft";
- final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
- final int handleSize = Integer.parseInt(DOM.getElementProperty(handle,
- domProperty));
- final int baseSize = Integer.parseInt(DOM.getElementProperty(base,
- domProperty)) - (2 * BASE_BORDER_WIDTH);
-
- final int range = baseSize - handleSize;
- double v = value.doubleValue();
-
- // Round value to resolution
- if (resolution > 0) {
- v = Math.round(v * Math.pow(10, resolution));
- v = v / Math.pow(10, resolution);
- } else {
- v = Math.round(v);
- }
- final double valueRange = max - min;
- double p = 0;
- if (valueRange > 0) {
- p = range * ((v - min) / valueRange);
- }
- if (p < 0) {
- p = 0;
- }
- if (vertical) {
- p = range - p;
- }
- final double pos = p;
-
- DOM.setStyleAttribute(handle, styleAttribute, (Math.round(pos)) + "px");
-
- // Update value
- this.value = new Double(v);
- setFeedbackValue(v);
-
- if (updateToServer) {
- updateValueToServer();
- }
- }
-
@Override
public void onBrowserEvent(Event event) {
if (disabled || readonly) {
@@ -386,7 +356,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
final int coord = getEventPosition(event);
final int handleSize, baseSize, baseOffset;
- if (vertical) {
+ if (isVertical()) {
handleSize = handle.getOffsetHeight();
baseSize = base.getOffsetHeight();
baseOffset = base.getAbsoluteTop() - Window.getScrollTop()
@@ -398,7 +368,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
+ handleSize / 2;
}
- if (vertical) {
+ if (isVertical()) {
v = ((baseSize - (coord - baseOffset)) / (double) (baseSize - handleSize))
* (max - min) + min;
} else {
@@ -423,7 +393,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
* @return
*/
protected int getEventPosition(Event event) {
- if (vertical) {
+ if (isVertical()) {
return Util.getTouchOrMouseClientY(event);
} else {
return Util.getTouchOrMouseClientX(event);
@@ -432,7 +402,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
@Override
public void iLayout() {
- if (vertical) {
+ if (isVertical()) {
setHeight();
}
// Update handle position
@@ -451,8 +421,8 @@ public class VSlider extends SimpleFocusablePanel implements Field,
DOM.setStyleAttribute(base, "overflow", "");
}
- private void updateValueToServer() {
- client.updateVariable(id, "value", value.doubleValue(), immediate);
+ private void fireValueChanged() {
+ ValueChangeEvent.fire(VSlider.this, value);
}
/**
@@ -469,8 +439,8 @@ public class VSlider extends SimpleFocusablePanel implements Field,
return false;
}
- if ((keycode == getNavigationUpKey() && vertical)
- || (keycode == getNavigationRightKey() && !vertical)) {
+ if ((keycode == getNavigationUpKey() && isVertical())
+ || (keycode == getNavigationRightKey() && !isVertical())) {
if (shift) {
for (int a = 0; a < acceleration; a++) {
increaseValue(false);
@@ -480,8 +450,8 @@ public class VSlider extends SimpleFocusablePanel implements Field,
increaseValue(false);
}
return true;
- } else if (keycode == getNavigationDownKey() && vertical
- || (keycode == getNavigationLeftKey() && !vertical)) {
+ } else if (keycode == getNavigationDownKey() && isVertical()
+ || (keycode == getNavigationLeftKey() && !isVertical())) {
if (shift) {
for (int a = 0; a < acceleration; a++) {
decreaseValue(false);
@@ -539,4 +509,119 @@ public class VSlider extends SimpleFocusablePanel implements Field,
protected int getNavigationRightKey() {
return KeyCodes.KEY_RIGHT;
}
+
+ public void setConnection(ApplicationConnection client) {
+ this.client = client;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setImmediate(boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public void setReadOnly(boolean readonly) {
+ this.readonly = readonly;
+ }
+
+ private boolean isVertical() {
+ return orientation == SliderOrientation.VERTICAL;
+ }
+
+ public void setOrientation(SliderOrientation orientation) {
+ if (this.orientation != orientation) {
+ this.orientation = orientation;
+
+ if (isVertical()) {
+ addStyleName(VSlider.CLASSNAME + "-vertical");
+ } else {
+ removeStyleName(VSlider.CLASSNAME + "-vertical");
+ }
+ }
+ }
+
+ public void setMinValue(double value) {
+ min = value;
+ }
+
+ public void setMaxValue(double value) {
+ max = value;
+ }
+
+ public void setResolution(int resolution) {
+ this.resolution = resolution;
+ }
+
+ public HandlerRegistration addValueChangeHandler(
+ ValueChangeHandler<Double> handler) {
+ return addHandler(handler, ValueChangeEvent.getType());
+ }
+
+ public Double getValue() {
+ return value;
+ }
+
+ public void setValue(Double value) {
+ if (value < min) {
+ value = min;
+ } else if (value > max) {
+ value = max;
+ }
+
+ // Update handle position
+ final String styleAttribute = isVertical() ? "marginTop" : "marginLeft";
+ final String domProperty = isVertical() ? "offsetHeight"
+ : "offsetWidth";
+ final int handleSize = Integer.parseInt(DOM.getElementProperty(handle,
+ domProperty));
+ final int baseSize = Integer.parseInt(DOM.getElementProperty(base,
+ domProperty)) - (2 * BASE_BORDER_WIDTH);
+
+ final int range = baseSize - handleSize;
+ double v = value.doubleValue();
+
+ // Round value to resolution
+ if (resolution > 0) {
+ v = Math.round(v * Math.pow(10, resolution));
+ v = v / Math.pow(10, resolution);
+ } else {
+ v = Math.round(v);
+ }
+ final double valueRange = max - min;
+ double p = 0;
+ if (valueRange > 0) {
+ p = range * ((v - min) / valueRange);
+ }
+ if (p < 0) {
+ p = 0;
+ }
+ if (isVertical()) {
+ p = range - p;
+ }
+ final double pos = p;
+
+ DOM.setStyleAttribute(handle, styleAttribute, (Math.round(pos)) + "px");
+
+ // Update value
+ this.value = new Double(v);
+ setFeedbackValue(v);
+ }
+
+ public void setValue(Double value, boolean fireEvents) {
+ if (value == null) {
+ return;
+ }
+
+ setValue(value);
+
+ if (fireEvents) {
+ fireValueChanged();
+ }
+ }
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java
index 9f4df02380..912f9a7c83 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java
@@ -138,9 +138,6 @@ public abstract class AbstractSplitPanelConnector extends
// Splitter updates
SplitterState splitterState = getState().getSplitterState();
- getWidget().setLocked(splitterState.isLocked());
- getWidget().setPositionReversed(splitterState.isPositionReversed());
-
getWidget().setStylenames();
getWidget().minimumPosition = splitterState.getMinPosition()
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
index 5fb7f97044..d5abed4fa9 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java
@@ -18,7 +18,6 @@ package com.vaadin.terminal.gwt.client.ui.textarea;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.textarea.TextAreaState;
-import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector;
import com.vaadin.ui.TextArea;
@@ -31,14 +30,6 @@ public class TextAreaConnector extends TextFieldConnector {
}
@Override
- public void onStateChanged(StateChangeEvent stateChangeEvent) {
- super.onStateChanged(stateChangeEvent);
-
- getWidget().setRows(getState().getRows());
- getWidget().setWordwrap(getState().isWordwrap());
- }
-
- @Override
public VTextArea getWidget() {
return (VTextArea) super.getWidget();
}