summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2012-06-26 15:39:39 +0300
committerHenri Sara <hesara@vaadin.com>2012-06-26 15:39:39 +0300
commitfd80c6937b9eb31de8af83f76ab71d545b8905fc (patch)
treeac30d1777abb525580b0bf695ae686c3911c63d5
parentb6e69bbb13614062752528580df13b19144e25ee (diff)
parent399b4cb789f4d898e84dfb386b8ad45af5cee7d5 (diff)
downloadvaadin-framework-fd80c6937b9eb31de8af83f76ab71d545b8905fc.tar.gz
vaadin-framework-fd80c6937b9eb31de8af83f76ab71d545b8905fc.zip
Merge branch 'master' into gwt
-rw-r--r--src/com/vaadin/Application.java12
-rw-r--r--src/com/vaadin/data/util/AbstractBeanContainer.java5
-rw-r--r--src/com/vaadin/data/util/AbstractInMemoryContainer.java4
-rw-r--r--src/com/vaadin/data/util/converter/ConverterUtil.java11
-rw-r--r--src/com/vaadin/navigator/Navigator.java50
-rw-r--r--src/com/vaadin/terminal/AbstractErrorMessage.java7
-rw-r--r--src/com/vaadin/terminal/CombinedRequest.java2
-rw-r--r--src/com/vaadin/terminal/Page.java26
-rw-r--r--src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java21
-rw-r--r--src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/button/ButtonState.java25
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java6
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java9
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java25
-rw-r--r--src/com/vaadin/terminal/gwt/server/BootstrapHandler.java2
-rw-r--r--src/com/vaadin/terminal/gwt/server/JsonCodec.java46
-rw-r--r--src/com/vaadin/terminal/gwt/server/RpcManager.java33
-rw-r--r--src/com/vaadin/terminal/gwt/server/ServerRpcManager.java9
-rw-r--r--src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java2
-rw-r--r--src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java2
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java21
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java151
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java29
-rw-r--r--src/com/vaadin/ui/AbstractField.java8
-rw-r--r--src/com/vaadin/ui/Button.java18
-rw-r--r--src/com/vaadin/ui/Component.java2
-rw-r--r--src/com/vaadin/ui/Notification.java95
-rw-r--r--src/com/vaadin/ui/Root.java299
-rw-r--r--src/com/vaadin/ui/Table.java52
-rw-r--r--src/com/vaadin/ui/Window.java43
-rw-r--r--tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java100
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java2
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java2
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java2
-rw-r--r--tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java21
-rw-r--r--tests/testbench/com/vaadin/tests/TestForWindowOpen.java6
-rw-r--r--tests/testbench/com/vaadin/tests/TestForWindowing.java2
-rw-r--r--tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java8
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/beanitemcontainer/BeanItemContainerNullValues.java8
-rw-r--r--tests/testbench/com/vaadin/tests/components/button/ButtonTabIndex.java53
-rw-r--r--tests/testbench/com/vaadin/tests/components/notification/Notifications.java3
-rw-r--r--tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java3
-rw-r--r--tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.html77
-rw-r--r--tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java73
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/HeaderClick.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java4
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.html192
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.java38
-rw-r--r--tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java (renamed from src/com/vaadin/ui/HelloWorldExtension.java)9
-rw-r--r--tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java3
-rw-r--r--tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java9
-rw-r--r--tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java19
-rw-r--r--tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java4
-rw-r--r--tests/testbench/com/vaadin/tests/serialization/SerializerTest.java273
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/ComplexTestBean.java70
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java227
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java64
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/SimpleTestBean.java38
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/GreetAgainRpc.java (renamed from src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/GreetAgainRpc.java)2
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java (renamed from src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldExtensionConnector.java)8
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldRpc.java (renamed from src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldRpc.java)2
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldState.java (renamed from src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldState.java)2
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/server/SerializerTestExtension.java22
65 files changed, 1902 insertions, 474 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index 3da314a11e..84a8df5053 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -2119,11 +2119,11 @@ public class Application implements Terminal.ErrorListener, Serializable {
* @return the current application instance if available, otherwise
* <code>null</code>
*
- * @see #setCurrentApplication(Application)
+ * @see #setCurrent(Application)
*
* @since 7.0
*/
- public static Application getCurrentApplication() {
+ public static Application getCurrent() {
return currentApplication.get();
}
@@ -2139,12 +2139,12 @@ public class Application implements Terminal.ErrorListener, Serializable {
*
* @param application
*
- * @see #getCurrentApplication()
+ * @see #getCurrent()
* @see ThreadLocal
*
* @since 7.0
*/
- public static void setCurrentApplication(Application application) {
+ public static void setCurrent(Application application) {
currentApplication.set(application);
}
@@ -2188,7 +2188,7 @@ public class Application implements Terminal.ErrorListener, Serializable {
*/
public Root getRootForRequest(WrappedRequest request)
throws RootRequiresMoreInformationException {
- Root root = Root.getCurrentRoot();
+ Root root = Root.getCurrent();
if (root != null) {
return root;
}
@@ -2240,7 +2240,7 @@ public class Application implements Terminal.ErrorListener, Serializable {
}
// Set thread local here so it is available in init
- Root.setCurrentRoot(root);
+ Root.setCurrent(root);
if (!initedRoots.contains(rootId)) {
boolean initRequiresBrowserDetails = isRootPreserved()
diff --git a/src/com/vaadin/data/util/AbstractBeanContainer.java b/src/com/vaadin/data/util/AbstractBeanContainer.java
index bed3ca0450..300f92ea3a 100644
--- a/src/com/vaadin/data/util/AbstractBeanContainer.java
+++ b/src/com/vaadin/data/util/AbstractBeanContainer.java
@@ -8,6 +8,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import com.vaadin.data.Container;
@@ -247,8 +248,8 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
*/
@Override
@SuppressWarnings("unchecked")
- public Collection<IDTYPE> getItemIds() {
- return (Collection<IDTYPE>) super.getItemIds();
+ public List<IDTYPE> getItemIds() {
+ return (List<IDTYPE>) super.getItemIds();
}
/*
diff --git a/src/com/vaadin/data/util/AbstractInMemoryContainer.java b/src/com/vaadin/data/util/AbstractInMemoryContainer.java
index cc7f469c0c..795aabb419 100644
--- a/src/com/vaadin/data/util/AbstractInMemoryContainer.java
+++ b/src/com/vaadin/data/util/AbstractInMemoryContainer.java
@@ -165,8 +165,8 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
}
}
- public Collection<?> getItemIds() {
- return Collections.unmodifiableCollection(getVisibleItemIds());
+ public List<?> getItemIds() {
+ return Collections.unmodifiableList(getVisibleItemIds());
}
// Container.Ordered
diff --git a/src/com/vaadin/data/util/converter/ConverterUtil.java b/src/com/vaadin/data/util/converter/ConverterUtil.java
index 239baf6b6d..7011496ed7 100644
--- a/src/com/vaadin/data/util/converter/ConverterUtil.java
+++ b/src/com/vaadin/data/util/converter/ConverterUtil.java
@@ -14,7 +14,7 @@ public class ConverterUtil implements Serializable {
* Finds a converter that can convert from the given presentation type to
* the given model type and back. Uses the given application to find a
* {@link ConverterFactory} or, if application is null, uses the
- * {@link Application#getCurrentApplication()}.
+ * {@link Application#getCurrent()}.
*
* @param <PRESENTATIONTYPE>
* The presentation type
@@ -35,7 +35,7 @@ public class ConverterUtil implements Serializable {
Class<MODELTYPE> modelType, Application application) {
Converter<PRESENTATIONTYPE, MODELTYPE> converter = null;
if (application == null) {
- application = Application.getCurrentApplication();
+ application = Application.getCurrent();
}
if (application != null) {
@@ -120,8 +120,11 @@ public class ConverterUtil implements Serializable {
return null;
}
- // check that the value class is compatible with the model type
- if (modelType.isAssignableFrom(presentationValue.getClass())) {
+ if (modelType == null) {
+ // No model type, return original value
+ return (MODELTYPE) presentationValue;
+ } else if (modelType.isAssignableFrom(presentationValue.getClass())) {
+ // presentation type directly compatible with model type
return modelType.cast(presentationValue);
} else {
throw new Converter.ConversionException(
diff --git a/src/com/vaadin/navigator/Navigator.java b/src/com/vaadin/navigator/Navigator.java
index 387f1d4eae..2c340adaa2 100644
--- a/src/com/vaadin/navigator/Navigator.java
+++ b/src/com/vaadin/navigator/Navigator.java
@@ -1,9 +1,9 @@
+package com.vaadin.navigator;
+
/*
-@VaadinApache2LicenseForJavaFiles@
+ @VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.navigator;
-
import java.io.Serializable;
import java.util.Iterator;
import java.util.LinkedList;
@@ -16,7 +16,6 @@ import com.vaadin.terminal.Page.FragmentChangedListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Root;
/**
* Navigator utility that allows switching of views in a part of an application.
@@ -60,7 +59,7 @@ public class Navigator implements Serializable {
}
/**
- * Fragment manager using URI fragments of a Root to track views and enable
+ * Fragment manager using URI fragments of a Page to track views and enable
* listening to view changes.
*
* This class is mostly for internal use by Navigator, and is only public
@@ -73,10 +72,10 @@ public class Navigator implements Serializable {
/**
* Create a new URIFragmentManager and attach it to listen to URI
- * fragment changes of a {@link Root}.
+ * fragment changes of a {@link Page}.
*
- * @param root
- * root whose URI fragment to get and modify
+ * @param page
+ * page whose URI fragment to get and modify
* @param navigator
* {@link Navigator} to notify of fragment changes (using
* {@link Navigator#navigateTo(String)}
@@ -93,8 +92,7 @@ public class Navigator implements Serializable {
}
public void setFragment(String fragment) {
- // TODO ", false" ???
- page.setFragment(fragment);
+ page.setFragment(fragment, false);
}
public void fragmentChanged(FragmentChangedEvent event) {
@@ -272,7 +270,16 @@ public class Navigator implements Serializable {
/**
* Create a navigator that is tracking the active view using URI fragments.
*
- * @param root
+ * <p>
+ * After all {@link View}s and {@link ViewProvider}s have been registered,
+ * the application should trigger navigation to the current fragment using
+ * e.g.
+ *
+ * <pre>
+ * navigator.navigateTo(Page.getCurrent().getFragment());
+ * </pre>
+ *
+ * @param page
* whose URI fragments are used
* @param display
* where to display the views
@@ -287,7 +294,16 @@ public class Navigator implements Serializable {
* By default, a {@link SimpleViewDisplay} is used and can be obtained using
* {@link #getDisplay()}.
*
- * @param root
+ * <p>
+ * After all {@link View}s and {@link ViewProvider}s have been registered,
+ * the application should trigger navigation to the current fragment using
+ * e.g.
+ *
+ * <pre>
+ * navigator.navigateTo(Page.getCurrent().getFragment());
+ * </pre>
+ *
+ * @param page
* whose URI fragments are used
*/
public Navigator(Page page) {
@@ -299,9 +315,12 @@ public class Navigator implements Serializable {
* Create a navigator.
*
* When a custom fragment manager is not needed, use the constructor
- * {@link #Navigator(Root, ViewDisplay)} which uses a URI fragment based
+ * {@link #Navigator(Page, ViewDisplay)} which uses a URI fragment based
* fragment manager.
*
+ * Note that navigation to the initial view must be performed explicitly by
+ * the application after creating a Navigator using this constructor.
+ *
* @param fragmentManager
* fragment manager keeping track of the active view and enabling
* bookmarking and direct navigation
@@ -335,12 +354,13 @@ public class Navigator implements Serializable {
* view name and parameters
*/
public void navigateTo(String viewAndParameters) {
- String longestViewName = "";
+ String longestViewName = null;
View viewWithLongestName = null;
for (ViewProvider provider : providers) {
String viewName = provider.getViewName(viewAndParameters);
if (null != viewName
- && viewName.length() > longestViewName.length()) {
+ && (longestViewName == null || viewName.length() > longestViewName
+ .length())) {
View view = provider.getView(viewName);
if (null != view) {
longestViewName = viewName;
diff --git a/src/com/vaadin/terminal/AbstractErrorMessage.java b/src/com/vaadin/terminal/AbstractErrorMessage.java
index 1a625fc0e6..3f526f7339 100644
--- a/src/com/vaadin/terminal/AbstractErrorMessage.java
+++ b/src/com/vaadin/terminal/AbstractErrorMessage.java
@@ -4,6 +4,8 @@
package com.vaadin.terminal;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
@@ -156,7 +158,10 @@ public abstract class AbstractErrorMessage implements ErrorMessage {
}
return error;
} else {
- return new SystemError(t);
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ return new SystemError(sw.toString());
}
}
diff --git a/src/com/vaadin/terminal/CombinedRequest.java b/src/com/vaadin/terminal/CombinedRequest.java
index ccef6d8963..abf5e0412a 100644
--- a/src/com/vaadin/terminal/CombinedRequest.java
+++ b/src/com/vaadin/terminal/CombinedRequest.java
@@ -129,7 +129,7 @@ public class CombinedRequest implements WrappedRequest {
public WebBrowser getWebBrowser() {
WebApplicationContext context = (WebApplicationContext) Application
- .getCurrentApplication().getContext();
+ .getCurrent().getContext();
return context.getBrowser();
}
};
diff --git a/src/com/vaadin/terminal/Page.java b/src/com/vaadin/terminal/Page.java
index 65fa500d27..8ccb243a1e 100644
--- a/src/com/vaadin/terminal/Page.java
+++ b/src/com/vaadin/terminal/Page.java
@@ -603,26 +603,42 @@ public class Page implements Serializable {
* Shows a notification message.
*
* @see Notification
- * @see #showNotification(String)
- * @see #showNotification(String, int)
- * @see #showNotification(String, String)
- * @see #showNotification(String, String, int)
*
* @param notification
* The notification message to show
+ *
+ * @deprecated Use Notification.show(Page) instead.
*/
+ @Deprecated
public void showNotification(Notification notification) {
addNotification(notification);
}
+ /**
+ * Gets the Page to which the current root belongs. This is automatically
+ * defined when processing requests to the server. In other cases, (e.g.
+ * from background threads), the current root is not automatically defined.
+ *
+ * @see Root#getCurrent()
+ *
+ * @return the current page instance if available, otherwise
+ * <code>null</code>
+ */
public static Page getCurrent() {
- Root currentRoot = Root.getCurrentRoot();
+ Root currentRoot = Root.getCurrent();
if (currentRoot == null) {
return null;
}
return currentRoot.getPage();
}
+ /**
+ * Sets the page title. The page title is displayed by the browser e.g. as
+ * the title of the browser window or as the title of the tab.
+ *
+ * @param title
+ * the new page title to set
+ */
public void setTitle(String title) {
root.getRpcProxy(PageClientRpc.class).setTitle(title);
}
diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java b/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java
index 742594671f..ea130779ea 100644
--- a/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java
+++ b/src/com/vaadin/terminal/gwt/client/LayoutManagerIE8.java
@@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.RootPanel;
@@ -36,11 +37,12 @@ public class LayoutManagerIE8 extends LayoutManager {
@Override
protected void cleanMeasuredSizes() {
+ Document document = RootPanel.get().getElement().getOwnerDocument();
+
Iterator<Element> i = measuredSizes.keySet().iterator();
while (i.hasNext()) {
Element e = i.next();
- if (e.getOwnerDocument() != RootPanel.get().getElement()
- .getOwnerDocument()) {
+ if (e.getOwnerDocument() != document) {
i.remove();
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
index 1459d8ee7d..23a2c30cd0 100644
--- a/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
+++ b/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
@@ -52,9 +52,7 @@ public class JsonDecoder {
}
String baseTypeName = type.getBaseTypeName();
- if (baseTypeName.endsWith("[]")) {
- return decodeArray(type, (JSONArray) jsonValue, connection);
- } else if (Map.class.getName().equals(baseTypeName)
+ if (Map.class.getName().equals(baseTypeName)
|| HashMap.class.getName().equals(baseTypeName)) {
return decodeMap(type, jsonValue, connection);
} else if (List.class.getName().equals(baseTypeName)
@@ -78,6 +76,13 @@ public class JsonDecoder {
} else if (Boolean.class.getName().equals(baseTypeName)) {
// TODO handle properly
return Boolean.valueOf(String.valueOf(jsonValue));
+ } else if (Byte.class.getName().equals(baseTypeName)) {
+ // TODO handle properly
+ return Byte.valueOf(String.valueOf(jsonValue));
+ } else if (Character.class.getName().equals(baseTypeName)) {
+ // TODO handle properly
+ return Character.valueOf(((JSONString) jsonValue).stringValue()
+ .charAt(0));
} else if (Connector.class.getName().equals(baseTypeName)) {
return ConnectorMap.get(connection).getConnector(
((JSONString) jsonValue).stringValue());
@@ -180,16 +185,6 @@ public class JsonDecoder {
return map;
}
- private static Object[] decodeArray(Type type, JSONArray jsonArray,
- ApplicationConnection connection) {
- String arrayTypeName = type.getBaseTypeName();
- String chldTypeName = arrayTypeName.substring(0,
- arrayTypeName.length() - 2);
- List<Object> list = decodeList(new Type(chldTypeName, null), jsonArray,
- connection);
- return list.toArray(new Object[list.size()]);
- }
-
private static List<Object> decodeList(Type type, JSONArray jsonArray,
ApplicationConnection connection) {
List<Object> tokens = new ArrayList<Object>();
diff --git a/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java b/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
index cb7dbe5e72..925f0b6272 100644
--- a/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
+++ b/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
@@ -13,6 +13,7 @@ import java.util.Set;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONBoolean;
import com.google.gwt.json.client.JSONNull;
+import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
@@ -72,6 +73,10 @@ public class JsonEncoder {
return new JSONString((String) value);
} else if (value instanceof Boolean) {
return JSONBoolean.getInstance((Boolean) value);
+ } else if (value instanceof Byte) {
+ return new JSONNumber((Byte) value);
+ } else if (value instanceof Character) {
+ return new JSONString(String.valueOf(value));
} else if (value instanceof Object[]) {
return encodeObjectArray((Object[]) value, restrictToInternalTypes,
connection);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/button/ButtonState.java b/src/com/vaadin/terminal/gwt/client/ui/button/ButtonState.java
index fdc053b3ae..2daceea0e8 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/button/ButtonState.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/button/ButtonState.java
@@ -5,6 +5,7 @@
package com.vaadin.terminal.gwt.client.ui.button;
import com.vaadin.terminal.gwt.client.ComponentState;
+import com.vaadin.terminal.gwt.client.ui.TabIndexState;
import com.vaadin.ui.Button;
/**
@@ -14,10 +15,14 @@ import com.vaadin.ui.Button;
*
* @since 7.0
*/
-public class ButtonState extends ComponentState {
+public class ButtonState extends ComponentState implements TabIndexState {
private boolean disableOnClick = false;
private int clickShortcutKeyCode = 0;
/**
+ * The tab order number of this field.
+ */
+ private int tabIndex = 0;
+ /**
* If caption should be rendered in HTML
*/
private boolean htmlContentAllowed = false;
@@ -92,4 +97,22 @@ public class ButtonState extends ComponentState {
return htmlContentAllowed;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#getTabIndex()
+ */
+ public int getTabIndex() {
+ return tabIndex;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int)
+ */
+ public void setTabIndex(int tabIndex) {
+ this.tabIndex = tabIndex;
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index b7be6fd394..c2f887674a 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -540,7 +540,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
if (application == null) {
return;
}
- Application.setCurrentApplication(application);
+ Application.setCurrent(application);
/*
* Get or create an application context and an application
@@ -689,8 +689,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
}
} finally {
- Root.setCurrentRoot(null);
- Application.setCurrentApplication(null);
+ Root.setCurrent(null);
+ Application.setCurrent(null);
PortletSession session = request
.getPortletSession(false);
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
index 0e548f61c8..f7e46a7ca9 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
@@ -385,7 +385,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
if (application == null) {
return;
}
- Application.setCurrentApplication(application);
+ Application.setCurrent(application);
/*
* Get or create a WebApplicationContext and an ApplicationManager
@@ -431,7 +431,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
Root root = application.getRootForRequest(request);
if (root == null) {
throw new ServletException(ERROR_NO_ROOT_FOUND);
- }// Handles AJAX UIDL requests
+ }
+ // Handles AJAX UIDL requests
applicationManager.handleUidlRequest(request, response,
servletWrapper, root);
return;
@@ -477,8 +478,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
.onRequestEnd(request, response);
}
} finally {
- Root.setCurrentRoot(null);
- Application.setCurrentApplication(null);
+ Root.setCurrent(null);
+ Application.setCurrent(null);
HttpSession session = request.getSession(false);
if (session != null) {
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 797f8f756c..7cad8e3a33 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -71,6 +71,7 @@ import com.vaadin.terminal.gwt.client.communication.SharedState;
import com.vaadin.terminal.gwt.client.communication.UidlValue;
import com.vaadin.terminal.gwt.server.BootstrapHandler.BootstrapContext;
import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout;
+import com.vaadin.terminal.gwt.server.RpcManager.RpcInvocationException;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Component;
@@ -1530,8 +1531,18 @@ public abstract class AbstractCommunicationManager implements Serializable {
}
if (invocation instanceof ServerRpcMethodInvocation) {
- ServerRpcManager.applyInvocation(connector,
- (ServerRpcMethodInvocation) invocation);
+ try {
+ ServerRpcManager.applyInvocation(connector,
+ (ServerRpcMethodInvocation) invocation);
+ } catch (RpcInvocationException e) {
+ Throwable realException = e.getCause();
+ Component errorComponent = null;
+ if (connector instanceof Component) {
+ errorComponent = (Component) connector;
+ }
+ handleChangeVariablesError(root.getApplication(),
+ errorComponent, realException, null);
+ }
} else {
// All code below is for legacy variable changes
@@ -1581,8 +1592,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
* Parse a message burst from the client into a list of MethodInvocation
* instances.
*
- * @param root
- * The root for this request
+ * @param connectorTracker
+ * The ConnectorTracker used to lookup connectors
* @param burst
* message string (JSON)
* @return list of MethodInvocation to perform
@@ -1775,10 +1786,10 @@ public abstract class AbstractCommunicationManager implements Serializable {
* map from variable names to values
*/
private void handleChangeVariablesError(Application application,
- Component owner, Exception e, Map<String, Object> m) {
+ Component owner, Throwable t, Map<String, Object> m) {
boolean handled = false;
ChangeVariablesErrorEvent errorEvent = new ChangeVariablesErrorEvent(
- owner, e, m);
+ owner, t, m);
if (owner instanceof AbstractField) {
try {
@@ -2183,7 +2194,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
// if we do not yet have a currentRoot, it should be initialized
// shortly, and we should send the initial UIDL
- boolean sendUIDL = Root.getCurrentRoot() == null;
+ boolean sendUIDL = Root.getCurrent() == null;
try {
CombinedRequest combinedRequest = new CombinedRequest(request);
diff --git a/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java
index ae1fadd91b..69f033c8cd 100644
--- a/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java
+++ b/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java
@@ -83,7 +83,7 @@ public abstract class BootstrapHandler implements RequestHandler {
public Root getRoot() {
if (!rootFetched) {
- root = Root.getCurrentRoot();
+ root = Root.getCurrent();
rootFetched = true;
}
return root;
diff --git a/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/src/com/vaadin/terminal/gwt/server/JsonCodec.java
index 4b470f7215..d3a2ef56f8 100644
--- a/src/com/vaadin/terminal/gwt/server/JsonCodec.java
+++ b/src/com/vaadin/terminal/gwt/server/JsonCodec.java
@@ -8,6 +8,7 @@ import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.Serializable;
+import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
@@ -82,6 +83,10 @@ public class JsonCodec implements Serializable {
public static boolean isInternalType(Type type) {
if (type instanceof Class && ((Class<?>) type).isPrimitive()) {
+ if (type == byte.class || type == char.class) {
+ // Almost all primitive types are handled internally
+ return false;
+ }
// All primitive types are handled internally
return true;
} else if (type == UidlValue.class) {
@@ -125,6 +130,16 @@ public class JsonCodec implements Serializable {
// Try to decode object using fields
if (value == JSONObject.NULL) {
return null;
+ } else if (targetType == byte.class || targetType == Byte.class) {
+ return Byte.valueOf(String.valueOf(value));
+ } else if (targetType == char.class || targetType == Character.class) {
+ return Character.valueOf(String.valueOf(value).charAt(0));
+ } else if (targetType instanceof Class<?>
+ && ((Class<?>) targetType).isArray()) {
+ // Legacy Object[] and String[] handled elsewhere, this takes care
+ // of generic arrays
+ return decodeArray((Class<?>) targetType, (JSONArray) value,
+ connectorTracker);
} else if (targetType == JSONObject.class
|| targetType == JSONArray.class) {
return value;
@@ -134,6 +149,18 @@ public class JsonCodec implements Serializable {
}
}
+ private static Object decodeArray(Class<?> targetType, JSONArray value,
+ ConnectorTracker connectorTracker) throws JSONException {
+ Class<?> componentType = targetType.getComponentType();
+ Object array = Array.newInstance(componentType, value.length());
+ for (int i = 0; i < value.length(); i++) {
+ Object decodedValue = decodeInternalOrCustomType(componentType,
+ value.get(i), connectorTracker);
+ Array.set(array, i, decodedValue);
+ }
+ return array;
+ }
+
/**
* Decodes a value that is of an internal type.
* <p>
@@ -207,7 +234,7 @@ public class JsonCodec implements Serializable {
return connectorTracker.getConnector(stringValue);
}
- // Standard Java types
+ // Legacy types
if (JsonEncoder.VTYPE_STRING.equals(transportType)) {
return stringValue;
@@ -503,14 +530,17 @@ public class JsonCodec implements Serializable {
return value;
} else if (value instanceof Number) {
return value;
+ } else if (value instanceof Character) {
+ // Character is not a Number
+ return value;
} else if (value instanceof Collection) {
Collection<?> collection = (Collection<?>) value;
JSONArray jsonArray = encodeCollection(valueType, collection,
connectorTracker);
return jsonArray;
- } else if (value instanceof Object[]) {
- Object[] array = (Object[]) value;
- JSONArray jsonArray = encodeArrayContents(array, connectorTracker);
+ } else if (valueType instanceof Class<?>
+ && ((Class<?>) valueType).isArray()) {
+ JSONArray jsonArray = encodeArrayContents(value, connectorTracker);
return jsonArray;
} else if (value instanceof Map) {
Object jsonMap = encodeMap(valueType, (Map<?, ?>) value,
@@ -613,11 +643,13 @@ public class JsonCodec implements Serializable {
return e.name();
}
- private static JSONArray encodeArrayContents(Object[] array,
+ private static JSONArray encodeArrayContents(Object array,
ConnectorTracker connectorTracker) throws JSONException {
JSONArray jsonArray = new JSONArray();
- for (Object o : array) {
- jsonArray.put(encode(o, null, null, connectorTracker));
+ Class<?> componentType = array.getClass().getComponentType();
+ for (int i = 0; i < Array.getLength(array); i++) {
+ jsonArray.put(encode(Array.get(array, i), null, componentType,
+ connectorTracker));
}
return jsonArray;
}
diff --git a/src/com/vaadin/terminal/gwt/server/RpcManager.java b/src/com/vaadin/terminal/gwt/server/RpcManager.java
index d240ab8467..026c847e2b 100644
--- a/src/com/vaadin/terminal/gwt/server/RpcManager.java
+++ b/src/com/vaadin/terminal/gwt/server/RpcManager.java
@@ -13,5 +13,36 @@ import java.io.Serializable;
* @since 7.0
*/
public interface RpcManager extends Serializable {
- public void applyInvocation(ServerRpcMethodInvocation invocation);
+ public void applyInvocation(ServerRpcMethodInvocation invocation)
+ throws RpcInvocationException;
+
+ /**
+ * Wrapper exception for exceptions which occur during invocation of an RPC
+ * call
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0
+ *
+ */
+ public static class RpcInvocationException extends Exception {
+
+ public RpcInvocationException() {
+ super();
+ }
+
+ public RpcInvocationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public RpcInvocationException(String message) {
+ super(message);
+ }
+
+ public RpcInvocationException(Throwable cause) {
+ super(cause);
+ }
+
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java b/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java
index 07f83864c2..d9931a9610 100644
--- a/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java
+++ b/src/com/vaadin/terminal/gwt/server/ServerRpcManager.java
@@ -5,6 +5,7 @@
package com.vaadin.terminal.gwt.server;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -66,9 +67,10 @@ public class ServerRpcManager<T> implements RpcManager {
* non-null target of the RPC call
* @param invocation
* method invocation to perform
+ * @throws RpcInvocationException
*/
public static void applyInvocation(RpcTarget target,
- ServerRpcMethodInvocation invocation) {
+ ServerRpcMethodInvocation invocation) throws RpcInvocationException {
RpcManager manager = target.getRpcManager(invocation
.getInterfaceClass());
if (manager != null) {
@@ -109,7 +111,8 @@ public class ServerRpcManager<T> implements RpcManager {
* @param invocation
* method invocation to perform
*/
- public void applyInvocation(ServerRpcMethodInvocation invocation) {
+ public void applyInvocation(ServerRpcMethodInvocation invocation)
+ throws RpcInvocationException {
Method method = invocation.getMethod();
Class<?>[] parameterTypes = method.getParameterTypes();
Object[] args = new Object[parameterTypes.length];
@@ -125,7 +128,7 @@ public class ServerRpcManager<T> implements RpcManager {
try {
method.invoke(implementation, args);
} catch (Exception e) {
- throw new RuntimeException("Unable to invoke method "
+ throw new RpcInvocationException("Unable to invoke method "
+ invocation.getMethodName() + " in "
+ invocation.getInterfaceName(), e);
}
diff --git a/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java b/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java
index b6f1a192cb..0774a79990 100644
--- a/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java
+++ b/src/com/vaadin/terminal/gwt/server/WrappedHttpServletRequest.java
@@ -82,7 +82,7 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper
public WebBrowser getWebBrowser() {
WebApplicationContext context = (WebApplicationContext) Application
- .getCurrentApplication().getContext();
+ .getCurrent().getContext();
return context.getBrowser();
}
};
diff --git a/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java b/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java
index 3838695aa3..85d8d5c69c 100644
--- a/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java
+++ b/src/com/vaadin/terminal/gwt/server/WrappedPortletRequest.java
@@ -130,7 +130,7 @@ public class WrappedPortletRequest implements WrappedRequest {
public WebBrowser getWebBrowser() {
PortletApplicationContext2 context = (PortletApplicationContext2) Application
- .getCurrentApplication().getContext();
+ .getCurrent().getContext();
return context.getBrowser();
}
};
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java
index ba3dcd85b9..b1d69b178b 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java
@@ -146,8 +146,8 @@ public class GeneratedRpcMethodProviderGenerator extends Generator {
if (i != 0) {
sourceWriter.print(", ");
}
- sourceWriter.print("("
- + parameterType.getQualifiedSourceName()
+ String parameterTypeName = getBoxedTypeName(parameterType);
+ sourceWriter.print("(" + parameterTypeName
+ ") parameters[" + i + "]");
}
sourceWriter.println(");");
@@ -179,13 +179,7 @@ public class GeneratedRpcMethodProviderGenerator extends Generator {
}
public static void writeTypeCreator(SourceWriter sourceWriter, JType type) {
- String typeName;
- if (type.isPrimitive() != null) {
- // Used boxed types for primitives
- typeName = type.isPrimitive().getQualifiedBoxedSourceName();
- } else {
- typeName = type.getErasedType().getQualifiedBinaryName();
- }
+ String typeName = getBoxedTypeName(type);
sourceWriter.print("new Type(\"" + typeName + "\", ");
JParameterizedType parameterized = type.isParameterized();
if (parameterized != null) {
@@ -202,6 +196,15 @@ public class GeneratedRpcMethodProviderGenerator extends Generator {
sourceWriter.print(")");
}
+ public static String getBoxedTypeName(JType type) {
+ if (type.isPrimitive() != null) {
+ // Used boxed types for primitives
+ return type.isPrimitive().getQualifiedBoxedSourceName();
+ } else {
+ return type.getErasedType().getQualifiedSourceName();
+ }
+ }
+
private String getInvokeMethodName(JClassType type) {
return "invoke" + type.getQualifiedSourceName().replaceAll("\\.", "_");
}
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
index c32b54ff1c..1951f8ba40 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
@@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.widgetsetutils;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -16,13 +15,15 @@ import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.TreeLogger.Type;
import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JArrayType;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JEnumConstant;
import com.google.gwt.core.ext.typeinfo.JEnumType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
import com.google.gwt.core.ext.typeinfo.JType;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.core.ext.typeinfo.TypeOracleException;
+import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
@@ -46,26 +47,32 @@ import com.vaadin.terminal.gwt.client.communication.SerializerMap;
public class SerializerGenerator extends Generator {
private static final String SUBTYPE_SEPARATOR = "___";
- private static String beanSerializerPackageName = SerializerMap.class
+ private static String serializerPackageName = SerializerMap.class
.getPackage().getName();
@Override
public String generate(TreeLogger logger, GeneratorContext context,
- String beanTypeName) throws UnableToCompleteException {
- JClassType beanType = context.getTypeOracle().findType(beanTypeName);
- String beanSerializerClassName = getSerializerSimpleClassName(beanType);
+ String typeName) throws UnableToCompleteException {
+ JClassType type;
+ try {
+ type = (JClassType) context.getTypeOracle().parse(typeName);
+ } catch (TypeOracleException e1) {
+ logger.log(Type.ERROR, "Could not find type " + typeName, e1);
+ throw new UnableToCompleteException();
+ }
+ String serializerClassName = getSerializerSimpleClassName(type);
try {
// Generate class source code
- generateClass(logger, context, beanType, beanSerializerPackageName,
- beanSerializerClassName);
+ generateClass(logger, context, type, serializerPackageName,
+ serializerClassName);
} catch (Exception e) {
logger.log(TreeLogger.ERROR, "SerializerGenerator failed for "
- + beanType.getQualifiedSourceName(), e);
+ + type.getQualifiedSourceName(), e);
throw new UnableToCompleteException();
}
// return the fully qualifed name of the class generated
- return getFullyQualifiedSerializerClassName(beanType);
+ return getFullyQualifiedSerializerClassName(type);
}
/**
@@ -75,7 +82,7 @@ public class SerializerGenerator extends Generator {
* Logger object
* @param context
* Generator context
- * @param beanType
+ * @param type
* @param beanTypeName
* bean type for which the serializer is to be generated
* @param beanSerializerTypeName
@@ -83,7 +90,7 @@ public class SerializerGenerator extends Generator {
* @throws UnableToCompleteException
*/
private void generateClass(TreeLogger logger, GeneratorContext context,
- JClassType beanType, String serializerPackageName,
+ JClassType type, String serializerPackageName,
String serializerClassName) throws UnableToCompleteException {
// get print writer that receives the source code
PrintWriter printWriter = null;
@@ -94,13 +101,12 @@ public class SerializerGenerator extends Generator {
if (printWriter == null) {
return;
}
- boolean isEnum = (beanType.isEnum() != null);
+ boolean isEnum = (type.isEnum() != null);
+ boolean isArray = (type.isArray() != null);
- Date date = new Date();
- TypeOracle typeOracle = context.getTypeOracle();
- String beanQualifiedSourceName = beanType.getQualifiedSourceName();
+ String qualifiedSourceName = type.getQualifiedSourceName();
logger.log(Type.DEBUG, "Processing serializable type "
- + beanQualifiedSourceName + "...");
+ + qualifiedSourceName + "...");
// init composer, set class properties, create source writer
ClassSourceFileComposerFactory composer = null;
@@ -115,12 +121,12 @@ public class SerializerGenerator extends Generator {
composer.addImport(JsonDecoder.class.getName());
// composer.addImport(VaadinSerializer.class.getName());
- if (isEnum) {
+ if (isEnum || isArray) {
composer.addImplementedInterface(JSONSerializer.class.getName()
- + "<" + beanQualifiedSourceName + ">");
+ + "<" + qualifiedSourceName + ">");
} else {
composer.addImplementedInterface(DiffJSONSerializer.class.getName()
- + "<" + beanQualifiedSourceName + ">");
+ + "<" + qualifiedSourceName + ">");
}
SourceWriter sourceWriter = composer.createSourceWriter(context,
@@ -132,17 +138,19 @@ public class SerializerGenerator extends Generator {
// public JSONValue serialize(Object value,
// ApplicationConnection connection) {
sourceWriter.println("public " + JSONValue.class.getName()
- + " serialize(" + beanQualifiedSourceName + " value, "
+ + " serialize(" + qualifiedSourceName + " value, "
+ ApplicationConnection.class.getName() + " connection) {");
sourceWriter.indent();
// MouseEventDetails castedValue = (MouseEventDetails) value;
- sourceWriter.println(beanQualifiedSourceName + " castedValue = ("
- + beanQualifiedSourceName + ") value;");
+ sourceWriter.println(qualifiedSourceName + " castedValue = ("
+ + qualifiedSourceName + ") value;");
if (isEnum) {
- writeEnumSerializer(logger, sourceWriter, beanType);
+ writeEnumSerializer(logger, sourceWriter, type);
+ } else if (isArray) {
+ writeArraySerializer(logger, sourceWriter, type.isArray());
} else {
- writeBeanSerializer(logger, sourceWriter, beanType);
+ writeBeanSerializer(logger, sourceWriter, type);
}
// }
sourceWriter.outdent();
@@ -152,14 +160,14 @@ public class SerializerGenerator extends Generator {
// Updater
// public void update(T target, Type type, JSONValue jsonValue,
// ApplicationConnection connection);
- if (!isEnum) {
- sourceWriter.println("public void update("
- + beanQualifiedSourceName + " target, Type type, "
- + JSONValue.class.getName() + " jsonValue, "
- + ApplicationConnection.class.getName() + " connection) {");
+ if (!isEnum && !isArray) {
+ sourceWriter.println("public void update(" + qualifiedSourceName
+ + " target, Type type, " + JSONValue.class.getName()
+ + " jsonValue, " + ApplicationConnection.class.getName()
+ + " connection) {");
sourceWriter.indent();
- writeBeanDeserializer(logger, sourceWriter, beanType);
+ writeBeanDeserializer(logger, sourceWriter, type);
sourceWriter.outdent();
sourceWriter.println("}");
@@ -168,18 +176,19 @@ public class SerializerGenerator extends Generator {
// Deserializer
// T deserialize(Type type, JSONValue jsonValue, ApplicationConnection
// connection);
- sourceWriter.println("public " + beanQualifiedSourceName
+ sourceWriter.println("public " + qualifiedSourceName
+ " deserialize(Type type, " + JSONValue.class.getName()
+ " jsonValue, " + ApplicationConnection.class.getName()
+ " connection) {");
sourceWriter.indent();
if (isEnum) {
- writeEnumDeserializer(logger, sourceWriter, beanType.isEnum());
+ writeEnumDeserializer(logger, sourceWriter, type.isEnum());
+ } else if (isArray) {
+ writeArrayDeserializer(logger, sourceWriter, type.isArray());
} else {
- sourceWriter.println(beanQualifiedSourceName
- + " target = GWT.create(" + beanQualifiedSourceName
- + ".class);");
+ sourceWriter.println(qualifiedSourceName + " target = GWT.create("
+ + qualifiedSourceName + ".class);");
sourceWriter
.println("update(target, type, jsonValue, connection);");
// return target;
@@ -195,7 +204,7 @@ public class SerializerGenerator extends Generator {
// commit generated class
context.commit(logger, printWriter);
logger.log(TreeLogger.INFO, "Generated Serializer class "
- + getFullyQualifiedSerializerClassName(beanType));
+ + getFullyQualifiedSerializerClassName(type));
}
private void writeEnumDeserializer(TreeLogger logger,
@@ -214,6 +223,43 @@ public class SerializerGenerator extends Generator {
sourceWriter.println("return null;");
}
+ private void writeArrayDeserializer(TreeLogger logger,
+ SourceWriter sourceWriter, JArrayType type) {
+ JType leafType = type.getLeafType();
+ int rank = type.getRank();
+
+ sourceWriter.println(JSONArray.class.getName()
+ + " jsonArray = jsonValue.isArray();");
+
+ // Type value = new Type[jsonArray.size()][][];
+ sourceWriter.print(type.getQualifiedSourceName() + " value = new "
+ + leafType.getQualifiedSourceName() + "[jsonArray.size()]");
+ for (int i = 1; i < rank; i++) {
+ sourceWriter.print("[]");
+ }
+ sourceWriter.println(";");
+
+ sourceWriter.println("for(int i = 0 ; i < value.length; i++) {");
+ sourceWriter.indent();
+
+ JType componentType = type.getComponentType();
+
+ sourceWriter.print("value[i] = ("
+ + GeneratedRpcMethodProviderGenerator
+ .getBoxedTypeName(componentType) + ") "
+ + JsonDecoder.class.getName() + ".decodeValue(");
+ GeneratedRpcMethodProviderGenerator.writeTypeCreator(sourceWriter,
+ componentType);
+ sourceWriter.print(", jsonArray.get(i), null, connection)");
+
+ sourceWriter.println(";");
+
+ sourceWriter.outdent();
+ sourceWriter.println("}");
+
+ sourceWriter.println("return value;");
+ }
+
private void writeBeanDeserializer(TreeLogger logger,
SourceWriter sourceWriter, JClassType beanType) {
String beanQualifiedSourceName = beanType.getQualifiedSourceName();
@@ -281,6 +327,23 @@ public class SerializerGenerator extends Generator {
+ "(castedValue.name());");
}
+ private void writeArraySerializer(TreeLogger logger,
+ SourceWriter sourceWriter, JArrayType array) {
+ sourceWriter.println(JSONArray.class.getName() + " values = new "
+ + JSONArray.class.getName() + "();");
+ JType componentType = array.getComponentType();
+ // JPrimitiveType primitive = componentType.isPrimitive();
+ sourceWriter.println("for (int i = 0; i < castedValue.length; i++) {");
+ sourceWriter.indent();
+ sourceWriter.print("values.set(i, ");
+ sourceWriter.print(JsonEncoder.class.getName()
+ + ".encode(castedValue[i], false, connection)");
+ sourceWriter.println(");");
+ sourceWriter.outdent();
+ sourceWriter.println("}");
+ sourceWriter.println("return values;");
+ }
+
private void writeBeanSerializer(TreeLogger logger,
SourceWriter sourceWriter, JClassType beanType)
throws UnableToCompleteException {
@@ -373,10 +436,15 @@ public class SerializerGenerator extends Generator {
return getSimpleClassName(beanType) + "_Serializer";
}
- private static String getSimpleClassName(JClassType type) {
- if (type.isMemberType()) {
+ private static String getSimpleClassName(JType type) {
+ JArrayType arrayType = type.isArray();
+ if (arrayType != null) {
+ return "Array" + getSimpleClassName(arrayType.getComponentType());
+ }
+ JClassType classType = type.isClass();
+ if (classType != null && classType.isMemberType()) {
// Assumed to be static sub class
- String baseName = getSimpleClassName(type.getEnclosingType());
+ String baseName = getSimpleClassName(classType.getEnclosingType());
String name = baseName + SUBTYPE_SEPARATOR
+ type.getSimpleSourceName();
return name;
@@ -385,7 +453,6 @@ public class SerializerGenerator extends Generator {
}
public static String getFullyQualifiedSerializerClassName(JClassType type) {
- return beanSerializerPackageName + "."
- + getSerializerSimpleClassName(type);
+ return serializerPackageName + "." + getSerializerSimpleClassName(type);
}
}
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
index 2688775435..5e151323a0 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
@@ -17,6 +17,7 @@ import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.TreeLogger.Type;
import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JArrayType;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JParameterizedType;
@@ -96,6 +97,10 @@ public class SerializerMapGenerator extends Generator {
JClassType javaSerializable = typeOracle.findType(Serializable.class
.getName());
for (JClassType type : typesNeedingSerializers) {
+ if (type.isArray() != null) {
+ // Don't check for arrays
+ continue;
+ }
boolean serializable = type.isAssignableTo(javaSerializable);
if (!serializable) {
logger.log(
@@ -166,8 +171,15 @@ public class SerializerMapGenerator extends Generator {
// TODO cache serializer instances in a map
for (JClassType type : typesNeedingSerializers) {
- sourceWriter.println("if (type.equals(\""
- + type.getQualifiedBinaryName() + "\")) {");
+ sourceWriter.print("if (type.equals(\""
+ + type.getQualifiedSourceName() + "\")");
+ if (type instanceof JArrayType) {
+ // Also add binary name to support encoding based on
+ // object.getClass().getName()
+ sourceWriter.print("||type.equals(\"" + type.getJNISignature()
+ + "\")");
+ }
+ sourceWriter.println(") {");
sourceWriter.indent();
String serializerName = SerializerGenerator
.getFullyQualifiedSerializerClassName(type);
@@ -277,6 +289,14 @@ public class SerializerMapGenerator extends Generator {
serializableTypes.add(typeClass);
findSubTypesNeedingSerializers(typeClass, serializableTypes);
}
+
+ // Generate (n-1)-dimensional array serializer for n-dimensional array
+ JArrayType arrayType = type.isArray();
+ if (arrayType != null) {
+ serializableTypes.add(arrayType);
+ addTypeIfNeeded(serializableTypes, arrayType.getComponentType());
+ }
+
}
Set<Class<?>> frameworkHandledTypes = new HashSet<Class<?>>();
@@ -293,15 +313,14 @@ public class SerializerMapGenerator extends Generator {
frameworkHandledTypes.add(Map.class);
frameworkHandledTypes.add(List.class);
frameworkHandledTypes.add(Set.class);
+ frameworkHandledTypes.add(Byte.class);
+ frameworkHandledTypes.add(Character.class);
}
private boolean serializationHandledByFramework(JType setterType) {
// Some types are handled by the framework at the moment. See #8449
// This method should be removed at some point.
- if (setterType.isArray() != null) {
- return true;
- }
if (setterType.isPrimitive() != null) {
return true;
}
diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java
index 21ca01f592..ce62fb43ed 100644
--- a/src/com/vaadin/ui/AbstractField.java
+++ b/src/com/vaadin/ui/AbstractField.java
@@ -591,7 +591,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
// Commits the value to datasource
committingValueToDataSource = true;
getPropertyDataSource().setValue(
- convertToDataSource(newFieldValue));
+ convertToModel(newFieldValue));
// The buffer is now unmodified
setModified(false);
@@ -792,13 +792,15 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* if there is no converter and the type is not compatible with
* the data source type.
*/
- private Object convertToDataSource(T fieldValue)
+ private Object convertToModel(T fieldValue)
throws Converter.ConversionException {
try {
Class<?> modelType = null;
Property pd = getPropertyDataSource();
if (pd != null) {
modelType = pd.getType();
+ } else if (getConverter() != null) {
+ modelType = getConverter().getModelType();
}
return ConverterUtil.convertToModel(fieldValue,
(Class<Object>) modelType, getConverter(), getLocale());
@@ -836,7 +838,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* @return The converted value that is compatible with the data source type
*/
public Object getConvertedValue() {
- return convertToDataSource(getFieldValue());
+ return convertToModel(getFieldValue());
}
/**
diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java
index 8e504d828b..0abc50f26f 100644
--- a/src/com/vaadin/ui/Button.java
+++ b/src/com/vaadin/ui/Button.java
@@ -357,8 +357,6 @@ public class Button extends AbstractComponent implements
protected ClickShortcut clickShortcut;
- private int tabIndex = 0;
-
/**
* Makes it possible to invoke a click on this button by pressing the given
* {@link KeyCode} and (optional) {@link ModifierKey}s.<br/>
@@ -471,13 +469,23 @@ public class Button extends AbstractComponent implements
requestRepaint();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Component.Focusable#getTabIndex()
+ */
public int getTabIndex() {
- return tabIndex;
+ return getState().getTabIndex();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Component.Focusable#setTabIndex(int)
+ */
public void setTabIndex(int tabIndex) {
- this.tabIndex = tabIndex;
-
+ getState().setTabIndex(tabIndex);
+ requestRepaint();
}
@Override
diff --git a/src/com/vaadin/ui/Component.java b/src/com/vaadin/ui/Component.java
index 2394d0f307..81e0319880 100644
--- a/src/com/vaadin/ui/Component.java
+++ b/src/com/vaadin/ui/Component.java
@@ -520,7 +520,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
* <p>
* Getting a null value is often a problem in constructors of regular
* components and in the initializers of custom composite components. A
- * standard workaround is to use {@link Application#getCurrentApplication()}
+ * standard workaround is to use {@link Application#getCurrent()}
* to retrieve the application instance that the current request relates to.
* Another way is to move the problematic initialization to
* {@link #attach()}, as described in the documentation of the method.
diff --git a/src/com/vaadin/ui/Notification.java b/src/com/vaadin/ui/Notification.java
index 075ab50196..0358283cb4 100644
--- a/src/com/vaadin/ui/Notification.java
+++ b/src/com/vaadin/ui/Notification.java
@@ -320,8 +320,15 @@ public class Notification implements Serializable {
return htmlContentAllowed;
}
- public void show() {
- Page.getCurrent().showNotification(this);
+ /**
+ * Shows this notification on a Page.
+ *
+ * @param page
+ * The page on which the notification should be shown
+ */
+ public void show(Page page) {
+ // TODO Can avoid deprecated API when Notification extends Extension
+ page.showNotification(this);
}
/**
@@ -331,14 +338,14 @@ public class Notification implements Serializable {
* Care should be taken to to avoid XSS vulnerabilities as the caption is
* rendered as html.
*
- * @see #showNotification(Notification)
- * @see Notification
+ * @see #Notification(String)
+ * @see #show(Page)
*
* @param caption
* The message
*/
public static void show(String caption) {
- new Notification(caption).show();
+ new Notification(caption).show(Page.getCurrent());
}
/**
@@ -350,8 +357,8 @@ public class Notification implements Serializable {
* Care should be taken to to avoid XSS vulnerabilities as the caption is
* rendered as html.
*
- * @see #showNotification(Notification)
- * @see Notification
+ * @see #Notification(String, int)
+ * @see #show(Page)
*
* @param caption
* The message
@@ -359,78 +366,6 @@ public class Notification implements Serializable {
* The message type
*/
public static void show(String caption, int type) {
- new Notification(caption, type).show();
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description on the middle of the current page. The message automatically
- * disappears ("humanized message").
- *
- * Care should be taken to to avoid XSS vulnerabilities as the caption and
- * description are rendered as html.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The caption of the message
- * @param description
- * The message description
- *
- */
- public static void show(String caption, String description) {
- new Notification(caption, description).show();
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description. The position and behavior of the message depends on the
- * type, which is one of the basic types defined in {@link Notification},
- * for instance Notification.TYPE_WARNING_MESSAGE.
- *
- * Care should be taken to to avoid XSS vulnerabilities as the caption and
- * description are rendered as html.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The caption of the message
- * @param description
- * The message description
- * @param type
- * The message type
- */
- public static void show(String caption, String description, int type) {
-
- new Notification(caption, description, type).show();
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description. The position and behavior of the message depends on the
- * type, which is one of the basic types defined in {@link Notification},
- * for instance Notification.TYPE_WARNING_MESSAGE.
- *
- * Care should be taken to avoid XSS vulnerabilities if html content is
- * allowed.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The message caption
- * @param description
- * The message description
- * @param type
- * The type of message
- * @param htmlContentAllowed
- * Whether html in the caption and description should be
- * displayed as html or as plain text
- */
- public static void show(String caption, String description, int type,
- boolean htmlContentAllowed) {
- new Notification(caption, description, type, htmlContentAllowed).show();
+ new Notification(caption, type).show(Page.getCurrent());
}
} \ No newline at end of file
diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java
index 64bfaf57a5..7ae687be79 100644
--- a/src/com/vaadin/ui/Root.java
+++ b/src/com/vaadin/ui/Root.java
@@ -338,152 +338,6 @@ public abstract class Root extends AbstractComponentContainer implements
}
/**
- * Shows a notification message on the middle of the root. The message
- * automatically disappears ("humanized message").
- *
- * Care should be taken to to avoid XSS vulnerabilities as the caption
- * is rendered as html.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The message
- *
- * @deprecated As of 7.0, use Notification.show instead
- */
- @Deprecated
- public void showNotification(String caption) {
- getPage().showNotification(new Notification(caption));
- }
-
- /**
- * Shows a notification message the root. The position and behavior of
- * the message depends on the type, which is one of the basic types
- * defined in {@link Notification}, for instance
- * Notification.TYPE_WARNING_MESSAGE.
- *
- * Care should be taken to to avoid XSS vulnerabilities as the caption
- * is rendered as html.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The message
- * @param type
- * The message type
- *
- * @deprecated As of 7.0, use Notification.show instead
- */
- @Deprecated
- public void showNotification(String caption, int type) {
- getPage().showNotification(new Notification(caption, type));
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description on the middle of the root. The message automatically
- * disappears ("humanized message").
- *
- * Care should be taken to to avoid XSS vulnerabilities as the caption
- * and description are rendered as html.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The caption of the message
- * @param description
- * The message description
- *
- * @deprecated As of 7.0, use Notification.show instead
- */
- @Deprecated
- public void showNotification(String caption, String description) {
- getPage().showNotification(new Notification(caption, description));
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description. The position and behavior of the message depends on the
- * type, which is one of the basic types defined in {@link Notification}
- * , for instance Notification.TYPE_WARNING_MESSAGE.
- *
- * Care should be taken to to avoid XSS vulnerabilities as the caption
- * and description are rendered as html.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The caption of the message
- * @param description
- * The message description
- * @param type
- * The message type
- *
- * @deprecated As of 7.0, use Notification.show instead
- */
- @Deprecated
- public void showNotification(String caption, String description,
- int type) {
- getPage().showNotification(
- new Notification(caption, description, type));
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description. The position and behavior of the message depends on the
- * type, which is one of the basic types defined in {@link Notification}
- * , for instance Notification.TYPE_WARNING_MESSAGE.
- *
- * Care should be taken to avoid XSS vulnerabilities if html content is
- * allowed.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @param caption
- * The message caption
- * @param description
- * The message description
- * @param type
- * The type of message
- * @param htmlContentAllowed
- * Whether html in the caption and description should be
- * displayed as html or as plain text
- *
- * @deprecated As of 7.0, use Notification.show instead
- */
- @Deprecated
- public void showNotification(String caption, String description,
- int type, boolean htmlContentAllowed) {
- getPage().showNotification(
- new Notification(caption, description, type,
- htmlContentAllowed));
- }
-
- /**
- * Shows a notification message.
- *
- * @see Notification
- * @see #showNotification(String)
- * @see #showNotification(String, int)
- * @see #showNotification(String, String)
- * @see #showNotification(String, String, int)
- *
- * @param notification
- * The notification message to show
- *
- * @deprecated As of 7.0, use Notification.show instead
- */
- @Deprecated
- public void showNotification(Notification notification) {
- getPage().showNotification(notification);
- }
-
- /**
* Executes JavaScript in this window.
*
* <p>
@@ -1069,10 +923,10 @@ public abstract class Root extends AbstractComponentContainer implements
* @param root
* the root to register as the current root
*
- * @see #getCurrentRoot()
+ * @see #getCurrent()
* @see ThreadLocal
*/
- public static void setCurrentRoot(Root root) {
+ public static void setCurrent(Root root) {
currentRoot.set(root);
}
@@ -1084,9 +938,9 @@ public abstract class Root extends AbstractComponentContainer implements
* @return the current root instance if available, otherwise
* <code>null</code>
*
- * @see #setCurrentRoot(Root)
+ * @see #setCurrent(Root)
*/
- public static Root getCurrentRoot() {
+ public static Root getCurrent() {
return currentRoot.get();
}
@@ -1204,4 +1058,149 @@ public abstract class Root extends AbstractComponentContainer implements
"You can not set the title of a Root. To set the title of the HTML page, use Page.setTitle");
}
+ /**
+ * Shows a notification message on the middle of the root. The message
+ * automatically disappears ("humanized message").
+ *
+ * Care should be taken to to avoid XSS vulnerabilities as the caption is
+ * rendered as html.
+ *
+ * @see #showNotification(Notification)
+ * @see Notification
+ *
+ * @param caption
+ * The message
+ *
+ * @deprecated As of 7.0, use Notification.show instead
+ */
+ @Deprecated
+ public void showNotification(String caption) {
+ getPage().showNotification(new Notification(caption));
+ }
+
+ /**
+ * Shows a notification message the root. The position and behavior of the
+ * message depends on the type, which is one of the basic types defined in
+ * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE.
+ *
+ * Care should be taken to to avoid XSS vulnerabilities as the caption is
+ * rendered as html.
+ *
+ * @see #showNotification(Notification)
+ * @see Notification
+ *
+ * @param caption
+ * The message
+ * @param type
+ * The message type
+ *
+ * @deprecated As of 7.0, use Notification.show instead
+ */
+ @Deprecated
+ public void showNotification(String caption, int type) {
+ getPage().showNotification(new Notification(caption, type));
+ }
+
+ /**
+ * Shows a notification consisting of a bigger caption and a smaller
+ * description on the middle of the root. The message automatically
+ * disappears ("humanized message").
+ *
+ * Care should be taken to to avoid XSS vulnerabilities as the caption and
+ * description are rendered as html.
+ *
+ * @see #showNotification(Notification)
+ * @see Notification
+ *
+ * @param caption
+ * The caption of the message
+ * @param description
+ * The message description
+ *
+ * @deprecated As of 7.0, use Notification.show instead
+ */
+ @Deprecated
+ public void showNotification(String caption, String description) {
+ getPage().showNotification(new Notification(caption, description));
+ }
+
+ /**
+ * Shows a notification consisting of a bigger caption and a smaller
+ * description. The position and behavior of the message depends on the
+ * type, which is one of the basic types defined in {@link Notification} ,
+ * for instance Notification.TYPE_WARNING_MESSAGE.
+ *
+ * Care should be taken to to avoid XSS vulnerabilities as the caption and
+ * description are rendered as html.
+ *
+ * @see #showNotification(Notification)
+ * @see Notification
+ *
+ * @param caption
+ * The caption of the message
+ * @param description
+ * The message description
+ * @param type
+ * The message type
+ *
+ * @deprecated As of 7.0, use Notification.show instead
+ */
+ @Deprecated
+ public void showNotification(String caption, String description, int type) {
+ getPage()
+ .showNotification(new Notification(caption, description, type));
+ }
+
+ /**
+ * Shows a notification consisting of a bigger caption and a smaller
+ * description. The position and behavior of the message depends on the
+ * type, which is one of the basic types defined in {@link Notification} ,
+ * for instance Notification.TYPE_WARNING_MESSAGE.
+ *
+ * Care should be taken to avoid XSS vulnerabilities if html content is
+ * allowed.
+ *
+ * @see #showNotification(Notification)
+ * @see Notification
+ *
+ * @param caption
+ * The message caption
+ * @param description
+ * The message description
+ * @param type
+ * The type of message
+ * @param htmlContentAllowed
+ * Whether html in the caption and description should be
+ * displayed as html or as plain text
+ *
+ * @deprecated As of 7.0, use Notification.show instead
+ */
+ @Deprecated
+ public void showNotification(String caption, String description, int type,
+ boolean htmlContentAllowed) {
+ getPage()
+ .showNotification(
+ new Notification(caption, description, type,
+ htmlContentAllowed));
+ }
+
+ /**
+ * Shows a notification message.
+ *
+ * @see Notification
+ * @see #showNotification(String)
+ * @see #showNotification(String, int)
+ * @see #showNotification(String, String)
+ * @see #showNotification(String, String, int)
+ *
+ * @param notification
+ * The notification message to show
+ *
+ * @deprecated As of 7.0, use Notification.show instead
+ */
+ @Deprecated
+ public void showNotification(Notification notification) {
+ getPage().showNotification(notification);
+ }
+
}
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index b74de7e180..a1cc4f95fe 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -476,10 +476,9 @@ public class Table extends AbstractSelect implements Action.Container,
private Object sortContainerPropertyId = null;
/**
- * Is table sorting disabled alltogether; even if some of the properties
- * would be sortable.
+ * Is table sorting by the user enabled.
*/
- private boolean sortDisabled = false;
+ private boolean sortEnabled = true;
/**
* Number of rows explicitly requested by the client to be painted on next
@@ -2589,7 +2588,7 @@ public class Table extends AbstractSelect implements Action.Container,
clientNeedsContentRefresh = true;
}
- if (!sortDisabled) {
+ if (isSortEnabled()) {
// Sorting
boolean doSort = false;
if (variables.containsKey("sortcolumn")) {
@@ -4323,16 +4322,21 @@ public class Table extends AbstractSelect implements Action.Container,
/**
* Gets the container property IDs, which can be used to sort the item.
+ * <p>
+ * Note that the {@link #isSortEnabled()} state affects what this method
+ * returns. Disabling sorting causes this method to always return an empty
+ * collection.
+ * </p>
*
* @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds()
*/
public Collection<?> getSortableContainerPropertyIds() {
final Container c = getContainerDataSource();
- if (c instanceof Container.Sortable && !isSortDisabled()) {
+ if (c instanceof Container.Sortable && isSortEnabled()) {
return ((Container.Sortable) c).getSortableContainerPropertyIds();
} else {
- return new LinkedList<Object>();
+ return Collections.EMPTY_LIST;
}
}
@@ -4423,23 +4427,47 @@ public class Table extends AbstractSelect implements Action.Container,
* would support this.
*
* @return True iff sorting is disabled.
+ * @deprecated Use {@link #isSortEnabled()} instead
*/
+ @Deprecated
public boolean isSortDisabled() {
- return sortDisabled;
+ return !isSortEnabled();
}
/**
- * Disables the sorting altogether.
+ * Checks if sorting is enabled.
*
- * To disable sorting altogether, set to true. In this case no sortable
- * columns are given even in the case where datasource would support this.
+ * @return true if sorting by the user is allowed, false otherwise
+ */
+ public boolean isSortEnabled() {
+ return sortEnabled;
+ }
+
+ /**
+ * Disables the sorting by the user altogether.
*
* @param sortDisabled
* True iff sorting is disabled.
+ * @deprecated Use {@link #setSortEnabled(boolean)} instead
*/
+ @Deprecated
public void setSortDisabled(boolean sortDisabled) {
- if (this.sortDisabled != sortDisabled) {
- this.sortDisabled = sortDisabled;
+ setSortEnabled(!sortDisabled);
+ }
+
+ /**
+ * Enables or disables sorting.
+ * <p>
+ * Setting this to false disallows sorting by the user. It is still possible
+ * to call {@link #sort()}.
+ * </p>
+ *
+ * @param sortEnabled
+ * true to allow the user to sort the table, false to disallow it
+ */
+ public void setSortEnabled(boolean sortEnabled) {
+ if (this.sortEnabled != sortEnabled) {
+ this.sortEnabled = sortEnabled;
requestRepaint();
}
}
diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java
index 02556c9961..e24e62236f 100644
--- a/src/com/vaadin/ui/Window.java
+++ b/src/com/vaadin/ui/Window.java
@@ -8,7 +8,6 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Map;
-import com.vaadin.Application;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.BlurNotifier;
@@ -29,43 +28,25 @@ import com.vaadin.terminal.gwt.client.ui.window.WindowServerRpc;
import com.vaadin.terminal.gwt.client.ui.window.WindowState;
/**
- * A component that represents an application (browser native) window or a sub
- * window.
+ * A component that represents a floating popup window that can be added to a
+ * {@link Root}. A window is added to a {@code Root} using
+ * {@link Root#addWindow(Window)}. </p>
* <p>
- * If the window is a application window or a sub window depends on how it is
- * added to the application. Adding a {@code Window} to a {@code Window} using
- * {@link Window#addWindow(Window)} makes it a sub window and adding a
- * {@code Window} to the {@code Application} using
- * {@link Application#addWindow(Window)} makes it an application window.
+ * The contents of a window is set using {@link #setContent(ComponentContainer)}
+ * or by using the {@link #Window(String, ComponentContainer)} constructor. The
+ * contents can in turn contain other components. By default, a
+ * {@link VerticalLayout} is used as content.
* </p>
* <p>
- * An application window is the base of any view in a Vaadin application. All
- * applications contain a main application window (set using
- * {@link Application#setMainWindow(Window)} which is what is initially shown to
- * the user. The contents of a window is set using
- * {@link #setContent(ComponentContainer)}. The contents can in turn contain
- * other components. For multi-tab applications there is one window instance per
- * opened tab.
+ * A window can be positioned on the screen using absolute coordinates (pixels)
+ * or set to be centered using {@link #center()}
* </p>
* <p>
- * A sub window is floating popup style window that can be added to an
- * application window. Like the application window its content is set using
- * {@link #setContent(ComponentContainer)}. A sub window can be positioned on
- * the screen using absolute coordinates (pixels). The default content of the
- * Window is set to be suitable for application windows. For sub windows it
- * might be necessary to set the size of the content to work as expected.
+ * The caption is displayed in the window header.
* </p>
* <p>
- * Window caption is displayed in the browser title bar for application level
- * windows and in the window header for sub windows.
- * </p>
- * <p>
- * Certain methods in this class are only meaningful for sub windows and other
- * parts only for application windows. These are marked using <b>Sub window
- * only</b> and <b>Application window only</b> respectively in the javadoc.
- * </p>
- * <p>
- * Sub window is to be split into a separate component in Vaadin 7.
+ * In Vaadin versions prior to 7.0.0, Window was also used as application level
+ * windows. This function is now covered by the {@link Root} class.
* </p>
*
* @author Vaadin Ltd.
diff --git a/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java b/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java
new file mode 100644
index 0000000000..4bd9cf0cf7
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/data/converter/ConverterFactory.java
@@ -0,0 +1,100 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.data.converter;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import com.vaadin.Application;
+import com.vaadin.data.util.converter.Converter;
+import com.vaadin.data.util.converter.DefaultConverterFactory;
+import com.vaadin.ui.TextField;
+
+public class ConverterFactory extends TestCase {
+
+ public static class ConvertTo42 implements Converter<String, Integer> {
+
+ public Integer convertToModel(String value, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return 42;
+ }
+
+ public String convertToPresentation(Integer value, Locale locale)
+ throws com.vaadin.data.util.converter.Converter.ConversionException {
+ return "42";
+ }
+
+ public Class<Integer> getModelType() {
+ return Integer.class;
+ }
+
+ public Class<String> getPresentationType() {
+ return String.class;
+ }
+
+ }
+
+ public static class ConverterFactory42 extends DefaultConverterFactory {
+ @Override
+ public <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> createConverter(
+ Class<PRESENTATION> presentationType, Class<MODEL> modelType) {
+ if (modelType == Integer.class) {
+ return (Converter<PRESENTATION, MODEL>) new ConvertTo42();
+ }
+
+ return super.createConverter(presentationType, modelType);
+ }
+ }
+
+ public void testApplicationConverterFactoryInBackgroundThread() {
+ Application.setCurrent(null);
+ final Application appWithCustomIntegerConverter = new Application();
+ appWithCustomIntegerConverter
+ .setConverterFactory(new ConverterFactory42());
+
+ TextField tf = new TextField("", "123") {
+ @Override
+ public Application getApplication() {
+ return appWithCustomIntegerConverter;
+ };
+ };
+ tf.setConverter(Integer.class);
+ // The application converter always returns 42. Current application is
+ // null
+ assertEquals(42, tf.getConvertedValue());
+ }
+
+ public void testApplicationConverterFactoryForDetachedComponent() {
+ final Application appWithCustomIntegerConverter = new Application();
+ appWithCustomIntegerConverter
+ .setConverterFactory(new ConverterFactory42());
+ Application.setCurrent(appWithCustomIntegerConverter);
+
+ TextField tf = new TextField("", "123");
+ tf.setConverter(Integer.class);
+ // The application converter always returns 42. Current application is
+ // null
+ assertEquals(42, tf.getConvertedValue());
+ }
+
+ public void testApplicationConverterFactoryForDifferentThanCurrentApplication() {
+ final Application fieldAppWithCustomIntegerConverter = new Application();
+ fieldAppWithCustomIntegerConverter
+ .setConverterFactory(new ConverterFactory42());
+ Application.setCurrent(new Application());
+
+ TextField tf = new TextField("", "123") {
+ @Override
+ public Application getApplication() {
+ return fieldAppWithCustomIntegerConverter;
+ }
+ };
+ tf.setConverter(Integer.class);
+
+ // The application converter always returns 42. Application.getCurrent()
+ // should not be used
+ assertEquals(42, tf.getConvertedValue());
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
index 7305e022ee..446228583a 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
@@ -175,7 +175,7 @@ public class AbstractFieldValueConversions extends TestCase {
public void testNumberDoubleConverterChange() {
final Application a = new Application();
- Application.setCurrentApplication(a);
+ Application.setCurrent(a);
TextField tf = new TextField() {
@Override
public Application getApplication() {
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
index e39b5d6629..25430fc9a5 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java
@@ -27,7 +27,7 @@ public class DefaultConverterFactory extends TestCase {
public void testDefaultNumberConversion() {
Application app = new Application();
- Application.setCurrentApplication(app);
+ Application.setCurrent(app);
TextField tf = new TextField();
tf.setLocale(new Locale("en", "US"));
tf.setPropertyDataSource(new MethodProperty<Integer>(paulaBean,
diff --git a/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java b/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java
index e79bd84741..5ba15cac6c 100644
--- a/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java
+++ b/tests/server-side/com/vaadin/tests/server/component/label/LabelConverters.java
@@ -25,7 +25,7 @@ public class LabelConverters extends TestCase {
}
public void testIntegerDataSource() {
- Application.setCurrentApplication(new Application());
+ Application.setCurrent(new Application());
Label l = new Label("Foo");
Property ds = new MethodProperty<Integer>(Person.createTestPerson1(),
"age");
diff --git a/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java b/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java
index c63c0caf16..3adaff93ea 100644
--- a/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java
+++ b/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java
@@ -3,6 +3,7 @@
*/
package com.vaadin.tests;
+import com.vaadin.terminal.Page;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CustomComponent;
@@ -91,11 +92,13 @@ public class TestComponentAddAndRecursion extends CustomComponent {
public void buttonClick(ClickEvent event) {
try {
p3.addComponent(p2);
- Notification.show("ERROR", "This should have failed",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("ERROR", "This should have failed",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
} catch (Exception e) {
- Notification.show("OK", "threw, as expected",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("OK", "threw, as expected",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
}
}
@@ -108,11 +111,13 @@ public class TestComponentAddAndRecursion extends CustomComponent {
p.addComponent(p2);
try {
p3.addComponent(p);
- Notification.show("ERROR", "This should have failed",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("ERROR", "This should have failed",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
} catch (Exception e) {
- Notification.show("OK", "threw, as expected",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("OK", "threw, as expected",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
}
}
diff --git a/tests/testbench/com/vaadin/tests/TestForWindowOpen.java b/tests/testbench/com/vaadin/tests/TestForWindowOpen.java
index 76154f2419..75395f0d5c 100644
--- a/tests/testbench/com/vaadin/tests/TestForWindowOpen.java
+++ b/tests/testbench/com/vaadin/tests/TestForWindowOpen.java
@@ -24,7 +24,7 @@ public class TestForWindowOpen extends CustomComponent {
public void buttonClick(ClickEvent event) {
final ExternalResource r = new ExternalResource(
"http://www.google.com");
- Root.getCurrentRoot().getPage().open(r);
+ Root.getCurrent().getPage().open(r);
}
@@ -36,7 +36,7 @@ public class TestForWindowOpen extends CustomComponent {
public void buttonClick(ClickEvent event) {
final ExternalResource r = new ExternalResource(
"http://www.google.com");
- Root.getCurrentRoot().getPage().open(r, "mytarget");
+ Root.getCurrent().getPage().open(r, "mytarget");
}
@@ -48,7 +48,7 @@ public class TestForWindowOpen extends CustomComponent {
public void buttonClick(ClickEvent event) {
final ExternalResource r = new ExternalResource(
"http://www.google.com");
- Root.getCurrentRoot().getPage().open(r, "secondtarget");
+ Root.getCurrent().getPage().open(r, "secondtarget");
}
diff --git a/tests/testbench/com/vaadin/tests/TestForWindowing.java b/tests/testbench/com/vaadin/tests/TestForWindowing.java
index f97ea33d61..b9e14608f5 100644
--- a/tests/testbench/com/vaadin/tests/TestForWindowing.java
+++ b/tests/testbench/com/vaadin/tests/TestForWindowing.java
@@ -85,7 +85,7 @@ public class TestForWindowing extends CustomComponent {
w.addComponent(s);
- Root.getCurrentRoot().addWindow(w);
+ Root.getCurrent().addWindow(w);
}
diff --git a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java
index 68a0bb3805..fd65adf209 100644
--- a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java
+++ b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java
@@ -16,8 +16,8 @@ import com.vaadin.ui.Root;
public class ThreadLocalInstances extends AbstractTestApplication {
private static final Application staticInitApplication = Application
- .getCurrentApplication();
- private static final Root staticInitRoot = Root.getCurrentRoot();
+ .getCurrent();
+ private static final Root staticInitRoot = Root.getCurrent();
private final Root mainWindow = new Root() {
boolean paintReported = false;
@@ -92,8 +92,8 @@ public class ThreadLocalInstances extends AbstractTestApplication {
}
private void reportCurrentStatus(String phase) {
- reportStatus(phase, Application.getCurrentApplication(),
- Root.getCurrentRoot());
+ reportStatus(phase, Application.getCurrent(),
+ Root.getCurrent());
}
private void reportStatus(String phase, Application application, Root root) {
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java
index 72cbcd386e..875d2b1df8 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java
@@ -57,7 +57,7 @@ public abstract class AbstractTestRoot extends Root {
protected abstract Integer getTicketNumber();
protected WebBrowser getBrowser() {
- ApplicationContext context = Application.getCurrentApplication()
+ ApplicationContext context = Application.getCurrent()
.getContext();
if (context instanceof AbstractWebApplicationContext) {
AbstractWebApplicationContext webContext = (AbstractWebApplicationContext) context;
diff --git a/tests/testbench/com/vaadin/tests/components/beanitemcontainer/BeanItemContainerNullValues.java b/tests/testbench/com/vaadin/tests/components/beanitemcontainer/BeanItemContainerNullValues.java
index 9045d18940..f613a8b14f 100644
--- a/tests/testbench/com/vaadin/tests/components/beanitemcontainer/BeanItemContainerNullValues.java
+++ b/tests/testbench/com/vaadin/tests/components/beanitemcontainer/BeanItemContainerNullValues.java
@@ -30,11 +30,11 @@ public class BeanItemContainerNullValues extends TestBase {
Button b = new Button("Disable sorting", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- table.setSortDisabled(!table.isSortDisabled());
- if (table.isSortDisabled()) {
- event.getButton().setCaption("Enable sorting");
- } else {
+ table.setSortEnabled(!table.isSortEnabled());
+ if (table.isSortEnabled()) {
event.getButton().setCaption("Disable sorting");
+ } else {
+ event.getButton().setCaption("Enable sorting");
}
}
diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonTabIndex.java b/tests/testbench/com/vaadin/tests/components/button/ButtonTabIndex.java
new file mode 100644
index 0000000000..048e0698f3
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/button/ButtonTabIndex.java
@@ -0,0 +1,53 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.components.button;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.TextField;
+
+public class ButtonTabIndex extends TestBase {
+
+ @Override
+ protected void setup() {
+ TextField tf1 = new TextField("Tab index 0");
+ tf1.setTabIndex(0);
+ TextField tf2 = new TextField("Tab index -1, focused initially");
+ tf2.setTabIndex(-1);
+ tf2.focus();
+ addComponent(tf1);
+ addComponent(tf2);
+
+ addComponent(createButton(1));
+ addComponent(createButton(5));
+ addComponent(createNativeButton(3));
+ addComponent(createButton(4));
+ addComponent(createNativeButton(2));
+
+ }
+
+ private Button createButton(int i) {
+ Button b = new Button("Button with tab index " + i);
+ b.setTabIndex(i);
+ return b;
+ }
+
+ private NativeButton createNativeButton(int i) {
+ NativeButton b = new NativeButton("NativeButton with tab index " + i);
+ b.setTabIndex(i);
+ return b;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test for tab indexes for Button and NativeButton";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 9022;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
index a36fbe3121..5a158c8f03 100644
--- a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
+++ b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
@@ -1,5 +1,6 @@
package com.vaadin.tests.components.notification;
+import com.vaadin.terminal.Page;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -52,6 +53,6 @@ public class Notifications extends TestBase implements ClickListener {
public void buttonClick(ClickEvent event) {
Notification n = new Notification(tf.getValue(),
(Integer) type.getValue());
- n.show();
+ n.show(Page.getCurrent());
}
}
diff --git a/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java b/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
index a16b8edcde..8e42db57f3 100644
--- a/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
+++ b/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
@@ -1,5 +1,6 @@
package com.vaadin.tests.components.notification;
+import com.vaadin.terminal.Page;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -45,7 +46,7 @@ public class NotificationsHtmlAllowed extends TestBase implements ClickListener
public void buttonClick(ClickEvent event) {
Notification n = makeNotification();
- n.show();
+ n.show(Page.getCurrent());
}
private Notification makeNotification() {
diff --git a/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.html b/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.html
new file mode 100644
index 0000000000..bff19c4846
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.html
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.panel.PanelChangeContents?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VPanel[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>stats</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VPanel[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>companies</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[2]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VPanel[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>settings</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VPanel[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>stats</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VPanel[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>companies</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[2]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/VPanel[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>settings</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java b/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java
new file mode 100644
index 0000000000..4859b22932
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java
@@ -0,0 +1,73 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.components.panel;
+
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.tests.components.AbstractTestRoot;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+public class PanelChangeContents extends AbstractTestRoot implements
+ ClickListener {
+
+ VerticalLayout stats = new VerticalLayout();
+ VerticalLayout companies = new VerticalLayout();
+ VerticalLayout settings = new VerticalLayout();
+
+ Button statsButton = new Button("Stats", this);
+ Button companiesButton = new Button("Companies", this);
+ Button settingsButton = new Button("Settings", this);
+
+ private Panel panel;
+
+ @Override
+ protected void setup(WrappedRequest request) {
+ VerticalLayout content = new VerticalLayout();
+ setSizeFull();
+ HorizontalLayout buttons = new HorizontalLayout();
+ stats.addComponent(new Label("stats"));
+ companies.addComponent(new Label("companies"));
+ settings.addComponent(new Label("settings"));
+ buttons.addComponent(statsButton);
+ buttons.addComponent(companiesButton);
+ buttons.addComponent(settingsButton);
+ panel = new Panel();
+ panel.setSizeFull();
+ panel.setContent(stats);
+ content.addComponent(buttons);
+ content.addComponent(panel);
+ content.setMargin(true);
+ content.setSpacing(true);
+ content.setExpandRatio(panel, 1);
+ setContent(content);
+ }
+
+ public void buttonClick(ClickEvent event) {
+ if (event.getButton() == statsButton) {
+ panel.setContent(stats);
+ } else if (event.getButton() == companiesButton) {
+ panel.setContent(companies);
+ } else if (event.getButton() == settingsButton) {
+ panel.setContent(settings);
+ }
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8735;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/HeaderClick.java b/tests/testbench/com/vaadin/tests/components/table/HeaderClick.java
index 970618374e..d5debcfe16 100644
--- a/tests/testbench/com/vaadin/tests/components/table/HeaderClick.java
+++ b/tests/testbench/com/vaadin/tests/components/table/HeaderClick.java
@@ -45,7 +45,7 @@ public class HeaderClick extends TestBase {
CheckBox sortEnabledCheckbox = new CheckBox("Sortable");
sortEnabledCheckbox.setImmediate(true);
- sortEnabledCheckbox.setValue(!table.isSortDisabled());
+ sortEnabledCheckbox.setValue(table.isSortEnabled());
sortEnabledCheckbox.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
diff --git a/tests/testbench/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java b/tests/testbench/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java
index 091891043f..cd54e21395 100644
--- a/tests/testbench/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java
+++ b/tests/testbench/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java
@@ -93,10 +93,10 @@ public class HeaderFooterClickLeftRightMiddle extends TestBase {
CheckBox sortEnabledCheckbox = new CheckBox("Sortable");
sortEnabledCheckbox.setImmediate(true);
- sortEnabledCheckbox.setValue(!table.isSortDisabled());
+ sortEnabledCheckbox.setValue(table.isSortEnabled());
sortEnabledCheckbox.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- table.setSortDisabled(!(Boolean) event.getProperty().getValue());
+ table.setSortEnabled((Boolean) event.getProperty().getValue());
}
});
diff --git a/tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.html b/tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.html
new file mode 100644
index 0000000000..51f13af004
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.html
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.SortLabelsInTable?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>Text 0</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[0]</td>
+ <td>Label 0</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[14]/domChild[0]/domChild[0]</td>
+ <td>Text 14</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VLabel[0]</td>
+ <td>Label 14</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
+ <td>22,11</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>Text 0</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>Text 10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[14]/domChild[0]/domChild[0]</td>
+ <td>Text 4</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[0]</td>
+ <td>Label 0</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]/VLabel[0]</td>
+ <td>Label 10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[11]/VLabel[0]</td>
+ <td>Label 19</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VLabel[0]</td>
+ <td>Label 4</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
+ <td>14,3</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>Text 9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[8]/domChild[0]/domChild[0]</td>
+ <td>Text 19</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[14]/domChild[0]/domChild[0]</td>
+ <td>Text 13</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[0]</td>
+ <td>Label 9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[8]/VLabel[0]</td>
+ <td>Label 19</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VLabel[0]</td>
+ <td>Label 13</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[2]</td>
+ <td>28,13</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>Text 9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[8]/domChild[0]/domChild[0]</td>
+ <td>Text 19</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[14]/domChild[0]/domChild[0]</td>
+ <td>Text 13</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[0]</td>
+ <td>Label 9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[8]/VLabel[0]</td>
+ <td>Label 19</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VLabel[0]</td>
+ <td>Label 13</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[2]</td>
+ <td>26,9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>Text 0</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>Text 10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[14]/domChild[0]/domChild[0]</td>
+ <td>Text 4</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VLabel[0]</td>
+ <td>Label 0</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]/VLabel[0]</td>
+ <td>Label 10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[11]/VLabel[0]</td>
+ <td>Label 19</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableSortLabelsInTable::/VVerticalLayout[0]/VVerticalLayout[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[14]/VLabel[0]</td>
+ <td>Label 4</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.java b/tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.java
new file mode 100644
index 0000000000..d46b9bf01d
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/SortLabelsInTable.java
@@ -0,0 +1,38 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+public class SortLabelsInTable extends TestBase {
+
+ @Override
+ protected void setup() {
+ Table t = new Table("A table with a text column and a Label column");
+ t.addContainerProperty("text", String.class, null);
+ t.addContainerProperty("label", Label.class, null);
+
+ for (int i = 0; i < 20; i++) {
+ Item item = t.addItem("" + i);
+ item.getItemProperty("text").setValue("Text " + i);
+ item.getItemProperty("label").setValue(new Label("Label " + i));
+ }
+ addComponent(t);
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8845;
+ }
+
+}
diff --git a/src/com/vaadin/ui/HelloWorldExtension.java b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java
index e705954f2e..23b892be66 100644
--- a/src/com/vaadin/ui/HelloWorldExtension.java
+++ b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java
@@ -1,12 +1,13 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.ui;
+package com.vaadin.tests.extensions;
import com.vaadin.terminal.AbstractExtension;
-import com.vaadin.terminal.gwt.client.ui.helloworldfeature.GreetAgainRpc;
-import com.vaadin.terminal.gwt.client.ui.helloworldfeature.HelloWorldRpc;
-import com.vaadin.terminal.gwt.client.ui.helloworldfeature.HelloWorldState;
+import com.vaadin.tests.widgetset.client.helloworldfeature.GreetAgainRpc;
+import com.vaadin.tests.widgetset.client.helloworldfeature.HelloWorldRpc;
+import com.vaadin.tests.widgetset.client.helloworldfeature.HelloWorldState;
+import com.vaadin.ui.Notification;
public class HelloWorldExtension extends AbstractExtension {
diff --git a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java
index b56e05b2a0..8625ffd955 100644
--- a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java
+++ b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java
@@ -3,12 +3,13 @@
*/
package com.vaadin.tests.extensions;
+import com.vaadin.annotations.Widgetset;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestRoot;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HelloWorldExtension;
+@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
public class HelloWorldExtensionTest extends AbstractTestRoot {
@Override
diff --git a/tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java b/tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java
index 913ce8f54c..b4de4fd3da 100644
--- a/tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java
+++ b/tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java
@@ -109,11 +109,10 @@ public class JSR286PortletRoot extends Root {
tf.setEnabled((request.getPortletMode() == PortletMode.EDIT));
// Show notification about current mode and state
- Notification.show(
- "Portlet status",
- "Mode: " + request.getPortletMode() + " State: "
- + request.getWindowState(),
- Notification.TYPE_WARNING_MESSAGE);
+ new Notification("Portlet status", "Mode: "
+ + request.getPortletMode() + " State: "
+ + request.getWindowState(),
+ Notification.TYPE_WARNING_MESSAGE).show(getPage());
// Display current user info
Map<?, ?> uinfo = (Map<?, ?>) request
diff --git a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
index 8b7f498b0e..9397206f1e 100644
--- a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
+++ b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
@@ -9,6 +9,7 @@ import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.event.Action;
import com.vaadin.terminal.ExternalResource;
+import com.vaadin.terminal.Page;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.client.ui.label.ContentMode;
@@ -595,8 +596,8 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
Button show = new Button("Humanized Notification",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue());
-
+ new Notification(title.getValue(), message.getValue())
+ .show(Page.getCurrent());
}
});
l.addComponent(show);
@@ -604,8 +605,9 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
l.addComponent(new Label("Warning", ContentMode.XHTML));
show = new Button("Warning Notification", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue(),
- Notification.TYPE_WARNING_MESSAGE);
+ new Notification(title.getValue(), message.getValue(),
+ Notification.TYPE_WARNING_MESSAGE).show(Page
+ .getCurrent());
}
});
@@ -614,8 +616,8 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
l.addComponent(new Label("Error", ContentMode.XHTML));
show = new Button("Error Notification", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue(),
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification(title.getValue(), message.getValue(),
+ Notification.TYPE_ERROR_MESSAGE).show(Page.getCurrent());
}
});
@@ -624,8 +626,9 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
l.addComponent(new Label("Tray", ContentMode.XHTML));
show = new Button("Tray Notification", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue(),
- Notification.TYPE_TRAY_NOTIFICATION);
+ new Notification(title.getValue(), message.getValue(),
+ Notification.TYPE_TRAY_NOTIFICATION).show(Page
+ .getCurrent());
}
});
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java
index c6e609c5ee..b237666caa 100644
--- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java
+++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java
@@ -29,10 +29,10 @@ public class FindCurrentRootAndApplication extends Root {
helloButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
String msg = "Running in ";
- msg += Application.getCurrentApplication().isProductionMode() ? "production"
+ msg += Application.getCurrent().isProductionMode() ? "production"
: "debug";
msg += " mode in a Root with the caption "
- + Root.getCurrentRoot().getCaption();
+ + Root.getCurrent().getCaption();
Notification.show(msg);
}
diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java
new file mode 100644
index 0000000000..d0b672fbf9
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java
@@ -0,0 +1,273 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.serialization;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.terminal.gwt.client.Connector;
+import com.vaadin.tests.components.AbstractTestRoot;
+import com.vaadin.tests.util.Log;
+import com.vaadin.tests.widgetset.client.ComplexTestBean;
+import com.vaadin.tests.widgetset.client.SerializerTestRpc;
+import com.vaadin.tests.widgetset.client.SimpleTestBean;
+import com.vaadin.tests.widgetset.server.SerializerTestExtension;
+
+@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet")
+public class SerializerTest extends AbstractTestRoot {
+
+ private Log log = new Log(40);
+
+ @Override
+ protected void setup(WrappedRequest request) {
+ final SerializerTestExtension testExtension = new SerializerTestExtension();
+ addExtension(testExtension);
+ addComponent(log);
+
+ SerializerTestRpc rpc = testExtension
+ .getRpcProxy(SerializerTestRpc.class);
+ rpc.sendBoolean(true, Boolean.FALSE, new boolean[] { true, true, false,
+ true, false, false });
+ rpc.sendByte((byte) 5, Byte.valueOf((byte) -12), new byte[] { 3, 1, 2 });
+ rpc.sendChar('\u222b', Character.valueOf('å'), "aBcD".toCharArray());
+ rpc.sendInt(Integer.MAX_VALUE, Integer.valueOf(0), new int[] { 5, 7 });
+ rpc.sendLong(577431841358l, Long.valueOf(0), new long[] {
+ -57841235865l, 57 });
+ rpc.sendFloat(3.14159f, Float.valueOf(Math.nextUp(1)), new float[] {
+ 57, 0, -12 });
+ rpc.sendDouble(Math.PI, Double.valueOf(-Math.E), new double[] {
+ Double.MAX_VALUE, Double.MIN_VALUE });
+ rpc.sendString("This is a tesing string ‡");
+ rpc.sendConnector(this);
+ rpc.sendBean(
+ new ComplexTestBean(new SimpleTestBean(0),
+ new SimpleTestBean(1), Arrays.asList(
+ new SimpleTestBean(3), new SimpleTestBean(4)),
+ 5), new SimpleTestBean(6),
+ new SimpleTestBean[] { new SimpleTestBean(7) });
+ rpc.sendNull("Not null", null);
+ rpc.sendNestedArray(new int[][] { { 5 }, { 7 } },
+ new SimpleTestBean[][] { { new SimpleTestBean(4),
+ new SimpleTestBean(2) } });
+ rpc.sendList(Arrays.asList(5, 8, -234), Arrays.<Connector> asList(this,
+ testExtension), Arrays.asList(new SimpleTestBean(234),
+ new SimpleTestBean(-568)));
+ // Disabled because of #8861
+ // rpc.sendArrayList(
+ // Arrays.asList(new int[] { 1, 2 }, new int[] { 3, 4 }),
+ // Arrays.asList(new Integer[] { 5, 6 }, new Integer[] { 7, 8 }),
+ // Collections
+ // .singletonList(new SimpleTestBean[] { new SimpleTestBean(
+ // 7) }));
+ // Disabled because of #8861
+ // rpc.sendListArray(
+ // new List[] { Arrays.asList(1, 2), Arrays.asList(3, 4) },
+ // new List[] { Collections.singletonList(new SimpleTestBean(-1)) });
+ rpc.sendSet(new HashSet<Integer>(Arrays.asList(4, 7, 12)), Collections
+ .singleton((Connector) this), new HashSet<SimpleTestBean>(
+ Arrays.asList(new SimpleTestBean(1), new SimpleTestBean(2))));
+
+ rpc.sendMap(new HashMap<String, SimpleTestBean>() {
+ {
+ put("1", new SimpleTestBean(1));
+ put("2", new SimpleTestBean(2));
+ }
+ }, new HashMap<Connector, Boolean>() {
+ {
+ put(testExtension, true);
+ put(getRoot(), false);
+ }
+ }, new HashMap<Integer, Connector>() {
+ {
+ put(5, testExtension);
+ put(10, getRoot());
+ }
+ }, new HashMap<SimpleTestBean, SimpleTestBean>() {
+ {
+ put(new SimpleTestBean(5), new SimpleTestBean(-5));
+ put(new SimpleTestBean(-4), new SimpleTestBean(4));
+ }
+ });
+ rpc.sendWrappedGenerics(new HashMap<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>>() {
+ {
+ put(Collections.singleton(new SimpleTestBean(42)),
+ new HashMap<Integer, List<SimpleTestBean>>() {
+ {
+ put(1, Arrays.asList(new SimpleTestBean(1),
+ new SimpleTestBean(3)));
+ }
+ });
+ }
+ });
+
+ testExtension.registerRpc(new SerializerTestRpc() {
+ public void sendBoolean(boolean value, Boolean boxedValue,
+ boolean[] array) {
+ log.log("sendBoolean: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendByte(byte value, Byte boxedValue, byte[] array) {
+ log.log("sendByte: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendChar(char value, Character boxedValue, char[] array) {
+ log.log("sendChar: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendInt(int value, Integer boxedValue, int[] array) {
+ log.log("sendInt: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendLong(long value, Long boxedValue, long[] array) {
+ log.log("sendLong: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendFloat(float value, Float boxedValue, float[] array) {
+ log.log("sendFloat: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendDouble(double value, Double boxedValue,
+ double[] array) {
+ log.log("sendDouble: " + value + ", " + boxedValue + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendString(String value) {
+ log.log("sendString: " + value);
+ }
+
+ public void sendConnector(Connector connector) {
+ log.log("sendConnector: " + connector.getClass().getName());
+ }
+
+ public void sendBean(ComplexTestBean complexBean,
+ SimpleTestBean simpleBean, SimpleTestBean[] array) {
+ log.log("sendBean: " + complexBean + ", " + simpleBean + ", "
+ + Arrays.toString(array));
+ }
+
+ public void sendNull(String value1, String value2) {
+ log.log("sendNull: " + value1 + ", " + value2);
+ }
+
+ public void sendNestedArray(int[][] nestedIntArray,
+ SimpleTestBean[][] nestedBeanArray) {
+ log.log("sendNestedArray: "
+ + Arrays.deepToString(nestedIntArray) + ", "
+ + Arrays.deepToString(nestedBeanArray));
+ }
+
+ public void sendList(List<Integer> intList,
+ List<Connector> connectorList, List<SimpleTestBean> beanList) {
+ log.log("sendList: " + intList + ", "
+ + connectorCollectionToString(connectorList) + ", "
+ + beanList);
+ }
+
+ private String connectorCollectionToString(
+ Collection<Connector> collection) {
+ StringBuilder sb = new StringBuilder();
+
+ for (Connector connector : collection) {
+ if (sb.length() != 0) {
+ sb.append(", ");
+ }
+ sb.append(connector.getClass());
+ }
+
+ String string = sb.toString();
+ return string;
+ }
+
+ public void sendArrayList(List<int[]> primitiveArrayList,
+ List<Integer[]> objectArrayList,
+ List<SimpleTestBean[]> beanArrayList) {
+ log.log("sendArrayList: " + primitiveArrayList + ", "
+ + objectArrayList + ", " + beanArrayList);
+ }
+
+ public void sendListArray(List<Integer>[] objectListArray,
+ List<SimpleTestBean>[] beanListArray) {
+ log.log("sendArrayList: " + Arrays.toString(objectListArray)
+ + ", " + Arrays.toString(beanListArray));
+ }
+
+ public void sendSet(Set<Integer> intSet,
+ Set<Connector> connectorSet, Set<SimpleTestBean> beanSet) {
+ log.log("sendSet: " + intSet + ", "
+ + connectorCollectionToString(connectorSet) + ", "
+ + beanSet);
+ }
+
+ public void sendMap(Map<String, SimpleTestBean> stringMap,
+ Map<Connector, Boolean> connectorMap,
+ Map<Integer, Connector> intMap,
+ Map<SimpleTestBean, SimpleTestBean> beanMap) {
+ StringBuilder sb = new StringBuilder();
+ for (Entry<Connector, Boolean> entry : connectorMap.entrySet()) {
+ if (sb.length() == 0) {
+ sb.append('[');
+ } else {
+ sb.append(", ");
+ }
+ sb.append(entry.getKey().getClass().getName());
+ sb.append('=');
+ sb.append(entry.getValue());
+ }
+ sb.append(']');
+ String connectorMapString = sb.toString();
+
+ sb = new StringBuilder();
+ for (Entry<Integer, Connector> entry : intMap.entrySet()) {
+ if (sb.length() == 0) {
+ sb.append('[');
+ } else {
+ sb.append(", ");
+ }
+ sb.append(entry.getKey());
+ sb.append('=');
+ sb.append(entry.getValue().getClass().getName());
+ }
+ sb.append(']');
+ String intMapString = sb.toString();
+
+ log.log("sendMap: " + stringMap + ", " + connectorMapString
+ + ", " + intMapString + ", " + beanMap);
+ }
+
+ public void sendWrappedGenerics(
+ Map<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>> generics) {
+ log.log("sendWrappedGenerics: " + generics.toString());
+ }
+
+ });
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test for lots of different cases of encoding and decoding variuos data types";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(8655);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/ComplexTestBean.java b/tests/testbench/com/vaadin/tests/widgetset/client/ComplexTestBean.java
new file mode 100644
index 0000000000..e465ee2624
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/ComplexTestBean.java
@@ -0,0 +1,70 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client;
+
+import java.util.List;
+
+import com.vaadin.terminal.gwt.client.communication.SharedState;
+
+@SuppressWarnings("javadoc")
+public class ComplexTestBean extends SharedState {
+ private SimpleTestBean innerBean1;
+ private SimpleTestBean innerBean2;
+ private List<SimpleTestBean> innerBeanCollection;
+ private int privimite;
+
+ public ComplexTestBean() {
+ // Default
+ }
+
+ public ComplexTestBean(SimpleTestBean innerBean1,
+ SimpleTestBean innerBean2,
+ List<SimpleTestBean> innerBeanCollection, int privimite) {
+ this.innerBean1 = innerBean1;
+ this.innerBean2 = innerBean2;
+ this.innerBeanCollection = innerBeanCollection;
+ this.privimite = privimite;
+ }
+
+ public SimpleTestBean getInnerBean1() {
+ return innerBean1;
+ }
+
+ public void setInnerBean1(SimpleTestBean innerBean) {
+ innerBean1 = innerBean;
+ }
+
+ public SimpleTestBean getInnerBean2() {
+ return innerBean2;
+ }
+
+ public void setInnerBean2(SimpleTestBean innerBean2) {
+ this.innerBean2 = innerBean2;
+ }
+
+ public List<SimpleTestBean> getInnerBeanCollection() {
+ return innerBeanCollection;
+ }
+
+ public void setInnerBeanCollection(List<SimpleTestBean> innerBeanCollection) {
+ this.innerBeanCollection = innerBeanCollection;
+ }
+
+ public int getPrivimite() {
+ return privimite;
+ }
+
+ public void setPrivimite(int privimite) {
+ this.privimite = privimite;
+ }
+
+ @Override
+ public String toString() {
+ return "ComplexTestBean [innerBean1=" + innerBean1 + ", innerBean2="
+ + innerBean2 + ", innerBeanCollection=" + innerBeanCollection
+ + ", privimite=" + privimite + "]";
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java
new file mode 100644
index 0000000000..72bfbe285a
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestConnector.java
@@ -0,0 +1,227 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import com.vaadin.terminal.gwt.client.Connector;
+import com.vaadin.terminal.gwt.client.communication.RpcProxy;
+import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector;
+import com.vaadin.terminal.gwt.client.ui.Connect;
+import com.vaadin.tests.widgetset.server.SerializerTestExtension;
+
+@Connect(SerializerTestExtension.class)
+public class SerializerTestConnector extends AbstractExtensionConnector {
+
+ private SerializerTestRpc rpc = RpcProxy.create(SerializerTestRpc.class,
+ this);
+
+ public SerializerTestConnector() {
+ registerRpc(SerializerTestRpc.class, new SerializerTestRpc() {
+ public void sendWrappedGenerics(
+ Map<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>> generics) {
+ Map<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>> updated = new HashMap<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>>();
+
+ SimpleTestBean firstValue = generics.values().iterator().next()
+ .get(Integer.valueOf(1)).get(0);
+ Set<SimpleTestBean> key = new HashSet<SimpleTestBean>(Arrays
+ .asList(firstValue));
+
+ Map<Integer, List<SimpleTestBean>> value = new HashMap<Integer, List<SimpleTestBean>>();
+ Set<SimpleTestBean> firstKeyValue = generics.keySet()
+ .iterator().next();
+ value.put(Integer.valueOf(1), new ArrayList<SimpleTestBean>(
+ firstKeyValue));
+
+ updated.put(key, value);
+
+ rpc.sendWrappedGenerics(updated);
+ }
+
+ public void sendString(String value) {
+ char[] chars = value.toCharArray();
+ Arrays.sort(chars);
+ rpc.sendString(new String(chars));
+ }
+
+ public void sendSet(Set<Integer> intSet,
+ Set<Connector> connectorSet, Set<SimpleTestBean> beanSet) {
+
+ beanSet.iterator().next().setValue(intSet.size());
+ Set<Integer> updatedIntSet = new HashSet<Integer>();
+
+ for (Integer integer : intSet) {
+ updatedIntSet.add(Integer.valueOf(-integer.intValue()));
+ }
+ rpc.sendSet(updatedIntSet,
+ Collections.singleton(getRootConnector()), beanSet);
+ }
+
+ public void sendNestedArray(int[][] nestedIntArray,
+ SimpleTestBean[][] nestedBeanArray) {
+ rpc.sendNestedArray(new int[][] { { nestedIntArray[1][0],
+ nestedIntArray[0][0] } }, new SimpleTestBean[][] {
+ { nestedBeanArray[0][1] }, { nestedBeanArray[0][0] } });
+ }
+
+ public void sendMap(Map<String, SimpleTestBean> stringMap,
+ Map<Connector, Boolean> connectorMap,
+ Map<Integer, Connector> intMap,
+ Map<SimpleTestBean, SimpleTestBean> beanMap) {
+ Map<SimpleTestBean, SimpleTestBean> updatedBeanMap = new HashMap<SimpleTestBean, SimpleTestBean>();
+ for (Entry<SimpleTestBean, SimpleTestBean> entry : beanMap
+ .entrySet()) {
+ updatedBeanMap.put(entry.getValue(), entry.getKey());
+ }
+
+ rpc.sendMap(Collections.singletonMap("a", stringMap.get("b")),
+ Collections.singletonMap(getThisConnector(),
+ connectorMap.get(getRootConnector())),
+ Collections.singletonMap(
+ Integer.valueOf(stringMap.size()),
+ getThisConnector()), updatedBeanMap);
+ }
+
+ public void sendLong(long value, Long boxedValue, long[] array) {
+ rpc.sendLong(array[0], Long.valueOf(value), new long[] {
+ array[1], boxedValue.longValue() });
+ }
+
+ public void sendList(List<Integer> intList,
+ List<Connector> connectorList, List<SimpleTestBean> beanList) {
+ Collections.sort(intList);
+ Collections.reverse(beanList);
+ rpc.sendList(intList,
+ Arrays.asList(getThisConnector(), getRootConnector()),
+ beanList);
+ }
+
+ public void sendInt(int value, Integer boxedValue, int[] array) {
+ rpc.sendInt(array.length, Integer.valueOf(array[0]), new int[] {
+ value, boxedValue.intValue() });
+ }
+
+ public void sendFloat(float value, Float boxedValue, float[] array) {
+ Arrays.sort(array);
+ rpc.sendFloat(boxedValue.floatValue(), Float.valueOf(value),
+ array);
+ }
+
+ public void sendDouble(double value, Double boxedValue,
+ double[] array) {
+ rpc.sendDouble(value + boxedValue.doubleValue(),
+ Double.valueOf(value - boxedValue.doubleValue()),
+ new double[] { array.length, array[0], array[1] });
+ }
+
+ public void sendConnector(Connector connector) {
+ rpc.sendConnector(getThisConnector());
+ }
+
+ public void sendChar(char value, Character boxedValue, char[] array) {
+ rpc.sendChar(Character.toUpperCase(boxedValue.charValue()),
+ Character.valueOf(value), new String(array)
+ .toLowerCase().toCharArray());
+ }
+
+ public void sendByte(byte value, Byte boxedValue, byte[] array) {
+ // There will most certainly be a bug that is not discovered
+ // because this particular method doesn't do anything with it's
+ // values...
+ rpc.sendByte(value, boxedValue, array);
+ }
+
+ public void sendBoolean(boolean value, Boolean boxedValue,
+ boolean[] array) {
+ boolean[] inverseArray = new boolean[array.length];
+ for (int i = 0; i < array.length; i++) {
+ inverseArray[i] = !array[i];
+ }
+ rpc.sendBoolean(boxedValue == Boolean.TRUE,
+ Boolean.valueOf(!value), inverseArray);
+ }
+
+ public void sendBean(ComplexTestBean complexBean,
+ SimpleTestBean simpleBean, SimpleTestBean[] array) {
+ SimpleTestBean updatedSimpleBean = new SimpleTestBean();
+ updatedSimpleBean.setValue(complexBean.getInnerBean1()
+ .getValue());
+
+ ComplexTestBean updatedComplexBean = new ComplexTestBean();
+ updatedComplexBean.setInnerBean1(complexBean.getInnerBean2());
+ updatedComplexBean.setInnerBean2(complexBean
+ .getInnerBeanCollection().get(0));
+ updatedComplexBean.setInnerBeanCollection(Arrays.asList(
+ simpleBean, updatedSimpleBean));
+ updatedComplexBean.setPrivimite(complexBean.getPrivimite() + 1);
+
+ ArrayList<SimpleTestBean> arrayList = new ArrayList<SimpleTestBean>(
+ Arrays.asList(array));
+ Collections.reverse(arrayList);
+
+ rpc.sendBean(updatedComplexBean, updatedSimpleBean,
+ arrayList.toArray(new SimpleTestBean[array.length]));
+ }
+
+ public void sendArrayList(List<int[]> primitiveArrayList,
+ List<Integer[]> objectArrayList,
+ List<SimpleTestBean[]> beanArrayList) {
+ Collections.reverse(beanArrayList);
+ List<Integer[]> updatedObjectArrayList = new ArrayList<Integer[]>();
+ for (int[] array : primitiveArrayList) {
+ updatedObjectArrayList.add(new Integer[] {
+ Integer.valueOf(array.length),
+ Integer.valueOf(array[0]) });
+ }
+
+ rpc.sendArrayList(Arrays.asList(
+ new int[] { primitiveArrayList.size() },
+ new int[] { objectArrayList.get(0).length }),
+ updatedObjectArrayList, beanArrayList);
+ }
+
+ public void sendNull(String value1, String value2) {
+ rpc.sendNull(value2, value1);
+ }
+
+ public void sendListArray(List<Integer>[] objectListArray,
+ List<SimpleTestBean>[] beanListArray) {
+ rpc.sendListArray(new List[] { objectListArray[1],
+ objectListArray[0] }, new List[] { Collections
+ .singletonList(beanListArray[0].get(0)) });
+ }
+ });
+ }
+
+ private Connector getRootConnector() {
+ return getConnection().getRootConnector();
+ }
+
+ private Connector getThisConnector() {
+ // Cast to Connector for use in e.g. Collections.singleton() to get a
+ // Set<Connector>
+ return this;
+ }
+
+ @Override
+ public ComplexTestBean getState() {
+ return (ComplexTestBean) super.getState();
+ }
+
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ // TODO do something clever
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java
new file mode 100644
index 0000000000..5b73e1d34d
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/SerializerTestRpc.java
@@ -0,0 +1,64 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.vaadin.terminal.gwt.client.Connector;
+import com.vaadin.terminal.gwt.client.communication.ClientRpc;
+import com.vaadin.terminal.gwt.client.communication.ServerRpc;
+
+@SuppressWarnings("javadoc")
+public interface SerializerTestRpc extends ServerRpc, ClientRpc {
+ public void sendBoolean(boolean value, Boolean boxedValue, boolean[] array);
+
+ public void sendByte(byte value, Byte boxedValue, byte[] array);
+
+ public void sendChar(char value, Character boxedValue, char[] array);
+
+ public void sendInt(int value, Integer boxedValue, int[] array);
+
+ public void sendLong(long value, Long boxedValue, long[] array);
+
+ public void sendFloat(float value, Float boxedValue, float[] array);
+
+ public void sendDouble(double value, Double boxedValue, double[] array);
+
+ public void sendString(String value);
+
+ public void sendConnector(Connector connector);
+
+ public void sendBean(ComplexTestBean complexBean,
+ SimpleTestBean simpleBean, SimpleTestBean[] array);
+
+ public void sendNull(String value1, String value2);
+
+ public void sendNestedArray(int[][] nestedIntArray,
+ SimpleTestBean[][] nestedBeanArray);
+
+ public void sendList(List<Integer> intList, List<Connector> connectorList,
+ List<SimpleTestBean> beanList);
+
+ public void sendArrayList(List<int[]> primitiveArrayList,
+ List<Integer[]> objectArrayList,
+ List<SimpleTestBean[]> beanArrayList);
+
+ public void sendListArray(List<Integer>[] objectListArray,
+ List<SimpleTestBean>[] beanListArray);
+
+ public void sendSet(Set<Integer> intSet, Set<Connector> connectorSet,
+ Set<SimpleTestBean> beanSet);
+
+ public void sendMap(Map<String, SimpleTestBean> stringMap,
+ Map<Connector, Boolean> connectorMap,
+ Map<Integer, Connector> intMap,
+ Map<SimpleTestBean, SimpleTestBean> beanMap);
+
+ public void sendWrappedGenerics(
+ Map<Set<SimpleTestBean>, Map<Integer, List<SimpleTestBean>>> generics);
+
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/SimpleTestBean.java b/tests/testbench/com/vaadin/tests/widgetset/client/SimpleTestBean.java
new file mode 100644
index 0000000000..43ad51e758
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/SimpleTestBean.java
@@ -0,0 +1,38 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.client;
+
+import java.io.Serializable;
+
+public class SimpleTestBean implements Serializable {
+ private int value;
+
+ public SimpleTestBean() {
+ this(0);
+ }
+
+ public SimpleTestBean(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "SimpleTestBean(" + value + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ // Implement hash code to get consistent HashSet.toString
+ return value;
+ }
+} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/GreetAgainRpc.java b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/GreetAgainRpc.java
index 0bfb8f3c32..cbfb1260e4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/GreetAgainRpc.java
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/GreetAgainRpc.java
@@ -1,7 +1,7 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.terminal.gwt.client.ui.helloworldfeature;
+package com.vaadin.tests.widgetset.client.helloworldfeature;
import com.vaadin.terminal.gwt.client.communication.ClientRpc;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldExtensionConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java
index ff444fece5..d2066c53c8 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldExtensionConnector.java
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java
@@ -1,19 +1,19 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.terminal.gwt.client.ui.helloworldfeature;
+package com.vaadin.tests.widgetset.client.helloworldfeature;
import com.google.gwt.user.client.Window;
import com.vaadin.terminal.gwt.client.ServerConnector;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.communication.RpcProxy;
-import com.vaadin.terminal.gwt.client.ui.AbstractConnector;
+import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector;
import com.vaadin.terminal.gwt.client.ui.Connect;
-import com.vaadin.ui.HelloWorldExtension;
+import com.vaadin.tests.extensions.HelloWorldExtension;
@Connect(HelloWorldExtension.class)
-public class HelloWorldExtensionConnector extends AbstractConnector {
+public class HelloWorldExtensionConnector extends AbstractExtensionConnector {
HelloWorldRpc rpc = RpcProxy.create(HelloWorldRpc.class, this);
@Override
diff --git a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldRpc.java b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldRpc.java
index 0289713390..a7a3b091bf 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldRpc.java
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldRpc.java
@@ -1,7 +1,7 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.terminal.gwt.client.ui.helloworldfeature;
+package com.vaadin.tests.widgetset.client.helloworldfeature;
import com.vaadin.terminal.gwt.client.communication.ServerRpc;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldState.java b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldState.java
index 9524a5e9aa..f26824c781 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/helloworldfeature/HelloWorldState.java
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldState.java
@@ -1,7 +1,7 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.terminal.gwt.client.ui.helloworldfeature;
+package com.vaadin.tests.widgetset.client.helloworldfeature;
import com.vaadin.terminal.gwt.client.communication.SharedState;
diff --git a/tests/testbench/com/vaadin/tests/widgetset/server/SerializerTestExtension.java b/tests/testbench/com/vaadin/tests/widgetset/server/SerializerTestExtension.java
new file mode 100644
index 0000000000..99c05e8f76
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/server/SerializerTestExtension.java
@@ -0,0 +1,22 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.widgetset.server;
+
+import com.vaadin.terminal.AbstractExtension;
+import com.vaadin.tests.widgetset.client.ComplexTestBean;
+import com.vaadin.tests.widgetset.client.SerializerTestRpc;
+
+public class SerializerTestExtension extends AbstractExtension {
+
+ @Override
+ public ComplexTestBean getState() {
+ return (ComplexTestBean) super.getState();
+ }
+
+ public void registerRpc(SerializerTestRpc rpc) {
+ super.registerRpc(rpc);
+ }
+
+}