summaryrefslogtreecommitdiffstats
path: root/client/src/com/vaadin/terminal
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2012-08-28 09:30:46 +0300
committerJohn Ahlroos <john@vaadin.com>2012-08-28 09:30:46 +0300
commit7b9e1566d6e36c10aef3566b20267449586a81cb (patch)
tree4c577240fd35d863b88b91b24c7d2a07c67adf1b /client/src/com/vaadin/terminal
parentbd5876005947b830a151889a86203fd77a6d6022 (diff)
parent52986fdf881260994e5465012af2afd80447b8b6 (diff)
downloadvaadin-framework-7b9e1566d6e36c10aef3566b20267449586a81cb.tar.gz
vaadin-framework-7b9e1566d6e36c10aef3566b20267449586a81cb.zip
Merge branch 'master' into layoutgraph
Diffstat (limited to 'client/src/com/vaadin/terminal')
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java139
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java53
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ServerConnector.java10
-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.java70
-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.java220
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java16
-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/csslayout/CssLayoutConnector.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java19
-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/formlayout/FormLayoutConnector.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java4
-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/link/LinkConnector.java7
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java18
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java36
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java5
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java38
48 files changed, 1071 insertions, 731 deletions
diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
index eea60b04ea..8bb4f37324 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
@@ -29,9 +29,12 @@ 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.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 {
@@ -207,7 +210,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;
@@ -390,12 +393,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) {
@@ -418,13 +441,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);
}
}
@@ -466,86 +483,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() {
@@ -582,7 +538,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 32b15d6d87..58357ae3fc 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -65,10 +65,10 @@ 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.Type;
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
@@ -105,8 +105,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
@@ -207,11 +205,13 @@ public class ApplicationConnection {
}
public ApplicationConnection() {
+ // Assuming Root data is eagerly loaded
+ ConnectorBundleLoader.get().loadBundle(
+ ConnectorBundleLoader.EAGER_BUNDLE_NAME, null);
rootConnector = GWT.create(RootConnector.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) {
@@ -396,32 +396,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.
*
@@ -2468,7 +2442,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,
@@ -2521,11 +2496,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);
}
/**
@@ -2564,6 +2541,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),
@@ -2573,8 +2554,4 @@ public class ApplicationConnection {
LayoutManager getLayoutManager() {
return layoutManager;
}
-
- public SerializerMap getSerializerMap() {
- return serializerMap;
- }
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
index d6479dad86..891e45edb5 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;
/**
@@ -164,4 +165,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/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..082d032e64
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
@@ -0,0 +1,70 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+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 getDelegateToWidgetMethod() {
+ String value = TypeDataStore.getDelegateToWidget(this);
+ if (value == null) {
+ return null;
+ } else if (value.isEmpty()) {
+ return "set" + Character.toUpperCase(value.charAt(0))
+ + value.substring(1);
+ } else {
+ return 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..55740f69da
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
@@ -0,0 +1,220 @@
+/*
+@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 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 63955ddcc8..a50dad0c2f 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
@@ -37,6 +37,9 @@ 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.datefield.PopupDateFieldConnector;
import com.vaadin.terminal.gwt.client.ui.root.RootConnector;
@@ -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);
+ }
}
/**
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 0148f7816c..fabd750f8b 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.
@@ -277,7 +280,20 @@ StateChangeHandler {
* @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/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java
index 47c2049a67..2e51d717a4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java
@@ -23,7 +23,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.LayoutClickRpc;
-import com.vaadin.shared.ui.VMarginInfo;
import com.vaadin.shared.ui.csslayout.CssLayoutServerRpc;
import com.vaadin.shared.ui.csslayout.CssLayoutState;
import com.vaadin.terminal.gwt.client.BrowserInfo;
@@ -75,9 +74,6 @@ public class CssLayoutConnector extends AbstractLayoutConnector {
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- getWidget().setMarginStyles(
- new VMarginInfo(getState().getMarginsBitmask()));
-
for (ComponentConnector child : getChildComponents()) {
if (!getState().getChildCss().containsKey(child)) {
continue;
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java
index 813e95e3ed..e66b1c4208 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java
@@ -21,8 +21,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.shared.ui.VMarginInfo;
-import com.vaadin.terminal.gwt.client.StyleConstants;
public class VCssLayout extends SimplePanel {
public static final String TAGNAME = "csslayout";
@@ -64,21 +62,4 @@ public class VCssLayout extends SimplePanel {
}
- /**
- * Sets CSS classes for margin based on the given parameters.
- *
- * @param margins
- * A {@link VMarginInfo} object that provides info on
- * top/left/bottom/right margins
- */
- protected void setMarginStyles(VMarginInfo margins) {
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_TOP, margins.hasTop());
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_RIGHT, margins.hasRight());
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_BOTTOM, margins.hasBottom());
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_LEFT, margins.hasLeft());
- }
}
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/formlayout/FormLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java
index 7d5edfadf5..cbe06244af 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java
@@ -18,7 +18,7 @@ package com.vaadin.terminal.gwt.client.ui.formlayout;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.Connect;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
@@ -46,7 +46,7 @@ public class FormLayoutConnector extends AbstractLayoutConnector {
VFormLayoutTable formLayoutTable = getWidget().table;
- formLayoutTable.setMargins(new VMarginInfo(getState()
+ formLayoutTable.setMargins(new MarginInfo(getState()
.getMarginsBitmask()));
formLayoutTable.setSpacing(getState().isSpacing());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java
index d3ce6f3d3f..7f211aaf9c 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java
@@ -29,7 +29,7 @@ import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ComponentState;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
@@ -112,7 +112,7 @@ public class VFormLayout extends SimplePanel {
}
}
- public void setMargins(VMarginInfo margins) {
+ public void setMargins(MarginInfo margins) {
Element margin = getElement();
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP,
margins.hasTop());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java
index 520afb778d..9a2732e408 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java
@@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.AlignmentInfo;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.LayoutClickRpc;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc;
import com.vaadin.shared.ui.gridlayout.GridLayoutState;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
@@ -163,7 +163,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
layout.colExpandRatioArray = uidl.getIntArrayAttribute("colExpand");
layout.rowExpandRatioArray = uidl.getIntArrayAttribute("rowExpand");
- layout.updateMarginStyleNames(new VMarginInfo(getState()
+ layout.updateMarginStyleNames(new MarginInfo(getState()
.getMarginsBitmask()));
layout.updateSpacingStyleName(getState().isSpacing());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java
index 25d7de6ee6..ef44964da7 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java
@@ -29,7 +29,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.AlignmentInfo;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ConnectorMap;
@@ -677,7 +677,7 @@ public class VGridLayout extends ComplexPanel {
}
}
- void updateMarginStyleNames(VMarginInfo marginInfo) {
+ void updateMarginStyleNames(MarginInfo marginInfo) {
togglePrefixedStyleName("margin-top", marginInfo.hasTop());
togglePrefixedStyleName("margin-right", marginInfo.hasRight());
togglePrefixedStyleName("margin-bottom", marginInfo.hasBottom());
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/link/LinkConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
index c4bbcd34f7..f2b8361f2b 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
@@ -17,6 +17,7 @@
package com.vaadin.terminal.gwt.client.ui.link;
import com.google.gwt.user.client.DOM;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.Connect;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Paintable;
@@ -57,12 +58,12 @@ public class LinkConnector extends AbstractComponentConnector implements
if (uidl.hasAttribute("border")) {
if ("none".equals(uidl.getStringAttribute("border"))) {
- getWidget().borderStyle = VLink.BORDER_STYLE_NONE;
+ getWidget().borderStyle = BorderStyle.NONE;
} else {
- getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL;
+ getWidget().borderStyle = BorderStyle.MINIMAL;
}
} else {
- getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT;
+ getWidget().borderStyle = BorderStyle.DEFAULT;
}
getWidget().targetHeight = uidl.hasAttribute("targetHeight") ? uidl
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java b/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
index e312d4d489..b0e44c9d13 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
@@ -23,6 +23,7 @@ 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.vaadin.shared.ui.BorderStyle;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.Icon;
@@ -31,15 +32,20 @@ public class VLink extends HTML implements ClickHandler {
public static final String CLASSNAME = "v-link";
- protected static final int BORDER_STYLE_DEFAULT = 0;
- protected static final int BORDER_STYLE_MINIMAL = 1;
- protected static final int BORDER_STYLE_NONE = 2;
+ @Deprecated
+ protected static final BorderStyle BORDER_STYLE_DEFAULT = BorderStyle.DEFAULT;
+
+ @Deprecated
+ protected static final BorderStyle BORDER_STYLE_MINIMAL = BorderStyle.MINIMAL;
+
+ @Deprecated
+ protected static final BorderStyle BORDER_STYLE_NONE = BorderStyle.NONE;
protected String src;
protected String target;
- protected int borderStyle = BORDER_STYLE_DEFAULT;
+ protected BorderStyle borderStyle = BorderStyle.DEFAULT;
protected boolean enabled;
@@ -73,10 +79,10 @@ public class VLink extends HTML implements ClickHandler {
}
String features;
switch (borderStyle) {
- case BORDER_STYLE_NONE:
+ case NONE:
features = "menubar=no,location=no,status=no";
break;
- case BORDER_STYLE_MINIMAL:
+ case MINIMAL:
features = "menubar=yes,location=no,status=no";
break;
default:
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..b4cea2dc72 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,6 +29,7 @@ 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.Position;
import com.vaadin.shared.ui.root.RootConstants;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
@@ -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;
}
@@ -417,8 +418,11 @@ public class VNotification extends VOverlay {
.hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification
.getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE)
: null;
- final int position = notification
+
+ final int pos = notification
.getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_POSITION);
+ Position position = Position.values()[pos];
+
final int delay = notification
.getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY);
createNotification(delay).show(html, position, style);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
index 5da01bf127..122547ddb4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
@@ -23,7 +23,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.AlignmentInfo;
import com.vaadin.shared.ui.LayoutClickRpc;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
import com.vaadin.terminal.gwt.client.ComponentConnector;
@@ -133,9 +133,8 @@ public abstract class AbstractOrderedLayoutConnector extends
slot.setExpandRatio(expandRatio);
}
- layout.updateMarginStyleNames(new VMarginInfo(getState()
+ layout.updateMarginStyleNames(new MarginInfo(getState()
.getMarginsBitmask()));
-
layout.updateSpacingStyleName(getState().isSpacing());
getLayoutManager().setNeedsLayout(this);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java
index ec2c4afa97..ee55bc07ba 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java
@@ -27,7 +27,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.WidgetCollection;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.gwt.client.VCaption;
import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot;
@@ -75,7 +75,7 @@ public class VMeasuringOrderedLayout extends ComplexPanel {
}
}
- void updateMarginStyleNames(VMarginInfo marginInfo) {
+ void updateMarginStyleNames(MarginInfo marginInfo) {
togglePrefixedStyleName("margin-top", marginInfo.hasTop());
togglePrefixedStyleName("margin-right", marginInfo.hasRight());
togglePrefixedStyleName("margin-bottom", marginInfo.hasBottom());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
index 9b5c3cd767..b3490effa7 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
@@ -25,16 +25,10 @@ import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -92,14 +86,6 @@ public class RootConnector extends AbstractComponentContainerConnector
com.google.gwt.user.client.Window.setTitle(title);
}
});
- final int heartbeatInterval = getState().getHeartbeatInterval();
- new Timer() {
- @Override
- public void run() {
- sendHeartbeat();
- schedule(heartbeatInterval);
- }
- }.schedule(heartbeatInterval);
getWidget().addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
@@ -468,28 +454,4 @@ public class RootConnector extends AbstractComponentContainerConnector
});
}
- private void sendHeartbeat() {
- RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "url");
-
- rb.setCallback(new RequestCallback() {
-
- @Override
- public void onResponseReceived(Request request, Response response) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onError(Request request, Throwable exception) {
- // TODO Auto-generated method stub
-
- }
- });
-
- try {
- rb.send();
- } catch (RequestException re) {
-
- }
- }
}