summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/build.xml14
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java157
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java665
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java41
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java41
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java223
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java138
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java159
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java484
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java377
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java90
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java45
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java588
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java24
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java43
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java58
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java77
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java (renamed from client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java)22
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java88
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java124
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java84
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java48
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java25
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java57
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java36
-rw-r--r--client/src/com/vaadin/Vaadin.gwt.xml46
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java139
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java53
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ServerConnector.java10
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/WidgetSet.java65
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java1
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java39
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java1
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java49
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java34
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java54
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java46
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java51
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java44
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/Type.java52
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java1
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java86
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java11
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java99
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java21
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java9
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Method.java71
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java (renamed from client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java)25
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Property.java70
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java23
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/Type.java97
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java20
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java33
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java220
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java16
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java18
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java52
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java43
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java55
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java19
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java33
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java8
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java8
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java7
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java18
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java36
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java5
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java4
-rw-r--r--client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java38
-rw-r--r--server/src/com/vaadin/Application.java70
-rw-r--r--server/src/com/vaadin/data/Buffered.java76
-rw-r--r--server/src/com/vaadin/data/util/QueryContainer.java685
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java6
-rw-r--r--server/src/com/vaadin/event/ActionManager.java2
-rw-r--r--server/src/com/vaadin/terminal/AbstractClientConnector.java78
-rw-r--r--server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java2
-rw-r--r--server/src/com/vaadin/terminal/AbstractRootProvider.java35
-rw-r--r--server/src/com/vaadin/terminal/DefaultRootProvider.java51
-rw-r--r--server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java6
-rw-r--r--server/src/com/vaadin/terminal/Page.java35
-rw-r--r--server/src/com/vaadin/terminal/RootProvider.java29
-rw-r--r--server/src/com/vaadin/terminal/Terminal.java36
-rw-r--r--server/src/com/vaadin/terminal/Vaadin6Component.java11
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java83
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java2
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/ClientConnector.java42
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java26
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/JsonCodec.java175
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/WebBrowser.java30
-rw-r--r--server/src/com/vaadin/ui/AbsoluteLayout.java36
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java68
-rw-r--r--server/src/com/vaadin/ui/AbstractComponentContainer.java9
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java157
-rw-r--r--server/src/com/vaadin/ui/AbstractJavaScriptComponent.java17
-rw-r--r--server/src/com/vaadin/ui/AbstractLayout.java55
-rw-r--r--server/src/com/vaadin/ui/AbstractMedia.java8
-rw-r--r--server/src/com/vaadin/ui/AbstractOrderedLayout.java53
-rw-r--r--server/src/com/vaadin/ui/AbstractSelect.java36
-rw-r--r--server/src/com/vaadin/ui/AbstractSplitPanel.java14
-rw-r--r--server/src/com/vaadin/ui/AbstractTextField.java19
-rw-r--r--server/src/com/vaadin/ui/Button.java9
-rw-r--r--server/src/com/vaadin/ui/CheckBox.java2
-rw-r--r--server/src/com/vaadin/ui/ComboBox.java4
-rw-r--r--server/src/com/vaadin/ui/Component.java14
-rw-r--r--server/src/com/vaadin/ui/ConnectorTracker.java4
-rw-r--r--server/src/com/vaadin/ui/CssLayout.java12
-rw-r--r--server/src/com/vaadin/ui/CustomComponent.java2
-rw-r--r--server/src/com/vaadin/ui/CustomField.java4
-rw-r--r--server/src/com/vaadin/ui/CustomLayout.java34
-rw-r--r--server/src/com/vaadin/ui/DateField.java30
-rw-r--r--server/src/com/vaadin/ui/DragAndDropWrapper.java24
-rw-r--r--server/src/com/vaadin/ui/Embedded.java22
-rw-r--r--server/src/com/vaadin/ui/Form.java89
-rw-r--r--server/src/com/vaadin/ui/FormLayout.java4
-rw-r--r--server/src/com/vaadin/ui/GridLayout.java106
-rw-r--r--server/src/com/vaadin/ui/JavaScript.java10
-rw-r--r--server/src/com/vaadin/ui/Label.java19
-rw-r--r--server/src/com/vaadin/ui/Layout.java120
-rw-r--r--server/src/com/vaadin/ui/Link.java39
-rw-r--r--server/src/com/vaadin/ui/ListSelect.java4
-rw-r--r--server/src/com/vaadin/ui/LoginForm.java3
-rw-r--r--server/src/com/vaadin/ui/MenuBar.java40
-rw-r--r--server/src/com/vaadin/ui/NativeSelect.java2
-rw-r--r--server/src/com/vaadin/ui/Notification.java66
-rw-r--r--server/src/com/vaadin/ui/OptionGroup.java10
-rw-r--r--server/src/com/vaadin/ui/Panel.java7
-rw-r--r--server/src/com/vaadin/ui/PopupDateField.java2
-rw-r--r--server/src/com/vaadin/ui/PopupView.java20
-rw-r--r--server/src/com/vaadin/ui/ProgressIndicator.java4
-rw-r--r--server/src/com/vaadin/ui/RichTextArea.java75
-rw-r--r--server/src/com/vaadin/ui/Root.java29
-rw-r--r--server/src/com/vaadin/ui/Select.java44
-rw-r--r--server/src/com/vaadin/ui/Slider.java8
-rw-r--r--server/src/com/vaadin/ui/TabSheet.java115
-rw-r--r--server/src/com/vaadin/ui/Table.java105
-rw-r--r--server/src/com/vaadin/ui/TextArea.java4
-rw-r--r--server/src/com/vaadin/ui/Tree.java38
-rw-r--r--server/src/com/vaadin/ui/TreeTable.java6
-rw-r--r--server/src/com/vaadin/ui/TwinColSelect.java8
-rw-r--r--server/src/com/vaadin/ui/Upload.java41
-rw-r--r--server/src/com/vaadin/ui/Video.java3
-rw-r--r--server/src/com/vaadin/ui/Window.java50
-rw-r--r--server/src/com/vaadin/ui/themes/BaseTheme.java12
-rw-r--r--server/src/com/vaadin/ui/themes/Reindeer.java18
-rw-r--r--shared/src/com/vaadin/shared/Connector.java11
-rwxr-xr-xshared/src/com/vaadin/shared/Position.java20
-rw-r--r--shared/src/com/vaadin/shared/ui/AbstractLayoutState.java9
-rwxr-xr-xshared/src/com/vaadin/shared/ui/BorderStyle.java20
-rw-r--r--shared/src/com/vaadin/shared/ui/MarginInfo.java (renamed from shared/src/com/vaadin/shared/ui/VMarginInfo.java)17
-rw-r--r--shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java9
-rw-r--r--shared/src/com/vaadin/shared/ui/label/LabelState.java21
-rw-r--r--shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java12
-rw-r--r--shared/src/com/vaadin/shared/ui/root/RootState.java8
-rw-r--r--tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java18
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java18
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java4
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java50
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java53
-rw-r--r--tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java33
-rw-r--r--tests/testbench/com/vaadin/tests/Parameters.java4
-rw-r--r--tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java2
-rw-r--r--tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java4
-rw-r--r--tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java16
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java9
-rw-r--r--tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/customfield/AddressField.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java7
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java6
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java5
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java4
-rw-r--r--tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java2
-rwxr-xr-xtests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java52
-rw-r--r--tests/testbench/com/vaadin/tests/components/notification/Notifications.java4
-rw-r--r--tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java15
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java6
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java4
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java4
-rw-r--r--tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java2
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java2
-rw-r--r--tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java2
-rw-r--r--tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java2
-rw-r--r--tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java1
-rw-r--r--tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java1
-rw-r--r--tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java6
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java5
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java6
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java4
-rw-r--r--tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java1
-rw-r--r--tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java1
-rw-r--r--tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java6
-rw-r--r--tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java2
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1435.java3
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1572.java9
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1710.java90
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1805.java4
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1806.java3
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java2
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1983.java2
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2021.java3
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2040.java4
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2060.java6
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2405.java4
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2998.java3
-rw-r--r--tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html (renamed from tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html)6
-rw-r--r--tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java (renamed from tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java)4
-rw-r--r--tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java2
217 files changed, 4457 insertions, 4964 deletions
diff --git a/build/build.xml b/build/build.xml
index 2988218c4d..d905bb9c6f 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -129,6 +129,7 @@
<property name="result-classes-sass" value="${result-path}/classes/sass"/>
<property name="result-classes-sass-junit" value="${result-path}/classes/sass-junit"/>
<property name="result-precompiled-widgetsets" value="${result-path}/classes/widgetsets"/>
+ <property name="result-classes-gwt" value="${result-path}/classes/gwt" />
<!-- Default classpath for building widgetsets, overridden for testing widgetset -->
<path id="compile.classpath.widgetset">
@@ -848,9 +849,12 @@
<!-- Create Vaadin JAR -->
<mkdir dir="${output-dir}/META-INF"/>
<echo file="${output-dir}/META-INF/VERSION">${version.full}</echo>
+
+ <!-- Replace GWT versioning with Vaadin versioning -->
+ <echo file="${result-classes-gwt}/com/google/gwt/dev/About.properties">gwt.version=${gwt-version}.vaadin${version.full}</echo>
<jarjar jarfile="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}"
- compress="true" manifest="build/package/META-INF/MANIFEST.MF" duplicate="preserve" index="true">
+ compress="true" manifest="build/package/META-INF/MANIFEST.MF" duplicate="preserve" index="true" >
<metainf dir="${output-dir}/META-INF"/>
<manifest>
<attribute name="Vaadin-Package-Version" value="1" />
@@ -874,6 +878,7 @@
<fileset dir="${result-src-shared}"/>
<fileset dir="${result-src-sass}"/>
<fileset dir="${result-src-client-compiler}"/>
+ <fileset dir="${result-classes-gwt}"/>
<fileset dir="${output-dir}/WebContent">
<patternset>
<include name="VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/**/*" />
@@ -899,7 +904,7 @@
<!-- GWT -->
<!-- Precompiled GWT modules (.gwtar file) not included to limit JAR size -->
<zipfileset src="${gwt.user.jar}" excludes="META-INF/**,javax/servlet/**,**/*.gwtar" />
-
+
<!-- TODO depends on locally compiled gwt-user -->
<!--
<fileset dir="${gwt.user.dir}/src" excludes="**/package.html" />
@@ -912,7 +917,9 @@
-->
<!-- GWT development JAR contents including many external dependencies -->
- <zipfileset src="${gwt.dev.jar}" excludes="javax/servlet/**,javax/xml/**" />
+ <zipfileset src="${gwt.dev.jar}" excludes="javax/servlet/**,javax/xml/**" >
+ <exclude name="com/google/gwt/dev/About.properties"/>
+ </zipfileset>
<!-- Alternative approach: GWT compiler and its dependencies only from the dev JAR -->
<!--
@@ -974,6 +981,7 @@
<rule pattern="org.hibernate.validator.**" result="com.vaadin.external.@0"/>
<rule pattern="org.jdesktop.swingworker.**" result="com.vaadin.external.@0"/>
<rule pattern="org.kohsuke.args4j.**" result="com.vaadin.external.@0"/>
+
</jarjar>
<!-- Generate the Export-Package attribute in the manifest of the JAR -->
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java
deleted file mode 100644
index 78579b7e54..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import java.io.PrintWriter;
-import java.util.Date;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.JMethod;
-import com.google.gwt.core.ext.typeinfo.JType;
-import com.google.gwt.core.ext.typeinfo.NotFoundException;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
-import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-import com.vaadin.terminal.gwt.client.ui.ConnectorClassBasedFactory;
-import com.vaadin.terminal.gwt.client.ui.ConnectorClassBasedFactory.Creator;
-
-/**
- * GWT generator that creates a lookup method for
- * {@link ConnectorClassBasedFactory} instances.
- *
- * @since 7.0
- */
-public abstract class AbstractConnectorClassBasedFactoryGenerator extends
- Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context,
- String typeName) throws UnableToCompleteException {
-
- try {
- // get classType and save instance variables
- return generateConnectorClassBasedFactory(typeName, logger, context);
- } catch (Exception e) {
- logger.log(TreeLogger.ERROR, typeName + " creation failed", e);
- throw new UnableToCompleteException();
- }
- }
-
- private String generateConnectorClassBasedFactory(String typeName,
- TreeLogger logger, GeneratorContext context)
- throws NotFoundException {
- TypeOracle typeOracle = context.getTypeOracle();
-
- JClassType classType = typeOracle.getType(typeName);
- String superName = classType.getSimpleSourceName();
- String packageName = classType.getPackage().getName();
- String className = superName + "Impl";
-
- // get print writer that receives the source code
- PrintWriter printWriter = null;
- printWriter = context.tryCreate(logger, packageName, className);
- // print writer if null, source code has ALREADY been generated
- if (printWriter == null) {
- return packageName + "." + className;
- }
-
- Date date = new Date();
-
- // init composer, set class properties, create source writer
- ClassSourceFileComposerFactory composer = null;
- composer = new ClassSourceFileComposerFactory(packageName, className);
- composer.addImport(GWT.class.getName());
- composer.addImport(Creator.class.getCanonicalName());
- composer.setSuperclass(superName);
-
- SourceWriter sourceWriter = composer.createSourceWriter(context,
- printWriter);
- sourceWriter.indent();
-
- // public ConnectorStateFactoryImpl() {
- sourceWriter.println("public " + className + "() {");
- sourceWriter.indent();
-
- JClassType serverConnectorType = typeOracle.getType(getConnectorType()
- .getCanonicalName());
- for (JClassType connector : serverConnectorType.getSubtypes()) {
- // addCreator(TextAreaConnector.class, new Creator<SharedState>() {
- if (connector.isInterface() != null || connector.isAbstract()) {
- continue;
- }
-
- JClassType targetType = getTargetType(connector);
- if (targetType.isAbstract()) {
- continue;
- }
-
- sourceWriter.println("addCreator("
- + connector.getQualifiedSourceName()
- + ".class, new Creator<"
- + targetType.getQualifiedSourceName() + ">() {");
- // public SharedState create() {
- sourceWriter.println("public "
- + targetType.getQualifiedSourceName() + " create() {");
- // return GWT.create(TextAreaState.class);
- sourceWriter.println("return GWT.create("
- + targetType.getQualifiedSourceName() + ".class);");
- // }
- sourceWriter.println("}");
- // });
- sourceWriter.println("});");
- }
-
- // End of constructor
- sourceWriter.outdent();
- sourceWriter.println("}");
-
- // close generated class
- sourceWriter.outdent();
- sourceWriter.println("}");
-
- // commit generated class
- context.commit(logger, printWriter);
- logger.log(Type.INFO,
- "Done. (" + (new Date().getTime() - date.getTime()) / 1000
- + "seconds)");
- return packageName + "." + className;
-
- }
-
- protected abstract Class<? extends ServerConnector> getConnectorType();
-
- protected abstract JClassType getTargetType(JClassType connectorType);
-
- protected JClassType getGetterReturnType(JClassType connector,
- String getterName) {
- try {
- JMethod getMethod = connector.getMethod(getterName, new JType[] {});
- return (JClassType) getMethod.getReturnType();
- } catch (NotFoundException e) {
- return getGetterReturnType(connector.getSuperclass(), getterName);
- }
-
- }
-
-}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java
new file mode 100644
index 0000000000..a2e61947e8
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java
@@ -0,0 +1,665 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+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.google.gwt.core.client.GWT;
+import com.google.gwt.core.ext.Generator;
+import com.google.gwt.core.ext.GeneratorContext;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JParameterizedType;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
+import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.shared.annotations.Delayed;
+import com.vaadin.shared.communication.ClientRpc;
+import com.vaadin.shared.communication.ServerRpc;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.Connect.LoadStyle;
+import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.InvokationHandler;
+import com.vaadin.terminal.gwt.client.metadata.ProxyHandler;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
+import com.vaadin.terminal.gwt.client.metadata.TypeDataBundle;
+import com.vaadin.terminal.gwt.client.metadata.TypeDataStore;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.ClientRpcVisitor;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorBundle;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorInitVisitor;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.GeneratedSerializer;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.Property;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.ServerRpcVisitor;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.StateInitVisitor;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.TypeVisitor;
+import com.vaadin.terminal.gwt.widgetsetutils.metadata.WidgetInitVisitor;
+
+public class ConnectorBundleLoaderFactory extends Generator {
+
+ @Override
+ public String generate(TreeLogger logger, GeneratorContext context,
+ String typeName) throws UnableToCompleteException {
+ TypeOracle typeOracle = context.getTypeOracle();
+
+ try {
+ JClassType classType = typeOracle.getType(typeName);
+ String packageName = classType.getPackage().getName();
+ String className = classType.getSimpleSourceName() + "Impl";
+
+ generateClass(logger, context, packageName, className, typeName);
+
+ return packageName + "." + className;
+ } catch (UnableToCompleteException e) {
+ // Just rethrow
+ throw e;
+ } catch (Exception e) {
+ logger.log(Type.ERROR, getClass() + " failed", e);
+ throw new UnableToCompleteException();
+ }
+
+ }
+
+ private void generateClass(TreeLogger logger, GeneratorContext context,
+ String packageName, String className, String requestedType)
+ throws Exception {
+ PrintWriter printWriter = context.tryCreate(logger, packageName,
+ className);
+ if (printWriter == null) {
+ return;
+ }
+
+ List<ConnectorBundle> bundles = buildBundles(logger,
+ context.getTypeOracle());
+
+ ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
+ packageName, className);
+ composer.setSuperclass(requestedType);
+
+ SourceWriter w = composer.createSourceWriter(context, printWriter);
+
+ w.println("public void init() {");
+ w.indent();
+
+ for (ConnectorBundle bundle : bundles) {
+ String name = bundle.getName();
+ boolean isEager = name
+ .equals(ConnectorBundleLoader.EAGER_BUNDLE_NAME);
+
+ w.print("addAsyncBlockLoader(new AsyncBundleLoader(\"");
+ w.print(escape(name));
+ w.print("\", ");
+
+ w.print("new String[] {");
+ for (Entry<JClassType, Set<String>> entry : bundle.getIdentifiers()
+ .entrySet()) {
+ Set<String> identifiers = entry.getValue();
+ for (String id : identifiers) {
+ w.print("\"");
+ w.print(escape(id));
+ w.print("\",");
+ }
+ }
+ w.println("}) {");
+ w.indent();
+
+ w.print("protected void load(final ");
+ w.print(TypeDataStore.class.getName());
+ w.println(" store) {");
+ w.indent();
+
+ if (!isEager) {
+ w.print(GWT.class.getName());
+ w.print(".runAsync(");
+ }
+
+ w.print("new ");
+ w.print(TypeDataBundle.class.getName());
+ w.println("(getName()) {");
+ w.indent();
+
+ w.println("public void load() {");
+ w.indent();
+
+ printBundleData(logger, w, bundle);
+
+ // Close load method
+ w.outdent();
+ w.println("}");
+
+ // Close new TypeDataBundle() {}
+ w.outdent();
+ w.print("}");
+
+ if (isEager) {
+ w.println(".onSuccess();");
+ } else {
+ w.println(");");
+ }
+
+ // Close load method
+ w.outdent();
+ w.println("}");
+
+ // Close add(new ...
+ w.outdent();
+ w.println("});");
+ }
+
+ w.outdent();
+ w.println("}");
+
+ w.commit(logger);
+ }
+
+ private void printBundleData(TreeLogger logger, SourceWriter w,
+ ConnectorBundle bundle) throws UnableToCompleteException {
+ writeIdentifiers(w, bundle);
+ writeGwtConstructors(w, bundle);
+ writeReturnTypes(w, bundle);
+ writeInvokers(w, bundle);
+ writeParamTypes(w, bundle);
+ writeProxys(w, bundle);
+ wirteDelayedInfo(w, bundle);
+ writeProperites(logger, w, bundle);
+ writePropertyTypes(w, bundle);
+ writeSetters(logger, w, bundle);
+ writeGetters(logger, w, bundle);
+ writeSerializers(logger, w, bundle);
+ }
+
+ private void writeSerializers(TreeLogger logger, SourceWriter w,
+ ConnectorBundle bundle) throws UnableToCompleteException {
+ Map<JType, GeneratedSerializer> serializers = bundle.getSerializers();
+ for (Entry<JType, GeneratedSerializer> entry : serializers.entrySet()) {
+ JType type = entry.getKey();
+ GeneratedSerializer serializer = entry.getValue();
+
+ w.print("store.setSerializerFactory(");
+ writeClassLiteral(w, type);
+ w.print(", ");
+ w.println("new Invoker() {");
+ w.indent();
+
+ w.println("public Object invoke(Object target, Object[] params) {");
+ w.indent();
+
+ serializer.writeSerializerInstantiator(logger, w);
+
+ w.outdent();
+ w.println("}");
+
+ w.outdent();
+ w.print("}");
+ w.println(");");
+ }
+ }
+
+ private void writeGetters(TreeLogger logger, SourceWriter w,
+ ConnectorBundle bundle) {
+ Set<Property> properties = bundle.getNeedsSetter();
+ for (Property property : properties) {
+ w.print("store.setGetter(");
+ writeClassLiteral(w, property.getBeanType());
+ w.print(", \"");
+ w.print(escape(property.getName()));
+ w.println("\", new Invoker() {");
+ w.indent();
+
+ w.println("public Object invoke(Object bean, Object[] params) {");
+ w.indent();
+
+ property.writeGetterBody(logger, w, "bean");
+ w.println();
+
+ w.outdent();
+ w.println("}");
+
+ w.outdent();
+ w.println("});");
+ }
+ }
+
+ private void writeSetters(TreeLogger logger, SourceWriter w,
+ ConnectorBundle bundle) {
+ Set<Property> properties = bundle.getNeedsSetter();
+ for (Property property : properties) {
+ w.print("store.setSetter(");
+ writeClassLiteral(w, property.getBeanType());
+ w.print(", \"");
+ w.print(escape(property.getName()));
+ w.println("\", new Invoker() {");
+ w.indent();
+
+ w.println("public Object invoke(Object bean, Object[] params) {");
+ w.indent();
+
+ property.writeSetterBody(logger, w, "bean", "params[0]");
+
+ w.println("return null;");
+
+ w.outdent();
+ w.println("}");
+
+ w.outdent();
+ w.println("});");
+ }
+ }
+
+ private void writePropertyTypes(SourceWriter w, ConnectorBundle bundle) {
+ Set<Property> properties = bundle.getNeedsType();
+ for (Property property : properties) {
+ w.print("store.setPropertyType(");
+ writeClassLiteral(w, property.getBeanType());
+ w.print(", \"");
+ w.print(escape(property.getName()));
+ w.print("\", ");
+ writeTypeCreator(w, property.getPropertyType());
+ w.println(");");
+ }
+ }
+
+ private void writeProperites(TreeLogger logger, SourceWriter w,
+ ConnectorBundle bundle) throws UnableToCompleteException {
+ Set<JClassType> needsPropertyListing = bundle.getNeedsPropertyListing();
+ for (JClassType type : needsPropertyListing) {
+ w.print("store.setProperties(");
+ writeClassLiteral(w, type);
+ w.print(", new String[] {");
+
+ Set<String> usedPropertyNames = new HashSet<String>();
+ Collection<Property> properties = bundle.getProperties(type);
+ for (Property property : properties) {
+ String name = property.getName();
+ if (!usedPropertyNames.add(name)) {
+ logger.log(
+ Type.ERROR,
+ type.getQualifiedSourceName()
+ + " has multiple properties with the name "
+ + name
+ + ". This can happen if there are multiple setters with identical names exect casing.");
+ throw new UnableToCompleteException();
+ }
+
+ w.print("\"");
+ w.print(name);
+ w.print("\", ");
+ }
+
+ w.println("});");
+ }
+ }
+
+ private void wirteDelayedInfo(SourceWriter w, ConnectorBundle bundle) {
+ Map<JClassType, Set<JMethod>> needsDelayedInfo = bundle
+ .getNeedsDelayedInfo();
+ Set<Entry<JClassType, Set<JMethod>>> entrySet = needsDelayedInfo
+ .entrySet();
+ for (Entry<JClassType, Set<JMethod>> entry : entrySet) {
+ JClassType type = entry.getKey();
+ Set<JMethod> methods = entry.getValue();
+ for (JMethod method : methods) {
+ Delayed annotation = method.getAnnotation(Delayed.class);
+ if (annotation != null) {
+ w.print("store.setDelayed(");
+ writeClassLiteral(w, type);
+ w.print(", \"");
+ w.print(escape(method.getName()));
+ w.println("\");");
+
+ if (annotation.lastonly()) {
+ w.print("store.setLastonly(");
+ writeClassLiteral(w, type);
+ w.print(", \"");
+ w.print(escape(method.getName()));
+ w.println("\");");
+ }
+ }
+ }
+ }
+ }
+
+ private void writeProxys(SourceWriter w, ConnectorBundle bundle) {
+ Set<JClassType> needsProxySupport = bundle.getNeedsProxySupport();
+ for (JClassType type : needsProxySupport) {
+ w.print("store.setProxyHandler(");
+ writeClassLiteral(w, type);
+ w.print(", new ");
+ w.print(ProxyHandler.class.getCanonicalName());
+ w.println("() {");
+ w.indent();
+
+ w.println("public Object createProxy(final "
+ + InvokationHandler.class.getName() + " handler) {");
+ w.indent();
+
+ w.print("return new ");
+ w.print(type.getQualifiedSourceName());
+ w.println("() {");
+ w.indent();
+
+ JMethod[] methods = type.getOverridableMethods();
+ for (JMethod method : methods) {
+ if (method.isAbstract()) {
+ w.print("public ");
+ w.print(method.getReturnType().getQualifiedSourceName());
+ w.print(" ");
+ w.print(method.getName());
+ w.print("(");
+
+ JType[] types = method.getParameterTypes();
+ for (int i = 0; i < types.length; i++) {
+ if (i != 0) {
+ w.print(", ");
+ }
+ w.print(types[i].getQualifiedSourceName());
+ w.print(" p");
+ w.print(Integer.toString(i));
+ }
+
+ w.println(") {");
+ w.indent();
+
+ if (!method.getReturnType().getQualifiedSourceName()
+ .equals("void")) {
+ w.print("return ");
+ }
+
+ w.print("handler.invoke(this, ");
+ w.print(TypeData.class.getCanonicalName());
+ w.print(".getType(");
+ writeClassLiteral(w, type);
+ w.print(").getMethod(\"");
+ w.print(escape(method.getName()));
+ w.print("\"), new Object [] {");
+ for (int i = 0; i < types.length; i++) {
+ w.print("p" + i + ", ");
+ }
+ w.println("});");
+
+ w.outdent();
+ w.println("}");
+ }
+ }
+
+ w.outdent();
+ w.println("};");
+
+ w.outdent();
+ w.println("}");
+
+ w.outdent();
+ w.println("});");
+
+ }
+ }
+
+ private void writeParamTypes(SourceWriter w, ConnectorBundle bundle) {
+ Map<JClassType, Set<JMethod>> needsParamTypes = bundle
+ .getNeedsParamTypes();
+ for (Entry<JClassType, Set<JMethod>> entry : needsParamTypes.entrySet()) {
+ JClassType type = entry.getKey();
+
+ Set<JMethod> methods = entry.getValue();
+ for (JMethod method : methods) {
+ w.print("store.setParamTypes(");
+ writeClassLiteral(w, type);
+ w.print(", \"");
+ w.print(escape(method.getName()));
+ w.print("\", new Type[] {");
+
+ for (JType parameter : method.getParameterTypes()) {
+ ConnectorBundleLoaderFactory.writeTypeCreator(w, parameter);
+ w.print(", ");
+ }
+
+ w.println("});");
+
+ }
+ }
+ }
+
+ private void writeInvokers(SourceWriter w, ConnectorBundle bundle) {
+ Map<JClassType, Set<JMethod>> needsInvoker = bundle.getNeedsInvoker();
+ for (Entry<JClassType, Set<JMethod>> entry : needsInvoker.entrySet()) {
+ JClassType type = entry.getKey();
+
+ Set<JMethod> methods = entry.getValue();
+ for (JMethod method : methods) {
+ w.print("store.setInvoker(");
+ writeClassLiteral(w, type);
+ w.print(", \"");
+ w.print(escape(method.getName()));
+ w.println("\", new Invoker() {");
+ w.indent();
+
+ w.println("public Object invoke(Object target, Object[] params) {");
+ w.indent();
+
+ JType returnType = method.getReturnType();
+ boolean hasReturnType = !"void".equals(returnType
+ .getQualifiedSourceName());
+ if (hasReturnType) {
+ w.print("return ");
+ }
+
+ JType[] parameterTypes = method.getParameterTypes();
+
+ w.print("((" + type.getQualifiedSourceName() + ") target)."
+ + method.getName() + "(");
+ for (int i = 0; i < parameterTypes.length; i++) {
+ JType parameterType = parameterTypes[i];
+ if (i != 0) {
+ w.print(", ");
+ }
+ String parameterTypeName = getBoxedTypeName(parameterType);
+ w.print("(" + parameterTypeName + ") params[" + i + "]");
+ }
+ w.println(");");
+
+ if (!hasReturnType) {
+ w.println("return null;");
+ }
+
+ w.outdent();
+ w.println("}");
+
+ w.outdent();
+ w.println("});");
+
+ }
+ }
+ }
+
+ private void writeReturnTypes(SourceWriter w, ConnectorBundle bundle) {
+ Map<JClassType, Set<JMethod>> methodReturnTypes = bundle
+ .getMethodReturnTypes();
+ for (Entry<JClassType, Set<JMethod>> entry : methodReturnTypes
+ .entrySet()) {
+ JClassType type = entry.getKey();
+
+ Set<JMethod> methods = entry.getValue();
+ for (JMethod method : methods) {
+ // setReturnType(Class<?> type, String methodName, Type
+ // returnType)
+ w.print("store.setReturnType(");
+ writeClassLiteral(w, type);
+ w.print(", \"");
+ w.print(escape(method.getName()));
+ w.print("\", ");
+ writeTypeCreator(w, method.getReturnType());
+ w.println(");");
+ }
+ }
+ }
+
+ private void writeGwtConstructors(SourceWriter w, ConnectorBundle bundle) {
+ Set<JClassType> constructors = bundle.getGwtConstructors();
+ for (JClassType type : constructors) {
+ w.print("store.setConstructor(");
+ writeClassLiteral(w, type);
+ w.println(", new Invoker() {");
+ w.indent();
+
+ w.println("public Object invoke(Object target, Object[] params) {");
+ w.indent();
+
+ w.print("return ");
+ w.print(GWT.class.getName());
+ w.print(".create(");
+ writeClassLiteral(w, type);
+ w.println(");");
+
+ w.outdent();
+ w.println("}");
+
+ w.outdent();
+ w.println("});");
+ }
+ }
+
+ public static void writeClassLiteral(SourceWriter w, JType type) {
+ w.print(type.getQualifiedSourceName());
+ w.print(".class");
+ }
+
+ private void writeIdentifiers(SourceWriter w, ConnectorBundle bundle) {
+ Map<JClassType, Set<String>> identifiers = bundle.getIdentifiers();
+ for (Entry<JClassType, Set<String>> entry : identifiers.entrySet()) {
+ Set<String> ids = entry.getValue();
+ JClassType type = entry.getKey();
+ for (String id : ids) {
+ w.print("store.setClass(\"");
+ w.print(escape(id));
+ w.print("\", ");
+ writeClassLiteral(w, type);
+ w.println(");");
+ }
+ }
+ }
+
+ private List<ConnectorBundle> buildBundles(TreeLogger logger,
+ TypeOracle typeOracle) throws NotFoundException,
+ UnableToCompleteException {
+
+ Map<LoadStyle, Collection<JClassType>> connectorsByLoadStyle = new HashMap<LoadStyle, Collection<JClassType>>();
+ for (LoadStyle loadStyle : LoadStyle.values()) {
+ connectorsByLoadStyle.put(loadStyle, new ArrayList<JClassType>());
+ }
+
+ JClassType connectorType = typeOracle.getType(ServerConnector.class
+ .getName());
+ JClassType[] subtypes = connectorType.getSubtypes();
+ for (JClassType connectorSubtype : subtypes) {
+ if (!connectorSubtype.isAnnotationPresent(Connect.class)) {
+ continue;
+ }
+ LoadStyle loadStyle = getLoadStyle(connectorSubtype);
+ if (loadStyle != null) {
+ connectorsByLoadStyle.get(loadStyle).add(connectorSubtype);
+ }
+ }
+
+ List<ConnectorBundle> bundles = new ArrayList<ConnectorBundle>();
+
+ Collection<TypeVisitor> visitors = getVisitors(typeOracle);
+
+ ConnectorBundle eagerBundle = new ConnectorBundle(
+ ConnectorBundleLoader.EAGER_BUNDLE_NAME, visitors, typeOracle);
+ TreeLogger eagerLogger = logger.branch(Type.TRACE,
+ "Populating eager bundle");
+
+ // Eager connectors and all RPC interfaces are loaded by default
+ eagerBundle.processTypes(eagerLogger,
+ connectorsByLoadStyle.get(LoadStyle.EAGER));
+ eagerBundle.processSubTypes(eagerLogger,
+ typeOracle.getType(ClientRpc.class.getName()));
+ eagerBundle.processSubTypes(eagerLogger,
+ typeOracle.getType(ServerRpc.class.getName()));
+
+ bundles.add(eagerBundle);
+
+ ConnectorBundle deferredBundle = new ConnectorBundle(
+ ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, eagerBundle);
+ TreeLogger deferredLogger = logger.branch(Type.TRACE,
+ "Populating deferred bundle");
+ deferredBundle.processTypes(deferredLogger,
+ connectorsByLoadStyle.get(LoadStyle.DEFERRED));
+
+ bundles.add(deferredBundle);
+
+ Collection<JClassType> lazy = connectorsByLoadStyle.get(LoadStyle.LAZY);
+ for (JClassType type : lazy) {
+ ConnectorBundle bundle = new ConnectorBundle(type.getName(),
+ eagerBundle);
+ TreeLogger subLogger = logger.branch(Type.TRACE, "Populating "
+ + type.getName() + " bundle");
+ bundle.processType(subLogger, type);
+
+ bundles.add(bundle);
+ }
+
+ return bundles;
+ }
+
+ private Collection<TypeVisitor> getVisitors(TypeOracle oracle)
+ throws NotFoundException {
+ List<TypeVisitor> visitors = Arrays.<TypeVisitor> asList(
+ new ConnectorInitVisitor(), new StateInitVisitor(),
+ new WidgetInitVisitor(), new ClientRpcVisitor(),
+ new ServerRpcVisitor());
+ for (TypeVisitor typeVisitor : visitors) {
+ typeVisitor.init(oracle);
+ }
+ return visitors;
+ }
+
+ protected LoadStyle getLoadStyle(JClassType connectorType) {
+ Connect annotation = connectorType.getAnnotation(Connect.class);
+ return annotation.loadStyle();
+ }
+
+ public static String getBoxedTypeName(JType type) {
+ if (type.isPrimitive() != null) {
+ // Used boxed types for primitives
+ return type.isPrimitive().getQualifiedBoxedSourceName();
+ } else {
+ return type.getErasedType().getQualifiedSourceName();
+ }
+ }
+
+ public static void writeTypeCreator(SourceWriter sourceWriter, JType type) {
+ String typeName = ConnectorBundleLoaderFactory.getBoxedTypeName(type);
+ JParameterizedType parameterized = type.isParameterized();
+ if (parameterized != null) {
+ sourceWriter.print("new Type(\"" + typeName + "\", ");
+ sourceWriter.print("new Type[] {");
+ JClassType[] typeArgs = parameterized.getTypeArgs();
+ for (JClassType jClassType : typeArgs) {
+ writeTypeCreator(sourceWriter, jClassType);
+ sourceWriter.print(", ");
+ }
+ sourceWriter.print("}");
+ } else {
+ sourceWriter.print("new Type(" + typeName + ".class");
+ }
+ sourceWriter.print(")");
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java
deleted file mode 100644
index 136ea3360e..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-
-/**
- * GWT generator that creates a SharedState class for a given Connector class,
- * based on the return type of getState()
- *
- * @since 7.0
- */
-public class ConnectorStateFactoryGenerator extends
- AbstractConnectorClassBasedFactoryGenerator {
-
- @Override
- protected JClassType getTargetType(JClassType connectorType) {
- return getGetterReturnType(connectorType, "getState");
- }
-
- @Override
- protected Class<? extends ServerConnector> getConnectorType() {
- return ServerConnector.class;
- }
-
-}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java
deleted file mode 100644
index 32693369f2..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.vaadin.terminal.gwt.client.ComponentConnector;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-
-/**
- * GWT generator that creates a Widget class for a given Connector class, based
- * on the return type of getWidget()
- *
- * @since 7.0
- */
-public class ConnectorWidgetFactoryGenerator extends
- AbstractConnectorClassBasedFactoryGenerator {
- @Override
- protected JClassType getTargetType(JClassType connectorType) {
- return getGetterReturnType(connectorType, "getWidget");
- }
-
- @Override
- protected Class<? extends ServerConnector> getConnectorType() {
- return ComponentConnector.class;
- }
-
-} \ No newline at end of file
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java
deleted file mode 100644
index 47062d9abb..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.JMethod;
-import com.google.gwt.core.ext.typeinfo.JParameterizedType;
-import com.google.gwt.core.ext.typeinfo.JType;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
-import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.shared.communication.ClientRpc;
-import com.vaadin.terminal.gwt.client.communication.GeneratedRpcMethodProvider;
-import com.vaadin.terminal.gwt.client.communication.RpcManager;
-import com.vaadin.terminal.gwt.client.communication.RpcMethod;
-
-/**
- * GWT generator that creates an implementation for {@link RpcManager} on the
- * client side classes for executing RPC calls received from the the server.
- *
- * @since 7.0
- */
-public class GeneratedRpcMethodProviderGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context,
- String typeName) throws UnableToCompleteException {
-
- String packageName = null;
- String className = null;
- try {
- TypeOracle typeOracle = context.getTypeOracle();
-
- // get classType and save instance variables
- JClassType classType = typeOracle.getType(typeName);
- packageName = classType.getPackage().getName();
- className = classType.getSimpleSourceName() + "Impl";
- // Generate class source code for SerializerMapImpl
- generateClass(logger, context, packageName, className);
- } catch (Exception e) {
- logger.log(TreeLogger.ERROR,
- "SerializerMapGenerator creation failed", e);
- }
- // return the fully qualifed name of the class generated
- return packageName + "." + className;
- }
-
- /**
- * Generate source code for RpcManagerImpl
- *
- * @param logger
- * Logger object
- * @param context
- * Generator context
- * @param packageName
- * package name for the class to generate
- * @param className
- * class name for the class to generate
- */
- private void generateClass(TreeLogger logger, GeneratorContext context,
- String packageName, String className) {
- // get print writer that receives the source code
- PrintWriter printWriter = null;
- printWriter = context.tryCreate(logger, packageName, className);
- // print writer if null, source code has ALREADY been generated
- if (printWriter == null) {
- return;
- }
- logger.log(Type.INFO,
- "Detecting server to client RPC interface types...");
- Date date = new Date();
- TypeOracle typeOracle = context.getTypeOracle();
- JClassType serverToClientRpcType = typeOracle.findType(ClientRpc.class
- .getName());
- JClassType[] rpcInterfaceSubtypes = serverToClientRpcType.getSubtypes();
-
- // init composer, set class properties, create source writer
- ClassSourceFileComposerFactory composer = null;
- composer = new ClassSourceFileComposerFactory(packageName, className);
- composer.addImport("com.google.gwt.core.client.GWT");
- composer.addImport(RpcMethod.class.getName());
- composer.addImport(ClientRpc.class.getName());
- composer.addImport(com.vaadin.terminal.gwt.client.communication.Type.class
- .getName());
- composer.addImplementedInterface(GeneratedRpcMethodProvider.class
- .getName());
- SourceWriter sourceWriter = composer.createSourceWriter(context,
- printWriter);
- sourceWriter.indent();
-
- List<JMethod> rpcMethods = new ArrayList<JMethod>();
-
- sourceWriter
- .println("public java.util.Collection<RpcMethod> getGeneratedRpcMethods() {");
- sourceWriter.indent();
-
- sourceWriter
- .println("java.util.ArrayList<RpcMethod> list = new java.util.ArrayList<RpcMethod>();");
-
- // iterate over RPC interfaces and create helper methods for each
- // interface
- for (JClassType type : rpcInterfaceSubtypes) {
- if (null == type.isInterface()) {
- // only interested in interfaces here, not implementations
- continue;
- }
-
- // loop over the methods of the interface and its superinterfaces
- // methods
- for (JClassType currentType : type.getFlattenedSupertypeHierarchy()) {
- for (JMethod method : currentType.getMethods()) {
-
- // RpcMethod(String interfaceName, String methodName,
- // Type... parameterTypes)
- sourceWriter.print("list.add(new RpcMethod(\""
- + type.getQualifiedSourceName() + "\", \""
- + method.getName() + "\"");
- JType[] parameterTypes = method.getParameterTypes();
- for (JType parameter : parameterTypes) {
- sourceWriter.print(", ");
- writeTypeCreator(sourceWriter, parameter);
- }
- sourceWriter.println(") {");
- sourceWriter.indent();
-
- sourceWriter
- .println("public void applyInvocation(ClientRpc target, Object... parameters) {");
- sourceWriter.indent();
-
- sourceWriter.print("((" + type.getQualifiedSourceName()
- + ")target)." + method.getName() + "(");
- for (int i = 0; i < parameterTypes.length; i++) {
- JType parameterType = parameterTypes[i];
- if (i != 0) {
- sourceWriter.print(", ");
- }
- String parameterTypeName = getBoxedTypeName(parameterType);
- sourceWriter.print("(" + parameterTypeName
- + ") parameters[" + i + "]");
- }
- sourceWriter.println(");");
-
- sourceWriter.outdent();
- sourceWriter.println("}");
-
- sourceWriter.outdent();
- sourceWriter.println("});");
- }
- }
- }
-
- sourceWriter.println("return list;");
-
- sourceWriter.outdent();
- sourceWriter.println("}");
- sourceWriter.println();
-
- // close generated class
- sourceWriter.outdent();
- sourceWriter.println("}");
- // commit generated class
- context.commit(logger, printWriter);
- logger.log(Type.INFO,
- "Done. (" + (new Date().getTime() - date.getTime()) / 1000
- + "seconds)");
-
- }
-
- public static void writeTypeCreator(SourceWriter sourceWriter, JType type) {
- String typeName = getBoxedTypeName(type);
- sourceWriter.print("new Type(\"" + typeName + "\", ");
- JParameterizedType parameterized = type.isParameterized();
- if (parameterized != null) {
- sourceWriter.print("new Type[] {");
- JClassType[] typeArgs = parameterized.getTypeArgs();
- for (JClassType jClassType : typeArgs) {
- writeTypeCreator(sourceWriter, jClassType);
- sourceWriter.print(", ");
- }
- sourceWriter.print("}");
- } else {
- sourceWriter.print("null");
- }
- 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/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java
deleted file mode 100644
index eccc6461c9..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import java.io.PrintWriter;
-import java.util.Date;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
-import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.shared.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-import com.vaadin.terminal.gwt.client.communication.InitializableServerRpc;
-import com.vaadin.terminal.gwt.client.communication.RpcProxy.RpcProxyCreator;
-
-public class RpcProxyCreatorGenerator extends Generator {
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext ctx,
- String requestedClassName) throws UnableToCompleteException {
- logger.log(TreeLogger.DEBUG, "Running RpcProxyCreatorGenerator");
- TypeOracle typeOracle = ctx.getTypeOracle();
- assert (typeOracle != null);
-
- JClassType requestedType = typeOracle.findType(requestedClassName);
- if (requestedType == null) {
- logger.log(TreeLogger.ERROR, "Unable to find metadata for type '"
- + requestedClassName + "'", null);
- throw new UnableToCompleteException();
- }
- String packageName = requestedType.getPackage().getName();
- String className = requestedType.getSimpleSourceName() + "Impl";
-
- createType(logger, ctx, packageName, className);
- return packageName + "." + className;
- }
-
- private void createType(TreeLogger logger, GeneratorContext context,
- String packageName, String className) {
- ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
- packageName, className);
-
- PrintWriter printWriter = context.tryCreate(logger,
- composer.getCreatedPackage(),
- composer.getCreatedClassShortName());
- if (printWriter == null) {
- // print writer is null if source code has already been generated
- return;
- }
- Date date = new Date();
- TypeOracle typeOracle = context.getTypeOracle();
-
- // init composer, set class properties, create source writer
- composer.addImport(GWT.class.getCanonicalName());
- composer.addImport(ServerRpc.class.getCanonicalName());
- composer.addImport(ServerConnector.class.getCanonicalName());
- composer.addImport(InitializableServerRpc.class.getCanonicalName());
- composer.addImport(IllegalArgumentException.class.getCanonicalName());
- composer.addImplementedInterface(RpcProxyCreator.class
- .getCanonicalName());
-
- SourceWriter sourceWriter = composer.createSourceWriter(context,
- printWriter);
- sourceWriter.indent();
-
- sourceWriter
- .println("public <T extends ServerRpc> T create(Class<T> rpcInterface, ServerConnector connector) {");
- sourceWriter.indent();
-
- sourceWriter
- .println("if (rpcInterface == null || connector == null) {");
- sourceWriter.indent();
- sourceWriter
- .println("throw new IllegalArgumentException(\"RpcInterface and/or connector cannot be null\");");
- sourceWriter.outdent();
-
- JClassType initializableInterface = typeOracle.findType(ServerRpc.class
- .getCanonicalName());
-
- for (JClassType rpcType : initializableInterface.getSubtypes()) {
- String rpcClassName = rpcType.getQualifiedSourceName();
- if (InitializableServerRpc.class.getCanonicalName().equals(
- rpcClassName)) {
- // InitializableClientToServerRpc is a special marker interface
- // that should not get a generated class
- continue;
- }
- sourceWriter.println("} else if (rpcInterface == " + rpcClassName
- + ".class) {");
- sourceWriter.indent();
- sourceWriter.println(rpcClassName + " rpc = GWT.create("
- + rpcClassName + ".class);");
- sourceWriter.println("((" + InitializableServerRpc.class.getName()
- + ") rpc).initRpc(connector);");
- sourceWriter.println("return (T) rpc;");
- sourceWriter.outdent();
- }
-
- sourceWriter.println("} else {");
- sourceWriter.indent();
- sourceWriter
- .println("throw new IllegalArgumentException(\"No RpcInterface of type \"+ rpcInterface.getName() + \" was found.\");");
- sourceWriter.outdent();
- // End of if
- sourceWriter.println("}");
- // End of method
- sourceWriter.println("}");
-
- // close generated class
- sourceWriter.outdent();
- sourceWriter.println("}");
- // commit generated class
- context.commit(logger, printWriter);
- logger.log(Type.INFO, composer.getCreatedClassName() + " created in "
- + (new Date().getTime() - date.getTime()) / 1000 + "seconds");
-
- }
-}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java
deleted file mode 100644
index 6d322c734e..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import java.io.PrintWriter;
-
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.JClassType;
-import com.google.gwt.core.ext.typeinfo.JMethod;
-import com.google.gwt.core.ext.typeinfo.JParameter;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
-import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.shared.annotations.Delayed;
-import com.vaadin.shared.communication.MethodInvocation;
-import com.vaadin.shared.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-import com.vaadin.terminal.gwt.client.communication.InitializableServerRpc;
-
-/**
- * GWT generator that creates client side proxy classes for making RPC calls
- * from the client to the server.
- *
- * GWT.create() calls for interfaces extending {@link ServerRpc} are affected,
- * and a proxy implementation is created. Note that the init(...) method of the
- * proxy must be called before the proxy is used.
- *
- * @since 7.0
- */
-public class RpcProxyGenerator extends Generator {
- @Override
- public String generate(TreeLogger logger, GeneratorContext ctx,
- String requestedClassName) throws UnableToCompleteException {
- logger.log(TreeLogger.DEBUG, "Running RpcProxyGenerator", null);
-
- TypeOracle typeOracle = ctx.getTypeOracle();
- assert (typeOracle != null);
-
- JClassType requestedType = typeOracle.findType(requestedClassName);
- if (requestedType == null) {
- logger.log(TreeLogger.ERROR, "Unable to find metadata for type '"
- + requestedClassName + "'", null);
- throw new UnableToCompleteException();
- }
-
- String generatedClassName = "ServerRpc_"
- + requestedType.getName().replaceAll("[$.]", "_");
-
- JClassType initializableInterface = typeOracle
- .findType(InitializableServerRpc.class.getCanonicalName());
-
- ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
- requestedType.getPackage().getName(), generatedClassName);
- composer.addImplementedInterface(requestedType.getQualifiedSourceName());
- composer.addImplementedInterface(initializableInterface
- .getQualifiedSourceName());
- composer.addImport(MethodInvocation.class.getCanonicalName());
-
- PrintWriter printWriter = ctx.tryCreate(logger,
- composer.getCreatedPackage(),
- composer.getCreatedClassShortName());
- if (printWriter != null) {
- logger.log(Type.INFO, "Generating client proxy for RPC interface '"
- + requestedType.getQualifiedSourceName() + "'");
- SourceWriter writer = composer.createSourceWriter(ctx, printWriter);
-
- // constructor
- writer.println("public " + generatedClassName + "() {}");
-
- // initialization etc.
- writeCommonFieldsAndMethods(logger, writer, typeOracle);
-
- // actual proxy methods forwarding calls to the server
- writeRemoteProxyMethods(logger, writer, typeOracle, requestedType,
- requestedType.isClassOrInterface().getInheritableMethods());
-
- // End of class
- writer.outdent();
- writer.println("}");
-
- ctx.commit(logger, printWriter);
- }
-
- return composer.getCreatedClassName();
- }
-
- private void writeCommonFieldsAndMethods(TreeLogger logger,
- SourceWriter writer, TypeOracle typeOracle) {
- JClassType applicationConnectionClass = typeOracle
- .findType(ApplicationConnection.class.getCanonicalName());
-
- // fields
- writer.println("private " + ServerConnector.class.getName()
- + " connector;");
-
- // init method from the RPC interface
- writer.println("public void initRpc(" + ServerConnector.class.getName()
- + " connector) {");
- writer.indent();
- writer.println("this.connector = connector;");
- writer.outdent();
- writer.println("}");
- }
-
- private static void writeRemoteProxyMethods(TreeLogger logger,
- SourceWriter writer, TypeOracle typeOracle,
- JClassType requestedType, JMethod[] methods) {
- for (JMethod m : methods) {
- writer.print(m.getReadableDeclaration(false, false, false, false,
- true));
- writer.println(" {");
- writer.indent();
-
- Delayed delayedAnnotation = m.getAnnotation(Delayed.class);
- boolean delayed = delayedAnnotation != null;
- boolean lastonly = delayed && delayedAnnotation.lastonly();
-
- writer.print("this.connector.getConnection().addMethodInvocationToQueue(new MethodInvocation(this.connector.getConnectorId(), \""
- + requestedType.getQualifiedBinaryName() + "\", \"");
- writer.print(m.getName());
- writer.print("\", new Object[] {");
- // new Object[] { ... } for parameters - autoboxing etc. by the
- // compiler
- JParameter[] parameters = m.getParameters();
- boolean first = true;
- for (JParameter p : parameters) {
- if (!first) {
- writer.print(", ");
- }
- first = false;
-
- writer.print(p.getName());
- }
- writer.println("}), " + delayed + ", " + lastonly + ");");
-
- writer.outdent();
- writer.println("}");
- }
- }
-}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
deleted file mode 100644
index cc92551846..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.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.JPackage;
-import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
-import com.google.gwt.core.ext.typeinfo.JType;
-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;
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
-import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.communication.DiffJSONSerializer;
-import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
-import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
-import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
-import com.vaadin.terminal.gwt.client.communication.SerializerMap;
-
-/**
- * GWT generator for creating serializer classes for custom classes sent from
- * server to client.
- *
- * Only fields with a correspondingly named setter are deserialized.
- *
- * @since 7.0
- */
-public class SerializerGenerator extends Generator {
-
- private static final String SUBTYPE_SEPARATOR = "___";
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context,
- 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, type,
- getSerializerPackageName(type), serializerClassName);
- } catch (Exception e) {
- logger.log(TreeLogger.ERROR, "SerializerGenerator failed for "
- + type.getQualifiedSourceName(), e);
- throw new UnableToCompleteException();
- }
-
- // return the fully qualifed name of the class generated
- return getFullyQualifiedSerializerClassName(type);
- }
-
- /**
- * Generate source code for a VaadinSerializer implementation.
- *
- * @param logger
- * Logger object
- * @param context
- * Generator context
- * @param type
- * @param beanTypeName
- * bean type for which the serializer is to be generated
- * @param beanSerializerTypeName
- * name of the serializer class to generate
- * @throws UnableToCompleteException
- */
- private void generateClass(TreeLogger logger, GeneratorContext context,
- JClassType type, String serializerPackageName,
- String serializerClassName) throws UnableToCompleteException {
- // get print writer that receives the source code
- PrintWriter printWriter = null;
- printWriter = context.tryCreate(logger, serializerPackageName,
- serializerClassName);
-
- // print writer if null, source code has ALREADY been generated
- if (printWriter == null) {
- return;
- }
- boolean isEnum = (type.isEnum() != null);
- boolean isArray = (type.isArray() != null);
-
- String qualifiedSourceName = type.getQualifiedSourceName();
- logger.log(Type.DEBUG, "Processing serializable type "
- + qualifiedSourceName + "...");
-
- // init composer, set class properties, create source writer
- ClassSourceFileComposerFactory composer = null;
- composer = new ClassSourceFileComposerFactory(serializerPackageName,
- serializerClassName);
- composer.addImport(GWT.class.getName());
- composer.addImport(JSONValue.class.getName());
- composer.addImport(com.vaadin.terminal.gwt.client.communication.Type.class
- .getName());
- // composer.addImport(JSONObject.class.getName());
- // composer.addImport(VPaintableMap.class.getName());
- composer.addImport(JsonDecoder.class.getName());
- // composer.addImport(VaadinSerializer.class.getName());
-
- if (isEnum || isArray) {
- composer.addImplementedInterface(JSONSerializer.class.getName()
- + "<" + qualifiedSourceName + ">");
- } else {
- composer.addImplementedInterface(DiffJSONSerializer.class.getName()
- + "<" + qualifiedSourceName + ">");
- }
-
- SourceWriter sourceWriter = composer.createSourceWriter(context,
- printWriter);
- sourceWriter.indent();
-
- // Serializer
-
- // public JSONValue serialize(Object value,
- // ApplicationConnection connection) {
- sourceWriter.println("public " + JSONValue.class.getName()
- + " serialize(" + qualifiedSourceName + " value, "
- + ApplicationConnection.class.getName() + " connection) {");
- sourceWriter.indent();
- // MouseEventDetails castedValue = (MouseEventDetails) value;
- sourceWriter.println(qualifiedSourceName + " castedValue = ("
- + qualifiedSourceName + ") value;");
-
- if (isEnum) {
- writeEnumSerializer(logger, sourceWriter, type);
- } else if (isArray) {
- writeArraySerializer(logger, sourceWriter, type.isArray());
- } else {
- writeBeanSerializer(logger, sourceWriter, type);
- }
- // }
- sourceWriter.outdent();
- sourceWriter.println("}");
- sourceWriter.println();
-
- // Updater
- // public void update(T target, Type type, JSONValue jsonValue,
- // ApplicationConnection 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, type);
-
- sourceWriter.outdent();
- sourceWriter.println("}");
- }
-
- // Deserializer
- // T deserialize(Type type, JSONValue jsonValue, ApplicationConnection
- // connection);
- sourceWriter.println("public " + qualifiedSourceName
- + " deserialize(Type type, " + JSONValue.class.getName()
- + " jsonValue, " + ApplicationConnection.class.getName()
- + " connection) {");
- sourceWriter.indent();
-
- if (isEnum) {
- writeEnumDeserializer(logger, sourceWriter, type.isEnum());
- } else if (isArray) {
- writeArrayDeserializer(logger, sourceWriter, type.isArray());
- } else {
- sourceWriter.println(qualifiedSourceName + " target = GWT.create("
- + qualifiedSourceName + ".class);");
- sourceWriter
- .println("update(target, type, jsonValue, connection);");
- // return target;
- sourceWriter.println("return target;");
- }
- sourceWriter.outdent();
- sourceWriter.println("}");
-
- // End of class
- sourceWriter.outdent();
- sourceWriter.println("}");
-
- // commit generated class
- context.commit(logger, printWriter);
- logger.log(TreeLogger.INFO, "Generated Serializer class "
- + getFullyQualifiedSerializerClassName(type));
- }
-
- private void writeEnumDeserializer(TreeLogger logger,
- SourceWriter sourceWriter, JEnumType enumType) {
- sourceWriter.println("String enumIdentifier = (("
- + JSONString.class.getName() + ")jsonValue).stringValue();");
- for (JEnumConstant e : enumType.getEnumConstants()) {
- sourceWriter.println("if (\"" + e.getName()
- + "\".equals(enumIdentifier)) {");
- sourceWriter.indent();
- sourceWriter.println("return " + enumType.getQualifiedSourceName()
- + "." + e.getName() + ";");
- sourceWriter.outdent();
- sourceWriter.println("}");
- }
- 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();
-
- // JSONOBject json = (JSONObject)jsonValue;
- sourceWriter.println(JSONObject.class.getName() + " json = ("
- + JSONObject.class.getName() + ")jsonValue;");
-
- for (JMethod method : getSetters(beanType)) {
- String setterName = method.getName();
- String baseName = setterName.substring(3);
- String fieldName = getTransportFieldName(baseName); // setZIndex()
- // -> zIndex
- JType setterParameterType = method.getParameterTypes()[0];
-
- logger.log(Type.DEBUG, "* Processing field " + fieldName + " in "
- + beanQualifiedSourceName + " (" + beanType.getName() + ")");
-
- // if (json.containsKey("height")) {
- sourceWriter.println("if (json.containsKey(\"" + fieldName
- + "\")) {");
- sourceWriter.indent();
- String jsonFieldName = "json_" + fieldName;
- // JSONValue json_Height = json.get("height");
- sourceWriter.println("JSONValue " + jsonFieldName
- + " = json.get(\"" + fieldName + "\");");
-
- String fieldType;
- String getterName = "get" + baseName;
- JPrimitiveType primitiveType = setterParameterType.isPrimitive();
- if (primitiveType != null) {
- // This is a primitive type -> must used the boxed type
- fieldType = primitiveType.getQualifiedBoxedSourceName();
- if (primitiveType == JPrimitiveType.BOOLEAN) {
- getterName = "is" + baseName;
- }
- } else {
- fieldType = setterParameterType.getQualifiedSourceName();
- }
-
- // String referenceValue = target.getHeight();
- sourceWriter.println(fieldType + " referenceValue = target."
- + getterName + "();");
-
- // target.setHeight((String)
- // JsonDecoder.decodeValue(jsonFieldValue,referenceValue, idMapper,
- // connection));
- sourceWriter.print("target." + setterName + "((" + fieldType + ") "
- + JsonDecoder.class.getName() + ".decodeValue(");
- GeneratedRpcMethodProviderGenerator.writeTypeCreator(sourceWriter,
- setterParameterType);
- sourceWriter.println(", " + jsonFieldName
- + ", referenceValue, connection));");
-
- // } ... end of if contains
- sourceWriter.outdent();
- sourceWriter.println("}");
- }
- }
-
- private void writeEnumSerializer(TreeLogger logger,
- SourceWriter sourceWriter, JClassType beanType) {
- // return new JSONString(castedValue.name());
- sourceWriter.println("return new " + JSONString.class.getName()
- + "(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 {
-
- // JSONObject json = new JSONObject();
- sourceWriter.println(JSONObject.class.getName() + " json = new "
- + JSONObject.class.getName() + "();");
-
- HashSet<String> usedFieldNames = new HashSet<String>();
-
- for (JMethod setterMethod : getSetters(beanType)) {
- String setterName = setterMethod.getName();
- String fieldName = getTransportFieldName(setterName.substring(3)); // setZIndex()
- // -> zIndex
- if (!usedFieldNames.add(fieldName)) {
- logger.log(
- TreeLogger.ERROR,
- "Can't encode "
- + beanType.getQualifiedSourceName()
- + " as it has multiple fields with the name "
- + fieldName.toLowerCase()
- + ". This can happen if only casing distinguishes one property name from another.");
- throw new UnableToCompleteException();
- }
- String getterName = findGetter(beanType, setterMethod);
-
- if (getterName == null) {
- logger.log(TreeLogger.ERROR, "No getter found for " + fieldName
- + ". Serialization will likely fail");
- }
- // json.put("button",
- // JsonEncoder.encode(castedValue.getButton(), false, idMapper,
- // connection));
- sourceWriter.println("json.put(\"" + fieldName + "\", "
- + JsonEncoder.class.getName() + ".encode(castedValue."
- + getterName + "(), false, connection));");
- }
- // return json;
- sourceWriter.println("return json;");
-
- }
-
- private static String getTransportFieldName(String baseName) {
- return Character.toLowerCase(baseName.charAt(0))
- + baseName.substring(1);
- }
-
- private String findGetter(JClassType beanType, JMethod setterMethod) {
- JType setterParameterType = setterMethod.getParameterTypes()[0];
- String fieldName = setterMethod.getName().substring(3);
- if (setterParameterType.getQualifiedSourceName().equals(
- boolean.class.getName())) {
- return "is" + fieldName;
- } else {
- return "get" + fieldName;
- }
- }
-
- /**
- * Returns a list of all setters found in the beanType or its parent class
- *
- * @param beanType
- * The type to check
- * @return A list of setter methods from the class and its parents
- */
- protected static List<JMethod> getSetters(JClassType beanType) {
-
- List<JMethod> setterMethods = new ArrayList<JMethod>();
-
- while (beanType != null
- && !beanType.getQualifiedSourceName().equals(
- Object.class.getName())) {
- for (JMethod method : beanType.getMethods()) {
- // Process all setters that have corresponding fields
- if (!method.isPublic() || method.isStatic()
- || !method.getName().startsWith("set")
- || method.getParameterTypes().length != 1) {
- // Not setter, skip to next method
- continue;
- }
- setterMethods.add(method);
- }
- beanType = beanType.getSuperclass();
- }
-
- return setterMethods;
- }
-
- private static String getSerializerSimpleClassName(JClassType beanType) {
- return getSimpleClassName(beanType) + "_Serializer";
- }
-
- 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(classType.getEnclosingType());
- String name = baseName + SUBTYPE_SEPARATOR
- + type.getSimpleSourceName();
- return name;
- }
- return type.getSimpleSourceName();
- }
-
- public static String getFullyQualifiedSerializerClassName(JClassType type) {
- return getSerializerPackageName(type) + "."
- + getSerializerSimpleClassName(type);
- }
-
- private static String getSerializerPackageName(JClassType type) {
- JPackage typePackage = type.getPackage();
- if (typePackage == null) {
- return SerializerMap.class.getPackage().getName();
- } else {
- String packageName = typePackage.getName();
- // Dev mode classloader gets unhappy for some java packages
- if (packageName.startsWith("java.")) {
- packageName = "com.vaadin." + packageName;
- }
- return packageName;
- }
- }
-}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
deleted file mode 100644
index 9e91763b9f..0000000000
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.widgetsetutils;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.gwt.core.ext.Generator;
-import com.google.gwt.core.ext.GeneratorContext;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.TreeLogger.Type;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.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;
-import com.google.gwt.core.ext.typeinfo.JType;
-import com.google.gwt.core.ext.typeinfo.NotFoundException;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.json.client.JSONValue;
-import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
-import com.google.gwt.user.rebind.SourceWriter;
-import com.vaadin.shared.communication.ClientRpc;
-import com.vaadin.shared.communication.ServerRpc;
-import com.vaadin.shared.communication.SharedState;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
-import com.vaadin.terminal.gwt.client.communication.SerializerMap;
-
-/**
- * GWT generator that creates a {@link SerializerMap} implementation (mapper
- * from type string to serializer instance) and serializer classes for all
- * subclasses of {@link SharedState}.
- *
- * @since 7.0
- */
-public class SerializerMapGenerator extends Generator {
-
- private static final String FAIL_IF_NOT_SERIALIZABLE = "vFailIfNotSerializable";
- private String packageName;
- private String className;
-
- @Override
- public String generate(TreeLogger logger, GeneratorContext context,
- String typeName) throws UnableToCompleteException {
-
- try {
- TypeOracle typeOracle = context.getTypeOracle();
- Set<JClassType> typesNeedingSerializers = findTypesNeedingSerializers(
- typeOracle, logger);
- checkForUnserializableTypes(typesNeedingSerializers, typeOracle,
- logger);
- Set<JClassType> typesWithExistingSerializers = findTypesWithExistingSerializers(
- typeOracle, logger);
- Set<JClassType> serializerMappings = new HashSet<JClassType>();
- serializerMappings.addAll(typesNeedingSerializers);
- serializerMappings.addAll(typesWithExistingSerializers);
- // get classType and save instance variables
- JClassType classType = typeOracle.getType(typeName);
- packageName = classType.getPackage().getName();
- className = classType.getSimpleSourceName() + "Impl";
- // Generate class source code for SerializerMapImpl
- generateSerializerMap(serializerMappings, logger, context);
-
- SerializerGenerator sg = new SerializerGenerator();
- for (JClassType type : typesNeedingSerializers) {
- sg.generate(logger, context, type.getQualifiedSourceName());
- }
- } catch (Exception e) {
- logger.log(TreeLogger.ERROR,
- "SerializerMapGenerator creation failed", e);
- throw new UnableToCompleteException();
- }
- // return the fully qualifed name of the class generated
- return packageName + "." + className;
- }
-
- /**
- * Emits a warning for all classes that are used in communication but do not
- * implement java.io.Serializable. Implementing java.io.Serializable is not
- * needed for communication but for the server side Application to be
- * serializable i.e. work in GAE for instance.
- *
- * @param typesNeedingSerializers
- * @param typeOracle
- * @param logger
- * @throws UnableToCompleteException
- */
- private void checkForUnserializableTypes(
- Set<JClassType> typesNeedingSerializers, TypeOracle typeOracle,
- TreeLogger logger) throws UnableToCompleteException {
- 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) {
- boolean abortCompile = "true".equals(System
- .getProperty(FAIL_IF_NOT_SERIALIZABLE));
- logger.log(
- abortCompile ? Type.ERROR : Type.WARN,
- type
- + " is used in RPC or shared state but does not implement "
- + Serializable.class.getName()
- + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type. "
- + "If the system property "
- + FAIL_IF_NOT_SERIALIZABLE
- + " is set to \"true\", this causes the compilation to fail instead of just emitting a warning.");
- if (abortCompile) {
- throw new UnableToCompleteException();
- }
- }
- }
- }
-
- private Set<JClassType> findTypesWithExistingSerializers(
- TypeOracle typeOracle, TreeLogger logger)
- throws UnableToCompleteException {
- JClassType serializerInterface = typeOracle
- .findType(JSONSerializer.class.getName());
- JType[] deserializeParamTypes = new JType[] {
- typeOracle
- .findType(com.vaadin.terminal.gwt.client.communication.Type.class
- .getName()),
- typeOracle.findType(JSONValue.class.getName()),
- typeOracle.findType(ApplicationConnection.class.getName()) };
- String deserializeMethodName = "deserialize";
- try {
- serializerInterface.getMethod(deserializeMethodName,
- deserializeParamTypes);
- } catch (NotFoundException e) {
- logger.log(Type.ERROR, "Could not find " + deserializeMethodName
- + " in " + serializerInterface);
- throw new UnableToCompleteException();
- }
-
- Set<JClassType> types = new HashSet<JClassType>();
- for (JClassType serializer : serializerInterface.getSubtypes()) {
- JMethod deserializeMethod = serializer.findMethod(
- deserializeMethodName, deserializeParamTypes);
- if (deserializeMethod == null) {
- logger.log(Type.DEBUG, "Could not find "
- + deserializeMethodName + " in " + serializer);
- continue;
- }
- JType returnType = deserializeMethod.getReturnType();
- logger.log(Type.DEBUG, "Found " + deserializeMethodName
- + " with return type " + returnType + " in " + serializer);
-
- types.add(returnType.isClass());
- }
- return types;
- }
-
- /**
- * Generate source code for SerializerMapImpl
- *
- * @param typesNeedingSerializers
- *
- * @param logger
- * Logger object
- * @param context
- * Generator context
- */
- private void generateSerializerMap(Set<JClassType> typesNeedingSerializers,
- TreeLogger logger, GeneratorContext context) {
- // get print writer that receives the source code
- PrintWriter printWriter = null;
- printWriter = context.tryCreate(logger, packageName, className);
- // print writer if null, source code has ALREADY been generated
- if (printWriter == null) {
- return;
- }
- Date date = new Date();
- TypeOracle typeOracle = context.getTypeOracle();
-
- // init composer, set class properties, create source writer
- ClassSourceFileComposerFactory composer = null;
- composer = new ClassSourceFileComposerFactory(packageName, className);
- composer.addImport("com.google.gwt.core.client.GWT");
- composer.addImplementedInterface(SerializerMap.class.getName());
- SourceWriter sourceWriter = composer.createSourceWriter(context,
- printWriter);
- sourceWriter.indent();
-
- sourceWriter.println("public " + JSONSerializer.class.getName()
- + " getSerializer(String type) {");
- sourceWriter.indent();
-
- // TODO cache serializer instances in a map
- for (JClassType type : typesNeedingSerializers) {
- 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);
- sourceWriter.println("return GWT.create(" + serializerName
- + ".class);");
- sourceWriter.outdent();
- sourceWriter.println("}");
- logger.log(Type.INFO, "Configured serializer (" + serializerName
- + ") for " + type.getName());
- }
- sourceWriter
- .println("throw new RuntimeException(\"No serializer found for class \"+type);");
- sourceWriter.outdent();
- sourceWriter.println("}");
-
- // close generated class
- sourceWriter.outdent();
- sourceWriter.println("}");
- // commit generated class
- context.commit(logger, printWriter);
- logger.log(Type.INFO,
- "Done. (" + (new Date().getTime() - date.getTime()) / 1000
- + "seconds)");
-
- }
-
- public Set<JClassType> findTypesNeedingSerializers(TypeOracle typeOracle,
- TreeLogger logger) {
- logger.log(Type.DEBUG, "Detecting serializable data types...");
-
- HashSet<JClassType> types = new HashSet<JClassType>();
-
- // Generate serializer classes for each subclass of SharedState
- JClassType serializerType = typeOracle.findType(SharedState.class
- .getName());
- types.add(serializerType);
- JClassType[] serializerSubtypes = serializerType.getSubtypes();
- for (JClassType type : serializerSubtypes) {
- types.add(type);
- }
-
- // Serializer classes might also be needed for RPC methods
- for (Class<?> cls : new Class[] { ServerRpc.class, ClientRpc.class }) {
- JClassType rpcType = typeOracle.findType(cls.getName());
- JClassType[] serverRpcSubtypes = rpcType.getSubtypes();
- for (JClassType type : serverRpcSubtypes) {
- addMethodParameterTypes(type, types, logger);
- }
- }
-
- // Add all types used from/in the types
- for (Object t : types.toArray()) {
- findSubTypesNeedingSerializers((JClassType) t, types);
- }
- logger.log(Type.DEBUG, "Serializable data types: " + types.toString());
-
- return types;
- }
-
- private void addMethodParameterTypes(JClassType classContainingMethods,
- Set<JClassType> types, TreeLogger logger) {
- for (JMethod method : classContainingMethods.getMethods()) {
- if (method.getName().equals("initRpc")) {
- continue;
- }
- for (JType type : method.getParameterTypes()) {
- addTypeIfNeeded(types, type);
- }
- }
- }
-
- public void findSubTypesNeedingSerializers(JClassType type,
- Set<JClassType> serializableTypes) {
- // Find all setters and look at their parameter type to determine if a
- // new serializer is needed
- for (JMethod setterMethod : SerializerGenerator.getSetters(type)) {
- // The one and only parameter for the setter
- JType setterType = setterMethod.getParameterTypes()[0];
- addTypeIfNeeded(serializableTypes, setterType);
- }
- }
-
- private void addTypeIfNeeded(Set<JClassType> serializableTypes, JType type) {
- if (serializableTypes.contains(type)) {
- return;
- }
- JParameterizedType parametrized = type.isParameterized();
- if (parametrized != null) {
- for (JClassType parameterType : parametrized.getTypeArgs()) {
- addTypeIfNeeded(serializableTypes, parameterType);
- }
- }
-
- if (serializationHandledByFramework(type)) {
- return;
- }
-
- if (serializableTypes.contains(type)) {
- return;
- }
-
- JClassType typeClass = type.isClass();
- if (typeClass != null) {
- // setterTypeClass is null at least for List<String>. It is
- // possible that we need to handle the cases somehow, for
- // instance for List<MyObject>.
- 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<?>>();
- {
- frameworkHandledTypes.add(String.class);
- frameworkHandledTypes.add(Boolean.class);
- frameworkHandledTypes.add(Integer.class);
- frameworkHandledTypes.add(Float.class);
- frameworkHandledTypes.add(Double.class);
- frameworkHandledTypes.add(Long.class);
- frameworkHandledTypes.add(Enum.class);
- frameworkHandledTypes.add(String[].class);
- frameworkHandledTypes.add(Object[].class);
- 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.isPrimitive() != null) {
- return true;
- }
-
- String qualifiedName = setterType.getQualifiedSourceName();
- for (Class<?> cls : frameworkHandledTypes) {
- if (qualifiedName.equals(cls.getName())) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java
new file mode 100644
index 0000000000..1c729e9841
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JArrayType;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
+import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
+import com.vaadin.terminal.gwt.widgetsetutils.ConnectorBundleLoaderFactory;
+
+public class ArraySerializer extends JsonSerializer {
+
+ private final JArrayType arrayType;
+
+ public ArraySerializer(JArrayType arrayType) {
+ super(arrayType);
+ this.arrayType = arrayType;
+ }
+
+ @Override
+ protected void printDeserializerBody(TreeLogger logger, SourceWriter w,
+ String type, String jsonValue, String connection) {
+ JType leafType = arrayType.getLeafType();
+ int rank = arrayType.getRank();
+
+ w.println(JSONArray.class.getName() + " jsonArray = " + jsonValue
+ + ".isArray();");
+
+ // Type value = new Type[jsonArray.size()][][];
+ w.print(arrayType.getQualifiedSourceName() + " value = new "
+ + leafType.getQualifiedSourceName() + "[jsonArray.size()]");
+ for (int i = 1; i < rank; i++) {
+ w.print("[]");
+ }
+ w.println(";");
+
+ w.println("for(int i = 0 ; i < value.length; i++) {");
+ w.indent();
+
+ JType componentType = arrayType.getComponentType();
+
+ w.print("value[i] = ("
+ + ConnectorBundleLoaderFactory.getBoxedTypeName(componentType)
+ + ") " + JsonDecoder.class.getName() + ".decodeValue(");
+ ConnectorBundleLoaderFactory.writeTypeCreator(w, componentType);
+ w.print(", jsonArray.get(i), null, " + connection + ")");
+
+ w.println(";");
+
+ w.outdent();
+ w.println("}");
+
+ w.println("return value;");
+ }
+
+ @Override
+ protected void printSerializerBody(TreeLogger logger, SourceWriter w,
+ String value, String applicationConnection) {
+ w.println(JSONArray.class.getName() + " values = new "
+ + JSONArray.class.getName() + "();");
+ // JPrimitiveType primitive = componentType.isPrimitive();
+ w.println("for (int i = 0; i < " + value + ".length; i++) {");
+ w.indent();
+ w.print("values.set(i, ");
+ w.print(JsonEncoder.class.getName() + ".encode(" + value
+ + "[i], false, " + applicationConnection + ")");
+ w.println(");");
+ w.outdent();
+ w.println("}");
+ w.println("return values;");
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java
new file mode 100644
index 0000000000..d5a78b86b9
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import java.util.Set;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JType;
+
+public class ClientRpcVisitor extends TypeVisitor {
+ @Override
+ public void visitClientRpc(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ Set<? extends JClassType> hierarchy = type
+ .getFlattenedSupertypeHierarchy();
+ for (JClassType subType : hierarchy) {
+ JMethod[] methods = subType.getMethods();
+ for (JMethod method : methods) {
+ bundle.setNeedsInvoker(type, method);
+ bundle.setNeedsParamTypes(type, method);
+
+ JType[] parameterTypes = method.getParameterTypes();
+ for (JType paramType : parameterTypes) {
+ bundle.setNeedsSerialize(paramType);
+ }
+ }
+ }
+ }
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java
new file mode 100644
index 0000000000..7515124a5a
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java
@@ -0,0 +1,588 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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.JEnumType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JParameterizedType;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.json.client.JSONValue;
+import com.vaadin.shared.communication.ClientRpc;
+import com.vaadin.shared.communication.ServerRpc;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
+
+public class ConnectorBundle {
+ private static final String FAIL_IF_NOT_SERIALIZABLE = "vFailIfNotSerializable";
+
+ private final String name;
+ private final ConnectorBundle previousBundle;
+ private final Collection<TypeVisitor> visitors;
+ private final Map<JType, JClassType> customSerializers;
+
+ private final Set<JType> hasSerializeSupport = new HashSet<JType>();
+ private final Set<JType> needsSerializeSupport = new HashSet<JType>();
+ private final Map<JType, GeneratedSerializer> serializers = new HashMap<JType, GeneratedSerializer>();
+
+ private final Set<JClassType> needsPropertyList = new HashSet<JClassType>();
+ private final Set<JClassType> needsGwtConstructor = new HashSet<JClassType>();
+ private final Set<JClassType> visitedTypes = new HashSet<JClassType>();
+ private final Set<JClassType> needsProxySupport = new HashSet<JClassType>();
+
+ private final Map<JClassType, Set<String>> identifiers = new HashMap<JClassType, Set<String>>();
+ private final Map<JClassType, Set<JMethod>> needsReturnType = new HashMap<JClassType, Set<JMethod>>();
+ private final Map<JClassType, Set<JMethod>> needsInvoker = new HashMap<JClassType, Set<JMethod>>();
+ private final Map<JClassType, Set<JMethod>> needsParamTypes = new HashMap<JClassType, Set<JMethod>>();
+ private final Map<JClassType, Set<JMethod>> needsDelayedInfo = new HashMap<JClassType, Set<JMethod>>();
+
+ private final Set<Property> needsSetter = new HashSet<Property>();
+ private final Set<Property> needsType = new HashSet<Property>();
+ private final Set<Property> needsGetter = new HashSet<Property>();
+
+ private ConnectorBundle(String name, ConnectorBundle previousBundle,
+ Collection<TypeVisitor> visitors,
+ Map<JType, JClassType> customSerializers) {
+ this.name = name;
+ this.previousBundle = previousBundle;
+ this.visitors = visitors;
+ this.customSerializers = customSerializers;
+ }
+
+ public ConnectorBundle(String name, ConnectorBundle previousBundle) {
+ this(name, previousBundle, previousBundle.visitors,
+ previousBundle.customSerializers);
+ }
+
+ public ConnectorBundle(String name, Collection<TypeVisitor> visitors,
+ TypeOracle oracle) throws NotFoundException {
+ this(name, null, visitors, findCustomSerializers(oracle));
+ }
+
+ private static Map<JType, JClassType> findCustomSerializers(
+ TypeOracle oracle) throws NotFoundException {
+ Map<JType, JClassType> serializers = new HashMap<JType, JClassType>();
+
+ JClassType serializerInterface = oracle.findType(JSONSerializer.class
+ .getName());
+ JType[] deserializeParamTypes = new JType[] {
+ oracle.findType(com.vaadin.terminal.gwt.client.metadata.Type.class
+ .getName()),
+ oracle.findType(JSONValue.class.getName()),
+ oracle.findType(ApplicationConnection.class.getName()) };
+ String deserializeMethodName = "deserialize";
+ // Just test that the method exists
+ serializerInterface.getMethod(deserializeMethodName,
+ deserializeParamTypes);
+
+ for (JClassType serializer : serializerInterface.getSubtypes()) {
+ JMethod deserializeMethod = serializer.findMethod(
+ deserializeMethodName, deserializeParamTypes);
+ if (deserializeMethod == null) {
+ continue;
+ }
+ JType returnType = deserializeMethod.getReturnType();
+
+ serializers.put(returnType, serializer);
+ }
+ return serializers;
+ }
+
+ public void setNeedsGwtConstructor(JClassType type) {
+ if (!needsGwtConstructor(type)) {
+ needsGwtConstructor.add(type);
+ }
+ }
+
+ private boolean needsGwtConstructor(JClassType type) {
+ if (needsGwtConstructor.contains(type)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.needsGwtConstructor(type);
+ }
+ }
+
+ public void setIdentifier(JClassType type, String identifier) {
+ if (!hasIdentifier(type, identifier)) {
+ addMapping(identifiers, type, identifier);
+ }
+ }
+
+ private boolean hasIdentifier(JClassType type, String identifier) {
+ if (hasMapping(identifiers, type, identifier)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.hasIdentifier(type, identifier);
+ }
+ }
+
+ public ConnectorBundle getPreviousBundle() {
+ return previousBundle;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Map<JClassType, Set<String>> getIdentifiers() {
+ return Collections.unmodifiableMap(identifiers);
+ }
+
+ public Set<JClassType> getGwtConstructors() {
+ return Collections.unmodifiableSet(needsGwtConstructor);
+ }
+
+ public void processTypes(TreeLogger logger, Collection<JClassType> types)
+ throws UnableToCompleteException {
+ for (JClassType type : types) {
+ processType(logger, type);
+ }
+ }
+
+ public void processType(TreeLogger logger, JClassType type)
+ throws UnableToCompleteException {
+ if (!isTypeVisited(type)) {
+ for (TypeVisitor typeVisitor : visitors) {
+ invokeVisitor(logger, type, typeVisitor);
+ }
+ visitedTypes.add(type);
+ purgeSerializeSupportQueue(logger);
+ }
+ }
+
+ private boolean isTypeVisited(JClassType type) {
+ if (visitedTypes.contains(type)) {
+ return true;
+ } else {
+ return previousBundle != null && previousBundle.isTypeVisited(type);
+ }
+ }
+
+ private void purgeSerializeSupportQueue(TreeLogger logger)
+ throws UnableToCompleteException {
+ while (!needsSerializeSupport.isEmpty()) {
+ Iterator<JType> iterator = needsSerializeSupport.iterator();
+ JType type = iterator.next();
+ iterator.remove();
+
+ if (hasSserializeSupport(type)) {
+ continue;
+ }
+
+ addSerializeSupport(logger, type);
+ }
+ }
+
+ private void addSerializeSupport(TreeLogger logger, JType type)
+ throws UnableToCompleteException {
+ hasSerializeSupport.add(type);
+
+ JParameterizedType parametrized = type.isParameterized();
+ if (parametrized != null) {
+ for (JClassType parameterType : parametrized.getTypeArgs()) {
+ setNeedsSerialize(parameterType);
+ }
+ }
+
+ if (serializationHandledByFramework(type)) {
+ return;
+ }
+
+ JClassType customSerializer = customSerializers.get(type);
+ JClassType typeAsClass = type.isClass();
+ JEnumType enumType = type.isEnum();
+ JArrayType arrayType = type.isArray();
+
+ if (customSerializer != null) {
+ logger.log(Type.INFO, "Will serialize " + type + " using "
+ + customSerializer.getName());
+ setSerializer(type, new CustomSerializer(customSerializer));
+ } else if (arrayType != null) {
+ logger.log(Type.INFO, "Will serialize " + type + " as an array");
+ setSerializer(type, new ArraySerializer(arrayType));
+ setNeedsSerialize(arrayType.getComponentType());
+ } else if (enumType != null) {
+ logger.log(Type.INFO, "Will serialize " + type + " as an enum");
+ setSerializer(type, new EnumSerializer(enumType));
+ } else if (typeAsClass != null) {
+ // Bean
+ checkSerializable(logger, typeAsClass);
+
+ logger.log(Type.INFO, "Will serialize " + type + " as a bean");
+
+ setNeedsPropertyList(typeAsClass);
+
+ for (Property property : getProperties(typeAsClass)) {
+ setNeedsGwtConstructor(property.getBeanType());
+ setNeedsSetter(property);
+
+ // Getters needed for reading previous value that should be
+ // passed to sub encoder
+ setNeedsGetter(property);
+ setNeedsType(property);
+
+ JType propertyType = property.getPropertyType();
+ setNeedsSerialize(propertyType);
+ }
+ }
+ }
+
+ private void checkSerializable(TreeLogger logger, JClassType type)
+ throws UnableToCompleteException {
+ JClassType javaSerializable = type.getOracle().findType(
+ Serializable.class.getName());
+ boolean serializable = type.isAssignableTo(javaSerializable);
+ if (!serializable) {
+ boolean abortCompile = "true".equals(System
+ .getProperty(FAIL_IF_NOT_SERIALIZABLE));
+ logger.log(
+ abortCompile ? Type.ERROR : Type.WARN,
+ type
+ + " is used in RPC or shared state but does not implement "
+ + Serializable.class.getName()
+ + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type. "
+ + "If the system property "
+ + FAIL_IF_NOT_SERIALIZABLE
+ + " is set to \"true\", this causes the compilation to fail instead of just emitting a warning.");
+ if (abortCompile) {
+ throw new UnableToCompleteException();
+ }
+ }
+ }
+
+ private void setSerializer(JType type, GeneratedSerializer serializer) {
+ if (!hasSerializer(type)) {
+ serializers.put(type, serializer);
+ }
+ }
+
+ private boolean hasSerializer(JType type) {
+ if (serializers.containsKey(type)) {
+ return true;
+ } else {
+ return previousBundle != null && previousBundle.hasSerializer(type);
+ }
+ }
+
+ public Map<JType, GeneratedSerializer> getSerializers() {
+ return Collections.unmodifiableMap(serializers);
+ }
+
+ private void setNeedsGetter(Property property) {
+ if (!isNeedsGetter(property)) {
+ needsGetter.add(property);
+ }
+ }
+
+ private boolean isNeedsGetter(Property property) {
+ if (needsGetter.contains(property)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsGetter(property);
+ }
+ }
+
+ public Set<Property> getNeedsGetter() {
+ return Collections.unmodifiableSet(needsGetter);
+ }
+
+ private void setNeedsType(Property property) {
+ if (!isNeedsType(property)) {
+ needsType.add(property);
+ }
+ }
+
+ public Set<Property> getNeedsType() {
+ return Collections.unmodifiableSet(needsType);
+ }
+
+ private boolean isNeedsType(Property property) {
+ if (needsType.contains(property)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsType(property);
+ }
+ }
+
+ public void setNeedsSetter(Property property) {
+ if (!isNeedsSetter(property)) {
+ needsSetter.add(property);
+ }
+ }
+
+ private boolean isNeedsSetter(Property property) {
+ if (needsSetter.contains(property)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsSetter(property);
+ }
+ }
+
+ public Set<Property> getNeedsSetter() {
+ return Collections.unmodifiableSet(needsSetter);
+ }
+
+ private void setNeedsPropertyList(JClassType type) {
+ if (!isNeedsPropertyList(type)) {
+ needsPropertyList.add(type);
+ }
+ }
+
+ private boolean isNeedsPropertyList(JClassType type) {
+ if (needsPropertyList.contains(type)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsPropertyList(type);
+ }
+ }
+
+ public Set<JClassType> getNeedsPropertyListing() {
+ return Collections.unmodifiableSet(needsPropertyList);
+ }
+
+ public Collection<Property> getProperties(JClassType type) {
+ HashSet<Property> properties = new HashSet<Property>();
+
+ properties.addAll(MethodProperty.findProperties(type));
+ properties.addAll(FieldProperty.findProperties(type));
+
+ return properties;
+ }
+
+ private void invokeVisitor(TreeLogger logger, JClassType type,
+ TypeVisitor typeVisitor) throws UnableToCompleteException {
+ TreeLogger subLogger = logger.branch(Type.TRACE,
+ "Visiting " + type.getName() + " with "
+ + typeVisitor.getClass().getSimpleName());
+ if (isConnectedConnector(type)) {
+ typeVisitor.visitConnector(subLogger, type, this);
+ }
+ if (isClientRpc(type)) {
+ typeVisitor.visitClientRpc(subLogger, type, this);
+ }
+ if (isServerRpc(type)) {
+ typeVisitor.visitServerRpc(subLogger, type, this);
+ }
+ }
+
+ public void processSubTypes(TreeLogger logger, JClassType type)
+ throws UnableToCompleteException {
+ processTypes(logger, Arrays.asList(type.getSubtypes()));
+ }
+
+ public void setNeedsReturnType(JClassType type, JMethod method) {
+ if (!isNeedsReturnType(type, method)) {
+ addMapping(needsReturnType, type, method);
+ }
+ }
+
+ private boolean isNeedsReturnType(JClassType type, JMethod method) {
+ if (hasMapping(needsReturnType, type, method)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsReturnType(type, method);
+ }
+ }
+
+ public Map<JClassType, Set<JMethod>> getMethodReturnTypes() {
+ return Collections.unmodifiableMap(needsReturnType);
+ }
+
+ private static boolean isClientRpc(JClassType type) {
+ return isType(type, ClientRpc.class);
+ }
+
+ private static boolean isServerRpc(JClassType type) {
+ return isType(type, ServerRpc.class);
+ }
+
+ public static boolean isConnectedConnector(JClassType type) {
+ return isConnected(type) && isType(type, ServerConnector.class);
+ }
+
+ private static boolean isConnected(JClassType type) {
+ return type.isAnnotationPresent(Connect.class);
+ }
+
+ public static boolean isConnectedComponentConnector(JClassType type) {
+ return isConnected(type) && isType(type, ComponentConnector.class);
+ }
+
+ private static boolean isType(JClassType type, Class<?> class1) {
+ try {
+ return type.getOracle().getType(class1.getName())
+ .isAssignableFrom(type);
+ } catch (NotFoundException e) {
+ throw new RuntimeException("Could not find " + class1.getName(), e);
+ }
+ }
+
+ public void setNeedsInvoker(JClassType type, JMethod method) {
+ if (!isNeedsInvoker(type, method)) {
+ addMapping(needsInvoker, type, method);
+ }
+ }
+
+ private <K, V> void addMapping(Map<K, Set<V>> map, K key, V value) {
+ Set<V> set = map.get(key);
+ if (set == null) {
+ set = new HashSet<V>();
+ map.put(key, set);
+ }
+ set.add(value);
+ }
+
+ private <K, V> boolean hasMapping(Map<K, Set<V>> map, K key, V value) {
+ return map.containsKey(key) && map.get(key).contains(value);
+ }
+
+ private boolean isNeedsInvoker(JClassType type, JMethod method) {
+ if (hasMapping(needsInvoker, type, method)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsInvoker(type, method);
+ }
+ }
+
+ public Map<JClassType, Set<JMethod>> getNeedsInvoker() {
+ return Collections.unmodifiableMap(needsInvoker);
+ }
+
+ public void setNeedsParamTypes(JClassType type, JMethod method) {
+ if (!isNeedsParamTypes(type, method)) {
+ addMapping(needsParamTypes, type, method);
+ }
+ }
+
+ private boolean isNeedsParamTypes(JClassType type, JMethod method) {
+ if (hasMapping(needsParamTypes, type, method)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsParamTypes(type, method);
+ }
+ }
+
+ public Map<JClassType, Set<JMethod>> getNeedsParamTypes() {
+ return Collections.unmodifiableMap(needsParamTypes);
+ }
+
+ public void setNeedsProxySupport(JClassType type) {
+ if (!isNeedsProxySupport(type)) {
+ needsProxySupport.add(type);
+ }
+ }
+
+ private boolean isNeedsProxySupport(JClassType type) {
+ if (needsProxySupport.contains(type)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsProxySupport(type);
+ }
+ }
+
+ public Set<JClassType> getNeedsProxySupport() {
+ return Collections.unmodifiableSet(needsProxySupport);
+ }
+
+ public void setNeedsDelayedInfo(JClassType type, JMethod method) {
+ if (!isNeedsDelayedInfo(type, method)) {
+ addMapping(needsDelayedInfo, type, method);
+ }
+ }
+
+ private boolean isNeedsDelayedInfo(JClassType type, JMethod method) {
+ if (hasMapping(needsDelayedInfo, type, method)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.isNeedsDelayedInfo(type, method);
+ }
+ }
+
+ public Map<JClassType, Set<JMethod>> getNeedsDelayedInfo() {
+ return Collections.unmodifiableMap(needsDelayedInfo);
+ }
+
+ public void setNeedsSerialize(JType type) {
+ if (!hasSserializeSupport(type)) {
+ needsSerializeSupport.add(type);
+ }
+ }
+
+ private static Set<Class<?>> frameworkHandledTypes = new HashSet<Class<?>>();
+ {
+ frameworkHandledTypes.add(String.class);
+ frameworkHandledTypes.add(Boolean.class);
+ frameworkHandledTypes.add(Integer.class);
+ frameworkHandledTypes.add(Float.class);
+ frameworkHandledTypes.add(Double.class);
+ frameworkHandledTypes.add(Long.class);
+ frameworkHandledTypes.add(Enum.class);
+ frameworkHandledTypes.add(String[].class);
+ frameworkHandledTypes.add(Object[].class);
+ 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.isPrimitive() != null) {
+ return true;
+ }
+
+ String qualifiedName = setterType.getQualifiedSourceName();
+ for (Class<?> cls : frameworkHandledTypes) {
+ if (qualifiedName.equals(cls.getName())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private boolean hasSserializeSupport(JType type) {
+ if (hasSerializeSupport.contains(type)) {
+ return true;
+ } else {
+ return previousBundle != null
+ && previousBundle.hasSserializeSupport(type);
+ }
+ }
+} \ No newline at end of file
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java
new file mode 100644
index 0000000000..09cdaddc31
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java
@@ -0,0 +1,24 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.TreeLogger.Type;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.vaadin.shared.ui.Connect;
+
+public class ConnectorInitVisitor extends TypeVisitor {
+
+ @Override
+ public void visitConnector(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ logger.log(Type.INFO, type.getName() + " will be in the "
+ + bundle.getName().replaceAll("^_*", "") + " bundle");
+ Connect connectAnnotation = type.getAnnotation(Connect.class);
+ bundle.setIdentifier(type, connectAnnotation.value().getCanonicalName());
+ bundle.setNeedsGwtConstructor(type);
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java
new file mode 100644
index 0000000000..11252c4acb
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.terminal.gwt.widgetsetutils.ConnectorBundleLoaderFactory;
+
+public class CustomSerializer implements GeneratedSerializer {
+
+ private final JClassType serializerType;
+
+ public CustomSerializer(JClassType serializerType) {
+ this.serializerType = serializerType;
+ }
+
+ @Override
+ public void writeSerializerInstantiator(TreeLogger logger, SourceWriter w)
+ throws UnableToCompleteException {
+ w.print("return ");
+ w.print(GWT.class.getCanonicalName());
+ w.print(".create(");
+ ConnectorBundleLoaderFactory.writeClassLiteral(w, serializerType);
+ w.println(");");
+ }
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java
new file mode 100644
index 0000000000..324b555300
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JEnumConstant;
+import com.google.gwt.core.ext.typeinfo.JEnumType;
+import com.google.gwt.json.client.JSONString;
+import com.google.gwt.user.rebind.SourceWriter;
+
+public class EnumSerializer extends JsonSerializer {
+
+ private final JEnumType enumType;
+
+ public EnumSerializer(JEnumType type) {
+ super(type);
+ enumType = type;
+ }
+
+ @Override
+ protected void printDeserializerBody(TreeLogger logger, SourceWriter w,
+ String type, String jsonValue, String connection) {
+ w.println("String enumIdentifier = ((" + JSONString.class.getName()
+ + ")" + jsonValue + ").stringValue();");
+ for (JEnumConstant e : enumType.getEnumConstants()) {
+ w.println("if (\"" + e.getName() + "\".equals(enumIdentifier)) {");
+ w.indent();
+ w.println("return " + enumType.getQualifiedSourceName() + "."
+ + e.getName() + ";");
+ w.outdent();
+ w.println("}");
+ }
+ w.println("return null;");
+ }
+
+ @Override
+ protected void printSerializerBody(TreeLogger logger, SourceWriter w,
+ String value, String applicationConnection) {
+ // return new JSONString(castedValue.name());
+ w.println("return new " + JSONString.class.getName() + "(" + value
+ + ".name());");
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java
new file mode 100644
index 0000000000..31555cc30b
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JField;
+import com.google.gwt.user.rebind.SourceWriter;
+
+public class FieldProperty extends Property {
+
+ private FieldProperty(JClassType beanType, JField field) {
+ super(field.getName(), beanType, field.getType());
+ }
+
+ @Override
+ public void writeSetterBody(TreeLogger logger, SourceWriter w,
+ String beanVariable, String valueVariable) {
+ w.print("((%s) %s).%s = (%s)%s;", getBeanType()
+ .getQualifiedSourceName(), beanVariable, getName(),
+ getUnboxedPropertyTypeName(), valueVariable);
+ }
+
+ @Override
+ public void writeGetterBody(TreeLogger logger, SourceWriter w,
+ String beanVariable) {
+ w.print("return ((%s) %s).%s;", getBeanType().getQualifiedSourceName(),
+ beanVariable, getName());
+ }
+
+ public static Collection<FieldProperty> findProperties(JClassType type) {
+ Collection<FieldProperty> properties = new ArrayList<FieldProperty>();
+
+ List<JField> fields = getPublicFields(type);
+ for (JField field : fields) {
+ properties.add(new FieldProperty(type, field));
+ }
+
+ return properties;
+ }
+
+ private static List<JField> getPublicFields(JClassType type) {
+ Set<String> names = new HashSet<String>();
+ ArrayList<JField> fields = new ArrayList<JField>();
+ for (JClassType subType : type.getFlattenedSupertypeHierarchy()) {
+ JField[] subFields = subType.getFields();
+ for (JField field : subFields) {
+ if (field.isPublic() && !field.isStatic()
+ && names.add(field.getName())) {
+ fields.add(field);
+ }
+ }
+ }
+ return fields;
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java
index e865dbc1b1..0cfde7748c 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -13,20 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.terminal.gwt.client.communication;
-import java.util.Collection;
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
-/**
- * Provides runtime data about client side RPC calls received from the server to
- * the client-side code.
- *
- * A GWT generator is used to create an implementation of this class at
- * run-time.
- *
- * @since 7.0
- */
-public interface GeneratedRpcMethodProvider {
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.user.rebind.SourceWriter;
- public Collection<RpcMethod> getGeneratedRpcMethods();
+public interface GeneratedSerializer {
+ public void writeSerializerInstantiator(TreeLogger logger, SourceWriter w)
+ throws UnableToCompleteException;
}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java
new file mode 100644
index 0000000000..accee84fe7
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.json.client.JSONValue;
+import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
+
+public abstract class JsonSerializer implements GeneratedSerializer {
+
+ private final JType type;
+
+ public JsonSerializer(JType type) {
+ this.type = type;
+ }
+
+ @Override
+ public void writeSerializerInstantiator(TreeLogger logger, SourceWriter w)
+ throws UnableToCompleteException {
+
+ w.print("return new ");
+ w.print(JSONSerializer.class.getCanonicalName());
+ w.print("<");
+ w.print(type.getQualifiedSourceName());
+ w.println(">() {");
+ w.indent();
+
+ writeSerializerBody(logger, w);
+
+ w.outdent();
+ w.println("};");
+ }
+
+ protected void writeSerializerBody(TreeLogger logger, SourceWriter w) {
+ String qualifiedSourceName = type.getQualifiedSourceName();
+ w.println("public " + JSONValue.class.getName() + " serialize("
+ + qualifiedSourceName + " value, "
+ + ApplicationConnection.class.getName() + " connection) {");
+ w.indent();
+ // MouseEventDetails castedValue = (MouseEventDetails) value;
+ w.println(qualifiedSourceName + " castedValue = ("
+ + qualifiedSourceName + ") value;");
+
+ printSerializerBody(logger, w, "castedValue", "connection");
+
+ // End of serializer method
+ w.outdent();
+ w.println("}");
+
+ // Deserializer
+ // T deserialize(Type type, JSONValue jsonValue, ApplicationConnection
+ // connection);
+ w.println("public " + qualifiedSourceName + " deserialize(Type type, "
+ + JSONValue.class.getName() + " jsonValue, "
+ + ApplicationConnection.class.getName() + " connection) {");
+ w.indent();
+
+ printDeserializerBody(logger, w, "type", "jsonValue", "connection");
+
+ w.outdent();
+ w.println("}");
+ }
+
+ protected abstract void printDeserializerBody(TreeLogger logger,
+ SourceWriter w, String type, String jsonValue, String connection);
+
+ protected abstract void printSerializerBody(TreeLogger logger,
+ SourceWriter w, String value, String applicationConnection);
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java
new file mode 100644
index 0000000000..f422205175
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.user.rebind.SourceWriter;
+
+public class MethodProperty extends Property {
+
+ private final JMethod setter;
+
+ private MethodProperty(JClassType beanType, JMethod setter) {
+ super(getTransportFieldName(setter), beanType, setter
+ .getParameterTypes()[0]);
+ this.setter = setter;
+ }
+
+ public static Collection<MethodProperty> findProperties(JClassType type) {
+ Collection<MethodProperty> properties = new ArrayList<MethodProperty>();
+
+ List<JMethod> setters = getSetters(type);
+ for (JMethod setter : setters) {
+ properties.add(new MethodProperty(type, setter));
+ }
+
+ return properties;
+ }
+
+ /**
+ * Returns a list of all setters found in the beanType or its parent class
+ *
+ * @param beanType
+ * The type to check
+ * @return A list of setter methods from the class and its parents
+ */
+ private static List<JMethod> getSetters(JClassType beanType) {
+ List<JMethod> setterMethods = new ArrayList<JMethod>();
+
+ while (beanType != null
+ && !beanType.getQualifiedSourceName().equals(
+ Object.class.getName())) {
+ for (JMethod method : beanType.getMethods()) {
+ // Process all setters that have corresponding fields
+ if (!method.isPublic() || method.isStatic()
+ || !method.getName().startsWith("set")
+ || method.getParameterTypes().length != 1) {
+ // Not setter, skip to next method
+ continue;
+ }
+ setterMethods.add(method);
+ }
+ beanType = beanType.getSuperclass();
+ }
+
+ return setterMethods;
+ }
+
+ @Override
+ public void writeSetterBody(TreeLogger logger, SourceWriter w,
+ String beanVariable, String valueVariable) {
+ w.print("((");
+ w.print(getBeanType().getQualifiedSourceName());
+ w.print(") ");
+ w.print(beanVariable);
+ w.print(").");
+ w.print(setter.getName());
+ w.print("((");
+ w.print(getUnboxedPropertyTypeName());
+ w.print(") ");
+ w.print(valueVariable);
+ w.println(");");
+ }
+
+ @Override
+ public void writeGetterBody(TreeLogger logger, SourceWriter w,
+ String beanVariable) {
+ w.print("return ((");
+ w.print(getBeanType().getQualifiedSourceName());
+ w.print(") ");
+ w.print(beanVariable);
+ w.print(").");
+ w.print(findGetter(getBeanType(), setter));
+ w.print("();");
+ }
+
+ private String findGetter(JClassType beanType, JMethod setterMethod) {
+ JType setterParameterType = setterMethod.getParameterTypes()[0];
+ String fieldName = setterMethod.getName().substring(3);
+ if (setterParameterType.getQualifiedSourceName().equals(
+ boolean.class.getName())) {
+ return "is" + fieldName;
+ } else {
+ return "get" + fieldName;
+ }
+ }
+
+ private static String getTransportFieldName(JMethod setter) {
+ String baseName = setter.getName().substring(3);
+ return Character.toLowerCase(baseName.charAt(0))
+ + baseName.substring(1);
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java
new file mode 100644
index 0000000000..1714489db5
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.user.rebind.SourceWriter;
+
+public abstract class Property {
+ private final String name;
+ private final JClassType beanType;
+ private final JType propertyType;
+
+ protected Property(String name, JClassType beanType, JType propertyType) {
+ this.name = name;
+ this.beanType = beanType;
+ this.propertyType = propertyType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public JType getPropertyType() {
+ return propertyType;
+ }
+
+ public String getUnboxedPropertyTypeName() {
+ JType propertyType = getPropertyType();
+ JPrimitiveType primitive = propertyType.isPrimitive();
+ if (primitive != null) {
+ return primitive.getQualifiedBoxedSourceName();
+ } else {
+ return propertyType.getQualifiedSourceName();
+ }
+ }
+
+ public JClassType getBeanType() {
+ return beanType;
+ }
+
+ public abstract void writeSetterBody(TreeLogger logger, SourceWriter w,
+ String beanVariable, String valueVariable);
+
+ public abstract void writeGetterBody(TreeLogger logger, SourceWriter w,
+ String beanVariable);
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ } else if (obj instanceof Property) {
+ Property other = (Property) obj;
+ return other.getClass() == getClass()
+ && other.getBeanType().equals(getBeanType())
+ && other.getName().equals(getName());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return getClass().hashCode() * 31 ^ 2 + getBeanType().hashCode() * 31
+ + getName().hashCode();
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java
new file mode 100644
index 0000000000..4c0fc94500
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import java.util.Set;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JType;
+
+public class ServerRpcVisitor extends TypeVisitor {
+ @Override
+ public void visitServerRpc(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ bundle.setNeedsProxySupport(type);
+
+ Set<? extends JClassType> superTypes = type
+ .getFlattenedSupertypeHierarchy();
+ for (JClassType subType : superTypes) {
+ if (subType.isInterface() != null) {
+ JMethod[] methods = subType.getMethods();
+ for (JMethod method : methods) {
+ bundle.setNeedsDelayedInfo(type, method);
+
+ JType[] parameterTypes = method.getParameterTypes();
+ for (JType paramType : parameterTypes) {
+ bundle.setNeedsSerialize(paramType);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java
new file mode 100644
index 0000000000..49cf687412
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java
@@ -0,0 +1,25 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JType;
+
+public class StateInitVisitor extends TypeVisitor {
+ @Override
+ public void visitConnector(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ JMethod getState = findInheritedMethod(type, "getState");
+ bundle.setNeedsReturnType(type, getState);
+
+ bundle.setNeedsSerialize(getState.getReturnType());
+
+ JType stateType = getState.getReturnType();
+ bundle.setNeedsGwtConstructor(stateType.isClass());
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java
new file mode 100644
index 0000000000..976eb6417a
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java
@@ -0,0 +1,57 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+
+public abstract class TypeVisitor {
+ public void init(TypeOracle oracle) throws NotFoundException {
+ // Default does nothing
+ }
+
+ public void visitConnector(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ // Default does nothing
+ }
+
+ public void visitClientRpc(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ // Default does nothing
+ }
+
+ public void visitServerRpc(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ // Default does nothing
+ }
+
+ protected JMethod findInheritedMethod(JClassType type, String methodName,
+ JType... params) {
+
+ JClassType currentType = type;
+ while (currentType != null) {
+ JMethod method = currentType.findMethod(methodName, params);
+ if (method != null) {
+ return method;
+ }
+ currentType = currentType.getSuperclass();
+ }
+
+ JClassType[] interfaces = type.getImplementedInterfaces();
+ for (JClassType iface : interfaces) {
+ JMethod method = iface.findMethod(methodName, params);
+ if (method != null) {
+ return method;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java
new file mode 100644
index 0000000000..4d63703151
--- /dev/null
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java
@@ -0,0 +1,36 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.widgetsetutils.metadata;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+
+public class WidgetInitVisitor extends TypeVisitor {
+
+ @Override
+ public void visitConnector(TreeLogger logger, JClassType type,
+ ConnectorBundle bundle) {
+ if (ConnectorBundle.isConnectedComponentConnector(type)) {
+ JClassType createWidgetClass = findInheritedMethod(type,
+ "createWidget").getEnclosingType();
+ boolean createWidgetOverridden = !createWidgetClass
+ .getQualifiedSourceName()
+ .equals(AbstractComponentConnector.class.getCanonicalName());
+ if (createWidgetOverridden) {
+ // Don't generate if createWidget is already overridden
+ return;
+ }
+
+ JMethod getWidget = findInheritedMethod(type, "getWidget");
+ bundle.setNeedsReturnType(type, getWidget);
+
+ JType widgetType = getWidget.getReturnType();
+ bundle.setNeedsGwtConstructor(widgetType.isClass());
+ }
+ }
+}
diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml
index 07d7c941e6..44357b24a0 100644
--- a/client/src/com/vaadin/Vaadin.gwt.xml
+++ b/client/src/com/vaadin/Vaadin.gwt.xml
@@ -23,60 +23,18 @@
<when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" />
</replace-with>
- <!-- Generators for serializators for classes used in communication between
- server and client -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.SerializerMapGenerator">
- <when-type-is
- class="com.vaadin.terminal.gwt.client.communication.SerializerMap" />
- </generate-with>
-
<replace-with class="com.vaadin.terminal.gwt.client.VDebugConsole">
<when-type-is class="com.vaadin.terminal.gwt.client.Console" />
</replace-with>
<generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator">
- <when-type-is class="com.vaadin.terminal.gwt.client.WidgetMap" />
- </generate-with>
-
- <generate-with
class="com.vaadin.terminal.gwt.widgetsetutils.AcceptCriteriaFactoryGenerator">
<when-type-is
class="com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory" />
</generate-with>
- <!-- Generate client side proxies for client to server RPC interfaces -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.RpcProxyGenerator">
- <when-type-assignable
- class="com.vaadin.shared.communication.ServerRpc" />
- </generate-with>
-
- <!-- Generate client side proxies for client to server RPC interfaces -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.RpcProxyCreatorGenerator">
- <when-type-assignable
- class="com.vaadin.terminal.gwt.client.communication.RpcProxy.RpcProxyCreator" />
- </generate-with>
-
- <!-- Generate client side RPC manager for server to client RPC -->
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.GeneratedRpcMethodProviderGenerator">
- <when-type-assignable
- class="com.vaadin.terminal.gwt.client.communication.GeneratedRpcMethodProvider" />
- </generate-with>
-
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.ConnectorWidgetFactoryGenerator">
- <when-type-assignable
- class="com.vaadin.terminal.gwt.client.ui.ConnectorWidgetFactory" />
- </generate-with>
-
- <generate-with
- class="com.vaadin.terminal.gwt.widgetsetutils.ConnectorStateFactoryGenerator">
- <when-type-assignable
- class="com.vaadin.terminal.gwt.client.ui.ConnectorStateFactory" />
+ <generate-with class="com.vaadin.terminal.gwt.widgetsetutils.ConnectorBundleLoaderFactory">
+ <when-type-assignable class="com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader" />
</generate-with>
<!-- Use the new cross site linker to get a nocache.js without document.write -->
diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
index eea60b04ea..8bb4f37324 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
@@ -29,9 +29,12 @@ import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.vaadin.shared.ApplicationConstants;
+import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector;
public class ApplicationConfiguration implements EntryPoint {
@@ -207,7 +210,7 @@ public class ApplicationConfiguration implements EntryPoint {
private HashMap<Integer, String> unknownComponents;
- private Class<? extends ServerConnector>[] classes = new Class[1024];
+ private Map<Integer, Class<? extends ServerConnector>> classes = new HashMap<Integer, Class<? extends ServerConnector>>();
private boolean browserDetailsSent = false;
private boolean widgetsetVersionSent = false;
@@ -390,12 +393,32 @@ public class ApplicationConfiguration implements EntryPoint {
public Class<? extends ServerConnector> getConnectorClassByEncodedTag(
int tag) {
- try {
- return classes[tag];
- } catch (Exception e) {
- // component was not present in mappings
- return UnknownComponentConnector.class;
+ Class<? extends ServerConnector> type = classes.get(tag);
+ if (type == null && !classes.containsKey(tag)) {
+ // Initialize if not already loaded
+ Integer currentTag = Integer.valueOf(tag);
+ while (type == null && currentTag != null) {
+ String serverSideClassNameForTag = getServerSideClassNameForTag(currentTag);
+ if (TypeData.hasIdentifier(serverSideClassNameForTag)) {
+ try {
+ type = (Class<? extends ServerConnector>) TypeData
+ .getClass(serverSideClassNameForTag);
+ } catch (NoDataException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ currentTag = getParentTag(currentTag.intValue());
+ }
+ if (type == null) {
+ type = UnknownComponentConnector.class;
+ if (unknownComponents == null) {
+ unknownComponents = new HashMap<Integer, String>();
+ }
+ unknownComponents.put(tag, getServerSideClassNameForTag(tag));
+ }
+ classes.put(tag, type);
}
+ return type;
}
public void addComponentInheritanceInfo(ValueMap valueMap) {
@@ -418,13 +441,7 @@ public class ApplicationConfiguration implements EntryPoint {
for (int i = 0; i < keyArray.length(); i++) {
String key = keyArray.get(i).intern();
int value = valueMap.getInt(key);
- classes[value] = widgetSet.getConnectorClassByTag(value, this);
- if (classes[value] == UnknownComponentConnector.class) {
- if (unknownComponents == null) {
- unknownComponents = new HashMap<Integer, String>();
- }
- unknownComponents.put(value, key);
- }
+ widgetSet.ensureConnectorLoaded(value, this);
}
}
@@ -466,86 +483,25 @@ public class ApplicationConfiguration implements EntryPoint {
cmd.execute();
}
callbacks.clear();
- } else if (dependenciesLoading == 0 && deferredWidgetLoader != null) {
- deferredWidgetLoader.trigger();
- }
-
- }
-
- /*
- * This loop loads widget implementation that should be loaded deferred.
- */
- static class DeferredWidgetLoader extends Timer {
- private static final int FREE_LIMIT = 4;
- private static final int FREE_CHECK_TIMEOUT = 100;
-
- int communicationFree = 0;
- int nextWidgetIndex = 0;
- private boolean pending;
-
- public DeferredWidgetLoader() {
- schedule(5000);
- }
-
- public void trigger() {
- if (!pending) {
- schedule(FREE_CHECK_TIMEOUT);
- }
- }
-
- @Override
- public void schedule(int delayMillis) {
- super.schedule(delayMillis);
- pending = true;
- }
-
- @Override
- public void run() {
- pending = false;
- if (!isBusy()) {
- Class<? extends ServerConnector> nextType = getNextType();
- if (nextType == null) {
- // ensured that all widgets are loaded
- deferredWidgetLoader = null;
- } else {
- communicationFree = 0;
- widgetSet.loadImplementation(nextType);
- }
- } else {
- schedule(FREE_CHECK_TIMEOUT);
- }
- }
-
- private Class<? extends ServerConnector> getNextType() {
- Class<? extends ServerConnector>[] deferredLoadedConnectors = widgetSet
- .getDeferredLoadedConnectors();
- if (deferredLoadedConnectors.length <= nextWidgetIndex) {
- return null;
- } else {
- return deferredLoadedConnectors[nextWidgetIndex++];
- }
- }
-
- private boolean isBusy() {
- if (dependenciesLoading > 0) {
- communicationFree = 0;
- return true;
- }
- for (ApplicationConnection app : runningApplications) {
- if (app.hasActiveRequest()) {
- // if an UIDL request or widget loading is active, mark as
- // busy
- communicationFree = 0;
- return true;
- }
- }
- communicationFree++;
- return communicationFree < FREE_LIMIT;
+ } else if (dependenciesLoading == 0
+ && !ConnectorBundleLoader.get().isBundleLoaded(
+ ConnectorBundleLoader.DEFERRED_BUNDLE_NAME)) {
+ ConnectorBundleLoader.get().loadBundle(
+ ConnectorBundleLoader.DEFERRED_BUNDLE_NAME,
+ new BundleLoadCallback() {
+ @Override
+ public void loaded() {
+ // Nothing to do
+ }
+
+ @Override
+ public void failed(Throwable reason) {
+ VConsole.error(reason);
+ }
+ });
}
}
- private static DeferredWidgetLoader deferredWidgetLoader;
-
@Override
public void onModuleLoad() {
@@ -582,7 +538,6 @@ public class ApplicationConfiguration implements EntryPoint {
return;
}
registerCallback(GWT.getModuleName());
- deferredWidgetLoader = new DeferredWidgetLoader();
}
/**
diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 32b15d6d87..58357ae3fc 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -65,10 +65,10 @@ import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper
import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
import com.vaadin.terminal.gwt.client.communication.RpcManager;
-import com.vaadin.terminal.gwt.client.communication.SerializerMap;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
-import com.vaadin.terminal.gwt.client.communication.Type;
import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.Type;
import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
@@ -105,8 +105,6 @@ public class ApplicationConnection {
public static final char VAR_ESCAPE_CHARACTER = '\u001b';
- private static SerializerMap serializerMap;
-
/**
* A string that, if found in a non-JSON response to a UIDL request, will
* cause the browser to refresh the page. If followed by a colon, optional
@@ -207,11 +205,13 @@ public class ApplicationConnection {
}
public ApplicationConnection() {
+ // Assuming Root data is eagerly loaded
+ ConnectorBundleLoader.get().loadBundle(
+ ConnectorBundleLoader.EAGER_BUNDLE_NAME, null);
rootConnector = GWT.create(RootConnector.class);
rpcManager = GWT.create(RpcManager.class);
layoutManager = GWT.create(LayoutManager.class);
layoutManager.setConnection(this);
- serializerMap = GWT.create(SerializerMap.class);
}
public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) {
@@ -396,32 +396,6 @@ public class ApplicationConnection {
}-*/;
/**
- * Get the active Console for writing debug messages. May return an actual
- * logging console, or the NullConsole if debugging is not turned on.
- *
- * @deprecated Developers should use {@link VConsole} since 6.4.5
- *
- * @return the active Console
- */
- @Deprecated
- public static Console getConsole() {
- return VConsole.getImplementation();
- }
-
- /**
- * Checks if client side is in debug mode. Practically this is invoked by
- * adding ?debug parameter to URI.
- *
- * @deprecated use ApplicationConfiguration isDebugMode instead.
- *
- * @return true if client side is currently been debugged
- */
- @Deprecated
- public static boolean isDebugMode() {
- return ApplicationConfiguration.isDebugMode();
- }
-
- /**
* Gets the application base URI. Using this other than as the download
* action URI can cause problems in Portlet 2.0 deployments.
*
@@ -2468,7 +2442,8 @@ public class ApplicationConnection {
* The identifier for the event
* @return true if at least one listener has been registered on server side
* for the event identified by eventIdentifier.
- * @deprecated Use {@link ComponentState#hasEventListener(String)} instead
+ * @deprecated as of Vaadin 7. Use
+ * {@link ComponentState#hasEventListener(String)} instead
*/
@Deprecated
public boolean hasEventListeners(ComponentConnector paintable,
@@ -2521,11 +2496,13 @@ public class ApplicationConnection {
return connectorMap;
}
+ /**
+ * @deprecated No longer needed in Vaadin 7
+ */
@Deprecated
public void unregisterPaintable(ServerConnector p) {
- System.out.println("unregisterPaintable (unnecessarily) called for "
+ VConsole.log("unregisterPaintable (unnecessarily) called for "
+ Util.getConnectorString(p));
- // connectorMap.unregisterConnector(p);
}
/**
@@ -2564,6 +2541,10 @@ public class ApplicationConnection {
return false;
}
+ /**
+ * @deprecated as of Vaadin 7. Use
+ * {@link ComponentState#hasEventListener(String)} instead
+ */
@Deprecated
public boolean hasEventListeners(Widget widget, String eventIdentifier) {
return hasEventListeners(getConnectorMap().getConnector(widget),
@@ -2573,8 +2554,4 @@ public class ApplicationConnection {
LayoutManager getLayoutManager() {
return layoutManager;
}
-
- public SerializerMap getSerializerMap() {
- return serializerMap;
- }
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
index d6479dad86..891e45edb5 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java
@@ -22,6 +22,7 @@ import com.google.gwt.event.shared.GwtEvent;
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.vaadin.shared.Connector;
import com.vaadin.shared.communication.ClientRpc;
+import com.vaadin.shared.communication.SharedState;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
/**
@@ -164,4 +165,13 @@ public interface ServerConnector extends Connector {
public void setChildren(List<ServerConnector> children);
public List<ServerConnector> getChildren();
+
+ /**
+ * Gets the current shared state of the connector.
+ *
+ * @since 7.0.
+ * @return state The shared state object. Can be any sub type of
+ * {@link SharedState}. Never null.
+ */
+ public SharedState getState();
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java
index fbcfbb68d9..8245371161 100644
--- a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java
+++ b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java
@@ -18,17 +18,13 @@ package com.vaadin.terminal.gwt.client;
import com.google.gwt.core.client.GWT;
import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper;
+import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback;
+import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector;
public class WidgetSet {
-
- /**
- * WidgetSet (and its extensions) delegate instantiation of widgets and
- * client-server matching to WidgetMap. The actual implementations are
- * generated with gwts generators/deferred binding.
- */
- private WidgetMap widgetMap = GWT.create(WidgetMap.class);
-
/**
* Create an uninitialized connector that best matches given UIDL. The
* connector must implement {@link ServerConnector}.
@@ -65,12 +61,21 @@ public class WidgetSet {
/*
* let the auto generated code instantiate this type
*/
- ServerConnector connector = widgetMap.instantiate(classType);
- if (connector instanceof HasJavaScriptConnectorHelper) {
- ((HasJavaScriptConnectorHelper) connector)
- .getJavascriptConnectorHelper().setTag(tag);
+ try {
+ ServerConnector connector = (ServerConnector) TypeData.getType(
+ classType).createInstance();
+ if (connector instanceof HasJavaScriptConnectorHelper) {
+ ((HasJavaScriptConnectorHelper) connector)
+ .getJavascriptConnectorHelper().setTag(tag);
+ }
+ return connector;
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about "
+ + classType
+ + ". Did you remember to compile the right widgetset?",
+ e);
}
- return connector;
}
}
@@ -102,26 +107,32 @@ public class WidgetSet {
* @param applicationConfiguration
* @return
*/
- public Class<? extends ServerConnector> getConnectorClassByTag(int tag,
- ApplicationConfiguration conf) {
- Class<? extends ServerConnector> connectorClass = null;
+ public void ensureConnectorLoaded(int tag, ApplicationConfiguration conf) {
+ ConnectorBundleLoader loader = ConnectorBundleLoader.get();
+ String bundleName = null;
Integer t = tag;
do {
String serverSideClassName = conf.getServerSideClassNameForTag(t);
- connectorClass = widgetMap
- .getConnectorClassForServerSideClassName(serverSideClassName);
- t = conf.getParentTag(t);
- } while (connectorClass == UnknownComponentConnector.class && t != null);
+ bundleName = loader.getBundleForIdentifier(serverSideClassName);
- return connectorClass;
- }
+ t = conf.getParentTag(t);
+ } while (bundleName == null && t != null);
- public Class<? extends ServerConnector>[] getDeferredLoadedConnectors() {
- return widgetMap.getDeferredLoadedConnectors();
- }
+ if (bundleName != null && !loader.isBundleLoaded(bundleName)) {
+ ApplicationConfiguration.startDependencyLoading();
+ loader.loadBundle(bundleName, new BundleLoadCallback() {
+ @Override
+ public void loaded() {
+ ApplicationConfiguration.endDependencyLoading();
+ }
- public void loadImplementation(Class<? extends ServerConnector> nextType) {
- widgetMap.ensureInstantiator(nextType);
+ @Override
+ public void failed(Throwable reason) {
+ VConsole.error(reason);
+ ApplicationConfiguration.endDependencyLoading();
+ }
+ });
+ }
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java
index a3b96a6cb2..1d5415263f 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java
@@ -17,6 +17,7 @@ package com.vaadin.terminal.gwt.client.communication;
import com.google.gwt.json.client.JSONValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.metadata.Type;
public interface DiffJSONSerializer<T> extends JSONSerializer<T> {
/**
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java b/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java
deleted file mode 100644
index 65887bf62e..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.communication;
-
-import com.vaadin.shared.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.ServerConnector;
-
-/**
- * Initialization support for client to server RPC interfaces.
- *
- * This is in a separate interface used by the GWT generator class. The init
- * method is not in {@link ServerRpc} because then also server side proxies
- * would have to implement the initialization method.
- *
- * @since 7.0
- */
-public interface InitializableServerRpc extends ServerRpc {
- /**
- * Associates the RPC proxy with a connector. Called by generated code.
- * Should never be called manually.
- *
- * @param connector
- * The connector the ServerRPC instance is assigned to.
- */
- public void initRpc(ServerConnector connector);
-} \ No newline at end of file
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
index a8fe2c7ccc..c6b814a5c1 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java
@@ -20,6 +20,7 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ConnectorMap;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Implementors of this interface knows how to serialize an Object of a given
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
index 7d2046982c..a98d08c368 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
@@ -31,6 +31,9 @@ import com.google.gwt.json.client.JSONValue;
import com.vaadin.shared.Connector;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ConnectorMap;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Property;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Client side decoder for decodeing shared state and other values from JSON
@@ -105,18 +108,42 @@ public class JsonDecoder {
private static Object decodeObject(Type type, JSONValue jsonValue,
Object target, ApplicationConnection connection) {
- JSONSerializer<Object> serializer = connection.getSerializerMap()
- .getSerializer(type.getBaseTypeName());
- // TODO handle case with no serializer found
- // Currently getSerializer throws exception if not found
-
- if (target != null && serializer instanceof DiffJSONSerializer<?>) {
- DiffJSONSerializer<Object> diffSerializer = (DiffJSONSerializer<Object>) serializer;
- diffSerializer.update(target, type, jsonValue, connection);
- return target;
+ JSONSerializer<Object> serializer = (JSONSerializer<Object>) type
+ .findSerializer();
+ if (serializer != null) {
+ if (target != null && serializer instanceof DiffJSONSerializer<?>) {
+ DiffJSONSerializer<Object> diffSerializer = (DiffJSONSerializer<Object>) serializer;
+ diffSerializer.update(target, type, jsonValue, connection);
+ return target;
+ } else {
+ Object object = serializer.deserialize(type, jsonValue,
+ connection);
+ return object;
+ }
} else {
- Object object = serializer.deserialize(type, jsonValue, connection);
- return object;
+ try {
+ Collection<Property> properties = type.getProperties();
+ if (target == null) {
+ target = type.createInstance();
+ }
+ JSONObject jsonObject = jsonValue.isObject();
+
+ for (Property property : properties) {
+ JSONValue encodedPropertyValue = jsonObject.get(property
+ .getName());
+ if (encodedPropertyValue == null) {
+ continue;
+ }
+ Object propertyReference = property.getValue(target);
+ Object decodedValue = decodeValue(property.getType(),
+ encodedPropertyValue, propertyReference, connection);
+ property.setValue(target, decodedValue);
+ }
+ return target;
+ } catch (NoDataException e) {
+ throw new RuntimeException("Can not deserialize "
+ + type.getSignature(), e);
+ }
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
index 3730cad4c3..9b28da8b34 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java
@@ -33,6 +33,9 @@ import com.vaadin.shared.Connector;
import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.communication.UidlValue;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Property;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Encoder for converting RPC parameters and other values to JSON for transfer
@@ -99,12 +102,33 @@ public class JsonEncoder {
} else {
// Try to find a generated serializer object, class name is the
// type
- transportType = value.getClass().getName();
- JSONSerializer serializer = connection.getSerializerMap()
- .getSerializer(transportType);
+ Type type = new Type(value.getClass());
+
+ JSONSerializer<Object> serializer = (JSONSerializer<Object>) type
+ .findSerializer();
+ if (serializer != null) {
+ return serializer.serialize(value, connection);
+ } else {
+ try {
+ Collection<Property> properties = type.getProperties();
+
+ JSONObject jsonObject = new JSONObject();
+ for (Property property : properties) {
+ Object propertyValue = property.getValue(value);
+ JSONValue encodedPropertyValue = encode(
+ propertyValue, restrictToInternalTypes,
+ connection);
+ jsonObject.put(property.getName(),
+ encodedPropertyValue);
+ }
+ return jsonObject;
+
+ } catch (NoDataException e) {
+ throw new RuntimeException("Can not encode "
+ + type.getSignature(), e);
+ }
+ }
- // TODO handle case with no serializer found
- return serializer.serialize(value, connection);
}
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java
index 04d0e3f56f..5b9bcff6a4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java
@@ -17,10 +17,7 @@
package com.vaadin.terminal.gwt.client.communication;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONString;
import com.vaadin.shared.communication.ClientRpc;
@@ -29,6 +26,9 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ConnectorMap;
import com.vaadin.terminal.gwt.client.ServerConnector;
import com.vaadin.terminal.gwt.client.VConsole;
+import com.vaadin.terminal.gwt.client.metadata.Method;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Type;
/**
* Client side RPC manager that can invoke methods based on RPC calls received
@@ -41,19 +41,6 @@ import com.vaadin.terminal.gwt.client.VConsole;
*/
public class RpcManager {
- private final Map<String, RpcMethod> methodMap = new HashMap<String, RpcMethod>();
-
- public RpcManager() {
- GeneratedRpcMethodProvider provider = GWT
- .create(GeneratedRpcMethodProvider.class);
- Collection<RpcMethod> methods = provider.getGeneratedRpcMethods();
- for (RpcMethod rpcMethod : methods) {
- methodMap.put(
- rpcMethod.getInterfaceName() + "."
- + rpcMethod.getMethodName(), rpcMethod);
- }
- }
-
/**
* Perform server to client RPC invocation.
*
@@ -62,24 +49,25 @@ public class RpcManager {
*/
public void applyInvocation(MethodInvocation invocation,
ServerConnector connector) {
- String signature = getSignature(invocation);
+ Method method = getMethod(invocation);
- RpcMethod rpcMethod = getRpcMethod(signature);
Collection<ClientRpc> implementations = connector
.getRpcImplementations(invocation.getInterfaceName());
- for (ClientRpc clientRpc : implementations) {
- rpcMethod.applyInvocation(clientRpc, invocation.getParameters());
+ try {
+ for (ClientRpc clientRpc : implementations) {
+ method.invoke(clientRpc, invocation.getParameters());
+ }
+ } catch (NoDataException e) {
+ throw new IllegalStateException("There is no information about "
+ + method.getSignature()
+ + ". Did you remember to compile the right widgetset?", e);
}
}
- private RpcMethod getRpcMethod(String signature) {
- RpcMethod rpcMethod = methodMap.get(signature);
- if (rpcMethod == null) {
- throw new IllegalStateException("There is no information about "
- + signature
- + ". Did you remember to compile the right widgetset?");
- }
- return rpcMethod;
+ private Method getMethod(MethodInvocation invocation) {
+ Type type = new Type(invocation.getInterfaceName(), null);
+ Method method = type.getMethod(invocation.getMethodName());
+ return method;
}
private static String getSignature(MethodInvocation invocation) {
@@ -87,7 +75,15 @@ public class RpcManager {
}
public Type[] getParameterTypes(MethodInvocation invocation) {
- return getRpcMethod(getSignature(invocation)).getParameterTypes();
+ Method method = getMethod(invocation);
+ try {
+ Type[] parameterTypes = method.getParameterTypes();
+ return parameterTypes;
+ } catch (NoDataException e) {
+ throw new IllegalStateException("There is no information about "
+ + method.getSignature()
+ + ". Did you remember to compile the right widgetset?", e);
+ }
}
public void parseAndApplyInvocation(JSONArray rpcCall,
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java
deleted file mode 100644
index a47fa5eab2..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.communication;
-
-import com.vaadin.shared.communication.ClientRpc;
-
-public abstract class RpcMethod {
- private String interfaceName;
- private String methodName;
- private Type[] parameterTypes;
-
- public RpcMethod(String interfaceName, String methodName,
- Type... parameterTypes) {
- this.interfaceName = interfaceName;
- this.methodName = methodName;
- this.parameterTypes = parameterTypes;
- }
-
- public String getInterfaceName() {
- return interfaceName;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public Type[] getParameterTypes() {
- return parameterTypes;
- }
-
- public abstract void applyInvocation(ClientRpc target, Object... parameters);
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java
index 226594adc6..e9dc6ab7fd 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java
@@ -15,9 +15,13 @@
*/
package com.vaadin.terminal.gwt.client.communication;
-import com.google.gwt.core.client.GWT;
+import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.metadata.InvokationHandler;
+import com.vaadin.terminal.gwt.client.metadata.Method;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
/**
* Class for creating proxy instances for Client to Server RPC.
@@ -26,25 +30,38 @@ import com.vaadin.terminal.gwt.client.ServerConnector;
*/
public class RpcProxy {
- private static RpcProxyCreator impl = GWT.create(RpcProxyCreator.class);
-
- /**
- * Create a proxy class for the given Rpc interface and assign it to the
- * given connector.
- *
- * @param rpcInterface
- * The rpc interface to construct a proxy for
- * @param connector
- * The connector this proxy is connected to
- * @return A proxy class used for calling Rpc methods.
- */
public static <T extends ServerRpc> T create(Class<T> rpcInterface,
ServerConnector connector) {
- return impl.create(rpcInterface, connector);
+ try {
+ return (T) TypeData.getType(rpcInterface).createProxy(
+ new RpcInvokationHandler(rpcInterface, connector));
+ } catch (NoDataException e) {
+ throw new IllegalStateException("There is no information about "
+ + rpcInterface
+ + ". Did you forget to compile the widgetset?");
+ }
}
- public interface RpcProxyCreator {
- <T extends ServerRpc> T create(Class<T> rpcInterface,
- ServerConnector connector);
+ private static final class RpcInvokationHandler implements
+ InvokationHandler {
+ private final Class<?> rpcInterface;
+ private final ServerConnector connector;
+
+ private RpcInvokationHandler(Class<?> rpcInterface,
+ ServerConnector connector) {
+ this.rpcInterface = rpcInterface;
+ this.connector = connector;
+ }
+
+ @Override
+ public Object invoke(Object target, Method method, Object[] params) {
+ MethodInvocation invocation = new MethodInvocation(
+ connector.getConnectorId(), rpcInterface.getName(),
+ method.getName(), params);
+ connector.getConnection().addMethodInvocationToQueue(invocation,
+ method.isDelayed(), method.isLastonly());
+ // No RPC iface should have a return value
+ return null;
+ }
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java b/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java
deleted file mode 100644
index 77df4c7b08..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.terminal.gwt.client.communication;
-
-/**
- * Provide a mapping from a type (communicated between the server and the
- * client) and a {@link JSONSerializer} instance.
- *
- * An implementation of this class is created at GWT compilation time by
- * SerializerMapGenerator, so this interface can be instantiated with
- * GWT.create().
- *
- * @since 7.0
- */
-public interface SerializerMap {
-
- /**
- * Returns a serializer instance for a given type.
- *
- * @param type
- * type communicated on between the server and the client
- * (currently fully qualified class name)
- * @return serializer instance, not null
- * @throws RuntimeException
- * if no serializer is found
- */
- // TODO better error handling in javadoc and in generator
- public JSONSerializer getSerializer(String type);
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/Type.java b/client/src/com/vaadin/terminal/gwt/client/communication/Type.java
deleted file mode 100644
index ff93234a1d..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/communication/Type.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.communication;
-
-public class Type {
- private final String baseTypeName;
- private final Type[] parameterTypes;
-
- public Type(String baseTypeName, Type[] parameterTypes) {
- this.baseTypeName = baseTypeName;
- this.parameterTypes = parameterTypes;
- }
-
- public String getBaseTypeName() {
- return baseTypeName;
- }
-
- public Type[] getParameterTypes() {
- return parameterTypes;
- }
-
- @Override
- public String toString() {
- String string = baseTypeName;
- if (parameterTypes != null) {
- string += '<';
- for (int i = 0; i < parameterTypes.length; i++) {
- if (i != 0) {
- string += ',';
- }
- string += parameterTypes[i].toString();
- }
- string += '>';
- }
-
- return string;
- }
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java
index f77553d3c0..3d2e4f3804 100644
--- a/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java
+++ b/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java
@@ -20,6 +20,7 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.vaadin.shared.communication.URLReference;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.metadata.Type;
public class URLReference_Serializer implements JSONSerializer<URLReference> {
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java
new file mode 100644
index 0000000000..e92e51b40d
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java
@@ -0,0 +1,86 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class AsyncBundleLoader {
+ public enum State {
+ NOT_STARTED, LOADING, LOADED, ERROR;
+ }
+
+ private State state = State.NOT_STARTED;
+
+ private Throwable error = null;
+
+ private List<BundleLoadCallback> callbacks = new ArrayList<BundleLoadCallback>();
+
+ private final String packageName;
+
+ private final String[] indentifiers;
+
+ public AsyncBundleLoader(String packageName, String[] indentifiers) {
+ this.packageName = packageName;
+ this.indentifiers = indentifiers;
+ }
+
+ protected abstract void load(TypeDataStore store);
+
+ public List<BundleLoadCallback> setError(Throwable error) {
+ assert state == State.LOADING;
+ state = State.ERROR;
+ this.error = error;
+
+ return clearCallbacks();
+ }
+
+ public Throwable getError() {
+ return error;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public List<BundleLoadCallback> getCallback() {
+ return Collections.unmodifiableList(callbacks);
+ }
+
+ public void load(BundleLoadCallback callback, TypeDataStore store) {
+ assert state == State.NOT_STARTED;
+ state = State.LOADING;
+ callbacks.add(callback);
+ load(store);
+ }
+
+ public void addCallback(BundleLoadCallback callback) {
+ assert state == State.LOADING;
+ callbacks.add(callback);
+ }
+
+ public List<BundleLoadCallback> setLoaded() {
+ assert state == State.LOADING;
+ state = State.LOADED;
+
+ return clearCallbacks();
+ }
+
+ private List<BundleLoadCallback> clearCallbacks() {
+ List<BundleLoadCallback> callbacks = this.callbacks;
+ this.callbacks = null;
+ return callbacks;
+ }
+
+ public String getName() {
+ return packageName;
+ }
+
+ public String[] getIndentifiers() {
+ return indentifiers;
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java b/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java
new file mode 100644
index 0000000000..c7fc735829
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java
@@ -0,0 +1,11 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface BundleLoadCallback {
+ public void loaded();
+
+ public void failed(Throwable reason);
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java
new file mode 100644
index 0000000000..ab1462efc1
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java
@@ -0,0 +1,99 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.core.shared.GWT;
+import com.vaadin.terminal.gwt.client.metadata.AsyncBundleLoader.State;
+
+public abstract class ConnectorBundleLoader {
+ public static final String EAGER_BUNDLE_NAME = "__eager";
+ public static final String DEFERRED_BUNDLE_NAME = "__deferred";
+
+ private static ConnectorBundleLoader impl;
+
+ private Map<String, AsyncBundleLoader> asyncBlockLoaders = new HashMap<String, AsyncBundleLoader>();
+ private Map<String, String> identifierToBundle = new HashMap<String, String>();
+
+ private final TypeDataStore datStore = new TypeDataStore();
+
+ public ConnectorBundleLoader() {
+ init();
+ }
+
+ public TypeDataStore getTypeDataStore() {
+ return datStore;
+ }
+
+ public static ConnectorBundleLoader get() {
+ if (impl == null) {
+ impl = GWT.create(ConnectorBundleLoader.class);
+ }
+ return impl;
+ }
+
+ public void loadBundle(String packageName, BundleLoadCallback callback) {
+ AsyncBundleLoader loader = asyncBlockLoaders.get(packageName);
+ switch (loader.getState()) {
+ case NOT_STARTED:
+ loader.load(callback, getTypeDataStore());
+ break;
+ case LOADING:
+ loader.addCallback(callback);
+ break;
+ case LOADED:
+ callback.loaded();
+ break;
+ case ERROR:
+ callback.failed(loader.getError());
+ }
+ }
+
+ public boolean isBundleLoaded(String bundleName) {
+ AsyncBundleLoader loader = asyncBlockLoaders.get(bundleName);
+ if (loader == null) {
+ throw new IllegalArgumentException("Bundle " + bundleName
+ + " not recognized");
+ }
+ return loader.getState() == State.LOADED;
+ }
+
+ public void setLoaded(String packageName) {
+ List<BundleLoadCallback> callbacks = asyncBlockLoaders.get(packageName)
+ .setLoaded();
+ for (BundleLoadCallback callback : callbacks) {
+ if (callback != null) {
+ callback.loaded();
+ }
+ }
+ }
+
+ public void setLoadFailure(String bundleName, Throwable reason) {
+ List<BundleLoadCallback> callbacks = asyncBlockLoaders.get(bundleName)
+ .setError(reason);
+ for (BundleLoadCallback callback : callbacks) {
+ callback.failed(reason);
+ }
+ }
+
+ public String getBundleForIdentifier(String identifier) {
+ return identifierToBundle.get(identifier);
+ }
+
+ protected void addAsyncBlockLoader(AsyncBundleLoader loader) {
+ String name = loader.getName();
+ asyncBlockLoaders.put(name, loader);
+ String[] indentifiers = loader.getIndentifiers();
+ for (String identifier : indentifiers) {
+ identifierToBundle.put(identifier, name);
+ }
+ }
+
+ public abstract void init();
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java
new file mode 100644
index 0000000000..2b1153ad97
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface InvokationHandler {
+ public Object invoke(Object target, Method method, Object[] params);
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java
new file mode 100644
index 0000000000..33e8776429
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java
@@ -0,0 +1,9 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface Invoker {
+ public Object invoke(Object target, Object... params);
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java
new file mode 100644
index 0000000000..527e8a29d2
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java
@@ -0,0 +1,71 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public class Method {
+
+ private final Type type;
+ private final String name;
+
+ public Method(Type type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Type getReturnType() throws NoDataException {
+ return TypeDataStore.getReturnType(this);
+ }
+
+ public void invoke(Object target, Object... params) throws NoDataException {
+ TypeDataStore.getInvoker(this).invoke(target, params);
+ }
+
+ public String getSignature() {
+ return type.toString() + "." + name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Method) {
+ Method other = (Method) obj;
+ return other.getSignature().equals(getSignature());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getSignature();
+ }
+
+ @Override
+ public int hashCode() {
+ return getSignature().hashCode();
+ }
+
+ public Type[] getParameterTypes() throws NoDataException {
+ return TypeDataStore.getParamTypes(this);
+ }
+
+ public boolean isDelayed() {
+ return TypeDataStore.isDelayed(this);
+ }
+
+ public boolean isLastonly() {
+ return TypeDataStore.isLastonly(this);
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java
index d8c7e67638..717b92edaf 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java
@@ -13,30 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.terminal.gwt.client;
-import com.google.gwt.core.client.GWT;
+package com.vaadin.terminal.gwt.client.metadata;
-@Deprecated
-public class ClientExceptionHandler {
-
- public static void displayError(Throwable e) {
- displayError(e.getClass().getName() + ": " + e.getMessage());
-
- GWT.log(e.getMessage(), e);
- }
-
- @Deprecated
- public static void displayError(String msg) {
- VConsole.error(msg);
- GWT.log(msg);
- }
-
- @Deprecated
- public static void displayError(String msg, Throwable e) {
- displayError(msg);
- displayError(e);
+public class NoDataException extends Exception {
+ public NoDataException(String message) {
+ super(message);
}
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
new file mode 100644
index 0000000000..082d032e64
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java
@@ -0,0 +1,70 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public class Property {
+ private final Type bean;
+ private final String name;
+
+ public Property(Type bean, String name) {
+ this.bean = bean;
+ this.name = name;
+ }
+
+ public Object getValue(Object bean) throws NoDataException {
+ return TypeDataStore.getGetter(this).invoke(bean);
+ }
+
+ public void setValue(Object bean, Object value) throws NoDataException {
+ TypeDataStore.getSetter(this).invoke(bean, value);
+ }
+
+ public String getDelegateToWidgetMethod() {
+ String value = TypeDataStore.getDelegateToWidget(this);
+ if (value == null) {
+ return null;
+ } else if (value.isEmpty()) {
+ return "set" + Character.toUpperCase(value.charAt(0))
+ + value.substring(1);
+ } else {
+ return value;
+ }
+ }
+
+ public Type getType() throws NoDataException {
+ return TypeDataStore.getType(this);
+ }
+
+ public String getSignature() {
+ return bean.toString() + "." + name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ } else if (obj instanceof Property) {
+ Property other = (Property) obj;
+ return getSignature().equals(other.getSignature());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return getSignature().hashCode();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return getSignature();
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java
new file mode 100644
index 0000000000..cc8168a8ff
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public interface ProxyHandler {
+
+ Object createProxy(InvokationHandler invokationHandler);
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java
new file mode 100644
index 0000000000..d869cc2599
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java
@@ -0,0 +1,97 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.Collection;
+
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
+
+public class Type {
+ private final String name;
+ private final Type[] parameterTypes;
+
+ public Type(Class<?> clazz) {
+ name = clazz.getName();
+ parameterTypes = null;
+ }
+
+ public Type(String baseTypeName, Type[] parameterTypes) {
+ name = baseTypeName;
+ this.parameterTypes = parameterTypes;
+ }
+
+ public String getBaseTypeName() {
+ return name;
+ }
+
+ public Type[] getParameterTypes() {
+ return parameterTypes;
+ }
+
+ public Object createInstance() throws NoDataException {
+ Invoker invoker = TypeDataStore.getConstructor(this);
+ return invoker.invoke(null);
+ }
+
+ public Method getMethod(String name) {
+ return new Method(this, name);
+ }
+
+ public Collection<Property> getProperties() throws NoDataException {
+ return TypeDataStore.getProperties(this);
+ }
+
+ public Property getProperty(String propertyName) {
+ return new Property(this, propertyName);
+ }
+
+ public String getSignature() {
+ String string = name;
+ if (parameterTypes != null && parameterTypes.length != 0) {
+ string += '<';
+ for (int i = 0; i < parameterTypes.length; i++) {
+ if (i != 0) {
+ string += ',';
+ }
+ string += parameterTypes[i].toString();
+ }
+ string += '>';
+ }
+
+ return string;
+ }
+
+ @Override
+ public String toString() {
+ return getSignature();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof Type) {
+ Type other = (Type) obj;
+ return other.getSignature().equals(getSignature());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return getSignature().hashCode();
+ }
+
+ public Object createProxy(InvokationHandler invokationHandler)
+ throws NoDataException {
+ return TypeDataStore.get().getProxyHandler(this)
+ .createProxy(invokationHandler);
+ }
+
+ public JSONSerializer<?> findSerializer() {
+ return TypeDataStore.findSerializer(this);
+ }
+
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java
new file mode 100644
index 0000000000..ec2a8f191c
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java
@@ -0,0 +1,20 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+public class TypeData {
+
+ public static Type getType(Class<?> type) {
+ return TypeDataStore.getType(type);
+ }
+
+ public static Class<?> getClass(String identifier) throws NoDataException {
+ return TypeDataStore.getClass(identifier);
+ }
+
+ public static boolean hasIdentifier(String identifier) {
+ return TypeDataStore.hasIdentifier(identifier);
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java
new file mode 100644
index 0000000000..cbde338ff2
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java
@@ -0,0 +1,33 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import com.google.gwt.core.client.RunAsyncCallback;
+
+public abstract class TypeDataBundle implements RunAsyncCallback {
+ private final String name;
+
+ public TypeDataBundle(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public void onSuccess() {
+ ConnectorBundleLoader loader = ConnectorBundleLoader.get();
+ load();
+ loader.setLoaded(getName());
+ }
+
+ @Override
+ public void onFailure(Throwable reason) {
+ ConnectorBundleLoader.get().setLoadFailure(getName(), reason);
+ }
+
+ public abstract void load();
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
new file mode 100644
index 0000000000..55740f69da
--- /dev/null
+++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java
@@ -0,0 +1,220 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.metadata;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.vaadin.terminal.gwt.client.communication.JSONSerializer;
+
+public class TypeDataStore {
+ private static final String CONSTRUCTOR_NAME = "!new";
+
+ private final Map<String, Class<?>> identifiers = new HashMap<String, Class<?>>();
+
+ private final Map<Type, Invoker> serializerFactories = new HashMap<Type, Invoker>();
+ private final Map<Type, ProxyHandler> proxyHandlers = new HashMap<Type, ProxyHandler>();
+ private final Map<Type, Collection<Property>> properties = new HashMap<Type, Collection<Property>>();
+
+ private final Set<Method> delayedMethods = new HashSet<Method>();
+ private final Set<Method> lastonlyMethods = new HashSet<Method>();
+
+ private final Map<Method, Type> returnTypes = new HashMap<Method, Type>();
+ private final Map<Method, Invoker> invokers = new HashMap<Method, Invoker>();
+ private final Map<Method, Type[]> paramTypes = new HashMap<Method, Type[]>();
+
+ private final Map<Property, Type> propertyTypes = new HashMap<Property, Type>();
+ private final Map<Property, Invoker> setters = new HashMap<Property, Invoker>();
+ private final Map<Property, Invoker> getters = new HashMap<Property, Invoker>();
+ private final Map<Property, String> delegateToWidget = new HashMap<Property, String>();
+
+ public static TypeDataStore get() {
+ return ConnectorBundleLoader.get().getTypeDataStore();
+ }
+
+ public void setClass(String identifier, Class<?> type) {
+ identifiers.put(identifier, type);
+ }
+
+ public static Class<?> getClass(String identifier) throws NoDataException {
+ Class<?> class1 = get().identifiers.get(identifier);
+ if (class1 == null) {
+ throw new NoDataException("There is not class for identifier "
+ + identifier);
+ }
+ return class1;
+ }
+
+ public static Type getType(Class<?> clazz) {
+ return new Type(clazz);
+ }
+
+ public static Type getReturnType(Method method) throws NoDataException {
+ Type type = get().returnTypes.get(method);
+ if (type == null) {
+ throw new NoDataException("There is return type for "
+ + method.getSignature());
+ }
+ return type;
+ }
+
+ public static Invoker getInvoker(Method method) throws NoDataException {
+ Invoker invoker = get().invokers.get(method);
+ if (invoker == null) {
+ throw new NoDataException("There is invoker for "
+ + method.getSignature());
+ }
+ return invoker;
+ }
+
+ public static Invoker getConstructor(Type type) throws NoDataException {
+ Invoker invoker = get().invokers
+ .get(new Method(type, CONSTRUCTOR_NAME));
+ if (invoker == null) {
+ throw new NoDataException("There is constructor for "
+ + type.getSignature());
+ }
+ return invoker;
+ }
+
+ public static Invoker getGetter(Property property) throws NoDataException {
+ Invoker getter = get().getters.get(property);
+ if (getter == null) {
+ throw new NoDataException("There is getter for "
+ + property.getSignature());
+ }
+
+ return getter;
+ }
+
+ public void setGetter(Class<?> clazz, String propertyName, Invoker invoker) {
+ getters.put(new Property(getType(clazz), propertyName), invoker);
+ }
+
+ public static String getDelegateToWidget(Property property) {
+ return get().delegateToWidget.get(property);
+ }
+
+ public void setReturnType(Class<?> type, String methodName, Type returnType) {
+ returnTypes.put(new Method(getType(type), methodName), returnType);
+ }
+
+ public void setConstructor(Class<?> type, Invoker constructor) {
+ setInvoker(type, CONSTRUCTOR_NAME, constructor);
+ }
+
+ public void setInvoker(Class<?> type, String methodName, Invoker invoker) {
+ invokers.put(new Method(getType(type), methodName), invoker);
+ }
+
+ public static Type[] getParamTypes(Method method) throws NoDataException {
+ Type[] types = get().paramTypes.get(method);
+ if (types == null) {
+ throw new NoDataException("There are no parameter type data for "
+ + method.getSignature());
+ }
+ return types;
+ }
+
+ public void setParamTypes(Class<?> type, String methodName,
+ Type[] paramTypes) {
+ this.paramTypes.put(new Method(getType(type), methodName), paramTypes);
+ }
+
+ public static boolean hasIdentifier(String identifier) {
+ return get().identifiers.containsKey(identifier);
+ }
+
+ public static ProxyHandler getProxyHandler(Type type)
+ throws NoDataException {
+ ProxyHandler proxyHandler = get().proxyHandlers.get(type);
+ if (proxyHandler == null) {
+ throw new NoDataException("No proxy handler for "
+ + type.getSignature());
+ }
+ return proxyHandler;
+ }
+
+ public void setProxyHandler(Class<?> type, ProxyHandler proxyHandler) {
+ proxyHandlers.put(getType(type), proxyHandler);
+ }
+
+ public static boolean isDelayed(Method method) {
+ return get().delayedMethods.contains(method);
+ }
+
+ public void setDelayed(Class<?> type, String methodName) {
+ delayedMethods.add(getType(type).getMethod(methodName));
+ }
+
+ public static boolean isLastonly(Method method) {
+ return get().lastonlyMethods.contains(method);
+ }
+
+ public void setLastonly(Class<?> clazz, String methodName) {
+ lastonlyMethods.add(getType(clazz).getMethod(methodName));
+ }
+
+ public static Collection<Property> getProperties(Type type)
+ throws NoDataException {
+ Collection<Property> properties = get().properties.get(type);
+ if (properties == null) {
+ throw new NoDataException("No property list for "
+ + type.getSignature());
+ }
+ return properties;
+ }
+
+ public void setProperties(Class<?> clazz, String[] propertyNames) {
+ Set<Property> properties = new HashSet<Property>();
+ Type type = getType(clazz);
+ for (String name : propertyNames) {
+ properties.add(new Property(type, name));
+ }
+ this.properties.put(type, Collections.unmodifiableSet(properties));
+ }
+
+ public static Type getType(Property property) throws NoDataException {
+ Type type = get().propertyTypes.get(property);
+ if (type == null) {
+ throw new NoDataException("No return type for "
+ + property.getSignature());
+ }
+ return type;
+ }
+
+ public void setPropertyType(Class<?> clazz, String propertName, Type type) {
+ propertyTypes.put(new Property(getType(clazz), propertName), type);
+ }
+
+ public static Invoker getSetter(Property property) throws NoDataException {
+ Invoker setter = get().setters.get(property);
+ if (setter == null) {
+ throw new NoDataException("No setter for "
+ + property.getSignature());
+ }
+ return setter;
+ }
+
+ public void setSetter(Class<?> clazz, String propertyName, Invoker setter) {
+ setters.put(new Property(getType(clazz), propertyName), setter);
+ }
+
+ public void setSerializerFactory(Class<?> clazz, Invoker factory) {
+ serializerFactories.put(getType(clazz), factory);
+ }
+
+ public static JSONSerializer<?> findSerializer(Type type) {
+ Invoker factoryCreator = get().serializerFactories.get(type);
+ if (factoryCreator == null) {
+ return null;
+ }
+ return (JSONSerializer<?>) factoryCreator.invoke(null);
+ }
+}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
index 63955ddcc8..a50dad0c2f 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
@@ -37,6 +37,9 @@ import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Type;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
import com.vaadin.terminal.gwt.client.ui.datefield.PopupDateFieldConnector;
import com.vaadin.terminal.gwt.client.ui.root.RootConnector;
@@ -77,7 +80,18 @@ public abstract class AbstractComponentConnector extends AbstractConnector
* @return
*/
protected Widget createWidget() {
- return ConnectorWidgetFactory.createWidget(getClass());
+ Type type = TypeData.getType(getClass());
+ try {
+ Type widgetType = type.getMethod("getWidget").getReturnType();
+ Object instance = widgetType.createInstance();
+ return (Widget) instance;
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about the widget for "
+ + Util.getSimpleName(this)
+ + ". Did you remember to compile the right widgetset?",
+ e);
+ }
}
/**
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java
index 0148f7816c..fabd750f8b 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java
@@ -33,6 +33,9 @@ import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
+import com.vaadin.terminal.gwt.client.metadata.NoDataException;
+import com.vaadin.terminal.gwt.client.metadata.Type;
+import com.vaadin.terminal.gwt.client.metadata.TypeData;
/**
* An abstract implementation of Connector.
@@ -277,7 +280,20 @@ StateChangeHandler {
* @return A new state object
*/
protected SharedState createState() {
- return ConnectorStateFactory.createState(getClass());
+ Type connectorType = TypeData.getType(getClass());
+ try {
+ Type stateType = connectorType.getMethod("getState")
+ .getReturnType();
+ Object stateInstance = stateType.createInstance();
+ return (SharedState) stateInstance;
+ } catch (NoDataException e) {
+ throw new IllegalStateException(
+ "There is no information about the state for "
+ + Util.getSimpleName(this)
+ + ". Did you remember to compile the right widgetset?",
+ e);
+ }
+
}
@Override
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java
deleted file mode 100644
index 698d8e6e61..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.shared.Connector;
-
-public abstract class ConnectorClassBasedFactory<T> {
- public interface Creator<T> {
- public T create();
- }
-
- private Map<Class<? extends Connector>, Creator<? extends T>> creators = new HashMap<Class<? extends Connector>, Creator<? extends T>>();
-
- protected void addCreator(Class<? extends Connector> cls,
- Creator<? extends T> creator) {
- creators.put(cls, creator);
- }
-
- /**
- * Creates a widget using GWT.create for the given connector, based on its
- * {@link AbstractComponentConnector#getWidget()} return type.
- *
- * @param connector
- * @return
- */
- public T create(Class<? extends Connector> connector) {
- Creator<? extends T> foo = creators.get(connector);
- if (foo == null) {
- throw new RuntimeException(getClass().getName()
- + " could not find a creator for connector of type "
- + connector.getName());
- }
- return foo.create();
- }
-
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java
deleted file mode 100644
index b04daa6910..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.ui;
-
-import com.google.gwt.core.client.GWT;
-import com.vaadin.shared.Connector;
-import com.vaadin.shared.communication.SharedState;
-
-public abstract class ConnectorStateFactory extends
- ConnectorClassBasedFactory<SharedState> {
- private static ConnectorStateFactory impl = null;
-
- /**
- * Creates a SharedState using GWT.create for the given connector, based on
- * its {@link AbstractComponentConnector#getSharedState ()} return type.
- *
- * @param connector
- * @return
- */
- public static SharedState createState(Class<? extends Connector> connector) {
- return getImpl().create(connector);
- }
-
- private static ConnectorStateFactory getImpl() {
- if (impl == null) {
- impl = GWT.create(ConnectorStateFactory.class);
- }
- return impl;
- }
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java
deleted file mode 100644
index 073e36cabb..0000000000
--- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.terminal.gwt.client.ui;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector;
-import com.vaadin.terminal.gwt.client.ui.textfield.VTextField;
-
-public abstract class ConnectorWidgetFactory extends
- ConnectorClassBasedFactory<Widget> {
- private static ConnectorWidgetFactory impl = null;
-
- // TODO Move to generator
- {
- addCreator(TextFieldConnector.class, new Creator<Widget>() {
- @Override
- public Widget create() {
- return GWT.create(VTextField.class);
- }
- });
- }
-
- /**
- * Creates a widget using GWT.create for the given connector, based on its
- * {@link AbstractComponentConnector#getWidget()} return type.
- *
- * @param connector
- * @return
- */
- public static Widget createWidget(
- Class<? extends AbstractComponentConnector> connector) {
- return getImpl().create(connector);
- }
-
- private static ConnectorWidgetFactory getImpl() {
- if (impl == null) {
- impl = GWT.create(ConnectorWidgetFactory.class);
- }
- return impl;
- }
-}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java
index 47c2049a67..2e51d717a4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/CssLayoutConnector.java
@@ -23,7 +23,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.LayoutClickRpc;
-import com.vaadin.shared.ui.VMarginInfo;
import com.vaadin.shared.ui.csslayout.CssLayoutServerRpc;
import com.vaadin.shared.ui.csslayout.CssLayoutState;
import com.vaadin.terminal.gwt.client.BrowserInfo;
@@ -75,9 +74,6 @@ public class CssLayoutConnector extends AbstractLayoutConnector {
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- getWidget().setMarginStyles(
- new VMarginInfo(getState().getMarginsBitmask()));
-
for (ComponentConnector child : getChildComponents()) {
if (!getState().getChildCss().containsKey(child)) {
continue;
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java
index 813e95e3ed..e66b1c4208 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/csslayout/VCssLayout.java
@@ -21,8 +21,6 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.shared.ui.VMarginInfo;
-import com.vaadin.terminal.gwt.client.StyleConstants;
public class VCssLayout extends SimplePanel {
public static final String TAGNAME = "csslayout";
@@ -64,21 +62,4 @@ public class VCssLayout extends SimplePanel {
}
- /**
- * Sets CSS classes for margin based on the given parameters.
- *
- * @param margins
- * A {@link VMarginInfo} object that provides info on
- * top/left/bottom/right margins
- */
- protected void setMarginStyles(VMarginInfo margins) {
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_TOP, margins.hasTop());
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_RIGHT, margins.hasRight());
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_BOTTOM, margins.hasBottom());
- setStyleName(margin, VCssLayout.CLASSNAME + "-"
- + StyleConstants.MARGIN_LEFT, margins.hasLeft());
- }
}
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java b/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
index b6012eded1..a4d00f59de 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java
@@ -24,23 +24,6 @@ import com.vaadin.terminal.gwt.client.Util;
public class DDUtil {
- /**
- * @deprecated use the version with the actual event instead of detected
- * clientY value
- *
- * @param element
- * @param clientY
- * @param topBottomRatio
- * @return
- */
- @Deprecated
- public static VerticalDropLocation getVerticalDropLocation(Element element,
- int clientY, double topBottomRatio) {
- int offsetHeight = element.getOffsetHeight();
- return getVerticalDropLocation(element, offsetHeight, clientY,
- topBottomRatio);
- }
-
public static VerticalDropLocation getVerticalDropLocation(Element element,
NativeEvent event, double topBottomRatio) {
int offsetHeight = element.getOffsetHeight();
@@ -76,21 +59,7 @@ public class DDUtil {
public static HorizontalDropLocation getHorizontalDropLocation(
Element element, NativeEvent event, double leftRightRatio) {
- int touchOrMouseClientX = Util.getTouchOrMouseClientX(event);
- return getHorizontalDropLocation(element, touchOrMouseClientX,
- leftRightRatio);
- }
-
- /**
- * @deprecated use the version with the actual event
- * @param element
- * @param clientX
- * @param leftRightRatio
- * @return
- */
- @Deprecated
- public static HorizontalDropLocation getHorizontalDropLocation(
- Element element, int clientX, double leftRightRatio) {
+ int clientX = Util.getTouchOrMouseClientX(event);
// Event coordinates are relative to the viewport, element absolute
// position is relative to the document. Make element position relative
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java b/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java
index 32abc787da..34bdb28c91 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java
@@ -53,14 +53,6 @@ public class VHtml5DragEvent extends NativeEvent {
return null;
}-*/;
- /**
- * @deprecated As of Vaadin 6.8, replaced by {@link #setDropEffect(String)}.
- */
- @Deprecated
- public final void setDragEffect(String effect) {
- setDropEffect(effect);
- }
-
public final native void setDropEffect(String effect)
/*-{
try {
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java
index 7d5edfadf5..cbe06244af 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/FormLayoutConnector.java
@@ -18,7 +18,7 @@ package com.vaadin.terminal.gwt.client.ui.formlayout;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.Connect;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
@@ -46,7 +46,7 @@ public class FormLayoutConnector extends AbstractLayoutConnector {
VFormLayoutTable formLayoutTable = getWidget().table;
- formLayoutTable.setMargins(new VMarginInfo(getState()
+ formLayoutTable.setMargins(new MarginInfo(getState()
.getMarginsBitmask()));
formLayoutTable.setSpacing(getState().isSpacing());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java
index d3ce6f3d3f..7f211aaf9c 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/formlayout/VFormLayout.java
@@ -29,7 +29,7 @@ import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ComponentState;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
@@ -112,7 +112,7 @@ public class VFormLayout extends SimplePanel {
}
}
- public void setMargins(VMarginInfo margins) {
+ public void setMargins(MarginInfo margins) {
Element margin = getElement();
setStyleName(margin, CLASSNAME + "-" + StyleConstants.MARGIN_TOP,
margins.hasTop());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java
index 520afb778d..9a2732e408 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/GridLayoutConnector.java
@@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.AlignmentInfo;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.LayoutClickRpc;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc;
import com.vaadin.shared.ui.gridlayout.GridLayoutState;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
@@ -163,7 +163,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
layout.colExpandRatioArray = uidl.getIntArrayAttribute("colExpand");
layout.rowExpandRatioArray = uidl.getIntArrayAttribute("rowExpand");
- layout.updateMarginStyleNames(new VMarginInfo(getState()
+ layout.updateMarginStyleNames(new MarginInfo(getState()
.getMarginsBitmask()));
layout.updateSpacingStyleName(getState().isSpacing());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java
index 25d7de6ee6..ef44964da7 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/gridlayout/VGridLayout.java
@@ -29,7 +29,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.AlignmentInfo;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ConnectorMap;
@@ -677,7 +677,7 @@ public class VGridLayout extends ComplexPanel {
}
}
- void updateMarginStyleNames(VMarginInfo marginInfo) {
+ void updateMarginStyleNames(MarginInfo marginInfo) {
togglePrefixedStyleName("margin-top", marginInfo.hasTop());
togglePrefixedStyleName("margin-right", marginInfo.hasRight());
togglePrefixedStyleName("margin-bottom", marginInfo.hasBottom());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java
index 4280db8bc9..57f8c16952 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java
@@ -43,10 +43,10 @@ public class LabelConnector extends AbstractComponentConnector {
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
boolean sinkOnloads = false;
- switch (getState().getContentMode()) {
+ switch (getState().contentMode) {
case PREFORMATTED:
PreElement preElement = Document.get().createPreElement();
- preElement.setInnerText(getState().getText());
+ preElement.setInnerText(getState().text);
// clear existing content
getWidget().setHTML("");
// add preformatted text to dom
@@ -54,14 +54,14 @@ public class LabelConnector extends AbstractComponentConnector {
break;
case TEXT:
- getWidget().setText(getState().getText());
+ getWidget().setText(getState().text);
break;
case XHTML:
case RAW:
sinkOnloads = true;
case XML:
- getWidget().setHTML(getState().getText());
+ getWidget().setHTML(getState().text);
break;
default:
getWidget().setText("");
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
index c4bbcd34f7..f2b8361f2b 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/link/LinkConnector.java
@@ -17,6 +17,7 @@
package com.vaadin.terminal.gwt.client.ui.link;
import com.google.gwt.user.client.DOM;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.Connect;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Paintable;
@@ -57,12 +58,12 @@ public class LinkConnector extends AbstractComponentConnector implements
if (uidl.hasAttribute("border")) {
if ("none".equals(uidl.getStringAttribute("border"))) {
- getWidget().borderStyle = VLink.BORDER_STYLE_NONE;
+ getWidget().borderStyle = BorderStyle.NONE;
} else {
- getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL;
+ getWidget().borderStyle = BorderStyle.MINIMAL;
}
} else {
- getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT;
+ getWidget().borderStyle = BorderStyle.DEFAULT;
}
getWidget().targetHeight = uidl.hasAttribute("targetHeight") ? uidl
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java b/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
index e312d4d489..b0e44c9d13 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/link/VLink.java
@@ -23,6 +23,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.Icon;
@@ -31,15 +32,20 @@ public class VLink extends HTML implements ClickHandler {
public static final String CLASSNAME = "v-link";
- protected static final int BORDER_STYLE_DEFAULT = 0;
- protected static final int BORDER_STYLE_MINIMAL = 1;
- protected static final int BORDER_STYLE_NONE = 2;
+ @Deprecated
+ protected static final BorderStyle BORDER_STYLE_DEFAULT = BorderStyle.DEFAULT;
+
+ @Deprecated
+ protected static final BorderStyle BORDER_STYLE_MINIMAL = BorderStyle.MINIMAL;
+
+ @Deprecated
+ protected static final BorderStyle BORDER_STYLE_NONE = BorderStyle.NONE;
protected String src;
protected String target;
- protected int borderStyle = BORDER_STYLE_DEFAULT;
+ protected BorderStyle borderStyle = BorderStyle.DEFAULT;
protected boolean enabled;
@@ -73,10 +79,10 @@ public class VLink extends HTML implements ClickHandler {
}
String features;
switch (borderStyle) {
- case BORDER_STYLE_NONE:
+ case NONE:
features = "menubar=no,location=no,status=no";
break;
- case BORDER_STYLE_MINIMAL:
+ case MINIMAL:
features = "menubar=yes,location=no,status=no";
break;
default:
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
index 6e253c9137..b4cea2dc72 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java
@@ -29,6 +29,7 @@ import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.shared.Position;
import com.vaadin.shared.ui.root.RootConstants;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
@@ -38,13 +39,13 @@ import com.vaadin.terminal.gwt.client.ui.VOverlay;
public class VNotification extends VOverlay {
- public static final int CENTERED = 1;
- public static final int CENTERED_TOP = 2;
- public static final int CENTERED_BOTTOM = 3;
- public static final int TOP_LEFT = 4;
- public static final int TOP_RIGHT = 5;
- public static final int BOTTOM_LEFT = 6;
- public static final int BOTTOM_RIGHT = 7;
+ public static final Position CENTERED = Position.MIDDLE_CENTER;
+ public static final Position CENTERED_TOP = Position.TOP_CENTER;
+ public static final Position CENTERED_BOTTOM = Position.BOTTOM_CENTER;
+ public static final Position TOP_LEFT = Position.TOP_LEFT;
+ public static final Position TOP_RIGHT = Position.TOP_RIGHT;
+ public static final Position BOTTOM_LEFT = Position.BOTTOM_LEFT;
+ public static final Position BOTTOM_RIGHT = Position.BOTTOM_RIGHT;
public static final int DELAY_FOREVER = -1;
public static final int DELAY_NONE = 0;
@@ -144,21 +145,21 @@ public class VNotification extends VOverlay {
show(CENTERED, style);
}
- public void show(int position) {
+ public void show(com.vaadin.shared.Position position) {
show(position, null);
}
- public void show(Widget widget, int position, String style) {
+ public void show(Widget widget, Position position, String style) {
setWidget(widget);
show(position, style);
}
- public void show(String html, int position, String style) {
+ public void show(String html, Position position, String style) {
setWidget(new HTML(html));
show(position, style);
}
- public void show(int position, String style) {
+ public void show(Position position, String style) {
setOpacity(getElement(), startOpacity);
if (style != null) {
temporaryStyle = style;
@@ -231,7 +232,7 @@ public class VNotification extends VOverlay {
}
}
- public void setPosition(int position) {
+ public void setPosition(com.vaadin.shared.Position position) {
final Element el = getElement();
DOM.setStyleAttribute(el, "top", "");
DOM.setStyleAttribute(el, "left", "");
@@ -260,17 +261,17 @@ public class VNotification extends VOverlay {
DOM.setStyleAttribute(el, "bottom", "0px");
DOM.setStyleAttribute(el, "left", "0px");
break;
- case CENTERED_TOP:
+ case TOP_CENTER:
center();
DOM.setStyleAttribute(el, "top", "0px");
break;
- case CENTERED_BOTTOM:
+ case BOTTOM_CENTER:
center();
DOM.setStyleAttribute(el, "top", "");
DOM.setStyleAttribute(el, "bottom", "0px");
break;
default:
- case CENTERED:
+ case MIDDLE_CENTER:
center();
break;
}
@@ -417,8 +418,11 @@ public class VNotification extends VOverlay {
.hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification
.getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE)
: null;
- final int position = notification
+
+ final int pos = notification
.getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_POSITION);
+ Position position = Position.values()[pos];
+
final int delay = notification
.getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY);
createNotification(delay).show(html, position, style);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
index 5da01bf127..122547ddb4 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
@@ -23,7 +23,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.AlignmentInfo;
import com.vaadin.shared.ui.LayoutClickRpc;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
import com.vaadin.terminal.gwt.client.ComponentConnector;
@@ -133,9 +133,8 @@ public abstract class AbstractOrderedLayoutConnector extends
slot.setExpandRatio(expandRatio);
}
- layout.updateMarginStyleNames(new VMarginInfo(getState()
+ layout.updateMarginStyleNames(new MarginInfo(getState()
.getMarginsBitmask()));
-
layout.updateSpacingStyleName(getState().isSpacing());
getLayoutManager().setNeedsLayout(this);
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java
index ec2c4afa97..ee55bc07ba 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/orderedlayout/VMeasuringOrderedLayout.java
@@ -27,7 +27,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.WidgetCollection;
-import com.vaadin.shared.ui.VMarginInfo;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.gwt.client.VCaption;
import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot;
@@ -75,7 +75,7 @@ public class VMeasuringOrderedLayout extends ComplexPanel {
}
}
- void updateMarginStyleNames(VMarginInfo marginInfo) {
+ void updateMarginStyleNames(MarginInfo marginInfo) {
togglePrefixedStyleName("margin-top", marginInfo.hasTop());
togglePrefixedStyleName("margin-right", marginInfo.hasRight());
togglePrefixedStyleName("margin-bottom", marginInfo.hasBottom());
diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
index 9b5c3cd767..b3490effa7 100644
--- a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
+++ b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
@@ -25,16 +25,10 @@ import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -92,14 +86,6 @@ public class RootConnector extends AbstractComponentContainerConnector
com.google.gwt.user.client.Window.setTitle(title);
}
});
- final int heartbeatInterval = getState().getHeartbeatInterval();
- new Timer() {
- @Override
- public void run() {
- sendHeartbeat();
- schedule(heartbeatInterval);
- }
- }.schedule(heartbeatInterval);
getWidget().addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
@@ -468,28 +454,4 @@ public class RootConnector extends AbstractComponentContainerConnector
});
}
- private void sendHeartbeat() {
- RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "url");
-
- rb.setCallback(new RequestCallback() {
-
- @Override
- public void onResponseReceived(Request request, Response response) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onError(Request request, Throwable exception) {
- // TODO Auto-generated method stub
-
- }
- });
-
- try {
- rb.send();
- } catch (RequestException re) {
-
- }
- }
}
diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java
index b120c8455a..d2924eb716 100644
--- a/server/src/com/vaadin/Application.java
+++ b/server/src/com/vaadin/Application.java
@@ -32,6 +32,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@@ -56,6 +57,7 @@ import com.vaadin.terminal.ApplicationResource;
import com.vaadin.terminal.CombinedRequest;
import com.vaadin.terminal.DeploymentConfiguration;
import com.vaadin.terminal.RequestHandler;
+import com.vaadin.terminal.RootProvider;
import com.vaadin.terminal.Terminal;
import com.vaadin.terminal.VariableOwner;
import com.vaadin.terminal.WrappedRequest;
@@ -503,6 +505,8 @@ public class Application implements Terminal.ErrorListener, Serializable {
*/
private Set<Integer> initedRoots = new HashSet<Integer>();
+ private List<RootProvider> rootProviders = new LinkedList<RootProvider>();
+
/**
* Gets the user of the application.
*
@@ -1873,55 +1877,21 @@ public class Application implements Terminal.ErrorListener, Serializable {
*/
protected Root getRoot(WrappedRequest request)
throws RootRequiresMoreInformationException {
- String rootClassName = getRootClassName(request);
- try {
- ClassLoader classLoader = request.getDeploymentConfiguration()
- .getClassLoader();
- if (classLoader == null) {
- classLoader = getClass().getClassLoader();
- }
- Class<? extends Root> rootClass = Class.forName(rootClassName,
- true, classLoader).asSubclass(Root.class);
- try {
- Root root = rootClass.newInstance();
- return root;
- } catch (Exception e) {
- throw new RuntimeException("Could not instantiate root class "
- + rootClassName, e);
+
+ // Iterate in reverse order - test check newest provider first
+ for (int i = rootProviders.size() - 1; i >= 0; i--) {
+ RootProvider provider = rootProviders.get(i);
+
+ Class<? extends Root> rootClass = provider.getRootClass(this,
+ request);
+
+ if (rootClass != null) {
+ return provider.instantiateRoot(this, rootClass, request);
}
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Could not load root class "
- + rootClassName, e);
}
- }
- /**
- * Provides the name of the <code>Root</code> class that should be used for
- * a request. The class must have an accessible no-args constructor.
- * <p>
- * The default implementation uses the {@value #ROOT_PARAMETER} parameter
- * from web.xml.
- * </p>
- * <p>
- * This method is mainly used by the default implementation of
- * {@link #getRoot(WrappedRequest)}. If you override that method with your
- * own functionality, the results of this method might not be used.
- * </p>
- *
- * @param request
- * the request for which a new root is required
- * @return the name of the root class to use
- *
- * @since 7.0
- */
- protected String getRootClassName(WrappedRequest request) {
- Object rootClassNameObj = getProperties().get(ROOT_PARAMETER);
- if (rootClassNameObj instanceof String) {
- return (String) rootClassNameObj;
- } else {
- throw new RuntimeException("No " + ROOT_PARAMETER
- + " defined in web.xml");
- }
+ throw new RuntimeException(
+ "No root providers available or providers are not able to find root instance");
}
/**
@@ -2169,6 +2139,14 @@ public class Application implements Terminal.ErrorListener, Serializable {
return configuration.isProductionMode();
}
+ public void addRootProvider(RootProvider rootProvider) {
+ rootProviders.add(rootProvider);
+ }
+
+ public void removeRootProvider(RootProvider rootProvider) {
+ rootProviders.remove(rootProvider);
+ }
+
/**
* Finds the {@link Root} to which a particular request belongs. If the
* request originates from an existing Root, that root is returned. In other
diff --git a/server/src/com/vaadin/data/Buffered.java b/server/src/com/vaadin/data/Buffered.java
index 5461d34fbd..0b59c9ff97 100644
--- a/server/src/com/vaadin/data/Buffered.java
+++ b/server/src/com/vaadin/data/Buffered.java
@@ -77,82 +77,6 @@ public interface Buffered extends Serializable {
public void discard() throws SourceException;
/**
- * Tests if the object is in write-through mode. If the object is in
- * write-through mode, all modifications to it will result in
- * <code>commit</code> being called after the modification.
- *
- * @return <code>true</code> if the object is in write-through mode,
- * <code>false</code> if it's not.
- * @deprecated Use {@link #setBuffered(boolean)} instead. Note that
- * setReadThrough(true), setWriteThrough(true) equals
- * setBuffered(false)
- */
- @Deprecated
- public boolean isWriteThrough();
-
- /**
- * Sets the object's write-through mode to the specified status. When
- * switching the write-through mode on, the <code>commit</code> operation
- * will be performed.
- *
- * @param writeThrough
- * Boolean value to indicate if the object should be in
- * write-through mode after the call.
- * @throws SourceException
- * If the operation fails because of an exception is thrown by
- * the data source.
- * @throws InvalidValueException
- * If the implicit commit operation fails because of a
- * validation error.
- *
- * @deprecated Use {@link #setBuffered(boolean)} instead. Note that
- * setReadThrough(true), setWriteThrough(true) equals
- * setBuffered(false)
- */
- @Deprecated
- public void setWriteThrough(boolean writeThrough) throws SourceException,
- InvalidValueException;
-
- /**
- * Tests if the object is in read-through mode. If the object is in
- * read-through mode, retrieving its value will result in the value being
- * first updated from the data source to the object.
- * <p>
- * The only exception to this rule is that when the object is not in
- * write-through mode and it's buffer contains a modified value, the value
- * retrieved from the object will be the locally modified value in the
- * buffer which may differ from the value in the data source.
- * </p>
- *
- * @return <code>true</code> if the object is in read-through mode,
- * <code>false</code> if it's not.
- * @deprecated Use {@link #isBuffered(boolean)} instead. Note that
- * setReadThrough(true), setWriteThrough(true) equals
- * setBuffered(false)
- */
- @Deprecated
- public boolean isReadThrough();
-
- /**
- * Sets the object's read-through mode to the specified status. When
- * switching read-through mode on, the object's value is updated from the
- * data source.
- *
- * @param readThrough
- * Boolean value to indicate if the object should be in
- * read-through mode after the call.
- *
- * @throws SourceException
- * If the operation fails because of an exception is thrown by
- * the data source. The cause is included in the exception.
- * @deprecated Use {@link #setBuffered(boolean)} instead. Note that
- * setReadThrough(true), setWriteThrough(true) equals
- * setBuffered(false)
- */
- @Deprecated
- public void setReadThrough(boolean readThrough) throws SourceException;
-
- /**
* Sets the object's buffered mode to the specified status.
* <p>
* When the object is in buffered mode, an internal buffer will be used to
diff --git a/server/src/com/vaadin/data/util/QueryContainer.java b/server/src/com/vaadin/data/util/QueryContainer.java
deleted file mode 100644
index add93c25ee..0000000000
--- a/server/src/com/vaadin/data/util/QueryContainer.java
+++ /dev/null
@@ -1,685 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.data.util;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-
-/**
- * <p>
- * The <code>QueryContainer</code> is the specialized form of Container which is
- * Ordered and Indexed. This is used to represent the contents of relational
- * database tables accessed through the JDBC Connection in the Vaadin Table.
- * This creates Items based on the queryStatement provided to the container.
- * </p>
- *
- * <p>
- * The <code>QueryContainer</code> can be visualized as a representation of a
- * relational database table.Each Item in the container represents the row
- * fetched by the query.All cells in a column have same data type and the data
- * type information is retrieved from the metadata of the resultset.
- * </p>
- *
- * <p>
- * Note : If data in the tables gets modified, Container will not get reflected
- * with the updates, we have to explicity invoke QueryContainer.refresh method.
- * {@link com.vaadin.data.util.QueryContainer#refresh() refresh()}
- * </p>
- *
- * @see com.vaadin.data.Container
- *
- * @author Vaadin Ltd.
- * @since 4.0
- *
- * @deprecated will be removed in the future, use the SQLContainer add-on
- */
-
-@Deprecated
-@SuppressWarnings("serial")
-public class QueryContainer implements Container, Container.Ordered,
- Container.Indexed {
-
- // default ResultSet type
- public static final int DEFAULT_RESULTSET_TYPE = ResultSet.TYPE_SCROLL_INSENSITIVE;
-
- // default ResultSet concurrency
- public static final int DEFAULT_RESULTSET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY;
-
- private int resultSetType = DEFAULT_RESULTSET_TYPE;
-
- private int resultSetConcurrency = DEFAULT_RESULTSET_CONCURRENCY;
-
- private final String queryStatement;
-
- private final Connection connection;
-
- private ResultSet result;
-
- private Collection<String> propertyIds;
-
- private final HashMap<String, Class<?>> propertyTypes = new HashMap<String, Class<?>>();
-
- private int size = -1;
-
- private Statement statement;
-
- /**
- * Constructs new <code>QueryContainer</code> with the specified
- * <code>queryStatement</code>.
- *
- * @param queryStatement
- * Database query
- * @param connection
- * Connection object
- * @param resultSetType
- * @param resultSetConcurrency
- * @throws SQLException
- * when database operation fails
- */
- public QueryContainer(String queryStatement, Connection connection,
- int resultSetType, int resultSetConcurrency) throws SQLException {
- this.queryStatement = queryStatement;
- this.connection = connection;
- this.resultSetType = resultSetType;
- this.resultSetConcurrency = resultSetConcurrency;
- init();
- }
-
- /**
- * Constructs new <code>QueryContainer</code> with the specified
- * queryStatement using the default resultset type and default resultset
- * concurrency.
- *
- * @param queryStatement
- * Database query
- * @param connection
- * Connection object
- * @see QueryContainer#DEFAULT_RESULTSET_TYPE
- * @see QueryContainer#DEFAULT_RESULTSET_CONCURRENCY
- * @throws SQLException
- * when database operation fails
- */
- public QueryContainer(String queryStatement, Connection connection)
- throws SQLException {
- this(queryStatement, connection, DEFAULT_RESULTSET_TYPE,
- DEFAULT_RESULTSET_CONCURRENCY);
- }
-
- /**
- * Fills the Container with the items and properties. Invoked by the
- * constructor.
- *
- * @throws SQLException
- * when parameter initialization fails.
- * @see QueryContainer#QueryContainer(String, Connection, int, int).
- */
- private void init() throws SQLException {
- refresh();
- ResultSetMetaData metadata;
- metadata = result.getMetaData();
- final int count = metadata.getColumnCount();
- final ArrayList<String> list = new ArrayList<String>(count);
- for (int i = 1; i <= count; i++) {
- final String columnName = metadata.getColumnName(i);
- list.add(columnName);
- final Property<?> p = getContainerProperty(new Integer(1),
- columnName);
- propertyTypes.put(columnName,
- p == null ? Object.class : p.getType());
- }
- propertyIds = Collections.unmodifiableCollection(list);
- }
-
- /**
- * <p>
- * Restores items in the container. This method will update the latest data
- * to the container.
- * </p>
- * Note: This method should be used to update the container with the latest
- * items.
- *
- * @throws SQLException
- * when database operation fails
- *
- */
-
- public void refresh() throws SQLException {
- close();
- statement = connection.createStatement(resultSetType,
- resultSetConcurrency);
- result = statement.executeQuery(queryStatement);
- result.last();
- size = result.getRow();
- }
-
- /**
- * Releases and nullifies the <code>statement</code>.
- *
- * @throws SQLException
- * when database operation fails
- */
-
- public void close() throws SQLException {
- if (statement != null) {
- statement.close();
- }
- statement = null;
- }
-
- /**
- * Gets the Item with the given Item ID from the Container.
- *
- * @param id
- * ID of the Item to retrieve
- * @return Item Id.
- */
-
- @Override
- public Item getItem(Object id) {
- return new Row(id);
- }
-
- /**
- * Gets the collection of propertyId from the Container.
- *
- * @return Collection of Property ID.
- */
-
- @Override
- public Collection<String> getContainerPropertyIds() {
- return propertyIds;
- }
-
- /**
- * Gets an collection of all the item IDs in the container.
- *
- * @return collection of Item IDs
- */
- @Override
- public Collection<?> getItemIds() {
- final Collection<Integer> c = new ArrayList<Integer>(size);
- for (int i = 1; i <= size; i++) {
- c.add(new Integer(i));
- }
- return c;
- }
-
- /**
- * Gets the property identified by the given itemId and propertyId from the
- * container. If the container does not contain the property
- * <code>null</code> is returned.
- *
- * @param itemId
- * ID of the Item which contains the Property
- * @param propertyId
- * ID of the Property to retrieve
- *
- * @return Property with the given ID if exists; <code>null</code>
- * otherwise.
- */
-
- @Override
- public synchronized Property<?> getContainerProperty(Object itemId,
- Object propertyId) {
- if (!(itemId instanceof Integer && propertyId instanceof String)) {
- return null;
- }
- Object value;
- try {
- result.absolute(((Integer) itemId).intValue());
- value = result.getObject((String) propertyId);
- } catch (final Exception e) {
- return null;
- }
-
- // Handle also null values from the database
- return new ObjectProperty<Object>(value != null ? value
- : new String(""));
- }
-
- /**
- * Gets the data type of all properties identified by the given type ID.
- *
- * @param id
- * ID identifying the Properties
- *
- * @return data type of the Properties
- */
-
- @Override
- public Class<?> getType(Object id) {
- return propertyTypes.get(id);
- }
-
- /**
- * Gets the number of items in the container.
- *
- * @return the number of items in the container.
- */
- @Override
- public int size() {
- return size;
- }
-
- /**
- * Tests if the list contains the specified Item.
- *
- * @param id
- * ID the of Item to be tested.
- * @return <code>true</code> if given id is in the container;
- * <code>false</code> otherwise.
- */
- @Override
- public boolean containsId(Object id) {
- if (!(id instanceof Integer)) {
- return false;
- }
- final int i = ((Integer) id).intValue();
- if (i < 1) {
- return false;
- }
- if (i > size) {
- return false;
- }
- return true;
- }
-
- /**
- * Creates new Item with the given ID into the Container.
- *
- * @param itemId
- * ID of the Item to be created.
- *
- * @return Created new Item, or <code>null</code> if it fails.
- *
- * @throws UnsupportedOperationException
- * if the addItem method is not supported.
- */
- @Override
- public Item addItem(Object itemId) throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Creates a new Item into the Container, and assign it an ID.
- *
- * @return ID of the newly created Item, or <code>null</code> if it fails.
- * @throws UnsupportedOperationException
- * if the addItem method is not supported.
- */
- @Override
- public Object addItem() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Removes the Item identified by ItemId from the Container.
- *
- * @param itemId
- * ID of the Item to remove.
- * @return <code>true</code> if the operation succeeded; <code>false</code>
- * otherwise.
- * @throws UnsupportedOperationException
- * if the removeItem method is not supported.
- */
- @Override
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Adds new Property to all Items in the Container.
- *
- * @param propertyId
- * ID of the Property
- * @param type
- * Data type of the new Property
- * @param defaultValue
- * The value all created Properties are initialized to.
- * @return <code>true</code> if the operation succeeded; <code>false</code>
- * otherwise.
- * @throws UnsupportedOperationException
- * if the addContainerProperty method is not supported.
- */
- @Override
- public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Removes a Property specified by the given Property ID from the Container.
- *
- * @param propertyId
- * ID of the Property to remove
- * @return <code>true</code> if the operation succeeded; <code>false</code>
- * otherwise.
- * @throws UnsupportedOperationException
- * if the removeContainerProperty method is not supported.
- */
- @Override
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Removes all Items from the Container.
- *
- * @return <code>true</code> if the operation succeeded; <code>false</code>
- * otherwise.
- * @throws UnsupportedOperationException
- * if the removeAllItems method is not supported.
- */
- @Override
- public boolean removeAllItems() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Adds new item after the given item.
- *
- * @param previousItemId
- * Id of the previous item in ordered container.
- * @param newItemId
- * Id of the new item to be added.
- * @return Returns new item or <code>null</code> if the operation fails.
- * @throws UnsupportedOperationException
- * if the addItemAfter method is not supported.
- */
- @Override
- public Item addItemAfter(Object previousItemId, Object newItemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Adds new item after the given item.
- *
- * @param previousItemId
- * Id of the previous item in ordered container.
- * @return Returns item id created new item or <code>null</code> if the
- * operation fails.
- * @throws UnsupportedOperationException
- * if the addItemAfter method is not supported.
- */
- @Override
- public Object addItemAfter(Object previousItemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns id of first item in the Container.
- *
- * @return ID of the first Item in the list.
- */
- @Override
- public Object firstItemId() {
- if (size < 1) {
- return null;
- }
- return new Integer(1);
- }
-
- /**
- * Returns <code>true</code> if given id is first id at first index.
- *
- * @param id
- * ID of an Item in the Container.
- */
- @Override
- public boolean isFirstId(Object id) {
- return size > 0 && (id instanceof Integer)
- && ((Integer) id).intValue() == 1;
- }
-
- /**
- * Returns <code>true</code> if given id is last id at last index.
- *
- * @param id
- * ID of an Item in the Container
- *
- */
- @Override
- public boolean isLastId(Object id) {
- return size > 0 && (id instanceof Integer)
- && ((Integer) id).intValue() == size;
- }
-
- /**
- * Returns id of last item in the Container.
- *
- * @return ID of the last Item.
- */
- @Override
- public Object lastItemId() {
- if (size < 1) {
- return null;
- }
- return new Integer(size);
- }
-
- /**
- * Returns id of next item in container at next index.
- *
- * @param id
- * ID of an Item in the Container.
- * @return ID of the next Item or null.
- */
- @Override
- public Object nextItemId(Object id) {
- if (size < 1 || !(id instanceof Integer)) {
- return null;
- }
- final int i = ((Integer) id).intValue();
- if (i >= size) {
- return null;
- }
- return new Integer(i + 1);
- }
-
- /**
- * Returns id of previous item in container at previous index.
- *
- * @param id
- * ID of an Item in the Container.
- * @return ID of the previous Item or null.
- */
- @Override
- public Object prevItemId(Object id) {
- if (size < 1 || !(id instanceof Integer)) {
- return null;
- }
- final int i = ((Integer) id).intValue();
- if (i <= 1) {
- return null;
- }
- return new Integer(i - 1);
- }
-
- /**
- * The <code>Row</code> class implements methods of Item.
- *
- * @author Vaadin Ltd.
- * @since 4.0
- */
- class Row implements Item {
-
- Object id;
-
- private Row(Object rowId) {
- id = rowId;
- }
-
- /**
- * Adds the item property.
- *
- * @param id
- * ID of the new Property.
- * @param property
- * Property to be added and associated with ID.
- * @return <code>true</code> if the operation succeeded;
- * <code>false</code> otherwise.
- * @throws UnsupportedOperationException
- * if the addItemProperty method is not supported.
- */
- @Override
- public boolean addItemProperty(Object id, Property property)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Gets the property corresponding to the given property ID stored in
- * the Item.
- *
- * @param propertyId
- * identifier of the Property to get
- * @return the Property with the given ID or <code>null</code>
- */
- @Override
- public Property<?> getItemProperty(Object propertyId) {
- return getContainerProperty(id, propertyId);
- }
-
- /**
- * Gets the collection of property IDs stored in the Item.
- *
- * @return unmodifiable collection containing IDs of the Properties
- * stored the Item.
- */
- @Override
- public Collection<String> getItemPropertyIds() {
- return propertyIds;
- }
-
- /**
- * Removes given item property.
- *
- * @param id
- * ID of the Property to be removed.
- * @return <code>true</code> if the item property is removed;
- * <code>false</code> otherwise.
- * @throws UnsupportedOperationException
- * if the removeItemProperty is not supported.
- */
- @Override
- public boolean removeItemProperty(Object id)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- }
-
- /**
- * Closes the statement.
- *
- * @see #close()
- */
- @Override
- public void finalize() {
- try {
- close();
- } catch (final SQLException ignored) {
-
- }
- }
-
- /**
- * Adds the given item at the position of given index.
- *
- * @param index
- * Index to add the new item.
- * @param newItemId
- * Id of the new item to be added.
- * @return new item or <code>null</code> if the operation fails.
- * @throws UnsupportedOperationException
- * if the addItemAt is not supported.
- */
- @Override
- public Item addItemAt(int index, Object newItemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Adds item at the position of provided index in the container.
- *
- * @param index
- * Index to add the new item.
- * @return item id created new item or <code>null</code> if the operation
- * fails.
- *
- * @throws UnsupportedOperationException
- * if the addItemAt is not supported.
- */
-
- @Override
- public Object addItemAt(int index) throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Gets the Index id in the container.
- *
- * @param index
- * Index Id.
- * @return ID in the given index.
- */
- @Override
- public Object getIdByIndex(int index) {
- if (size < 1 || index < 0 || index >= size) {
- return null;
- }
- return new Integer(index + 1);
- }
-
- /**
- * Gets the index of the Item corresponding to id in the container.
- *
- * @param id
- * ID of an Item in the Container
- * @return index of the Item, or -1 if the Container does not include the
- * Item
- */
-
- @Override
- public int indexOfId(Object id) {
- if (size < 1 || !(id instanceof Integer)) {
- return -1;
- }
- final int i = ((Integer) id).intValue();
- if (i >= size || i < 1) {
- return -1;
- }
- return i - 1;
- }
-
-}
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
index 0146c92b5c..6e5ba0dc57 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
@@ -69,7 +69,9 @@ final public class ColumnProperty implements Property {
* @param value
* @param type
*
- * @deprecated
+ * @deprecated as of 7.0. Use
+ * {@link #ColumnProperty(String, boolean, boolean, boolean, boolean, Object, Class)
+ * instead
*/
@Deprecated
public ColumnProperty(String propertyId, boolean readOnly,
@@ -144,7 +146,7 @@ final public class ColumnProperty implements Property {
@Override
public void setValue(Object newValue) throws ReadOnlyException,
- ConversionException {
+ ConversionException {
if (newValue == null && !nullable) {
throw new NotNullableException(
"Null values are not allowed for this property.");
diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java
index 50ddef6265..296d12ba92 100644
--- a/server/src/com/vaadin/event/ActionManager.java
+++ b/server/src/com/vaadin/event/ActionManager.java
@@ -67,7 +67,7 @@ public class ActionManager implements Action.Container, Action.Handler,
private void requestRepaint() {
if (viewer != null) {
- viewer.requestRepaint();
+ viewer.markAsDirty();
}
}
diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java
index bc1cd2af1a..d2490225fb 100644
--- a/server/src/com/vaadin/terminal/AbstractClientConnector.java
+++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java
@@ -31,9 +31,12 @@ import java.util.NoSuchElementException;
import java.util.logging.Logger;
import com.vaadin.Application;
+import com.vaadin.external.json.JSONException;
+import com.vaadin.external.json.JSONObject;
import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.communication.SharedState;
+import com.vaadin.terminal.gwt.server.AbstractCommunicationManager;
import com.vaadin.terminal.gwt.server.ClientConnector;
import com.vaadin.terminal.gwt.server.ClientMethodInvocation;
import com.vaadin.terminal.gwt.server.RpcManager;
@@ -68,6 +71,8 @@ public abstract class AbstractClientConnector implements ClientConnector {
*/
private SharedState sharedState;
+ private Class<? extends SharedState> stateType;
+
/**
* Pending RPC method invocations to be sent.
*/
@@ -80,8 +85,15 @@ public abstract class AbstractClientConnector implements ClientConnector {
private ClientConnector parent;
/* Documentation copied from interface */
+ @Deprecated
@Override
public void requestRepaint() {
+ markAsDirty();
+ }
+
+ /* Documentation copied from interface */
+ @Override
+ public void markAsDirty() {
Root root = getRoot();
if (root != null) {
root.getConnectorTracker().markDirty(this);
@@ -137,14 +149,24 @@ public abstract class AbstractClientConnector implements ClientConnector {
registerRpc(implementation, type);
}
- @Override
- public SharedState getState() {
+ protected SharedState getState() {
if (null == sharedState) {
sharedState = createState();
}
+
+ Root root = getRoot();
+ if (root != null && !root.getConnectorTracker().isDirty(this)) {
+ requestRepaint();
+ }
+
return sharedState;
}
+ @Override
+ public JSONObject encodeState() throws JSONException {
+ return AbstractCommunicationManager.encodeState(this, getState());
+ }
+
/**
* Creates the shared state bean to be used in server to client
* communication.
@@ -172,17 +194,33 @@ public abstract class AbstractClientConnector implements ClientConnector {
}
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.terminal.gwt.server.ClientConnector#getStateType()
- */
@Override
public Class<? extends SharedState> getStateType() {
+ // Lazy load because finding type can be expensive because of the
+ // exceptions flying around
+ if (stateType == null) {
+ stateType = findStateType();
+ }
+
+ return stateType;
+ }
+
+ private Class<? extends SharedState> findStateType() {
try {
- Method m = getClass().getMethod("getState", (Class[]) null);
- Class<?> type = m.getReturnType();
- return type.asSubclass(SharedState.class);
+ Class<?> class1 = getClass();
+ while (class1 != null) {
+ try {
+ Method m = class1.getDeclaredMethod("getState",
+ (Class[]) null);
+ Class<?> type = m.getReturnType();
+ return type.asSubclass(SharedState.class);
+ } catch (NoSuchMethodException nsme) {
+ // Try in superclass instead
+ class1 = class1.getSuperclass();
+ }
+ }
+ throw new NoSuchMethodException(getClass().getCanonicalName()
+ + ".getState()");
} catch (Exception e) {
throw new RuntimeException("Error finding state type for "
+ getClass().getName(), e);
@@ -255,8 +293,6 @@ public abstract class AbstractClientConnector implements ClientConnector {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
addMethodInvocationToQueue(rpcInterfaceName, method, args);
- // TODO no need to do full repaint if only RPC calls
- requestRepaint();
return null;
}
@@ -279,6 +315,8 @@ public abstract class AbstractClientConnector implements ClientConnector {
// add to queue
pendingInvocations.add(new ClientMethodInvocation(this, interfaceName,
method, parameters));
+ // TODO no need to do full repaint if only RPC calls
+ requestRepaint();
}
/**
@@ -358,11 +396,17 @@ public abstract class AbstractClientConnector implements ClientConnector {
}
@Override
+ @Deprecated
public void requestRepaintAll() {
- requestRepaint();
+ markAsDirtyRecursive();
+ }
+
+ @Override
+ public void markAsDirtyRecursive() {
+ markAsDirty();
for (ClientConnector connector : getAllChildrenIterable(this)) {
- connector.requestRepaintAll();
+ connector.markAsDirtyRecursive();
}
}
@@ -438,14 +482,14 @@ public abstract class AbstractClientConnector implements ClientConnector {
extensions.add(extension);
extension.setParent(this);
- requestRepaint();
+ markAsDirty();
}
@Override
public void removeExtension(Extension extension) {
extension.setParent(null);
extensions.remove(extension);
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -482,7 +526,7 @@ public abstract class AbstractClientConnector implements ClientConnector {
@Override
public void attach() {
- requestRepaint();
+ markAsDirty();
getRoot().getConnectorTracker().registerConnector(this);
diff --git a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java b/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java
index aae71640aa..1def6df697 100644
--- a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java
+++ b/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java
@@ -166,7 +166,7 @@ public abstract class AbstractJavaScriptExtension extends AbstractExtension {
}
@Override
- public JavaScriptExtensionState getState() {
+ protected JavaScriptExtensionState getState() {
return (JavaScriptExtensionState) super.getState();
}
}
diff --git a/server/src/com/vaadin/terminal/AbstractRootProvider.java b/server/src/com/vaadin/terminal/AbstractRootProvider.java
new file mode 100644
index 0000000000..0b63003440
--- /dev/null
+++ b/server/src/com/vaadin/terminal/AbstractRootProvider.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Root;
+
+public abstract class AbstractRootProvider implements RootProvider {
+
+ @Override
+ public Root instantiateRoot(Application application,
+ Class<? extends Root> type, WrappedRequest request) {
+ try {
+ return type.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Could not instantiate root class", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Could not access root class", e);
+ }
+ }
+}
diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java
new file mode 100644
index 0000000000..cbf8c98828
--- /dev/null
+++ b/server/src/com/vaadin/terminal/DefaultRootProvider.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.ui.Root;
+
+public class DefaultRootProvider extends AbstractRootProvider {
+
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request) throws RootRequiresMoreInformationException {
+ Object rootClassNameObj = application
+ .getProperty(Application.ROOT_PARAMETER);
+
+ if (rootClassNameObj instanceof String) {
+ String rootClassName = rootClassNameObj.toString();
+
+ ClassLoader classLoader = request.getDeploymentConfiguration()
+ .getClassLoader();
+ if (classLoader == null) {
+ classLoader = getClass().getClassLoader();
+ }
+ try {
+ Class<? extends Root> rootClass = Class.forName(rootClassName,
+ true, classLoader).asSubclass(Root.class);
+
+ return rootClass;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not find root class", e);
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java
index 6153cf2619..f0063a8708 100644
--- a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java
+++ b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java
@@ -60,9 +60,7 @@ public class JavaScriptCallbackHelper implements Serializable {
JavaScriptFunction javaScriptCallback) {
callbacks.put(functionName, javaScriptCallback);
JavaScriptConnectorState state = getConnectorState();
- if (state.getCallbackNames().add(functionName)) {
- connector.requestRepaint();
- }
+ state.getCallbackNames().add(functionName);
ensureRpc();
}
@@ -100,7 +98,6 @@ public class JavaScriptCallbackHelper implements Serializable {
connector.addMethodInvocationToQueue(
JavaScriptCallbackRpc.class.getName(), CALL_METHOD,
new Object[] { name, args });
- connector.requestRepaint();
}
public void registerRpc(Class<?> rpcInterfaceType) {
@@ -119,7 +116,6 @@ public class JavaScriptCallbackHelper implements Serializable {
}
rpcInterfaces.put(interfaceName, methodNames);
- connector.requestRepaint();
}
}
diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java
index 933f9b39e6..41ab8cc8b6 100644
--- a/server/src/com/vaadin/terminal/Page.java
+++ b/server/src/com/vaadin/terminal/Page.java
@@ -24,6 +24,7 @@ import java.util.LinkedList;
import java.util.List;
import com.vaadin.event.EventRouter;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.root.PageClientRpc;
import com.vaadin.shared.ui.root.RootConstants;
import com.vaadin.terminal.WrappedRequest.BrowserDetails;
@@ -128,7 +129,7 @@ public class Page implements Serializable {
/**
* The border style of the target window
*/
- private final int border;
+ private final BorderStyle border;
/**
* Creates a new open resource.
@@ -145,7 +146,7 @@ public class Page implements Serializable {
* The border style of the target window
*/
private OpenResource(Resource resource, String name, int width,
- int height, int border) {
+ int height, BorderStyle border) {
this.resource = resource;
this.name = name;
this.width = width;
@@ -174,10 +175,10 @@ public class Page implements Serializable {
target.addAttribute("height", height);
}
switch (border) {
- case BORDER_MINIMAL:
+ case MINIMAL:
target.addAttribute("border", "minimal");
break;
- case BORDER_NONE:
+ case NONE:
target.addAttribute("border", "none");
break;
}
@@ -193,19 +194,20 @@ public class Page implements Serializable {
/**
* A border style used for opening resources in a window without a border.
*/
- public static final int BORDER_NONE = 0;
+ @Deprecated
+ public static final BorderStyle BORDER_NONE = BorderStyle.NONE;
/**
* A border style used for opening resources in a window with a minimal
* border.
*/
- public static final int BORDER_MINIMAL = 1;
+ public static final BorderStyle BORDER_MINIMAL = BorderStyle.MINIMAL;
/**
* A border style that indicates that the default border style should be
* used when opening resources.
*/
- public static final int BORDER_DEFAULT = 2;
+ public static final BorderStyle BORDER_DEFAULT = BorderStyle.DEFAULT;
/**
* Listener that listens changes in URI fragment.
@@ -330,7 +332,7 @@ public class Page implements Serializable {
if (fireEvents) {
fireEvent(new FragmentChangedEvent(this, newFragment));
}
- root.requestRepaint();
+ root.markAsDirty();
}
}
@@ -491,8 +493,8 @@ public class Page implements Serializable {
true);
}
target.addAttribute(
- RootConstants.ATTRIBUTE_NOTIFICATION_POSITION,
- n.getPosition());
+ RootConstants.ATTRIBUTE_NOTIFICATION_POSITION, n
+ .getPosition().ordinal());
target.addAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY,
n.getDelayMsec());
if (n.getStyleName() != null) {
@@ -521,7 +523,7 @@ public class Page implements Serializable {
*/
public void open(Resource resource) {
openList.add(new OpenResource(resource, null, -1, -1, BORDER_DEFAULT));
- root.requestRepaint();
+ root.markAsDirty();
}
/**
@@ -564,7 +566,7 @@ public class Page implements Serializable {
public void open(Resource resource, String windowName) {
openList.add(new OpenResource(resource, windowName, -1, -1,
BORDER_DEFAULT));
- root.requestRepaint();
+ root.markAsDirty();
}
/**
@@ -581,14 +583,13 @@ public class Page implements Serializable {
* @param height
* the height of the window in pixels
* @param border
- * the border style of the window. See {@link #BORDER_NONE
- * Window.BORDER_* constants}
+ * the border style of the window.
*/
public void open(Resource resource, String windowName, int width,
- int height, int border) {
+ int height, BorderStyle border) {
openList.add(new OpenResource(resource, windowName, width, height,
border));
- root.requestRepaint();
+ root.markAsDirty();
}
/**
@@ -602,7 +603,7 @@ public class Page implements Serializable {
notifications = new LinkedList<Notification>();
}
notifications.add(notification);
- root.requestRepaint();
+ root.markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/terminal/RootProvider.java b/server/src/com/vaadin/terminal/RootProvider.java
new file mode 100644
index 0000000000..476cf1bd78
--- /dev/null
+++ b/server/src/com/vaadin/terminal/RootProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.ui.Root;
+
+public interface RootProvider {
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request) throws RootRequiresMoreInformationException;
+
+ public Root instantiateRoot(Application application,
+ Class<? extends Root> type, WrappedRequest request);
+}
diff --git a/server/src/com/vaadin/terminal/Terminal.java b/server/src/com/vaadin/terminal/Terminal.java
index 29cb649d54..a02bcb50bb 100644
--- a/server/src/com/vaadin/terminal/Terminal.java
+++ b/server/src/com/vaadin/terminal/Terminal.java
@@ -25,44 +25,12 @@ import java.io.Serializable;
*
* @author Vaadin Ltd.
* @since 3.0
+ * @deprecated Currently only a container for ErrorEvent and ErrorListener
*/
+@Deprecated
public interface Terminal extends Serializable {
/**
- * Gets the name of the default theme for this terminal.
- *
- * @return the name of the theme that is used by default by this terminal.
- */
- public String getDefaultTheme();
-
- /**
- * Gets the width of the terminal screen in pixels. This is the width of the
- * screen and not the width available for the application.
- * <p>
- * Note that the screen width is typically not available in the
- * {@link com.vaadin.Application#init()} method as this is called before the
- * browser has a chance to report the screen size to the server.
- * </p>
- *
- * @return the width of the terminal screen.
- */
- public int getScreenWidth();
-
- /**
- * Gets the height of the terminal screen in pixels. This is the height of
- * the screen and not the height available for the application.
- *
- * <p>
- * Note that the screen height is typically not available in the
- * {@link com.vaadin.Application#init()} method as this is called before the
- * browser has a chance to report the screen size to the server.
- * </p>
- *
- * @return the height of the terminal screen.
- */
- public int getScreenHeight();
-
- /**
* An error event implementation for Terminal.
*/
public interface ErrorEvent extends Serializable {
diff --git a/server/src/com/vaadin/terminal/Vaadin6Component.java b/server/src/com/vaadin/terminal/Vaadin6Component.java
index 048000e31d..eb169c90f9 100644
--- a/server/src/com/vaadin/terminal/Vaadin6Component.java
+++ b/server/src/com/vaadin/terminal/Vaadin6Component.java
@@ -52,4 +52,15 @@ public interface Vaadin6Component extends VariableOwner, Component,
*/
public void paintContent(PaintTarget target) throws PaintException;
+ /**
+ * (non-Javadoc) {@inheritDoc}
+ * <p>
+ * For a Vaadin6Component, markAsDirty will also cause
+ * {@link #paintContent(PaintTarget)} to be called before sending changes to
+ * the client.
+ *
+ * @see com.vaadin.terminal.gwt.server.ClientConnector#markAsDirty()
+ */
+ @Override
+ public void markAsDirty();
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 99376ffd1f..7ea4a7d097 100644
--- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -880,49 +880,19 @@ public abstract class AbstractCommunicationManager implements Serializable {
// processing.
JSONObject sharedStates = new JSONObject();
for (ClientConnector connector : dirtyVisibleConnectors) {
- SharedState state = connector.getState();
- if (null != state) {
- // encode and send shared state
- try {
- Class<? extends SharedState> stateType = connector
- .getStateType();
- Object diffState = rootConnectorTracker
- .getDiffState(connector);
- if (diffState == null) {
- diffState = new JSONObject();
- // Use an empty state object as reference for full
- // repaints
- boolean emptyInitialState = JavaScriptConnectorState.class
- .isAssignableFrom(stateType);
- if (!emptyInitialState) {
- try {
- SharedState referenceState = stateType
- .newInstance();
- diffState = JsonCodec.encode(referenceState,
- null, stateType,
- root.getConnectorTracker());
- } catch (Exception e) {
- getLogger().log(
- Level.WARNING,
- "Error creating reference object for state of type "
- + stateType.getName());
- }
- }
- rootConnectorTracker.setDiffState(connector, diffState);
- }
- JSONObject stateJson = (JSONObject) JsonCodec.encode(state,
- diffState, stateType, root.getConnectorTracker());
+ // encode and send shared state
+ try {
+ JSONObject stateJson = connector.encodeState();
- if (stateJson.length() != 0) {
- sharedStates.put(connector.getConnectorId(), stateJson);
- }
- } catch (JSONException e) {
- throw new PaintException(
- "Failed to serialize shared state for connector "
- + connector.getClass().getName() + " ("
- + connector.getConnectorId() + "): "
- + e.getMessage(), e);
+ if (stateJson != null && stateJson.length() != 0) {
+ sharedStates.put(connector.getConnectorId(), stateJson);
}
+ } catch (JSONException e) {
+ throw new PaintException(
+ "Failed to serialize shared state for connector "
+ + connector.getClass().getName() + " ("
+ + connector.getConnectorId() + "): "
+ + e.getMessage(), e);
}
}
outWriter.print("\"state\":");
@@ -1273,6 +1243,37 @@ public abstract class AbstractCommunicationManager implements Serializable {
writePerformanceData(outWriter);
}
+ public static JSONObject encodeState(ClientConnector connector,
+ SharedState state) throws JSONException {
+ Root root = connector.getRoot();
+ ConnectorTracker connectorTracker = root.getConnectorTracker();
+ Class<? extends SharedState> stateType = connector.getStateType();
+ Object diffState = connectorTracker.getDiffState(connector);
+ if (diffState == null) {
+ diffState = new JSONObject();
+ // Use an empty state object as reference for full
+ // repaints
+ boolean emptyInitialState = JavaScriptConnectorState.class
+ .isAssignableFrom(stateType);
+ if (!emptyInitialState) {
+ try {
+ SharedState referenceState = stateType.newInstance();
+ diffState = JsonCodec.encode(referenceState, null,
+ stateType, root.getConnectorTracker());
+ } catch (Exception e) {
+ getLogger().log(
+ Level.WARNING,
+ "Error creating reference object for state of type "
+ + stateType.getName());
+ }
+ }
+ connectorTracker.setDiffState(connector, diffState);
+ }
+ JSONObject stateJson = (JSONObject) JsonCodec.encode(state, diffState,
+ stateType, root.getConnectorTracker());
+ return stateJson;
+ }
+
/**
* Resolves a resource URI, registering the URI with this
* {@code AbstractCommunicationManager} if needed and returns a fully
diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java
index 06bc70872d..52885f3fbb 100644
--- a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java
+++ b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java
@@ -20,6 +20,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import com.vaadin.Application;
+import com.vaadin.terminal.DefaultRootProvider;
import com.vaadin.terminal.gwt.server.ServletPortletHelper.ApplicationClassException;
/**
@@ -69,6 +70,7 @@ public class ApplicationServlet extends AbstractApplicationServlet {
// Creates a new application instance
try {
final Application application = getApplicationClass().newInstance();
+ application.addRootProvider(new DefaultRootProvider());
return application;
} catch (final IllegalAccessException e) {
diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java
index c9fe2563f9..24675c9e45 100644
--- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java
+++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java
@@ -18,6 +18,8 @@ package com.vaadin.terminal.gwt.server;
import java.util.Collection;
import java.util.List;
+import com.vaadin.external.json.JSONException;
+import com.vaadin.external.json.JSONObject;
import com.vaadin.shared.Connector;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.terminal.AbstractClientConnector;
@@ -63,17 +65,39 @@ public interface ClientConnector extends Connector, RpcTarget {
public ClientConnector getParent();
/**
- * Requests that the connector should be repainted as soon as possible.
+ * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead
*/
+ @Deprecated
public void requestRepaint();
/**
- * Causes a repaint of this connector, and all connectors below it.
+ * Marks that this connector's state might have changed. When the framework
+ * is about to send new data to the client-side, it will run
+ * {@link #beforeClientResponse(boolean)} followed by {@link #encodeState()}
+ * for all connectors that are marked as dirty and send any updated state
+ * info to the client.
*
+ * @since 7.0.0
+ */
+ public void markAsDirty();
+
+ /**
+ * @deprecated As of 7.0.0, use {@link #markAsDirtyRecursive()} instead
+ */
+ @Deprecated
+ public void requestRepaintAll();
+
+ /**
+ * Causes this connector and all connectors below it to be marked as dirty.
+ * <p>
* This should only be used in special cases, e.g when the state of a
* descendant depends on the state of an ancestor.
+ *
+ * @see #markAsDirty()
+ *
+ * @since 7.0.0
*/
- public void requestRepaintAll();
+ public void markAsDirtyRecursive();
/**
* Sets the parent connector of the connector.
@@ -177,4 +201,16 @@ public interface ClientConnector extends Connector, RpcTarget {
* @since 7.0
*/
public void beforeClientResponse(boolean initial);
+
+ /**
+ * Called by the framework to encode the state to a JSONObject. This is
+ * typically done by calling the static method
+ * {@link AbstractCommunicationManager#encodeState(ClientConnector, SharedState)}
+ * .
+ *
+ * @return a JSON object with the encoded connector state
+ * @throws JSONException
+ * if the state can not be encoded
+ */
+ public JSONObject encodeState() throws JSONException;
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java
index 56d5ed1393..221598171c 100644
--- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java
+++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java
@@ -31,6 +31,8 @@ import com.vaadin.event.dd.DropTarget;
import com.vaadin.event.dd.TargetDetails;
import com.vaadin.event.dd.TargetDetailsImpl;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
+import com.vaadin.external.json.JSONException;
+import com.vaadin.external.json.JSONObject;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.shared.ui.dd.DragEventType;
@@ -235,12 +237,6 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
}
@Override
- public SharedState getState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
public String getConnectorId() {
return ApplicationConstants.DRAG_AND_DROP_CONNECTOR_ID;
}
@@ -268,7 +264,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
}
@Override
+ @Deprecated
public void requestRepaint() {
+ markAsDirty();
+ }
+
+ @Override
+ public void markAsDirty() {
// TODO Auto-generated method stub
}
@@ -280,7 +282,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
}
@Override
+ @Deprecated
public void requestRepaintAll() {
+ markAsDirtyRecursive();
+ }
+
+ @Override
+ public void markAsDirtyRecursive() {
// TODO Auto-generated method stub
}
@@ -327,4 +335,10 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
public void beforeClientResponse(boolean initial) {
// Nothing to do
}
+
+ @Override
+ public JSONObject encodeState() throws JSONException {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java
index 884e01f9a5..1eee9c4f52 100644
--- a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java
+++ b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java
@@ -21,9 +21,10 @@ import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.Serializable;
import java.lang.reflect.Array;
+import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
@@ -55,6 +56,107 @@ import com.vaadin.ui.ConnectorTracker;
*/
public class JsonCodec implements Serializable {
+ public static interface BeanProperty {
+ public Object getValue(Object bean) throws Exception;
+
+ public void setValue(Object bean, Object value) throws Exception;
+
+ public String getName();
+
+ public Type getType();
+ }
+
+ private static class FieldProperty implements BeanProperty {
+ private final Field field;
+
+ public FieldProperty(Field field) {
+ this.field = field;
+ }
+
+ @Override
+ public Object getValue(Object bean) throws Exception {
+ return field.get(bean);
+ }
+
+ @Override
+ public void setValue(Object bean, Object value) throws Exception {
+ field.set(bean, value);
+ }
+
+ @Override
+ public String getName() {
+ return field.getName();
+ }
+
+ @Override
+ public Type getType() {
+ return field.getGenericType();
+ }
+
+ public static Collection<FieldProperty> find(Class<?> type)
+ throws IntrospectionException {
+ Collection<FieldProperty> properties = new ArrayList<FieldProperty>();
+
+ Field[] fields = type.getFields();
+ for (Field field : fields) {
+ if (!Modifier.isStatic(field.getModifiers())) {
+ properties.add(new FieldProperty(field));
+ }
+ }
+
+ return properties;
+ }
+
+ }
+
+ private static class MethodProperty implements BeanProperty {
+ private final PropertyDescriptor pd;
+
+ public MethodProperty(PropertyDescriptor pd) {
+ this.pd = pd;
+ }
+
+ @Override
+ public Object getValue(Object bean) throws Exception {
+ Method readMethod = pd.getReadMethod();
+ return readMethod.invoke(bean);
+ }
+
+ @Override
+ public void setValue(Object bean, Object value) throws Exception {
+ pd.getWriteMethod().invoke(bean, value);
+ }
+
+ @Override
+ public String getName() {
+ String fieldName = pd.getWriteMethod().getName().substring(3);
+ fieldName = Character.toLowerCase(fieldName.charAt(0))
+ + fieldName.substring(1);
+ return fieldName;
+ }
+
+ public static Collection<MethodProperty> find(Class<?> type)
+ throws IntrospectionException {
+ Collection<MethodProperty> properties = new ArrayList<MethodProperty>();
+
+ for (PropertyDescriptor pd : Introspector.getBeanInfo(type)
+ .getPropertyDescriptors()) {
+ if (pd.getReadMethod() == null || pd.getWriteMethod() == null) {
+ continue;
+ }
+
+ properties.add(new MethodProperty(pd));
+ }
+ return properties;
+ }
+
+ @Override
+ public Type getType() {
+ return pd.getReadMethod().getGenericReturnType();
+ }
+
+ }
+
private static Map<Class<?>, String> typeToTransportType = new HashMap<Class<?>, String>();
/**
@@ -468,27 +570,6 @@ public class JsonCodec implements Serializable {
return set;
}
- /**
- * Returns the name that should be used as field name in the JSON. We strip
- * "set" from the setter, keeping the result - this is easy to do on both
- * server and client, avoiding some issues with cASE. E.g setZIndex()
- * becomes "zIndex". Also ensures that both getter and setter are present,
- * returning null otherwise.
- *
- * @param pd
- * @return the name to be used or null if both getter and setter are not
- * found.
- */
- static String getTransportFieldName(PropertyDescriptor pd) {
- if (pd.getReadMethod() == null || pd.getWriteMethod() == null) {
- return null;
- }
- String fieldName = pd.getWriteMethod().getName().substring(3);
- fieldName = Character.toLowerCase(fieldName.charAt(0))
- + fieldName.substring(1);
- return fieldName;
- }
-
private static Object decodeObject(Type targetType,
JSONObject serializedObject, ConnectorTracker connectorTracker)
throws JSONException {
@@ -497,31 +578,19 @@ public class JsonCodec implements Serializable {
try {
Object decodedObject = targetClass.newInstance();
- for (PropertyDescriptor pd : Introspector.getBeanInfo(targetClass)
- .getPropertyDescriptors()) {
+ for (BeanProperty property : getProperties(targetClass)) {
- String fieldName = getTransportFieldName(pd);
- if (fieldName == null) {
- continue;
- }
+ String fieldName = property.getName();
Object encodedFieldValue = serializedObject.get(fieldName);
- Type fieldType = pd.getReadMethod().getGenericReturnType();
+ Type fieldType = property.getType();
Object decodedFieldValue = decodeInternalOrCustomType(
fieldType, encodedFieldValue, connectorTracker);
- pd.getWriteMethod().invoke(decodedObject, decodedFieldValue);
+ property.setValue(decodedObject, decodedFieldValue);
}
return decodedObject;
- } catch (IllegalArgumentException e) {
- throw new JSONException(e);
- } catch (IllegalAccessException e) {
- throw new JSONException(e);
- } catch (InvocationTargetException e) {
- throw new JSONException(e);
- } catch (InstantiationException e) {
- throw new JSONException(e);
- } catch (IntrospectionException e) {
+ } catch (Exception e) {
throw new JSONException(e);
}
}
@@ -602,28 +671,36 @@ public class JsonCodec implements Serializable {
return JSONObject.NULL;
}
+ public static Collection<BeanProperty> getProperties(Class<?> type)
+ throws IntrospectionException {
+ Collection<BeanProperty> properties = new ArrayList<BeanProperty>();
+
+ properties.addAll(MethodProperty.find(type));
+ properties.addAll(FieldProperty.find(type));
+
+ return properties;
+ }
+
private static Object encodeObject(Object value, JSONObject diffState,
ConnectorTracker connectorTracker) throws JSONException {
JSONObject jsonMap = new JSONObject();
try {
- for (PropertyDescriptor pd : Introspector.getBeanInfo(
- value.getClass()).getPropertyDescriptors()) {
- String fieldName = getTransportFieldName(pd);
- if (fieldName == null) {
- continue;
- }
- Method getterMethod = pd.getReadMethod();
+ for (BeanProperty property : getProperties(value.getClass())) {
+ String fieldName = property.getName();
// We can't use PropertyDescriptor.getPropertyType() as it does
// not support generics
- Type fieldType = getterMethod.getGenericReturnType();
- Object fieldValue = getterMethod.invoke(value, (Object[]) null);
+ Type fieldType = property.getType();
+ Object fieldValue = property.getValue(value);
boolean equals = false;
Object diffStateValue = null;
- if (diffState != null) {
+ if (diffState != null && diffState.has(fieldName)) {
diffStateValue = diffState.get(fieldName);
Object referenceFieldValue = decodeInternalOrCustomType(
fieldType, diffStateValue, connectorTracker);
+ if (JSONObject.NULL.equals(diffStateValue)) {
+ diffStateValue = null;
+ }
equals = equals(fieldValue, referenceFieldValue);
}
if (!equals) {
diff --git a/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java
index 90aef4283d..37bc81cfcf 100644
--- a/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java
+++ b/server/src/com/vaadin/terminal/gwt/server/WebBrowser.java
@@ -20,7 +20,6 @@ import java.util.Date;
import java.util.Locale;
import com.vaadin.shared.VBrowserDetails;
-import com.vaadin.terminal.Terminal;
import com.vaadin.terminal.WrappedRequest;
/**
@@ -30,7 +29,7 @@ import com.vaadin.terminal.WrappedRequest;
*
* @author Vaadin Ltd.
*/
-public class WebBrowser implements Terminal {
+public class WebBrowser {
private int screenHeight = 0;
private int screenWidth = 0;
@@ -48,34 +47,21 @@ public class WebBrowser implements Terminal {
private long clientServerTimeDelta;
/**
- * There is no default-theme for this terminal type.
+ * Gets the height of the screen in pixels. This is the full screen
+ * resolution and not the height available for the application.
*
- * @return Always returns null.
+ * @return the height of the screen in pixels.
*/
-
- @Override
- public String getDefaultTheme() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.terminal.Terminal#getScreenHeight()
- */
-
- @Override
public int getScreenHeight() {
return screenHeight;
}
- /*
- * (non-Javadoc)
+ /**
+ * Gets the width of the screen in pixels. This is the full screen
+ * resolution and not the width available for the application.
*
- * @see com.vaadin.terminal.Terminal#getScreenWidth()
+ * @return the width of the screen in pixels.
*/
-
- @Override
public int getScreenWidth() {
return screenWidth;
}
diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java
index a3bc577fe3..56bbd19852 100644
--- a/server/src/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/com/vaadin/ui/AbsoluteLayout.java
@@ -61,7 +61,7 @@ public class AbsoluteLayout extends AbstractLayout implements
}
@Override
- public AbsoluteLayoutState getState() {
+ protected AbsoluteLayoutState getState() {
return (AbsoluteLayoutState) super.getState();
}
@@ -153,7 +153,7 @@ public class AbsoluteLayout extends AbstractLayout implements
internalRemoveComponent(c);
throw e;
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -197,7 +197,7 @@ public class AbsoluteLayout extends AbstractLayout implements
public void removeComponent(Component c) {
internalRemoveComponent(c);
super.removeComponent(c);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -245,7 +245,7 @@ public class AbsoluteLayout extends AbstractLayout implements
private void internalSetPosition(Component component,
ComponentPosition position) {
componentToCoordinates.put(component, position);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -322,7 +322,7 @@ public class AbsoluteLayout extends AbstractLayout implements
}
}
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -363,7 +363,7 @@ public class AbsoluteLayout extends AbstractLayout implements
public void setTop(Float topValue, Unit topUnits) {
this.topValue = topValue;
this.topUnits = topUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -379,7 +379,7 @@ public class AbsoluteLayout extends AbstractLayout implements
public void setRight(Float rightValue, Unit rightUnits) {
this.rightValue = rightValue;
this.rightUnits = rightUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -395,7 +395,7 @@ public class AbsoluteLayout extends AbstractLayout implements
public void setBottom(Float bottomValue, Unit bottomUnits) {
this.bottomValue = bottomValue;
this.bottomUnits = bottomUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -411,7 +411,7 @@ public class AbsoluteLayout extends AbstractLayout implements
public void setLeft(Float leftValue, Unit leftUnits) {
this.leftValue = leftValue;
this.leftUnits = leftUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -422,7 +422,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setZIndex(int zIndex) {
this.zIndex = zIndex;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -434,7 +434,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setTopValue(Float topValue) {
this.topValue = topValue;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -468,7 +468,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setRightValue(Float rightValue) {
this.rightValue = rightValue;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -492,7 +492,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setBottomValue(Float bottomValue) {
this.bottomValue = bottomValue;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -516,7 +516,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setLeftValue(Float leftValue) {
this.leftValue = leftValue;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -538,7 +538,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setTopUnits(Unit topUnits) {
this.topUnits = topUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -560,7 +560,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setRightUnits(Unit rightUnits) {
this.rightUnits = rightUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -582,7 +582,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setBottomUnits(Unit bottomUnits) {
this.bottomUnits = bottomUnits;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -604,7 +604,7 @@ public class AbsoluteLayout extends AbstractLayout implements
*/
public void setLeftUnits(Unit leftUnits) {
this.leftUnits = leftUnits;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index cde5217ca1..b1393488f7 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -121,34 +121,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
return getState().getDebugId();
}
- /**
- * Gets style for component. Multiple styles are joined with spaces.
- *
- * @return the component's styleValue of property style.
- * @deprecated Use getStyleName() instead; renamed for consistency and to
- * indicate that "style" should not be used to switch client
- * side implementation, only to style the component.
- */
- @Deprecated
- public String getStyle() {
- return getStyleName();
- }
-
- /**
- * Sets and replaces all previous style names of the component. This method
- * will trigger a {@link RepaintRequestEvent}.
- *
- * @param style
- * the new style of the component.
- * @deprecated Use setStyleName() instead; renamed for consistency and to
- * indicate that "style" should not be used to switch client
- * side implementation, only to style the component.
- */
- @Deprecated
- public void setStyle(String style) {
- setStyleName(style);
- }
-
/*
* Gets the component's style. Don't add a JavaDoc comment here, we use the
* default documentation from implemented interface.
@@ -176,7 +148,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
public void setStyleName(String style) {
if (style == null || "".equals(style)) {
getState().setStyles(null);
- requestRepaint();
return;
}
if (getState().getStyles() == null) {
@@ -190,7 +161,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
styles.add(part);
}
}
- requestRepaint();
}
@Override
@@ -212,7 +182,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
List<String> styles = getState().getStyles();
if (!styles.contains(style)) {
styles.add(style);
- requestRepaint();
}
}
@@ -225,7 +194,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
getState().getStyles().remove(part);
}
}
- requestRepaint();
}
}
@@ -249,7 +217,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public void setCaption(String caption) {
getState().setCaption(caption);
- requestRepaint();
}
/*
@@ -295,7 +262,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
this.locale = locale;
// FIXME: Reload value if there is a converter
- requestRepaint();
+ markAsDirty();
}
/*
@@ -317,7 +284,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public void setIcon(Resource icon) {
getState().setIcon(ResourceReference.create(icon));
- requestRepaint();
}
/*
@@ -337,10 +303,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public void setEnabled(boolean enabled) {
- if (getState().isEnabled() != enabled) {
- getState().setEnabled(enabled);
- requestRepaint();
- }
+ getState().setEnabled(enabled);
}
/*
@@ -383,7 +346,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
public void setImmediate(boolean immediate) {
getState().setImmediate(immediate);
- requestRepaint();
}
/*
@@ -408,11 +370,10 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
getState().setVisible(visible);
- requestRepaint();
if (getParent() != null) {
// Must always repaint the parent (at least the hierarchy) when
// visibility of a child component changes.
- getParent().requestRepaint();
+ getParent().markAsDirty();
}
}
@@ -491,7 +452,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
public void setDescription(String description) {
getState().setDescription(description);
- requestRepaint();
}
/*
@@ -575,7 +535,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
public void setComponentError(ErrorMessage componentError) {
this.componentError = componentError;
fireComponentErrorEvent();
- requestRepaint();
+ markAsDirty();
}
/*
@@ -594,7 +554,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public void setReadOnly(boolean readOnly) {
getState().setReadOnly(readOnly);
- requestRepaint();
}
/*
@@ -713,7 +672,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
* @return updated component shared state
*/
@Override
- public ComponentState getState() {
+ protected ComponentState getState() {
return (ComponentState) super.getState();
}
@@ -746,17 +705,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
}
- /* Documentation copied from interface */
- @Override
- public void requestRepaint() {
- // Invisible components (by flag in this particular component) do not
- // need repaints
- if (!getState().isVisible()) {
- return;
- }
- super.requestRepaint();
- }
-
/* General event framework */
private static final Method COMPONENT_EVENT_METHOD = ReflectTools
@@ -803,7 +751,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
if (needRepaint) {
getState().addRegisteredEventListener(eventIdentifier);
- requestRepaint();
}
}
@@ -852,7 +799,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
eventRouter.removeListener(eventType, target);
if (!eventRouter.hasListeners(eventType)) {
getState().removeRegisteredEventListener(eventIdentifier);
- requestRepaint();
}
}
}
@@ -1159,7 +1105,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
this.height = height;
heightUnit = unit;
- requestRepaint();
+ markAsDirty();
// ComponentSizeValidator.setHeightLocation(this);
}
@@ -1197,7 +1143,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
this.width = width;
widthUnit = unit;
- requestRepaint();
+ markAsDirty();
// ComponentSizeValidator.setWidthLocation(this);
}
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index 7450c76fda..4939eb1265 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -212,7 +212,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
// If the visibility state is toggled it might affect all children
// aswell, e.g. make container visible should make children visible if
// they were only hidden because the container was hidden.
- requestRepaintAll();
+ markAsDirtyRecursive();
}
@Override
@@ -306,12 +306,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
private void repaintChildTrees(Collection<Component> dirtyChildren) {
for (Component c : dirtyChildren) {
- if (c instanceof ComponentContainer) {
- ComponentContainer cc = (ComponentContainer) c;
- cc.requestRepaintAll();
- } else {
- c.requestRepaint();
- }
+ c.markAsDirtyRecursive();
}
}
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index 67a1826100..5123d08da9 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -97,14 +97,9 @@ public abstract class AbstractField<T> extends AbstractComponent implements
private LinkedList<Validator> validators = null;
/**
- * Auto commit mode.
+ * True if field is in buffered mode, false otherwise
*/
- private boolean writeThroughMode = true;
-
- /**
- * Reads the value from data-source, when it is not modified.
- */
- private boolean readThroughMode = true;
+ private boolean buffered;
/**
* Flag to indicate that the field is currently committing its value to the
@@ -306,7 +301,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
// Sets the buffering state
currentBufferedSourceException = new Buffered.SourceException(
this, e);
- requestRepaint();
+ markAsDirty();
// Throws the source exception
throw currentBufferedSourceException;
@@ -321,7 +316,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
fireValueChange(false);
} else if (wasModified) {
// If the value did not change, but the modification status did
- requestRepaint();
+ markAsDirty();
}
}
}
@@ -345,7 +340,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
private T getFieldValue() {
// Give the value from abstract buffers if the field if possible
- if (dataSource == null || !isReadThrough() || isModified()) {
+ if (dataSource == null || isBuffered() || isModified()) {
return getInternalValue();
}
@@ -365,92 +360,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements
private void setModified(boolean modified) {
getState().setModified(modified);
- requestRepaint();
- }
-
- /*
- * Tests if the field is in write-through mode. Don't add a JavaDoc comment
- * here, we use the default documentation from the implemented interface.
- */
- @Override
- public boolean isWriteThrough() {
- return writeThroughMode;
- }
-
- /**
- * Sets the field's write-through mode to the specified status. When
- * switching the write-through mode on, a {@link #commit()} will be
- * performed.
- *
- * @see #setBuffered(boolean) for an easier way to control read through and
- * write through modes
- *
- * @param writeThrough
- * Boolean value to indicate if the object should be in
- * write-through mode after the call.
- * @throws SourceException
- * If the operation fails because of an exception is thrown by
- * the data source.
- * @throws InvalidValueException
- * If the implicit commit operation fails because of a
- * validation error.
- * @deprecated Use {@link #setBuffered(boolean)} instead. Note that
- * setReadThrough(true), setWriteThrough(true) equals
- * setBuffered(false)
- */
- @Override
- @Deprecated
- public void setWriteThrough(boolean writeThrough)
- throws Buffered.SourceException, InvalidValueException {
- if (writeThroughMode == writeThrough) {
- return;
- }
- writeThroughMode = writeThrough;
- if (writeThroughMode) {
- commit();
- }
- }
-
- /*
- * Tests if the field is in read-through mode. Don't add a JavaDoc comment
- * here, we use the default documentation from the implemented interface.
- */
- @Override
- public boolean isReadThrough() {
- return readThroughMode;
- }
-
- /**
- * Sets the field's read-through mode to the specified status. When
- * switching read-through mode on, the object's value is updated from the
- * data source.
- *
- * @see #setBuffered(boolean) for an easier way to control read through and
- * write through modes
- *
- * @param readThrough
- * Boolean value to indicate if the object should be in
- * read-through mode after the call.
- *
- * @throws SourceException
- * If the operation fails because of an exception is thrown by
- * the data source. The cause is included in the exception.
- * @deprecated Use {@link #setBuffered(boolean)} instead. Note that
- * setReadThrough(true), setWriteThrough(true) equals
- * setBuffered(false)
- */
- @Override
- @Deprecated
- public void setReadThrough(boolean readThrough)
- throws Buffered.SourceException {
- if (readThroughMode == readThrough) {
- return;
- }
- readThroughMode = readThrough;
- if (!isModified() && readThroughMode && getPropertyDataSource() != null) {
- setInternalValue(convertFromDataSource(getDataSourceValue()));
- fireValueChange(false);
- }
}
/**
@@ -460,34 +369,35 @@ public abstract class AbstractField<T> extends AbstractComponent implements
* property data source until {@link #commit()} is called.
* </p>
* <p>
- * Changing buffered mode will change the read through and write through
- * state for the field.
+ * Setting buffered mode from true to false will commit any pending changes.
* </p>
* <p>
- * Mixing calls to {@link #setBuffered(boolean)} and
- * {@link #setReadThrough(boolean)} or {@link #setWriteThrough(boolean)} is
- * generally a bad idea.
+ *
* </p>
*
+ * @since 7.0.0
* @param buffered
* true if buffered mode should be turned on, false otherwise
*/
@Override
public void setBuffered(boolean buffered) {
- setReadThrough(!buffered);
- setWriteThrough(!buffered);
+ if (this.buffered == buffered) {
+ return;
+ }
+ this.buffered = buffered;
+ if (!buffered) {
+ commit();
+ }
}
/**
* Checks the buffered mode of this Field.
- * <p>
- * This method only returns true if both read and write buffering is used.
*
* @return true if buffered mode is on, false otherwise
*/
@Override
public boolean isBuffered() {
- return !isReadThrough() && !isWriteThrough();
+ return buffered;
}
/* Property interface implementation */
@@ -607,8 +517,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements
setModified(dataSource != null);
valueWasModifiedByDataSourceDuringCommit = false;
- // In write through mode , try to commit
- if (isWriteThrough() && dataSource != null
+ // In not buffering, try to commit
+ if (!isBuffered() && dataSource != null
&& (isInvalidCommitted() || isValid())) {
try {
@@ -625,7 +535,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
// Sets the buffering state
currentBufferedSourceException = new Buffered.SourceException(
this, e);
- requestRepaint();
+ markAsDirty();
// Throws the source exception
throw currentBufferedSourceException;
@@ -895,7 +805,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
validators = new LinkedList<Validator>();
}
validators.add(validator);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -923,7 +833,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
if (validators != null) {
validators.remove(validator);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -933,7 +843,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
if (validators != null) {
validators.clear();
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1160,7 +1070,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
protected void fireValueChange(boolean repaintIsNotNeeded) {
fireEvent(new AbstractField.ValueChangeEvent(this));
if (!repaintIsNotNeeded) {
- requestRepaint();
+ markAsDirty();
}
}
@@ -1190,7 +1100,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements
@Override
public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) {
getState().setPropertyReadOnly(event.getProperty().isReadOnly());
- requestRepaint();
}
/**
@@ -1267,7 +1176,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public void valueChange(Property.ValueChangeEvent event) {
- if (isReadThrough()) {
+ if (!isBuffered()) {
if (committingValueToDataSource) {
boolean propertyNotifiesOfTheBufferedValue = equals(event
.getProperty().getValue(), getInternalValue());
@@ -1322,7 +1231,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements
@Override
public void setTabIndex(int tabIndex) {
getState().setTabIndex(tabIndex);
- requestRepaint();
}
/**
@@ -1356,7 +1264,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
protected void setInternalValue(T newValue) {
value = newValue;
if (validators != null && !validators.isEmpty()) {
- requestRepaint();
+ markAsDirty();
}
}
@@ -1371,7 +1279,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
if (!isListeningToPropertyEvents) {
addPropertyListeners();
- if (!isModified() && isReadThrough()) {
+ if (!isModified() && !isBuffered()) {
// Update value from data source
discard();
}
@@ -1425,7 +1333,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements
@Override
public void setRequired(boolean required) {
getState().setRequired(required);
- requestRepaint();
}
/**
@@ -1440,7 +1347,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
@Override
public void setRequiredError(String requiredMessage) {
requiredError = requiredMessage;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1468,7 +1375,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
public void setConversionError(String valueConversionError) {
this.conversionError = valueConversionError;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1510,7 +1417,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
public void setValidationVisible(boolean validateAutomatically) {
if (validationVisible != validateAutomatically) {
- requestRepaint();
+ markAsDirty();
validationVisible = validateAutomatically;
}
}
@@ -1523,7 +1430,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
public void setCurrentBufferedSourceException(
Buffered.SourceException currentBufferedSourceException) {
this.currentBufferedSourceException = currentBufferedSourceException;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1611,11 +1518,11 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
public void setConverter(Converter<T, ?> converter) {
this.converter = (Converter<T, Object>) converter;
- requestRepaint();
+ markAsDirty();
}
@Override
- public AbstractFieldState getState() {
+ protected AbstractFieldState getState() {
return (AbstractFieldState) super.getState();
}
diff --git a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java
index c442bf2204..e19bdf1b2b 100644
--- a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java
+++ b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java
@@ -34,9 +34,10 @@ import com.vaadin.terminal.JavaScriptCallbackHelper;
* , then <code>com_example_SuperComponent</code> will also be attempted if
* <code>com_example_MyComponent</code> has not been defined.
* <p>
- * JavaScript components have a very simple GWT widget ({@link JavaScriptWidget}
- * ) just consisting of a <code>div</code> element to which the JavaScript code
- * should initialize its own user interface.
+ * JavaScript components have a very simple GWT widget (
+ * {@link com.vaadin.terminal.gwt.client.ui.JavaScriptWidget} ) just consisting
+ * of a <code>div</code> element to which the JavaScript code should initialize
+ * its own user interface.
* <p>
* The initialization function will be called with <code>this</code> pointing to
* a connector wrapper object providing integration to Vaadin with the following
@@ -79,7 +80,8 @@ import com.vaadin.terminal.JavaScriptCallbackHelper;
* functions is described bellow.</li>
* <li><code>translateVaadinUri(uri)</code> - Translates a Vaadin URI to a URL
* that can be used in the browser. This is just way of accessing
- * {@link ApplicationConnection#translateVaadinUri(String)}</li>
+ * {@link com.vaadin.terminal.gwt.client.ApplicationConnection#translateVaadinUri(String)}
+ * </li>
* </ul>
* The connector wrapper also supports these special functions:
* <ul>
@@ -90,9 +92,8 @@ import com.vaadin.terminal.JavaScriptCallbackHelper;
* {@link #addFunction(String, JavaScriptFunction)} on the server will
* automatically be present as a function that triggers the registered function
* on the server.</li>
- * <li>Any field name referred to using
- * {@link #callFunction(String, Object...)} on the server will be called if a
- * function has been assigned to the field.</li>
+ * <li>Any field name referred to using {@link #callFunction(String, Object...)}
+ * on the server will be called if a function has been assigned to the field.</li>
* </ul>
* <p>
*
@@ -168,7 +169,7 @@ public abstract class AbstractJavaScriptComponent extends AbstractComponent {
}
@Override
- public JavaScriptComponentState getState() {
+ protected JavaScriptComponentState getState() {
return (JavaScriptComponentState) super.getState();
}
}
diff --git a/server/src/com/vaadin/ui/AbstractLayout.java b/server/src/com/vaadin/ui/AbstractLayout.java
index c26812f3fc..6743b09211 100644
--- a/server/src/com/vaadin/ui/AbstractLayout.java
+++ b/server/src/com/vaadin/ui/AbstractLayout.java
@@ -17,7 +17,6 @@
package com.vaadin.ui;
import com.vaadin.shared.ui.AbstractLayoutState;
-import com.vaadin.ui.Layout.MarginHandler;
/**
* An abstract class that defines default implementation for the {@link Layout}
@@ -26,62 +25,12 @@ import com.vaadin.ui.Layout.MarginHandler;
* @author Vaadin Ltd.
* @since 5.0
*/
-@SuppressWarnings("serial")
public abstract class AbstractLayout extends AbstractComponentContainer
- implements Layout, MarginHandler {
-
- protected MarginInfo margins = new MarginInfo(false);
+ implements Layout {
@Override
- public AbstractLayoutState getState() {
+ protected AbstractLayoutState getState() {
return (AbstractLayoutState) super.getState();
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Layout#setMargin(boolean)
- */
- @Override
- public void setMargin(boolean enabled) {
- margins.setMargins(enabled);
- getState().setMarginsBitmask(margins.getBitMask());
- requestRepaint();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Layout.MarginHandler#getMargin()
- */
- @Override
- public MarginInfo getMargin() {
- return margins;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo)
- */
- @Override
- public void setMargin(MarginInfo marginInfo) {
- margins.setMargins(marginInfo);
- getState().setMarginsBitmask(margins.getBitMask());
- requestRepaint();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Layout#setMargin(boolean, boolean, boolean, boolean)
- */
- @Override
- public void setMargin(boolean topEnabled, boolean rightEnabled,
- boolean bottomEnabled, boolean leftEnabled) {
- margins.setMargins(topEnabled, rightEnabled, bottomEnabled, leftEnabled);
- getState().setMarginsBitmask(margins.getBitMask());
- requestRepaint();
- }
-
}
diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java
index 51a3bcd2be..77c12ac045 100644
--- a/server/src/com/vaadin/ui/AbstractMedia.java
+++ b/server/src/com/vaadin/ui/AbstractMedia.java
@@ -33,7 +33,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference;
public abstract class AbstractMedia extends AbstractComponent {
@Override
- public AbstractMediaState getState() {
+ protected AbstractMediaState getState() {
return (AbstractMediaState) super.getState();
}
@@ -66,7 +66,6 @@ public abstract class AbstractMedia extends AbstractComponent {
if (source != null) {
getState().getSources().add(new ResourceReference(source));
getState().getSourceTypes().add(source.getMIMEType());
- requestRepaint();
}
}
@@ -103,7 +102,6 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public void setShowControls(boolean showControls) {
getState().setShowControls(showControls);
- requestRepaint();
}
/**
@@ -126,7 +124,6 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public void setAltText(String altText) {
getState().setAltText(altText);
- requestRepaint();
}
/**
@@ -145,7 +142,6 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
getState().setHtmlContentAllowed(htmlContentAllowed);
- requestRepaint();
}
/**
@@ -164,7 +160,6 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public void setAutoplay(boolean autoplay) {
getState().setAutoplay(autoplay);
- requestRepaint();
}
/**
@@ -181,7 +176,6 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public void setMuted(boolean muted) {
getState().setMuted(muted);
- requestRepaint();
}
/**
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
index a7cc780414..596bbb7ee2 100644
--- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -25,6 +25,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickNotifier;
import com.vaadin.shared.Connector;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState.ChildComponentData;
@@ -32,7 +33,8 @@ import com.vaadin.terminal.Sizeable;
@SuppressWarnings("serial")
public abstract class AbstractOrderedLayout extends AbstractLayout implements
- Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier {
+ Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier,
+ Layout.MarginHandler {
private AbstractOrderedLayoutServerRpc rpc = new AbstractOrderedLayoutServerRpc() {
@@ -61,7 +63,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
}
@Override
- public AbstractOrderedLayoutState getState() {
+ protected AbstractOrderedLayoutState getState() {
return (AbstractOrderedLayoutState) super.getState();
}
@@ -142,13 +144,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
private void componentRemoved(Component c) {
getState().getChildData().remove(c);
- requestRepaint();
}
private void componentAdded(Component c) {
getState().getChildData().put(c, new ChildComponentData());
- requestRepaint();
-
}
/**
@@ -226,23 +225,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
components.add(newLocation, oldComponent);
}
- requestRepaint();
+ markAsDirty();
}
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com
- * .vaadin.ui.Component, int, int)
- */
- @Override
- public void setComponentAlignment(Component childComponent,
- int horizontalAlignment, int verticalAlignment) {
- Alignment a = new Alignment(horizontalAlignment + verticalAlignment);
- setComponentAlignment(childComponent, a);
- }
-
@Override
public void setComponentAlignment(Component childComponent,
Alignment alignment) {
@@ -251,7 +237,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
if (childData != null) {
// Alignments are bit masks
childData.setAlignmentBitmask(alignment.getBitMask());
- requestRepaint();
} else {
throw new IllegalArgumentException(
"Component must be added to layout before using setComponentAlignment()");
@@ -285,7 +270,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
@Override
public void setSpacing(boolean spacing) {
getState().setSpacing(spacing);
- requestRepaint();
}
/*
@@ -335,8 +319,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
}
childData.setExpandRatio(ratio);
- requestRepaint();
- };
+ }
/**
* Returns the expand ratio of given component.
@@ -392,4 +375,28 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
return components.get(index);
}
+ @Override
+ public void setMargin(boolean enabled) {
+ setMargin(new MarginInfo(enabled));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Layout.MarginHandler#getMargin()
+ */
+ @Override
+ public MarginInfo getMargin() {
+ return new MarginInfo(getState().getMarginsBitmask());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo)
+ */
+ @Override
+ public void setMargin(MarginInfo marginInfo) {
+ getState().setMarginsBitmask(marginInfo.getBitMask());
+ }
}
diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java
index 19a74782c4..21ff7ba948 100644
--- a/server/src/com/vaadin/ui/AbstractSelect.java
+++ b/server/src/com/vaadin/ui/AbstractSelect.java
@@ -462,7 +462,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
- requestRepaint();
+ markAsDirty();
} else if (id != null && containsId(id)) {
acceptedSelections.add(id);
}
@@ -470,7 +470,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
if (!isNullSelectionAllowed() && acceptedSelections.size() < 1) {
// empty selection not allowed, keep old value
- requestRepaint();
+ markAsDirty();
return;
}
@@ -498,7 +498,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
if (!isNullSelectionAllowed()
&& (clientSideSelectedKeys.length == 0
|| clientSideSelectedKeys[0] == null || clientSideSelectedKeys[0] == getNullSelectionItemId())) {
- requestRepaint();
+ markAsDirty();
return;
}
if (clientSideSelectedKeys.length == 0) {
@@ -513,7 +513,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
final Object id = itemIdMapper
.get(clientSideSelectedKeys[0]);
if (!isNullSelectionAllowed() && id == null) {
- requestRepaint();
+ markAsDirty();
} else if (id != null
&& id.equals(getNullSelectionItemId())) {
setValue(null, true);
@@ -975,7 +975,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
*/
setValue(null);
- requestRepaint();
+ markAsDirty();
}
}
@@ -1042,7 +1042,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -1071,7 +1071,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
this.allowNewOptions = allowNewOptions;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1087,7 +1087,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
public void setItemCaption(Object itemId, String caption) {
if (itemId != null) {
itemCaptions.put(itemId, caption);
- requestRepaint();
+ markAsDirty();
}
}
@@ -1173,7 +1173,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
} else {
itemIcons.put(itemId, icon);
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -1239,7 +1239,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
public void setItemCaptionMode(ItemCaptionMode mode) {
if (mode != null) {
itemCaptionMode = mode;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1302,13 +1302,13 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
if (propertyId != null) {
itemCaptionPropertyId = propertyId;
setItemCaptionMode(ITEM_CAPTION_MODE_PROPERTY);
- requestRepaint();
+ markAsDirty();
} else {
itemCaptionPropertyId = null;
if (getItemCaptionMode() == ITEM_CAPTION_MODE_PROPERTY) {
setItemCaptionMode(ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID);
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -1360,7 +1360,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
throw new IllegalArgumentException(
"Property type must be assignable to Resource");
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1579,7 +1579,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
.containerPropertySetChange(event);
}
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1594,7 +1594,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
.containerItemSetChange(event);
}
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1665,7 +1665,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
public void setNullSelectionAllowed(boolean nullSelectionAllowed) {
if (nullSelectionAllowed != this.nullSelectionAllowed) {
this.nullSelectionAllowed = nullSelectionAllowed;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1824,13 +1824,13 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
- requestRepaint();
+ markAsDirty();
}
@Override
public void itemPropertySetChange(
com.vaadin.data.Item.PropertySetChangeEvent event) {
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java
index 03e8a2dfb6..8b7499115c 100644
--- a/server/src/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java
@@ -154,8 +154,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
if (c != null) {
super.addComponent(c);
}
-
- requestRepaint();
}
/**
@@ -179,7 +177,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
if (c != null) {
super.addComponent(c);
}
- requestRepaint();
}
/**
@@ -217,7 +214,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
} else if (c == getSecondComponent()) {
getState().setSecondChild(null);
}
- requestRepaint();
+ markAsDirty();
}
/*
@@ -259,7 +256,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
} else if (oldComponent == getSecondComponent()) {
setSecondComponent(newComponent);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -329,8 +326,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
splitterState.setPositionUnit(unit.getSymbol());
splitterState.setPositionReversed(reverse);
posUnit = unit;
-
- requestRepaint();
}
/**
@@ -452,8 +447,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
state.setMaxPosition(maxPos);
state.setMaxPositionUnit(maxPosUnit.getSymbol());
posMaxUnit = maxPosUnit;
-
- requestRepaint();
}
/**
@@ -465,7 +458,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
*/
public void setLocked(boolean locked) {
getSplitterState().setLocked(locked);
- requestRepaint();
}
/**
@@ -520,7 +512,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
}
@Override
- public AbstractSplitPanelState getState() {
+ protected AbstractSplitPanelState getState() {
return (AbstractSplitPanelState) super.getState();
}
diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java
index 86315f801f..1bd61023a4 100644
--- a/server/src/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/com/vaadin/ui/AbstractTextField.java
@@ -92,7 +92,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
}
@Override
- public AbstractTextFieldState getState() {
+ protected AbstractTextFieldState getState() {
return (AbstractTextFieldState) super.getState();
}
@@ -184,7 +184,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
// If the modified status changes, or if we have a
// formatter, repaint is needed after all.
if (wasModified != isModified()) {
- requestRepaint();
+ markAsDirty();
}
}
}
@@ -271,7 +271,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
public void setNullRepresentation(String nullRepresentation) {
this.nullRepresentation = nullRepresentation;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -297,7 +297,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
public void setNullSettingAllowed(boolean nullSettingAllowed) {
this.nullSettingAllowed = nullSettingAllowed;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -324,7 +324,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
public void setMaxLength(int maxLength) {
getState().setMaxLength(maxLength);
- requestRepaint();
}
/**
@@ -351,7 +350,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
columns = 0;
}
getState().setColumns(columns);
- requestRepaint();
}
/**
@@ -372,7 +370,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
public void setInputPrompt(String inputPrompt) {
getState().setInputPrompt(inputPrompt);
- requestRepaint();
}
/* ** Text Change Events ** */
@@ -443,7 +440,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
if (lastKnownTextContent != null) {
lastKnownTextContent = null;
- requestRepaint();
+ markAsDirty();
}
}
@@ -468,7 +465,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
public void setTextChangeEventMode(TextChangeEventMode inputEventMode) {
textChangeEventMode = inputEventMode;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -539,7 +536,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
public void setTextChangeTimeout(int timeout) {
textChangeEventTimeout = timeout;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -630,7 +627,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
selectionPosition = pos;
selectionLength = length;
focus();
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index f568d770e8..8546d8f830 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -478,7 +478,6 @@ public class Button extends AbstractComponent implements
*/
public void setDisableOnClick(boolean disableOnClick) {
getState().setDisableOnClick(disableOnClick);
- requestRepaint();
}
/*
@@ -499,7 +498,6 @@ public class Button extends AbstractComponent implements
@Override
public void setTabIndex(int tabIndex) {
getState().setTabIndex(tabIndex);
- requestRepaint();
}
@Override
@@ -509,7 +507,7 @@ public class Button extends AbstractComponent implements
}
@Override
- public ButtonState getState() {
+ protected ButtonState getState() {
return (ButtonState) super.getState();
}
@@ -526,10 +524,7 @@ public class Button extends AbstractComponent implements
* <code>false</code> otherwise
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- if (getState().isHtmlContentAllowed() != htmlContentAllowed) {
- getState().setHtmlContentAllowed(htmlContentAllowed);
- requestRepaint();
- }
+ getState().setHtmlContentAllowed(htmlContentAllowed);
}
/**
diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java
index 158c9d0032..6da86b9711 100644
--- a/server/src/com/vaadin/ui/CheckBox.java
+++ b/server/src/com/vaadin/ui/CheckBox.java
@@ -106,7 +106,7 @@ public class CheckBox extends AbstractField<Boolean> {
}
@Override
- public CheckBoxState getState() {
+ protected CheckBoxState getState() {
return (CheckBoxState) super.getState();
}
diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java
index e2655be405..af19ca5b96 100644
--- a/server/src/com/vaadin/ui/ComboBox.java
+++ b/server/src/com/vaadin/ui/ComboBox.java
@@ -81,7 +81,7 @@ public class ComboBox extends Select {
*/
public void setInputPrompt(String inputPrompt) {
this.inputPrompt = inputPrompt;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -110,7 +110,7 @@ public class ComboBox extends Select {
*/
public void setTextInputAllowed(boolean textInputAllowed) {
this.textInputAllowed = textInputAllowed;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java
index ff7ed47930..89e282d4e1 100644
--- a/server/src/com/vaadin/ui/Component.java
+++ b/server/src/com/vaadin/ui/Component.java
@@ -23,7 +23,6 @@ import java.util.Locale;
import com.vaadin.Application;
import com.vaadin.event.FieldEvents;
-import com.vaadin.shared.ComponentState;
import com.vaadin.terminal.ErrorMessage;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.Sizeable;
@@ -624,19 +623,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
public Locale getLocale();
/**
- * Returns the current shared state bean for the component. The state (or
- * changes to it) is communicated from the server to the client.
- *
- * Subclasses can use a more specific return type for this method.
- *
- * @return The state object for the component
- *
- * @since 7.0
- */
- @Override
- public ComponentState getState();
-
- /**
* Adds an unique id for component that get's transferred to terminal for
* testing purposes. Keeping identifiers unique is the responsibility of the
* programmer.
diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java
index 2afe7f9025..72879e0a25 100644
--- a/server/src/com/vaadin/ui/ConnectorTracker.java
+++ b/server/src/com/vaadin/ui/ConnectorTracker.java
@@ -385,4 +385,8 @@ public class ConnectorTracker implements Serializable {
diffStates.put(connector, diffState);
}
+ public boolean isDirty(ClientConnector connector) {
+ return dirtyConnectors.contains(connector);
+ }
+
}
diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java
index 0192debc4a..b16bcf31df 100644
--- a/server/src/com/vaadin/ui/CssLayout.java
+++ b/server/src/com/vaadin/ui/CssLayout.java
@@ -102,7 +102,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.add(c);
try {
super.addComponent(c);
- requestRepaint();
+ markAsDirty();
} catch (IllegalArgumentException e) {
components.remove(c);
throw e;
@@ -125,7 +125,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.addFirst(c);
try {
super.addComponent(c);
- requestRepaint();
+ markAsDirty();
} catch (IllegalArgumentException e) {
components.remove(c);
throw e;
@@ -154,7 +154,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.add(index, c);
try {
super.addComponent(c);
- requestRepaint();
+ markAsDirty();
} catch (IllegalArgumentException e) {
components.remove(c);
throw e;
@@ -171,7 +171,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
public void removeComponent(Component c) {
components.remove(c);
super.removeComponent(c);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -211,7 +211,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
}
@Override
- public CssLayoutState getState() {
+ protected CssLayoutState getState() {
return (CssLayoutState) super.getState();
}
@@ -276,7 +276,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.add(newLocation, oldComponent);
}
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/CustomComponent.java b/server/src/com/vaadin/ui/CustomComponent.java
index 88f7b162c1..b67fa89ecb 100644
--- a/server/src/com/vaadin/ui/CustomComponent.java
+++ b/server/src/com/vaadin/ui/CustomComponent.java
@@ -100,7 +100,7 @@ public class CustomComponent extends AbstractComponentContainer {
super.addComponent(compositionRoot);
}
root = compositionRoot;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/CustomField.java b/server/src/com/vaadin/ui/CustomField.java
index 794e472dae..9ac5e2defb 100644
--- a/server/src/com/vaadin/ui/CustomField.java
+++ b/server/src/com/vaadin/ui/CustomField.java
@@ -120,13 +120,13 @@ public abstract class CustomField<T> extends AbstractField<T> implements
@Override
public void setHeight(float height, Unit unit) {
super.setHeight(height, unit);
- requestRepaintAll();
+ markAsDirtyRecursive();
}
@Override
public void setWidth(float height, Unit unit) {
super.setWidth(height, unit);
- requestRepaintAll();
+ markAsDirtyRecursive();
}
// ComponentContainer methods
diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java
index 2da443bfa5..54308b99c3 100644
--- a/server/src/com/vaadin/ui/CustomLayout.java
+++ b/server/src/com/vaadin/ui/CustomLayout.java
@@ -123,7 +123,7 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component {
}
@Override
- public CustomLayoutState getState() {
+ protected CustomLayoutState getState() {
return (CustomLayoutState) super.getState();
}
@@ -145,7 +145,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component {
getState().getChildLocations().put(c, location);
c.setParent(this);
fireComponentAttachEvent(c);
- requestRepaint();
}
/**
@@ -176,7 +175,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component {
slots.values().remove(c);
getState().getChildLocations().remove(c);
super.removeComponent(c);
- requestRepaint();
}
/**
@@ -251,7 +249,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component {
slots.put(oldLocation, newComponent);
getState().getChildLocations().put(newComponent, oldLocation);
getState().getChildLocations().put(oldComponent, newLocation);
- requestRepaint();
}
}
@@ -277,7 +274,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component {
public void setTemplateName(String templateName) {
getState().setTemplateName(templateName);
getState().setTemplateContents(null);
- requestRepaint();
}
/**
@@ -288,34 +284,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component {
public void setTemplateContents(String templateContents) {
getState().setTemplateContents(templateContents);
getState().setTemplateName(null);
- requestRepaint();
- }
-
- /**
- * Although most layouts support margins, CustomLayout does not. The
- * behaviour of this layout is determined almost completely by the actual
- * template.
- *
- * @throws UnsupportedOperationException
- */
- @Override
- public void setMargin(boolean enabled) {
- throw new UnsupportedOperationException(
- "CustomLayout does not support margins.");
- }
-
- /**
- * Although most layouts support margins, CustomLayout does not. The
- * behaviour of this layout is determined almost completely by the actual
- * template.
- *
- * @throws UnsupportedOperationException
- */
- @Override
- public void setMargin(boolean topEnabled, boolean rightEnabled,
- boolean bottomEnabled, boolean leftEnabled) {
- throw new UnsupportedOperationException(
- "CustomLayout does not support margins.");
}
@Override
diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java
index 5130d665eb..828fa3b21d 100644
--- a/server/src/com/vaadin/ui/DateField.java
+++ b/server/src/com/vaadin/ui/DateField.java
@@ -131,7 +131,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: seconds.
*
- * @deprecated Use {@link Resolution#SECOND}
+ * @deprecated As of 7.0, use {@link Resolution#SECOND}
*/
@Deprecated
public static final Resolution RESOLUTION_SEC = Resolution.SECOND;
@@ -139,7 +139,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: minutes.
*
- * @deprecated Use {@link Resolution#MINUTE}
+ * @deprecated As of 7.0, use {@link Resolution#MINUTE}
*/
@Deprecated
public static final Resolution RESOLUTION_MIN = Resolution.MINUTE;
@@ -147,7 +147,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: hours.
*
- * @deprecated Use {@link Resolution#HOUR}
+ * @deprecated As of 7.0, use {@link Resolution#HOUR}
*/
@Deprecated
public static final Resolution RESOLUTION_HOUR = Resolution.HOUR;
@@ -155,7 +155,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: days.
*
- * @deprecated Use {@link Resolution#DAY}
+ * @deprecated As of 7.0, use {@link Resolution#DAY}
*/
@Deprecated
public static final Resolution RESOLUTION_DAY = Resolution.DAY;
@@ -163,7 +163,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: months.
*
- * @deprecated Use {@link Resolution#MONTH}
+ * @deprecated As of 7.0, use {@link Resolution#MONTH}
*/
@Deprecated
public static final Resolution RESOLUTION_MONTH = Resolution.MONTH;
@@ -171,7 +171,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: years.
*
- * @deprecated Use {@link Resolution#YEAR}
+ * @deprecated As of 7.0, use {@link Resolution#YEAR}
*/
@Deprecated
public static final Resolution RESOLUTION_YEAR = Resolution.YEAR;
@@ -429,7 +429,7 @@ public class DateField extends AbstractField<Date> implements
* if handleUnparsableDateString throws an exception. In
* this case the invalid text remains in the DateField.
*/
- requestRepaint();
+ markAsDirty();
} catch (Converter.ConversionException e) {
/*
@@ -471,7 +471,7 @@ public class DateField extends AbstractField<Date> implements
* change and form depends on this implementation detail.
*/
notifyFormOfValidityChange();
- requestRepaint();
+ markAsDirty();
}
} else if (newDate != oldDate
&& (newDate == null || !newDate.equals(oldDate))) {
@@ -562,7 +562,7 @@ public class DateField extends AbstractField<Date> implements
* this.
*/
notifyFormOfValidityChange();
- requestRepaint();
+ markAsDirty();
return;
}
@@ -588,7 +588,7 @@ public class DateField extends AbstractField<Date> implements
* thing as form does in its value change listener that
* it registers to all fields.
*/
- f.requestRepaint();
+ f.markAsDirty();
formFound = true;
break;
}
@@ -639,7 +639,7 @@ public class DateField extends AbstractField<Date> implements
*/
public void setResolution(Resolution resolution) {
this.resolution = resolution;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -699,7 +699,7 @@ public class DateField extends AbstractField<Date> implements
*/
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -725,7 +725,7 @@ public class DateField extends AbstractField<Date> implements
*/
public void setLenient(boolean lenient) {
this.lenient = lenient;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -781,7 +781,7 @@ public class DateField extends AbstractField<Date> implements
*/
public void setShowISOWeekNumbers(boolean showWeekNumbers) {
showISOWeekNumbers = showWeekNumbers;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -850,7 +850,7 @@ public class DateField extends AbstractField<Date> implements
*/
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java
index 3fd94210d8..ec805ecf46 100644
--- a/server/src/com/vaadin/ui/DragAndDropWrapper.java
+++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java
@@ -60,7 +60,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
String id = (String) rawVariables.get("fi" + i);
files[i] = file;
receivers.put(id, file);
- requestRepaint(); // paint Receivers
+ markAsDirty(); // paint Receivers
}
}
}
@@ -156,22 +156,6 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
.valueOf((String) getData("horizontalLocation"));
}
- /**
- * @deprecated use {@link #getVerticalDropLocation()} instead
- */
- @Deprecated
- public VerticalDropLocation verticalDropLocation() {
- return getVerticalDropLocation();
- }
-
- /**
- * @deprecated use {@link #getHorizontalDropLocation()} instead
- */
- @Deprecated
- public HorizontalDropLocation horizontalDropLocation() {
- return getHorizontalDropLocation();
- }
-
}
public enum DragStartMode {
@@ -223,7 +207,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
*/
public void setHTML5DataFlavor(String type, Object value) {
html5DataFlavors.put(type, value);
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -270,7 +254,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
public void setDropHandler(DropHandler dropHandler) {
this.dropHandler = dropHandler;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -286,7 +270,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
public void setDragStartMode(DragStartMode dragStartMode) {
this.dragStartMode = dragStartMode;
- requestRepaint();
+ markAsDirty();
}
public DragStartMode getDragStartMode() {
diff --git a/server/src/com/vaadin/ui/Embedded.java b/server/src/com/vaadin/ui/Embedded.java
index d019ea3b0b..41b93d0b27 100644
--- a/server/src/com/vaadin/ui/Embedded.java
+++ b/server/src/com/vaadin/ui/Embedded.java
@@ -196,7 +196,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
if (altText != this.altText
|| (altText != null && !altText.equals(this.altText))) {
this.altText = altText;
- requestRepaint();
+ markAsDirty();
}
}
@@ -222,7 +222,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
*/
public void setParameter(String name, String value) {
parameters.put(name, value);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -244,7 +244,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
*/
public void removeParameter(String name) {
parameters.remove(name);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -307,7 +307,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
if (codebase != this.codebase
|| (codebase != null && !codebase.equals(this.codebase))) {
this.codebase = codebase;
- requestRepaint();
+ markAsDirty();
}
}
@@ -325,7 +325,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
if (codetype != this.codetype
|| (codetype != null && !codetype.equals(this.codetype))) {
this.codetype = codetype;
- requestRepaint();
+ markAsDirty();
}
}
@@ -350,7 +350,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
setParameter("wmode", "transparent");
}
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -365,7 +365,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
if (standby != this.standby
|| (standby != null && !standby.equals(this.standby))) {
this.standby = standby;
- requestRepaint();
+ markAsDirty();
}
}
@@ -390,7 +390,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
if (classId != this.classId
|| (classId != null && !classId.equals(this.classId))) {
this.classId = classId;
- requestRepaint();
+ markAsDirty();
}
}
@@ -443,7 +443,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
} else {
// Keep previous type
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -467,7 +467,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
}
if (type != this.type) {
this.type = type;
- requestRepaint();
+ markAsDirty();
}
}
@@ -502,7 +502,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component {
if (archive != this.archive
|| (archive != null && !archive.equals(this.archive))) {
this.archive = archive;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index a1ec0f9917..55404b2e6b 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -99,14 +99,9 @@ public class Form extends AbstractField<Object> implements Item.Editor,
private Buffered.SourceException currentBufferedSourceException = null;
/**
- * Is the form in write trough mode.
+ * Is the form in buffered mode.
*/
- private boolean writeThrough = true;
-
- /**
- * Is the form in read trough mode.
- */
- private boolean readThrough = true;
+ private boolean buffered = false;
/**
* Mapping from propertyName to corresponding field.
@@ -138,7 +133,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
private final ValueChangeListener fieldValueChangeListener = new ValueChangeListener() {
@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
- requestRepaint();
+ markAsDirty();
}
};
@@ -200,7 +195,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
}
@Override
- public FormState getState() {
+ protected FormState getState() {
return (FormState) super.getState();
}
@@ -347,7 +342,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
if (problems == null) {
if (currentBufferedSourceException != null) {
currentBufferedSourceException = null;
- requestRepaint();
+ markAsDirty();
}
return;
}
@@ -362,7 +357,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
final Buffered.SourceException e = new Buffered.SourceException(this,
causes);
currentBufferedSourceException = e;
- requestRepaint();
+ markAsDirty();
throw e;
}
@@ -391,7 +386,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
if (problems == null) {
if (currentBufferedSourceException != null) {
currentBufferedSourceException = null;
- requestRepaint();
+ markAsDirty();
}
return;
}
@@ -406,7 +401,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
final Buffered.SourceException e = new Buffered.SourceException(this,
causes);
currentBufferedSourceException = e;
- requestRepaint();
+ markAsDirty();
throw e;
}
@@ -427,50 +422,15 @@ public class Form extends AbstractField<Object> implements Item.Editor,
}
/*
- * Is the editor in a read-through mode? Don't add a JavaDoc comment here,
- * we use the default one from the interface.
- */
- @Override
- @Deprecated
- public boolean isReadThrough() {
- return readThrough;
- }
-
- /*
- * Is the editor in a write-through mode? Don't add a JavaDoc comment here,
- * we use the default one from the interface.
- */
- @Override
- @Deprecated
- public boolean isWriteThrough() {
- return writeThrough;
- }
-
- /*
- * Sets the editor's read-through mode to the specified status. Don't add a
+ * Sets the editor's buffered mode to the specified status. Don't add a
* JavaDoc comment here, we use the default one from the interface.
*/
@Override
- public void setReadThrough(boolean readThrough) {
- if (readThrough != this.readThrough) {
- this.readThrough = readThrough;
+ public void setBuffered(boolean buffered) {
+ if (buffered != this.buffered) {
+ this.buffered = buffered;
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).setReadThrough(readThrough);
- }
- }
- }
-
- /*
- * Sets the editor's read-through mode to the specified status. Don't add a
- * JavaDoc comment here, we use the default one from the interface.
- */
- @Override
- public void setWriteThrough(boolean writeThrough) throws SourceException,
- InvalidValueException {
- if (writeThrough != this.writeThrough) {
- this.writeThrough = writeThrough;
- for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).setWriteThrough(writeThrough);
+ (fields.get(i.next())).setBuffered(buffered);
}
}
}
@@ -531,7 +491,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
public void addField(Object propertyId, Field<?> field) {
registerField(propertyId, field);
attachField(propertyId, field);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -560,11 +520,10 @@ public class Form extends AbstractField<Object> implements Item.Editor,
propertyIds.addLast(propertyId);
}
- // Update the read and write through status and immediate to match the
+ // Update the buffered mode and immediate to match the
// form.
// Should this also include invalidCommitted (#3993)?
- field.setReadThrough(readThrough);
- field.setWriteThrough(writeThrough);
+ field.setBuffered(buffered);
if (isImmediate() && field instanceof AbstractComponent) {
((AbstractComponent) field).setImmediate(true);
}
@@ -761,7 +720,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
// If the new datasource is null, just set null datasource
if (itemDatasource == null) {
- requestRepaint();
+ markAsDirty();
return;
}
@@ -861,10 +820,6 @@ public class Form extends AbstractField<Object> implements Item.Editor,
// Replace the previous layout
layout.setParent(this);
getState().setLayout(layout);
-
- // Hierarchy has changed so we need to repaint (this could be a
- // hierarchy repaint only)
- requestRepaint();
}
/**
@@ -949,8 +904,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
: new Select();
newField.setCaption(oldField.getCaption());
newField.setReadOnly(oldField.isReadOnly());
- newField.setReadThrough(oldField.isReadThrough());
- newField.setWriteThrough(oldField.isWriteThrough());
+ newField.setBuffered(oldField.isBuffered());
// Creates the options list
newField.addContainerProperty("desc", String.class, "");
@@ -1281,11 +1235,6 @@ public class Form extends AbstractField<Object> implements Item.Editor,
getState().setFooter(footer);
footer.setParent(this);
-
- // Hierarchy has changed so we need to repaint (this could be a
- // hierarchy repaint only)
- requestRepaint();
-
}
@Override
@@ -1295,7 +1244,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
// some ancestor still disabled, don't update children
return;
} else {
- getLayout().requestRepaintAll();
+ getLayout().markAsDirtyRecursive();
}
}
diff --git a/server/src/com/vaadin/ui/FormLayout.java b/server/src/com/vaadin/ui/FormLayout.java
index c4ba4665ea..15ea478597 100644
--- a/server/src/com/vaadin/ui/FormLayout.java
+++ b/server/src/com/vaadin/ui/FormLayout.java
@@ -16,6 +16,8 @@
package com.vaadin.ui;
+import com.vaadin.shared.ui.MarginInfo;
+
/**
* FormLayout is used by {@link Form} to layout fields. It may also be used
* separately without {@link Form}.
@@ -36,7 +38,7 @@ public class FormLayout extends AbstractOrderedLayout {
public FormLayout() {
super();
setSpacing(true);
- setMargin(true, false, true, false);
+ setMargin(new MarginInfo(true, false, true, false));
setWidth(100, UNITS_PERCENTAGE);
}
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index 5a748c04f6..3870b71611 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -30,6 +30,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickNotifier;
import com.vaadin.shared.Connector;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc;
import com.vaadin.shared.ui.gridlayout.GridLayoutState;
import com.vaadin.terminal.LegacyPaint;
@@ -63,8 +64,8 @@ import com.vaadin.terminal.Vaadin6Component;
*/
@SuppressWarnings("serial")
public class GridLayout extends AbstractLayout implements
- Layout.AlignmentHandler, Layout.SpacingHandler, LayoutClickNotifier,
- Vaadin6Component {
+ Layout.AlignmentHandler, Layout.SpacingHandler, Layout.MarginHandler,
+ LayoutClickNotifier, Vaadin6Component {
private GridLayoutServerRpc rpc = new GridLayoutServerRpc() {
@@ -140,7 +141,7 @@ public class GridLayout extends AbstractLayout implements
}
@Override
- public GridLayoutState getState() {
+ protected GridLayoutState getState() {
return (GridLayoutState) super.getState();
}
@@ -253,7 +254,7 @@ public class GridLayout extends AbstractLayout implements
}
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -399,7 +400,7 @@ public class GridLayout extends AbstractLayout implements
super.removeComponent(component);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -805,14 +806,6 @@ public class GridLayout extends AbstractLayout implements
}
/**
- * @deprecated Use {@link #getColumn1()} instead.
- */
- @Deprecated
- public int getX1() {
- return getColumn1();
- }
-
- /**
* Gets the column of the top-left corner cell.
*
* @return the column of the top-left corner cell.
@@ -822,14 +815,6 @@ public class GridLayout extends AbstractLayout implements
}
/**
- * @deprecated Use {@link #getColumn2()} instead.
- */
- @Deprecated
- public int getX2() {
- return getColumn2();
- }
-
- /**
* Gets the column of the bottom-right corner cell.
*
* @return the column of the bottom-right corner cell.
@@ -839,14 +824,6 @@ public class GridLayout extends AbstractLayout implements
}
/**
- * @deprecated Use {@link #getRow1()} instead.
- */
- @Deprecated
- public int getY1() {
- return getRow1();
- }
-
- /**
* Gets the row of the top-left corner cell.
*
* @return the row of the top-left corner cell.
@@ -856,14 +833,6 @@ public class GridLayout extends AbstractLayout implements
}
/**
- * @deprecated Use {@link #getRow2()} instead.
- */
- @Deprecated
- public int getY2() {
- return getRow2();
- }
-
- /**
* Gets the row of the bottom-right corner cell.
*
* @return the row of the bottom-right corner cell.
@@ -993,8 +962,6 @@ public class GridLayout extends AbstractLayout implements
}
getState().setColumns(columns);
-
- requestRepaint();
}
/**
@@ -1037,8 +1004,6 @@ public class GridLayout extends AbstractLayout implements
}
getState().setRows(rows);
-
- requestRepaint();
}
/**
@@ -1131,7 +1096,7 @@ public class GridLayout extends AbstractLayout implements
} else {
oldLocation.setComponent(newComponent);
newLocation.setComponent(oldComponent);
- requestRepaint();
+ markAsDirty();
}
}
@@ -1148,25 +1113,11 @@ public class GridLayout extends AbstractLayout implements
cursorY = 0;
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com
- * .vaadin.ui.Component, int, int)
- */
- @Override
- public void setComponentAlignment(Component childComponent,
- int horizontalAlignment, int verticalAlignment) {
- componentToAlignment.put(childComponent, new Alignment(
- horizontalAlignment + verticalAlignment));
- requestRepaint();
- }
-
@Override
public void setComponentAlignment(Component childComponent,
Alignment alignment) {
componentToAlignment.put(childComponent, alignment);
- requestRepaint();
+ markAsDirty();
}
/*
@@ -1177,7 +1128,6 @@ public class GridLayout extends AbstractLayout implements
@Override
public void setSpacing(boolean spacing) {
getState().setSpacing(spacing);
- requestRepaint();
}
/*
@@ -1223,7 +1173,7 @@ public class GridLayout extends AbstractLayout implements
setRows(getRows() + 1);
structuralChange = true;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1282,7 +1232,7 @@ public class GridLayout extends AbstractLayout implements
}
structuralChange = true;
- requestRepaint();
+ markAsDirty();
}
@@ -1307,7 +1257,7 @@ public class GridLayout extends AbstractLayout implements
*/
public void setColumnExpandRatio(int columnIndex, float ratio) {
columnExpandRatio.put(columnIndex, ratio);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1345,7 +1295,7 @@ public class GridLayout extends AbstractLayout implements
*/
public void setRowExpandRatio(int rowIndex, float ratio) {
rowExpandRatio.put(rowIndex, ratio);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1416,4 +1366,36 @@ public class GridLayout extends AbstractLayout implements
LayoutClickEvent.class, listener);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Layout.MarginHandler#setMargin(boolean)
+ */
+ @Override
+ public void setMargin(boolean enabled) {
+ setMargin(new MarginInfo(enabled));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.ui.Layout.MarginHandler#setMargin(com.vaadin.shared.ui.MarginInfo
+ * )
+ */
+ @Override
+ public void setMargin(MarginInfo marginInfo) {
+ getState().setMarginsBitmask(marginInfo.getBitMask());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.Layout.MarginHandler#getMargin()
+ */
+ @Override
+ public MarginInfo getMargin() {
+ return new MarginInfo(getState().getMarginsBitmask());
+ }
+
}
diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java
index 35cc1893f6..e34ccae82a 100644
--- a/server/src/com/vaadin/ui/JavaScript.java
+++ b/server/src/com/vaadin/ui/JavaScript.java
@@ -66,7 +66,7 @@ public class JavaScript extends AbstractExtension {
}
@Override
- public JavaScriptManagerState getState() {
+ protected JavaScriptManagerState getState() {
return (JavaScriptManagerState) super.getState();
}
@@ -93,9 +93,7 @@ public class JavaScript extends AbstractExtension {
*/
public void addFunction(String name, JavaScriptFunction function) {
functions.put(name, function);
- if (getState().getNames().add(name)) {
- requestRepaint();
- }
+ getState().getNames().add(name);
}
/**
@@ -111,9 +109,7 @@ public class JavaScript extends AbstractExtension {
*/
public void removeFunction(String name) {
functions.remove(name);
- if (getState().getNames().remove(name)) {
- requestRepaint();
- }
+ getState().getNames().remove(name);
}
/**
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index 668b99a74c..81a343e937 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -151,7 +151,7 @@ public class Label extends AbstractComponent implements Property<String>,
}
@Override
- public LabelState getState() {
+ protected LabelState getState() {
return (LabelState) super.getState();
}
@@ -168,7 +168,7 @@ public class Label extends AbstractComponent implements Property<String>,
public String getValue() {
if (getPropertyDataSource() == null) {
// Use internal value if we are running without a data source
- return getState().getText();
+ return getState().text;
}
return ConverterUtil.convertFromModel(getPropertyDataSource()
.getValue(), String.class, getConverter(), getLocale());
@@ -189,8 +189,7 @@ public class Label extends AbstractComponent implements Property<String>,
+ String.class.getName());
}
if (getPropertyDataSource() == null) {
- getState().setText((String) newStringValue);
- requestRepaint();
+ getState().text = (String) newStringValue;
} else {
throw new IllegalStateException(
"Label is only a Property.Viewer and cannot update its data source");
@@ -266,7 +265,7 @@ public class Label extends AbstractComponent implements Property<String>,
.isAssignableFrom(dataSource.getClass())) {
((Property.ValueChangeNotifier) dataSource).addListener(this);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -277,7 +276,7 @@ public class Label extends AbstractComponent implements Property<String>,
* @see ContentMode
*/
public ContentMode getContentMode() {
- return getState().getContentMode();
+ return getState().contentMode;
}
/**
@@ -293,8 +292,7 @@ public class Label extends AbstractComponent implements Property<String>,
throw new IllegalArgumentException("Content mode can not be null");
}
- getState().setContentMode(contentMode);
- requestRepaint();
+ getState().contentMode = contentMode;
}
/* Value change events */
@@ -384,8 +382,7 @@ public class Label extends AbstractComponent implements Property<String>,
@Override
public void valueChange(Property.ValueChangeEvent event) {
// Update the internal value from the data source
- getState().setText(getValue());
- requestRepaint();
+ getState().text = getValue();
fireValueChange();
}
@@ -485,7 +482,7 @@ public class Label extends AbstractComponent implements Property<String>,
*/
public void setConverter(Converter<String, ?> converter) {
this.converter = (Converter<String, Object>) converter;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/Layout.java b/server/src/com/vaadin/ui/Layout.java
index 6a95d23f8c..b32cf8c47d 100644
--- a/server/src/com/vaadin/ui/Layout.java
+++ b/server/src/com/vaadin/ui/Layout.java
@@ -18,8 +18,7 @@ package com.vaadin.ui;
import java.io.Serializable;
-import com.vaadin.shared.ui.VMarginInfo;
-import com.vaadin.shared.ui.AlignmentInfo.Bits;
+import com.vaadin.shared.ui.MarginInfo;
/**
* Extension to the {@link ComponentContainer} interface which adds the
@@ -33,104 +32,12 @@ import com.vaadin.shared.ui.AlignmentInfo.Bits;
public interface Layout extends ComponentContainer, Serializable {
/**
- * Enable layout margins. Affects all four sides of the layout. This will
- * tell the client-side implementation to leave extra space around the
- * layout. The client-side implementation decides the actual amount, and it
- * can vary between themes.
- *
- * @param enabled
- */
- public void setMargin(boolean enabled);
-
- /**
- * Enable specific layout margins. This will tell the client-side
- * implementation to leave extra space around the layout in specified edges,
- * clockwise from top (top, right, bottom, left). The client-side
- * implementation decides the actual amount, and it can vary between themes.
- *
- * @param top
- * @param right
- * @param bottom
- * @param left
- */
- public void setMargin(boolean top, boolean right, boolean bottom,
- boolean left);
-
- /**
* AlignmentHandler is most commonly an advanced {@link Layout} that can
* align its components.
*/
public interface AlignmentHandler extends Serializable {
/**
- * Contained component should be aligned horizontally to the left.
- *
- * @deprecated Use of {@link Alignment} class and its constants
- */
- @Deprecated
- public static final int ALIGNMENT_LEFT = Bits.ALIGNMENT_LEFT;
-
- /**
- * Contained component should be aligned horizontally to the right.
- *
- * @deprecated Use of {@link Alignment} class and its constants
- */
- @Deprecated
- public static final int ALIGNMENT_RIGHT = Bits.ALIGNMENT_RIGHT;
-
- /**
- * Contained component should be aligned vertically to the top.
- *
- * @deprecated Use of {@link Alignment} class and its constants
- */
- @Deprecated
- public static final int ALIGNMENT_TOP = Bits.ALIGNMENT_TOP;
-
- /**
- * Contained component should be aligned vertically to the bottom.
- *
- * @deprecated Use of {@link Alignment} class and its constants
- */
- @Deprecated
- public static final int ALIGNMENT_BOTTOM = Bits.ALIGNMENT_BOTTOM;
-
- /**
- * Contained component should be horizontally aligned to center.
- *
- * @deprecated Use of {@link Alignment} class and its constants
- */
- @Deprecated
- public static final int ALIGNMENT_HORIZONTAL_CENTER = Bits.ALIGNMENT_HORIZONTAL_CENTER;
-
- /**
- * Contained component should be vertically aligned to center.
- *
- * @deprecated Use of {@link Alignment} class and its constants
- */
- @Deprecated
- public static final int ALIGNMENT_VERTICAL_CENTER = Bits.ALIGNMENT_VERTICAL_CENTER;
-
- /**
- * Set alignment for one contained component in this layout. Alignment
- * is calculated as a bit mask of the two passed values.
- *
- * @deprecated Use {@link #setComponentAlignment(Component, Alignment)}
- * instead
- *
- * @param childComponent
- * the component to align within it's layout cell.
- * @param horizontalAlignment
- * the horizontal alignment for the child component (left,
- * center, right). Use ALIGNMENT constants.
- * @param verticalAlignment
- * the vertical alignment for the child component (top,
- * center, bottom). Use ALIGNMENT constants.
- */
- @Deprecated
- public void setComponentAlignment(Component childComponent,
- int horizontalAlignment, int verticalAlignment);
-
- /**
* Set alignment for one contained component in this layout. Use
* predefined alignments from Alignment class.
*
@@ -197,6 +104,19 @@ public interface Layout extends ComponentContainer, Serializable {
* its components).
*/
public interface MarginHandler extends Serializable {
+
+ /**
+ * Enable layout margins. Affects all four sides of the layout. This
+ * will tell the client-side implementation to leave extra space around
+ * the layout. The client-side implementation decides the actual amount,
+ * and it can vary between themes.
+ *
+ * @param enabled
+ * true if margins should be enabled on all sides, false to
+ * disable all margins
+ */
+ public void setMargin(boolean enabled);
+
/**
* Enable margins for this layout.
*
@@ -224,16 +144,4 @@ public interface Layout extends ComponentContainer, Serializable {
public MarginInfo getMargin();
}
- @SuppressWarnings("serial")
- public static class MarginInfo extends VMarginInfo implements Serializable {
-
- public MarginInfo(boolean enabled) {
- super(enabled, enabled, enabled, enabled);
- }
-
- public MarginInfo(boolean top, boolean right, boolean bottom,
- boolean left) {
- super(top, right, bottom, left);
- }
- }
}
diff --git a/server/src/com/vaadin/ui/Link.java b/server/src/com/vaadin/ui/Link.java
index 57f2088054..f98a2b0d2d 100644
--- a/server/src/com/vaadin/ui/Link.java
+++ b/server/src/com/vaadin/ui/Link.java
@@ -18,7 +18,7 @@ package com.vaadin.ui;
import java.util.Map;
-import com.vaadin.terminal.Page;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
@@ -34,19 +34,22 @@ import com.vaadin.terminal.Vaadin6Component;
public class Link extends AbstractComponent implements Vaadin6Component {
/* Target window border type constant: No window border */
- public static final int TARGET_BORDER_NONE = Page.BORDER_NONE;
+ @Deprecated
+ public static final BorderStyle TARGET_BORDER_NONE = BorderStyle.NONE;
/* Target window border type constant: Minimal window border */
- public static final int TARGET_BORDER_MINIMAL = Page.BORDER_MINIMAL;
+ @Deprecated
+ public static final BorderStyle TARGET_BORDER_MINIMAL = BorderStyle.MINIMAL;
/* Target window border type constant: Default window border */
- public static final int TARGET_BORDER_DEFAULT = Page.BORDER_DEFAULT;
+ @Deprecated
+ public static final BorderStyle TARGET_BORDER_DEFAULT = BorderStyle.DEFAULT;
private Resource resource = null;
private String targetName;
- private int targetBorder = TARGET_BORDER_DEFAULT;
+ private BorderStyle targetBorder = BorderStyle.DEFAULT;
private int targetWidth = -1;
@@ -89,7 +92,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
*
*/
public Link(String caption, Resource resource, String targetName,
- int width, int height, int border) {
+ int width, int height, BorderStyle border) {
setCaption(caption);
this.resource = resource;
setTargetName(targetName);
@@ -131,10 +134,10 @@ public class Link extends AbstractComponent implements Vaadin6Component {
// Target window border
switch (getTargetBorder()) {
- case TARGET_BORDER_MINIMAL:
+ case MINIMAL:
target.addAttribute("border", "minimal");
break;
- case TARGET_BORDER_NONE:
+ case NONE:
target.addAttribute("border", "none");
break;
}
@@ -145,7 +148,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
*
* @return the target window border.
*/
- public int getTargetBorder() {
+ public BorderStyle getTargetBorder() {
return targetBorder;
}
@@ -183,13 +186,9 @@ public class Link extends AbstractComponent implements Vaadin6Component {
* @param targetBorder
* the targetBorder to set.
*/
- public void setTargetBorder(int targetBorder) {
- if (targetBorder == TARGET_BORDER_DEFAULT
- || targetBorder == TARGET_BORDER_MINIMAL
- || targetBorder == TARGET_BORDER_NONE) {
- this.targetBorder = targetBorder;
- requestRepaint();
- }
+ public void setTargetBorder(BorderStyle targetBorder) {
+ this.targetBorder = targetBorder;
+ markAsDirty();
}
/**
@@ -200,7 +199,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
*/
public void setTargetHeight(int targetHeight) {
this.targetHeight = targetHeight;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -211,7 +210,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
*/
public void setTargetName(String targetName) {
this.targetName = targetName;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -222,7 +221,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
*/
public void setTargetWidth(int targetWidth) {
this.targetWidth = targetWidth;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -242,7 +241,7 @@ public class Link extends AbstractComponent implements Vaadin6Component {
*/
public void setResource(Resource resource) {
this.resource = resource;
- requestRepaint();
+ markAsDirty();
}
@Override
diff --git a/server/src/com/vaadin/ui/ListSelect.java b/server/src/com/vaadin/ui/ListSelect.java
index eb54183164..da78e24fa8 100644
--- a/server/src/com/vaadin/ui/ListSelect.java
+++ b/server/src/com/vaadin/ui/ListSelect.java
@@ -62,7 +62,7 @@ public class ListSelect extends AbstractSelect {
}
if (this.columns != columns) {
this.columns = columns;
- requestRepaint();
+ markAsDirty();
}
}
@@ -88,7 +88,7 @@ public class ListSelect extends AbstractSelect {
}
if (this.rows != rows) {
this.rows = rows;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java
index c8634ea81a..bb7767084c 100644
--- a/server/src/com/vaadin/ui/LoginForm.java
+++ b/server/src/com/vaadin/ui/LoginForm.java
@@ -99,6 +99,9 @@ public class LoginForm extends CustomComponent {
throws IOException {
String requestPathInfo = request.getRequestPathInfo();
if ("/loginHandler".equals(requestPathInfo)) {
+ // Ensure Root.getCurrent() works in listeners
+ Root.setCurrent(getRoot());
+
response.setCacheTime(-1);
response.setContentType("text/html; charset=utf-8");
response.getWriter()
diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java
index 37728ee69b..51c06cf934 100644
--- a/server/src/com/vaadin/ui/MenuBar.java
+++ b/server/src/com/vaadin/ui/MenuBar.java
@@ -223,7 +223,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
}
MenuItem newItem = new MenuItem(caption, icon, command);
menuItems.add(newItem);
- requestRepaint();
+ markAsDirty();
return newItem;
@@ -259,7 +259,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
menuItems.add(newItem);
}
- requestRepaint();
+ markAsDirty();
return newItem;
}
@@ -283,7 +283,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
if (item != null) {
menuItems.remove(item);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -291,7 +291,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
*/
public void removeItems() {
menuItems.clear();
- requestRepaint();
+ markAsDirty();
}
/**
@@ -318,7 +318,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
} else {
moreItem = new MenuItem("", null, null);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -345,7 +345,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
public void setAutoOpen(boolean autoOpenTopLevelMenu) {
if (autoOpenTopLevelMenu != openRootOnHover) {
openRootOnHover = autoOpenTopLevelMenu;
- requestRepaint();
+ markAsDirty();
}
}
@@ -373,7 +373,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
this.htmlContentAllowed = htmlContentAllowed;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -521,7 +521,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
newItem.setParent(this);
itsChildren.add(newItem);
- requestRepaint();
+ markAsDirty();
return newItem;
}
@@ -560,7 +560,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
newItem = addItem(caption, icon, command);
}
- requestRepaint();
+ markAsDirty();
return newItem;
}
@@ -651,7 +651,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
*/
public void setIcon(Resource icon) {
itsIcon = icon;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -664,7 +664,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
if (text != null) {
itsText = text;
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -679,7 +679,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
if (itsChildren.isEmpty()) {
itsChildren = null;
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -690,7 +690,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
if (itsChildren != null) {
itsChildren.clear();
itsChildren = null;
- requestRepaint();
+ markAsDirty();
}
}
@@ -706,7 +706,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
public void setEnabled(boolean enabled) {
this.enabled = enabled;
- requestRepaint();
+ markAsDirty();
}
public boolean isEnabled() {
@@ -715,7 +715,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
public void setVisible(boolean visible) {
this.visible = visible;
- requestRepaint();
+ markAsDirty();
}
public boolean isVisible() {
@@ -724,7 +724,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
private void setSeparator(boolean isSeparator) {
this.isSeparator = isSeparator;
- requestRepaint();
+ markAsDirty();
}
public boolean isSeparator() {
@@ -733,7 +733,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
public void setStyleName(String styleName) {
this.styleName = styleName;
- requestRepaint();
+ markAsDirty();
}
public String getStyleName() {
@@ -750,7 +750,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
*/
public void setDescription(String description) {
this.description = description;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -855,7 +855,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
"A menu item with children cannot be checkable");
}
this.checkable = checkable;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -897,7 +897,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component {
*/
public void setChecked(boolean checked) {
this.checked = checked;
- requestRepaint();
+ markAsDirty();
}
}// class MenuItem
diff --git a/server/src/com/vaadin/ui/NativeSelect.java b/server/src/com/vaadin/ui/NativeSelect.java
index 53c225a256..c2969874b0 100644
--- a/server/src/com/vaadin/ui/NativeSelect.java
+++ b/server/src/com/vaadin/ui/NativeSelect.java
@@ -64,7 +64,7 @@ public class NativeSelect extends AbstractSelect {
}
if (this.columns != columns) {
this.columns = columns;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/Notification.java b/server/src/com/vaadin/ui/Notification.java
index d408889519..22ad31dffe 100644
--- a/server/src/com/vaadin/ui/Notification.java
+++ b/server/src/com/vaadin/ui/Notification.java
@@ -18,6 +18,7 @@ package com.vaadin.ui;
import java.io.Serializable;
+import com.vaadin.shared.Position;
import com.vaadin.terminal.Page;
import com.vaadin.terminal.Resource;
@@ -61,18 +62,33 @@ import com.vaadin.terminal.Resource;
*
*/
public class Notification implements Serializable {
- public static final int TYPE_HUMANIZED_MESSAGE = 1;
- public static final int TYPE_WARNING_MESSAGE = 2;
- public static final int TYPE_ERROR_MESSAGE = 3;
- public static final int TYPE_TRAY_NOTIFICATION = 4;
-
- public static final int POSITION_CENTERED = 1;
- public static final int POSITION_CENTERED_TOP = 2;
- public static final int POSITION_CENTERED_BOTTOM = 3;
- public static final int POSITION_TOP_LEFT = 4;
- public static final int POSITION_TOP_RIGHT = 5;
- public static final int POSITION_BOTTOM_LEFT = 6;
- public static final int POSITION_BOTTOM_RIGHT = 7;
+ public enum Type {
+ HUMANIZED_MESSAGE, WARNING_MESSAGE, ERROR_MESSAGE, TRAY_NOTIFICATION;
+ }
+
+ @Deprecated
+ public static final Type TYPE_HUMANIZED_MESSAGE = Type.HUMANIZED_MESSAGE;
+ @Deprecated
+ public static final Type TYPE_WARNING_MESSAGE = Type.WARNING_MESSAGE;
+ @Deprecated
+ public static final Type TYPE_ERROR_MESSAGE = Type.ERROR_MESSAGE;
+ @Deprecated
+ public static final Type TYPE_TRAY_NOTIFICATION = Type.TRAY_NOTIFICATION;
+
+ @Deprecated
+ public static final Position POSITION_CENTERED = Position.MIDDLE_CENTER;
+ @Deprecated
+ public static final Position POSITION_CENTERED_TOP = Position.TOP_CENTER;
+ @Deprecated
+ public static final Position POSITION_CENTERED_BOTTOM = Position.BOTTOM_CENTER;
+ @Deprecated
+ public static final Position POSITION_TOP_LEFT = Position.TOP_LEFT;
+ @Deprecated
+ public static final Position POSITION_TOP_RIGHT = Position.TOP_RIGHT;
+ @Deprecated
+ public static final Position POSITION_BOTTOM_LEFT = Position.BOTTOM_LEFT;
+ @Deprecated
+ public static final Position POSITION_BOTTOM_RIGHT = Position.BOTTOM_RIGHT;
public static final int DELAY_FOREVER = -1;
public static final int DELAY_NONE = 0;
@@ -80,7 +96,7 @@ public class Notification implements Serializable {
private String caption;
private String description;
private Resource icon;
- private int position = POSITION_CENTERED;
+ private Position position = Position.MIDDLE_CENTER;
private int delayMsec = 0;
private String styleName;
private boolean htmlContentAllowed;
@@ -107,7 +123,7 @@ public class Notification implements Serializable {
* @param type
* The type of message
*/
- public Notification(String caption, int type) {
+ public Notification(String caption, Type type) {
this(caption, null, type);
}
@@ -141,7 +157,7 @@ public class Notification implements Serializable {
* @param type
* The type of message
*/
- public Notification(String caption, String description, int type) {
+ public Notification(String caption, String description, Type type) {
this(caption, description, type, false);
}
@@ -161,7 +177,7 @@ public class Notification implements Serializable {
* Whether html in the caption and description should be
* displayed as html or as plain text
*/
- public Notification(String caption, String description, int type,
+ public Notification(String caption, String description, Type type,
boolean htmlContentAllowed) {
this.caption = caption;
this.description = description;
@@ -169,22 +185,22 @@ public class Notification implements Serializable {
setType(type);
}
- private void setType(int type) {
+ private void setType(Type type) {
switch (type) {
- case TYPE_WARNING_MESSAGE:
+ case WARNING_MESSAGE:
delayMsec = 1500;
styleName = "warning";
break;
- case TYPE_ERROR_MESSAGE:
+ case ERROR_MESSAGE:
delayMsec = -1;
styleName = "error";
break;
- case TYPE_TRAY_NOTIFICATION:
+ case TRAY_NOTIFICATION:
delayMsec = 3000;
- position = POSITION_BOTTOM_RIGHT;
+ position = Position.BOTTOM_RIGHT;
styleName = "tray";
- case TYPE_HUMANIZED_MESSAGE:
+ case HUMANIZED_MESSAGE:
default:
break;
}
@@ -233,7 +249,7 @@ public class Notification implements Serializable {
*
* @return The position
*/
- public int getPosition() {
+ public Position getPosition() {
return position;
}
@@ -243,7 +259,7 @@ public class Notification implements Serializable {
* @param position
* The desired notification position
*/
- public void setPosition(int position) {
+ public void setPosition(Position position) {
this.position = position;
}
@@ -373,7 +389,7 @@ public class Notification implements Serializable {
* @param type
* The message type
*/
- public static void show(String caption, int type) {
+ public static void show(String caption, Type type) {
new Notification(caption, type).show(Page.getCurrent());
}
} \ No newline at end of file
diff --git a/server/src/com/vaadin/ui/OptionGroup.java b/server/src/com/vaadin/ui/OptionGroup.java
index dfb5019331..12507442c9 100644
--- a/server/src/com/vaadin/ui/OptionGroup.java
+++ b/server/src/com/vaadin/ui/OptionGroup.java
@@ -125,14 +125,14 @@ public class OptionGroup extends AbstractSelect implements
Set<?> newValueSet = (Set<?>) newValue;
for (Object itemId : currentValueSet) {
if (!isItemEnabled(itemId) && !newValueSet.contains(itemId)) {
- requestRepaint();
+ markAsDirty();
return;
}
}
for (Object itemId : newValueSet) {
if (!isItemEnabled(itemId)
&& !currentValueSet.contains(itemId)) {
- requestRepaint();
+ markAsDirty();
return;
}
}
@@ -141,7 +141,7 @@ public class OptionGroup extends AbstractSelect implements
newValue = getNullSelectionItemId();
}
if (!isItemEnabled(newValue)) {
- requestRepaint();
+ markAsDirty();
return;
}
}
@@ -169,7 +169,7 @@ public class OptionGroup extends AbstractSelect implements
} else {
disabledItemIds.add(itemId);
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -200,7 +200,7 @@ public class OptionGroup extends AbstractSelect implements
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
this.htmlContentAllowed = htmlContentAllowed;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java
index ba68238707..00810b83db 100644
--- a/server/src/com/vaadin/ui/Panel.java
+++ b/server/src/com/vaadin/ui/Panel.java
@@ -176,7 +176,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
.addListener((ComponentContainer.ComponentDetachListener) this);
content = newContent;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -318,7 +318,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
"Scroll offset must be at least 0");
}
getState().setScrollLeft(scrollLeft);
- requestRepaint();
}
/*
@@ -333,7 +332,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
"Scroll offset must be at least 0");
}
getState().setScrollTop(scrollTop);
- requestRepaint();
}
/* Documented in superclass */
@@ -465,7 +463,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
@Override
public void setTabIndex(int tabIndex) {
getState().setTabIndex(tabIndex);
- requestRepaint();
}
/**
@@ -489,7 +486,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
}
@Override
- public PanelState getState() {
+ protected PanelState getState() {
return (PanelState) super.getState();
}
diff --git a/server/src/com/vaadin/ui/PopupDateField.java b/server/src/com/vaadin/ui/PopupDateField.java
index a4304faaf9..acff49a142 100644
--- a/server/src/com/vaadin/ui/PopupDateField.java
+++ b/server/src/com/vaadin/ui/PopupDateField.java
@@ -84,7 +84,7 @@ public class PopupDateField extends DateField {
*/
public void setInputPrompt(String inputPrompt) {
this.inputPrompt = inputPrompt;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java
index 4a5814f660..786257c240 100644
--- a/server/src/com/vaadin/ui/PopupView.java
+++ b/server/src/com/vaadin/ui/PopupView.java
@@ -147,7 +147,7 @@ public class PopupView extends AbstractComponentContainer implements
throw new IllegalArgumentException("Content must not be null");
}
content = newContent;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -160,22 +160,6 @@ public class PopupView extends AbstractComponentContainer implements
}
/**
- * @deprecated Use {@link #setPopupVisible()} instead.
- */
- @Deprecated
- public void setPopupVisibility(boolean visible) {
- setPopupVisible(visible);
- }
-
- /**
- * @deprecated Use {@link #isPopupVisible()} instead.
- */
- @Deprecated
- public boolean getPopupVisibility() {
- return isPopupVisible();
- }
-
- /**
* Set the visibility of the popup. Does not hide the minimal
* representation.
*
@@ -195,7 +179,7 @@ public class PopupView extends AbstractComponentContainer implements
visibleComponent = null;
}
fireEvent(new PopupVisibilityEvent(this));
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java
index d3e292a3e1..528c404ab9 100644
--- a/server/src/com/vaadin/ui/ProgressIndicator.java
+++ b/server/src/com/vaadin/ui/ProgressIndicator.java
@@ -226,7 +226,7 @@ public class ProgressIndicator extends AbstractField<Number> implements
*/
public void setIndeterminate(boolean newValue) {
indeterminate = newValue;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -246,7 +246,7 @@ public class ProgressIndicator extends AbstractField<Number> implements
*/
public void setPollingInterval(int newValue) {
pollingInterval = newValue;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java
index e3d1168559..51caa82136 100644
--- a/server/src/com/vaadin/ui/RichTextArea.java
+++ b/server/src/com/vaadin/ui/RichTextArea.java
@@ -16,7 +16,6 @@
package com.vaadin.ui;
-import java.text.Format;
import java.util.Map;
import com.vaadin.data.Property;
@@ -35,12 +34,6 @@ public class RichTextArea extends AbstractField<String> implements
Vaadin6Component {
/**
- * Value formatter used to format the string contents.
- */
- @Deprecated
- private Format format;
-
- /**
* Null representation.
*/
private String nullRepresentation = "null";
@@ -123,7 +116,7 @@ public class RichTextArea extends AbstractField<String> implements
}
// Adds the content as variable
- String value = getFormattedValue();
+ String value = getValue();
if (value == null) {
value = getNullRepresentation();
}
@@ -164,38 +157,7 @@ public class RichTextArea extends AbstractField<String> implements
*/
selectAll = true;
focus();
- requestRepaint();
- }
-
- /**
- * Gets the formatted string value. Sets the field value by using the
- * assigned Format.
- *
- * @return the Formatted value.
- * @see #setFormat(Format)
- * @see Format
- * @deprecated
- */
- @Deprecated
- protected String getFormattedValue() {
- Object v = getValue();
- if (v == null) {
- return null;
- }
- return v.toString();
- }
-
- @Override
- public String getValue() {
- String v = super.getValue();
- if (format == null || v == null) {
- return v;
- }
- try {
- return format.format(v);
- } catch (final IllegalArgumentException e) {
- return v;
- }
+ markAsDirty();
}
@Override
@@ -207,7 +169,7 @@ public class RichTextArea extends AbstractField<String> implements
// has been updated
String newValue = (String) variables.get("text");
- final String oldValue = getFormattedValue();
+ final String oldValue = getValue();
if (newValue != null
&& (oldValue == null || isNullSettingAllowed())
&& newValue.equals(getNullRepresentation())) {
@@ -218,10 +180,10 @@ public class RichTextArea extends AbstractField<String> implements
boolean wasModified = isModified();
setValue(newValue, true);
- // If the modified status changes, or if we have a formatter,
+ // If the modified status changes,
// repaint is needed after all.
- if (format != null || wasModified != isModified()) {
- requestRepaint();
+ if (wasModified != isModified()) {
+ markAsDirty();
}
}
}
@@ -323,31 +285,6 @@ public class RichTextArea extends AbstractField<String> implements
this.nullSettingAllowed = nullSettingAllowed;
}
- /**
- * Gets the value formatter of TextField.
- *
- * @return the Format used to format the value.
- * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter}
- */
- @Deprecated
- public Format getFormat() {
- return format;
- }
-
- /**
- * Gets the value formatter of TextField.
- *
- * @param format
- * the Format used to format the value. Null disables the
- * formatting.
- * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter}
- */
- @Deprecated
- public void setFormat(Format format) {
- this.format = format;
- requestRepaint();
- }
-
@Override
protected boolean isEmpty() {
return super.isEmpty() || getValue().length() == 0;
diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java
index b37005a16e..67f2e04a65 100644
--- a/server/src/com/vaadin/ui/Root.java
+++ b/server/src/com/vaadin/ui/Root.java
@@ -34,6 +34,7 @@ import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.root.RootConstants;
import com.vaadin.shared.ui.root.RootServerRpc;
import com.vaadin.shared.ui.root.RootState;
@@ -283,13 +284,12 @@ public abstract class Root extends AbstractComponentContainer implements
* @param height
* the height of the window in pixels
* @param border
- * the border style of the window. See {@link #BORDER_NONE
- * Window.BORDER_* constants}
+ * the border style of the window.
* @deprecated As of 7.0, use getPage().open instead
*/
@Deprecated
public void open(Resource resource, String windowName, int width,
- int height, int border) {
+ int height, BorderStyle border) {
getPage().open(resource, windowName, width, height, border);
}
@@ -498,7 +498,7 @@ public abstract class Root extends AbstractComponentContainer implements
}
@Override
- public RootState getState() {
+ protected RootState getState() {
return (RootState) super.getState();
}
@@ -723,7 +723,7 @@ public abstract class Root extends AbstractComponentContainer implements
private void attachWindow(Window w) {
windows.add(w);
w.setParent(this);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -746,7 +746,7 @@ public abstract class Root extends AbstractComponentContainer implements
}
window.setParent(null);
window.fireClose();
- requestRepaint();
+ markAsDirty();
return true;
}
@@ -788,7 +788,7 @@ public abstract class Root extends AbstractComponentContainer implements
*/
public void setFocusedComponent(Focusable focusable) {
pendingFocus = focusable;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -808,7 +808,7 @@ public abstract class Root extends AbstractComponentContainer implements
"The component where to scroll must belong to this root.");
}
scrollIntoView = component;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -860,8 +860,6 @@ public abstract class Root extends AbstractComponentContainer implements
if (content != null) {
super.addComponent(content);
}
-
- requestRepaint();
}
/**
@@ -1015,7 +1013,7 @@ public abstract class Root extends AbstractComponentContainer implements
*/
public void setResizeLazy(boolean resizeLazy) {
this.resizeLazy = resizeLazy;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1126,7 +1124,7 @@ public abstract class Root extends AbstractComponentContainer implements
* Notification.show does not allow HTML.
*/
@Deprecated
- public void showNotification(String caption, int type) {
+ public void showNotification(String caption, Notification.Type type) {
Notification notification = new Notification(caption, type);
notification.setHtmlContentAllowed(true);// Backwards compatibility
getPage().showNotification(notification);
@@ -1181,7 +1179,8 @@ public abstract class Root extends AbstractComponentContainer implements
* be aware that HTML by default not allowed.
*/
@Deprecated
- public void showNotification(String caption, String description, int type) {
+ public void showNotification(String caption, String description,
+ Notification.Type type) {
Notification notification = new Notification(caption, description, type);
notification.setHtmlContentAllowed(true);// Backwards compatibility
getPage().showNotification(notification);
@@ -1212,8 +1211,8 @@ public abstract class Root extends AbstractComponentContainer implements
* @deprecated As of 7.0, use new Notification(...).show(Page).
*/
@Deprecated
- public void showNotification(String caption, String description, int type,
- boolean htmlContentAllowed) {
+ public void showNotification(String caption, String description,
+ Notification.Type type, boolean htmlContentAllowed) {
getPage()
.showNotification(
new Notification(caption, description, type,
diff --git a/server/src/com/vaadin/ui/Select.java b/server/src/com/vaadin/ui/Select.java
index 698350cb30..20345b55e0 100644
--- a/server/src/com/vaadin/ui/Select.java
+++ b/server/src/com/vaadin/ui/Select.java
@@ -676,15 +676,21 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering,
}
@Override
+ @Deprecated
public void requestRepaint() {
- super.requestRepaint();
+ markAsDirty();
+ }
+
+ @Override
+ public void markAsDirty() {
+ super.markAsDirty();
optionRequest = false;
prevfilterstring = filterstring;
filterstring = null;
}
private void optionRepaint() {
- super.requestRepaint();
+ super.markAsDirty();
}
@Override
@@ -697,40 +703,6 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering,
return filteringMode;
}
- /**
- * Note, one should use more generic setWidth(String) method instead of
- * this. This now days actually converts columns to width with em css unit.
- *
- * Sets the number of columns in the editor. If the number of columns is set
- * 0, the actual number of displayed columns is determined implicitly by the
- * adapter.
- *
- * @deprecated
- *
- * @param columns
- * the number of columns to set.
- */
- @Deprecated
- public void setColumns(int columns) {
- if (columns < 0) {
- columns = 0;
- }
- if (this.columns != columns) {
- this.columns = columns;
- setWidth(columns, Select.UNITS_EM);
- requestRepaint();
- }
- }
-
- /**
- * @deprecated see setter function
- * @return
- */
- @Deprecated
- public int getColumns() {
- return columns;
- }
-
@Override
public void addListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java
index f7672f617c..d4e2db4853 100644
--- a/server/src/com/vaadin/ui/Slider.java
+++ b/server/src/com/vaadin/ui/Slider.java
@@ -174,7 +174,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component {
if (getValue() > max) {
setValue(max);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -198,7 +198,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component {
if (getValue() < min) {
setValue(min);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -220,7 +220,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component {
*/
public void setOrientation(int orientation) {
this.orientation = orientation;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -244,7 +244,7 @@ public class Slider extends AbstractField<Double> implements Vaadin6Component {
return;
}
this.resolution = resolution;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java
index 5a1aa02845..82faedcc41 100644
--- a/server/src/com/vaadin/ui/TabSheet.java
+++ b/server/src/com/vaadin/ui/TabSheet.java
@@ -176,7 +176,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
fireSelectedTabChange();
}
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -301,7 +301,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
fireSelectedTabChange();
}
super.addComponent(c);
- requestRepaint();
+ markAsDirty();
return tab;
}
}
@@ -361,8 +361,9 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
String caption = null;
Resource icon = null;
if (TabSheet.class.isAssignableFrom(source.getClass())) {
- caption = ((TabSheet) source).getTabCaption(c);
- icon = ((TabSheet) source).getTabIcon(c);
+ Tab tab = ((TabSheet) source).getTab(c);
+ caption = tab.getCaption();
+ icon = tab.getIcon();
}
source.removeComponent(c);
addTab(c, caption, icon);
@@ -474,83 +475,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
*/
public void hideTabs(boolean tabsHidden) {
this.tabsHidden = tabsHidden;
- requestRepaint();
- }
-
- /**
- * Gets tab caption. The tab is identified by the tab content component.
- *
- * @param c
- * the component in the tab
- * @deprecated Use {@link #getTab(Component)} and {@link Tab#getCaption()}
- * instead.
- */
- @Deprecated
- public String getTabCaption(Component c) {
- Tab info = tabs.get(c);
- if (info == null) {
- return "";
- } else {
- return info.getCaption();
- }
- }
-
- /**
- * Sets tab caption. The tab is identified by the tab content component.
- *
- * @param c
- * the component in the tab
- * @param caption
- * the caption to set.
- * @deprecated Use {@link #getTab(Component)} and
- * {@link Tab#setCaption(String)} instead.
- */
- @Deprecated
- public void setTabCaption(Component c, String caption) {
- Tab info = tabs.get(c);
- if (info != null) {
- info.setCaption(caption);
- requestRepaint();
- }
- }
-
- /**
- * Gets the icon for a tab. The tab is identified by the tab content
- * component.
- *
- * @param c
- * the component in the tab
- * @deprecated Use {@link #getTab(Component)} and {@link Tab#getIcon()}
- * instead.
- */
- @Deprecated
- public Resource getTabIcon(Component c) {
- Tab info = tabs.get(c);
- if (info == null) {
- return null;
- } else {
- return info.getIcon();
- }
- }
-
- /**
- * Sets icon for the given component. The tab is identified by the tab
- * content component.
- *
- * @param c
- * the component in the tab
- * @param icon
- * the icon to set
- * @deprecated Use {@link #getTab(Component)} and
- * {@link Tab#setIcon(Resource)} instead.
- */
- @Deprecated
- public void setTabIcon(Component c, Resource icon) {
- Tab info = tabs.get(c);
- if (info != null) {
- info.setIcon(icon);
- requestRepaint();
- }
+ markAsDirty();
}
/**
@@ -594,7 +519,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
setSelected(c);
updateSelection();
fireSelectedTabChange();
- requestRepaint();
+ markAsDirty();
}
}
@@ -612,13 +537,13 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
// "cached" update even though the client knows nothing about the
// connector
if (selected instanceof ComponentContainer) {
- ((ComponentContainer) selected).requestRepaintAll();
+ ((ComponentContainer) selected).markAsDirtyRecursive();
} else if (selected instanceof Table) {
// Workaround until there's a generic way of telling a component
// that there is no client side state to rely on. See #8642
((Table) selected).refreshRowCache();
} else if (selected != null) {
- selected.requestRepaint();
+ selected.markAsDirty();
}
}
@@ -791,7 +716,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
copyTabMetadata(oldTab, newTab);
copyTabMetadata(tmp, oldTab);
- requestRepaint();
+ markAsDirty();
}
}
@@ -1103,7 +1028,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setCaption(String caption) {
this.caption = caption;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1114,7 +1039,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setIcon(Resource icon) {
this.icon = icon;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1128,7 +1053,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
if (updateSelection()) {
fireSelectedTabChange();
}
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1142,7 +1067,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
if (updateSelection()) {
fireSelectedTabChange();
}
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1153,7 +1078,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setClosable(boolean closable) {
this.closable = closable;
- requestRepaint();
+ markAsDirty();
}
public void close() {
@@ -1168,7 +1093,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setDescription(String description) {
this.description = description;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1179,7 +1104,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setComponentError(ErrorMessage componentError) {
this.componentError = componentError;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1195,7 +1120,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setStyleName(String styleName) {
this.styleName = styleName;
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -1255,7 +1180,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
int oldPosition = getTabPosition(tab);
components.remove(oldPosition);
components.add(position, tab.getComponent());
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1282,7 +1207,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
@Override
public void setTabIndex(int tabIndex) {
this.tabIndex = tabIndex;
- requestRepaint();
+ markAsDirty();
}
@Override
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 6f7f88f883..8fc3fc2572 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -729,7 +729,7 @@ public class Table extends AbstractSelect implements Action.Container,
this.columnHeaders.put(it.next(), columnHeaders[i]);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -788,7 +788,7 @@ public class Table extends AbstractSelect implements Action.Container,
this.columnIcons.put(it.next(), columnIcons[i]);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -888,7 +888,7 @@ public class Table extends AbstractSelect implements Action.Container,
} else {
columnWidths.put(propertyId, Integer.valueOf(width));
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1026,7 +1026,7 @@ public class Table extends AbstractSelect implements Action.Container,
}
if (this.cacheRate != cacheRate) {
this.cacheRate = cacheRate;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1158,7 +1158,7 @@ public class Table extends AbstractSelect implements Action.Container,
columnIcons.put(propertyId, icon);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1198,7 +1198,7 @@ public class Table extends AbstractSelect implements Action.Container,
columnHeaders.put(propertyId, header);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1361,7 +1361,7 @@ public class Table extends AbstractSelect implements Action.Container,
public void setColumnReorderingAllowed(boolean columnReorderingAllowed) {
if (columnReorderingAllowed != this.columnReorderingAllowed) {
this.columnReorderingAllowed = columnReorderingAllowed;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1507,31 +1507,6 @@ public class Table extends AbstractSelect implements Action.Container,
}
/**
- * Getter for property pageBuffering.
- *
- * @deprecated functionality is not needed in ajax rendering model
- *
- * @return the Value of property pageBuffering.
- */
- @Deprecated
- public boolean isPageBufferingEnabled() {
- return true;
- }
-
- /**
- * Setter for property pageBuffering.
- *
- * @deprecated functionality is not needed in ajax rendering model
- *
- * @param pageBuffering
- * the New value of property pageBuffering.
- */
- @Deprecated
- public void setPageBufferingEnabled(boolean pageBuffering) {
-
- }
-
- /**
* Getter for property selectable.
*
* <p>
@@ -1557,7 +1532,7 @@ public class Table extends AbstractSelect implements Action.Container,
public void setSelectable(boolean selectable) {
if (this.selectable != selectable) {
this.selectable = selectable;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1583,7 +1558,7 @@ public class Table extends AbstractSelect implements Action.Container,
}
if (columnHeaderMode != this.columnHeaderMode) {
this.columnHeaderMode = columnHeaderMode;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1652,7 +1627,7 @@ public class Table extends AbstractSelect implements Action.Container,
}
setRowCacheInvalidated(true);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1661,17 +1636,39 @@ public class Table extends AbstractSelect implements Action.Container,
* Note that a {@code Table} does not necessarily repaint its contents when
* this method has been called. See {@link #refreshRowCache()} for forcing
* an update of the contents.
+ *
+ * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead
*/
+ @Deprecated
@Override
public void requestRepaint() {
+ markAsDirty();
+ }
+
+ /**
+ * Requests that the Table should be repainted as soon as possible.
+ *
+ * Note that a {@code Table} does not necessarily repaint its contents when
+ * this method has been called. See {@link #refreshRowCache()} for forcing
+ * an update of the contents.
+ */
+
+ @Override
+ public void markAsDirty() {
// Overridden only for javadoc
- super.requestRepaint();
+ super.markAsDirty();
}
+ @Deprecated
@Override
public void requestRepaintAll() {
- super.requestRepaintAll();
+ markAsDirtyRecursive();
+ }
+
+ @Override
+ public void markAsDirtyRecursive() {
+ super.markAsDirtyRecursive();
// Avoid sending a partial repaint (#8714)
refreshRowCache();
@@ -2230,16 +2227,6 @@ public class Table extends AbstractSelect implements Action.Container,
}
/**
- * Refreshes the current page contents.
- *
- * @deprecated should not need to be used
- */
- @Deprecated
- public void refreshCurrentPage() {
-
- }
-
- /**
* Sets the row header mode.
* <p>
* The mode can be one of the following ones:
@@ -2471,7 +2458,7 @@ public class Table extends AbstractSelect implements Action.Container,
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
- requestRepaint();
+ markAsDirty();
} else if (id != null && containsId(id)) {
newValue.add(id);
renderedButNotSelectedItemIds.remove(id);
@@ -2498,7 +2485,7 @@ public class Table extends AbstractSelect implements Action.Container,
if (!isNullSelectionAllowed() && newValue.isEmpty()) {
// empty selection not allowed, keep old value
- requestRepaint();
+ markAsDirty();
return;
}
@@ -2837,7 +2824,7 @@ public class Table extends AbstractSelect implements Action.Container,
if (refreshContent) {
refreshRenderedCells();
// Ensure that client gets a response
- requestRepaint();
+ markAsDirty();
}
}
@@ -3786,7 +3773,7 @@ public class Table extends AbstractSelect implements Action.Container,
refreshRowCache();
containerChangeToBeRendered = true;
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -4470,7 +4457,7 @@ public class Table extends AbstractSelect implements Action.Container,
* would support this.
*
* @return True iff sorting is disabled.
- * @deprecated Use {@link #isSortEnabled()} instead
+ * @deprecated As of 7.0, use {@link #isSortEnabled()} instead
*/
@Deprecated
public boolean isSortDisabled() {
@@ -4491,7 +4478,7 @@ public class Table extends AbstractSelect implements Action.Container,
*
* @param sortDisabled
* True iff sorting is disabled.
- * @deprecated Use {@link #setSortEnabled(boolean)} instead
+ * @deprecated As of 7.0, use {@link #setSortEnabled(boolean)} instead
*/
@Deprecated
public void setSortDisabled(boolean sortDisabled) {
@@ -4511,7 +4498,7 @@ public class Table extends AbstractSelect implements Action.Container,
public void setSortEnabled(boolean sortEnabled) {
if (this.sortEnabled != sortEnabled) {
this.sortEnabled = sortEnabled;
- requestRepaint();
+ markAsDirty();
}
}
@@ -4608,7 +4595,7 @@ public class Table extends AbstractSelect implements Action.Container,
// some ancestor still disabled, don't update children
return;
} else {
- requestRepaintAll();
+ markAsDirtyRecursive();
}
}
@@ -4620,7 +4607,7 @@ public class Table extends AbstractSelect implements Action.Container,
*/
public void setDragMode(TableDragMode newDragMode) {
dragMode = newDragMode;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -4704,7 +4691,7 @@ public class Table extends AbstractSelect implements Action.Container,
*/
public void setMultiSelectMode(MultiSelectMode mode) {
multiSelectMode = mode;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -5012,7 +4999,7 @@ public class Table extends AbstractSelect implements Action.Container,
columnFooters.put(propertyId, footer);
}
- requestRepaint();
+ markAsDirty();
}
/**
@@ -5028,7 +5015,7 @@ public class Table extends AbstractSelect implements Action.Container,
public void setFooterVisible(boolean visible) {
if (visible != columnFootersVisible) {
columnFootersVisible = visible;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java
index fed06b561a..0dc9722eb3 100644
--- a/server/src/com/vaadin/ui/TextArea.java
+++ b/server/src/com/vaadin/ui/TextArea.java
@@ -81,7 +81,7 @@ public class TextArea extends AbstractTextField {
}
@Override
- public TextAreaState getState() {
+ protected TextAreaState getState() {
return (TextAreaState) super.getState();
}
@@ -96,7 +96,6 @@ public class TextArea extends AbstractTextField {
rows = 0;
}
getState().setRows(rows);
- requestRepaint();
}
/**
@@ -117,7 +116,6 @@ public class TextArea extends AbstractTextField {
*/
public void setWordwrap(boolean wordwrap) {
getState().setWordwrap(wordwrap);
- requestRepaint();
}
/**
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java
index dda0a78aff..2d6673a67d 100644
--- a/server/src/com/vaadin/ui/Tree.java
+++ b/server/src/com/vaadin/ui/Tree.java
@@ -184,7 +184,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
*/
public boolean expandItem(Object itemId) {
boolean success = expandItem(itemId, true);
- requestRepaint();
+ markAsDirty();
return success;
}
@@ -215,7 +215,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
expandedItemId = itemId;
if (initialPaint) {
- requestRepaint();
+ markAsDirty();
} else if (sendChildTree) {
requestPartialRepaint();
}
@@ -225,13 +225,13 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
}
@Override
- public void requestRepaint() {
- super.requestRepaint();
+ public void markAsDirty() {
+ super.markAsDirty();
partialUpdate = false;
}
private void requestPartialRepaint() {
- super.requestRepaint();
+ super.markAsDirty();
partialUpdate = true;
}
@@ -262,7 +262,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
todo.addAll(getChildren(id));
}
}
- requestRepaint();
+ markAsDirty();
return result;
}
@@ -282,7 +282,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
// Collapse
expanded.remove(itemId);
- requestRepaint();
+ markAsDirty();
fireCollapseEvent(itemId);
return true;
@@ -349,7 +349,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
public void setSelectable(boolean selectable) {
if (this.selectable != selectable) {
this.selectable = selectable;
- requestRepaint();
+ markAsDirty();
}
}
@@ -362,7 +362,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
public void setMultiselectMode(MultiSelectMode mode) {
if (multiSelectMode != mode && mode != null) {
multiSelectMode = mode;
- requestRepaint();
+ markAsDirty();
}
}
@@ -478,7 +478,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
- requestRepaint();
+ markAsDirty();
} else if (id != null && containsId(id)) {
s.add(id);
}
@@ -486,7 +486,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
if (!isNullSelectionAllowed() && s.size() < 1) {
// empty selection not allowed, keep old value
- requestRepaint();
+ markAsDirty();
return;
}
@@ -796,7 +796,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
final boolean success = ((Container.Hierarchical) items)
.setChildrenAllowed(itemId, areChildrenAllowed);
if (success) {
- requestRepaint();
+ markAsDirty();
}
return success;
}
@@ -812,7 +812,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
final boolean success = ((Container.Hierarchical) items).setParent(
itemId, newParentId);
if (success) {
- requestRepaint();
+ markAsDirty();
}
return success;
}
@@ -1036,7 +1036,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
if (!actionHandlers.contains(actionHandler)) {
actionHandlers.add(actionHandler);
- requestRepaint();
+ markAsDirty();
}
}
}
@@ -1058,7 +1058,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
actionMapper = null;
}
- requestRepaint();
+ markAsDirty();
}
}
@@ -1068,7 +1068,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
public void removeAllActionHandlers() {
actionHandlers = null;
actionMapper = null;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1182,7 +1182,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
public void setItemStyleGenerator(ItemStyleGenerator itemStyleGenerator) {
if (this.itemStyleGenerator != itemStyleGenerator) {
this.itemStyleGenerator = itemStyleGenerator;
- requestRepaint();
+ markAsDirty();
}
}
@@ -1342,7 +1342,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
*/
public void setDragMode(TreeDragMode dragMode) {
this.dragMode = dragMode;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -1601,7 +1601,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
public void setItemDescriptionGenerator(ItemDescriptionGenerator generator) {
if (generator != itemDescriptionGenerator) {
itemDescriptionGenerator = generator;
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/TreeTable.java b/server/src/com/vaadin/ui/TreeTable.java
index 7548a4840b..05757a6d09 100644
--- a/server/src/com/vaadin/ui/TreeTable.java
+++ b/server/src/com/vaadin/ui/TreeTable.java
@@ -463,7 +463,7 @@ public class TreeTable extends Table implements Hierarchical {
// been processed
clearFocusedRowPending = true;
}
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -561,7 +561,7 @@ public class TreeTable extends Table implements Hierarchical {
}
if (containerSupportsPartialUpdates && !forceFullRefresh) {
- requestRepaint();
+ markAsDirty();
} else {
// For containers that do not send item set change events, always do
// full repaint instead of partial row update.
@@ -826,7 +826,7 @@ public class TreeTable extends Table implements Hierarchical {
*/
public void setAnimationsEnabled(boolean animationsEnabled) {
this.animationsEnabled = animationsEnabled;
- requestRepaint();
+ markAsDirty();
}
private static final Logger getLogger() {
diff --git a/server/src/com/vaadin/ui/TwinColSelect.java b/server/src/com/vaadin/ui/TwinColSelect.java
index 80f4ae49c8..891e695a5f 100644
--- a/server/src/com/vaadin/ui/TwinColSelect.java
+++ b/server/src/com/vaadin/ui/TwinColSelect.java
@@ -79,7 +79,7 @@ public class TwinColSelect extends AbstractSelect {
}
if (this.columns != columns) {
this.columns = columns;
- requestRepaint();
+ markAsDirty();
}
}
@@ -111,7 +111,7 @@ public class TwinColSelect extends AbstractSelect {
}
if (this.rows != rows) {
this.rows = rows;
- requestRepaint();
+ markAsDirty();
}
}
@@ -159,7 +159,7 @@ public class TwinColSelect extends AbstractSelect {
*/
public void setRightColumnCaption(String rightColumnCaption) {
this.rightColumnCaption = rightColumnCaption;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -179,7 +179,7 @@ public class TwinColSelect extends AbstractSelect {
*/
public void setLeftColumnCaption(String leftColumnCaption) {
this.leftColumnCaption = leftColumnCaption;
- requestRepaint();
+ markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java
index c4f15ebea9..619db07eea 100644
--- a/server/src/com/vaadin/ui/Upload.java
+++ b/server/src/com/vaadin/ui/Upload.java
@@ -138,7 +138,7 @@ public class Upload extends AbstractComponent implements Component.Focusable,
int id = (Integer) variables.get("pollForStart");
if (!isUploading && id == nextid) {
notStarted = true;
- requestRepaint();
+ markAsDirty();
} else {
}
}
@@ -829,7 +829,7 @@ public class Upload extends AbstractComponent implements Component.Focusable,
isUploading = false;
contentLength = -1;
interrupted = false;
- requestRepaint();
+ markAsDirty();
}
public boolean isUploading() {
@@ -856,33 +856,6 @@ public class Upload extends AbstractComponent implements Component.Focusable,
}
/**
- * This method is deprecated, use addListener(ProgressListener) instead.
- *
- * @deprecated Use addListener(ProgressListener) instead.
- * @param progressListener
- */
- @Deprecated
- public void setProgressListener(ProgressListener progressListener) {
- addListener(progressListener);
- }
-
- /**
- * This method is deprecated.
- *
- * @deprecated Replaced with addListener/removeListener
- * @return listener
- *
- */
- @Deprecated
- public ProgressListener getProgressListener() {
- if (progressListeners == null || progressListeners.isEmpty()) {
- return null;
- } else {
- return progressListeners.iterator().next();
- }
- }
-
- /**
* ProgressListener receives events to track progress of upload.
*/
public interface ProgressListener extends Serializable {
@@ -928,7 +901,7 @@ public class Upload extends AbstractComponent implements Component.Focusable,
*/
public void setButtonCaption(String buttonCaption) {
this.buttonCaption = buttonCaption;
- requestRepaint();
+ markAsDirty();
}
/**
@@ -949,14 +922,14 @@ public class Upload extends AbstractComponent implements Component.Focusable,
* fired.
*/
public void submitUpload() {
- requestRepaint();
+ markAsDirty();
forceSubmit = true;
}
@Override
- public void requestRepaint() {
+ public void markAsDirty() {
forceSubmit = false;
- super.requestRepaint();
+ super.markAsDirty();
}
/*
@@ -1009,7 +982,7 @@ public class Upload extends AbstractComponent implements Component.Focusable,
fireUploadSuccess(event.getFileName(), event.getMimeType(),
event.getContentLength());
endUpload();
- requestRepaint();
+ markAsDirty();
}
@Override
diff --git a/server/src/com/vaadin/ui/Video.java b/server/src/com/vaadin/ui/Video.java
index 95a38c59d5..b54d404da6 100644
--- a/server/src/com/vaadin/ui/Video.java
+++ b/server/src/com/vaadin/ui/Video.java
@@ -44,7 +44,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference;
public class Video extends AbstractMedia {
@Override
- public VideoState getState() {
+ protected VideoState getState() {
return (VideoState) super.getState();
}
@@ -80,7 +80,6 @@ public class Video extends AbstractMedia {
*/
public void setPoster(Resource poster) {
getState().setPoster(ResourceReference.create(poster));
- requestRepaint();
}
/**
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index d1d2c25d8b..d79588cc63 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -174,14 +174,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
final int x = positionx.intValue();
// This is information from the client so it is already using the
// position. No need to repaint.
- setPositionX(x < 0 ? -1 : x, false);
+ setPositionX(x < 0 ? -1 : x);
}
final Integer positiony = (Integer) variables.get("positiony");
if (positiony != null) {
final int y = positiony.intValue();
// This is information from the client so it is already using the
// position. No need to repaint.
- setPositionY(y < 0 ? -1 : y, false);
+ setPositionY(y < 0 ? -1 : y);
}
if (isClosable()) {
@@ -255,26 +255,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public void setPositionX(int positionX) {
- setPositionX(positionX, true);
- }
-
- /**
- * Sets the distance of Window left border in pixels from left border of the
- * containing (main window).
- *
- * @param positionX
- * the Distance of Window left border in pixels from left border
- * of the containing (main window). or -1 if unspecified.
- * @param repaintRequired
- * true if the window needs to be repainted, false otherwise
- * @since 6.3.4
- */
- private void setPositionX(int positionX, boolean repaintRequired) {
getState().setPositionX(positionX);
getState().setCentered(false);
- if (repaintRequired) {
- requestRepaint();
- }
}
/**
@@ -301,27 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public void setPositionY(int positionY) {
- setPositionY(positionY, true);
- }
-
- /**
- * Sets the distance of Window top border in pixels from top border of the
- * containing (main window).
- *
- * @param positionY
- * the Distance of Window top border in pixels from top border of
- * the containing (main window). or -1 if unspecified
- * @param repaintRequired
- * true if the window needs to be repainted, false otherwise
- *
- * @since 6.3.4
- */
- private void setPositionY(int positionY, boolean repaintRequired) {
getState().setPositionY(positionY);
getState().setCentered(false);
- if (repaintRequired) {
- requestRepaint();
- }
}
private static final Method WINDOW_CLOSE_METHOD;
@@ -530,7 +493,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
}
}
bringToFront = Integer.valueOf(maxBringToFront + 1);
- requestRepaint();
+ markAsDirty();
}
/**
@@ -543,7 +506,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
public void setModal(boolean modal) {
getState().setModal(modal);
center();
- requestRepaint();
}
/**
@@ -561,7 +523,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
*/
public void setResizable(boolean resizable) {
getState().setResizable(resizable);
- requestRepaint();
}
/**
@@ -595,7 +556,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
*/
public void setResizeLazy(boolean resizeLazy) {
getState().setResizeLazy(resizeLazy);
- requestRepaint();
}
/**
@@ -609,7 +569,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
*/
public void center() {
getState().setCentered(true);
- requestRepaint();
}
/**
@@ -674,7 +633,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
*/
public void setDraggable(boolean draggable) {
getState().setDraggable(draggable);
- requestRepaint();
}
/*
@@ -838,7 +796,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
}
@Override
- public WindowState getState() {
+ protected WindowState getState() {
return (WindowState) super.getState();
}
}
diff --git a/server/src/com/vaadin/ui/themes/BaseTheme.java b/server/src/com/vaadin/ui/themes/BaseTheme.java
index bdb0087d2e..9e95627eec 100644
--- a/server/src/com/vaadin/ui/themes/BaseTheme.java
+++ b/server/src/com/vaadin/ui/themes/BaseTheme.java
@@ -45,18 +45,6 @@ public class BaseTheme {
public static final String BUTTON_LINK = "link";
/**
- * Removes extra decorations from the panel.
- *
- * @deprecated Base theme does not implement this style, but it is defined
- * here since it has been a part of the framework before
- * multiple themes were available. Use the constant provided by
- * the theme you're using instead, e.g.
- * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT}.
- */
- @Deprecated
- public static final String PANEL_LIGHT = "light";
-
- /**
* Adds the connector lines between a parent node and its child nodes to
* indicate the tree hierarchy better.
*/
diff --git a/server/src/com/vaadin/ui/themes/Reindeer.java b/server/src/com/vaadin/ui/themes/Reindeer.java
index 7bc6720465..037f59d7b4 100644
--- a/server/src/com/vaadin/ui/themes/Reindeer.java
+++ b/server/src/com/vaadin/ui/themes/Reindeer.java
@@ -48,12 +48,6 @@ public class Reindeer extends BaseTheme {
*/
public static final String LABEL_SMALL = "light";
- /**
- * @deprecated Use {@link #LABEL_SMALL} instead.
- */
- @Deprecated
- public static final String LABEL_LIGHT = "small";
-
/***************************************************************************
*
* Button styles
@@ -68,12 +62,6 @@ public class Reindeer extends BaseTheme {
public static final String BUTTON_DEFAULT = "primary";
/**
- * @deprecated Use {@link #BUTTON_DEFAULT} instead
- */
- @Deprecated
- public static final String BUTTON_PRIMARY = BUTTON_DEFAULT;
-
- /**
* Small sized button, use for context specific actions for example
*/
public static final String BUTTON_SMALL = "small";
@@ -129,12 +117,6 @@ public class Reindeer extends BaseTheme {
public static final String TABSHEET_SMALL = "bar";
/**
- * @deprecated Use {@link #TABSHEET_SMALL} instead.
- */
- @Deprecated
- public static final String TABSHEET_BAR = TABSHEET_SMALL;
-
- /**
* Removes borders and background color from the tab sheet. The tabs are
* presented with minimal lines indicating the selected tab.
*/
diff --git a/shared/src/com/vaadin/shared/Connector.java b/shared/src/com/vaadin/shared/Connector.java
index 5a00f6cca2..5927d08d79 100644
--- a/shared/src/com/vaadin/shared/Connector.java
+++ b/shared/src/com/vaadin/shared/Connector.java
@@ -17,8 +17,6 @@ package com.vaadin.shared;
import java.io.Serializable;
-import com.vaadin.shared.communication.SharedState;
-
/**
* Interface implemented by all classes that are capable of communicating with
* the server or the client side.
@@ -41,15 +39,6 @@ import com.vaadin.shared.communication.SharedState;
*/
public interface Connector extends Serializable {
/**
- * Gets the current shared state of the connector.
- *
- * @since 7.0.
- * @return state The shared state object. Can be any sub type of
- * {@link SharedState}. Never null.
- */
- public SharedState getState();
-
- /**
* Returns the id for this connector. This is set by the framework and does
* not change during the lifetime of a connector.
*
diff --git a/shared/src/com/vaadin/shared/Position.java b/shared/src/com/vaadin/shared/Position.java
new file mode 100755
index 0000000000..89d6a4261c
--- /dev/null
+++ b/shared/src/com/vaadin/shared/Position.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared;
+
+public enum Position {
+ TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT;
+}
diff --git a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java
index 675d11d0b7..4fc865626c 100644
--- a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java
+++ b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java
@@ -18,14 +18,5 @@ package com.vaadin.shared.ui;
import com.vaadin.shared.ComponentState;
public class AbstractLayoutState extends ComponentState {
- private int marginsBitmask;
-
- public int getMarginsBitmask() {
- return marginsBitmask;
- }
-
- public void setMarginsBitmask(int marginsBitmask) {
- this.marginsBitmask = marginsBitmask;
- }
} \ No newline at end of file
diff --git a/shared/src/com/vaadin/shared/ui/BorderStyle.java b/shared/src/com/vaadin/shared/ui/BorderStyle.java
new file mode 100755
index 0000000000..786d340f1c
--- /dev/null
+++ b/shared/src/com/vaadin/shared/ui/BorderStyle.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.ui;
+
+public enum BorderStyle {
+ NONE, MINIMAL, DEFAULT;
+}
diff --git a/shared/src/com/vaadin/shared/ui/VMarginInfo.java b/shared/src/com/vaadin/shared/ui/MarginInfo.java
index 9e9e0a4bb4..21e52f258a 100644
--- a/shared/src/com/vaadin/shared/ui/VMarginInfo.java
+++ b/shared/src/com/vaadin/shared/ui/MarginInfo.java
@@ -18,8 +18,7 @@ package com.vaadin.shared.ui;
import java.io.Serializable;
-@SuppressWarnings("serial")
-public class VMarginInfo implements Serializable {
+public class MarginInfo implements Serializable {
private static final int TOP = 1;
private static final int RIGHT = 2;
@@ -28,11 +27,15 @@ public class VMarginInfo implements Serializable {
private int bitMask;
- public VMarginInfo(int bitMask) {
+ public MarginInfo(boolean enabled) {
+ this(enabled, enabled, enabled, enabled);
+ }
+
+ public MarginInfo(int bitMask) {
this.bitMask = bitMask;
}
- public VMarginInfo(boolean top, boolean right, boolean bottom, boolean left) {
+ public MarginInfo(boolean top, boolean right, boolean bottom, boolean left) {
setMargins(top, right, bottom, left);
}
@@ -44,7 +47,7 @@ public class VMarginInfo implements Serializable {
bitMask += left ? LEFT : 0;
}
- public void setMargins(VMarginInfo marginInfo) {
+ public void setMargins(MarginInfo marginInfo) {
bitMask = marginInfo.bitMask;
}
@@ -78,11 +81,11 @@ public class VMarginInfo implements Serializable {
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof VMarginInfo)) {
+ if (!(obj instanceof MarginInfo)) {
return false;
}
- return ((VMarginInfo) obj).bitMask == bitMask;
+ return ((MarginInfo) obj).bitMask == bitMask;
}
@Override
diff --git a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java
index d2e685d8cb..381a6a7f85 100644
--- a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java
+++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java
@@ -21,6 +21,7 @@ public class GridLayoutState extends AbstractLayoutState {
private boolean spacing = false;
private int rows = 0;
private int columns = 0;
+ private int marginsBitmask = 0;
public boolean isSpacing() {
return spacing;
@@ -30,6 +31,14 @@ public class GridLayoutState extends AbstractLayoutState {
this.spacing = spacing;
}
+ public int getMarginsBitmask() {
+ return marginsBitmask;
+ }
+
+ public void setMarginsBitmask(int marginsBitmask) {
+ this.marginsBitmask = marginsBitmask;
+ }
+
public int getRows() {
return rows;
}
diff --git a/shared/src/com/vaadin/shared/ui/label/LabelState.java b/shared/src/com/vaadin/shared/ui/label/LabelState.java
index 35e27bc63d..a91aeb0aa1 100644
--- a/shared/src/com/vaadin/shared/ui/label/LabelState.java
+++ b/shared/src/com/vaadin/shared/ui/label/LabelState.java
@@ -18,23 +18,6 @@ package com.vaadin.shared.ui.label;
import com.vaadin.shared.ComponentState;
public class LabelState extends ComponentState {
- private ContentMode contentMode = ContentMode.TEXT;
- private String text = "";
-
- public ContentMode getContentMode() {
- return contentMode;
- }
-
- public void setContentMode(ContentMode contentMode) {
- this.contentMode = contentMode;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
+ public ContentMode contentMode = ContentMode.TEXT;
+ public String text = "";
}
diff --git a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java
index 235c9eab13..35456ab9ac 100644
--- a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java
+++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java
@@ -25,7 +25,9 @@ import com.vaadin.shared.ui.AlignmentInfo;
public class AbstractOrderedLayoutState extends AbstractLayoutState {
private boolean spacing = false;
- public HashMap<Connector, ChildComponentData> childData = new HashMap<Connector, ChildComponentData>();
+ private HashMap<Connector, ChildComponentData> childData = new HashMap<Connector, ChildComponentData>();
+
+ private int marginsBitmask = 0;
public static class ChildComponentData implements Serializable {
private int alignmentBitmask = AlignmentInfo.TOP_LEFT.getBitMask();
@@ -65,4 +67,12 @@ public class AbstractOrderedLayoutState extends AbstractLayoutState {
this.spacing = spacing;
}
+ public int getMarginsBitmask() {
+ return marginsBitmask;
+ }
+
+ public void setMarginsBitmask(int marginsBitmask) {
+ this.marginsBitmask = marginsBitmask;
+ }
+
} \ No newline at end of file
diff --git a/shared/src/com/vaadin/shared/ui/root/RootState.java b/shared/src/com/vaadin/shared/ui/root/RootState.java
index 07c71c8167..b7c2c88ce5 100644
--- a/shared/src/com/vaadin/shared/ui/root/RootState.java
+++ b/shared/src/com/vaadin/shared/ui/root/RootState.java
@@ -20,7 +20,6 @@ import com.vaadin.shared.Connector;
public class RootState extends ComponentState {
private Connector content;
- private int heartbeatInterval;
public Connector getContent() {
return content;
@@ -30,11 +29,4 @@ public class RootState extends ComponentState {
this.content = content;
}
- public int getHeartbeatInterval() {
- return heartbeatInterval;
- }
-
- public void setHeartbeatInterval(int heartbeatInterval) {
- this.heartbeatInterval = heartbeatInterval;
- }
} \ No newline at end of file
diff --git a/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java b/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java
index 16cc0ede98..7775b667a1 100644
--- a/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java
+++ b/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java
@@ -1,7 +1,7 @@
package com.vaadin.terminal.gwt.server;
/*
- * Copyright 2011 Vaadin Ltd.
+ * Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -15,9 +15,6 @@ package com.vaadin.terminal.gwt.server;
* License for the specific language governing permissions and limitations under
* the License.
*/
-import java.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashMap;
@@ -28,6 +25,7 @@ import junit.framework.TestCase;
import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState;
import com.vaadin.terminal.gwt.client.communication.JsonDecoder;
import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
+import com.vaadin.terminal.gwt.server.JsonCodec.BeanProperty;
/**
* Tests for {@link JsonCodec}, {@link JsonEncoder}, {@link JsonDecoder}
@@ -118,15 +116,9 @@ public class JSONSerializerTest extends TestCase {
}
private boolean equalsBean(Object o1, Object o2) throws Exception {
- BeanInfo beanInfo = Introspector.getBeanInfo(o1.getClass());
- for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
- String fieldName = JsonCodec.getTransportFieldName(pd);
- if (fieldName == null) {
- continue;
- }
-
- Object c1 = pd.getReadMethod().invoke(o1);
- Object c2 = pd.getReadMethod().invoke(o2);
+ for (BeanProperty property : JsonCodec.getProperties(o1.getClass())) {
+ Object c1 = property.getValue(o1);
+ Object c2 = property.getValue(o2);
if (!equals(c1, c2)) {
return false;
}
diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
index fa730515a2..74770f8652 100644
--- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
+++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java
@@ -6,15 +6,16 @@ import java.util.Properties;
import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
import com.vaadin.Application;
import com.vaadin.Application.ApplicationStartEvent;
import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.DefaultRootProvider;
import com.vaadin.terminal.DeploymentConfiguration;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.ui.Root;
-import org.easymock.EasyMock;
-
public class CustomRootClassLoader extends TestCase {
/**
@@ -111,10 +112,17 @@ public class CustomRootClassLoader extends TestCase {
private Application createStubApplication() {
return new Application() {
+ {
+ addRootProvider(new DefaultRootProvider());
+ }
+
@Override
- protected String getRootClassName(WrappedRequest request) {
- // Always use the same root class
- return MyRoot.class.getName();
+ public String getProperty(String name) {
+ if (name.equals(ROOT_PARAMETER)) {
+ return MyRoot.class.getName();
+ } else {
+ return super.getProperty(name);
+ }
}
@Override
diff --git a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java
index bd6dd6c7b1..4bb0177a18 100644
--- a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java
+++ b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java
@@ -30,9 +30,9 @@ public class TextFieldWithPropertyFormatter extends TestCase {
field = new TextField() {
@Override
- public void requestRepaint() {
+ public void markAsDirty() {
repainted++;
- super.requestRepaint();
+ super.markAsDirty();
}
};
diff --git a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
index 3512f555c9..f2de4f3c04 100644
--- a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
@@ -42,8 +42,7 @@ public abstract class AbstractTestFieldValueChange<T> extends TestCase {
*/
public void testRemoveListener() {
getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(true);
- getField().setReadThrough(true);
+ getField().setBuffered(false);
// Expectations and start test
listener.valueChange(EasyMock.isA(ValueChangeEvent.class));
@@ -76,10 +75,9 @@ public abstract class AbstractTestFieldValueChange<T> extends TestCase {
* Field value change notifications closely mirror value changes of the data
* source behind the field.
*/
- public void testWriteThroughReadThrough() {
+ public void testNonBuffered() {
getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(true);
- getField().setReadThrough(true);
+ getField().setBuffered(false);
expectValueChangeFromSetValueNotCommit();
}
@@ -91,47 +89,9 @@ public abstract class AbstractTestFieldValueChange<T> extends TestCase {
* Field value change notifications reflect the buffered value in the field,
* not the original data source value changes.
*/
- public void testNoWriteThroughNoReadThrough() {
+ public void testBuffered() {
getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(false);
- getField().setReadThrough(false);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- /**
- * Less common partly buffered case: writeThrough (auto-commit) is on and
- * readThrough is off. Calling commit() should not cause notifications.
- *
- * Without readThrough activated, changes to the data source that do not
- * cause notifications are not reflected by the field value.
- *
- * Field value change notifications correspond to changes made to the data
- * source value through the text field or the (notifying) property.
- */
- public void testWriteThroughNoReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(true);
- getField().setReadThrough(false);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- /**
- * Partly buffered use where the data source is read but not nor modified
- * during editing, and is updated at commit().
- *
- * When used like this, a field is updated from the data source if necessary
- * when its value is requested and the property value has changed but the
- * field has not been modified in its buffer.
- *
- * Field value change notifications reflect the buffered value in the field,
- * not the original data source value changes.
- */
- public void testNoWriteThroughReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(false);
- getField().setReadThrough(true);
+ getField().setBuffered(true);
expectValueChangeFromSetValueNotCommit();
}
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
index f5db67be97..de838e339c 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
@@ -78,59 +78,6 @@ public class TestTextFieldValueChange extends
}
/**
- * If read through is on and value has been modified, but not committed, the
- * value should not propagate similar to
- * {@link #testValueChangeEventPropagationWithReadThrough()}
- *
- * TODO make test field type agnostic (eg. combobox)
- */
- public void testValueChangePropagationWithReadThroughWithModifiedValue() {
- final String initialValue = "initial";
- ObjectProperty<String> property = new ObjectProperty<String>(
- initialValue);
- getField().setPropertyDataSource(property);
-
- // write buffering on, read buffering off
- getField().setWriteThrough(false);
- getField().setReadThrough(true);
-
- // Expect no value changes calls to listener
- EasyMock.replay(getListener());
-
- // first set the value (note, write through false -> not forwarded to
- // property)
- setValue(getField());
-
- Assert.assertTrue(getField().isModified());
-
- // Add listener and set the value -> should end up in listener once
- getField().addListener(getListener());
-
- // modify property value, should not fire value change in field as the
- // field has uncommitted value (aka isModified() == true)
- property.setValue("Foo");
-
- // Ensure listener was called once
- EasyMock.verify(getListener());
-
- // get value should not fire value change again
- Object value = getField().getValue();
- // Ensure listener still has been called only once
- EasyMock.verify(getListener());
-
- // field value should be different from the original value and current
- // proeprty value
- boolean isValueEqualToInitial = value.equals(initialValue);
- Assert.assertFalse(isValueEqualToInitial);
- boolean isValueEqualToPropertyValue = value.equals(property.getValue());
- Assert.assertFalse(isValueEqualToPropertyValue);
-
- // Ensure listener has not been called
- EasyMock.verify(getListener());
-
- }
-
- /**
* Value change events from property should not propagate if read through is
* false. Execpt when the property is being set.
*
diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
index 6b7b36c3f3..bb37082d30 100644
--- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
+++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java
@@ -30,6 +30,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
import com.vaadin.terminal.gwt.server.WrappedHttpServletRequest;
@@ -40,23 +42,6 @@ import com.vaadin.ui.Root;
public class ApplicationRunnerServlet extends AbstractApplicationServlet {
/**
- * Internal implementation of an application with a dynamically selected
- * Root implementation;
- */
- private static class RootRunnerApplication extends Application {
- private final Class<?> runnableClass;
-
- private RootRunnerApplication(Class<?> runnableClass) {
- this.runnableClass = runnableClass;
- }
-
- @Override
- protected String getRootClassName(WrappedRequest request) {
- return runnableClass.getCanonicalName();
- }
- }
-
- /**
* The name of the application class currently used. Only valid within one
* request.
*/
@@ -126,7 +111,17 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet {
try {
final Class<?> classToRun = getClassToRun();
if (Root.class.isAssignableFrom(classToRun)) {
- return new RootRunnerApplication(classToRun);
+ Application application = new Application();
+ application.addRootProvider(new AbstractRootProvider() {
+
+ @Override
+ public Class<? extends Root> getRootClass(
+ Application application, WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ return (Class<? extends Root>) classToRun;
+ }
+ });
+ return application;
} else if (Application.class.isAssignableFrom(classToRun)) {
return (Application) classToRun.newInstance();
} else {
@@ -221,7 +216,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet {
throws ClassNotFoundException {
Class<?> classToRun = getClassToRun();
if (Root.class.isAssignableFrom(classToRun)) {
- return RootRunnerApplication.class;
+ return Application.class;
} else if (Application.class.isAssignableFrom(classToRun)) {
return classToRun.asSubclass(Application.class);
} else {
diff --git a/tests/testbench/com/vaadin/tests/Parameters.java b/tests/testbench/com/vaadin/tests/Parameters.java
index 4fb224eb19..e9824d9c40 100644
--- a/tests/testbench/com/vaadin/tests/Parameters.java
+++ b/tests/testbench/com/vaadin/tests/Parameters.java
@@ -27,7 +27,7 @@ import com.vaadin.terminal.RequestHandler;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.WrappedResponse;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Root.LegacyWindow;
@@ -90,7 +90,7 @@ public class Parameters extends com.vaadin.Application.LegacyApplication
final Panel panel2 = new Panel("Parameter Handler");
params.setSizeFull();
panel2.setContent(new VerticalLayout());
- ((Layout) panel2.getContent()).setMargin(true);
+ ((MarginHandler) panel2.getContent()).setMargin(true);
params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID);
panel2.addComponent(params);
diff --git a/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java b/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java
index aa8814ce4c..8002059227 100644
--- a/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java
+++ b/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java
@@ -62,7 +62,7 @@ public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent {
new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- testContainer.requestRepaint();
+ testContainer.markAsDirty();
}
}));
diff --git a/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java b/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java
index 50cbe0778b..f33132a709 100644
--- a/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java
+++ b/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java
@@ -78,7 +78,7 @@ public class TestSizeableIncomponents extends Application.LegacyApplication {
getMainWindow().showNotification(
"Selected test:" + prev.getTestableName());
select.setValue(prev);
- select.requestRepaint();
+ select.markAsDirty();
}
}
});
@@ -94,7 +94,7 @@ public class TestSizeableIncomponents extends Application.LegacyApplication {
getMainWindow().showNotification(
"Selected test:" + next.getTestableName());
select.setValue(next);
- select.requestRepaint();
+ select.markAsDirty();
}
}
});
diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
index 36a793bd6d..bd2aea3756 100644
--- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
+++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java
@@ -1,5 +1,8 @@
package com.vaadin.tests.application;
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestApplication;
import com.vaadin.ui.Label;
@@ -20,11 +23,14 @@ public class RefreshStatePreserve extends AbstractTestApplication {
public void init() {
super.init();
setRootPreserved(true);
- }
-
- @Override
- protected String getRootClassName(WrappedRequest request) {
- return RefreshStateRoot.class.getName();
+ addRootProvider(new AbstractRootProvider() {
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ return RefreshStateRoot.class;
+ }
+ });
}
@Override
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java b/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java
index af62e5e4a4..c04be3d724 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java
@@ -2,11 +2,12 @@ package com.vaadin.tests.components;
import java.util.LinkedHashMap;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.Layout.MarginInfo;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Layout.SpacingHandler;
public abstract class AbstractLayoutTest<T extends AbstractLayout> extends
@@ -17,7 +18,7 @@ public abstract class AbstractLayoutTest<T extends AbstractLayout> extends
@Override
public void execute(T c, MarginInfo value, Object data) {
- c.setMargin(value);
+ ((MarginHandler) c).setMargin(value);
}
};
@@ -42,7 +43,9 @@ public abstract class AbstractLayoutTest<T extends AbstractLayout> extends
@Override
protected void createActions() {
super.createActions();
- createMarginsSelect(CATEGORY_LAYOUT_FEATURES);
+ if (MarginHandler.class.isAssignableFrom(getTestClass())) {
+ createMarginsSelect(CATEGORY_LAYOUT_FEATURES);
+ }
if (SpacingHandler.class.isAssignableFrom(getTestClass())) {
createSpacingSelect(CATEGORY_LAYOUT_FEATURES);
}
diff --git a/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java b/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java
index 826b7cee07..c14cda58f1 100644
--- a/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java
@@ -40,7 +40,7 @@ public class MoveComponentsFromAbsoluteLayoutToInnerLayout extends TestBase {
@Override
public void buttonClick(ClickEvent event) {
- vl.requestRepaint();
+ vl.markAsDirty();
}
});
diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java
index aa630c79fd..0aaa7c5f13 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java
@@ -28,7 +28,7 @@ public class AbstractFieldCommitWithInvalidValues extends TestBase {
tf = new TextField("A field, must contain 1-2 chars",
new ObjectProperty<String>("a"));
tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false));
- tf.setWriteThrough(false);
+ tf.setBuffered(true);
tf.setRequired(true);
Button b = new Button("Commit", new ClickListener() {
diff --git a/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java b/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java
index a3ee89b3ee..2daeb7bf25 100644
--- a/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java
+++ b/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java
@@ -34,7 +34,7 @@ public class AddressField extends CustomField<Address> {
addressForm = new Form();
}
addressForm.setCaption("Address");
- addressForm.setWriteThrough(false);
+ addressForm.setBuffered(true);
// make sure field changes are sent early
addressForm.setImmediate(true);
diff --git a/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java b/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java
index 0bc4f45545..9b40074433 100644
--- a/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java
+++ b/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java
@@ -4,6 +4,7 @@ import java.util.Arrays;
import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItem;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.tests.util.Person;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
@@ -13,6 +14,7 @@ import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout.MarginHandler;
/**
* Example of nested forms
@@ -29,7 +31,7 @@ public class NestedPersonForm extends Form {
beanItem = new BeanItem<Person>(person);
setCaption("Update person details");
- setWriteThrough(false);
+ setBuffered(true);
setFormFieldFactory(new PersonFieldFactory());
// set the data source and the visible fields
// Note that if the nested form is the first or last field in the parent
@@ -37,7 +39,8 @@ public class NestedPersonForm extends Form {
setItemDataSource(beanItem, Arrays.asList("firstName", "lastName",
"address", "email", "phoneNumber"));
getFooter().addComponent(getButtonsLayout());
- getFooter().setMargin(false, false, true, true);
+ ((MarginHandler) getFooter()).setMargin(new MarginInfo(false, false,
+ true, true));
}
/**
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java b/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java
index c4f001ac41..e24f4753ff 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java
@@ -41,7 +41,7 @@ public class CommitInvalid extends TestBase {
* Create and configure form.
*/
final Form form = new Form();
- form.setWriteThrough(false); // set write buffering on
+ form.setBuffered(true); // set write buffering on
form.setImmediate(true); // make form (and especially its fields
// immediate)
@@ -132,8 +132,8 @@ public class CommitInvalid extends TestBase {
}
private void printState() {
- log.log("Date. Field: " + f((Date) dateField.getValue())
- + " Property: " + f(dateProperty.getValue()));
+ log.log("Date. Field: " + f(dateField.getValue()) + " Property: "
+ + f(dateProperty.getValue()));
log.log("Integer: Field: " + integerField.getValue() + " Property: "
+ integerProperty.getValue());
}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
index 2a7807670b..85f1c80a08 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
@@ -88,7 +88,7 @@ public class DateFieldInSubWindow extends AbstractTestCase {
final Form generalForm = new Form();
{
generalForm.setCaption("My form");
- generalForm.setWriteThrough(true);
+ generalForm.setBuffered(false);
generalForm.setFormFieldFactory(fieldFactory);
BeanItem<MyBean> myBeanItem = new BeanItem<MyBean>(myBean);
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java
index befdd65693..c085088917 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java
@@ -58,7 +58,7 @@ public class DateFieldRangeValidation extends TestBase {
@Override
public void valueChange(ValueChangeEvent event) {
- actualDateField.requestRepaint();
+ actualDateField.markAsDirty();
}
};
@@ -125,8 +125,7 @@ public class DateFieldRangeValidation extends TestBase {
PopupDateField df = new PopupDateField();
df.setLocale(new Locale("en", "US"));
df.setResolution(Resolution.DAY);
- df.setWriteThrough(true);
- df.setReadThrough(true);
+ df.setBuffered(false);
df.setImmediate(true);
return df;
}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java b/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
index 4e256aa947..403b82a2a7 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
@@ -18,7 +18,7 @@ public class DisabledDateFieldWidth extends TestBase {
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- dateField1.requestRepaint();
+ dateField1.markAsDirty();
}
});
diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
index e316fcc5ec..3020942844 100644
--- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
+++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
@@ -47,7 +47,7 @@ public class EmbeddedImageRefresh extends TestBase {
button.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- embedded.requestRepaint();
+ embedded.markAsDirty();
}
});
addComponent(button);
@@ -57,7 +57,7 @@ public class EmbeddedImageRefresh extends TestBase {
public void buttonClick(ClickEvent event) {
((StreamResource) embedded.getSource()).setFilename(new Date()
.getTime() + ".png");
- embedded.requestRepaint();
+ embedded.markAsDirty();
}
});
addComponent(button);
diff --git a/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java b/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java
index 1c10b1d9d7..0106f2e218 100644
--- a/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java
@@ -40,7 +40,7 @@ public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase {
@Override
public void buttonClick(ClickEvent event) {
- vl.requestRepaint();
+ vl.markAsDirty();
}
});
diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java
new file mode 100755
index 0000000000..2c0a8744fc
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java
@@ -0,0 +1,52 @@
+package com.vaadin.tests.components.loginform;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.LoginForm;
+import com.vaadin.ui.LoginForm.LoginEvent;
+import com.vaadin.ui.LoginForm.LoginListener;
+import com.vaadin.ui.Root;
+
+public class LoginFormRootInLoginHandler extends TestBase {
+
+ @Override
+ protected void setup() {
+ LoginForm lf = new LoginForm();
+ lf.addListener(new LoginListener() {
+
+ @Override
+ public void onLogin(LoginEvent event) {
+ Root r1 = Root.getCurrent();
+ if (r1 != null) {
+ addComponent(new Label("Root.getCurrent().data: "
+ + r1.getData()));
+ } else {
+ addComponent(new Label("Root.getCurrent() is null"));
+ }
+ Root r2 = ((LoginForm) event.getSource()).getRoot();
+ if (r2 != null) {
+ addComponent(new Label("event.getSource().data: "
+ + r2.getData()));
+ } else {
+ addComponent(new Label(
+ "event.getSource().getRoot() is null"));
+ }
+ }
+ });
+ addComponent(lf);
+ getLayout().getRoot().setData("This root");
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
index ab632a2a57..97e038dc1a 100644
--- a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
+++ b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
@@ -7,6 +7,7 @@ import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.TextArea;
public class Notifications extends TestBase implements ClickListener {
@@ -52,8 +53,7 @@ public class Notifications extends TestBase implements ClickListener {
@Override
public void buttonClick(ClickEvent event) {
- Notification n = new Notification(tf.getValue(),
- (Integer) type.getValue());
+ Notification n = new Notification(tf.getValue(), (Type) type.getValue());
n.setHtmlContentAllowed(true);
n.show(Page.getCurrent());
}
diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
index c3b20c5e7c..ae3182401d 100644
--- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
+++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
@@ -1,5 +1,8 @@
package com.vaadin.tests.components.root;
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestApplication;
import com.vaadin.ui.Label;
@@ -19,9 +22,15 @@ public class RootsInMultipleTabs extends AbstractTestApplication {
}
}
- @Override
- protected String getRootClassName(WrappedRequest request) {
- return TabRoot.class.getName();
+ public RootsInMultipleTabs() {
+ addRootProvider(new AbstractRootProvider() {
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request)
+ throws RootRequiresMoreInformationException {
+ return TabRoot.class;
+ }
+ });
}
@Override
diff --git a/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java b/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java
index b9ae958a03..77c187ff60 100644
--- a/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java
+++ b/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java
@@ -121,8 +121,7 @@ public class SelectDisplaysOldValue extends TestBase {
controllerComboBox.setNullSelectionAllowed(false);
controllerComboBox.setNewItemsAllowed(false);
controllerComboBox.setImmediate(true);
- controllerComboBox.setWriteThrough(false);
- controllerComboBox.setReadThrough(false);
+ controllerComboBox.setBuffered(true);
}
@@ -131,8 +130,7 @@ public class SelectDisplaysOldValue extends TestBase {
slaveComboBox.setNullSelectionAllowed(false);
slaveComboBox.setNewItemsAllowed(false);
slaveComboBox.setImmediate(true);
- slaveComboBox.setWriteThrough(false);
- slaveComboBox.setReadThrough(false);
+ slaveComboBox.setBuffered(true);
}
private void refreshSlaveDropdown(Integer masterId) {
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
index 05e10397ac..00012522ca 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
@@ -62,8 +62,8 @@ public class SplitPanelExtraScrollbars extends AbstractTestCase implements
}
// Sending all changes in one repaint triggers the bug
- hl.requestRepaint();
- sp.requestRepaint();
+ hl.markAsDirty();
+ sp.markAsDirty();
}
}
diff --git a/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java b/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java
index 88c7c76889..26ac23d5be 100644
--- a/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java
+++ b/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java
@@ -114,7 +114,7 @@ public class EditableTableLeak extends TestBase {
addComponent(new Button("Show size of the table", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- table.requestRepaintAll();
+ table.markAsDirtyRecursive();
updateSize();
}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java
index 00df9fa3c3..a37cf48579 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java
@@ -63,7 +63,7 @@ public class TableClickValueChangeInteraction extends TestBase {
@Override
public void itemClick(ItemClickEvent event) {
- table.requestRepaint();
+ table.markAsDirty();
clickLabel.setValue("Click " + event.getItemId());
}
});
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java b/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java
index 1895191cc4..0b695b41c7 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java
@@ -34,14 +34,14 @@ public class TableColumnResizeContentsWidth extends TestBase {
@Override
public void buttonClick(ClickEvent event) {
table.setColumnWidth(COL1, table.getColumnWidth(COL1) + 20);
- table.requestRepaint();
+ table.markAsDirty();
}
}));
addComponent(new Button("Decrease width", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setColumnWidth(COL1, table.getColumnWidth(COL1) - 40);
- table.requestRepaint();
+ table.markAsDirty();
}
}));
}
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java b/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java
index 89f9ffda40..955a9c2772 100644
--- a/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java
+++ b/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java
@@ -70,7 +70,7 @@ public class OutOfSyncIssueWithKeyboardShortcut extends TestBase {
form.setImmediate(true);
// this is critical for the problem to occur
- form.setWriteThrough(false);
+ form.setBuffered(true);
HorizontalLayout footer = new HorizontalLayout();
footer.setSpacing(true);
diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java b/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java
index bd7984cdeb..be65a335be 100644
--- a/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java
+++ b/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java
@@ -51,7 +51,7 @@ public class TreeFiltering extends TestBase {
public void valueChange(ValueChangeEvent event) {
cont.setIncludeParentsWhenFiltering((Boolean) ((CheckBox) event
.getProperty()).getValue());
- ccTree.requestRepaint();
+ ccTree.markAsDirty();
}
});
addComponent(filterType);
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java b/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java
index 799537f923..f444b781dd 100644
--- a/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java
+++ b/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java
@@ -40,7 +40,7 @@ public class KeepAllItemsVisible extends TestBase implements ExpandListener,
@Override
public void valueChange(ValueChangeEvent event) {
recalculatePageLength(tt);
- tt.requestRepaint();
+ tt.markAsDirty();
}
});
addComponent(tt);
diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
index f34c12607a..537c9be973 100644
--- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
+++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
@@ -76,7 +76,7 @@ public class CheckboxUpdateProblem extends Application.LegacyApplication
private TestForm() {
setSizeFull();
- setWriteThrough(false);
+ setBuffered(true);
setInvalidCommitted(false);
save = new Button("Save", this);
diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java
index abe8553267..020a6b56c5 100644
--- a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java
+++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java
@@ -64,7 +64,7 @@ public class NotPaintedAcceptSource extends TestBase {
} else {
horizontalLayout.replaceComponent(source2, source1);
}
- target.requestRepaint();
+ target.markAsDirty();
}
}));
diff --git a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java
index de028cf0c3..60db95827c 100644
--- a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java
+++ b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java
@@ -39,7 +39,6 @@ public class HelloWorldExtension extends AbstractExtension {
public void setGreeting(String greeting) {
getState().setGreeting(greeting);
- requestRepaint();
}
public String getGreeting() {
diff --git a/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java b/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
index b33162d714..7d4f41cfb3 100644
--- a/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
+++ b/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
@@ -84,7 +84,6 @@ public class SimpleJavaScriptExtensionTest extends AbstractTestRoot {
public void setPrefix(String prefix) {
getState().setPrefix(prefix);
- requestRepaint();
}
public void greetRpc(String message) {
diff --git a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
index 1ea800821b..a35b78c219 100644
--- a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
+++ b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
@@ -8,6 +8,7 @@ import com.vaadin.Application;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.event.Action;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.Page;
@@ -103,7 +104,6 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
mainLayout.addComponent(getTopMenu());
CssLayout margin = new CssLayout();
- margin.setMargin(false, true, true, true);
margin.setSizeFull();
tabs = new TabSheet();
tabs.setSizeFull();
@@ -239,7 +239,7 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
HorizontalLayout hl = new HorizontalLayout();
hl.setSpacing(true);
- hl.setMargin(true, false, false, false);
+ hl.setMargin(new MarginInfo(true, false, false, false));
l.addComponent(hl);
AbstractSelect cb = new ComboBox();
@@ -270,7 +270,7 @@ public class LiferayThemeDemo extends Application.LegacyApplication {
HorizontalLayout hl = new HorizontalLayout();
hl.setSpacing(true);
- hl.setMargin(true, false, false, false);
+ hl.setMargin(new MarginInfo(true, false, false, false));
l.addComponent(hl);
DateField df = new DateField();
diff --git a/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java b/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java
index 792bcb1aab..2f717d2b64 100644
--- a/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java
+++ b/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java
@@ -12,6 +12,7 @@ import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.NativeButton;
public class CssLayoutCustomCss extends TestBase implements ClickListener {
@@ -48,7 +49,7 @@ public class CssLayoutCustomCss extends TestBase implements ClickListener {
@Override
public void valueChange(ValueChangeEvent event) {
- layout.setMargin(cb.getValue());
+ ((MarginHandler) layout).setMargin(cb.getValue());
}
});
@@ -84,7 +85,7 @@ public class CssLayoutCustomCss extends TestBase implements ClickListener {
css.remove(b);
b.setCaption("not " + b.getCaption());
}
- layout.requestRepaint();
+ layout.markAsDirty();
}
diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java
index 1c864fdb47..e200c40744 100644
--- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java
+++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel.java
@@ -3,7 +3,7 @@ package com.vaadin.tests.layouts;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Panel;
public class GridLayoutInsidePanel extends TestBase {
@@ -27,7 +27,7 @@ public class GridLayoutInsidePanel extends TestBase {
"A label which defines the size of the GL"));
Panel p = new Panel("Panel 1");
- ((Layout) p.getContent()).setMargin(false);
+ ((MarginHandler) p.getContent()).setMargin(false);
p.setSizeUndefined();
p.getContent().setSizeUndefined();
@@ -41,7 +41,7 @@ public class GridLayoutInsidePanel extends TestBase {
"A label which defines the size of the GL"));
Panel p = new Panel("Panel 2", gl);
- ((Layout) p.getContent()).setMargin(false);
+ ((MarginHandler) p.getContent()).setMargin(false);
p.setSizeUndefined();
p.getContent().setSizeUndefined();
diff --git a/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java b/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java
index d2f14c114e..33fa0558e7 100644
--- a/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java
+++ b/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java
@@ -271,14 +271,14 @@ public class TestAbsoluteLayout extends TestBase {
addComponent(addComp);
componentEditor = new Form();
- componentEditor.setWriteThrough(false);
+ componentEditor.setBuffered(true);
componentEditor.setCaption("Component properties:");
componentEditor.setFormFieldFactory(MFieldFactory.get());
addComponent(componentEditor);
positionEditor = new Form();
positionEditor.setCaption("Component position");
- positionEditor.setWriteThrough(false);
+ positionEditor.setBuffered(true);
positionEditor.setFormFieldFactory(MFieldFactory.get());
addComponent(positionEditor);
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java
index c6109eebcd..061eb7a23e 100644
--- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java
+++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java
@@ -29,7 +29,6 @@ public class ComponentInStateComponent extends AbstractComponent {
public void setOtherComponent(Component component) {
getState().setOtherComponent(component);
- requestRepaint();
}
public Component getOtherComponent() {
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java
index b85d49172b..292ac62125 100644
--- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java
+++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java
@@ -51,7 +51,6 @@ public class MyComponent extends AbstractComponent {
public void setText(String text) {
getState().setText(text);
- requestRepaint();
}
public String getText() {
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
index 40bb7b68b8..5c519dbdfe 100644
--- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
+++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
@@ -15,14 +15,14 @@ public class WidgetContainer extends AbstractComponentContainer {
public void addComponent(Component c) {
children.add(c);
super.addComponent(c);
- requestRepaint();
+ markAsDirty();
}
@Override
public void removeComponent(Component c) {
children.remove(c);
super.removeComponent(c);
- requestRepaint();
+ markAsDirty();
}
@Override
@@ -33,7 +33,7 @@ public class WidgetContainer extends AbstractComponentContainer {
children.add(index, newComponent);
fireComponentDetachEvent(oldComponent);
fireComponentAttachEvent(newComponent);
- requestRepaint();
+ markAsDirty();
}
}
diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java
index 99e6418fdc..816c60cfe5 100644
--- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java
+++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java
@@ -58,8 +58,6 @@ public class Flot extends AbstractJavaScriptComponent {
}
getState().getSeries().add(pointList);
-
- requestRepaint();
}
public void highlight(int seriesIndex, int dataIndex) {
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java
index 438f7e2d5f..d6d3b132c3 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java
@@ -10,6 +10,7 @@ import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.Table;
@@ -159,7 +160,7 @@ public class Ticket1435 extends Application.LegacyApplication {
private void initContainer() {
container.setStyleName("custompanel");
container.setSizeFull();
- ((Layout) container.getContent()).setMargin(false);
+ ((MarginHandler) container.getContent()).setMargin(false);
container.getContent().setSizeFull();
root.addComponent(container);
root.setExpandRatio(container, 1);
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java
index b9fd2debd5..87ea7e86a8 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java
@@ -1,5 +1,6 @@
package com.vaadin.tests.tickets;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.GridLayout;
@@ -82,19 +83,19 @@ public class Ticket1572 extends com.vaadin.Application.LegacyApplication {
state.setValue("Margin on");
break;
case 2:
- gl.setMargin(true, false, false, false);
+ gl.setMargin(new MarginInfo(true, false, false, false));
state.setValue("Margin top");
break;
case 3:
- gl.setMargin(false, true, false, false);
+ gl.setMargin(new MarginInfo(false, true, false, false));
state.setValue("Margin right");
break;
case 4:
- gl.setMargin(false, false, true, false);
+ gl.setMargin(new MarginInfo(false, false, true, false));
state.setValue("Margin bottom");
break;
case 5:
- gl.setMargin(false, false, false, true);
+ gl.setMargin(new MarginInfo(false, false, false, true));
state.setValue("Margin left");
break;
default:
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
index 01792aeb89..6547572e6d 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
@@ -5,9 +5,12 @@ import java.util.Iterator;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.MethodProperty;
+import com.vaadin.shared.ui.AlignmentInfo.Bits;
+import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.terminal.SystemError;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
@@ -319,84 +322,77 @@ public class Ticket1710 extends com.vaadin.Application.LegacyApplication {
hAlign.setNullSelectionAllowed(false);
vAlign.setNullSelectionAllowed(false);
- vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP));
- vAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_TOP), "top");
- vAlign.addItem(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER));
- vAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER),
+ vAlign.addItem(new Integer(Bits.ALIGNMENT_TOP));
+ vAlign.setItemCaption(new Integer(Bits.ALIGNMENT_TOP), "top");
+ vAlign.addItem(new Integer(Bits.ALIGNMENT_VERTICAL_CENTER));
+ vAlign.setItemCaption(new Integer(Bits.ALIGNMENT_VERTICAL_CENTER),
"center");
- vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_BOTTOM));
- vAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_BOTTOM), "bottom");
-
- hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
- hAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_LEFT), "left");
- hAlign.addItem(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER));
- hAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER),
- "center");
- hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT));
- hAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right");
+ vAlign.addItem(new Integer(Bits.ALIGNMENT_BOTTOM));
+ vAlign.setItemCaption(new Integer(Bits.ALIGNMENT_BOTTOM), "bottom");
+
+ hAlign.addItem(new Integer(Bits.ALIGNMENT_LEFT));
+ hAlign.setItemCaption(new Integer(Bits.ALIGNMENT_LEFT), "left");
+ hAlign.addItem(new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER));
+ hAlign.setItemCaption(
+ new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER), "center");
+ hAlign.addItem(new Integer(Bits.ALIGNMENT_RIGHT));
+ hAlign.setItemCaption(new Integer(Bits.ALIGNMENT_RIGHT), "right");
Property.ValueChangeListener alignmentChangeListener = new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- updateAlignments(((Integer) hAlign.getValue()).intValue(),
- ((Integer) vAlign.getValue()).intValue());
+ Integer h = ((Integer) hAlign.getValue()).intValue();
+ int v = ((Integer) vAlign.getValue()).intValue();
+
+ updateAlignments(new Alignment(h + v));
}
};
- hAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
+ hAlign.setValue(new Integer(Bits.ALIGNMENT_LEFT));
vAlign.addListener(alignmentChangeListener);
hAlign.addListener(alignmentChangeListener);
- vAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP));
+ vAlign.setValue(new Integer(Bits.ALIGNMENT_TOP));
controls.addComponent(new Label("layout alignment"));
final NativeSelect lAlign = new NativeSelect();
controls.addComponent(lAlign);
lAlign.setNullSelectionAllowed(false);
- lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
- lAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_LEFT), "left");
- lAlign.addItem(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER));
- lAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER),
- "center");
- lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT));
- lAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right");
+ lAlign.addItem(new Integer(Bits.ALIGNMENT_LEFT));
+ lAlign.setItemCaption(new Integer(Bits.ALIGNMENT_LEFT), "left");
+ lAlign.addItem(new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER));
+ lAlign.setItemCaption(
+ new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER), "center");
+ lAlign.addItem(new Integer(Bits.ALIGNMENT_RIGHT));
+ lAlign.setItemCaption(new Integer(Bits.ALIGNMENT_RIGHT), "right");
lAlign.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
- testPanelLayout.setComponentAlignment(testedLayout,
- ((Integer) lAlign.getValue()).intValue(),
- VerticalLayout.ALIGNMENT_TOP);
+ testPanelLayout.setComponentAlignment(
+ testedLayout,
+ new Alignment(((Integer) lAlign.getValue())
+ .intValue() + Bits.ALIGNMENT_TOP));
}
});
}
- @SuppressWarnings("deprecation")
- private void updateAlignments(int h, int v) {
+ private void updateAlignments(Alignment a) {
for (Iterator<Component> i = testedLayout.getComponentIterator(); i
.hasNext();) {
((Layout.AlignmentHandler) testedLayout).setComponentAlignment(
- i.next(), h, v);
+ i.next(), a);
}
}
private void updateMarginsAndSpacing() {
- testedLayout.setMargin(marginTop.getValue().booleanValue(),
- marginRight.getValue().booleanValue(), marginBottom
- .getValue().booleanValue(), marginLeft.getValue()
- .booleanValue());
+ if (testedLayout instanceof Layout.MarginHandler) {
+ ((Layout.MarginHandler) testedLayout).setMargin(new MarginInfo(
+ marginTop.getValue().booleanValue(), marginRight
+ .getValue().booleanValue(), marginBottom
+ .getValue().booleanValue(), marginLeft
+ .getValue().booleanValue()));
+ }
if (testedLayout instanceof Layout.SpacingHandler) {
((Layout.SpacingHandler) testedLayout).setSpacing(spacing
.getValue().booleanValue());
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java
index a40f5b25b9..e5fcf59db8 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java
@@ -6,7 +6,7 @@ import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.TextField;
@@ -17,7 +17,7 @@ public class Ticket1805 extends com.vaadin.Application.LegacyApplication {
final LegacyWindow main = new LegacyWindow(getClass().getName()
.substring(getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- ((Layout) main.getContent()).setMargin(false);
+ ((MarginHandler) main.getContent()).setMargin(false);
Label description = new Label(
"GridLayout with 100% (no height), is wanted to "
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java
index 2c979f4600..fa572039aa 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java
@@ -17,8 +17,7 @@ public class Ticket1806 extends com.vaadin.Application.LegacyApplication {
final ObjectProperty<String> prop = new ObjectProperty<String>("");
final TextField tf1 = new TextField(
"Buffered TextField bound to ObjectProperty");
- tf1.setWriteThrough(false);
- tf1.setReadThrough(false);
+ tf1.setBuffered(true);
tf1.setPropertyDataSource(prop);
main.addComponent(tf1);
main.addComponent(new Button(
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
index de91b04c1c..e31748ec2f 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
@@ -66,7 +66,7 @@ public class Ticket1834PanelScrolling extends
b.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
- p.requestRepaint();
+ p.markAsDirty();
}
});
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java
index 4deb5020ab..4db82c3371 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java
@@ -107,7 +107,7 @@ public class Ticket1983 extends Application.LegacyApplication {
isLong = true;
}
// Works the same way with or without repaint request
- table.requestRepaint();
+ table.markAsDirty();
}
});
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java
index c36bb5c25e..f6d8ce5e01 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java
@@ -9,6 +9,7 @@ import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.TextArea;
@@ -78,7 +79,7 @@ public class Ticket2021 extends Application.LegacyApplication {
p3.setHeight("500px");
// p3.setContent(new GridLayout());
p3.getContent().setSizeFull();
- ((Layout) p3.getContent()).setMargin(false);
+ ((MarginHandler) p3.getContent()).setMargin(false);
GridLayout gl = new GridLayout();
gl.setSizeFull();
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java
index ac8928d110..d98656b9ca 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java
@@ -2,7 +2,7 @@ package com.vaadin.tests.tickets;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
@@ -17,7 +17,7 @@ public class Ticket2040 extends com.vaadin.Application.LegacyApplication {
setMainWindow(main);
main.getContent().setSizeFull();
- ((Layout) main.getContent()).setMargin(true);
+ ((MarginHandler) main.getContent()).setMargin(true);
setTheme("tests-tickets");
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java
index 1d7d8bb006..88404b6ef1 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java
@@ -33,9 +33,9 @@ public class Ticket2060 extends Application.LegacyApplication {
@Override
public void buttonClick(ClickEvent event) {
- button1.requestRepaint();
- button2.requestRepaint();
- button3.requestRepaint();
+ button1.markAsDirty();
+ button2.markAsDirty();
+ button3.markAsDirty();
}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java
index 16a552e37a..c5ef9ec0b0 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java
@@ -8,7 +8,7 @@ import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
@@ -31,7 +31,7 @@ public class Ticket2405 extends Application.LegacyApplication {
setMainWindow(root);
root.getContent().setSizeFull();
- ((Layout) root.getContent()).setMargin(false);
+ ((MarginHandler) root.getContent()).setMargin(false);
// Top area, containing playback and volume controls, play status, view
// modes and search
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
index ee60c0ce7e..2d2970d36e 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
@@ -19,6 +19,7 @@ import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.MarginHandler;
import com.vaadin.ui.ListSelect;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
@@ -252,7 +253,7 @@ public class Ticket2998 extends Application.LegacyApplication {
// set theme and some layout stuff
setMainWindow(w);
w.getContent().setSizeFull();
- ((Layout) w.getContent()).setMargin(false);
+ ((MarginHandler) w.getContent()).setMargin(false);
Panel p = new Panel("Workout Log");
p.setStyleName(Reindeer.PANEL_LIGHT);
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html
index 84c02254b4..8888f95d15 100644
--- a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html
+++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html
@@ -13,13 +13,13 @@
</thead><tbody>
<tr>
<td>open</td>
- <td>/run/com.vaadin.tests.vaadincontext.BoostrapModifyRoot?restartApplication</td>
+ <td>/run/com.vaadin.tests.vaadincontext.BootstrapModifyRoot?restartApplication</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
- <td>vaadin=runcomvaadintestsvaadincontextBoostrapModifyRoot::/VVerticalLayout[0]/VLabel[0]</td>
- <td>There should be a static h1 in the HTML of the bootstrap page for this Root</td>
+ <td>vaadin=runcomvaadintestsvaadincontextBootstrapModifyRoot::/VVerticalLayout[0]/VLabel[0]</td>
+ <td>There should be two additional divs in the HTML of the bootstrap page for this Root</td>
</tr>
<tr>
<td>assertText</td>
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java
index ede8d51192..6c17c3005e 100644
--- a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java
+++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java
@@ -19,7 +19,7 @@ package com.vaadin.tests.vaadincontext;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestRoot;
-public class BoostrapModifyRoot extends AbstractTestRoot {
+public class BootstrapModifyRoot extends AbstractTestRoot {
@Override
protected void setup(WrappedRequest request) {
@@ -29,7 +29,7 @@ public class BoostrapModifyRoot extends AbstractTestRoot {
@Override
protected String getTestDescription() {
- return "There should be a static h1 in the HTML of the bootstrap page for this Root";
+ return "There should be two additional divs in the HTML of the bootstrap page for this Root";
}
@Override
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
index 4c93d70b36..da058892b4 100644
--- a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
+++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
@@ -44,7 +44,7 @@ public class TestAddonContextListener implements AddonContextListener {
private boolean shouldModify(BootstrapResponse response) {
Root root = response.getRoot();
boolean shouldModify = root != null
- && root.getClass() == BoostrapModifyRoot.class;
+ && root.getClass() == BootstrapModifyRoot.class;
return shouldModify;
}