diff options
532 files changed, 10237 insertions, 8789 deletions
diff --git a/WebContent/VAADIN/themes/base/styles.css b/WebContent/VAADIN/themes/base/styles.css index 874f0369f0..fc8d8d1ae1 100644 --- a/WebContent/VAADIN/themes/base/styles.css +++ b/WebContent/VAADIN/themes/base/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"6_4_5_dev-20100917";} -.v-theme-version-6_4_5_dev-20100917 {display: none;} +.v-theme-version:after {content:"9_9_9_INTERNAL-DEBUG-BUILD";} +.v-theme-version-9_9_9_INTERNAL-DEBUG-BUILD {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -167,6 +167,10 @@ /* * Checkbox styles * -------------------------------------- */ + + .v-checkbox { + display: block; + } .v-checkbox, .v-checkbox label, diff --git a/WebContent/VAADIN/themes/liferay/styles.css b/WebContent/VAADIN/themes/liferay/styles.css index eed3379a6a..a865448ffb 100644 --- a/WebContent/VAADIN/themes/liferay/styles.css +++ b/WebContent/VAADIN/themes/liferay/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"6_4_5_dev-20100926";} -.v-theme-version-6_4_5_dev-20100926 {display: none;} +.v-theme-version:after {content:"9_9_9_INTERNAL-DEBUG-BUILD";} +.v-theme-version-9_9_9_INTERNAL-DEBUG-BUILD {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -167,6 +167,10 @@ /* * Checkbox styles * -------------------------------------- */ + + .v-checkbox { + display: block; + } .v-checkbox, .v-checkbox label, diff --git a/WebContent/VAADIN/themes/reindeer/common/img/horizontal-sprites.png b/WebContent/VAADIN/themes/reindeer/common/img/horizontal-sprites.png Binary files differindex 3f107c2c31..7980a5aa18 100644 --- a/WebContent/VAADIN/themes/reindeer/common/img/horizontal-sprites.png +++ b/WebContent/VAADIN/themes/reindeer/common/img/horizontal-sprites.png diff --git a/WebContent/VAADIN/themes/reindeer/menubar/menubar.css b/WebContent/VAADIN/themes/reindeer/menubar/menubar.css index be5a1ab172..2ed2e6aabe 100644 --- a/WebContent/VAADIN/themes/reindeer/menubar/menubar.css +++ b/WebContent/VAADIN/themes/reindeer/menubar/menubar.css @@ -45,7 +45,7 @@ background: transparent url(img/submenu-icon.png) no-repeat right 70%; width: 26px; height: 16px; - text-indent: -999px; + text-indent: -9999px; } .v-menubar-submenu .v-menubar-menuitem-selected .v-menubar-submenu-indicator { background-image: url(img/submenu-icon-hover.png); diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css index 52d08579cb..48990fca83 100644 --- a/WebContent/VAADIN/themes/runo/styles.css +++ b/WebContent/VAADIN/themes/runo/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"6_4_5_dev-20100923";} -.v-theme-version-6_4_5_dev-20100923 {display: none;} +.v-theme-version:after {content:"9_9_9_INTERNAL-DEBUG-BUILD";} +.v-theme-version-9_9_9_INTERNAL-DEBUG-BUILD {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -167,6 +167,10 @@ /* * Checkbox styles * -------------------------------------- */ + + .v-checkbox { + display: block; + } .v-checkbox, .v-checkbox label, diff --git a/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-bottom.png b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-bottom.png Binary files differnew file mode 100644 index 0000000000..11511f6d34 --- /dev/null +++ b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-bottom.png diff --git a/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-left.png b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-left.png Binary files differnew file mode 100644 index 0000000000..94cc431687 --- /dev/null +++ b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-left.png diff --git a/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-right.png b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-right.png Binary files differnew file mode 100644 index 0000000000..ce38258c8e --- /dev/null +++ b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-right.png diff --git a/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-top.png b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-top.png Binary files differnew file mode 100644 index 0000000000..cb27085e0e --- /dev/null +++ b/WebContent/VAADIN/themes/sampler/layouts/images/measured-from-top.png diff --git a/WebContent/VAADIN/themes/sampler/layouts/splitpanelpositioningexample.css b/WebContent/VAADIN/themes/sampler/layouts/splitpanelpositioningexample.css new file mode 100644 index 0000000000..30321bf24b --- /dev/null +++ b/WebContent/VAADIN/themes/sampler/layouts/splitpanelpositioningexample.css @@ -0,0 +1,42 @@ +.split-panel-positioning-example .measured-from-left{ + background-image: url("images/measured-from-left.png"); + background-repeat: repeat-y; + text-align: center; + vertical-align: middle; + -moz-opacity:.50; + filter:alpha(opacity=50); + opacity:.50; +} +.split-panel-positioning-example .measured-from-right{ + background-image: url("images/measured-from-right.png"); + background-position: right; + background-repeat: repeat-y; + text-align: center; + vertical-align: middle; + -moz-opacity:.50; + filter:alpha(opacity=50); + opacity:.50; +} +.split-panel-positioning-example .measured-from-top{ + background-image: url("images/measured-from-top.png"); + background-repeat: repeat-x; + text-align: center; + vertical-align: middle; + -moz-opacity:.50; + filter:alpha(opacity=50); + opacity:.50; +} +.split-panel-positioning-example .measured-from-bottom{ + background-image: url("images/measured-from-bottom.png"); + background-position: bottom; + background-repeat: repeat-x; + text-align: center; + vertical-align: middle; + -moz-opacity:.50; + filter:alpha(opacity=50); + opacity:.50; +} + +.split-panel-positioning-example .v-select-optiongroup .v-select-option{ + display:inline; +}
\ No newline at end of file diff --git a/WebContent/VAADIN/themes/sampler/styles.css b/WebContent/VAADIN/themes/sampler/styles.css index 1ee032e25a..ea7215a344 100644 --- a/WebContent/VAADIN/themes/sampler/styles.css +++ b/WebContent/VAADIN/themes/sampler/styles.css @@ -21,6 +21,8 @@ @import url(layouts/clickableexample.css); +@import url(layouts/splitpanelpositioningexample.css); + @import url(table/styles.css); @import url(misc/item-styles.css); diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 0cfd1703d5..0d776d631a 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -3,11 +3,8 @@ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
- <!--
- THIS IS THE DEVELOPMENT web.xml Package web.xml can be found in
- build/package, please update it too when making changes that should
- affect the package.
- -->
+<!-- THIS IS THE DEVELOPMENT web.xml Package web.xml can be found in build/package,
+ please update it too when making changes that should affect the package. -->
<web-app>
@@ -19,17 +16,19 @@ <param-value>false</param-value>
<description>Vaadin production mode</description>
</context-param>
-
+
<context-param>
<param-name>resourceCacheTime</param-name>
- <param-value>3600</param-value>
+ <param-value>3600</param-value>
</context-param>
<servlet>
<servlet-name>VaadinApplicationRunner</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationRunnerServlet</servlet-class>
- <init-param><param-name>defaultPackages</param-name>
- <param-value>com.vaadin.tests,com.vaadin.demo,com.vaadin.tests.tickets,com.vaadin.tests.components,com.vaadin.tests.components.layouts,com.vaadin.tests.components.panel,com.vaadin.tests.components.combobox,com.vaadin.tests.components.popupview,com.vaadin.tests.components.datefield,com.vaadin.tests.components.richtextarea,com.vaadin.tests.components.absolutelayout,com.vaadin.tests.components.embedded,com.vaadin.tests.components.splitpanel,com.vaadin.tests.components.abstractfield,com.vaadin.tests.components.form,com.vaadin.tests.components.table,com.vaadin.tests.components.accordion,com.vaadin.tests.components.label,com.vaadin.tests.components.tabsheet,com.vaadin.tests.components.beanitemcontainer,com.vaadin.tests.components.link,com.vaadin.tests.components.textfield,com.vaadin.tests.components.button,com.vaadin.tests.components.optiongroup,com.vaadin.tests.components.tree,com.vaadin.tests.components.caption,com.vaadin.tests.components.orderedlayout,com.vaadin.tests.components.window,com.vaadin.tests.dd,com.vaadin.tests.validation</param-value></init-param>
+ <init-param>
+ <param-name>defaultPackages</param-name>
+ <param-value>com.vaadin.tests,com.vaadin.demo,com.vaadin.tests.tickets,com.vaadin.tests.components,com.vaadin.tests.components.layouts,com.vaadin.tests.components.panel,com.vaadin.tests.components.combobox,com.vaadin.tests.components.popupview,com.vaadin.tests.components.datefield,com.vaadin.tests.components.richtextarea,com.vaadin.tests.components.absolutelayout,com.vaadin.tests.components.embedded,com.vaadin.tests.components.splitpanel,com.vaadin.tests.components.abstractfield,com.vaadin.tests.components.form,com.vaadin.tests.components.table,com.vaadin.tests.components.accordion,com.vaadin.tests.components.label,com.vaadin.tests.components.tabsheet,com.vaadin.tests.components.beanitemcontainer,com.vaadin.tests.components.link,com.vaadin.tests.components.textfield,com.vaadin.tests.components.button,com.vaadin.tests.components.optiongroup,com.vaadin.tests.components.tree,com.vaadin.tests.components.caption,com.vaadin.tests.components.orderedlayout,com.vaadin.tests.components.window,com.vaadin.tests.dd,com.vaadin.tests.validation</param-value>
+ </init-param>
</servlet>
@@ -119,7 +118,7 @@ <param-value>com.vaadin.tests.RandomLayoutStress</param-value>
</init-param>
</servlet>
-
+
<servlet>
<servlet-name>PortletDemo</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
@@ -127,7 +126,7 @@ <param-name>application</param-name>
<param-value>com.vaadin.demo.portlet.PortletDemo</param-value>
</init-param>
- </servlet>
+ </servlet>
<servlet>
<servlet-name>CustomLayoutDemo</servlet-name>
@@ -208,15 +207,10 @@ <param-name>application</param-name>
<param-value>com.vaadin.tests.TreeFilesystemContainer</param-value>
</init-param>
- <!--
- Set this property if demo cannot access context base directory
- because of Application Server or Servlet Container security
- constraints
- -->
- <!--
- <init-param> <param-name>sampleDirectory</param-name>
- <param-value>/mySampleDirectory</param-value> </init-param>
- -->
+ <!-- Set this property if demo cannot access context base directory because
+ of Application Server or Servlet Container security constraints -->
+ <!-- <init-param> <param-name>sampleDirectory</param-name> <param-value>/mySampleDirectory</param-value>
+ </init-param> -->
</servlet>
<servlet>
@@ -226,15 +220,10 @@ <param-name>application</param-name>
<param-value>com.vaadin.tests.TreeFilesystem</param-value>
</init-param>
- <!--
- Set this property if demo cannot access context base directory
- because of Application Server or Servlet Container security
- constraints
- -->
- <!--
- <init-param> <param-name>sampleDirectory</param-name>
- <param-value>/mySampleDirectory</param-value> </init-param>
- -->
+ <!-- Set this property if demo cannot access context base directory because
+ of Application Server or Servlet Container security constraints -->
+ <!-- <init-param> <param-name>sampleDirectory</param-name> <param-value>/mySampleDirectory</param-value>
+ </init-param> -->
</servlet>
<servlet>
@@ -278,33 +267,6 @@ </servlet>
<servlet>
- <servlet-name>BookTestServlet</servlet-name>
- <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
- <init-param>
- <param-name>application</param-name>
- <param-value>com.vaadin.tests.book.BookTestApplication</param-value>
- </init-param>
- </servlet>
-
- <servlet>
- <servlet-name>WindowTestServlet</servlet-name>
- <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
- <init-param>
- <param-name>application</param-name>
- <param-value>com.vaadin.tests.book.WindowTestApplication</param-value>
- </init-param>
- </servlet>
-
- <servlet>
- <servlet-name>ChatServlet</servlet-name>
- <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
- <init-param>
- <param-name>application</param-name>
- <param-value>com.vaadin.tests.book.ChatApplication</param-value>
- </init-param>
- </servlet>
-
- <servlet>
<servlet-name>GAESyncTest</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.GAEApplicationServlet</servlet-class>
<init-param>
@@ -421,25 +383,12 @@ <servlet-name>ColorPickerApplication</servlet-name>
<url-pattern>/colorpicker/*</url-pattern>
</servlet-mapping>
- <servlet-mapping>
- <servlet-name>BookTestServlet</servlet-name>
- <url-pattern>/book/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>WindowTestServlet</servlet-name>
- <url-pattern>/windowtest/*</url-pattern>
- </servlet-mapping>
<servlet-mapping>
- <servlet-name>ChatServlet</servlet-name>
- <url-pattern>/chat/*</url-pattern>
- </servlet-mapping>
-
- <servlet-mapping>
<servlet-name>PortletDemo</servlet-name>
<url-pattern>/PortletDemo/*</url-pattern>
</servlet-mapping>
-
+
<servlet-mapping>
<servlet-name>GAESyncTest</servlet-name>
<url-pattern>/gaesynctest/*</url-pattern>
@@ -449,12 +398,12 @@ <servlet-name>AddressBook</servlet-name>
<url-pattern>/AddressBook/*</url-pattern>
</servlet-mapping>
-
+
<servlet-mapping>
<servlet-name>ReindeerThemeStyles</servlet-name>
<url-pattern>/ReindeerTheme/*</url-pattern>
</servlet-mapping>
-
+
<servlet-mapping>
<servlet-name>RunoTheme</servlet-name>
<url-pattern>/RunoTheme/*</url-pattern>
diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html index 37abcdddb6..1bbcd1e4ba 100644 --- a/WebContent/release-notes.html +++ b/WebContent/release-notes.html @@ -28,83 +28,54 @@ <ul> <li><a href="#overview">Overview</a></li> <li><a href="#upgrading">General Upgrade Notes</a></li> - <li><a href="#upgradefrom63">Upgrading from Vaadin 6.3</a></li> - <li><a href="#widgetupgrade">Upgrading from Vaadin 6.0 or 6.1</a></li> <li><a href="#upgrading-tk5">Instructions for Upgrading from IT Mill Toolkit 5</a></li> <li><a href="#known-problems">Important known problems in Vaadin @version@</a></li> + <li><a href="#changelog">Change Log</a></li> <li><a href="#requirements">Requirements</a></li> </ul> -<p>Vaadin @version@ is a maintenance release for Vaadin 6.4. It contains several important fixes.</p> +<p>Vaadin @version@ is an update release for Vaadin 6. In addition to various fixes, it +contains a number of significant enhancements.</p> -<p>Please see the <a href="http://dev.vaadin.com/query?status=closed&resolution=fixed&order=id&milestone=Vaadin+@version@&type=!task">list of fixed issues in Vaadin @version@</a> -for more details. Problem fixes and enhancements planned for upcoming -releases can be found from the <a -href="http://dev.vaadin.com/roadmap">Vaadin Roadmap</a> in Vaadin Trac.</p> +<h3>Enhancements</h3> -<p>An outline of enhancements introduced in Vaadin 6.4 is given in the <a href="http://vaadin.com/download/release/6.4/6.4.0/release-notes.html">Release Notes for Vaadin 6.4.0</a>.</p> +<ul> + <li>Implemented server-side logging using java.util.logging, allowing you to specify loglevels and get + rid of unnecessary messages. See <a href="http://dev.vaadin.com/ticket/5715">#5715</a> for more info. + </li> + <li>ItemClickSource has been renamed to ItemClickNotifier for consistency with other classes.</li> + <li>GWT has been updated to version 2.1.0</li> + <li>Widgetset builder has been optimized to only look for paintables in Vaadin add-on jars (containing an add-on manifest). If you are packaging your own widgets into jar file, ensure they also contain the <a href="http://dev.vaadin.com/wiki/VaadinAddon">Vaadin add-on manifest</a>.</li> +</ul> -<p>Problem fixes and enhancements planned for upcoming releases can be found in the <a -href="http://dev.vaadin.com/roadmap">Vaadin Roadmap</a> in Vaadin Trac.</p> +<h3>Backward Incompatible API Changes</h3> -<p>As always, when upgrading from an earlier version, you should recompile any custom -widget sets and refresh your project in Eclipse. If you are upgrading from earlier than -6.3.0, notice that Vaadin 6.4 uses GWT 2.0 (included in the installation package). See -<a href="#upgrading">General Upgrade Notes</a> for more details on upgrading.</p> +<p>The following changes can break backward compatibility in applications using an earlier version of Vaadin:</p> -<h2 id="upgrading">General Upgrade Notes</h2> +<ul> + <li>Table.setColumnCollapsed throws IllegalStateException instead of IllegalAccessException is collapsing is not allowed.</li> + <li>Window.removeWindow(Window) now triggers window close listeners also when called explicitly. + See <a href="http://dev.vaadin.com/ticket/3865">#3865</a> for more info. + </li> +</ul> -<p>When upgrading from an earlier version of the Vaadin library, you should always do the following:</p> +<ul> + <li>AbstractStringValidator and now converts non-String values using toString() prior to validation (#5785). + This also affects most built-in validators such as IntegerValidator.</li> +</ul> -<ol> - <li>Install the new Vaadin JAR to your project</li> - <ul> - <li>If using the Vaadin Plugin in Eclipse, download and select the new version in project preferences.</li> - </ul> - <li>Install new GWT JARs if the GWT version has changed</li> - <ul> - <li>The Eclipse plugin will automatically download the new GWT and update launch configurations and the project build path when you update the Vaadin version.</li> - </ul> - <li>If you have custom widget sets, recompile them with the new Vaadin library using the included GWT compiler</li> - <li>If using the Eclipse IDE: - <ol type="a"> - <li>Refresh the Eclipse project by selecting the project folder and pressing <strong>F5</strong></li> - <li>Restart the application server</li> - </ol> -</ol> -<p>Using the Vaadin project facet in the Eclipse IDE does the steps 1 and 2 automatically.</p> +<h3>Change Log, Future Releases, and Upgrading</h3> -<h2 id="upgradefrom63">Upgrading from Vaadin 6.3</h2> +<p>See the <a href="#changelog">Change Log</a> for a full list of tickets fixed in this release.</p> -<p>The following changes can break backward compatibility in applications -using Vaadin 6.3 or earlier:</p> +<p>Problem fixes and enhancements planned for upcoming releases can be found in the <a +href="http://dev.vaadin.com/roadmap">Vaadin Roadmap</a> in Vaadin Trac.</p> -<ul> - <li><p>In <b>AbsoluteLayout.ComponentPosition</b> (<a href="http://dev.vaadin.com/ticket/5311">#5311</a>):</p> - <ul> - <li><p>The setters and getters of floating-point properties now use <b>Float</b> - instead of <tt>float</tt> to allow null values for indicating "unset" - values. This change can cause compile-time errors, which you may need - to solve with proper casts.</p></li> - - <li><p>The <tt>setCSSString()</tt> now resets attributes not present - in the given parameter to their unset state, which may cause change - application behavior without causing any compile- or runtime-errors.</p></li> - </ul> - </li> - - <li>In the rare case that you have extended the <b>DefaultWidgetSet</b> class, please notice that earlier, the custom entry point was defined in the <tt>.gwt.xml</tt> file as follows: - - <pre> <entry-point class="com.example.MyExtendedWidgetSet" /></pre> - - Now you need to write as follows: - <pre> <replace-with class="com.example.MyExtendedWidgetSet"> - <when-type-is class="com.vaadin.terminal.gwt.client.WidgetSet" /> - </replace-with></pre> - </li> - -</ul> +<p>As always, when upgrading from an earlier version, you should recompile any custom +widget sets and refresh your project in Eclipse. If you are upgrading from earlier than +6.3.0, notice that Vaadin 6.4 uses GWT 2.0 (included in the installation package). See +<a href="#upgrading">General Upgrade Notes</a> for more details on upgrading.</p> <h2 id="widgetupgrade">Upgrading from Vaadin 6.0 or 6.1</h2> @@ -124,7 +95,7 @@ For applications where custom widgets are used (also applicable to widget projec <p> If you are using widgets from another project (typically in a separate JAR file): <ul> -<li>Acquire a new JAR which is compatible with Vaadin 6.4 and add it to <tt>WEB-INF/lib</tt>. The widget set compilation will automatically include the JAR in your <tt>.gwt.xml</tt> during compilation if you use the Eclipse <b>Compile Widget Set</b> button. For Ant/Maven you need to specify the location of the widget set JARs that you want to include in the application widget set.</li> +<li>Acquire a new JAR which is compatible with Vaadin 6.3 and add it to <tt>WEB-INF/lib</tt>. The widget set compilation will automatically include the JAR in your <tt>.gwt.xml</tt> during compilation if you use the Eclipse <b>Compile Widget Set</b> button. For Ant/Maven you need to specify the location of the widget set JARs that you want to include in the application widget set.</li> </ul> </p> <p> @@ -135,6 +106,29 @@ If you package a widget set as a JAR for use in other projects: </ul> </p> +<h2 id="upgrading">General Upgrade Notes</h2> + +<p>When upgrading from an earlier version of the Vaadin library, you should always do the following:</p> + +<ol> + <li>Install the new Vaadin JAR to your project</li> + <ul> + <li>If using the Vaadin Plugin in Eclipse, download and select the new version in project preferences.</li> + </ul> + <li>Install new GWT JARs if the GWT version has changed</li> + <ul> + <li>The Eclipse plugin will automatically download the new GWT and update launch configurations and the project build path when you update the Vaadin version.</li> + </ul> + <li>If you have custom widget sets, recompile them with the new Vaadin library using the included GWT compiler</li> + <li>If using the Eclipse IDE: + <ol type="a"> + <li>Refresh the Eclipse project by selecting the project folder and pressing <strong>F5</strong></li> + <li>Restart the application server</li> + </ol> +</ol> + +<p>Using the Vaadin project facet in the Eclipse IDE does the steps 1 and 2 automatically.</p> + <h2 id="upgrading-tk5">Instructions for Upgrading from IT Mill Toolkit 5</h2> <p>While the Vaadin 6 API is otherwise mostly backward-compatible with IT Mill Toolkit 5.4, the @@ -258,6 +252,103 @@ under the Google App Engine.</p> <p>For other known problems, see open tickets at developer site <a href="http://dev.vaadin.com/">dev.vaadin.com</a>.</p> +<h2 id="changelog">Change Log</h2> + +<p>The following closed issues have been included in this release:</p> + +<ul> + <li><a href="http://dev.vaadin.com/ticket/1086">#1086</a>: Tree: Keyboard navigation</li> + <li><a href="http://dev.vaadin.com/ticket/1553">#1553</a>: Table: add footer element</li> + <li><a href="http://dev.vaadin.com/ticket/2228">#2228</a>: Cannot get multiple causes from InvalidValueException</li> + <li><a href="http://dev.vaadin.com/ticket/2366">#2366</a>: Optimize subtree rendering when becoming/losing width or height</li> + <li><a href="http://dev.vaadin.com/ticket/2390">#2390</a>: Keyboard navigation for Table</li> + <li><a href="http://dev.vaadin.com/ticket/2497">#2497</a>: Missing icons</li> + <li><a href="http://dev.vaadin.com/ticket/2807">#2807</a>: Table should update column size back to server</li> + <li><a href="http://dev.vaadin.com/ticket/2974">#2974</a>: Combobox with icon broken in reindeer theme</li> + <li><a href="http://dev.vaadin.com/ticket/3161">#3161</a>: Reindeer black window rounded borders look pixelated in Chrome</li> + <li><a href="http://dev.vaadin.com/ticket/3520">#3520</a>: Improve Table multiselect to use Ctrl and Shift for selection</li> + <li><a href="http://dev.vaadin.com/ticket/3720">#3720</a>: Disable Items for OptionGroup</li> + <li><a href="http://dev.vaadin.com/ticket/3723">#3723</a>: ComponentContainerers should have the possibility to give an index of some component.</li> + <li><a href="http://dev.vaadin.com/ticket/3988">#3988</a>: Provide access to portlet ResourceBundles</li> + <li><a href="http://dev.vaadin.com/ticket/4259">#4259</a>: Improve Tree multiselect to use Ctrl and Shift for selection</li> + <li><a href="http://dev.vaadin.com/ticket/4311">#4311</a>: DateField should not show stacktrace for invalid dates</li> + <li><a href="http://dev.vaadin.com/ticket/4315">#4315</a>: Window name generation should be deterministic</li> + <li><a href="http://dev.vaadin.com/ticket/4317">#4317</a>: VScrollTable should not update page length when hidden or disabled</li> + <li><a href="http://dev.vaadin.com/ticket/4442">#4442</a>: Fix differences script to use zip instead of tar.gz for previous version</li> + <li><a href="http://dev.vaadin.com/ticket/4448">#4448</a>: TextField input prompt focus timing problem with Firefox</li> + <li><a href="http://dev.vaadin.com/ticket/4484">#4484</a>: PropertyFormatter constructor calls format</li> + <li><a href="http://dev.vaadin.com/ticket/4499">#4499</a>: Chrome GWT development mode rendering broken</li> + <li><a href="http://dev.vaadin.com/ticket/4515">#4515</a>: Add support for Table header click listener</li> + <li><a href="http://dev.vaadin.com/ticket/4516">#4516</a>: Add support for Table footer click listener</li> + <li><a href="http://dev.vaadin.com/ticket/4567">#4567</a>: FormLayout doesn't focus the fields when clicking on their caption</li> + <li><a href="http://dev.vaadin.com/ticket/4581">#4581</a>: Dropdowns in a table auto-close when clicked in IE</li> + <li><a href="http://dev.vaadin.com/ticket/4595">#4595</a>: BeanItemContainer: no warning about use of Bean's hashCode</li> + <li><a href="http://dev.vaadin.com/ticket/4609">#4609</a>: Retrieving an index of a component in an AbstractOrderedLayout</li> + <li><a href="http://dev.vaadin.com/ticket/4619">#4619</a>: Gecko as user.agent for GWT doesn't work with Firefox 3.6</li> + <li><a href="http://dev.vaadin.com/ticket/4631">#4631</a>: Implement Runo theme demo application</li> + <li><a href="http://dev.vaadin.com/ticket/4636">#4636</a>: Checking a checkbox moves it 1 pixel down in IE6+IE7</li> + <li><a href="http://dev.vaadin.com/ticket/4997">#4997</a>: VFormLayout should copy component style names to the caption as well</li> + <li><a href="http://dev.vaadin.com/ticket/5006">#5006</a>: Table does not refresh header state when no rows exist</li> + <li><a href="http://dev.vaadin.com/ticket/5008">#5008</a>: Tree should ensure that the selected node is visible after navigation with the keyboard</li> + <li><a href="http://dev.vaadin.com/ticket/5012">#5012</a>: Self comparison of classId with itself in com.vaadin.ui.Embedded.setClassId(String)</li> + <li><a href="http://dev.vaadin.com/ticket/5024">#5024</a>: Table keyboard navigation blocks essential shortcuts</li> + <li><a href="http://dev.vaadin.com/ticket/5026">#5026</a>: WidgetSetBuilder creates duplicate references to non-Vaadin GWT modules</li> + <li><a href="http://dev.vaadin.com/ticket/5030">#5030</a>: ItemSetChangeEvent's in HierarchicalContainer are fired too early</li> + <li><a href="http://dev.vaadin.com/ticket/5033">#5033</a>: Widget not found error should reference to manual or another help page</li> + <li><a href="http://dev.vaadin.com/ticket/5038">#5038</a>: Window clicklistener is not working</li> + <li><a href="http://dev.vaadin.com/ticket/5057">#5057</a>: Keyboard support for TwinColSelect</li> + <li><a href="http://dev.vaadin.com/ticket/5059">#5059</a>: PopupView is not closed when focus is moved outside using tab</li> + <li><a href="http://dev.vaadin.com/ticket/5060">#5060</a>: Pressing ESC inside a ComboBox with input prompt shows an editable prompt</li> + <li><a href="http://dev.vaadin.com/ticket/5061">#5061</a>: Keyboard support for MenuBar</li> + <li><a href="http://dev.vaadin.com/ticket/5063">#5063</a>: RichTextArea class should have constructors</li> + <li><a href="http://dev.vaadin.com/ticket/5065">#5065</a>: Table should not receive focus if it is not in selectable mode and all rows are visible</li> + <li><a href="http://dev.vaadin.com/ticket/5068">#5068</a>: When moving focus to Tree or Table keyboard nav focus should be placed to the current selection</li> + <li><a href="http://dev.vaadin.com/ticket/5079">#5079</a>: AbsoluteLayout z-index parsing is picky</li> + <li><a href="http://dev.vaadin.com/ticket/5091">#5091</a>: RichTextArea with fixed height does not work</li> + <li><a href="http://dev.vaadin.com/ticket/5099">#5099</a>: Slider keyboard navigation</li> + <li><a href="http://dev.vaadin.com/ticket/5102">#5102</a>: Double click in TwinColSelect should move selected item</li> + <li><a href="http://dev.vaadin.com/ticket/5104">#5104</a>: "Table with setNullSelectionAllowed(false) can be visually ""set to null"" using the keyboard"</li> + <li><a href="http://dev.vaadin.com/ticket/5110">#5110</a>: Context menu should get keyboard focus when opened</li> + <li><a href="http://dev.vaadin.com/ticket/5112">#5112</a>: Table.focus() should not throw UnsupportedOperationException</li> + <li><a href="http://dev.vaadin.com/ticket/5114">#5114</a>: ClassPathExplorer should not use URL instances as map or set keys</li> + <li><a href="http://dev.vaadin.com/ticket/5120">#5120</a>: TableClickHandlers sample has extra scrollbar</li> + <li><a href="http://dev.vaadin.com/ticket/5124">#5124</a>: Unsteady first apperance of modal popup Window</li> + <li><a href="http://dev.vaadin.com/ticket/5144">#5144</a>: Moving the caret inside a textfield which is inside a selectable Table is impossible</li> + <li><a href="http://dev.vaadin.com/ticket/5148">#5148</a>: WebBrowser doesn't get correct details when application is run as a portlet</li> + <li><a href="http://dev.vaadin.com/ticket/5174">#5174</a>: Menu cannot be clicked using mouse</li> + <li><a href="http://dev.vaadin.com/ticket/5177">#5177</a>: Popup for DateField with msec resolution fails to open after entering invalid date</li> + <li><a href="http://dev.vaadin.com/ticket/5179">#5179</a>: TabSheet should have a removeTab(Tab t)</li> + <li><a href="http://dev.vaadin.com/ticket/5180">#5180</a>: Selecting a menu item that has no parent using enter does not remove focus from the item</li> + <li><a href="http://dev.vaadin.com/ticket/5182">#5182</a>: ComponentLocator fails to identify widgets attached to RootPanel</li> + <li><a href="http://dev.vaadin.com/ticket/5203">#5203</a>: DateField setResolution() should call requestRepaint</li> + <li><a href="http://dev.vaadin.com/ticket/5212">#5212</a>: Table.setColumnAlignment(Object, String) API and JavaDoc misleading</li> + <li><a href="http://dev.vaadin.com/ticket/5217">#5217</a>: Text selections/cursor position features</li> + <li><a href="http://dev.vaadin.com/ticket/5225">#5225</a>: ApplicationServlet#getApplicationClass does not retain its parent class's 'throws ClassNotFoundException' clause</li> + <li><a href="http://dev.vaadin.com/ticket/5227">#5227</a>: GridLayout column expansion is incorrect</li> + <li><a href="http://dev.vaadin.com/ticket/5269">#5269</a>: Scrolling Tree and the clicking on item will not select item</li> + <li><a href="http://dev.vaadin.com/ticket/5270">#5270</a>: CombobBox is not always opened by first click on dropdown button (Webkit)</li> + <li><a href="http://dev.vaadin.com/ticket/5277">#5277</a>: PopupDateField: isEmpty() returns incorrect result</li> + <li><a href="http://dev.vaadin.com/ticket/5278">#5278</a>: Moving an invisible component to another layout renders the component as visible</li> + <li><a href="http://dev.vaadin.com/ticket/5279">#5279</a>: Combobox selected item's caption disappears from scrolling</li> + <li><a href="http://dev.vaadin.com/ticket/5280">#5280</a>: ContainerHierarchicalWrapper is not fully serializable</li> + <li><a href="http://dev.vaadin.com/ticket/5281">#5281</a>: Tree keeps selected items even after a new containerDataSource has been set</li> + <li><a href="http://dev.vaadin.com/ticket/5282">#5282</a>: Transferable interface and classes implementing it are not serializable</li> + <li><a href="http://dev.vaadin.com/ticket/5285">#5285</a>: Action and event related interfaces and notifiers should be serializable</li> + <li><a href="http://dev.vaadin.com/ticket/5286">#5286</a>: Relevant server side classes and interfaces should implement Serializable</li> + <li><a href="http://dev.vaadin.com/ticket/5291">#5291</a>: PopupDateField ValueChangEvents sent for invalid date changes but not when clearing the field</li> + <li><a href="http://dev.vaadin.com/ticket/5292">#5292</a>: PopupDateField setValue(null) does not clear the field when there is invalid input</li> + <li><a href="http://dev.vaadin.com/ticket/5293">#5293</a>: WidgetsetBuilder should create widgetset directory if it does not exist</li> + <li><a href="http://dev.vaadin.com/ticket/5300">#5300</a>: The Upload component should have a default constructor</li> + <li><a href="http://dev.vaadin.com/ticket/5303">#5303</a>: Error indicator not always shown for checkboxes</li> + <li><a href="http://dev.vaadin.com/ticket/5306">#5306</a>: The multiselect mode for normal Selects doesn't work</li> + <li><a href="http://dev.vaadin.com/ticket/5311">#5311</a>: AbsoluteLayout$ComponentPosition does not indicate unset values properly</li> + <li><a href="http://dev.vaadin.com/ticket/5314">#5314</a>: Menubar should not use a static field for generating menu item ids</li> + <li><a href="http://dev.vaadin.com/ticket/5315">#5315</a>: Header and footer clicks should be immediate even if Table is not immediate</li> + <li><a href="http://dev.vaadin.com/ticket/5316">#5316</a>: Footer cell not resized with the rightmost column</li> + <li><a href="http://dev.vaadin.com/ticket/5320">#5320</a>: Error in table column header mode JavaDoc</li> + <li><a href="http://dev.vaadin.com/ticket/5323">#5323</a>: Disabled buttons in OptionGroup not grayed in CSS</li> +</ul> + <h2 id="requirements">Requirements</h2> <p>Vaadin is available for the following operating systems:</p> @@ -330,4 +421,4 @@ work.</p> </div> <!-- /footer --> </body> -</html> +</html>
\ No newline at end of file diff --git a/build/GWT-VERSION.properties b/build/GWT-VERSION.properties index 999f0e5ab8..3d6d3443fb 100644 --- a/build/GWT-VERSION.properties +++ b/build/GWT-VERSION.properties @@ -1 +1 @@ -gwt-version=2.0.4 +gwt-version=2.1.0 diff --git a/build/VERSION.properties b/build/VERSION.properties index cb84002819..7bd1bbbaf1 100644 --- a/build/VERSION.properties +++ b/build/VERSION.properties @@ -1,2 +1,2 @@ -version=6.4.9 -manual.repository=http://dev.vaadin.com/svn/doc/branches/6.4 +version=6.5.0 +manual.repository=http://dev.vaadin.com/svn/doc/branches/6.5 diff --git a/build/build.xml b/build/build.xml index 36056df797..a96096153b 100644 --- a/build/build.xml +++ b/build/build.xml @@ -180,7 +180,6 @@ <!-- Construct classpath used by java and javadoc compilation --> <path id="compile.classpath"> <pathelement path="build/lib/servlet.jar" /> - <pathelement path="build/external/fileupload/classes" /> <fileset dir="lib/core"> <include name="**/*.jar"/> @@ -574,12 +573,7 @@ </copy> </target> - <target name="compile-fileupload"> - <echo>Compiling custom fileupload classes.</echo> - <ant dir="build/external/fileupload" antfile="build.xml" target="compile" /> - </target> - - <target name="compile-java" depends="init, check-servlet-version, compile-fileupload, webcontent"> + <target name="compile-java" depends="init, check-servlet-version, webcontent"> <echo>Compiling src (server-side)</echo> <!-- Compile all sources at the same time as they depend on each other --> @@ -593,10 +587,12 @@ </javac> </target> - <target name="defaulttheme" depends="init"> - <echo>Combining default themes css files</echo> - <!-- ensure buildhelpers are compiled --> + <target name="compile-helpers" depends="init"> <javac source="1.5" target="1.5" srcdir="build/buildhelpers" classpath="build/smartsprites/lib/smartsprites-0.2.3-itmill.jar"/> + </target> + + <target name="defaulttheme" depends="init, compile-helpers"> + <echo>Combining default themes css files</echo> <java classname="com.vaadin.buildhelpers.CompileDefaultTheme" failonerror="yes" fork="yes"> <arg value="-version" /> <arg value="${version.full}"/> @@ -779,7 +775,7 @@ <!-- specifically on it, because dependence does not see compiled --> <!-- individual widgetsets, because antcall does not fulfill --> <!-- dependencies. --> - <target name="vaadin.jar" depends="compile-server-side, compile-client-side"> + <target name="vaadin.jar" depends="compile-server-side, compile-client-side, compile-helpers"> <echo>Creating JAR (server-side) ${lib-jar-name}</echo> <!-- Create Vaadin JAR --> <mkdir dir="${output-dir}/META-INF"/> @@ -789,7 +785,12 @@ compress="true" manifest="build/package/META-INF/MANIFEST.MF"> <metainf dir="${output-dir}/META-INF"/> <manifest> + <attribute name="Vaadin-Package-Version" value="1" /> <attribute name="Vaadin-Widgetsets" value="com.vaadin.terminal.gwt.DefaultWidgetSet" /> + <attribute name="Implementation-Vendor" value="Vaadin Ltd" /> + <attribute name="Implementation-URL" value="http://vaadin.com" /> + <attribute name="Implementation-Version" value="${version.full}" /> + <attribute name="GWT-Version" value="${gwt-version}" /> <attribute name="Bundle-Version" value="${version.full}" /> </manifest> <fileset dir="${result-path}/classes"> @@ -799,10 +800,6 @@ <exclude name="${toolkit-package}/launcher/**" /> </patternset> </fileset> - <!-- fileupload, see build/external/fileupload/build.xml --> - <fileset dir="build/external/fileupload/classes"> - <include name="**/*" /> - </fileset> <!-- add sources --> <fileset dir="${result-path}/src/core"> <patternset> @@ -819,6 +816,15 @@ </patternset> </fileset> </jar> + + <!-- Generate the Export-Package attribute in the manifest of the JAR --> + <java classname="com.vaadin.buildhelpers.GeneratePackageExports" failonerror="true" fork="yes"> + <arg value="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}"/> + <classpath> + <pathelement location="build/buildhelpers" /> + </classpath> + </java> + <copy file="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}" tofile="${output-dir}/WebContent/${lib-jar-name}" /> </target> @@ -868,15 +874,6 @@ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <target name="manual-init" depends="init"> - <!-- Can run XEP only if license is available. --> - <available file="build/lib/XEP/license.xml" property="xep.license.available" /> - - <!-- Path to installed XEP license. --> - <property name="xep.license.path.installed" value="/opt/RenderX/XEP/license.xml"/> - <echo>XEP license expected to be installed as ${xep.license.path.installed}</echo> - - <!-- Can copy XEP license only if it is available. --> - <available file="${xep.license.path.installed}" property="xep.license.installed"/> </target> <!-- Checkout doc repository. --> @@ -900,13 +897,8 @@ <echo>Manual checked out from repository successfully</echo> </target> - <!-- If the XEP is installed, copy it to proper place. --> - <target name="xep-license-copy" if="xep.license.installed"> - <copy file="${xep.license.path.installed}" todir="${docdir}/build/lib/XEP"/> - </target> - <!-- Build manual. --> - <target name="manual-build" depends="manual-init, xep-license-copy"> + <target name="manual-build" depends="manual-init"> <!-- The HTML and Eclipse Manual must be built with separate runs --> <ant dir="${docdir}" antfile="build/build.xml" inheritAll="false"> <property name="version" value="${version.full}"/> diff --git a/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java b/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java new file mode 100644 index 0000000000..742450f3d5 --- /dev/null +++ b/build/buildhelpers/com/vaadin/buildhelpers/GeneratePackageExports.java @@ -0,0 +1,131 @@ +package com.vaadin.buildhelpers; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Vector; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.Manifest; +import java.util.jar.Attributes.Name; + +/** + * Generates Export-Packages attribute for OSGi compatible manifest. + * + * Reads the included Java packages in Vaadin JAR, generates a corresponding + * MANIFEST.MF file, and replaces the dummy one in the JAR with the + * generated one. + * + * See #3521 for details. + * + * @author magi + */ +public class GeneratePackageExports { + public static void main(String[] args) { + if (args.length < 1) { + System.err.println("Invalid number of parameters\n"+ + "Usage: java -cp .. GenerateManifest <package.jar>"); + System.exit(1); + } + + // Open tje JAR + String jarFilename = args[0]; + JarFile jar = null; + try { + jar = new JarFile(jarFilename); + } catch (IOException e) { + System.err.println("Unable to open JAR '"+jarFilename+"'"); + System.exit(1); + } + + // List the included Java packages + HashSet<String> packages = new HashSet<String>(); + for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements();) { + JarEntry entry = it.nextElement(); + if (entry.getName().startsWith("com") && entry.getName().endsWith(".class")) { + int lastSlash = entry.getName().lastIndexOf('/'); + String pkg = entry.getName().substring(0, lastSlash).replace('/', '.'); + packages.add(pkg); + } + } + + // List theme packages + for (Enumeration<JarEntry> it = jar.entries(); it.hasMoreElements();) { + JarEntry entry = it.nextElement(); + if (entry.isDirectory() && entry.getName().startsWith("VAADIN/themes")) { + // Strip ending slash + int lastSlash = entry.getName().lastIndexOf('/'); + String pkg = entry.getName().substring(0, lastSlash).replace('/', '.'); + packages.add(pkg); + } + } + + // Replacement for the "Export-Package" attribute in the manifest + String exportPackage = ""; + + // Produce an ordered listing of the package names + String packageArray[] = new String[packages.size()]; + packages.toArray(packageArray); + Arrays.sort(packageArray); + for (int i=0; i<packageArray.length; i++) { + if (i == 0) + exportPackage = packageArray[i]; + else + exportPackage += ", " + packageArray[i]; + } + + // Read old manifest + Manifest oldMF = null; + try { + oldMF = jar.getManifest(); + } catch (IOException e) { + e.printStackTrace(); + } + + // Read main attributes + Attributes mainAtts = oldMF.getMainAttributes(); + Vector<String> keys = new Vector<String>(mainAtts.size()); + for (Iterator<Object> attrit = mainAtts.keySet().iterator(); attrit.hasNext();) { + Name name = (Name) attrit.next(); + keys.add(name.toString()); + } + + // Put the manifest version as the first line + String orderedKeys[] = new String[keys.size()]; + keys.toArray(orderedKeys); + Arrays.sort(orderedKeys); // Must sort to be able to search + int mvPos = Arrays.binarySearch(orderedKeys, "Manifest-Version"); + orderedKeys[mvPos] = orderedKeys[0]; // Swap + orderedKeys[0] = "Manifest-Version"; + + // This final ordering is just for esthetic reasons and + // in practice unnecessary and will actually be messed up + // when the 'jar' command reads the manifest + Arrays.sort(orderedKeys, 1, orderedKeys.length-1); + + // Create the modified manifest + ManifestWriter manifest = new ManifestWriter(); + for (int i=0; i<orderedKeys.length; i++) { + // Skip an existing Export-Package attribute + if (orderedKeys[i].equals("Export-Package")) { + // Copy the attribute to the modified manifest + manifest.writeAttribute(orderedKeys[i], mainAtts.getValue(orderedKeys[i])); + } + } + + // Add the Export-Package attribute at the end of the manifest. + // The alternative would be replacing an existing attribute in + // the loop above, but it's not guaranteed that it exists. + manifest.writeAttribute("Export-Package", exportPackage); + + // Update the manifest in the Jar + int status = manifest.updateJar(jarFilename); + + if (status != 0) + System.exit(status); + } + +} diff --git a/build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java b/build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java new file mode 100644 index 0000000000..a6130e2a46 --- /dev/null +++ b/build/buildhelpers/com/vaadin/buildhelpers/ManifestWriter.java @@ -0,0 +1,130 @@ +/** + * + */ +package com.vaadin.buildhelpers; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Date; +import java.util.jar.Manifest; + +public class ManifestWriter { + StringBuffer buffer = new StringBuffer(); + + public ManifestWriter() { + } + + /** + * Writes a manifest attribute to a temporary buffer. + * + * @param name Attribute name + * @param value Attribute value + */ + public void writeAttribute(String name, String value) { + int linelen = name.length() + 2; + buffer.append(name); + buffer.append(": "); + + String remainingValue = value; + while (linelen + remainingValue.length() > 72) { + int fitsLine = 72 - linelen; + buffer.append(remainingValue.substring(0, fitsLine) + "\n "); + remainingValue = remainingValue.substring(fitsLine); + linelen = 1; + } + buffer.append(remainingValue + "\n"); + } + + /** + * Writes the manifest to given JAR file. + * + * The manifest must be created with {@code #writeAttribute(String, String)} + * before calling this write. + * + * @param jarFilename File name of the JAR in which the manifest is written + * @return 0 on success, nonzero value on error + */ + int updateJar(String jarFilename) { + int status = 0; + + // Determine a temporary file name + String newMfPrefix = "vaadin-manifest-" + (new Date()).getTime(); + File newMfFile = null; + try { + newMfFile = File.createTempFile(newMfPrefix, ".mf"); + } catch (IOException e) { + System.err.println("Creating temp file failed"); + status = 1; + } + + // Write the manifest to the temporary file + if (status == 0) { + FileOutputStream fos = null; + try { + fos = new FileOutputStream(newMfFile); + fos.write(getBytes()); + fos.close(); + } catch (IOException e) { + System.err.println("Writing to file '"+newMfFile.getAbsolutePath() +"' failed because: " + e.getMessage()); + status = 1; + } + } + + // Check that the manifest is OK + if (status == 0) { + Manifest checkMf = new Manifest(); + FileInputStream is; + try { + is = new FileInputStream(newMfFile); + checkMf.read(is); + } catch (IOException e) { + System.err.println("Reading from file '"+newMfFile.getAbsolutePath() +"' failed because: " + e.getMessage()); + status = 1; + } + } + + // Update the manifest in the Jar + if (status == 0) { + System.out.println("Updating manifest in JAR " + jarFilename); + try { + // The "mf" order must correspond with manifest-jarfile order + Process process = Runtime.getRuntime().exec(new String[]{"jar", "umf", newMfFile.getAbsolutePath(), jarFilename}); + int exitValue = process.waitFor(); + if (exitValue != 0) { + InputStream jarErr = process.getErrorStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(jarErr)); + while (reader.ready()) { + System.err.println("jar: " + reader.readLine()); + } + System.err.println("The 'jar' command returned with exit value " + exitValue); + status = 1; + } + } catch (IOException e) { + System.err.println("Failed to execute 'jar' command. " + e.getMessage()); + status = 1; + } catch (InterruptedException e) { + System.err.println("Execution of 'jar' command was interrupted. " + e.getMessage()); + status = 1; + } + } + + // Remove the temporary file + if (newMfFile != null) + newMfFile.delete(); + + return status; + } + + public String toString() { + return buffer.toString(); + } + + public byte[] getBytes() { + return buffer.toString().getBytes(); + } +}
\ No newline at end of file diff --git a/build/package/META-INF/MANIFEST.MF b/build/package/META-INF/MANIFEST.MF index b1bbf0b6ad..c787fcba06 100644 --- a/build/package/META-INF/MANIFEST.MF +++ b/build/package/META-INF/MANIFEST.MF @@ -2,6 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: Vaadin Bundle-SymbolicName: com.vaadin Bundle-Vendor: IT Mill Ltd -Export-Package: VAADIN.themes, VAADIN.themes.base, VAADIN.themes.base.absolutelayout, VAADIN.themes.base.accordion, VAADIN.themes.base.button, VAADIN.themes.base.caption, VAADIN.themes.base.common, VAADIN.themes.base.common.img, VAADIN.themes.base.csslayout, VAADIN.themes.base.customcomponent, VAADIN.themes.base.customlayout, VAADIN.themes.base.datefield, VAADIN.themes.base.formlayout, VAADIN.themes.base.gridlayout, VAADIN.themes.base.link, VAADIN.themes.base.menubar, VAADIN.themes.base.notification, VAADIN.themes.base.orderedlayout, VAADIN.themes.base.panel, VAADIN.themes.base.popupview, VAADIN.themes.base.progressindicator, VAADIN.themes.base.select, VAADIN.themes.base.shadow, VAADIN.themes.base.shadow.img, VAADIN.themes.base.slider, VAADIN.themes.base.splitpanel, VAADIN.themes.base.table, VAADIN.themes.base.tabsheet, VAADIN.themes.base.textfield, VAADIN.themes.base.tree, VAADIN.themes.base.upload, VAADIN.themes.base.window, VAADIN.themes.base.window.img.shadow, VAADIN.themes.reindeer, VAADIN.themes.reindeer.accordion, VAADIN.themes.reindeer.button, VAADIN.themes.reindeer.button.img, VAADIN.themes.reindeer.button.img.black, VAADIN.themes.reindeer.common, VAADIN.themes.reindeer.common.icons, VAADIN.themes.reindeer.common.img, VAADIN.themes.reindeer.datefield, VAADIN.themes.reindeer.datefield.img, VAADIN.themes.reindeer.formlayout, VAADIN.themes.reindeer.label, VAADIN.themes.reindeer.layouts,VAADIN.themes.reindeer.layouts.img,VAADIN.themes.reindeer.menubar,VAADIN.themes.reindeer.menubar.img,VAADIN.themes.reindeer.notification,VAADIN.themes.reindeer.notification.img,VAADIN.themes.reindeer.panel,VAADIN.themes.reindeer.progressindicator,VAADIN.themes.reindeer.progressindicator.img,VAADIN.themes.reindeer.select,VAADIN.themes.reindeer.select.img,VAADIN.themes.reindeer.select.img.black,VAADIN.themes.reindeer.slider,VAADIN.themes.reindeer.slider.img,VAADIN.themes.reindeer.splitpanel,VAADIN.themes.reindeer.splitpanel.img,VAADIN.themes.reindeer.table,VAADIN.themes.reindeer.table.img,VAADIN.themes.reindeer.tabsheet,VAADIN.themes.reindeer.tabsheet.img,VAADIN.themes.reindeer.tabsheet.img.bar,VAADIN.themes.reindeer.tabsheet.img.framed,VAADIN.themes.reindeer.textfield,VAADIN.themes.reindeer.textfield.img,VAADIN.themes.reindeer.tree,VAADIN.themes.reindeer.tree.img,VAADIN.themes.reindeer.window,VAADIN.themes.reindeer.window.img,VAADIN.themes.reindeer.window.img.black,VAADIN.themes.runo,VAADIN.themes.runo.absolutelayout,VAADIN.themes.runo.accordion,VAADIN.themes.runo.accordion.img,VAADIN.themes.runo.button,VAADIN.themes.runo.button.img,VAADIN.themes.runo.caption,VAADIN.themes.runo.common,VAADIN.themes.runo.common.img,VAADIN.themes.runo.datefield,VAADIN.themes.runo.datefield.img,VAADIN.themes.runo.formlayout,VAADIN.themes.runo.gridlayout,VAADIN.themes.runo.icons,VAADIN.themes.runo.link,VAADIN.themes.runo.menubar,VAADIN.themes.runo.notification,VAADIN.themes.runo.notification.img,VAADIN.themes.runo.orderedlayout,VAADIN.themes.runo.panel,VAADIN.themes.runo.panel.img,VAADIN.themes.runo.popupview,VAADIN.themes.runo.progressindicator,VAADIN.themes.runo.progressindicator.img,VAADIN.themes.runo.select,VAADIN.themes.runo.select.img,VAADIN.themes.runo.shadow,VAADIN.themes.runo.shadow.img,VAADIN.themes.runo.slider,VAADIN.themes.runo.slider.img,VAADIN.themes.runo.splitpanel,VAADIN.themes.runo.splitpanel.img,VAADIN.themes.runo.table,VAADIN.themes.runo.table.img,VAADIN.themes.runo.tabsheet,VAADIN.themes.runo.tabsheet.img,VAADIN.themes.runo.textfield,VAADIN.themes.runo.textfield.img,VAADIN.themes.runo.tree,VAADIN.themes.runo.tree.img,VAADIN.themes.runo.window,VAADIN.themes.runo.window.img,VAADIN.themes.runo.window.img.shadow,VAADIN.widgetsets,VAADIN.widgetsets.com.vaadin.terminal.gwt.DefaultWidgetSet,com.vaadin,com.vaadin.annotations,com.vaadin.data,com.vaadin.data.util,com.vaadin.data.validator,com.vaadin.event,com.vaadin.event.dd,com.vaadin.event.dd.acceptcriteria,com.vaadin.external.org.apache.commons.fileupload,com.vaadin.external.org.apache.commons.fileupload.disk,com.vaadin.external.org.apache.commons.fileupload.portlet,com.vaadin.external.org.apache.commons.fileupload.servlet,com.vaadin.external.org.apache.commons.fileupload.util,com.vaadin.portal.gwt,com.vaadin.portal.gwt.client,com.vaadin.service,com.vaadin.terminal,com.vaadin.terminal.gwt,com.vaadin.terminal.gwt.client,com.vaadin.terminal.gwt.client.ui,com.vaadin.terminal.gwt.client.ui.dd,com.vaadin.terminal.gwt.client.ui.layout,com.vaadin.terminal.gwt.client.ui.richtextarea,com.vaadin.terminal.gwt.server,com.vaadin.tools,com.vaadin.ui,com.vaadin.ui.themes,com.vaadin.util Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: javax.servlet; version="2.3.0",javax.servlet.http; version="2.3.0" diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java index 14837fa0f9..68f64613e9 100644 --- a/src/com/vaadin/Application.java +++ b/src/com/vaadin/Application.java @@ -17,6 +17,8 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Locale; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.service.ApplicationContext; import com.vaadin.terminal.ApplicationResource; @@ -90,6 +92,9 @@ import com.vaadin.ui.Window; public abstract class Application implements URIHandler, Terminal.ErrorListener, Serializable { + private final static Logger logger = Logger.getLogger(Application.class + .getName()); + /** * Id use for the next window that is opened. Access to this must be * synchronized. @@ -1186,9 +1191,8 @@ public abstract class Application implements URIHandler, final Throwable t = event.getThrowable(); if (t instanceof SocketException) { // Most likely client browser closed socket - System.err - .println("Warning: SocketException in CommunicationManager." - + " Most likely client (browser) closed socket."); + logger.info("SocketException in CommunicationManager." + + " Most likely client (browser) closed socket."); return; } @@ -1215,7 +1219,7 @@ public abstract class Application implements URIHandler, } // also print the error on console - t.printStackTrace(); + logger.log(Level.SEVERE, "Terminal error:", t); } /** diff --git a/src/com/vaadin/data/Validator.java b/src/com/vaadin/data/Validator.java index 8c96bcba49..21a9da9f97 100644 --- a/src/com/vaadin/data/Validator.java +++ b/src/com/vaadin/data/Validator.java @@ -6,7 +6,6 @@ package com.vaadin.data; import java.io.Serializable; -import com.vaadin.data.Validator.InvalidValueException; import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; diff --git a/src/com/vaadin/data/util/BeanItem.java b/src/com/vaadin/data/util/BeanItem.java index 816a1c1c96..534969ba4f 100644 --- a/src/com/vaadin/data/util/BeanItem.java +++ b/src/com/vaadin/data/util/BeanItem.java @@ -73,8 +73,8 @@ public class BeanItem<BT> extends PropertysetItem { final Method setMethod = pd.getWriteMethod(); final Class<?> type = pd.getPropertyType(); final String name = pd.getName(); - final Property p = new MethodProperty(type, bean, getMethod, - setMethod); + final Property p = new MethodProperty<Object>(type, bean, + getMethod, setMethod); addItemProperty(name, p); } @@ -114,8 +114,8 @@ public class BeanItem<BT> extends PropertysetItem { final Method getMethod = pd.getReadMethod(); final Method setMethod = pd.getWriteMethod(); final Class<?> type = pd.getPropertyType(); - final Property p = new MethodProperty(type, bean, getMethod, - setMethod); + final Property p = new MethodProperty<Object>(type, bean, + getMethod, setMethod); addItemProperty(name, p); } } diff --git a/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java b/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java index 4dca5cf52b..3633154c4a 100644 --- a/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java @@ -253,14 +253,14 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * comment here, we use the default documentation from implemented * interface. */ - public Collection getChildren(Object itemId) { + public Collection<?> getChildren(Object itemId) { // If the wrapped container implements the method directly, use it if (hierarchical) { return ((Container.Hierarchical) container).getChildren(itemId); } - final Collection c = children.get(itemId); + final Collection<?> c = children.get(itemId); if (c == null) { return null; } @@ -321,7 +321,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * comment here, we use the default documentation from implemented * interface. */ - public Collection rootItemIds() { + public Collection<?> rootItemIds() { // If the wrapped container implements the method directly, use it if (hierarchical) { @@ -632,7 +632,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * comment here, we use the default documentation from implemented * interface. */ - public Collection getItemIds() { + public Collection<?> getItemIds() { return container.getItemIds(); } @@ -650,7 +650,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * JavaDoc comment here, we use the default documentation from implemented * interface. */ - public Collection getContainerPropertyIds() { + public Collection<?> getContainerPropertyIds() { return container.getContainerPropertyIds(); } @@ -659,7 +659,7 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, * Don't add a JavaDoc comment here, we use the default documentation from * implemented interface. */ - public Class getType(Object propertyId) { + public Class<?> getType(Object propertyId) { return container.getType(propertyId); } diff --git a/src/com/vaadin/data/util/ContainerOrderedWrapper.java b/src/com/vaadin/data/util/ContainerOrderedWrapper.java index 44bd6a8653..958476240e 100644 --- a/src/com/vaadin/data/util/ContainerOrderedWrapper.java +++ b/src/com/vaadin/data/util/ContainerOrderedWrapper.java @@ -43,12 +43,12 @@ public class ContainerOrderedWrapper implements Container.Ordered, /** * Ordering information, ie. the mapping from Item ID to the next item ID */ - private Hashtable next; + private Hashtable<Object, Object> next; /** * Reverse ordering information for convenience and performance reasons. */ - private Hashtable prev; + private Hashtable<Object, Object> prev; /** * ID of the first Item in the container. @@ -180,19 +180,19 @@ public class ContainerOrderedWrapper implements Container.Ordered, if (!ordered) { - final Collection ids = container.getItemIds(); + final Collection<?> ids = container.getItemIds(); // Recreates ordering if some parts of it are missing if (next == null || first == null || last == null || prev != null) { first = null; last = null; - next = new Hashtable(); - prev = new Hashtable(); + next = new Hashtable<Object, Object>(); + prev = new Hashtable<Object, Object>(); } // Filter out all the missing items - final LinkedList l = new LinkedList(next.keySet()); - for (final Iterator i = l.iterator(); i.hasNext();) { + final LinkedList<?> l = new LinkedList<Object>(next.keySet()); + for (final Iterator<?> i = l.iterator(); i.hasNext();) { final Object id = i.next(); if (!container.containsId(id)) { removeFromOrderWrapper(id); @@ -200,7 +200,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, } // Adds missing items - for (final Iterator i = ids.iterator(); i.hasNext();) { + for (final Iterator<?> i = ids.iterator(); i.hasNext();) { final Object id = i.next(); if (!next.containsKey(id)) { addToOrderWrapper(id); @@ -421,7 +421,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, * comment here, we use the default documentation from implemented * interface. */ - public Collection getItemIds() { + public Collection<?> getItemIds() { return container.getItemIds(); } @@ -439,7 +439,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, * JavaDoc comment here, we use the default documentation from implemented * interface. */ - public Collection getContainerPropertyIds() { + public Collection<?> getContainerPropertyIds() { return container.getContainerPropertyIds(); } @@ -448,7 +448,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, * Don't add a JavaDoc comment here, we use the default documentation from * implemented interface. */ - public Class getType(Object propertyId) { + public Class<?> getType(Object propertyId) { return container.getType(propertyId); } diff --git a/src/com/vaadin/data/util/DefaultItemSorter.java b/src/com/vaadin/data/util/DefaultItemSorter.java index 372e94a5f9..fa36ef1a57 100644 --- a/src/com/vaadin/data/util/DefaultItemSorter.java +++ b/src/com/vaadin/data/util/DefaultItemSorter.java @@ -154,7 +154,8 @@ public class DefaultItemSorter implements ItemSorter { // Removes any non-sortable property ids final List<Object> ids = new ArrayList<Object>(); final List<Boolean> orders = new ArrayList<Boolean>(); - final Collection sortable = container.getSortableContainerPropertyIds(); + final Collection<?> sortable = container + .getSortableContainerPropertyIds(); for (int i = 0; i < propertyId.length; i++) { if (sortable.contains(propertyId[i])) { ids.add(propertyId[i]); @@ -180,6 +181,7 @@ public class DefaultItemSorter implements ItemSorter { public static class DefaultPropertyValueComparator implements Comparator<Object>, Serializable { + @SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { int r = 0; // Normal non-null comparison @@ -197,7 +199,7 @@ public class DefaultItemSorter implements ItemSorter { } else { // Assume the objects can be cast to Comparable, throw // ClassCastException otherwise. - r = ((Comparable) o1).compareTo(o2); + r = ((Comparable<Object>) o1).compareTo(o2); } } else if (o1 == o2) { // Objects are equal if both are null @@ -212,7 +214,6 @@ public class DefaultItemSorter implements ItemSorter { return r; } - } } diff --git a/src/com/vaadin/data/util/FilesystemContainer.java b/src/com/vaadin/data/util/FilesystemContainer.java index 1c9671d52d..a26323f487 100644 --- a/src/com/vaadin/data/util/FilesystemContainer.java +++ b/src/com/vaadin/data/util/FilesystemContainer.java @@ -461,23 +461,23 @@ public class FilesystemContainer implements Container.Hierarchical { } if (propertyId.equals(PROPERTY_NAME)) { - return new MethodProperty(getType(propertyId), new FileItem( - (File) itemId), FILEITEM_NAME, null); + return new MethodProperty<Object>(getType(propertyId), + new FileItem((File) itemId), FILEITEM_NAME, null); } if (propertyId.equals(PROPERTY_ICON)) { - return new MethodProperty(getType(propertyId), new FileItem( - (File) itemId), FILEITEM_ICON, null); + return new MethodProperty<Object>(getType(propertyId), + new FileItem((File) itemId), FILEITEM_ICON, null); } if (propertyId.equals(PROPERTY_SIZE)) { - return new MethodProperty(getType(propertyId), new FileItem( - (File) itemId), FILEITEM_SIZE, null); + return new MethodProperty<Object>(getType(propertyId), + new FileItem((File) itemId), FILEITEM_SIZE, null); } if (propertyId.equals(PROPERTY_LASTMODIFIED)) { - return new MethodProperty(getType(propertyId), new FileItem( - (File) itemId), FILEITEM_LASTMODIFIED, null); + return new MethodProperty<Object>(getType(propertyId), + new FileItem((File) itemId), FILEITEM_LASTMODIFIED, null); } return null; diff --git a/src/com/vaadin/data/util/HierarchicalContainer.java b/src/com/vaadin/data/util/HierarchicalContainer.java index 108c544198..2b434224ac 100644 --- a/src/com/vaadin/data/util/HierarchicalContainer.java +++ b/src/com/vaadin/data/util/HierarchicalContainer.java @@ -89,7 +89,7 @@ public class HierarchicalContainer extends IndexedContainer implements * comment here, we use the default documentation from implemented * interface. */ - public Collection getChildren(Object itemId) { + public Collection<?> getChildren(Object itemId) { LinkedList<Object> c; if (filteredChildren != null) { @@ -156,7 +156,7 @@ public class HierarchicalContainer extends IndexedContainer implements * comment here, we use the default documentation from implemented * interface. */ - public Collection rootItemIds() { + public Collection<?> rootItemIds() { if (filteredRoots != null) { return Collections.unmodifiableCollection(filteredRoots); } else { diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java index 6d1d3cdad8..f35e09a68d 100644 --- a/src/com/vaadin/data/util/IndexedContainer.java +++ b/src/com/vaadin/data/util/IndexedContainer.java @@ -16,6 +16,8 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import com.vaadin.data.Container; @@ -68,24 +70,24 @@ public class IndexedContainer implements Container.Indexed, /** * Property ID to type mapping. */ - private Hashtable types = new Hashtable(); + private Hashtable<Object, Class<?>> types = new Hashtable<Object, Class<?>>(); /** * Hash of Items, where each Item is implemented as a mapping from Property * ID to Property value. */ - private Hashtable items = new Hashtable(); + private Hashtable<Object, Map<Object, Object>> items = new Hashtable<Object, Map<Object, Object>>(); /** * Set of properties that are read-only. */ - private HashSet readOnlyProperties = new HashSet(); + private HashSet<Property> readOnlyProperties = new HashSet<Property>(); /** * List of all Property value change event listeners listening all the * properties. */ - private LinkedList propertyValueChangeListeners = null; + private LinkedList<Property.ValueChangeListener> propertyValueChangeListeners = null; /** * Data structure containing all listeners interested in changes to single @@ -93,17 +95,17 @@ public class IndexedContainer implements Container.Indexed, * hashtable that maps Item IDs to a linked list of listeners listening * Property identified by given Property ID and Item ID. */ - private Hashtable singlePropertyValueChangeListeners = null; + private Hashtable<Object, Map<Object, List<Property.ValueChangeListener>>> singlePropertyValueChangeListeners = null; /** * List of all Property set change event listeners. */ - private LinkedList propertySetChangeListeners = null; + private LinkedList<Container.PropertySetChangeListener> propertySetChangeListeners = null; /** * List of all container Item set change event listeners. */ - private LinkedList itemSetChangeListeners = null; + private LinkedList<Container.ItemSetChangeListener> itemSetChangeListeners = null; /** * The item sorter which is used for sorting the container. @@ -125,9 +127,9 @@ public class IndexedContainer implements Container.Indexed, public IndexedContainer() { } - public IndexedContainer(Collection itemIds) { + public IndexedContainer(Collection<?> itemIds) { if (items != null) { - for (final Iterator i = itemIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = itemIds.iterator(); i.hasNext();) { this.addItem(i.next()); } } @@ -155,7 +157,7 @@ public class IndexedContainer implements Container.Indexed, * * @see com.vaadin.data.Container#getItemIds() */ - public Collection getItemIds() { + public Collection<?> getItemIds() { if (filteredItemIds != null) { return Collections.unmodifiableCollection(filteredItemIds); } @@ -167,7 +169,7 @@ public class IndexedContainer implements Container.Indexed, * * @see com.vaadin.data.Container#getContainerPropertyIds() */ - public Collection getContainerPropertyIds() { + public Collection<?> getContainerPropertyIds() { return Collections.unmodifiableCollection(propertyIds); } @@ -178,8 +180,8 @@ public class IndexedContainer implements Container.Indexed, * the ID of the Property. * @return Type of the requested Property */ - public Class getType(Object propertyId) { - return (Class) types.get(propertyId); + public Class<?> getType(Object propertyId) { + return types.get(propertyId); } /* @@ -255,7 +257,7 @@ public class IndexedContainer implements Container.Indexed, // If default value is given, set it if (defaultValue != null) { // for existing rows - for (final Iterator i = itemIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = itemIds.iterator(); i.hasNext();) { getItem(i.next()).getItemProperty(propertyId).setValue( defaultValue); } @@ -322,7 +324,7 @@ public class IndexedContainer implements Container.Indexed, // Adds the Item to container (at the end of the unfiltered list) itemIds.add(itemId); - Hashtable t = new Hashtable(); + Hashtable<Object, Object> t = new Hashtable<Object, Object>(); items.put(itemId, t); addDefaultValues(t); @@ -347,7 +349,7 @@ public class IndexedContainer implements Container.Indexed, * @param t * data table of added item */ - private void addDefaultValues(Hashtable t) { + private void addDefaultValues(Hashtable<Object, Object> t) { if (defaultPropertyValues != null) { for (Object key : defaultPropertyValues.keySet()) { t.put(key, defaultPropertyValues.get(key)); @@ -398,8 +400,8 @@ public class IndexedContainer implements Container.Indexed, } // If remove the Property from all Items - for (final Iterator i = itemIds.iterator(); i.hasNext();) { - ((Hashtable) items.get(i.next())).remove(propertyId); + for (final Iterator<Object> i = itemIds.iterator(); i.hasNext();) { + items.get(i.next()).remove(propertyId); } // Sends a change event @@ -435,7 +437,7 @@ public class IndexedContainer implements Container.Indexed, public Object lastItemId() { try { if (filteredItemIds != null) { - final Iterator i = filteredItemIds.iterator(); + final Iterator<?> i = filteredItemIds.iterator(); Object last = null; while (i.hasNext()) { last = i.next(); @@ -458,7 +460,7 @@ public class IndexedContainer implements Container.Indexed, if (itemId == null || !filteredItemIds.contains(itemId)) { return null; } - final Iterator i = filteredItemIds.iterator(); + final Iterator<?> i = filteredItemIds.iterator(); while (i.hasNext() && !itemId.equals(i.next())) { ; } @@ -490,7 +492,7 @@ public class IndexedContainer implements Container.Indexed, if (!filteredItemIds.contains(itemId)) { return null; } - final Iterator i = filteredItemIds.iterator(); + final Iterator<?> i = filteredItemIds.iterator(); if (itemId == null) { return null; } @@ -534,7 +536,8 @@ public class IndexedContainer implements Container.Indexed, if (filteredItemIds != null) { try { Object last = null; - for (final Iterator i = filteredItemIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = filteredItemIds.iterator(); i + .hasNext();) { last = i.next(); } return (itemId != null && itemId.equals(last)); @@ -599,7 +602,7 @@ public class IndexedContainer implements Container.Indexed, throw new IndexOutOfBoundsException(); } try { - final Iterator i = filteredItemIds.iterator(); + final Iterator<?> i = filteredItemIds.iterator(); while (index-- > 0) { i.next(); } @@ -623,7 +626,7 @@ public class IndexedContainer implements Container.Indexed, if (itemId == null) { return -1; } - final Iterator i = filteredItemIds.iterator(); + final Iterator<?> i = filteredItemIds.iterator(); while (i.hasNext()) { Object id = i.next(); if (itemId.equals(id)) { @@ -720,7 +723,7 @@ public class IndexedContainer implements Container.Indexed, // Adds the Item to container itemIds.add(index, newItemId); - Hashtable t = new Hashtable(); + Hashtable<Object, Object> t = new Hashtable<Object, Object>(); items.put(newItemId, t); addDefaultValues(t); @@ -836,7 +839,7 @@ public class IndexedContainer implements Container.Indexed, */ public void addListener(Container.PropertySetChangeListener listener) { if (propertySetChangeListeners == null) { - propertySetChangeListeners = new LinkedList(); + propertySetChangeListeners = new LinkedList<Container.PropertySetChangeListener>(); } propertySetChangeListeners.add(listener); } @@ -861,7 +864,7 @@ public class IndexedContainer implements Container.Indexed, */ public void addListener(Container.ItemSetChangeListener listener) { if (itemSetChangeListeners == null) { - itemSetChangeListeners = new LinkedList(); + itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>(); } itemSetChangeListeners.add(listener); } @@ -886,7 +889,7 @@ public class IndexedContainer implements Container.Indexed, */ public void addListener(Property.ValueChangeListener listener) { if (propertyValueChangeListeners == null) { - propertyValueChangeListeners = new LinkedList(); + propertyValueChangeListeners = new LinkedList<Property.ValueChangeListener>(); } propertyValueChangeListeners.add(listener); } @@ -923,10 +926,10 @@ public class IndexedContainer implements Container.Indexed, // Sends event to single property value change listeners if (singlePropertyValueChangeListeners != null) { - final Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners + final Map<Object, List<Property.ValueChangeListener>> propertySetToListenerListMap = singlePropertyValueChangeListeners .get(source.propertyId); if (propertySetToListenerListMap != null) { - final LinkedList listenerList = (LinkedList) propertySetToListenerListMap + final List<Property.ValueChangeListener> listenerList = propertySetToListenerListMap .get(source.itemId); if (listenerList != null) { final Property.ValueChangeEvent event = new IndexedContainer.PropertyValueChangeEvent( @@ -989,22 +992,22 @@ public class IndexedContainer implements Container.Indexed, Object itemId, Property.ValueChangeListener listener) { if (listener != null) { if (singlePropertyValueChangeListeners == null) { - singlePropertyValueChangeListeners = new Hashtable(); + singlePropertyValueChangeListeners = new Hashtable<Object, Map<Object, List<Property.ValueChangeListener>>>(); } - Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners + Map<Object, List<Property.ValueChangeListener>> propertySetToListenerListMap = singlePropertyValueChangeListeners .get(propertyId); if (propertySetToListenerListMap == null) { - propertySetToListenerListMap = new Hashtable(); + propertySetToListenerListMap = new Hashtable<Object, List<Property.ValueChangeListener>>(); singlePropertyValueChangeListeners.put(propertyId, propertySetToListenerListMap); } - LinkedList listenerList = (LinkedList) propertySetToListenerListMap + List<Property.ValueChangeListener> listenerList = propertySetToListenerListMap .get(itemId); if (listenerList == null) { - listenerList = new LinkedList(); + listenerList = new LinkedList<Property.ValueChangeListener>(); propertySetToListenerListMap.put(itemId, listenerList); } - listenerList.addLast(listener); + listenerList.add(listener); } } @@ -1021,10 +1024,10 @@ public class IndexedContainer implements Container.Indexed, private void removeSinglePropertyChangeListener(Object propertyId, Object itemId, Property.ValueChangeListener listener) { if (listener != null && singlePropertyValueChangeListeners != null) { - final Hashtable propertySetToListenerListMap = (Hashtable) singlePropertyValueChangeListeners + final Map<Object, List<Property.ValueChangeListener>> propertySetToListenerListMap = singlePropertyValueChangeListeners .get(propertyId); if (propertySetToListenerListMap != null) { - final LinkedList listenerList = (LinkedList) propertySetToListenerListMap + final List<Property.ValueChangeListener> listenerList = propertySetToListenerListMap .get(itemId); if (listenerList != null) { listenerList.remove(listener); @@ -1086,7 +1089,7 @@ public class IndexedContainer implements Container.Indexed, return new IndexedContainerProperty(itemId, id); } - public Collection getItemPropertyIds() { + public Collection<?> getItemPropertyIds() { return Collections.unmodifiableCollection(propertyIds); } @@ -1102,7 +1105,7 @@ public class IndexedContainer implements Container.Indexed, public String toString() { String retValue = ""; - for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) { final Object propertyId = i.next(); retValue += getItemProperty(propertyId).toString(); if (i.hasNext()) { @@ -1227,8 +1230,8 @@ public class IndexedContainer implements Container.Indexed, * * @see com.vaadin.data.Property#getType() */ - public Class getType() { - return (Class) types.get(propertyId); + public Class<?> getType() { + return types.get(propertyId); } /* @@ -1237,7 +1240,7 @@ public class IndexedContainer implements Container.Indexed, * @see com.vaadin.data.Property#getValue() */ public Object getValue() { - return ((Hashtable) items.get(itemId)).get(propertyId); + return items.get(itemId).get(propertyId); } /* @@ -1271,7 +1274,7 @@ public class IndexedContainer implements Container.Indexed, throws Property.ReadOnlyException, Property.ConversionException { // Gets the Property set - final Hashtable propertySet = (Hashtable) items.get(itemId); + final Map<Object, Object> propertySet = items.get(itemId); // Support null values on all types if (newValue == null) { @@ -1282,7 +1285,7 @@ public class IndexedContainer implements Container.Indexed, try { // Gets the string constructor - final Constructor constr = getType().getConstructor( + final Constructor<?> constr = getType().getConstructor( new Class[] { String.class }); // Creates new object from the string @@ -1423,10 +1426,10 @@ public class IndexedContainer implements Container.Indexed, */ public Collection<?> getSortableContainerPropertyIds() { - final LinkedList list = new LinkedList(); - for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + final List<Object> list = new LinkedList<Object>(); + for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) { final Object id = i.next(); - final Class type = getType(id); + final Class<?> type = getType(id); if (type != null && Comparable.class.isAssignableFrom(type)) { list.add(id); } @@ -1470,36 +1473,39 @@ public class IndexedContainer implements Container.Indexed, final IndexedContainer nc = new IndexedContainer(); // Clone the shallow properties - nc.itemIds = itemIds != null ? (ArrayList) itemIds.clone() : null; - nc.itemSetChangeListeners = itemSetChangeListeners != null ? (LinkedList) itemSetChangeListeners - .clone() : null; - nc.propertyIds = propertyIds != null ? (ArrayList) propertyIds.clone() + nc.itemIds = itemIds != null ? (ArrayList<Object>) itemIds.clone() : null; - nc.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners + nc.itemSetChangeListeners = itemSetChangeListeners != null ? (LinkedList<Container.ItemSetChangeListener>) itemSetChangeListeners + .clone() : null; + nc.propertyIds = propertyIds != null ? (ArrayList<Object>) propertyIds + .clone() : null; + nc.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList<Container.PropertySetChangeListener>) propertySetChangeListeners .clone() : null; - nc.propertyValueChangeListeners = propertyValueChangeListeners != null ? (LinkedList) propertyValueChangeListeners + nc.propertyValueChangeListeners = propertyValueChangeListeners != null ? (LinkedList<Property.ValueChangeListener>) propertyValueChangeListeners .clone() : null; - nc.readOnlyProperties = readOnlyProperties != null ? (HashSet) readOnlyProperties + nc.readOnlyProperties = readOnlyProperties != null ? (HashSet<Property>) readOnlyProperties .clone() : null; - nc.singlePropertyValueChangeListeners = singlePropertyValueChangeListeners != null ? (Hashtable) singlePropertyValueChangeListeners + nc.singlePropertyValueChangeListeners = singlePropertyValueChangeListeners != null ? (Hashtable<Object, Map<Object, List<Property.ValueChangeListener>>>) singlePropertyValueChangeListeners .clone() : null; - nc.types = types != null ? (Hashtable) types.clone() : null; + nc.types = types != null ? (Hashtable<Object, Class<?>>) types.clone() + : null; nc.filters = filters == null ? null : (HashSet<Filter>) filters.clone(); nc.filteredItemIds = filteredItemIds == null ? null - : (LinkedHashSet) filteredItemIds.clone(); + : (LinkedHashSet<Object>) filteredItemIds.clone(); // Clone property-values if (items == null) { nc.items = null; } else { - nc.items = new Hashtable(); - for (final Iterator i = items.keySet().iterator(); i.hasNext();) { + nc.items = new Hashtable<Object, Map<Object, Object>>(); + for (final Iterator<?> i = items.keySet().iterator(); i.hasNext();) { final Object id = i.next(); - final Hashtable it = (Hashtable) items.get(id); - nc.items.put(id, it.clone()); + final Hashtable<Object, Object> it = (Hashtable<Object, Object>) items + .get(id); + nc.items.put(id, (Map<Object, Object>) it.clone()); } } @@ -1592,13 +1598,13 @@ public class IndexedContainer implements Container.Indexed, } // Reset filtered list if (filteredItemIds == null) { - filteredItemIds = new LinkedHashSet(); + filteredItemIds = new LinkedHashSet<Object>(); } else { filteredItemIds.clear(); } // Filter - for (final Iterator i = itemIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = itemIds.iterator(); i.hasNext();) { final Object id = i.next(); if (passesFilters(id)) { filteredItemIds.add(id); @@ -1624,9 +1630,6 @@ public class IndexedContainer implements Container.Indexed, if (filters == null) { return true; } - if (item == null) { - return false; - } final Iterator<Filter> i = filters.iterator(); while (i.hasNext()) { final Filter f = i.next(); diff --git a/src/com/vaadin/data/util/MethodProperty.java b/src/com/vaadin/data/util/MethodProperty.java index e95d1ed817..6cfa5e87b7 100644 --- a/src/com/vaadin/data/util/MethodProperty.java +++ b/src/com/vaadin/data/util/MethodProperty.java @@ -9,6 +9,8 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.LinkedList; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.data.Property; import com.vaadin.util.SerializerHelper; @@ -46,9 +48,11 @@ import com.vaadin.util.SerializerHelper; * @since 3.0 */ @SuppressWarnings("serial") -public class MethodProperty implements Property, Property.ValueChangeNotifier, - Property.ReadOnlyStatusChangeNotifier { +public class MethodProperty<T> implements Property, + Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { + private static final Logger logger = Logger.getLogger(MethodProperty.class + .getName()); /** * The object that includes the property the MethodProperty is bound to. */ @@ -79,7 +83,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, /** * Type of the property. */ - private transient Class<?> type; + private transient Class<? extends T> type; /** * List of listeners who are interested in the read-only status changes of @@ -123,7 +127,10 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, ClassNotFoundException { in.defaultReadObject(); try { - type = SerializerHelper.readClass(in); + @SuppressWarnings("unchecked") + // business assumption; type parameters not checked at runtime + Class<T> class1 = (Class<T>) SerializerHelper.readClass(in); + type = class1; instance = in.readObject(); setArgs = (Object[]) in.readObject(); getArgs = (Object[]) in.readObject(); @@ -143,11 +150,9 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, getMethod = null; } } catch (SecurityException e) { - System.err.println("Internal deserialization error"); - e.printStackTrace(); + logger.log(Level.SEVERE, "Internal deserialization error", e); } catch (NoSuchMethodException e) { - System.err.println("Internal deserialization error"); - e.printStackTrace(); + logger.log(Level.SEVERE, "Internal deserialization error", e); } }; @@ -171,7 +176,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * </p> * * <p> - * Method names are constucted from the bean property by adding + * Method names are constructed from the bean property by adding * get/is/are/set prefix and capitalising the first character in the name of * the given bean property. * </p> @@ -208,42 +213,48 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, getMethod = beanClass.getMethod("are" + beanPropertyName, new Class[] {}); } catch (final java.lang.NoSuchMethodException e) { - throw new MethodProperty.MethodException("Bean property " + throw new MethodException(this, "Bean property " + beanPropertyName + " can not be found"); } } } // In case the get method is found, resolve the type - type = getMethod.getReturnType(); + Class<?> returnType = getMethod.getReturnType(); // Finds the set method setMethod = null; try { setMethod = beanClass.getMethod("set" + beanPropertyName, - new Class[] { type }); + new Class[] { returnType }); } catch (final java.lang.NoSuchMethodException skipped) { } // Gets the return type from get method - if (type.isPrimitive()) { - if (type.equals(Boolean.TYPE)) { - type = Boolean.class; - } else if (type.equals(Integer.TYPE)) { - type = Integer.class; - } else if (type.equals(Float.TYPE)) { - type = Float.class; - } else if (type.equals(Double.TYPE)) { - type = Double.class; - } else if (type.equals(Byte.TYPE)) { - type = Byte.class; - } else if (type.equals(Character.TYPE)) { - type = Character.class; - } else if (type.equals(Short.TYPE)) { - type = Short.class; - } else if (type.equals(Long.TYPE)) { - type = Long.class; + if (returnType.isPrimitive()) { + if (returnType.equals(Boolean.TYPE)) { + type = (Class<T>) Boolean.class; + } else if (returnType.equals(Integer.TYPE)) { + type = (Class<T>) Integer.class; + } else if (returnType.equals(Float.TYPE)) { + type = (Class<T>) Float.class; + } else if (returnType.equals(Double.TYPE)) { + type = (Class<T>) Double.class; + } else if (returnType.equals(Byte.TYPE)) { + type = (Class<T>) Byte.class; + } else if (returnType.equals(Character.TYPE)) { + type = (Class<T>) Character.class; + } else if (returnType.equals(Short.TYPE)) { + type = (Class<T>) Short.class; + } else if (returnType.equals(Long.TYPE)) { + type = (Class<T>) Long.class; + } else { + throw new MethodException(this, "Bean property " + + beanPropertyName + + " getter return type must not be void"); } + } else { + type = (Class<T>) returnType; } setArguments(new Object[] {}, new Object[] { null }, 0); @@ -275,9 +286,8 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * the name of the setter method. * */ - @SuppressWarnings("unchecked") - public MethodProperty(Class type, Object instance, String getMethodName, - String setMethodName) { + public MethodProperty(Class<? extends T> type, Object instance, + String getMethodName, String setMethodName) { this(type, instance, getMethodName, setMethodName, new Object[] {}, new Object[] { null }, 0); } @@ -305,9 +315,8 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * @param setMethod * the setter method. */ - @SuppressWarnings("unchecked") - public MethodProperty(Class type, Object instance, Method getMethod, - Method setMethod) { + public MethodProperty(Class<? extends T> type, Object instance, + Method getMethod, Method setMethod) { this(type, instance, getMethod, setMethod, new Object[] {}, new Object[] { null }, 0); } @@ -349,9 +358,9 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * {@link #setValue(Object newValue)} is called. */ @SuppressWarnings("unchecked") - public MethodProperty(Class type, Object instance, String getMethodName, - String setMethodName, Object[] getArgs, Object[] setArgs, - int setArgumentIndex) { + public MethodProperty(Class<? extends T> type, Object instance, + String getMethodName, String setMethodName, Object[] getArgs, + Object[] setArgs, int setArgumentIndex) { // Check the setargs and setargs index if (setMethodName != null && setArgs == null) { @@ -406,7 +415,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, // all paramteters matched if (found == true) { - throw new MethodProperty.MethodException( + throw new MethodException(this, "Could not uniquely identify " + getMethodName + "-method"); } else { @@ -416,8 +425,8 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, } } if (found != true) { - throw new MethodProperty.MethodException("Could not find " - + getMethodName + "-method"); + throw new MethodException(this, "Could not find " + getMethodName + + "-method"); } // Finds set method @@ -459,7 +468,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, // all parameters match if (found == true) { - throw new MethodProperty.MethodException( + throw new MethodException(this, "Could not identify unique " + setMethodName + "-method"); } else { @@ -469,7 +478,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, } } if (found != true) { - throw new MethodProperty.MethodException("Could not identify " + throw new MethodException(this, "Could not identify " + setMethodName + "-method"); } } @@ -477,21 +486,21 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, // Gets the return type from get method if (type.isPrimitive()) { if (type.equals(Boolean.TYPE)) { - this.type = Boolean.class; + this.type = (Class<T>) Boolean.class; } else if (type.equals(Integer.TYPE)) { - this.type = Integer.class; + this.type = (Class<T>) Integer.class; } else if (type.equals(Float.TYPE)) { - this.type = Float.class; + this.type = (Class<T>) Float.class; } else if (type.equals(Double.TYPE)) { - this.type = Double.class; + this.type = (Class<T>) Double.class; } else if (type.equals(Byte.TYPE)) { - this.type = Byte.class; + this.type = (Class<T>) Byte.class; } else if (type.equals(Character.TYPE)) { - this.type = Character.class; + this.type = (Class<T>) Character.class; } else if (type.equals(Short.TYPE)) { - this.type = Short.class; + this.type = (Class<T>) Short.class; } else if (type.equals(Long.TYPE)) { - this.type = Long.class; + this.type = (Class<T>) Long.class; } } @@ -535,7 +544,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, int setArgumentIndex) { if (getMethod == null) { - throw new MethodProperty.MethodException( + throw new MethodException(this, "Property GET-method cannot not be null: " + type); } @@ -615,7 +624,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, try { return getMethod.invoke(instance, getArgs); } catch (final Throwable e) { - throw new MethodProperty.MethodException(e); + throw new MethodException(this, e); } } @@ -733,9 +742,9 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, } } catch (final InvocationTargetException e) { final Throwable targetException = e.getTargetException(); - throw new MethodProperty.MethodException(targetException); + throw new MethodException(this, targetException); } catch (final Exception e) { - throw new MethodProperty.MethodException(e); + throw new MethodException(this, e); } } @@ -767,7 +776,14 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * @VERSION@ * @since 3.0 */ - public class MethodException extends RuntimeException { + @SuppressWarnings("rawtypes") + // Exceptions cannot be parameterized, ever. + public static class MethodException extends RuntimeException { + + /** + * The method property from which the exception originates from + */ + private final MethodProperty methodProperty; /** * Cause of the method exception @@ -778,20 +794,26 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * Constructs a new <code>MethodException</code> with the specified * detail message. * + * @param methodProperty + * the method property. * @param msg * the detail message. */ - public MethodException(String msg) { + public MethodException(MethodProperty methodProperty, String msg) { super(msg); + this.methodProperty = methodProperty; } /** * Constructs a new <code>MethodException</code> from another exception. * + * @param methodProperty + * the method property. * @param cause * the cause of the exception. */ - public MethodException(Throwable cause) { + public MethodException(MethodProperty methodProperty, Throwable cause) { + this.methodProperty = methodProperty; this.cause = cause; } @@ -807,7 +829,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * Gets the method property this exception originates from. */ public MethodProperty getMethodProperty() { - return MethodProperty.this; + return methodProperty; } } @@ -831,7 +853,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * @param source * source object of the event. */ - protected ReadOnlyStatusChangeEvent(MethodProperty source) { + protected ReadOnlyStatusChangeEvent(MethodProperty<T> source) { super(source); } @@ -877,7 +899,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, private void fireReadOnlyStatusChange() { if (readOnlyStatusChangeListeners != null) { final Object[] l = readOnlyStatusChangeListeners.toArray(); - final Property.ReadOnlyStatusChangeEvent event = new MethodProperty.ReadOnlyStatusChangeEvent( + final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Property.ReadOnlyStatusChangeListener) l[i]) @@ -904,7 +926,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, * @param source * source object of the event. */ - protected ValueChangeEvent(MethodProperty source) { + protected ValueChangeEvent(MethodProperty<T> source) { super(source); } @@ -940,8 +962,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, public void fireValueChange() { if (valueChangeListeners != null) { final Object[] l = valueChangeListeners.toArray(); - final Property.ValueChangeEvent event = new MethodProperty.ValueChangeEvent( - this); + final Property.ValueChangeEvent event = new ValueChangeEvent(this); for (int i = 0; i < l.length; i++) { ((Property.ValueChangeListener) l[i]).valueChange(event); } diff --git a/src/com/vaadin/data/util/ObjectProperty.java b/src/com/vaadin/data/util/ObjectProperty.java index 8993b74a1e..6724f1d40f 100644 --- a/src/com/vaadin/data/util/ObjectProperty.java +++ b/src/com/vaadin/data/util/ObjectProperty.java @@ -20,8 +20,8 @@ import com.vaadin.data.Property; * @since 3.0 */ @SuppressWarnings("serial") -public class ObjectProperty implements Property, Property.ValueChangeNotifier, - Property.ReadOnlyStatusChangeNotifier { +public class ObjectProperty<T> implements Property, + Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { /** * A boolean value storing the Property's read-only status information. @@ -31,22 +31,22 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, /** * The value contained by the Property. */ - private Object value; + private T value; /** * Data type of the Property's value. */ - private final Class type; + private final Class<T> type; /** * Internal list of registered value change listeners. */ - private LinkedList valueChangeListeners = null; + private LinkedList<ValueChangeListener> valueChangeListeners = null; /** * Internal list of registered read-only status change listeners. */ - private LinkedList readOnlyStatusChangeListeners = null; + private LinkedList<ReadOnlyStatusChangeListener> readOnlyStatusChangeListeners = null; /** * Creates a new instance of ObjectProperty with the given value. The type @@ -56,20 +56,26 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * @param value * the Initial value of the Property. */ - public ObjectProperty(Object value) { - this(value, value.getClass()); + @SuppressWarnings("unchecked") + // the cast is safe, because an object of type T has class Class<T> + public ObjectProperty(T value) { + this(value, (Class<T>) value.getClass()); } /** * Creates a new instance of ObjectProperty with the given value and type. * + * Any value of type Object is accepted because, if the type class contains + * a string constructor, the toString of the value is used to create the new + * value. See {@link #setValue(Object)}. + * * @param value * the Initial value of the Property. * @param type * the type of the value. The value must be assignable to given * type. */ - public ObjectProperty(Object value, Class type) { + public ObjectProperty(Object value, Class<T> type) { // Set the values this.type = type; @@ -80,6 +86,9 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * Creates a new instance of ObjectProperty with the given value, type and * read-only mode status. * + * Any value of type Object is accepted, see + * {@link #ObjectProperty(Object, Class)}. + * * @param value * the Initial value of the property. * @param type @@ -88,7 +97,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * @param readOnly * Sets the read-only mode. */ - public ObjectProperty(Object value, Class type, boolean readOnly) { + public ObjectProperty(Object value, Class<T> type, boolean readOnly) { this(value, type); setReadOnly(readOnly); } @@ -102,7 +111,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * * @return type of the Property */ - public final Class getType() { + public final Class<T> getType() { return type; } @@ -111,7 +120,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * * @return the value stored in the Property */ - public Object getValue() { + public T getValue() { return value; } @@ -182,12 +191,15 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, // Tries to assign the compatible value directly if (newValue == null || type.isAssignableFrom(newValue.getClass())) { - value = newValue; + @SuppressWarnings("unchecked") + // the cast is safe after an isAssignableFrom check + T value = (T) newValue; + this.value = value; } else { try { // Gets the string constructor - final Constructor constr = getType().getConstructor( + final Constructor<T> constr = getType().getConstructor( new Class[] { String.class }); // Creates new object from the string @@ -222,7 +234,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * @param source * the source object of the event. */ - protected ValueChangeEvent(ObjectProperty source) { + protected ValueChangeEvent(ObjectProperty<T> source) { super(source); } @@ -254,7 +266,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, * @param source * source object of the event */ - protected ReadOnlyStatusChangeEvent(ObjectProperty source) { + protected ReadOnlyStatusChangeEvent(ObjectProperty<T> source) { super(source); } @@ -288,7 +300,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, */ public void addListener(Property.ValueChangeListener listener) { if (valueChangeListeners == null) { - valueChangeListeners = new LinkedList(); + valueChangeListeners = new LinkedList<ValueChangeListener>(); } valueChangeListeners.add(listener); } @@ -301,7 +313,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, */ public void addListener(Property.ReadOnlyStatusChangeListener listener) { if (readOnlyStatusChangeListeners == null) { - readOnlyStatusChangeListeners = new LinkedList(); + readOnlyStatusChangeListeners = new LinkedList<ReadOnlyStatusChangeListener>(); } readOnlyStatusChangeListeners.add(listener); } @@ -324,8 +336,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, private void fireValueChange() { if (valueChangeListeners != null) { final Object[] l = valueChangeListeners.toArray(); - final Property.ValueChangeEvent event = new ObjectProperty.ValueChangeEvent( - this); + final Property.ValueChangeEvent event = new ValueChangeEvent(this); for (int i = 0; i < l.length; i++) { ((Property.ValueChangeListener) l[i]).valueChange(event); } @@ -338,7 +349,7 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, private void fireReadOnlyStatusChange() { if (readOnlyStatusChangeListeners != null) { final Object[] l = readOnlyStatusChangeListeners.toArray(); - final Property.ReadOnlyStatusChangeEvent event = new ObjectProperty.ReadOnlyStatusChangeEvent( + final Property.ReadOnlyStatusChangeEvent event = new ReadOnlyStatusChangeEvent( this); for (int i = 0; i < l.length; i++) { ((Property.ReadOnlyStatusChangeListener) l[i]) diff --git a/src/com/vaadin/data/util/PropertyFormatter.java b/src/com/vaadin/data/util/PropertyFormatter.java index df2a2e47f3..23e4fb324f 100644 --- a/src/com/vaadin/data/util/PropertyFormatter.java +++ b/src/com/vaadin/data/util/PropertyFormatter.java @@ -8,7 +8,7 @@ import java.util.LinkedList; import com.vaadin.data.Property; /** - * Formatting proxy for a property. + * Formatting proxy for a {@link Property}. * * <p> * This class can be used to implement formatting for any type of Property @@ -18,7 +18,7 @@ import com.vaadin.data.Property; * * <p> * For example <code> - * textfield.setPropertyDataSource(new PropertyFormatter(property) { + * <pre>textfield.setPropertyDataSource(new PropertyFormatter(property) { public String format(Object value) { return ((Double) value).toString() + "000000000"; } @@ -27,8 +27,8 @@ import com.vaadin.data.Property; return Double.parseDouble(formattedValue); } - });</code> adds formatter for Double-typed property that extends standard - * "1.0" notation with more zeroes. + });</pre></code> adds formatter for Double-typed property that extends + * standard "1.0" notation with more zeroes. * </p> * * @author IT Mill Ltd. @@ -43,12 +43,12 @@ public abstract class PropertyFormatter implements Property, /** * Internal list of registered value change listeners. */ - private LinkedList valueChangeListeners = null; + private LinkedList<Property.ValueChangeListener> valueChangeListeners = null; /** * Internal list of registered read-only status change listeners. */ - private LinkedList readOnlyStatusChangeListeners = null; + private LinkedList<Property.ReadOnlyStatusChangeListener> readOnlyStatusChangeListeners = null; /** Datasource that stores the actual value. */ Property dataSource; @@ -316,7 +316,7 @@ public abstract class PropertyFormatter implements Property, */ public void addListener(Property.ValueChangeListener listener) { if (valueChangeListeners == null) { - valueChangeListeners = new LinkedList(); + valueChangeListeners = new LinkedList<Property.ValueChangeListener>(); } valueChangeListeners.add(listener); } @@ -329,7 +329,7 @@ public abstract class PropertyFormatter implements Property, */ public void addListener(Property.ReadOnlyStatusChangeListener listener) { if (readOnlyStatusChangeListeners == null) { - readOnlyStatusChangeListeners = new LinkedList(); + readOnlyStatusChangeListeners = new LinkedList<Property.ReadOnlyStatusChangeListener>(); } readOnlyStatusChangeListeners.add(listener); } diff --git a/src/com/vaadin/data/util/PropertysetItem.java b/src/com/vaadin/data/util/PropertysetItem.java index 1f1398983c..75f9114bc7 100644 --- a/src/com/vaadin/data/util/PropertysetItem.java +++ b/src/com/vaadin/data/util/PropertysetItem.java @@ -34,17 +34,17 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, /** * Mapping from property id to property. */ - private HashMap map = new HashMap(); + private HashMap<Object, Property> map = new HashMap<Object, Property>(); /** * List of all property ids to maintain the order. */ - private LinkedList list = new LinkedList(); + private LinkedList<Object> list = new LinkedList<Object>(); /** * List of property set modification listeners. */ - private LinkedList propertySetChangeListeners = null; + private LinkedList<Item.PropertySetChangeListener> propertySetChangeListeners = null; /* Item methods */ @@ -58,7 +58,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, * @return the Property with the given ID or <code>null</code> */ public Property getItemProperty(Object id) { - return (Property) map.get(id); + return map.get(id); } /** @@ -67,7 +67,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, * @return unmodifiable collection containing IDs of the Properties stored * the Item */ - public Collection getItemPropertyIds() { + public Collection<?> getItemPropertyIds() { return Collections.unmodifiableCollection(list); } @@ -141,7 +141,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, public String toString() { String retValue = ""; - for (final Iterator i = getItemPropertyIds().iterator(); i.hasNext();) { + for (final Iterator<?> i = getItemPropertyIds().iterator(); i.hasNext();) { final Object propertyId = i.next(); retValue += getItemProperty(propertyId).toString(); if (i.hasNext()) { @@ -188,7 +188,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, */ public void addListener(Item.PropertySetChangeListener listener) { if (propertySetChangeListeners == null) { - propertySetChangeListeners = new LinkedList(); + propertySetChangeListeners = new LinkedList<PropertySetChangeListener>(); } propertySetChangeListeners.add(listener); } @@ -246,10 +246,10 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, final PropertysetItem npsi = new PropertysetItem(); - npsi.list = list != null ? (LinkedList) list.clone() : null; - npsi.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList) propertySetChangeListeners + npsi.list = list != null ? (LinkedList<Object>) list.clone() : null; + npsi.propertySetChangeListeners = propertySetChangeListeners != null ? (LinkedList<PropertySetChangeListener>) propertySetChangeListeners .clone() : null; - npsi.map = (HashMap) map.clone(); + npsi.map = (HashMap<Object, Property>) map.clone(); return npsi; } @@ -285,7 +285,14 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, } } if (other.propertySetChangeListeners != propertySetChangeListeners) { - if (other.propertySetChangeListeners == null) { + boolean thisEmpty = (propertySetChangeListeners == null || propertySetChangeListeners + .isEmpty()); + boolean otherEmpty = (other.propertySetChangeListeners == null || other.propertySetChangeListeners + .isEmpty()); + if (thisEmpty && otherEmpty) { + return true; + } + if (otherEmpty) { return false; } if (!other.propertySetChangeListeners @@ -307,7 +314,7 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, return (list == null ? 0 : list.hashCode()) ^ (map == null ? 0 : map.hashCode()) - ^ (propertySetChangeListeners == null ? 0 - : propertySetChangeListeners.hashCode()); + ^ ((propertySetChangeListeners == null || propertySetChangeListeners + .isEmpty()) ? 0 : propertySetChangeListeners.hashCode()); } } diff --git a/src/com/vaadin/data/util/QueryContainer.java b/src/com/vaadin/data/util/QueryContainer.java index 21aef731b0..2b9cf2e1e1 100644 --- a/src/com/vaadin/data/util/QueryContainer.java +++ b/src/com/vaadin/data/util/QueryContainer.java @@ -66,9 +66,9 @@ public class QueryContainer implements Container, Container.Ordered, private ResultSet result; - private Collection propertyIds; + private Collection<String> propertyIds; - private final HashMap propertyTypes = new HashMap(); + private final HashMap<String, Class<?>> propertyTypes = new HashMap<String, Class<?>>(); private int size = -1; @@ -129,7 +129,7 @@ public class QueryContainer implements Container, Container.Ordered, ResultSetMetaData metadata; metadata = result.getMetaData(); final int count = metadata.getColumnCount(); - final ArrayList list = new ArrayList(count); + final ArrayList<String> list = new ArrayList<String>(count); for (int i = 1; i <= count; i++) { final String columnName = metadata.getColumnName(i); list.add(columnName); @@ -194,7 +194,7 @@ public class QueryContainer implements Container, Container.Ordered, * @return Collection of Property ID. */ - public Collection getContainerPropertyIds() { + public Collection<String> getContainerPropertyIds() { return propertyIds; } @@ -203,8 +203,8 @@ public class QueryContainer implements Container, Container.Ordered, * * @return collection of Item IDs */ - public Collection getItemIds() { - final Collection c = new ArrayList(size); + public Collection<?> getItemIds() { + final Collection<Integer> c = new ArrayList<Integer>(size); for (int i = 1; i <= size; i++) { c.add(new Integer(i)); } @@ -239,7 +239,8 @@ public class QueryContainer implements Container, Container.Ordered, } // Handle also null values from the database - return new ObjectProperty(value != null ? value : new String("")); + return new ObjectProperty<Object>(value != null ? value + : new String("")); } /** @@ -251,8 +252,8 @@ public class QueryContainer implements Container, Container.Ordered, * @return data type of the Properties */ - public Class getType(Object id) { - return (Class) propertyTypes.get(id); + public Class<?> getType(Object id) { + return propertyTypes.get(id); } /** @@ -537,7 +538,7 @@ public class QueryContainer implements Container, Container.Ordered, * @return unmodifiable collection containing IDs of the Properties * stored the Item. */ - public Collection getItemPropertyIds() { + public Collection<String> getItemPropertyIds() { return propertyIds; } diff --git a/src/com/vaadin/data/util/TextFileProperty.java b/src/com/vaadin/data/util/TextFileProperty.java index 9d1c8b8737..8d99112338 100644 --- a/src/com/vaadin/data/util/TextFileProperty.java +++ b/src/com/vaadin/data/util/TextFileProperty.java @@ -206,7 +206,7 @@ public class TextFileProperty implements Property, Property.ValueChangeNotifier */
public void addListener(Property.ValueChangeListener listener) {
if (valueChangeListeners == null) {
- valueChangeListeners = new LinkedList();
+ valueChangeListeners = new LinkedList<Property.ValueChangeListener>();
}
valueChangeListeners.add(listener);
}
diff --git a/src/com/vaadin/data/validator/AbstractStringValidator.java b/src/com/vaadin/data/validator/AbstractStringValidator.java index 359d83ef10..90778e16b1 100644 --- a/src/com/vaadin/data/validator/AbstractStringValidator.java +++ b/src/com/vaadin/data/validator/AbstractStringValidator.java @@ -42,20 +42,21 @@ public abstract class AbstractStringValidator extends AbstractValidator { * Tests if the given value is a valid string. * <p> * Null values are always accepted. Values that are not {@link String}s are - * always rejected. Uses {@link #isValidString(String)} to validate the - * value. + * converted using {@link #toString()}. Then {@link #isValidString(String)} + * is used to validate the value. * </p> * * @param value * the value to check - * @return true if the value is a valid string, false otherwise + * @return true if the value (or its toString()) is a valid string, false + * otherwise */ public boolean isValid(Object value) { if (value == null) { return true; } if (!(value instanceof String)) { - return false; + value = String.valueOf(value); } return isValidString((String) value); } diff --git a/src/com/vaadin/event/ActionManager.java b/src/com/vaadin/event/ActionManager.java index 621a2413b9..e3d579f4ef 100644 --- a/src/com/vaadin/event/ActionManager.java +++ b/src/com/vaadin/event/ActionManager.java @@ -189,7 +189,7 @@ public class ActionManager implements Action.Container, Action.Handler, clientHasActions = !actions.isEmpty(); } - public void handleActions(Map variables, Container sender) { + public void handleActions(Map<String, Object> variables, Container sender) { if (variables.containsKey("action") && actionMapper != null) { final String key = (String) variables.get("action"); final Action action = (Action) actionMapper.get(key); diff --git a/src/com/vaadin/event/EventRouter.java b/src/com/vaadin/event/EventRouter.java index dd13445e93..dc4f67bf65 100644 --- a/src/com/vaadin/event/EventRouter.java +++ b/src/com/vaadin/event/EventRouter.java @@ -33,7 +33,7 @@ public class EventRouter implements MethodEventSource { * events generated by this component. Don't add a JavaDoc comment here, we * use the default documentation from implemented interface. */ - public void addListener(Class eventType, Object object, Method method) { + public void addListener(Class<?> eventType, Object object, Method method) { if (listenerList == null) { listenerList = new LinkedHashSet<ListenerMethod>(); } @@ -45,7 +45,7 @@ public class EventRouter implements MethodEventSource { * listen events generated by this component. Don't add a JavaDoc comment * here, we use the default documentation from implemented interface. */ - public void addListener(Class eventType, Object object, String methodName) { + public void addListener(Class<?> eventType, Object object, String methodName) { if (listenerList == null) { listenerList = new LinkedHashSet<ListenerMethod>(); } @@ -57,7 +57,7 @@ public class EventRouter implements MethodEventSource { * a JavaDoc comment here, we use the default documentation from implemented * interface. */ - public void removeListener(Class eventType, Object target) { + public void removeListener(Class<?> eventType, Object target) { if (listenerList != null) { final Iterator<ListenerMethod> i = listenerList.iterator(); while (i.hasNext()) { @@ -75,7 +75,7 @@ public class EventRouter implements MethodEventSource { * Don't add a JavaDoc comment here, we use the default documentation from * implemented interface. */ - public void removeListener(Class eventType, Object target, Method method) { + public void removeListener(Class<?> eventType, Object target, Method method) { if (listenerList != null) { final Iterator<ListenerMethod> i = listenerList.iterator(); while (i.hasNext()) { @@ -93,7 +93,8 @@ public class EventRouter implements MethodEventSource { * Don't add a JavaDoc comment here, we use the default documentation from * implemented interface. */ - public void removeListener(Class eventType, Object target, String methodName) { + public void removeListener(Class<?> eventType, Object target, + String methodName) { // Find the correct method final Method[] methods = target.getClass().getMethods(); @@ -152,6 +153,14 @@ public class EventRouter implements MethodEventSource { } } + /** + * Checks if the given Event type is listened by a listener registered to + * this router. + * + * @param eventType + * the event type to be checked + * @return true if a listener is registered for the given event type + */ public boolean hasListeners(Class<?> eventType) { if (listenerList != null) { for (ListenerMethod lm : listenerList) { diff --git a/src/com/vaadin/event/FieldEvents.java b/src/com/vaadin/event/FieldEvents.java index 202b079536..3d539be3ee 100644 --- a/src/com/vaadin/event/FieldEvents.java +++ b/src/com/vaadin/event/FieldEvents.java @@ -11,6 +11,8 @@ import com.vaadin.terminal.gwt.client.EventId; import com.vaadin.tools.ReflectTools;
import com.vaadin.ui.Component;
import com.vaadin.ui.Field;
+import com.vaadin.ui.Field.ValueChangeEvent;
+import com.vaadin.ui.TextField;
/**
* Interface that serves as a wrapper for {@link Field} related events.
@@ -173,4 +175,76 @@ public interface FieldEvents { public void blur(BlurEvent event);
}
+ /**
+ * TextChangeEvents are fired when the user is editing the text content of a
+ * field. Most commonly text change events are triggered by typing text with
+ * keyboard, but e.g. pasting content from clip board to a text field also
+ * triggers an event.
+ * <p>
+ * TextChangeEvents differ from {@link ValueChangeEvent}s so that they are
+ * triggered repeatedly while the end user is filling the field.
+ * ValueChangeEvents are not fired until the user for example hits enter or
+ * focuses another field. Also note the difference that TextChangeEvents are
+ * only fired if the change is triggered from the user, while
+ * ValueChangeEvents are also fired if the field value is set by the
+ * application code.
+ * <p>
+ * The {@link TextChangeNotifier}s implementation may decide when exactly
+ * TextChangeEvents are fired. TextChangeEvents are not necessary fire for
+ * example on each key press, but buffered with a small delay. The
+ * {@link TextField} component supports different modes for triggering
+ * TextChangeEvents.
+ *
+ * @see TextChangeListener
+ * @see TextChangeNotifier
+ * @see TextField#setTextChangeEventMode(com.vaadin.ui.TextField.TextChangeEventMode)
+ * @since 6.5
+ */
+ public static abstract class TextChangeEvent extends Component.Event {
+ public TextChangeEvent(Component source) {
+ super(source);
+ }
+
+ /**
+ * @return the text content of the field after the
+ * {@link TextChangeEvent}
+ */
+ public abstract String getText();
+
+ /**
+ * @return the cursor position during after the {@link TextChangeEvent}
+ */
+ public abstract int getCursorPosition();
+ }
+
+ /**
+ * A listener for {@link TextChangeEvent}s.
+ *
+ * @since 6.5
+ */
+ public interface TextChangeListener extends ComponentEventListener {
+
+ public static String EVENT_ID = "ie";
+ public static Method EVENT_METHOD = ReflectTools.findMethod(
+ TextChangeListener.class, "textChange", TextChangeEvent.class);
+
+ /**
+ * This method is called repeatedly while the text is edited by a user.
+ *
+ * @param event
+ * the event providing details of the text change
+ */
+ public void textChange(TextChangeEvent event);
+ }
+
+ /**
+ * An interface implemented by a {@link Field} supporting
+ * {@link TextChangeEvent}s. An example a {@link TextField} supports
+ * {@link TextChangeListener}s.
+ */
+ public interface TextChangeNotifier extends Serializable {
+ public void addListener(TextChangeListener listener);
+
+ public void removeListener(TextChangeListener listener);
+ }
}
diff --git a/src/com/vaadin/event/ItemClickEvent.java b/src/com/vaadin/event/ItemClickEvent.java index ab8d652c6e..94540aa174 100644 --- a/src/com/vaadin/event/ItemClickEvent.java +++ b/src/com/vaadin/event/ItemClickEvent.java @@ -88,14 +88,35 @@ public class ItemClickEvent extends ClickEvent implements Serializable { * * @link {@link Container} interface may support emitting * {@link ItemClickEvent}s. + * + * @deprecated Use {@link ItemClickNotifier} instead. ItemClickSource was + * deprecated in version 6.5. + */ + @Deprecated + public interface ItemClickSource extends ItemClickNotifier { + } + + /** + * The interface for adding and removing <code>ItemClickEvent</code> + * listeners. By implementing this interface a class explicitly announces + * that it will generate an <code>ItemClickEvent</code> when one of its + * items is clicked. + * <p> + * Note: The general Java convention is not to explicitly declare that a + * class generates events, but to directly define the + * <code>addListener</code> and <code>removeListener</code> methods. That + * way the caller of these methods has no real way of finding out if the + * class really will send the events, or if it just defines the methods to + * be able to implement an interface. + * </p> + * + * @since 6.5 + * @see ItemClickListener + * @see ItemClickEvent */ - public interface ItemClickSource extends Serializable { + public interface ItemClickNotifier extends Serializable { /** - * Register listener to handle ItemClickEvents. - * - * Note! Click listeners are rather terminal dependent features. - * - * This feature is EXPERIMENTAL + * Register a listener to handle {@link ItemClickEvent}s. * * @param listener * ItemClickListener to be registered @@ -103,9 +124,10 @@ public class ItemClickEvent extends ClickEvent implements Serializable { public void addListener(ItemClickListener listener); /** - * Removes ItemClickListener. + * Removes an ItemClickListener. * * @param listener + * ItemClickListener to be removed */ public void removeListener(ItemClickListener listener); } diff --git a/src/com/vaadin/event/ListenerMethod.java b/src/com/vaadin/event/ListenerMethod.java index b294dbf86d..b8ec0b1828 100644 --- a/src/com/vaadin/event/ListenerMethod.java +++ b/src/com/vaadin/event/ListenerMethod.java @@ -11,6 +11,8 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.EventListener; import java.util.EventObject; +import java.util.logging.Level; +import java.util.logging.Logger; /** * <p> @@ -41,6 +43,9 @@ import java.util.EventObject; @SuppressWarnings("serial") public class ListenerMethod implements EventListener, Serializable { + private static final Logger logger = Logger.getLogger(ListenerMethod.class + .getName()); + /** * Type of the event that should trigger this listener. Also the subclasses * of this class are accepted to trigger the listener. @@ -50,7 +55,7 @@ public class ListenerMethod implements EventListener, Serializable { /** * The object containing the trigger method. */ - private Object object; + private final Object object; /** * The trigger method to call when an event passing the given criteria @@ -79,10 +84,9 @@ public class ListenerMethod implements EventListener, Serializable { out.writeObject(name); out.writeObject(paramTypes); } catch (NotSerializableException e) { - System.err - .println("Fatal error in serialization of the application: Class " - + object.getClass().getName() - + " must implement serialization."); + logger.warning("Error in serialization of the application: Class " + + object.getClass().getName() + + " must implement serialization."); throw e; } @@ -99,8 +103,7 @@ public class ListenerMethod implements EventListener, Serializable { // inner classes method = findHighestMethod(object.getClass(), name, paramTypes); } catch (SecurityException e) { - System.err.println("Internal deserialization error"); - e.printStackTrace(); + logger.log(Level.SEVERE, "Internal deserialization error", e); } }; diff --git a/src/com/vaadin/event/MethodEventSource.java b/src/com/vaadin/event/MethodEventSource.java index 680aaad4b8..e6c16ab054 100644 --- a/src/com/vaadin/event/MethodEventSource.java +++ b/src/com/vaadin/event/MethodEventSource.java @@ -48,7 +48,7 @@ public interface MethodEventSource extends Serializable { * unless <code>method</code> has exactly one match in * <code>object</code> */ - public void addListener(Class eventType, Object object, Method method); + public void addListener(Class<?> eventType, Object object, Method method); /** * <p> @@ -81,7 +81,7 @@ public interface MethodEventSource extends Serializable { * unless <code>method</code> has exactly one match in * <code>object</code> */ - public void addListener(Class eventType, Object object, String methodName); + public void addListener(Class<?> eventType, Object object, String methodName); /** * Removes all registered listeners matching the given parameters. Since @@ -101,7 +101,7 @@ public interface MethodEventSource extends Serializable { * the target object that has registered to listen to events of * type <code>eventType</code> with one or more methods. */ - public void removeListener(Class eventType, Object target); + public void removeListener(Class<?> eventType, Object target); /** * Removes one registered listener method. The given method owned by the @@ -122,7 +122,7 @@ public interface MethodEventSource extends Serializable { * the method owned by the target that's registered to listen to * events of type eventType. */ - public void removeListener(Class eventType, Object target, Method method); + public void removeListener(Class<?> eventType, Object target, Method method); /** * <p> @@ -152,5 +152,6 @@ public interface MethodEventSource extends Serializable { * the name of the method owned by <code>target</code> that's * registered to listen to events of type <code>eventType</code>. */ - public void removeListener(Class eventType, Object target, String methodName); + public void removeListener(Class<?> eventType, Object target, + String methodName); } diff --git a/src/com/vaadin/event/MouseEvents.java b/src/com/vaadin/event/MouseEvents.java index 0825961a9c..547a56a9ea 100644 --- a/src/com/vaadin/event/MouseEvents.java +++ b/src/com/vaadin/event/MouseEvents.java @@ -6,7 +6,6 @@ package com.vaadin.event; import java.lang.reflect.Method; -import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.Component; diff --git a/src/com/vaadin/event/ShortcutAction.java b/src/com/vaadin/event/ShortcutAction.java index 9499997176..cd426d2f72 100644 --- a/src/com/vaadin/event/ShortcutAction.java +++ b/src/com/vaadin/event/ShortcutAction.java @@ -8,8 +8,6 @@ import java.io.Serializable; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.vaadin.event.Action.Handler; -import com.vaadin.event.Action.Notifier; import com.vaadin.terminal.Resource; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Panel; diff --git a/src/com/vaadin/launcher/DemoLauncher.java b/src/com/vaadin/launcher/DemoLauncher.java index 38b6060a27..f18cdf636f 100644 --- a/src/com/vaadin/launcher/DemoLauncher.java +++ b/src/com/vaadin/launcher/DemoLauncher.java @@ -36,7 +36,8 @@ public class DemoLauncher { public static void main(String[] args) throws Exception { - final Map serverArgs = DevelopmentServerLauncher.parseArguments(args); + final Map<String, String> serverArgs = DevelopmentServerLauncher + .parseArguments(args); boolean deployed = false; try { // Default deployment: embedded.war @@ -176,7 +177,8 @@ public class DemoLauncher { * @return * @throws IOException */ - protected static boolean deployEmbeddedWarfile(Map args) throws IOException { + protected static boolean deployEmbeddedWarfile(Map<String, String> args) + throws IOException { final String embeddedWarfileName = "/embedded.war"; final InputStream embeddedWarfile = DemoLauncher.class .getResourceAsStream(embeddedWarfileName); diff --git a/src/com/vaadin/terminal/ClassResource.java b/src/com/vaadin/terminal/ClassResource.java index 740660933c..7f61036e04 100644 --- a/src/com/vaadin/terminal/ClassResource.java +++ b/src/com/vaadin/terminal/ClassResource.java @@ -38,7 +38,7 @@ public class ClassResource implements ApplicationResource, Serializable { /** * Associated class used for indetifying the source of the resource. */ - private final Class associatedClass; + private final Class<?> associatedClass; /** * Name of the resource is relative to the associated class. @@ -79,7 +79,7 @@ public class ClassResource implements ApplicationResource, Serializable { * @param application * the application this resource will be added to. */ - public ClassResource(Class associatedClass, String resourceName, + public ClassResource(Class<?> associatedClass, String resourceName, Application application) { this.associatedClass = associatedClass; this.resourceName = resourceName; diff --git a/src/com/vaadin/terminal/DownloadStream.java b/src/com/vaadin/terminal/DownloadStream.java index d46f104273..1460918ca3 100644 --- a/src/com/vaadin/terminal/DownloadStream.java +++ b/src/com/vaadin/terminal/DownloadStream.java @@ -37,7 +37,7 @@ public class DownloadStream implements Serializable { private String fileName; - private Map params; + private Map<String, String> params; private long cacheTime = DEFAULT_CACHETIME; @@ -125,7 +125,7 @@ public class DownloadStream implements Serializable { */ public void setParameter(String name, String value) { if (params == null) { - params = new HashMap(); + params = new HashMap<String, String>(); } params.put(name, value); } @@ -142,7 +142,7 @@ public class DownloadStream implements Serializable { */ public String getParameter(String name) { if (params != null) { - return (String) params.get(name); + return params.get(name); } return null; } @@ -152,7 +152,7 @@ public class DownloadStream implements Serializable { * * @return Iterator of names or null if no parameters are set. */ - public Iterator getParameterNames() { + public Iterator<String> getParameterNames() { if (params != null) { return params.keySet().iterator(); } diff --git a/src/com/vaadin/terminal/KeyMapper.java b/src/com/vaadin/terminal/KeyMapper.java index 706b5d27e7..b0ab3c2ffe 100644 --- a/src/com/vaadin/terminal/KeyMapper.java +++ b/src/com/vaadin/terminal/KeyMapper.java @@ -21,9 +21,9 @@ public class KeyMapper implements Serializable { private int lastKey = 0; - private final Hashtable objectKeyMap = new Hashtable(); + private final Hashtable<Object, String> objectKeyMap = new Hashtable<Object, String>(); - private final Hashtable keyObjectMap = new Hashtable(); + private final Hashtable<String, Object> keyObjectMap = new Hashtable<String, Object>(); /** * Gets key for an object. @@ -38,7 +38,7 @@ public class KeyMapper implements Serializable { } // If the object is already mapped, use existing key - String key = (String) objectKeyMap.get(o); + String key = objectKeyMap.get(o); if (key != null) { return key; } @@ -70,7 +70,7 @@ public class KeyMapper implements Serializable { * the object to be removed. */ public void remove(Object removeobj) { - final String key = (String) objectKeyMap.get(removeobj); + final String key = objectKeyMap.get(removeobj); if (key != null) { objectKeyMap.remove(key); diff --git a/src/com/vaadin/terminal/PaintTarget.java b/src/com/vaadin/terminal/PaintTarget.java index 7bfc3555fc..a81c637de2 100644 --- a/src/com/vaadin/terminal/PaintTarget.java +++ b/src/com/vaadin/terminal/PaintTarget.java @@ -7,6 +7,8 @@ package com.vaadin.terminal; import java.io.Serializable; import java.util.Map; +import com.vaadin.terminal.StreamVariable.StreamingStartEvent; + /** * This interface defines the methods for painting XML to the UIDL stream. * @@ -152,6 +154,37 @@ public interface PaintTarget extends Serializable { public void addAttribute(String name, Resource value) throws PaintException; /** + * Adds details about {@link StreamVariable} to the UIDL stream. Eg. in web + * terminals Receivers are typically rendered for the client side as URLs, + * where the client side implementation can do an http post request. + * <p> + * Note that in current terminal implementation StreamVariables are cleaned + * from the terminal only when: + * <ul> + * <li>a StreamVariable with same name replaces an old one + * <li>the variable owner is no more attached + * <li>the developer signals this by calling + * {@link StreamingStartEvent#disposeStreamVariable()} + * </ul> + * Most commonly a component developer can just ignore this issue, but with + * strict memory requirements and lots of StreamVariables implementations + * that reserve a lot of memory this may be a critical issue. + * + * @param owner + * the ReceiverOwner that can track the progress of streaming to + * the given StreamVariable + * @param name + * an identifying name for the StreamVariable + * @param value + * the StreamVariable to paint + * + * @throws PaintException + * if the paint operation failed. + */ + public void addVariable(VariableOwner owner, String name, + StreamVariable value) throws PaintException; + + /** * Adds a long attribute to component. Atributes must be added before any * content is written. * diff --git a/src/com/vaadin/terminal/StreamVariable.java b/src/com/vaadin/terminal/StreamVariable.java new file mode 100644 index 0000000000..92dc057fd9 --- /dev/null +++ b/src/com/vaadin/terminal/StreamVariable.java @@ -0,0 +1,154 @@ +package com.vaadin.terminal; + +import java.io.OutputStream; +import java.io.Serializable; + +import com.vaadin.Application; +import com.vaadin.terminal.StreamVariable.StreamingEndEvent; +import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; +import com.vaadin.terminal.StreamVariable.StreamingStartEvent; + +/** + * StreamVariable is a special kind of variable whose value is streamed to an + * {@link OutputStream} provided by the {@link #getOutputStream()} method. E.g. + * in web terminals {@link StreamVariable} can be used to send large files from + * browsers to the server without consuming large amounts of memory. + * <p> + * Note, writing to the {@link OutputStream} is not synchronized by the terminal + * (to avoid stalls in other operations when eg. streaming to a slow network + * service or file system). If UI is changed as a side effect of writing to the + * output stream, developer must handle synchronization manually. + * <p> + * + * @author IT Mill Ltd. + * @version + * @VERSION@ + * @since 6.5 + * @see PaintTarget#addVariable(VariableOwner, String, StreamVariable) + */ +public interface StreamVariable extends Serializable { + + /** + * Invoked by the terminal when a new upload arrives, after + * {@link #streamingStarted(StreamingStartEvent)} method has been called. + * The terminal implementation will write the streamed variable to the + * returned output stream. + * + * @return Stream to which the uploaded file should be written. + */ + public OutputStream getOutputStream(); + + /** + * Whether the {@link #onProgress(long, long)} method should be called + * during the upload. + * <p> + * {@link #onProgress(long, long)} is called in a synchronized block when + * the content is being received. This is potentially bit slow, so we are + * calling that method only if requested. The value is requested after the + * {@link #uploadStarted(StreamingStartEvent)} event, but not after reading + * each buffer. + * + * @return true if this {@link StreamVariable} wants to by notified during + * the upload of the progress of streaming. + * @see #onProgress(StreamingProgressEvent) + */ + boolean listenProgress(); + + /** + * This method is called by the terminal if {@link #listenProgress()} + * returns true when the streaming starts. + */ + void onProgress(StreamingProgressEvent event); + + void streamingStarted(StreamingStartEvent event); + + void streamingFinished(StreamingEndEvent event); + + void streamingFailed(StreamingErrorEvent event); + + /* + * Not synchronized to avoid stalls (caused by UIDL requests) while + * streaming the content. Implementations also most commonly atomic even + * without the restriction. + */ + /** + * If this method returns true while the content is being streamed the + * Terminal to stop receiving current upload. + * <p> + * Note, the usage of this method is not synchronized over the Application + * instance by the terminal like other methods. The implementation should + * only return a boolean field and especially not modify UI or implement a + * synchronization by itself. + * + * @return true if the streaming should be interrupted as soon as possible. + */ + boolean isInterrupted(); + + interface StreamingEvent extends Serializable { + + /** + * @return the file name of the streamed file if known + */ + String getFileName(); + + /** + * @return the mime type of the streamed file if known + */ + String getMimeType(); + + /** + * @return the length of the stream (in bytes) if known, else -1 + */ + long getContentLength(); + + /** + * @return then number of bytes streamed to StreamVariable + */ + long getBytesReceived(); + } + + /** + * Event passed to {@link #uploadStarted(StreamingStartEvent)} method before + * the streaming of the content to {@link StreamVariable} starts. + */ + public interface StreamingStartEvent extends StreamingEvent { + /** + * The owner of the StreamVariable can call this method to inform the + * terminal implementation that this StreamVariable will not be used to + * accept more post. + */ + public void disposeStreamVariable(); + } + + /** + * Event passed to {@link #onProgress(StreamingProgressEvent)} method during + * the streaming progresses. + */ + public interface StreamingProgressEvent extends StreamingEvent { + } + + /** + * Event passed to {@link #uploadFinished(StreamingEndEvent)} method the + * contents have been streamed to StreamVariable successfully. + */ + public interface StreamingEndEvent extends StreamingEvent { + } + + /** + * Event passed to {@link #uploadFailed(StreamingErrorEvent)} method when + * the streaming ended before the end of the input. The streaming may fail + * due an interruption by {@link } or due an other unknown exception in + * communication. In the latter case the exception is also passed to + * {@link Application#terminalError(com.vaadin.terminal.Terminal.ErrorEvent)} + * . + */ + public interface StreamingErrorEvent extends StreamingEvent { + + /** + * @return the exception that caused the receiving not to finish cleanly + */ + Exception getException(); + + } + +} diff --git a/src/com/vaadin/terminal/UploadStream.java b/src/com/vaadin/terminal/UploadStream.java deleted file mode 100644 index 95351e071d..0000000000 --- a/src/com/vaadin/terminal/UploadStream.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.terminal; - -import java.io.InputStream; -import java.io.Serializable; - -/** - * Defines a variable type, that is used for passing uploaded files from - * terminal. Most often, file upload is implented using the - * {@link com.vaadin.ui.Upload Upload} component. - * - * @author IT Mill Ltd. - * @version - * @VERSION@ - * @since 3.0 - */ -public interface UploadStream extends Serializable { - - /** - * Gets the name of the stream. - * - * @return the name of the stream. - */ - public String getStreamName(); - - /** - * Gets the input stream. - * - * @return the Input stream. - */ - public InputStream getStream(); - - /** - * Gets the input stream content type. - * - * @return the content type of the input stream. - */ - public String getContentType(); - - /** - * Gets stream content name. Stream content name usually differs from the - * actual stream name. It is used to identify the content of the stream. - * - * @return the Name of the stream content. - */ - public String getContentName(); -} diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml index c7809cfffe..929d35f364 100644 --- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml +++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml @@ -1,11 +1,10 @@ <module> - <!-- + <!-- This GWT module defines the Vaadin DefaultWidgetSet. This is the module + you want to extend when creating an extended widget set, or when creating + a specialized widget set with a subset of the components. --> - This GWT module defines the Vaadin DefaultWidgetSet. This is the - module you want to extend when creating an extended widget set, or - when creating a specialized widget set with a subset of the - components. WS Compiler: manually edited - --> + <!-- Hint for WidgetSetBuilder not to automatically update the file --> + <!-- WS Compiler: manually edited --> <inherits name="com.google.gwt.user.User" /> @@ -13,22 +12,17 @@ <source path="client" /> - <!-- Use our own history impl for IE to workaround #2931. --> + <!-- Use own Scheduler implementation to be able to track if commands are running --> + <replace-with class="com.vaadin.terminal.gwt.client.VSchedulerImpl"> + <when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" /> + </replace-with> + + <!-- Use our own history impl for IE to workaround #2931. --> <replace-with class="com.vaadin.terminal.gwt.client.HistoryImplIEVaadin"> <when-type-is class="com.google.gwt.user.client.impl.HistoryImpl" /> <when-property-is name="user.agent" value="ie6" /> </replace-with> - <!-- - Safari needs a different implementation due to GWT bug. See #4279 - (vaadin trac) - --> - <replace-with - class="com.vaadin.terminal.gwt.client.ui.richtextarea.CustomWebkitRichTextArea"> - <when-type-is class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" /> - <when-property-is name="user.agent" value="safari" /> - </replace-with> - <generate-with class="com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator"> <when-type-is class="com.vaadin.terminal.gwt.client.WidgetMap" /> @@ -41,12 +35,16 @@ </generate-with> <!-- Fall through to this rule for everything but IE --> - <replace-with class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategy"> - <when-type-is class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategy" /> + <replace-with + class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategy"> + <when-type-is + class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategy" /> </replace-with> - <replace-with class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategyIE"> - <when-type-is class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategy" /> + <replace-with + class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategyIE"> + <when-type-is + class="com.vaadin.terminal.gwt.client.ui.UploadIFrameOnloadStrategy" /> <any> <when-property-is name="user.agent" value="ie6" /> <when-property-is name="user.agent" value="ie8" /> @@ -55,4 +53,5 @@ <entry-point class="com.vaadin.terminal.gwt.client.ApplicationConfiguration" /> + </module> diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index eccd925457..f57a465bb2 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -196,8 +196,8 @@ public class ApplicationConfiguration implements EntryPoint { for (Iterator<String> it = appIds.iterator(); it.hasNext();) { String appId = it.next(); ApplicationConfiguration appConf = getConfigFromDOM(appId); - ApplicationConnection a = new ApplicationConnection(widgetSet, - appConf); + ApplicationConnection a = GWT.create(ApplicationConnection.class); + a.init(widgetSet, appConf); unstartedApplications.add(a); } diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 9cf14b4ec0..7f72e745a9 100755 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -12,9 +12,11 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsArrayString; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.http.client.Request; import com.google.gwt.http.client.RequestBuilder; import com.google.gwt.http.client.RequestCallback; @@ -22,13 +24,13 @@ 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.DeferredCommand; import com.google.gwt.user.client.Element; 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.FocusWidget; +import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.RenderInformation.FloatSize; @@ -98,7 +100,7 @@ public class ApplicationConnection { private final ComponentDetailMap idToPaintableDetail = ComponentDetailMap .create(); - private final WidgetSet widgetSet; + private WidgetSet widgetSet; private VContextMenu contextMenu = null; @@ -109,12 +111,12 @@ public class ApplicationConnection { private final VView view; - private boolean applicationRunning = false; + protected boolean applicationRunning = false; private int activeRequests = 0; /** Parameters for this application connection loaded from the web-page */ - private final ApplicationConfiguration configuration; + private ApplicationConfiguration configuration; /** List of pending variable change bursts that must be submitted in order */ private final ArrayList<ArrayList<String>> pendingVariableBursts = new ArrayList<ArrayList<String>>(); @@ -136,16 +138,11 @@ public class ApplicationConnection { private Set<Paintable> zeroHeightComponents = null; - /** - * Keeps track of if there are (potentially) {@link DeferredCommand}s that - * are being executed. 0 == no DeferredCommands currently in progress, > 0 - * otherwise. - */ - private int deferredCommandTrackers = 0; - - public ApplicationConnection(WidgetSet widgetSet, - ApplicationConfiguration cnf) { + public ApplicationConnection() { + view = GWT.create(VView.class); + } + public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) { VConsole.log("Starting application " + cnf.getRootPanelId()); VConsole.log("Vaadin application servlet version: " @@ -172,10 +169,8 @@ public class ApplicationConnection { initializeClientHooks(); - view = new VView(); view.init(cnf.getRootPanelId()); showLoadingIndicator(); - } /** @@ -184,9 +179,11 @@ public class ApplicationConnection { * called once this application has started (first response received) or * failed to start. This ensures that the applications are started in order, * to avoid session-id problems. + * + * @return */ - void start() { - makeUidlRequest("", true, false, false); + public void start() { + repaintAll(); } private native void initializeTestbenchHooks( @@ -221,7 +218,6 @@ public class ApplicationConnection { /** * Helper for tt initialization */ - @SuppressWarnings("unused") private JavaScriptObject getVersionInfo() { return configuration.getVersionInfoJSObject(); } @@ -339,14 +335,61 @@ public class ApplicationConnection { return (activeRequests > 0); } - private void makeUidlRequest(final String requestData, - final boolean repaintAll, final boolean forceSync, - final boolean analyzeLayouts) { - startRequest(); + private String getRepaintAllParameters() { + // collect some client side data that will be sent to server on + // initial uidl request + int clientHeight = Window.getClientHeight(); + int clientWidth = Window.getClientWidth(); + com.google.gwt.dom.client.Element pe = view.getElement() + .getParentElement(); + int offsetHeight = pe.getOffsetHeight(); + int offsetWidth = pe.getOffsetWidth(); + int screenWidth = BrowserInfo.get().getScreenWidth(); + int screenHeight = BrowserInfo.get().getScreenHeight(); + + String token = History.getToken(); + + // TODO figure out how client and view size could be used better on + // server. screen size can be accessed via Browser object, but other + // values currently only via transaction listener. + String parameters = "repaintAll=1&" + "sh=" + screenHeight + "&sw=" + + screenWidth + "&cw=" + clientWidth + "&ch=" + clientHeight + + "&vw=" + offsetWidth + "&vh=" + offsetHeight + "&fr=" + token; + return parameters; + } + protected void repaintAll() { + String repainAllParameters = getRepaintAllParameters(); + makeUidlRequest("", repainAllParameters, false); + } + + /** + * Requests an analyze of layouts, to find inconsistencies. Exclusively used + * for debugging during development. + */ + public void analyzeLayouts() { + String params = getRepaintAllParameters() + "&analyzeLayouts=1"; + makeUidlRequest("", params, false); + } + + /** + * Makes an UIDL request to the server. + * + * @param requestData + * Data that is passed to the server. + * @param extraParams + * Parameters that are added as GET parameters to the url. + * Contains key=value pairs joined by & characters or is empty if + * no parameters should be added. Should not start with any + * special character. + * @param forceSync + * true if the request should be synchronous, false otherwise + */ + protected void makeUidlRequest(final String requestData, + final String extraParams, final boolean forceSync) { + startRequest(); // Security: double cookie submission pattern final String rd = uidl_security_key + VAR_BURST_SEPARATOR + requestData; - VConsole.log("Making UIDL Request with params: " + rd); String uri; if (configuration.usePortletURLs()) { @@ -354,39 +397,12 @@ public class ApplicationConnection { } else { uri = getAppUri() + "UIDL" + configuration.getPathInfo(); } - if (repaintAll) { - // collect some client side data that will be sent to server on - // initial uidl request - int clientHeight = Window.getClientHeight(); - int clientWidth = Window.getClientWidth(); - com.google.gwt.dom.client.Element pe = view.getElement() - .getParentElement(); - int offsetHeight = pe.getOffsetHeight(); - int offsetWidth = pe.getOffsetWidth(); - int screenWidth = BrowserInfo.get().getScreenWidth(); - int screenHeight = BrowserInfo.get().getScreenHeight(); - - String token = History.getToken(); - - // TODO figure out how client and view size could be used better on - // server. screen size can be accessed via Browser object, but other - // values currently only via transaction listener. - if (configuration.usePortletURLs()) { - uri += "&"; - } else { - uri += "?"; - } - uri += "repaintAll=1&" + "sh=" + screenHeight + "&sw=" - + screenWidth + "&cw=" + clientWidth + "&ch=" - + clientHeight + "&vw=" + offsetWidth + "&vh=" - + offsetHeight + "&fr=" + token; - if (analyzeLayouts) { - uri += "&analyzeLayouts=1"; - } + + if (extraParams != null && extraParams.length() > 0) { + uri = addGetParameters(uri, extraParams); } if (windowName != null && windowName.length() > 0) { - uri += (repaintAll || configuration.usePortletURLs() ? "&" : "?") - + "windowName=" + windowName; + uri = addGetParameters(uri, "windowName=" + windowName); } if (!forceSync) { @@ -439,8 +455,8 @@ public class ApplicationConnection { @Override public void run() { activeRequests--; - makeUidlRequest(requestData, repaintAll, - forceSync, analyzeLayouts); + makeUidlRequest(requestData, extraParams, + forceSync); } }).schedule(delay); return; @@ -456,41 +472,32 @@ public class ApplicationConnection { return; } + final Date start = new Date(); + // for(;;);[realjson] + final String jsonText = response.getText().substring(9, + response.getText().length() - 1); + final ValueMap json; + try { + json = parseJSONResponse(jsonText); + } catch (final Exception e) { + endRequest(); + showCommunicationError(e.getMessage() + + " - Original JSON-text:" + jsonText); + return; + } + + VConsole.log("JSON parsing took " + + (new Date().getTime() - start.getTime()) + + "ms"); if (applicationRunning) { - handleReceivedJSONMessage(response); + handleReceivedJSONMessage(start, jsonText, json); } else { applicationRunning = true; - handleWhenCSSLoaded(response); + handleWhenCSSLoaded(jsonText, json); ApplicationConfiguration.startNextApplication(); } } - int cssWaits = 0; - static final int MAX_CSS_WAITS = 20; - - private void handleWhenCSSLoaded(final Response response) { - int heightOfLoadElement = DOM.getElementPropertyInt( - loadElement, "offsetHeight"); - if (heightOfLoadElement == 0 - && cssWaits < MAX_CSS_WAITS) { - (new Timer() { - @Override - public void run() { - handleWhenCSSLoaded(response); - } - }).schedule(50); - VConsole.log("Assuming CSS loading is not complete, " - + "postponing render phase. " - + "(.v-loading-indicator height == 0)"); - cssWaits++; - } else { - handleReceivedJSONMessage(response); - if (cssWaits >= MAX_CSS_WAITS) { - VConsole.error("CSS files may have not loaded properly."); - } - } - } - }); } catch (RequestException e) { @@ -509,6 +516,32 @@ public class ApplicationConnection { } } + int cssWaits = 0; + static final int MAX_CSS_WAITS = 20; + + protected void handleWhenCSSLoaded(final String jsonText, + final ValueMap json) { + int heightOfLoadElement = DOM.getElementPropertyInt(loadElement, + "offsetHeight"); + if (heightOfLoadElement == 0 && cssWaits < MAX_CSS_WAITS) { + (new Timer() { + @Override + public void run() { + handleWhenCSSLoaded(jsonText, json); + } + }).schedule(50); + VConsole.log("Assuming CSS loading is not complete, " + + "postponing render phase. " + + "(.v-loading-indicator height == 0)"); + cssWaits++; + } else { + handleReceivedJSONMessage(new Date(), jsonText, json); + if (cssWaits >= MAX_CSS_WAITS) { + VConsole.error("CSS files may have not loaded properly."); + } + } + } + /** * Shows the communication error notification. * @@ -572,7 +605,7 @@ public class ApplicationConnection { } } - private void startRequest() { + protected void startRequest() { activeRequests++; requestStartTime = new Date(); // show initial throbber @@ -596,38 +629,20 @@ public class ApplicationConnection { loadTimer.schedule(300); } - private void endRequest() { + protected void endRequest() { if (applicationRunning) { checkForPendingVariableBursts(); runPostRequestHooks(configuration.getRootPanelId()); } activeRequests--; // deferring to avoid flickering - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { if (activeRequests == 0) { hideLoadingIndicator(); } } }); - addDeferredCommandTracker(); - } - - /** - * Adds a {@link DeferredCommand} tracker. Increments the tracker count when - * called and decrements in a DeferredCommand that is executed after all - * other DeferredCommands have executed. - * - */ - private void addDeferredCommandTracker() { - deferredCommandTrackers++; - DeferredCommand.addCommand(new Command() { - - public void execute() { - deferredCommandTrackers--; - } - - }); } /** @@ -716,19 +731,24 @@ public class ApplicationConnection { } /** - * Checks if {@link DeferredCommand}s are (potentially) still being executed - * as a result of an update from the server. Returns true if a - * DeferredCommand might still be executing, false otherwise. This will fail - * if a DeferredCommand adds another DeferredCommand. + * Checks if deferred commands are (potentially) still being executed as a + * result of an update from the server. Returns true if a deferred command + * might still be executing, false otherwise. This will not work correctly + * if a deferred command is added in another deferred command. * <p> - * Called by the native "client.isActive" function. + * Used by the native "client.isActive" function. * </p> * - * @return + * @return true if deferred commands are (potentially) being executed, false + * otherwise */ - @SuppressWarnings("unused") private boolean isExecutingDeferredCommands() { - return (deferredCommandTrackers > 0); + Scheduler s = Scheduler.get(); + if (s instanceof VSchedulerImpl) { + return ((VSchedulerImpl) s).hasWorkQueued(); + } else { + return false; + } } /** @@ -756,23 +776,13 @@ public class ApplicationConnection { } }-*/; - private void handleReceivedJSONMessage(Response response) { - final Date start = new Date(); - // for(;;);[realjson] - final String jsonText = response.getText().substring(9, - response.getText().length() - 1); - final ValueMap json; - try { - json = parseJSONResponse(jsonText); - } catch (final Exception e) { - endRequest(); - showCommunicationError(e.getMessage() + " - Original JSON-text:" - + jsonText); - return; - } + private void handleReceivedJSONMessage(Date start, String jsonText, + ValueMap json) { + handleUIDLMessage(start, jsonText, json); + } - VConsole.log("JSON parsing took " - + (new Date().getTime() - start.getTime()) + "ms"); + protected void handleUIDLMessage(final Date start, final String jsonText, + final ValueMap json) { // Handle redirect if (json.containsKey("redirect")) { String url = json.getValueMap("redirect").getString("url"); @@ -1197,7 +1207,11 @@ public class ApplicationConnection { req.append(VAR_BURST_SEPARATOR); } } - makeUidlRequest(req.toString(), false, forceSync, false); + makeUidlRequest(req.toString(), "", forceSync); + } + + private void makeUidlRequest(String string) { + makeUidlRequest(string, "", false); } /** @@ -1619,12 +1633,16 @@ public class ApplicationConnection { } boolean enabled = !uidl.getBooleanAttribute("disabled"); + if (uidl.hasAttribute("tabindex") && component instanceof Focusable) { + ((Focusable) component).setTabIndex(uidl + .getIntAttribute("tabindex")); + } + /* + * Disabled state may affect (override) tabindex so the order must be + * first setting tabindex, then enabled state. + */ if (component instanceof FocusWidget) { FocusWidget fw = (FocusWidget) component; - if (uidl.hasAttribute("tabindex")) { - fw.setTabIndex(uidl.getIntAttribute("tabindex")); - } - // Disabled state may affect tabindex fw.setEnabled(enabled); } @@ -2216,14 +2234,6 @@ public class ApplicationConnection { } /** - * Requests an analyze of layouts, to find inconsistensies. Exclusively used - * for debugging during develpoment. - */ - public void analyzeLayouts() { - makeUidlRequest("", true, false, true); - } - - /** * Gets the main view, a.k.a top-level window. * * @return the main view @@ -2287,4 +2297,45 @@ public class ApplicationConnection { eventIdentifier); } + /** + * Adds the get parameters to the uri and returns the new uri that contains + * the parameters. + * + * @param uri + * The uri to which the parameters should be added. + * @param extraParams + * One or more parameters in the format "a=b" or "c=d&e=f". An + * empty string is allowed but will not modify the url. + * @return The modified URI with the get parameters in extraParams added. + */ + public static String addGetParameters(String uri, String extraParams) { + if (extraParams == null || extraParams.length() == 0) { + return uri; + } + // RFC 3986: The query component is indicated by the first question + // mark ("?") character and terminated by a number sign ("#") character + // or by the end of the URI. + String fragment = null; + int hashPosition = uri.indexOf('#'); + if (hashPosition != -1) { + // Fragment including "#" + fragment = uri.substring(hashPosition); + // The full uri before the fragment + uri = uri.substring(0, hashPosition); + } + + if (uri.contains("?")) { + uri += "&"; + } else { + uri += "?"; + } + uri += extraParams; + + if (fragment != null) { + uri += fragment; + } + + return uri; + } + } diff --git a/src/com/vaadin/terminal/gwt/client/DateTimeService.java b/src/com/vaadin/terminal/gwt/client/DateTimeService.java index 8c3f9cdfaa..5202872730 100644 --- a/src/com/vaadin/terminal/gwt/client/DateTimeService.java +++ b/src/com/vaadin/terminal/gwt/client/DateTimeService.java @@ -311,7 +311,6 @@ public class DateTimeService { private String formatMonthNames(Date date, String formatStr) {
if (formatStr.contains("MMMM")) {
- @SuppressWarnings("deprecation")
String monthName = getMonth(date.getMonth());
if (monthName != null) {
@@ -332,7 +331,6 @@ public class DateTimeService { if (formatStr.contains("MMM")) {
- @SuppressWarnings("deprecation")
String monthName = getShortMonth(date.getMonth());
if (monthName != null) {
diff --git a/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java b/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java index 2a2f27a20a..f0ad3d561a 100644 --- a/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java +++ b/src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java @@ -70,7 +70,6 @@ public class HistoryImplIEVaadin extends HistoryImpl { * untrusted string that may contain html * @return sanitized string */ - @SuppressWarnings("unused") private static String escapeHtml(String maybeHtml) { final Element div = DOM.createDiv(); DOM.setInnerText(div, maybeHtml); @@ -82,7 +81,6 @@ public class HistoryImplIEVaadin extends HistoryImpl { * the fragment contains a '?'. To avoid this bug, we use location.href * instead. */ - @SuppressWarnings("unused") private static native String getLocationHash() /*-{ var href = $wnd.location.href; diff --git a/src/com/vaadin/terminal/gwt/client/LocaleService.java b/src/com/vaadin/terminal/gwt/client/LocaleService.java index 8bf124599f..4b15bd04cd 100644 --- a/src/com/vaadin/terminal/gwt/client/LocaleService.java +++ b/src/com/vaadin/terminal/gwt/client/LocaleService.java @@ -42,7 +42,7 @@ public class LocaleService { return defaultLocale;
}
- public static Set getAvailableLocales() {
+ public static Set<String> getAvailableLocales() {
return cache.keySet();
}
diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java index da1d9ce43e..5d4e8d1dc4 100644 --- a/src/com/vaadin/terminal/gwt/client/Util.java +++ b/src/com/vaadin/terminal/gwt/client/Util.java @@ -10,11 +10,11 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; @@ -114,19 +114,24 @@ public class Util { * Called when the size of one or more widgets have changed during * rendering. Finds parent container and notifies them of the size change. * - * @param widgets + * @param paintables */ - public static void componentSizeUpdated(Set<Paintable> widgets) { - if (widgets.isEmpty()) { + public static void componentSizeUpdated(Set<Paintable> paintables) { + if (paintables.isEmpty()) { return; } Map<Container, Set<Paintable>> childWidgets = new HashMap<Container, Set<Paintable>>(); - for (Paintable widget : widgets) { + for (Paintable paintable : paintables) { + Widget widget = (Widget) paintable; + if (!widget.isAttached()) { + continue; + } + // ApplicationConnection.getConsole().log( // "Widget " + Util.getSimpleName(widget) + " size updated"); - Widget parent = ((Widget) widget).getParent(); + Widget parent = widget.getParent(); while (parent != null && !(parent instanceof Container)) { parent = parent.getParent(); } @@ -136,7 +141,7 @@ public class Util { set = new HashSet<Paintable>(); childWidgets.put((Container) parent, set); } - set.add(widget); + set.add(paintable); } } @@ -324,7 +329,7 @@ public class Util { public static int measureHorizontalBorder(Element element) { int borders; - int cw = element.getClientWidth(); + // element.getClientWidth(); if (BrowserInfo.get().isIE()) { String width = element.getStyle().getProperty("width"); String height = element.getStyle().getProperty("height"); @@ -573,7 +578,7 @@ public class Util { final int scrolltop = elem.getScrollTop(); elem.getStyle().setProperty("overflow", "hidden"); - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { // Dough, Safari scroll auto means actually just a moped elem.getStyle().setProperty("overflow", originalOverflow); diff --git a/src/com/vaadin/terminal/gwt/client/VErrorMessage.java b/src/com/vaadin/terminal/gwt/client/VErrorMessage.java index d7ab581092..09f3b87691 100644 --- a/src/com/vaadin/terminal/gwt/client/VErrorMessage.java +++ b/src/com/vaadin/terminal/gwt/client/VErrorMessage.java @@ -25,7 +25,7 @@ public class VErrorMessage extends FlowPanel { if (uidl.getChildCount() == 0) { add(new HTML(" ")); } else { - for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { final Object child = it.next(); if (child instanceof String) { final String errorMessage = (String) child; diff --git a/src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java b/src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java new file mode 100644 index 0000000000..2b7f12e105 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/VSchedulerImpl.java @@ -0,0 +1,29 @@ +package com.vaadin.terminal.gwt.client;
+
+import com.google.gwt.core.client.impl.SchedulerImpl;
+
+public class VSchedulerImpl extends SchedulerImpl {
+
+ /**
+ * Keeps track of if there are deferred commands that are being executed. 0
+ * == no deferred commands currently in progress, > 0 otherwise.
+ */
+ private int deferredCommandTrackers = 0;
+
+ @Override
+ public void scheduleDeferred(ScheduledCommand cmd) {
+ deferredCommandTrackers++;
+ super.scheduleDeferred(cmd);
+ super.scheduleDeferred(new ScheduledCommand() {
+
+ public void execute() {
+ deferredCommandTrackers--;
+ }
+ });
+ }
+
+ public boolean hasWorkQueued() {
+ boolean hasWorkQueued = (deferredCommandTrackers != 0);
+ return hasWorkQueued;
+ }
+}
diff --git a/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/src/com/vaadin/terminal/gwt/client/WidgetSet.java index e6ed1cb34f..38984e75c3 100644 --- a/src/com/vaadin/terminal/gwt/client/WidgetSet.java +++ b/src/com/vaadin/terminal/gwt/client/WidgetSet.java @@ -8,18 +8,13 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ui.VButton; import com.vaadin.terminal.gwt.client.ui.VCheckBox; -import com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar; import com.vaadin.terminal.gwt.client.ui.VFilterSelect; import com.vaadin.terminal.gwt.client.ui.VListSelect; -import com.vaadin.terminal.gwt.client.ui.VNativeSelect; -import com.vaadin.terminal.gwt.client.ui.VOptionGroup; import com.vaadin.terminal.gwt.client.ui.VPasswordField; -import com.vaadin.terminal.gwt.client.ui.VPopupCalendar; import com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal; import com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical; import com.vaadin.terminal.gwt.client.ui.VTextArea; import com.vaadin.terminal.gwt.client.ui.VTextField; -import com.vaadin.terminal.gwt.client.ui.VTwinColSelect; import com.vaadin.terminal.gwt.client.ui.VUnknownComponent; import com.vaadin.terminal.gwt.client.ui.VView; import com.vaadin.terminal.gwt.client.ui.VWindow; @@ -61,17 +56,11 @@ public class WidgetSet { if (classType == null || classType == VUnknownComponent.class) { String serverSideName = conf .getUnknownServerClassNameByEncodedTagName(uidl.getTag()); - return new VUnknownComponent(serverSideName); - } else if (VSplitPanelVertical.class == classType) { - return new VSplitPanelVertical(); - } else if (VTextArea.class == classType) { - return new VTextArea(); - } else if (VDateFieldCalendar.class == classType) { - return new VDateFieldCalendar(); - } else if (VPasswordField.class == classType) { - return new VPasswordField(); + VUnknownComponent c = GWT.create(VUnknownComponent.class); + c.setServerSideClassName(serverSideName); + return c; } else if (VWindow.class == classType) { - return new VWindow(); + return GWT.create(VWindow.class); } else { /* * let the auto generated code instantiate this type @@ -96,21 +85,8 @@ public class WidgetSet { return VWindow.class; } else if (widgetClass == VFilterSelect.class) { if (uidl.hasAttribute("type")) { - // TODO check if all type checks are really needed final String type = uidl.getStringAttribute("type").intern(); - if ("twincol".equals(type)) { - return VTwinColSelect.class; - } else if ("optiongroup".equals(type)) { - return VOptionGroup.class; - } else if ("native".equals(type)) { - return VNativeSelect.class; - } else if ("list".equals(type)) { - return VListSelect.class; - } else if ("legacy-multi".equals(type)) { - return VListSelect.class; - } else if (uidl.hasAttribute("selectmode") - && uidl.getStringAttribute("selectmode") - .equals("multi")) { + if ("legacy-multi" == type) { return VListSelect.class; } } @@ -120,11 +96,6 @@ public class WidgetSet { } else if (uidl.hasAttribute("secret")) { return VPasswordField.class; } - } else if (widgetClass == VPopupCalendar.class) { - if (uidl.hasAttribute("type") - && uidl.getStringAttribute("type").equals("inline")) { - return VDateFieldCalendar.class; - } } else if (widgetClass == VSplitPanelHorizontal.class && uidl.hasAttribute("vertical")) { return VSplitPanelVertical.class; @@ -175,15 +146,10 @@ public class WidgetSet { if (fullyqualifiedName.equals("com.vaadin.ui.Button")) { loadImplementation(VCheckBox.class); } else if (fullyqualifiedName.equals("com.vaadin.ui.Select")) { - loadImplementation(VTwinColSelect.class); - loadImplementation(VOptionGroup.class); - loadImplementation(VNativeSelect.class); loadImplementation(VListSelect.class); } else if (fullyqualifiedName.equals("com.vaadin.ui.TextField")) { loadImplementation(VTextArea.class); loadImplementation(VPasswordField.class); - } else if (fullyqualifiedName.equals("com.vaadin.ui.DateField")) { - loadImplementation(VDateFieldCalendar.class); } else if (fullyqualifiedName.equals("com.vaadin.ui.SplitPanel")) { loadImplementation(VSplitPanelVertical.class); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/CalendarEntry.java b/src/com/vaadin/terminal/gwt/client/ui/CalendarEntry.java index cfff056e69..52d53bef78 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/CalendarEntry.java +++ b/src/com/vaadin/terminal/gwt/client/ui/CalendarEntry.java @@ -16,6 +16,7 @@ public class CalendarEntry { private String description;
private boolean notime;
+ @SuppressWarnings("deprecation")
public CalendarEntry(String styleName, Date start, Date end, String title,
String description, boolean notime) {
this.styleName = styleName;
@@ -90,6 +91,7 @@ public class CalendarEntry { this.notime = notime;
}
+ @SuppressWarnings("deprecation")
public String getStringForDate(Date d) {
// TODO format from DateTimeService
String s = "";
diff --git a/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java index d20f617bc1..ebb5ef5c54 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java @@ -24,9 +24,9 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.ArrayList; import java.util.List; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.PopupListener; @@ -61,7 +61,7 @@ import com.google.gwt.user.client.ui.Widget; public class MenuBar extends Widget implements PopupListener { private final Element body; - private final ArrayList items = new ArrayList(); + private final ArrayList<MenuItem> items = new ArrayList<MenuItem>(); private MenuBar parentMenu; private PopupPanel popup; private MenuItem selectedItem; @@ -294,7 +294,7 @@ public class MenuBar extends Widget implements PopupListener { * @return a list containing the <code>MenuItem</code> objects in the menu * bar */ - protected List getItems() { + protected List<MenuItem> getItems() { return items; } @@ -368,7 +368,7 @@ public class MenuBar extends Widget implements PopupListener { // Fire the item's command. final Command cmd = item.getCommand(); if (cmd != null) { - DeferredCommand.addCommand(cmd); + Scheduler.get().scheduleDeferred(cmd); } } return; @@ -478,7 +478,7 @@ public class MenuBar extends Widget implements PopupListener { private MenuItem findItem(Element hItem) { for (int i = 0; i < items.size(); ++i) { - final MenuItem item = (MenuItem) items.get(i); + final MenuItem item = items.get(i); if (DOM.isOrHasChild(item.getElement(), hItem)) { return item; } @@ -512,7 +512,7 @@ public class MenuBar extends Widget implements PopupListener { private void onShow() { // Select the first item when a menu is shown. if (items.size() > 0) { - selectItem((MenuItem) items.get(0)); + selectItem(items.get(0)); } } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java b/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java index 0817d3d6e0..77210caa63 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java +++ b/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java @@ -7,9 +7,9 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.ArrayList; import java.util.Iterator; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.HasWidgets; @@ -94,7 +94,7 @@ public class ShortcutActionHandler { */ public void updateActionMap(UIDL c) { actions.clear(); - final Iterator it = c.getChildIterator(); + final Iterator<?> it = c.getChildIterator(); while (it.hasNext()) { final UIDL action = (UIDL) it.next(); @@ -155,14 +155,14 @@ public class ShortcutActionHandler { .onBeforeShortcutAction(event); } else { shakeTarget(et); - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { shakeTarget(et); } }); } - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { if (finalTarget != null) { client.updateVariable(paintableId, "actiontarget", @@ -193,7 +193,7 @@ public class ShortcutActionHandler { // will mess up with focus and blur event if the focus is not // deferred. Will cause a small flickering, so not doing it for all // browsers. - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { focus(e); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java index af856d047c..50e33c4c19 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java @@ -45,9 +45,9 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { protected final Element canvas = DOM.createDiv(); - private int excessPixelsHorizontal; - - private int excessPixelsVertical; + // private int excessPixelsHorizontal; + // + // private int excessPixelsVertical; private Object previousStyleName; @@ -199,8 +199,8 @@ public class VAbsoluteLayout extends ComplexPanel implements Container { public void setStyleName(String style) { super.setStyleName(style); if (previousStyleName == null || !previousStyleName.equals(style)) { - excessPixelsHorizontal = -1; - excessPixelsVertical = -1; + // excessPixelsHorizontal = -1; + // excessPixelsVertical = -1; } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java index d6fa5f5551..66192489a9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java @@ -564,8 +564,9 @@ public class VAccordion extends VTabsheetBase implements } @Override - protected Iterator getPaintableIterator() { - return paintables.iterator(); + @SuppressWarnings("unchecked") + protected Iterator<Object> getPaintableIterator() { + return (Iterator) paintables.iterator(); } public boolean hasChildComponent(Widget component) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java index fa21eda37b..ee754a08f7 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java @@ -7,6 +7,7 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.Date;
import java.util.Iterator;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Node;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
@@ -29,7 +30,6 @@ import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
@@ -1648,7 +1648,7 @@ public class VCalendarPanel extends FocusableFlexTable implements */
public void onBlur(final BlurEvent event) {
if (isAttached()) {
- DeferredCommand.addCommand(new Command() {
+ Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
if (!hasFocus) {
onTabOut(event);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VContextMenu.java b/src/com/vaadin/terminal/gwt/client/ui/VContextMenu.java index d2acd0617a..fc0478ce95 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VContextMenu.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VContextMenu.java @@ -4,6 +4,7 @@ package com.vaadin.terminal.gwt.client.ui; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableSectionElement; @@ -21,7 +22,6 @@ import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.MenuBar; @@ -104,7 +104,7 @@ public class VContextMenu extends VOverlay implements SubPartAware { * the focus is certainly moved to the menu in all browser after * the positioning has been done. */ - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { // Focus the menu. menu.setFocus(true); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java b/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java index 9cd6cc27a6..35ed2c5fed 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java @@ -6,8 +6,8 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.Set; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -54,7 +54,7 @@ public class VCustomComponent extends SimplePanel implements Container { boolean updateDynamicSize = updateDynamicSize(); if (updateDynamicSize) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { // FIXME deferred relative size update needed to fix some // scrollbar issues in sampler. This must be the wrong way diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java index e67c9e6a44..e92e6e2960 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java @@ -40,13 +40,13 @@ public class VCustomLayout extends ComplexPanel implements Paintable, public static final String CLASSNAME = "v-customlayout"; /** Location-name to containing element in DOM map */ - private final HashMap locationToElement = new HashMap(); + private final HashMap<String, Element> locationToElement = new HashMap<String, Element>(); /** Location-name to contained widget map */ private final HashMap<String, Widget> locationToWidget = new HashMap<String, Widget>(); /** Widget to captionwrapper map */ - private final HashMap widgetToCaptionWrapper = new HashMap(); + private final HashMap<Paintable, VCaptionWrapper> widgetToCaptionWrapper = new HashMap<Paintable, VCaptionWrapper>(); /** Name of the currently rendered style */ String currentTemplateName; @@ -104,7 +104,7 @@ public class VCustomLayout extends ComplexPanel implements Paintable, } // If no given location is found in the layout, and exception is throws - Element elem = (Element) locationToElement.get(location); + Element elem = locationToElement.get(location); if (elem == null && hasTemplate()) { throw new IllegalArgumentException("No location " + location + " found"); @@ -153,11 +153,11 @@ public class VCustomLayout extends ComplexPanel implements Paintable, // TODO Check if this is needed client.runDescendentsLayout(this); - Set oldWidgets = new HashSet(); + Set<Widget> oldWidgets = new HashSet<Widget>(); oldWidgets.addAll(locationToWidget.values()); // For all contained widgets - for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL uidlForChild = (UIDL) i.next(); if (uidlForChild.getTag().equals("location")) { final String location = uidlForChild.getStringAttribute("name"); @@ -172,8 +172,9 @@ public class VCustomLayout extends ComplexPanel implements Paintable, oldWidgets.remove(child); } } - for (Iterator iterator = oldWidgets.iterator(); iterator.hasNext();) { - Widget oldWidget = (Widget) iterator.next(); + for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator + .hasNext();) { + Widget oldWidget = iterator.next(); if (oldWidget.isAttached()) { // slot of this widget is emptied, remove it remove(oldWidget); @@ -384,14 +385,13 @@ public class VCustomLayout extends ComplexPanel implements Paintable, /** Update caption for given widget */ public void updateCaption(Paintable component, UIDL uidl) { - VCaptionWrapper wrapper = (VCaptionWrapper) widgetToCaptionWrapper - .get(component); + VCaptionWrapper wrapper = widgetToCaptionWrapper.get(component); if (VCaption.isNeeded(uidl)) { if (wrapper == null) { final String loc = getLocation((Widget) component); super.remove((Widget) component); wrapper = new VCaptionWrapper(component, client); - super.add(wrapper, (Element) locationToElement.get(loc)); + super.add(wrapper, locationToElement.get(loc)); widgetToCaptionWrapper.put(component, wrapper); } wrapper.updateCaption(uidl); @@ -400,7 +400,7 @@ public class VCustomLayout extends ComplexPanel implements Paintable, final String loc = getLocation((Widget) component); super.remove(wrapper); super.add((Widget) wrapper.getPaintable(), - (Element) locationToElement.get(loc)); + locationToElement.get(loc)); widgetToCaptionWrapper.remove(component); } } @@ -408,9 +408,9 @@ public class VCustomLayout extends ComplexPanel implements Paintable, /** Get the location of an widget */ public String getLocation(Widget w) { - for (final Iterator i = locationToWidget.keySet().iterator(); i + for (final Iterator<String> i = locationToWidget.keySet().iterator(); i .hasNext();) { - final String location = (String) i.next(); + final String location = i.next(); if (locationToWidget.get(location) == w) { return location; } @@ -426,8 +426,7 @@ public class VCustomLayout extends ComplexPanel implements Paintable, if (location != null) { locationToWidget.remove(location); } - final VCaptionWrapper cw = (VCaptionWrapper) widgetToCaptionWrapper - .get(w); + final VCaptionWrapper cw = widgetToCaptionWrapper.get(w); if (cw != null) { widgetToCaptionWrapper.remove(w); return super.remove(cw); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java index 63a6776394..ee738c6204 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java @@ -10,11 +10,14 @@ import com.google.gwt.event.dom.client.DomEvent; import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusOutListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.SubmitListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
-import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
+/**
+ * A client side implementation for InlineDateField
+ */
public class VDateFieldCalendar extends VDateField {
private final VCalendarPanel calendarPanel;
@@ -34,7 +37,7 @@ public class VDateFieldCalendar extends VDateField { }
});
calendarPanel.setFocusOutListener(new FocusOutListener() {
- public boolean onFocusOut(DomEvent event) {
+ public boolean onFocusOut(DomEvent<?> event) {
updateValueFromPanel();
return false;
}
@@ -42,6 +45,7 @@ public class VDateFieldCalendar extends VDateField { }
@Override
+ @SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
calendarPanel.setShowISOWeekNumbers(isShowISOWeekNumbers());
@@ -73,10 +77,10 @@ public class VDateFieldCalendar extends VDateField { if (currentResolution <= RESOLUTION_MONTH) {
calendarPanel.setFocusChangeListener(new FocusChangeListener() {
public void focusChanged(Date date) {
- Date date2 = new Date();
- if (calendarPanel.getDate() != null) {
- date2.setTime(calendarPanel.getDate().getTime());
- }
+ Date date2 = new Date();
+ if (calendarPanel.getDate() != null) {
+ date2.setTime(calendarPanel.getDate().getTime());
+ }
/*
* Update the value of calendarPanel
*/
@@ -100,6 +104,7 @@ public class VDateFieldCalendar extends VDateField { /**
* TODO refactor: almost same method as in VPopupCalendar.updateValue
*/
+ @SuppressWarnings("deprecation")
private void updateValueFromPanel() {
Date date2 = calendarPanel.getDate();
Date currentDate = getCurrentDate();
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java index ffbe25e9a7..6a5beefaa2 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java @@ -3,15 +3,20 @@ */ package com.vaadin.terminal.gwt.client.ui; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Set; -import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.JsArrayString; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseDownHandler; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Widget; import com.google.gwt.xhr.client.ReadyStateChangeHandler; import com.google.gwt.xhr.client.XMLHttpRequest; @@ -33,7 +38,6 @@ import com.vaadin.terminal.gwt.client.ui.dd.VDropHandler; import com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler; import com.vaadin.terminal.gwt.client.ui.dd.VHtml5DragEvent; import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File; -import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File.Callback; import com.vaadin.terminal.gwt.client.ui.dd.VTransferable; import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; @@ -96,46 +100,118 @@ public class VDragAndDropWrapper extends VCustomComponent implements private final static int WRAPPER = 2; private int dragStarMode; private int filecounter = 0; - private boolean dragLeavPostponed; + private Map<String, String> fileIdToReceiver; @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { this.client = client; super.updateFromUIDL(uidl, client); if (!uidl.hasAttribute("cached") && !uidl.hasAttribute("hidden")) { - int childCount = uidl.getChildCount(); - if (childCount > 1) { - UIDL childUIDL = uidl.getChildUIDL(1); + UIDL acceptCrit = uidl.getChildByTagName("-ac"); + if (acceptCrit == null) { + dropHandler = null; + } else { if (dropHandler == null) { dropHandler = new CustomDropHandler(); } - dropHandler.updateAcceptRules(childUIDL); - } else { - dropHandler = null; + dropHandler.updateAcceptRules(acceptCrit); + } + + Set<String> variableNames = uidl.getVariableNames(); + for (String fileId : variableNames) { + if (fileId.startsWith("rec-")) { + String receiverUrl = uidl.getStringVariable(fileId); + fileId = fileId.substring(4); + if (fileIdToReceiver == null) { + fileIdToReceiver = new HashMap<String, String>(); + } + if ("".equals(receiverUrl)) { + Integer id = Integer.parseInt(fileId); + int indexOf = fileIds.indexOf(id); + if (indexOf != -1) { + files.remove(indexOf); + fileIds.remove(indexOf); + } + } else { + fileIdToReceiver.put(fileId, receiverUrl); + } + } } + startNextUpload(); dragStarMode = uidl.getIntAttribute("dragStartMode"); } } + private boolean uploading; + + private ReadyStateChangeHandler readyStateChangeHandler = new ReadyStateChangeHandler() { + public void onReadyStateChange(XMLHttpRequest xhr) { + if (xhr.getReadyState() == XMLHttpRequest.DONE) { + // visit server for possible + // variable changes + client.sendPendingVariableChanges(); + uploading = false; + startNextUpload(); + xhr.clearOnReadyStateChange(); + } + } + }; + private Timer dragleavetimer; + + private void startNextUpload() { + Scheduler.get().scheduleDeferred(new Command() { + + public void execute() { + if (!uploading) { + if (fileIds.size() > 0) { + + uploading = true; + final Integer fileId = fileIds.remove(0); + VHtml5File file = files.remove(0); + final String receiverUrl = fileIdToReceiver + .remove(fileId.toString()); + ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR + .create(); + extendedXHR + .setOnReadyStateChange(readyStateChangeHandler); + extendedXHR.open("POST", receiverUrl); + extendedXHR.postFile(file); + + } + } + + } + }); + + } + public boolean html5DragEnter(VHtml5DragEvent event) { if (dropHandler == null) { return true; } - if (dragLeavPostponed) { - // returned quickly back to wrapper - dragLeavPostponed = false; + try { + if (dragleavetimer != null) { + // returned quickly back to wrapper + dragleavetimer.cancel(); + dragleavetimer = null; + } + if (VDragAndDropManager.get().getCurrentDropHandler() != getDropHandler()) { + VTransferable transferable = new VTransferable(); + transferable.setDragSource(this); + + vaadinDragEvent = VDragAndDropManager.get().startDrag( + transferable, event, false); + VDragAndDropManager.get().setCurrentDropHandler( + getDropHandler()); + } + event.preventDefault(); + event.stopPropagation(); return false; + } catch (Exception e) { + GWT.getUncaughtExceptionHandler().onUncaughtException(e); + return true; } - VTransferable transferable = new VTransferable(); - transferable.setDragSource(this); - - vaadinDragEvent = VDragAndDropManager.get().startDrag(transferable, - event, false); - VDragAndDropManager.get().setCurrentDropHandler(getDropHandler()); - event.preventDefault(); - event.stopPropagation(); - return false; } public boolean html5DragLeave(VHtml5DragEvent event) { @@ -143,24 +219,30 @@ public class VDragAndDropWrapper extends VCustomComponent implements return true; } - dragLeavPostponed = true; - DeferredCommand.addCommand(new Command() { - public void execute() { - // Yes, dragleave happens before drop. Makes no sense to me. - // IMO shouldn't fire leave at all if drop happens (I guess this - // is what IE does). - // In Vaadin we fire it only if drop did not happen. - if (dragLeavPostponed - && vaadinDragEvent != null - && VDragAndDropManager.get().getCurrentDropHandler() == getDropHandler()) { - VDragAndDropManager.get().interruptDrag(); + try { + dragleavetimer = new Timer() { + @Override + public void run() { + // Yes, dragleave happens before drop. Makes no sense to me. + // IMO shouldn't fire leave at all if drop happens (I guess + // this + // is what IE does). + // In Vaadin we fire it only if drop did not happen. + if (vaadinDragEvent != null + && VDragAndDropManager.get() + .getCurrentDropHandler() == getDropHandler()) { + VDragAndDropManager.get().interruptDrag(); + } } - dragLeavPostponed = false; - } - }); - event.preventDefault(); - event.stopPropagation(); - return false; + }; + dragleavetimer.schedule(350); + event.preventDefault(); + event.stopPropagation(); + return false; + } catch (Exception e) { + GWT.getUncaughtExceptionHandler().onUncaughtException(e); + return true; + } } public boolean html5DragOver(VHtml5DragEvent event) { @@ -168,6 +250,12 @@ public class VDragAndDropWrapper extends VCustomComponent implements return true; } + if (dragleavetimer != null) { + // returned quickly back to wrapper + dragleavetimer.cancel(); + dragleavetimer = null; + } + vaadinDragEvent.setCurrentGwtEvent(event); getDropHandler().dragOver(vaadinDragEvent); // needed to be set for Safari, otherwise drop will not happen @@ -188,41 +276,47 @@ public class VDragAndDropWrapper extends VCustomComponent implements if (dropHandler == null || !currentlyValid) { return true; } + try { - VTransferable transferable = vaadinDragEvent.getTransferable(); + VTransferable transferable = vaadinDragEvent.getTransferable(); - JsArrayString types = event.getTypes(); - for (int i = 0; i < types.length(); i++) { - String type = types.get(i); - if (isAcceptedType(type)) { - String data = event.getDataAsText(type); - if (data != null) { - transferable.setData(type, data); + JsArrayString types = event.getTypes(); + for (int i = 0; i < types.length(); i++) { + String type = types.get(i); + if (isAcceptedType(type)) { + String data = event.getDataAsText(type); + if (data != null) { + transferable.setData(type, data); + } } } - } - int fileCount = event.getFileCount(); - if (fileCount > 0) { - transferable.setData("filecount", fileCount); - for (int i = 0; i < fileCount; i++) { - final int fileId = filecounter++; - final VHtml5File file = event.getFile(i); - transferable.setData("fi" + i, "" + fileId); - transferable.setData("fn" + i, file.getName()); - transferable.setData("ft" + i, file.getType()); - transferable.setData("fs" + i, file.getSize()); - postFile(fileId, file); + int fileCount = event.getFileCount(); + if (fileCount > 0) { + transferable.setData("filecount", fileCount); + for (int i = 0; i < fileCount; i++) { + final int fileId = filecounter++; + final VHtml5File file = event.getFile(i); + transferable.setData("fi" + i, "" + fileId); + transferable.setData("fn" + i, file.getName()); + transferable.setData("ft" + i, file.getType()); + transferable.setData("fs" + i, file.getSize()); + queueFilePost(fileId, file); + } + } - } + VDragAndDropManager.get().endDrag(); + vaadinDragEvent = null; + event.preventDefault(); + event.stopPropagation(); - VDragAndDropManager.get().endDrag(); - vaadinDragEvent = null; - event.preventDefault(); - event.stopPropagation(); + return false; + } catch (Exception e) { + GWT.getUncaughtExceptionHandler().onUncaughtException(e); + return true; + } - return false; } protected String[] acceptedTypes = new String[] { "Text", "Url", @@ -242,10 +336,11 @@ public class VDragAndDropWrapper extends VCustomComponent implements protected ExtendedXHR() { } - public final native void sendBinary(JavaScriptObject data) + public final native void postFile(VHtml5File file) /*-{ - //this.overrideMimeType('text/plain; charset=x-user-defined-binary'); - this.sendAsBinary(data); + + this.setRequestHeader('Content-Type', 'multipart/form-data'); + this.send(file); }-*/; } @@ -257,65 +352,18 @@ public class VDragAndDropWrapper extends VCustomComponent implements * @param fileId * @param data */ - private void postFile(final int fileId, final VHtml5File file) { - DeferredCommand.addCommand(new Command() { - public void execute() { - /* - * File contents is sent deferred to allow quick reaction on GUI - * although file upload may last long. - */ - file.readAsBinary(new Callback() { - public void handleFile(final JavaScriptObject object) { - - ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR - .create(); - String name = "XHRFILE" + getPid() + "." + fileId; - extendedXHR - .setOnReadyStateChange(new ReadyStateChangeHandler() { - public void onReadyStateChange( - XMLHttpRequest xhr) { - if (xhr.getReadyState() == XMLHttpRequest.DONE) { - client.sendPendingVariableChanges(); - xhr.clearOnReadyStateChange(); - } - } - }); - extendedXHR.open("POST", client.getAppUri()); - multipartSend(extendedXHR, object, name); - - } - }); - - } - }); + private List<Integer> fileIds = new ArrayList<Integer>(); + private List<VHtml5File> files = new ArrayList<VHtml5File>(); + private void queueFilePost(final int fileId, final VHtml5File file) { + fileIds.add(fileId); + files.add(file); } private String getPid() { return client.getPid(this); } - private native void multipartSend(JavaScriptObject xhr, - JavaScriptObject data, String name) - /*-{ - - var boundaryString = "------------------------------------------VAADINXHRFILEUPLOAD"; - var boundary = "--" + boundaryString; - var CRLF = "\r\n"; - xhr.setRequestHeader("Content-type", "multipart/form-data; boundary=\"" + boundaryString + "\""); - var requestBody = boundary - + CRLF - + "Content-Disposition: form-data; name=\""+name+"\"; filename=\"file\"" - + CRLF - + "Content-Type: application/octet-stream" // hard coded, type sent separately - + CRLF + CRLF + data.target.result + CRLF + boundary + "--" + CRLF; - xhr.setRequestHeader("Content-Length", requestBody.length); - - - xhr.sendAsBinary(requestBody); - - }-*/; - public VDropHandler getDropHandler() { return dropHandler; } @@ -344,7 +392,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override public void dragLeave(VDragEvent drag) { deEmphasis(true); - dragLeavPostponed = false; + dragleavetimer = null; } @Override diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index cbe6ce0de9..7e55b091ba 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -10,6 +10,7 @@ import java.util.Date; import java.util.Iterator; import java.util.List; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Style.Overflow; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -28,7 +29,6 @@ import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; @@ -277,8 +277,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, final MenuItem cur = menu.getSelectedItem(); final int index = 1 + menu.getItems().indexOf(cur); if (menu.getItems().size() > index) { - final MenuItem newSelectedItem = (MenuItem) menu.getItems() - .get(index); + final MenuItem newSelectedItem = menu.getItems().get(index); menu.selectItem(newSelectedItem); tb.setText(newSelectedItem.getText()); tb.setSelectionRange(lastFilter.length(), newSelectedItem @@ -297,8 +296,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, final MenuItem cur = menu.getSelectedItem(); final int index = -1 + menu.getItems().indexOf(cur); if (index > -1) { - final MenuItem newSelectedItem = (MenuItem) menu.getItems() - .get(index); + final MenuItem newSelectedItem = menu.getItems().get(index); menu.selectItem(newSelectedItem); tb.setText(newSelectedItem.getText()); tb.setSelectionRange(lastFilter.length(), newSelectedItem @@ -309,8 +307,8 @@ public class VFilterSelect extends Composite implements Paintable, Field, filterOptions(currentPage - 1, lastFilter); } } else { - final MenuItem newSelectedItem = (MenuItem) menu.getItems() - .get(menu.getItems().size() - 1); + final MenuItem newSelectedItem = menu.getItems().get( + menu.getItems().size() - 1); menu.selectItem(newSelectedItem); tb.setText(newSelectedItem.getText()); tb.setSelectionRange(lastFilter.length(), newSelectedItem @@ -586,8 +584,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, int p = getItems().size(); if (p > 0) { for (int i = 0; i < p; i++) { - final MenuItem potentialExactMatch = (MenuItem) getItems() - .get(i); + final MenuItem potentialExactMatch = getItems().get(i); if (potentialExactMatch.getText().equals(enteredItemValue)) { selectItem(potentialExactMatch); // do not send a value change event if null was and @@ -663,7 +660,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, int index = Integer.parseInt(subPart.substring(SUBPART_PREFIX .length())); - MenuItem item = (MenuItem) getItems().get(index); + MenuItem item = getItems().get(index); return item.getElement(); } @@ -682,7 +679,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, final int itemCount = getItems().size(); for (int i = 0; i < itemCount; i++) { - if (((MenuItem) getItems().get(i)).getElement() == menuItemRoot) { + if (getItems().get(i).getElement() == menuItemRoot) { String name = SUBPART_PREFIX + i; return name; } @@ -983,7 +980,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, String captions = inputPrompt; - for (final Iterator i = options.getChildIterator(); i.hasNext();) { + for (final Iterator<?> i = options.getChildIterator(); i.hasNext();) { final UIDL optionUidl = (UIDL) i.next(); final FilterSelectSuggestion suggestion = new FilterSelectSuggestion( optionUidl); @@ -1037,7 +1034,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, if (lastIndex == 0) { // going up, select last item int lastItem = pageLength - 1; - List items = suggestionPopup.menu.getItems(); + List<MenuItem> items = suggestionPopup.menu.getItems(); /* * The first page can contain less than 10 items if the null * selection item is filtered away @@ -1045,12 +1042,11 @@ public class VFilterSelect extends Composite implements Paintable, Field, if (lastItem >= items.size()) { lastItem = items.size() - 1; } - activeMenuItem = (MenuItem) items.get(lastItem); + activeMenuItem = items.get(lastItem); suggestionPopup.menu.selectItem(activeMenuItem); } else { // going down, select first item - activeMenuItem = (MenuItem) suggestionPopup.menu.getItems() - .get(0); + activeMenuItem = suggestionPopup.menu.getItems().get(0); suggestionPopup.menu.selectItem(activeMenuItem); } @@ -1086,7 +1082,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, */ private void setTextboxText(final String text) { if (BrowserInfo.get().isGecko()) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { tb.setText(text); } @@ -1298,8 +1294,8 @@ public class VFilterSelect extends Composite implements Paintable, Field, } if (currentSuggestions.size() == 1 && !allowNewItem) { // If there is only one suggestion, select that - suggestionPopup.menu.selectItem((MenuItem) suggestionPopup.menu - .getItems().get(0)); + suggestionPopup.menu.selectItem(suggestionPopup.menu.getItems() + .get(0)); } suggestionPopup.menu.doSelectedItemAction(); break; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java index 798fb01edf..4fce0938ad 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java @@ -20,6 +20,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.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.Container; import com.vaadin.terminal.gwt.client.Focusable; import com.vaadin.terminal.gwt.client.Paintable; @@ -107,7 +108,7 @@ public class VFormLayout extends SimplePanel implements Container { uidl.hasAttribute("spacing")); int i = 0; - for (final Iterator it = uidl.getChildIterator(); it.hasNext(); i++) { + for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext(); i++) { prepareCell(i, 1); final UIDL childUidl = (UIDL) it.next(); final Paintable p = client.getPaintable(childUidl); @@ -400,7 +401,7 @@ public class VFormLayout extends SimplePanel implements Container { // Workaround for IE weirdness, sometimes returns bad height in some // circumstances when Caption is empty. See #1444 // IE7 bugs more often. I wonder what happens when IE8 arrives... - if (Util.isIE()) { + if (BrowserInfo.get().isIE()) { if (isEmpty) { setHeight("0px"); DOM.setStyleAttribute(getElement(), "overflow", "hidden"); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java index be47be7f4b..b4c3dccbc9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java @@ -98,6 +98,7 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { return margin.cast(); } + @SuppressWarnings("unchecked") public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; this.client = client; @@ -143,10 +144,10 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { LinkedList<Cell> relativeHeighted = new LinkedList<Cell>(); - for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL r = (UIDL) i.next(); if ("gr".equals(r.getTag())) { - for (final Iterator j = r.getChildIterator(); j.hasNext();) { + for (final Iterator<?> j = r.getChildIterator(); j.hasNext();) { final UIDL c = (UIDL) j.next(); if ("gc".equals(c.getTag())) { Cell cell = getCell(c); @@ -495,8 +496,9 @@ public class VGridLayout extends SimplePanel implements Paintable, Container { private void renderRemainingComponentsWithNoRelativeHeight( LinkedList<Cell> pendingCells) { - for (Iterator iterator = pendingCells.iterator(); iterator.hasNext();) { - Cell cell = (Cell) iterator.next(); + for (Iterator<Cell> iterator = pendingCells.iterator(); iterator + .hasNext();) { + Cell cell = iterator.next(); if (!cell.hasRelativeHeight()) { cell.render(); iterator.remove(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VListSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VListSelect.java index a6fc0107c3..e19079039d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VListSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VListSelect.java @@ -46,7 +46,7 @@ public class VListSelect extends VOptionGroupBase { // can't unselect last item in singleselect mode select.addItem("", null); } - for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL optionUidl = (UIDL) i.next(); select.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key")); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 4a8ff451ca..5214b86b28 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -8,6 +8,7 @@ import java.util.Iterator; import java.util.List; import java.util.Stack; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NodeList; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; @@ -20,25 +21,29 @@ import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.HasHTML; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.UIObject; +import com.google.gwt.user.client.ui.Widget; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.ContainerResizedListener; import com.vaadin.terminal.gwt.client.Paintable; +import com.vaadin.terminal.gwt.client.TooltipInfo; import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; +import com.vaadin.terminal.gwt.client.VTooltip; public class VMenuBar extends SimpleFocusablePanel implements Paintable, CloseHandler<PopupPanel>, ContainerResizedListener, KeyPressHandler, KeyDownHandler, FocusHandler, SubPartAware { + // The hierarchy of VMenuBar is a bit weird as VMenuBar is the Paintable, + // used for the root menu but also used for the sub menus. + /** Set the CSS class name to allow styling. */ public static final String CLASSNAME = "v-menubar"; @@ -49,6 +54,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, protected final VMenuBar hostReference = this; protected String submenuIcon = null; protected CustomMenuItem moreItem = null; + + // Only used by the root menu bar protected VMenuBar collapsedRootItems; // Construct an empty command to be used when the item has no command @@ -70,9 +77,11 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, private boolean enabled = true; + private String width = "notinited"; + public VMenuBar() { // Create an empty horizontal menubar - this(false); + this(false, null); // Navigation is only handled by the root bar addFocusHandler(this); @@ -89,7 +98,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, } } - public VMenuBar(boolean subMenu) { + public VMenuBar(boolean subMenu, VMenuBar parentMenu) { items = new ArrayList<CustomMenuItem>(); popup = null; @@ -101,11 +110,14 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, setStyleName(CLASSNAME); } else { setStyleName(CLASSNAME + "-submenu"); + this.parentMenu = parentMenu; } this.subMenu = subMenu; sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONLOAD); + + sinkEvents(VTooltip.TOOLTIP_EVENTS); } @Override @@ -120,6 +132,11 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, @Override public void setWidth(String width) { + if (Util.equals(this.width, width)) { + return; + } + + this.width = width; Util.setWidthExcludingPaddingAndBorder(this, width, 0); if (!subMenu) { // Only needed for root level menu @@ -181,7 +198,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, itemHTML.append(moreItemText); moreItem = new CustomMenuItem(itemHTML.toString(), emptyCommand); - collapsedRootItems = new VMenuBar(true); + collapsedRootItems = new VMenuBar(true, + (VMenuBar) client.getPaintable(uidlId)); moreItem.setSubMenu(collapsedRootItems); moreItem.addStyleName(CLASSNAME + "-more-menuitem"); } @@ -244,18 +262,13 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, } currentItem = currentMenu.addItem(itemHTML.toString(), cmd); - currentItem.setSeparator(item.hasAttribute("separator")); - currentItem.setEnabled(!item.hasAttribute("disabled")); - if (item.hasAttribute("style")) { - String itemStyle = item.getStringAttribute("style"); - currentItem.addStyleDependentName(itemStyle); - } + currentItem.updateFromUIDL(item, client); if (item.getChildCount() > 0) { menuStack.push(currentMenu); iteratorStack.push(itr); itr = item.getChildIterator(); - currentMenu = new VMenuBar(true); + currentMenu = new VMenuBar(true, currentMenu); if (uidl.hasAttribute("style")) { for (String style : uidl.getStringAttribute("style").split( " ")) { @@ -271,7 +284,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, } }// while - iLayout(); + iLayout(false); }// updateFromUIDL @@ -395,7 +408,16 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, // Handle onload events (icon loaded, size changes) if (DOM.eventGetType(e) == Event.ONLOAD) { - requestLayout(); + VMenuBar parent = getParentMenu(); + if (parent != null) { + // The onload event for an image in a popup should be sent to + // the parent, which owns the popup + parent.iconLoaded(); + } else { + // Onload events for images in the root menu are handled by the + // root menu itself + iconLoaded(); + } return; } @@ -408,6 +430,15 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, } } + // Handle tooltips + if (targetItem == null && client != null) { + // Handle root menubar tooltips + client.handleTooltipEvent(e, this); + } else if (targetItem != null) { + // Handle item tooltips + targetItem.onBrowserEvent(e); + } + if (targetItem != null) { switch (DOM.eventGetType(e)) { @@ -450,13 +481,13 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, return enabled; } - private void requestLayout() { + private void iconLoaded() { if (layoutTimer == null) { layoutTimer = new Timer() { @Override public void run() { layoutTimer = null; - iLayout(); + iLayout(true); } }; } @@ -478,7 +509,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, hideParents(true); menuVisible = false; - DeferredCommand.addCommand(item.getCommand()); + Scheduler.get().scheduleDeferred(item.getCommand()); } else { if (item.getSubMenu() != null @@ -583,7 +614,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, // Part of a fix to correct #3850 if (BrowserInfo.get().isIE7()) { popup.getElement().getStyle().setProperty("zoom", ""); - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { if (popup == null) { // The child menu can be hidden before this command is @@ -716,7 +747,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, * A class to hold information on menu items * */ - private class CustomMenuItem extends UIObject implements HasHTML { + private class CustomMenuItem extends Widget implements HasHTML { + + private ApplicationConnection client; protected String html = null; protected Command command = null; @@ -734,6 +767,15 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, setSelected(false); setStyleName(CLASSNAME + "-menuitem"); + sinkEvents(VTooltip.TOOLTIP_EVENTS); + + // Sink the onload event for an icon (if it exists). The onload + // events are handled by the parent VMenuBar. + NodeList<com.google.gwt.dom.client.Element> imgElements = getElement() + .getElementsByTagName("img"); + for (int i = 0; i < imgElements.getLength(); i++) { + DOM.sinkEvents((Element) imgElements.getItem(i), Event.ONLOAD); + } } public void setSelected(boolean selected) { @@ -781,7 +823,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, DOM.setInnerHTML(getElement(), html); if (BrowserInfo.get().isIE6() && client != null) { // Find possible icon element - final NodeList imgs = getElement().getElementsByTagName("IMG"); + final NodeList<com.google.gwt.dom.client.Element> imgs = getElement() + .getElementsByTagName("IMG"); if (imgs.getLength() > 0) { client.addPngFix((Element) imgs.getItem(0).cast()); } @@ -822,6 +865,45 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, public boolean isSeparator() { return isSeparator; } + + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + this.client = client; + setSeparator(uidl.hasAttribute("separator")); + setEnabled(!uidl.hasAttribute("disabled")); + + if (uidl.hasAttribute("style")) { + String itemStyle = uidl.getStringAttribute("style"); + addStyleDependentName(itemStyle); + } + + if (uidl.hasAttribute("description")) { + String description = uidl.getStringAttribute("description"); + TooltipInfo info = new TooltipInfo(description); + + VMenuBar root = findRootMenu(); + client.registerTooltip(root, this, info); + } + } + + @Override + public void onBrowserEvent(Event event) { + super.onBrowserEvent(event); + if (client != null) { + client.handleTooltipEvent(event, findRootMenu(), this); + } + } + + private VMenuBar findRootMenu() { + VMenuBar menubar = getParentMenu(); + + // Traverse up until root menu is found + while (menubar.getParentMenu() != null) { + menubar = menubar.getParentMenu(); + } + + return menubar; + } + } /** @@ -830,6 +912,10 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, private int paddingWidth = -1; public void iLayout() { + iLayout(false); + } + + public void iLayout(boolean iconLoadEvent) { // Only collapse if there is more than one item in the root menu and the // menu has an explicit size if ((getItems().size() > 1 || (collapsedRootItems != null && collapsedRootItems @@ -912,6 +998,17 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable, addItem(moreItem); } } + + // If a popup is open we might need to adjust the shadow as well if an + // icon shown in that popup was loaded + if (popup != null) { + // Forces a recalculation of the shadow size + popup.show(); + } + if (iconLoadEvent) { + // Size have changed if the width is undefined + Util.notifyParentOfSizeChange(this, false); + } } private int getConsumedWidth() { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java index 21e74bab09..7cbaca1c19 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java @@ -4,6 +4,7 @@ package com.vaadin.terminal.gwt.client.ui; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -14,7 +15,6 @@ import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Button; import com.vaadin.terminal.gwt.client.ApplicationConnection; @@ -123,7 +123,7 @@ public class VNativeButton extends Button implements Paintable, ClickHandler, * issues with a button with an icon using the reindeer theme */ if (width.equals("")) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { setWidth(""); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeSelect.java index a1c4e0ba01..5e47ac571e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNativeSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeSelect.java @@ -38,7 +38,7 @@ public class VNativeSelect extends VOptionGroupBase implements Field { select.addItem("", null); } boolean selected = false; - for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL optionUidl = (UIDL) i.next(); select.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key")); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java index c27c03287d..b6ae9cca1a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java @@ -10,6 +10,7 @@ import java.util.Iterator; import java.util.List;
import java.util.Map;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -17,7 +18,6 @@ import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Focusable;
@@ -35,7 +35,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, private final Panel panel;
- private final Map optionsToKeys;
+ private final Map<CheckBox, String> optionsToKeys;
private boolean sendFocusEvents = false;
private boolean sendBlurEvents = false;
@@ -54,7 +54,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, public VOptionGroup() {
super(CLASSNAME);
panel = (Panel) optionsContainer;
- optionsToKeys = new HashMap();
+ optionsToKeys = new HashMap<CheckBox, String>();
}
@Override
@@ -98,7 +98,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, @Override
protected void buildOptions(UIDL uidl) {
panel.clear();
- for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
final UIDL opUidl = (UIDL) it.next();
CheckBox op;
if (isMultiselect()) {
@@ -130,7 +130,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, super.onClick(event);
if (event.getSource() instanceof CheckBox) {
final boolean selected = ((CheckBox) event.getSource()).getValue();
- final String key = (String) optionsToKeys.get(event.getSource());
+ final String key = optionsToKeys.get(event.getSource());
if (!isMultiselect()) {
selectedKeys.clear();
}
@@ -146,7 +146,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, @Override
protected void setTabIndex(int tabIndex) {
- for (Iterator iterator = panel.iterator(); iterator.hasNext();) {
+ for (Iterator<Widget> iterator = panel.iterator(); iterator.hasNext();) {
FocusWidget widget = (FocusWidget) iterator.next();
widget.setTabIndex(tabIndex);
}
@@ -179,7 +179,7 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, public void onBlur(BlurEvent arg0) {
blurOccured = true;
if (sendBlurEvents) {
- DeferredCommand.addCommand(new Command() {
+ Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
// check whether blurOccured still is true and then send the
// event out to the server
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java index 0f6cb0fe68..9b1471b0e3 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java @@ -64,7 +64,7 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, calendar = GWT.create(VCalendarPanel.class);
calendar.setFocusOutListener(new FocusOutListener() {
- public boolean onFocusOut(DomEvent event) {
+ public boolean onFocusOut(DomEvent<?> event) {
event.preventDefault();
closeCalendarPanel();
return true;
@@ -99,6 +99,7 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, }
+ @SuppressWarnings("deprecation")
private void updateValue(Date newDate) {
Date currentDate = getCurrentDate();
if (currentDate == null || newDate.getTime() != currentDate.getTime()) {
@@ -148,6 +149,7 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, * com.vaadin.terminal.gwt.client.ApplicationConnection)
*/
@Override
+ @SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
boolean lastReadOnlyState = readonly;
parsable = uidl.getBooleanAttribute("parsable");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index b1ebb763bf..bc8b1eefc4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Set; import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.NodeList; @@ -40,7 +41,6 @@ import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; @@ -687,12 +687,19 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, tFoot.clear(); } + int oldPageLength = pageLength; if (uidl.hasAttribute("pagelength")) { pageLength = uidl.getIntAttribute("pagelength"); } else { // pagelenght is "0" meaning scrolling is turned off pageLength = totalRows; } + + if (oldPageLength != pageLength && initializedAndAttached) { + // page length changed, need to update size + sizeInit(); + } + firstvisible = uidl.hasVariable("firstvisible") ? uidl .getIntVariable("firstvisible") : 0; if (firstvisible != lastRequestedFirstvisible && scrollBody != null) { @@ -809,7 +816,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // webkits may still bug with their disturbing scrollbar bug, // See #3457 // run overflow fix for scrollable area - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { Util.runWebkitOverflowAutoFix(scrollBodyPanel .getElement()); @@ -1485,7 +1492,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, if (firstvisible > 0) { // Deferred due some Firefox oddities. IE & Safari could survive // without - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { scrollBodyPanel .setScrollPosition((int) (firstvisible * scrollBody @@ -1520,7 +1527,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, * (child components widths are correct) */ scrollBody.reLayoutComponents(); - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement()); } @@ -1594,9 +1601,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // tell scroll position to user if currently "visible" rows are // not rendered - if ((firstRowInViewPort + pageLength > scrollBody - .getLastRendered()) - || (firstRowInViewPort < scrollBody.getFirstRendered())) { + if (totalRows > pageLength + && ((firstRowInViewPort + pageLength > scrollBody + .getLastRendered()) || (firstRowInViewPort < scrollBody + .getFirstRendered()))) { announceScrollPosition(); } else { hideScrollPositionAnnotation(); @@ -1797,7 +1805,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, int tdWidth = width + scrollBody.getCellExtraWidth(); setWidth(tdWidth + "px"); } else { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { int tdWidth = width + scrollBody.getCellExtraWidth(); @@ -1862,10 +1870,16 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, onResizeEvent(event); } } else { - handleCaptionEvent(event); - if (DOM.eventGetType(event) == Event.ONMOUSEUP) { + /* + * Ensure focus before handling caption event. Otherwise + * variables changed from caption event may be before + * variables from other components that fire variables when + * they lose focus. + */ + if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) { scrollBodyPanel.setFocus(true); } + handleCaptionEvent(event); event.stopPropagation(); event.preventDefault(); } @@ -1966,7 +1980,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, rowRequestHandler.setReqFirstRow(0); rowRequestHandler.setReqRows((int) (2 * pageLength * cache_rate + pageLength)); - rowRequestHandler.deferRowFetch(); + rowRequestHandler.deferRowFetch(); // some validation + + // defer 250ms + rowRequestHandler.cancel(); // instead of waiting + rowRequestHandler.run(); // run immediately } fireHeaderClickedEvent(event); break; @@ -2691,7 +2708,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, - borderWidths; setWidth(tdWidth + "px"); } else { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { int borderWidths = 1; int tdWidth = width @@ -4437,14 +4454,20 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } setContentWidth(innerPixels); - if (!rendering) { - // readjust undefined width columns - lazyAdjustColumnWidths.cancel(); - lazyAdjustColumnWidths.schedule(LAZY_COLUMN_ADJUST_TIMEOUT); - } + // readjust undefined width columns + lazyAdjustColumnWidths.cancel(); + lazyAdjustColumnWidths.schedule(LAZY_COLUMN_ADJUST_TIMEOUT); } else { + // Undefined width super.setWidth(""); + + // Readjust size of table + sizeInit(); + + // readjust undefined width columns + lazyAdjustColumnWidths.cancel(); + lazyAdjustColumnWidths.schedule(LAZY_COLUMN_ADJUST_TIMEOUT); } /* @@ -4541,7 +4564,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } } scrollBody.reLayoutComponents(); - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement()); } @@ -4658,7 +4681,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, super.setVisible(visible); if (initializedAndAttached) { if (visible) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { scrollBodyPanel .setScrollPosition((int) (firstRowInViewPort * scrollBody @@ -4711,7 +4734,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // for webkit, although it really is not. Expecting to have the // correct // value available soon. - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { onScroll(null); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSlider.java b/src/com/vaadin/terminal/gwt/client/ui/VSlider.java index 9b7103d39f..a392b1f780 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSlider.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSlider.java @@ -4,10 +4,10 @@ //
package com.vaadin.terminal.gwt.client.ui;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
@@ -46,7 +46,6 @@ public class VSlider extends SimpleFocusablePanel implements Paintable, Field, private int resolution;
private Double value;
private boolean vertical;
- private final int size = -1;
private boolean arrows;
private final HTML feedback = new HTML("", false);
@@ -159,7 +158,7 @@ public class VSlider extends SimpleFocusablePanel implements Paintable, Field, if (!vertical) {
// Draw handle with a delay to allow base to gain maximum width
- DeferredCommand.addCommand(new Command() {
+ Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
buildHandle();
setValue(value, false);
@@ -198,35 +197,31 @@ public class VSlider extends SimpleFocusablePanel implements Paintable, Field, final String styleAttribute = vertical ? "height" : "width";
final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
- if (size == -1) {
- final Element p = DOM.getParent(getElement());
- if (DOM.getElementPropertyInt(p, domProperty) > 50) {
- if (vertical) {
- setHeight();
- } else {
- DOM.setStyleAttribute(base, styleAttribute, "");
- }
+ final Element p = DOM.getParent(getElement());
+ if (DOM.getElementPropertyInt(p, domProperty) > 50) {
+ if (vertical) {
+ setHeight();
} else {
- // Set minimum size and adjust after all components have
- // (supposedly) been drawn completely.
- DOM.setStyleAttribute(base, styleAttribute, MIN_SIZE + "px");
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- final Element p = DOM.getParent(getElement());
- if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) {
- if (vertical) {
- setHeight();
- } else {
- DOM.setStyleAttribute(base, styleAttribute, "");
- }
- // Ensure correct position
- setValue(value, false);
- }
- }
- });
+ DOM.setStyleAttribute(base, styleAttribute, "");
}
} else {
- DOM.setStyleAttribute(base, styleAttribute, size + "px");
+ // Set minimum size and adjust after all components have
+ // (supposedly) been drawn completely.
+ DOM.setStyleAttribute(base, styleAttribute, MIN_SIZE + "px");
+ Scheduler.get().scheduleDeferred(new Command() {
+ public void execute() {
+ final Element p = DOM.getParent(getElement());
+ if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) {
+ if (vertical) {
+ setHeight();
+ } else {
+ DOM.setStyleAttribute(base, styleAttribute, "");
+ }
+ // Ensure correct position
+ setValue(value, false);
+ }
+ }
+ });
}
// TODO attach listeners for focusing and arrow keys
@@ -493,18 +488,14 @@ public class VSlider extends SimpleFocusablePanel implements Paintable, Field, }
private void setHeight() {
- if (size == -1) {
- // Calculate decoration size
- DOM.setStyleAttribute(base, "height", "0");
- DOM.setStyleAttribute(base, "overflow", "hidden");
- int h = DOM.getElementPropertyInt(getElement(), "offsetHeight");
- if (h < MIN_SIZE) {
- h = MIN_SIZE;
- }
- DOM.setStyleAttribute(base, "height", h + "px");
- } else {
- DOM.setStyleAttribute(base, "height", size + "px");
+ // Calculate decoration size
+ DOM.setStyleAttribute(base, "height", "0");
+ DOM.setStyleAttribute(base, "overflow", "hidden");
+ int h = DOM.getElementPropertyInt(getElement(), "offsetHeight");
+ if (h < MIN_SIZE) {
+ h = MIN_SIZE;
}
+ DOM.setStyleAttribute(base, "height", h + "px");
DOM.setStyleAttribute(base, "overflow", "");
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index 0b0a9befa3..33c13f6742 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -1,4 +1,4 @@ -/* +/* @ITMillApache2LicenseForJavaFiles@ */ @@ -6,13 +6,13 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.Set; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.ComplexPanel; @@ -107,6 +107,8 @@ public class VSplitPanel extends ComplexPanel implements Container, private boolean locked = false; + private boolean positionReversed = false; + private String[] componentStyleNames; private Element draggingCurtain; @@ -215,6 +217,8 @@ public class VSplitPanel extends ComplexPanel implements Container, setLocked(uidl.getBooleanAttribute("locked")); + setPositionReversed(uidl.getBooleanAttribute("reversed")); + setStylenames(); position = uidl.getStringAttribute("position"); @@ -243,7 +247,7 @@ public class VSplitPanel extends ComplexPanel implements Container, if (BrowserInfo.get().isIE7()) { // Part III of IE7 hack - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { iLayout(); } @@ -266,6 +270,20 @@ public class VSplitPanel extends ComplexPanel implements Container, } } + private void setPositionReversed(boolean reversed) { + if (positionReversed != reversed) { + if (orientation == ORIENTATION_HORIZONTAL) { + DOM.setStyleAttribute(splitter, "right", ""); + DOM.setStyleAttribute(splitter, "left", ""); + } else if (orientation == ORIENTATION_VERTICAL) { + DOM.setStyleAttribute(splitter, "top", ""); + DOM.setStyleAttribute(splitter, "bottom", ""); + } + + positionReversed = reversed; + } + } + private void setSplitPosition(String pos) { if (pos == null) { return; @@ -280,9 +298,17 @@ public class VSplitPanel extends ComplexPanel implements Container, } if (orientation == ORIENTATION_HORIZONTAL) { - DOM.setStyleAttribute(splitter, "left", pos); + if (positionReversed) { + DOM.setStyleAttribute(splitter, "right", pos); + } else { + DOM.setStyleAttribute(splitter, "left", pos); + } } else { - DOM.setStyleAttribute(splitter, "top", pos); + if (positionReversed) { + DOM.setStyleAttribute(splitter, "bottom", pos); + } else { + DOM.setStyleAttribute(splitter, "top", pos); + } } iLayout(); @@ -310,8 +336,8 @@ public class VSplitPanel extends ComplexPanel implements Container, pixelPosition = DOM.getElementPropertyInt(splitter, "offsetLeft"); // reposition splitter in case it is out of box - if (pixelPosition > 0 - && pixelPosition + getSplitterSize() > wholeSize) { + if ((pixelPosition > 0 && pixelPosition + getSplitterSize() > wholeSize) + || (positionReversed && pixelPosition < 0)) { pixelPosition = wholeSize - getSplitterSize(); if (pixelPosition < 0) { pixelPosition = 0; @@ -342,8 +368,8 @@ public class VSplitPanel extends ComplexPanel implements Container, pixelPosition = DOM.getElementPropertyInt(splitter, "offsetTop"); // reposition splitter in case it is out of box - if (pixelPosition > 0 - && pixelPosition + getSplitterSize() > wholeSize) { + if ((pixelPosition > 0 && pixelPosition + getSplitterSize() > wholeSize) + || (positionReversed && pixelPosition < 0)) { pixelPosition = wholeSize - getSplitterSize(); if (pixelPosition < 0) { pixelPosition = 0; @@ -479,9 +505,23 @@ public class VSplitPanel extends ComplexPanel implements Container, if (newX + getSplitterSize() >= getOffsetWidth()) { pos = getOffsetWidth(); } - position = pos / getOffsetWidth() * 100 + "%"; + // Reversed position + if (positionReversed) { + pos = getOffsetWidth() - pos; + } + position = (pos / getOffsetWidth() * 100) + "%"; } else { - position = newX + "px"; + // Reversed position + if (positionReversed) { + position = (getOffsetWidth() - newX - getSplitterSize()) + "px"; + } else { + position = newX + "px"; + } + } + + // Reversed position + if (positionReversed) { + newX = getOffsetWidth() - newX - getSplitterSize(); } setSplitPosition(newX + "px"); @@ -507,9 +547,24 @@ public class VSplitPanel extends ComplexPanel implements Container, if (newY + getSplitterSize() >= getOffsetHeight()) { pos = getOffsetHeight(); } + // Reversed position + if(positionReversed){ + pos = getOffsetHeight() - pos - getSplitterSize(); + } position = pos / getOffsetHeight() * 100 + "%"; } else { - position = newY + "px"; + // Reversed position + if (positionReversed) { + position = (getOffsetHeight() - newY - getSplitterSize()) + + "px"; + } else { + position = newY + "px"; + } + } + + // Reversed position + if (positionReversed) { + newY = getOffsetHeight() - newY - getSplitterSize(); } setSplitPosition(newY + "px"); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTablePaging.java b/src/com/vaadin/terminal/gwt/client/ui/VTablePaging.java index 24999aaa25..39f271c25e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTablePaging.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTablePaging.java @@ -55,7 +55,7 @@ public class VTablePaging extends Composite implements Table, Paintable, private int totalRows; - private final HashMap visibleColumns = new HashMap(); + private final HashMap<?, ?> visibleColumns = new HashMap<Object, Object>(); private int rows; @@ -63,7 +63,7 @@ public class VTablePaging extends Composite implements Table, Paintable, private boolean sortAscending = true; private final HorizontalPanel pager; - public HashMap rowKeysToTableRows = new HashMap(); + public HashMap<String, TableRow> rowKeysToTableRows = new HashMap<String, TableRow>(); public VTablePaging() { @@ -128,7 +128,7 @@ public class VTablePaging extends Composite implements Table, Paintable, UIDL rowData = null; UIDL visibleColumns = null; - for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { + for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { final UIDL c = (UIDL) it.next(); if (c.getTag().equals("rows")) { rowData = c; @@ -147,7 +147,7 @@ public class VTablePaging extends Composite implements Table, Paintable, } private void updateHeader(UIDL c) { - final Iterator it = c.getChildIterator(); + final Iterator<?> it = c.getChildIterator(); visibleColumns.clear(); int colIndex = (rowHeaders ? 1 : 0); while (it.hasNext()) { @@ -178,7 +178,7 @@ public class VTablePaging extends Composite implements Table, Paintable, * which contains row data */ private void updateBody(UIDL uidl) { - final Iterator it = uidl.getChildIterator(); + final Iterator<?> it = uidl.getChildIterator(); int curRowIndex = 1; while (it.hasNext()) { @@ -192,7 +192,7 @@ public class VTablePaging extends Composite implements Table, Paintable, rowUidl.getStringAttribute("caption"))); colIndex++; } - final Iterator cells = rowUidl.getChildIterator(); + final Iterator<?> cells = rowUidl.getChildIterator(); while (cells.hasNext()) { final Object cell = cells.next(); if (cell instanceof String) { @@ -375,7 +375,7 @@ public class VTablePaging extends Composite implements Table, Paintable, } } - public void setContextMenuOptions(HashMap options) { + public void setContextMenuOptions(HashMap<?, ?> options) { } @@ -415,8 +415,7 @@ public class VTablePaging extends Composite implements Table, Paintable, public void deselectAll() { final Object[] keys = selectedRowKeys.toArray(); for (int i = 0; i < keys.length; i++) { - final TableRow tableRow = (TableRow) rowKeysToTableRows - .get(keys[i]); + final TableRow tableRow = rowKeysToTableRows.get(keys[i]); if (tableRow != null) { tableRow.setSelected(false); } @@ -435,7 +434,7 @@ public class VTablePaging extends Composite implements Table, Paintable, } - public Iterator iterator() { + public Iterator<Widget> iterator() { // TODO Auto-generated method stub return null; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java index 2ca1eb3a6f..678f01d79b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Set; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.TableCellElement; @@ -16,7 +17,6 @@ import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.ComplexPanel; @@ -338,7 +338,7 @@ public class VTabsheet extends VTabsheetBase { addStyleDependentName("loading"); // run updating variables in deferred command to bypass some FF // optimization issues - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { previousVisibleWidget = tp.getWidget(tp.getVisibleWidget()); DOM.setStyleAttribute( @@ -890,7 +890,7 @@ public class VTabsheet extends VTabsheetBase { */ final Style style = scroller.getStyle(); style.setProperty("whiteSpace", "normal"); - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { style.setProperty("whiteSpace", ""); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBase.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBase.java index 1ed309dc05..5e7f7c4fb4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBase.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheetBase.java @@ -21,11 +21,11 @@ abstract class VTabsheetBase extends ComplexPanel implements Container { String id; ApplicationConnection client; - protected final ArrayList tabKeys = new ArrayList(); + protected final ArrayList<String> tabKeys = new ArrayList<String>(); protected int activeTabIndex = 0; protected boolean disabled; protected boolean readonly; - protected Set disabledTabKeys = new HashSet(); + protected Set<String> disabledTabKeys = new HashSet<String>(); protected boolean cachedUpdate = false; public VTabsheetBase(String classname) { @@ -50,8 +50,9 @@ abstract class VTabsheetBase extends ComplexPanel implements Container { final UIDL tabs = uidl.getChildUIDL(0); // Paintables in the TabSheet before update - ArrayList oldPaintables = new ArrayList(); - for (Iterator iterator = getPaintableIterator(); iterator.hasNext();) { + ArrayList<Object> oldPaintables = new ArrayList<Object>(); + for (Iterator<Object> iterator = getPaintableIterator(); iterator + .hasNext();) { oldPaintables.add(iterator.next()); } @@ -60,7 +61,7 @@ abstract class VTabsheetBase extends ComplexPanel implements Container { disabledTabKeys.clear(); int index = 0; - for (final Iterator it = tabs.getChildIterator(); it.hasNext();) { + for (final Iterator<Object> it = tabs.getChildIterator(); it.hasNext();) { final UIDL tab = (UIDL) it.next(); final String key = tab.getStringAttribute("key"); final boolean selected = tab.getBooleanAttribute("selected"); @@ -90,7 +91,8 @@ abstract class VTabsheetBase extends ComplexPanel implements Container { } // Perform unregister for any paintables removed during update - for (Iterator iterator = oldPaintables.iterator(); iterator.hasNext();) { + for (Iterator<Object> iterator = oldPaintables.iterator(); iterator + .hasNext();) { Object oldPaintable = iterator.next(); if (oldPaintable instanceof Paintable) { Widget w = (Widget) oldPaintable; @@ -105,8 +107,12 @@ abstract class VTabsheetBase extends ComplexPanel implements Container { /** * @return a list of currently shown Paintables + * + * Apparently can be something else than Paintable as + * {@link #updateFromUIDL(UIDL, ApplicationConnection)} checks if + * instanceof Paintable. Therefore set to <Object> */ - abstract protected Iterator getPaintableIterator(); + abstract protected Iterator<Object> getPaintableIterator(); /** * Clears current tabs and contents diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java index 07d0588681..cf81ce1fb8 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java @@ -4,9 +4,9 @@ package com.vaadin.terminal.gwt.client.ui;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
@@ -58,7 +58,7 @@ public class VTextArea extends VTextField { @Override
public void onBrowserEvent(Event event) {
if (getMaxLength() >= 0 && event.getTypeInt() == Event.ONKEYPRESS) {
- DeferredCommand.addCommand(new Command() {
+ Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
if (getText().length() > getMaxLength()) {
setText(getText().substring(0, getMaxLength()));
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java index 3311eef1c5..49d31d6194 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java @@ -4,6 +4,7 @@ package com.vaadin.terminal.gwt.client.ui; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ChangeEvent; @@ -12,9 +13,9 @@ import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.TextBoxBase; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; @@ -34,6 +35,7 @@ import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutAct public class VTextField extends TextBoxBase implements Paintable, Field, ChangeHandler, FocusHandler, BlurHandler, BeforeShortcutActionListener { + public static final String VAR_CUR_TEXT = "curText"; /** * The input node CSS classname. */ @@ -56,11 +58,16 @@ public class VTextField extends TextBoxBase implements Paintable, Field, private static final String CLASSNAME_PROMPT = "prompt"; private static final String ATTR_INPUTPROMPT = "prompt"; - private static final String VAR_CURSOR = "c"; + public static final String ATTR_TEXTCHANGE_TIMEOUT = "iet"; + public static final String VAR_CURSOR = "c"; + public static final String ATTR_TEXTCHANGE_EVENTMODE = "iem"; + private static final String TEXTCHANGE_MODE_EAGER = "EAGER"; + private static final String TEXTCHANGE_MODE_TIMEOUT = "TIMEOUT"; private String inputPrompt = null; private boolean prompting = false; private int lastCursorPos = -1; + private boolean wordwrap = true; public VTextField() { this(DOM.createInputText()); @@ -81,12 +88,83 @@ public class VTextField extends TextBoxBase implements Paintable, Field, sinkEvents(VTooltip.TOOLTIP_EVENTS); } + /* + * TODO When GWT adds ONCUT, add it there and remove workaround. See + * http://code.google.com/p/google-web-toolkit/issues/detail?id=4030 + * + * Also note that the cut/paste are not totally crossbrowsers compatible. + * E.g. in Opera mac works via context menu, but on via File->Paste/Cut. + * Opera might need the polling method for 100% working textchanceevents. + * Eager polling for a change is bit dum and heavy operation, so I guess we + * should first try to survive without. + */ + private static final int TEXTCHANGE_EVENTS = Event.ONPASTE + | Event.KEYEVENTS | Event.ONMOUSEUP; + @Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (client != null) { client.handleTooltipEvent(event, this); } + + if (listenTextChangeEvents + && (event.getTypeInt() & TEXTCHANGE_EVENTS) == event + .getTypeInt()) { + deferTextChangeEvent(); + } + + } + + /* + * TODO optimize this so that only changes are sent + make the value change + * event just a flag that moves the current text to value + */ + private String lastTextChangeString = null; + + private String getLastCommunicatedString() { + return lastTextChangeString; + } + + private boolean communicateTextValueToServer() { + String text = getText(); + if (!text.equals(getLastCommunicatedString())) { + lastTextChangeString = text; + client.updateVariable(id, VAR_CUR_TEXT, text, true); + return true; + } + return false; + } + + private Timer textChangeEventTrigger = new Timer() { + + @Override + public void run() { + updateCursorPosition(); + boolean textChanged = communicateTextValueToServer(); + if (textChanged) { + client.sendPendingVariableChanges(); + } + scheduled = false; + } + }; + private boolean scheduled = false; + private boolean listenTextChangeEvents; + private String textChangeEventMode; + private int textChangeEventTimeout; + + private void deferTextChangeEvent() { + if (textChangeEventMode.equals(TEXTCHANGE_MODE_TIMEOUT) && scheduled) { + return; + } else { + textChangeEventTrigger.cancel(); + } + textChangeEventTrigger.schedule(getInputEventTimeout()); + scheduled = true; + } + + private int getInputEventTimeout() { + return textChangeEventTimeout; } @Override @@ -127,6 +205,20 @@ public class VTextField extends TextBoxBase implements Paintable, Field, immediate = uidl.getBooleanAttribute("immediate"); + listenTextChangeEvents = client.hasEventListeners(this, "ie"); + if (listenTextChangeEvents) { + textChangeEventMode = uidl + .getStringAttribute(ATTR_TEXTCHANGE_EVENTMODE); + if (textChangeEventMode.equals(TEXTCHANGE_MODE_EAGER)) { + textChangeEventTimeout = 1; + } else { + textChangeEventTimeout = uidl + .getIntAttribute(ATTR_TEXTCHANGE_TIMEOUT); + } + sinkEvents(TEXTCHANGE_EVENTS); + attachCutEventListener(getElement()); + } + if (uidl.hasAttribute("cols")) { setColumns(new Integer(uidl.getStringAttribute("cols")).intValue()); } @@ -144,7 +236,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field, * stabilized. In tests, about ten times better performance is * achieved with this optimization. See for eg. #2898 */ - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { String fieldValue; if (prompting) { @@ -154,7 +246,13 @@ public class VTextField extends TextBoxBase implements Paintable, Field, fieldValue = text; removeStyleDependentName(CLASSNAME_PROMPT); } - setText(fieldValue); + /* + * Avoid resetting the old value. Prevents cursor flickering + * which then again happens due to this Gecko hack. + */ + if (!getText().equals(fieldValue)) { + setText(fieldValue); + } } }); } else { @@ -169,7 +267,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field, setText(fieldValue); } - valueBeforeEdit = uidl.getStringVariable("text"); + lastTextChangeString = valueBeforeEdit = uidl.getStringVariable("text"); if (uidl.hasAttribute("selpos")) { final int pos = uidl.getIntAttribute("selpos"); @@ -177,12 +275,55 @@ public class VTextField extends TextBoxBase implements Paintable, Field, /* * Gecko defers setting the text so we need to defer the selection. */ - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { setSelectionRange(pos, length); } }); } + + // Here for backward compatibility; to be moved to TextArea. + // Optimization: server does not send attribute for the default 'true' + // state. + if (uidl.hasAttribute("wordwrap") + && uidl.getBooleanAttribute("wordwrap") == false) { + setWordwrap(false); + } else { + setWordwrap(true); + } + } + + protected void onCut() { + if (listenTextChangeEvents) { + deferTextChangeEvent(); + } + } + + protected native void attachCutEventListener(Element el) + /*-{ + var me = this; + el.oncut = function() { + me.@com.vaadin.terminal.gwt.client.ui.VTextField::onCut()(); + }; + }-*/; + + protected native void detachCutEventListener(Element el) + /*-{ + el.oncut = null; + }-*/; + + @Override + protected void onDetach() { + super.onDetach(); + detachCutEventListener(getElement()); + } + + @Override + protected void onAttach() { + super.onAttach(); + if (listenTextChangeEvents) { + detachCutEventListener(getElement()); + } } private void setMaxLength(int newMaxLength) { @@ -245,6 +386,11 @@ public class VTextField extends TextBoxBase implements Paintable, Field, updateCursorPosition(); if (sendBlurEvent || sendValueChange) { + /* + * Avoid sending text change event as we will simulate it on the + * server side before value change events. + */ + textChangeEventTrigger.cancel(); client.sendPendingVariableChanges(); } } @@ -403,4 +549,19 @@ public class VTextField extends TextBoxBase implements Paintable, Field, valueChange(false); } + // Here for backward compatibility; to be moved to TextArea + public void setWordwrap(boolean enabled) { + if (enabled == wordwrap) { + return; // No change + } + + if (enabled) { + DOM.removeElementAttribute(getElement(), "wrap"); + DOM.setStyleAttribute(getElement(), "overflow", null); + } else { + DOM.setElementAttribute(getElement(), "wrap", "off"); + DOM.setStyleAttribute(getElement(), "overflow", "auto"); + } + wordwrap = enabled; + } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java index df5a0a1db6..e4253c979f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java @@ -135,8 +135,8 @@ public class VTextualDate extends VDateField implements Paintable, Field, String frmString = LocaleService .getDateFormat(currentLocale); frmString = cleanFormat(frmString); - String delim = LocaleService - .getClockDelimiter(currentLocale); + // String delim = LocaleService + // .getClockDelimiter(currentLocale); if (currentResolution >= RESOLUTION_HOUR) { if (dts.isTwelveHourClock()) { @@ -211,6 +211,7 @@ public class VTextualDate extends VDateField implements Paintable, Field, } } + @SuppressWarnings("deprecation") public void onChange(ChangeEvent event) { if (!text.getText().equals("")) { try { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTree.java b/src/com/vaadin/terminal/gwt/client/ui/VTree.java index edf04c913b..f903d60cc4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTree.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTree.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Set; import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -25,7 +26,6 @@ import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; @@ -171,7 +171,7 @@ public class VTree extends SimpleFocusablePanel implements Paintable, } private void updateActionMap(UIDL c) { - final Iterator it = c.getChildIterator(); + final Iterator<?> it = c.getChildIterator(); while (it.hasNext()) { final UIDL action = (UIDL) it.next(); final String key = action.getStringAttribute("key"); @@ -223,7 +223,7 @@ public class VTree extends SimpleFocusablePanel implements Paintable, isNullSelectionAllowed = uidl.getBooleanAttribute("nullselect"); body.clear(); - for (final Iterator i = uidl.getChildIterator(); i.hasNext();) { + for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL childUidl = (UIDL) i.next(); if ("actions".equals(childUidl.getTag())) { updateActionMap(childUidl); @@ -890,7 +890,7 @@ public class VTree extends SimpleFocusablePanel implements Paintable, DOM.setInnerText(nodeCaptionSpan, text); } - private void renderChildNodes(Iterator i) { + private void renderChildNodes(Iterator<?> i) { childNodeContainer.clear(); childNodeContainer.setVisible(true); while (i.hasNext()) { @@ -1498,7 +1498,7 @@ public class VTree extends SimpleFocusablePanel implements Paintable, if (!rendering) { node.scrollIntoView(); } else { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { focusedNode.scrollIntoView(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTwinColSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VTwinColSelect.java index 2733836f1e..24d6dee749 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTwinColSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTwinColSelect.java @@ -115,7 +115,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, remove.setEnabled(enabled);
options.clear();
selections.clear();
- for (final Iterator i = uidl.getChildIterator(); i.hasNext();) {
+ for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
final UIDL optionUidl = (UIDL) i.next();
if (optionUidl.hasAttribute("selected")) {
selections.addItem(optionUidl.getStringAttribute("caption"),
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java b/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java index 062df4f6ae..e03d450243 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java @@ -17,10 +17,9 @@ public class VUnknownComponent extends Composite implements Paintable { com.google.gwt.user.client.ui.Label caption = new com.google.gwt.user.client.ui.Label();; Tree uidlTree; private VerticalPanel panel; - private String serverClassName; + private String serverClassName = "unkwnown"; - public VUnknownComponent(String serverClassName) { - this.serverClassName = serverClassName; + public VUnknownComponent() { panel = new VerticalPanel(); panel.add(caption); initWidget(panel); @@ -28,6 +27,10 @@ public class VUnknownComponent extends Composite implements Paintable { caption.setStyleName("vaadin-unknown-caption"); } + public void setServerSideClassName(String serverClassName) { + this.serverClassName = serverClassName; + } + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { if (client.updateComponent(this, uidl, false)) { return; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUpload.java b/src/com/vaadin/terminal/gwt/client/ui/VUpload.java index b175a50619..f267f97860 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VUpload.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VUpload.java @@ -5,13 +5,13 @@ package com.vaadin.terminal.gwt.client.ui; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.FormElement; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; @@ -147,7 +147,7 @@ public class VUpload extends SimplePanel implements Paintable { this.client = client; paintableId = uidl.getId(); nextUploadId = uidl.getIntAttribute("nextid"); - element.setAction(client.getAppUri()); + element.setAction(uidl.getStringVariable("action")); submitButton.setText(uidl.getStringAttribute("buttoncaption")); fu.setName(paintableId + "_file"); @@ -217,10 +217,9 @@ public class VUpload extends SimplePanel implements Paintable { /** * Called by JSNI (hooked via {@link #onloadstrategy}) */ - @SuppressWarnings("unused") private void onSubmitComplete() { /* Needs to be run dereferred to avoid various browser issues. */ - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { if (client != null) { if (t != null) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index a0af7f90d5..00fc937421 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -10,6 +10,7 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.event.dom.client.DomEvent.Type; @@ -19,7 +20,6 @@ import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; @@ -190,7 +190,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler, // source will be opened to this browser window, but we may have // to finish rendering this window in case this is a download // (and window stays open). - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { goTo(url); } @@ -271,7 +271,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler, String script = childUidl.getStringAttribute("script"); eval(script); } else if (tag == "notifications") { - for (final Iterator it = childUidl.getChildIterator(); it + for (final Iterator<?> it = childUidl.getChildIterator(); it .hasNext();) { final UIDL notification = (UIDL) it.next(); String html = ""; @@ -322,7 +322,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler, if (uidl.hasAttribute("focused")) { // set focused component when render phase is finished - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { final Paintable toBeFocused = uidl.getPaintableAttribute( "focused", connection); @@ -383,7 +383,7 @@ public class VView extends SimplePanel implements Container, ResizeHandler, */ void scrollIntoView(final UIDL uidl) { if (uidl.hasAttribute("scrollTo")) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { final Paintable paintable = uidl.getPaintableAttribute( "scrollTo", connection); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index ec26626015..add0590e7c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -8,12 +8,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Set; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.DomEvent.Type; import com.google.gwt.event.shared.EventHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; @@ -403,7 +403,7 @@ public class VWindow extends VOverlay implements Container, ScrollListener, shortcutHandler.updateActionMap(childUidl); } else if (childUidl.getTag().equals("notifications")) { // TODO needed? move -> - for (final Iterator it = childUidl.getChildIterator(); it + for (final Iterator<?> it = childUidl.getChildIterator(); it .hasNext();) { final UIDL notification = (UIDL) it.next(); String html = ""; @@ -639,7 +639,7 @@ public class VWindow extends VOverlay implements Container, ScrollListener, /** Disable overflow auto with FF3 to fix #1837. */ private void fixFF3OverflowBug() { if (BrowserInfo.get().isFF3()) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { DOM.setStyleAttribute(getElement(), "overflow", ""); } @@ -658,7 +658,7 @@ public class VWindow extends VOverlay implements Container, ScrollListener, private void setFF2CaretFixEnabled(boolean enable) { if (BrowserInfo.get().isFF2()) { if (enable) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { DOM.setStyleAttribute(getElement(), "overflow", "auto"); } @@ -687,7 +687,7 @@ public class VWindow extends VOverlay implements Container, ScrollListener, showModalityCurtain(); bringToFront(); } else { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { // vaadinModality window must on top of others bringToFront(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5File.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5File.java index 2e72eead9e..756d102690 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5File.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5File.java @@ -4,8 +4,6 @@ import com.google.gwt.core.client.JavaScriptObject; /** * Wrapper for html5 File object. - * - * TODO gear support? */ public class VHtml5File extends JavaScriptObject { @@ -27,27 +25,4 @@ public class VHtml5File extends JavaScriptObject { return this.size ? this.size : 0; }-*/; - public native final void readAsBinary(final Callback callback) - /*-{ - var r = new FileReader(); - r.onloadend = function(content) { - callback.@com.vaadin.terminal.gwt.client.ui.dd.VHtml5File.Callback::handleFile(Lcom/google/gwt/core/client/JavaScriptObject;)(content); - }; - r.readAsBinaryString(this); - var j = 0; - - }-*/; - - public native final void readAsDataUrl(final Callback callback) - /*-{ - var r = new FileReader(); - r.onloadend = function(content) { - callback.@com.vaadin.terminal.gwt.client.ui.dd.VHtml5File.Callback::handleFile(Lcom/google/gwt/core/client/JavaScriptObject;)(content); - }; - r.readAsDataURL(this); - }-*/; - - public interface Callback { - public void handleFile(JavaScriptObject object); - } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java index 9279cc8bc3..8878b297ea 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VTargetDetailIs.java @@ -24,7 +24,7 @@ final public class VTargetDetailIs extends VAcceptCriterion { if (value != null) { Object object = drag.getDropDetails().get(name); if (object instanceof Enum) { - return ((Enum) object).name().equals(value); + return ((Enum<?>) object).name().equals(value); } else { return value.equals(object); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayout.java b/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayout.java index f573e36e09..64b1ea5f69 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayout.java @@ -342,8 +342,8 @@ public abstract class CellBasedLayout extends ComplexPanel implements Container throw new NullPointerException(); } } - ChildComponentContainer remove = widgetToComponentContainer - .remove(widget); + // ChildComponentContainer remove = + widgetToComponentContainer.remove(widget); remove(child); if (!relocated) { Paintable p = (Paintable) widget; diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java b/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java index babb00c61b..bcb972ca6a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java +++ b/src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java @@ -9,7 +9,6 @@ import java.util.NoSuchElementException; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.TableElement; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Widget; @@ -51,7 +50,7 @@ public class ChildComponentContainer extends Panel { private double expandRatio; - private int containerMarginLeft = 0; + // private int containerMarginLeft = 0; private int containerMarginTop = 0; AlignmentInfo alignment = AlignmentInfo.TOP_LEFT; @@ -80,7 +79,7 @@ public class ChildComponentContainer extends Panel { widgetDIV = Document.get().createDivElement(); if (BrowserInfo.get().isFF2()) { - Style style = widgetDIV.getStyle(); + // Style style = widgetDIV.getStyle(); // FF2 chokes on some floats very easily. Measuring size escpecially // becomes terribly slow TableElement tableEl = Document.get().createTableElement(); @@ -174,7 +173,7 @@ public class ChildComponentContainer extends Panel { // setWidth("0px"); contSize.setHeight(0); contSize.setWidth(0); - containerMarginLeft = 0; + // containerMarginLeft = 0; containerMarginTop = 0; containerDIV.getStyle().setProperty("paddingLeft", "0"); containerDIV.getStyle().setProperty("paddingTop", "0"); @@ -234,7 +233,7 @@ public class ChildComponentContainer extends Panel { } public void setMarginLeft(int marginLeft) { - containerMarginLeft = marginLeft; + // containerMarginLeft = marginLeft; containerDIV.getStyle().setPropertyPx("paddingLeft", marginLeft); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/CustomWebkitRichTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/CustomWebkitRichTextArea.java deleted file mode 100644 index 94086f3d45..0000000000 --- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/CustomWebkitRichTextArea.java +++ /dev/null @@ -1,38 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ -/** - * - */ -package com.vaadin.terminal.gwt.client.ui.richtextarea; - -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.impl.RichTextAreaImplSafari; - -/** - * TODO remove me when GWT RichTextArea is fixed. See #4279 (vaadin trac) - * - */ -class CustomWebkitRichTextArea extends RichTextAreaImplSafari { - public CustomWebkitRichTextArea() { - DeferredCommand.addCommand(new Command() { - public void execute() { - hookBlur(getElement()); - } - }); - } - - private native void hookBlur(Element iframe) - /*-{ - - iframe.contentDocument.documentElement.onblur = function(evt) { - if (iframe.__listener) { - iframe.__listener.@com.google.gwt.user.client.ui.Widget::onBrowserEvent(Lcom/google/gwt/user/client/Event;)(evt); - } - }; - - - }-*/; -}
\ No newline at end of file diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java index 8dcae8e735..59370b6dfc 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java +++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java @@ -4,6 +4,7 @@ package com.vaadin.terminal.gwt.client.ui.richtextarea; +import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ChangeEvent; @@ -15,11 +16,12 @@ import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Focusable; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RichTextArea; import com.google.gwt.user.client.ui.Widget; @@ -41,7 +43,7 @@ import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHan */ public class VRichTextArea extends Composite implements Paintable, Field, ChangeHandler, BlurHandler, KeyPressHandler, KeyDownHandler, - BeforeShortcutActionListener { + BeforeShortcutActionListener, Focusable { /** * The input node CSS classname. @@ -159,6 +161,33 @@ public class VRichTextArea extends Composite implements Paintable, Field, maxLength = -1; keyPressHandler.removeHandler(); } + + if (uidl.hasAttribute("selectAll")) { + selectAll(); + } + + } + + private void selectAll() { + /* + * There is a timing issue if trying to select all immediately on first + * render. Simple deferred command is not enough. Using Timer with + * moderated timeout. If this appears to fail on many (most likely slow) + * environments, consider increasing the timeout. + * + * FF seems to require the most time to stabilize its RTA. On Vaadin + * tiergarden test machines, 200ms was not enough always (about 50% + * success rate) - 300 ms was 100% successful. This however was not + * enough on a sluggish old non-virtualized XP test machine. A bullet + * proof solution would be nice, GWT 2.1 might however solve these. At + * least setFocus has a workaround for this kind of issue. + */ + new Timer() { + @Override + public void run() { + rta.getFormatter().selectAll(); + } + }.schedule(320); } private void setReadOnly(boolean b) { @@ -195,6 +224,7 @@ public class VRichTextArea extends Composite implements Paintable, Field, public void onBlur(BlurEvent event) { synchronizeContentToServer(); + // TODO notify possible server side blur/focus listeners } /** @@ -256,7 +286,7 @@ public class VRichTextArea extends Composite implements Paintable, Field, * The formatter height will be initially calculated wrong so we * delay the height setting so the DOM has had time to stabilize. */ - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { int editorHeight = getOffsetHeight() - getExtraVerticalPixels() @@ -298,7 +328,7 @@ public class VRichTextArea extends Composite implements Paintable, Field, public void onKeyPress(KeyPressEvent event) { if (maxLength >= 0) { - DeferredCommand.addCommand(new Command() { + Scheduler.get().scheduleDeferred(new Command() { public void execute() { if (rta.getHTML().length() > maxLength) { rta.setHTML(rta.getHTML().substring(0, maxLength)); @@ -338,4 +368,30 @@ public class VRichTextArea extends Composite implements Paintable, Field, synchronizeContentToServer(); } + public int getTabIndex() { + return rta.getTabIndex(); + } + + public void setAccessKey(char key) { + rta.setAccessKey(key); + } + + public void setFocus(boolean focused) { + /* + * Similar issue as with selectAll. Focusing must happen before possible + * selectall, so keep the timeout here lower. + */ + new Timer() { + + @Override + public void run() { + rta.setFocus(true); + } + }.schedule(300); + } + + public void setTabIndex(int index) { + rta.setTabIndex(index); + } + } diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextToolbar.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextToolbar.java index 9154017a32..7f05439b59 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextToolbar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextToolbar.java @@ -172,6 +172,7 @@ public class VRichTextToolbar extends Composite { private class EventHandler implements ClickHandler, ChangeHandler, KeyUpHandler { + @SuppressWarnings("deprecation") public void onChange(ChangeEvent event) { Object sender = event.getSource(); if (sender == backColors) { @@ -192,6 +193,7 @@ public class VRichTextToolbar extends Composite { } } + @SuppressWarnings("deprecation") public void onClick(ClickEvent event) { Object sender = event.getSource(); if (sender == bold) { @@ -269,7 +271,9 @@ public class VRichTextToolbar extends Composite { private final EventHandler handler = new EventHandler(); private final RichTextArea richText; + @SuppressWarnings("deprecation") private final RichTextArea.BasicFormatter basic; + @SuppressWarnings("deprecation") private final RichTextArea.ExtendedFormatter extended; private final FlowPanel outer = new FlowPanel(); @@ -305,6 +309,7 @@ public class VRichTextToolbar extends Composite { * @param richText * the rich text area to be controlled */ + @SuppressWarnings("deprecation") public VRichTextToolbar(RichTextArea richText) { this.richText = richText; basic = richText.getBasicFormatter(); @@ -382,6 +387,7 @@ public class VRichTextToolbar extends Composite { lb.addItem(strings.green(), "green"); lb.addItem(strings.yellow(), "yellow"); lb.addItem(strings.blue(), "blue"); + lb.setTabIndex(-1); return lb; } @@ -398,6 +404,7 @@ public class VRichTextToolbar extends Composite { lb.addItem("Georgia", "Georgia"); lb.addItem("Trebuchet", "Trebuchet"); lb.addItem("Verdana", "Verdana"); + lb.setTabIndex(-1); return lb; } @@ -414,6 +421,7 @@ public class VRichTextToolbar extends Composite { lb.addItem(strings.large()); lb.addItem(strings.xlarge()); lb.addItem(strings.xxlarge()); + lb.setTabIndex(-1); return lb; } @@ -421,6 +429,7 @@ public class VRichTextToolbar extends Composite { final PushButton pb = new PushButton(new Image(img)); pb.addClickHandler(handler); pb.setTitle(tip); + pb.setTabIndex(-1); return pb; } @@ -428,12 +437,14 @@ public class VRichTextToolbar extends Composite { final ToggleButton tb = new ToggleButton(new Image(img)); tb.addClickHandler(handler); tb.setTitle(tip); + tb.setTabIndex(-1); return tb; } /** * Updates the status of all the stateful buttons. */ + @SuppressWarnings("deprecation") private void updateStatus() { if (basic != null) { bold.setDown(basic.isBold()); diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index b8cd013a69..953ab0c5d4 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -21,6 +21,8 @@ import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; @@ -49,7 +51,6 @@ import com.liferay.portal.kernel.util.PortalClassInvoker; import com.liferay.portal.kernel.util.PropsUtil; import com.vaadin.Application; import com.vaadin.Application.SystemMessages; -import com.vaadin.external.org.apache.commons.fileupload.portlet.PortletFileUpload; import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.gwt.client.ApplicationConfiguration; @@ -67,6 +68,9 @@ import com.vaadin.ui.Window; public abstract class AbstractApplicationPortlet extends GenericPortlet implements Constants { + private static final Logger logger = Logger + .getLogger(AbstractApplicationPortlet.class.getName()); + /** * This portlet parameter is used to add styles to the main element. E.g * "height:500px" generates a style="height:500px" to the main element. @@ -87,24 +91,23 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet private boolean productionMode = false; - @SuppressWarnings("unchecked") @Override public void init(PortletConfig config) throws PortletException { super.init(config); // Stores the application parameters into Properties object applicationProperties = new Properties(); - for (final Enumeration e = config.getInitParameterNames(); e + for (final Enumeration<String> e = config.getInitParameterNames(); e .hasMoreElements();) { - final String name = (String) e.nextElement(); + final String name = e.nextElement(); applicationProperties.setProperty(name, config.getInitParameter(name)); } // Overrides with server.xml parameters final PortletContext context = config.getPortletContext(); - for (final Enumeration e = context.getInitParameterNames(); e + for (final Enumeration<String> e = context.getInitParameterNames(); e .hasMoreElements();) { - final String name = (String) e.nextElement(); + final String name = e.nextElement(); applicationProperties.setProperty(name, context.getInitParameter(name)); } @@ -120,7 +123,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet * Print an information/warning message about running with xsrf * protection disabled */ - System.err.println(WARNING_XSRF_PROTECTION_DISABLED); + logger.warning(WARNING_XSRF_PROTECTION_DISABLED); } } @@ -140,7 +143,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet if (!productionMode) { /* Print an information/warning message about running in debug mode */ // TODO Maybe we need a different message for portlets? - System.err.println(NOT_PRODUCTION_MODE_INFO); + logger.warning(NOT_PRODUCTION_MODE_INFO); } } @@ -260,6 +263,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } else if (request instanceof ResourceRequest) { if (isUIDLRequest((ResourceRequest) request)) { return RequestType.UIDL; + } else if (isFileUploadRequest((ResourceRequest) request)) { + return RequestType.FILE_UPLOAD; } else if (isApplicationResourceRequest((ResourceRequest) request)) { return RequestType.APPLICATION_RESOURCE; } else if (isDummyRequest((ResourceRequest) request)) { @@ -268,12 +273,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet return RequestType.STATIC_FILE; } } else if (request instanceof ActionRequest) { - if (isFileUploadRequest((ActionRequest) request)) { - return RequestType.FILE_UPLOAD; - } else { - // action other than upload - return RequestType.ACTION; - } + return RequestType.ACTION; } else if (request instanceof EventRequest) { return RequestType.EVENT; } @@ -295,8 +295,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet && request.getResourceID().equals("DUMMY"); } - private boolean isFileUploadRequest(ActionRequest request) { - return PortletFileUpload.isMultipartContent(request); + private boolean isFileUploadRequest(ResourceRequest request) { + return "UPLOAD".equals(request.getResourceID()); } /** @@ -357,19 +357,6 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet PortletCommunicationManager applicationManager = applicationContext .getApplicationManager(application); - if (response instanceof RenderResponse - && applicationManager.dummyURL == null) { - /* - * The application manager needs an URL to the dummy page. - * See the PortletCommunicationManager.sendUploadResponse - * method for more information. - */ - ResourceURL dummyURL = ((RenderResponse) response) - .createResourceURL(); - dummyURL.setResourceID("DUMMY"); - applicationManager.dummyURL = dummyURL.toString(); - } - /* Update browser information from request */ updateBrowserProperties(applicationContext.getBrowser(), request); @@ -439,7 +426,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet /* Handle the request */ if (requestType == RequestType.FILE_UPLOAD) { applicationManager.handleFileUpload( - (ActionRequest) request, (ActionResponse) response); + (ResourceRequest) request, + (ResourceResponse) response); return; } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests @@ -463,14 +451,11 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } catch (final SessionExpiredException e) { // TODO Figure out a better way to deal with // SessionExpiredExceptions - System.err.println("Session has expired"); - e.printStackTrace(System.err); + logger.finest("A user session has expired"); } catch (final GeneralSecurityException e) { // TODO Figure out a better way to deal with // GeneralSecurityExceptions - System.err - .println("General security exception, should never happen"); - e.printStackTrace(System.err); + logger.fine("General security exception, the security key was probably incorrect."); } catch (final Throwable e) { handleServiceException(request, response, application, e); } finally { @@ -493,7 +478,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet private void handleUnknownRequest(PortletRequest request, PortletResponse response) { - System.err.println("Unknown request type"); + logger.warning("Unknown request type"); } /** @@ -586,7 +571,6 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet return false; } - @SuppressWarnings("unchecked") private void handleDownload(DownloadStream stream, ResourceRequest request, ResourceResponse response) throws IOException { @@ -621,10 +605,10 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet // Copy download stream parameters directly // to HTTP headers. - final Iterator i = stream.getParameterNames(); + final Iterator<String> i = stream.getParameterNames(); if (i != null) { while (i.hasNext()) { - final String param = (String) i.next(); + final String param = i.next(); response.setProperty(param, stream.getParameter(param)); } } @@ -675,7 +659,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet os.write(buffer, 0, bytes); } } else { - System.err.println("Requested resource [" + resourceID + logger.info("Requested resource [" + resourceID + "] could not be found"); response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_NOT_FOUND)); @@ -930,7 +914,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet appClass += getApplicationClass().getSimpleName(); } catch (ClassNotFoundException e) { appClass += "unknown"; - e.printStackTrace(); + logger.log(Level.SEVERE, "Could not find application class", e); } String themeClass = "v-theme-" + themeName.replaceAll("[^a-zA-Z0-9]", ""); @@ -1056,7 +1040,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet Map<String, String> config = new LinkedHashMap<String, String>(); /* - * We need this in order to get uploads to work. + * We need this in order to get uploads to work. TODO this is not needed + * for uploads anymore, check if this is needed for some other things */ PortletURL appUri = response.createActionURL(); config.put("appUri", "'" + appUri.toString() + "'"); diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 43fc63883a..5b422b226d 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -23,6 +23,8 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -34,7 +36,6 @@ import javax.servlet.http.HttpSession; import com.vaadin.Application; import com.vaadin.Application.SystemMessages; -import com.vaadin.external.org.apache.commons.fileupload.servlet.ServletFileUpload; import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.ParameterHandler; import com.vaadin.terminal.Terminal; @@ -64,6 +65,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // TODO Move some (all?) of the constants to a separate interface (shared // with portlet) + private static final Logger logger = Logger + .getLogger(AbstractApplicationServlet.class.getName()); + /** * The version number of this release. For example "6.2.0". Always in the * format "major.minor.revision[.build]". The build part is optional. All of @@ -177,6 +181,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements private final String resourcePath = null; private int resourceCacheTime = 3600; + static final String UPLOAD_URL_PREFIX = "APP/UPLOAD/"; /** * Called by the servlet container to indicate to a servlet that the servlet @@ -197,18 +202,18 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // Stores the application parameters into Properties object applicationProperties = new Properties(); - for (final Enumeration e = servletConfig.getInitParameterNames(); e - .hasMoreElements();) { - final String name = (String) e.nextElement(); + for (final Enumeration<String> e = servletConfig + .getInitParameterNames(); e.hasMoreElements();) { + final String name = e.nextElement(); applicationProperties.setProperty(name, servletConfig.getInitParameter(name)); } // Overrides with server.xml parameters final ServletContext context = servletConfig.getServletContext(); - for (final Enumeration e = context.getInitParameterNames(); e + for (final Enumeration<String> e = context.getInitParameterNames(); e .hasMoreElements();) { - final String name = (String) e.nextElement(); + final String name = e.nextElement(); applicationProperties.setProperty(name, context.getInitParameter(name)); } @@ -225,7 +230,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * Print an information/warning message about running with xsrf * protection disabled */ - System.err.println(WARNING_XSRF_PROTECTION_DISABLED); + logger.warning(WARNING_XSRF_PROTECTION_DISABLED); } } @@ -244,7 +249,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements if (!productionMode) { /* Print an information/warning message about running in debug mode */ - System.err.println(NOT_PRODUCTION_MODE_INFO); + logger.warning(NOT_PRODUCTION_MODE_INFO); } } @@ -258,7 +263,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } catch (NumberFormatException nfe) { // Default is 1h resourceCacheTime = 3600; - System.err.println(WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC); + logger.warning(WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC); } } @@ -486,7 +491,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } // Handle parameters - final Map parameters = request.getParameterMap(); + final Map<String, String[]> parameters = request.getParameterMap(); if (window != null && parameters != null) { window.handleParameters(parameters); } @@ -816,7 +821,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements resultPath = url.getFile(); } catch (final Exception e) { // FIXME: Handle exception - e.printStackTrace(); + logger.log(Level.INFO, "Could not find resource path " + path, + e); } } return resultPath; @@ -839,7 +845,6 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * * @see com.vaadin.terminal.URIHandler */ - @SuppressWarnings("unchecked") private void handleDownload(DownloadStream stream, HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -875,10 +880,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // Copy download stream parameters directly // to HTTP headers. - final Iterator i = stream.getParameterNames(); + final Iterator<String> i = stream.getParameterNames(); if (i != null) { while (i.hasNext()) { - final String param = (String) i.next(); + final String param = i.next(); response.setHeader(param, stream.getParameter(param)); } } @@ -1198,11 +1203,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements if (resourceUrl == null) { // cannot serve requested file - System.err - .println("Requested resource [" - + filename - + "] not found from filesystem or through class loader." - + " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder."); + logger.info("Requested resource [" + + filename + + "] not found from filesystem or through class loader." + + " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder."); response.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } @@ -1223,7 +1227,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } } catch (Exception e) { // Failed to find out last modified timestamp. Continue without it. - e.printStackTrace(); + logger.log( + Level.FINEST, + "Failed to find out last modified timestamp. Continuing without it.", + e); } // Set type mime type if we can determine it based on the filename @@ -1363,7 +1370,18 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } private boolean isFileUploadRequest(HttpServletRequest request) { - return ServletFileUpload.isMultipartContent(request); + String pathInfo = getRequestPathInfo(request); + + if (pathInfo == null) { + return false; + } + + if (pathInfo.startsWith("/" + UPLOAD_URL_PREFIX)) { + return true; + } + + return false; + } private boolean isOnUnloadRequest(HttpServletRequest request) { @@ -1643,7 +1661,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements try { return getApplicationClass().getSimpleName(); } catch (ClassNotFoundException e) { - e.printStackTrace(); + logger.log(Level.WARNING, "getApplicationCSSClassName failed", e); return "unknown"; } } @@ -1890,8 +1908,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements String title, String themeUri) throws IOException { page.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"); - // Force IE9 into IE8 mode. Remove when IE 9 mode works (#5546) - page.write("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\"/>\n"); + // Force IE9 into IE8 mode. Remove when IE 9 mode works (#5546), chrome + // frame if available #5261 + page.write("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8,chrome=1\"/>\n"); page.write("<style type=\"text/css\">" + "html, body {height:100%;margin:0;}</style>"); @@ -2009,7 +2028,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * @throws InstantiationException * @throws SessionExpiredException */ - private Application getExistingApplication(HttpServletRequest request, + protected Application getExistingApplication(HttpServletRequest request, boolean allowSessionCreation) throws MalformedURLException, SessionExpiredException { @@ -2255,4 +2274,19 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } } + + /** + * Override this method if you need to use a specialized communicaiton + * mananger implementation. + * + * TODO figure out the right place for CM instantiation, must be + * overridieable + * + * @param application + * @return + */ + public CommunicationManager createCommunicationManager( + Application application) { + return new CommunicationManager(application); + } } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 01dcffe6fc..e8af424935 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -35,6 +35,8 @@ import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.portlet.PortletRequest; import javax.portlet.PortletResponse; @@ -43,29 +45,23 @@ import javax.servlet.ServletResponse; import com.vaadin.Application; import com.vaadin.Application.SystemMessages; -import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator; -import com.vaadin.external.org.apache.commons.fileupload.FileItemStream; -import com.vaadin.external.org.apache.commons.fileupload.FileUpload; -import com.vaadin.external.org.apache.commons.fileupload.FileUploadException; -import com.vaadin.external.org.apache.commons.fileupload.ProgressListener; import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Paintable; import com.vaadin.terminal.Paintable.RepaintRequestEvent; +import com.vaadin.terminal.StreamVariable; +import com.vaadin.terminal.StreamVariable.StreamingEndEvent; +import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; import com.vaadin.terminal.Terminal.ErrorEvent; import com.vaadin.terminal.Terminal.ErrorListener; import com.vaadin.terminal.URIHandler; -import com.vaadin.terminal.UploadStream; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.server.ComponentSizeValidator.InvalidLayout; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; -import com.vaadin.ui.DragAndDropWrapper; -import com.vaadin.ui.Upload; -import com.vaadin.ui.Upload.UploadException; import com.vaadin.ui.Window; /** @@ -88,6 +84,9 @@ import com.vaadin.ui.Window; public abstract class AbstractCommunicationManager implements Paintable.RepaintRequestListener, Serializable { + private static final Logger logger = Logger + .getLogger(AbstractCommunicationManager.class.getName()); + /** * Generic interface of a (HTTP or Portlet) request to the application. * @@ -99,7 +98,7 @@ public abstract class AbstractCommunicationManager implements * * @author peholmst */ - protected interface Request { + public interface Request { /** * Gets a {@link Session} wrapper implementation representing the @@ -189,7 +188,7 @@ public abstract class AbstractCommunicationManager implements * * @author peholmst */ - protected interface Response { + public interface Response { /** * Gets the output stream to which the response can be written. @@ -248,7 +247,7 @@ public abstract class AbstractCommunicationManager implements * * @author peholmst */ - protected interface Callback { + public interface Callback { public void criticalNotification(Request request, Response response, String cap, String msg, String details, String outOfSyncURL) @@ -261,6 +260,12 @@ public abstract class AbstractCommunicationManager implements } + static class UploadInterruptedException extends Exception { + public UploadInterruptedException() { + super("Upload interrupted by other thread"); + } + } + private static String GET_PARAM_REPAINT_ALL = "repaintAll"; // flag used in the request to indicate that the security token should be @@ -296,6 +301,9 @@ public abstract class AbstractCommunicationManager implements private static final int MAX_BUFFER_SIZE = 64 * 1024; + /* Same as in apache commons file upload library that was previously used. */ + private static final int MAX_UPLOAD_BUFFER_SIZE = 4 * 1024; + private static final String GET_PARAM_ANALYZE_LAYOUTS = "analyzeLayouts"; private final ArrayList<Paintable> dirtyPaintables = new ArrayList<Paintable>(); @@ -320,6 +328,10 @@ public abstract class AbstractCommunicationManager implements private DragAndDropService dragAndDropService; + private String requestThemeName; + + private int maxInactiveInterval; + private static int nextUnusedWindowSuffix = 1; /** @@ -332,146 +344,352 @@ public abstract class AbstractCommunicationManager implements requireLocale(application.getLocale().toString()); } - /** - * Create an upload handler that is appropriate to the context in which the - * application is being run (servlet or portlet). - * - * @return new {@link FileUpload} instance - */ - protected abstract FileUpload createFileUpload(); + protected Application getApplication() { + return application; + } - /** - * TODO New method - document me! - * - * @param upload - * @param request - * @return - * @throws IOException - * @throws FileUploadException - */ - protected abstract FileItemIterator getUploadItemIterator( - FileUpload upload, Request request) throws IOException, - FileUploadException; + private static final int LF = "\n".getBytes()[0]; + + private static final String CRLF = "\r\n"; + + private static String readLine(InputStream stream) throws IOException { + StringBuilder sb = new StringBuilder(); + int readByte = stream.read(); + while (readByte != LF) { + char c = (char) readByte; + sb.append(c); + readByte = stream.read(); + } + + return sb.substring(0, sb.length() - 1); + } /** - * TODO New method - document me! + * Method used to stream content from a multipart request (either from + * servlet or portlet request) to given StreamVariable + * * * @param request * @param response + * @param streamVariable + * @param owner + * @param boundary * @throws IOException - * @throws FileUploadException */ - protected void doHandleFileUpload(Request request, Response response) - throws IOException, FileUploadException { + protected void doHandleSimpleMultipartFileUpload(Request request, + Response response, StreamVariable streamVariable, + String variableName, VariableOwner owner, String boundary) + throws IOException { + boundary = CRLF + "--" + boundary + "--"; + + // multipart parsing, supports only one file for request, but that is + // fine for our current terminal - // Create a new file upload handler - final FileUpload upload = createFileUpload(); + final InputStream inputStream = request.getInputStream(); - final UploadProgressListener pl = new UploadProgressListener(); + int contentLength = request.getContentLength(); - upload.setProgressListener(pl); + boolean atStart = false; - // Parse the request - FileItemIterator iter; + String rawfilename = "unknown"; + String rawMimeType = "application/octet-stream"; - try { - iter = getUploadItemIterator(upload, request); - /* - * ATM this loop is run only once as we are uploading one file per - * request. + /* + * Read the stream until the actual file starts (empty line). Read + * filename and content type from multipart headers. + */ + while (!atStart) { + String readLine = readLine(inputStream); + contentLength -= (readLine.length() + 2); + if (readLine.startsWith("Content-Disposition:") + && readLine.indexOf("filename=") > 0) { + rawfilename = readLine.replaceAll(".*filename=", ""); + String parenthesis = rawfilename.substring(0, 1); + rawfilename = rawfilename.substring(1); + rawfilename = rawfilename.substring(0, + rawfilename.indexOf(parenthesis)); + } else if (readLine.equals("")) { + atStart = true; + } else if (readLine.startsWith("Content-Type")) { + rawMimeType = readLine.split(": ")[1]; + } + } + + contentLength -= (boundary.length() + 2); // 2 == CRLF + + final char[] charArray = boundary.toCharArray(); + + /* + * Reads bytes from the underlying stream. Compares the read bytes to + * the boundary string and returns -1 if met. + * + * The matching happens so that if the read byte equals to the first + * char of boundary string, the stream goes to "buffering mode". In + * buffering mode bytes are read until the character does not match the + * corresponding from boundary string or the full boundary string is + * found. + * + * Note, if this is someday needed elsewhere, don't shoot yourself to + * foot and split to a top level helper class. + */ + InputStream simpleMultiPartReader = new InputStream() { + + /** + * Counter of how many characters have been matched to boundary + * string from the stream */ - while (iter.hasNext()) { - final FileItemStream item = iter.next(); - final String name = item.getFieldName(); - // Should report only the filename even if the browser sends the - // path - final String filename = removePath(item.getName()); - final String mimeType = item.getContentType(); - final InputStream stream = item.openStream(); - if (item.isFormField()) { - // ignored, upload requests contains only files - } else { - final UploadStream upstream = new UploadStream() { + int matchedCount = 0; - public String getContentName() { - return filename; + /** + * Used as pointer when returning bytes after partly matched + * boundary string. + */ + int curBoundaryIndex = 0; + /** + * The byte found after a "promising start for boundary" + */ + private int bufferedByte = -1; + private boolean atTheEnd = false; + + @Override + public int read() throws IOException { + if (atTheEnd) { + return -1; + } else if (bufferedByte >= 0) { + /* "buffered mode", purge partially matched boundary */ + return getBuffered(); + } else { + int fromActualStream = inputStream.read(); + if (fromActualStream == -1) { + // unexpected end of stream + throw new IOException( + "The multipart stream ended unexpectedly"); + } + if (charArray[matchedCount] == fromActualStream) { + /* + * Going to "buffered mode". Read until full boundary + * match or a different character. + */ + while (true) { + matchedCount++; + if (matchedCount == charArray.length) { + // reached the end of file + atTheEnd = true; + return -1; + } + fromActualStream = inputStream.read(); + if (fromActualStream != charArray[matchedCount]) { + // Did not find full boundary, cache the last + // byte + bufferedByte = fromActualStream; + return getBuffered(); + } } + } + return fromActualStream; + } + } - public String getContentType() { - return mimeType; - } + private int getBuffered() throws IOException { + int b; + if (matchedCount == 0) { + b = bufferedByte; + bufferedByte = -1; + } else { + b = charArray[curBoundaryIndex++]; + if (curBoundaryIndex == matchedCount) { + matchedCount = 0; + curBoundaryIndex = 0; + // next call for getBuffered will return the + // bufferedByte, not from the char array. + } + } + if (b == -1) { + throw new IOException( + "The multipart stream ended unexpectedly"); + } + return b; + } + }; - public InputStream getStream() { - return stream; - } + /* + * Should report only the filename even if the browser sends the path + */ + final String filename = removePath(rawfilename); + final String mimeType = rawMimeType; - public String getStreamName() { - return "stream"; - } + try { + /* + * safe cast as in GWT terminal all variable owners are expected to + * be components. + */ + Component component = (Component) owner; + if (component.isReadOnly()) { + throw new UploadException( + "Warning: file upload ignored because the componente was read-only"); + } + boolean forgetVariable = streamToReceiver(simpleMultiPartReader, + streamVariable, filename, mimeType, contentLength); + if (forgetVariable) { + cleanStreamVariable(owner, variableName); + } + } catch (Exception e) { + synchronized (application) { + handleChangeVariablesError(application, (Component) owner, e, + new HashMap<String, Object>()); + } + } + sendUploadResponse(request, response); - }; + } - if (name.startsWith("XHRFILE")) { - String[] split = item.getFieldName().substring(7) - .split("\\."); - DragAndDropWrapper ddw = (DragAndDropWrapper) idPaintableMap - .get(split[0]); + /** + * Used to stream plain file post (aka XHR2.post(File)) + * + * @param request + * @param response + * @param streamVariable + * @param owner + * @param contentLength + * @throws IOException + */ + protected void doHandleXhrFilePost(Request request, Response response, + StreamVariable streamVariable, String variableName, + VariableOwner owner, int contentLength) throws IOException { + + // These are unknown in filexhr ATM, maybe add to Accept header that + // is accessible in portlets + final String filename = "unknown"; + final String mimeType = filename; + final InputStream stream = request.getInputStream(); + try { + /* + * safe cast as in GWT terminal all variable owners are expected to + * be components. + */ + Component component = (Component) owner; + if (component.isReadOnly()) { + throw new UploadException( + "Warning: file upload ignored because the component was read-only"); + } + boolean forgetVariable = streamToReceiver(stream, streamVariable, + filename, mimeType, contentLength); + if (forgetVariable) { + cleanStreamVariable(owner, variableName); + } + } catch (Exception e) { + synchronized (application) { + handleChangeVariablesError(application, (Component) owner, e, + new HashMap<String, Object>()); + } + } + sendUploadResponse(request, response); + } - try { - ddw.receiveFile(upstream, split[1]); - } catch (UploadException e) { - synchronized (application) { - handleChangeVariablesError(application, ddw, e, - new HashMap<String, Object>()); - } - } + /** + * @param in + * @param streamVariable + * @param filename + * @param type + * @param contentLength + * @return true if the streamvariable has informed that the terminal can + * forget this variable + * @throws UploadException + */ + protected final boolean streamToReceiver(final InputStream in, + StreamVariable streamVariable, String filename, String type, + int contentLength) throws UploadException { + if (streamVariable == null) { + throw new IllegalStateException( + "StreamVariable for the post not found"); + } - } else { + final Application application = getApplication(); - int separatorPos = name.lastIndexOf("_"); - final String pid = name.substring(0, separatorPos); - final Upload uploadComponent = (Upload) idPaintableMap - .get(pid); - if (uploadComponent == null) { - throw new FileUploadException( - "Upload component not found"); - } - if (uploadComponent.isReadOnly()) { - throw new FileUploadException( - "Warning: ignored file upload because upload component is set as read-only"); - } - synchronized (application) { - // put upload component into receiving state - uploadComponent.startUpload(); - } + OutputStream out = null; + int totalBytes = 0; + StreamingStartEventImpl startedEvent = new StreamingStartEventImpl( + filename, type, contentLength); + try { + boolean listenProgress; + synchronized (application) { + streamVariable.streamingStarted(startedEvent); + out = streamVariable.getOutputStream(); + listenProgress = streamVariable.listenProgress(); + } - // tell UploadProgressListener which component is - // receiving - // file - pl.setUpload(uploadComponent); - - try { - uploadComponent.receiveUpload(upstream); - } catch (UploadException e) { - // error happened while receiving file. Handle the - // error in the same manner as it would have - // happened in - // variable change. - synchronized (application) { - handleChangeVariablesError(application, - uploadComponent, e, - new HashMap<String, Object>()); - } - } + // Gets the output target stream + if (out == null) { + throw new NoOutputStreamException(); + } + + if (null == in) { + // No file, for instance non-existent filename in html upload + throw new NoInputStreamException(); + } + + final byte buffer[] = new byte[MAX_UPLOAD_BUFFER_SIZE]; + int bytesReadToBuffer = 0; + while ((bytesReadToBuffer = in.read(buffer)) > 0) { + out.write(buffer, 0, bytesReadToBuffer); + totalBytes += bytesReadToBuffer; + if (listenProgress) { + // update progress if listener set and contentLength + // received + synchronized (application) { + StreamingProgressEventImpl progressEvent = new StreamingProgressEventImpl( + filename, type, contentLength, totalBytes); + streamVariable.onProgress(progressEvent); } + } + if (streamVariable.isInterrupted()) { + throw new UploadInterruptedException(); + } + } + // upload successful + out.close(); + StreamingEndEvent event = new StreamingEndEventImpl(filename, type, + totalBytes); + synchronized (application) { + streamVariable.streamingFinished(event); + } + + } catch (UploadInterruptedException e) { + // Download interrupted by application code + tryToCloseStream(out); + StreamingErrorEvent event = new StreamingErrorEventImpl(filename, + type, contentLength, totalBytes, e); + synchronized (application) { + streamVariable.streamingFailed(event); + } + // Note, we are not throwing interrupted exception forward as it is + // not a terminal level error like all other exception. + } catch (final Exception e) { + tryToCloseStream(out); + synchronized (application) { + StreamingErrorEvent event = new StreamingErrorEventImpl( + filename, type, contentLength, totalBytes, e); + synchronized (application) { + streamVariable.streamingFailed(event); } + // throw exception for terminal to be handled (to be passed to + // terminalErrorHandler) + throw new UploadException(e); } - } catch (final FileUploadException e) { - throw e; } + return startedEvent.isDisposed(); + } - sendUploadResponse(request, response); + private void tryToCloseStream(OutputStream out) { + try { + // try to close output stream (e.g. file handle) + if (out != null) { + out.close(); + } + } catch (IOException e1) { + // NOP + } } /** @@ -535,6 +753,8 @@ public abstract class AbstractCommunicationManager implements Callback callback, Window window) throws IOException, InvalidUIDLSecurityKeyException { + requestThemeName = request.getParameter("theme"); + maxInactiveInterval = request.getSession().getMaxInactiveInterval(); // repaint requested or session has timed out and new one is created boolean repaintAll; final OutputStream out; @@ -563,9 +783,8 @@ public abstract class AbstractCommunicationManager implements if (window == null) { // This should not happen, no windows exists but // application is still open. - System.err - .println("Warning, could not get window for application with request ID " - + request.getRequestID()); + logger.warning("Could not get window for application with request ID " + + request.getRequestID()); return; } } else { @@ -589,7 +808,8 @@ public abstract class AbstractCommunicationManager implements // FIXME: Handle exception // Not critical, but something is still wrong; print // stacktrace - e2.printStackTrace(); + logger.log(Level.WARNING, + "getSystemMessages() failed - continuing", e2); } if (ci != null) { String msg = ci.getOutOfSyncMessage(); @@ -616,6 +836,7 @@ public abstract class AbstractCommunicationManager implements } outWriter.close(); + requestThemeName = null; } /** @@ -637,21 +858,7 @@ public abstract class AbstractCommunicationManager implements IOException { if (repaintAll) { - // If repaint is requested, clean all ids in this root window - for (final Iterator<String> it = idPaintableMap.keySet().iterator(); it - .hasNext();) { - final Component c = (Component) idPaintableMap.get(it.next()); - if (isChildOf(window, c)) { - it.remove(); - paintableIdMap.remove(c); - } - } - // clean WindowCache - OpenWindowCache openWindowCache = currentlyOpenWindowsInClient - .get(window.getName()); - if (openWindowCache != null) { - openWindowCache.clear(); - } + makeAllPaintablesDirty(window); } // Removes application if it has stopped during variable changes @@ -683,16 +890,11 @@ public abstract class AbstractCommunicationManager implements outWriter.print("\","); } - outWriter.print("\"changes\":["); - - ArrayList<Paintable> paintables = null; - // If the browser-window has been closed - we do not need to paint it at // all - if (!window.getName().equals(closingWindowName)) { - - List<InvalidLayout> invalidComponentRelativeSizes = null; - + if (window.getName().equals(closingWindowName)) { + outWriter.print("\"changes\":[]"); + } else { // re-get window - may have been changed Window newWindow = doGetApplicationWindow(request, callback, application, window); @@ -701,280 +903,336 @@ public abstract class AbstractCommunicationManager implements repaintAll = true; } - JsonPaintTarget paintTarget = new JsonPaintTarget(this, outWriter, - !repaintAll); - OpenWindowCache windowCache = currentlyOpenWindowsInClient - .get(window.getName()); - if (windowCache == null) { - windowCache = new OpenWindowCache(); - currentlyOpenWindowsInClient.put(window.getName(), windowCache); - } + writeUidlResponce(callback, repaintAll, outWriter, window, + analyzeLayouts); - // Paints components - if (repaintAll) { - paintables = new ArrayList<Paintable>(); - paintables.add(window); + } + outWriter.print("}]"); - // Reset sent locales - locales = null; - requireLocale(application.getLocale().toString()); + outWriter.close(); - } else { - // remove detached components from paintableIdMap so they - // can be GC'ed - for (Iterator<Paintable> it = paintableIdMap.keySet() - .iterator(); it.hasNext();) { - Component p = (Component) it.next(); - if (p.getApplication() == null) { - idPaintableMap.remove(paintableIdMap.get(p)); - it.remove(); - dirtyPaintables.remove(p); - p.removeListener(this); - } + } + + public void writeUidlResponce(Callback callback, boolean repaintAll, + final PrintWriter outWriter, Window window, boolean analyzeLayouts) + throws PaintException { + outWriter.print("\"changes\":["); + + ArrayList<Paintable> paintables = null; + + List<InvalidLayout> invalidComponentRelativeSizes = null; + + JsonPaintTarget paintTarget = new JsonPaintTarget(this, outWriter, + !repaintAll); + OpenWindowCache windowCache = currentlyOpenWindowsInClient.get(window + .getName()); + if (windowCache == null) { + windowCache = new OpenWindowCache(); + currentlyOpenWindowsInClient.put(window.getName(), windowCache); + } + + // Paints components + if (repaintAll) { + paintables = new ArrayList<Paintable>(); + paintables.add(window); + + // Reset sent locales + locales = null; + requireLocale(application.getLocale().toString()); + + } else { + // remove detached components from paintableIdMap so they + // can be GC'ed + /* + * TODO figure out if we could move this beyond the painting phase, + * "respond as fast as possible, then do the cleanup". Beware of + * painting the dirty detatched components. + */ + for (Iterator<Paintable> it = paintableIdMap.keySet().iterator(); it + .hasNext();) { + Component p = (Component) it.next(); + if (p.getApplication() == null) { + unregisterPaintable(p); + idPaintableMap.remove(paintableIdMap.get(p)); + it.remove(); + dirtyPaintables.remove(p); } - paintables = getDirtyVisibleComponents(window); } - if (paintables != null) { - - // We need to avoid painting children before parent. - // This is ensured by ordering list by depth in component - // tree - Collections.sort(paintables, new Comparator<Paintable>() { - public int compare(Paintable o1, Paintable o2) { - Component c1 = (Component) o1; - Component c2 = (Component) o2; - int d1 = 0; - while (c1.getParent() != null) { - d1++; - c1 = c1.getParent(); - } - int d2 = 0; - while (c2.getParent() != null) { - d2++; - c2 = c2.getParent(); - } - if (d1 < d2) { - return -1; - } - if (d1 > d2) { - return 1; - } - return 0; + paintables = getDirtyVisibleComponents(window); + } + if (paintables != null) { + + // We need to avoid painting children before parent. + // This is ensured by ordering list by depth in component + // tree + Collections.sort(paintables, new Comparator<Paintable>() { + public int compare(Paintable o1, Paintable o2) { + Component c1 = (Component) o1; + Component c2 = (Component) o2; + int d1 = 0; + while (c1.getParent() != null) { + d1++; + c1 = c1.getParent(); } - }); - - for (final Iterator<Paintable> i = paintables.iterator(); i - .hasNext();) { - final Paintable p = i.next(); - - // TODO CLEAN - if (p instanceof Window) { - final Window w = (Window) p; - if (w.getTerminal() == null) { - w.setTerminal(application.getMainWindow() - .getTerminal()); - } + int d2 = 0; + while (c2.getParent() != null) { + d2++; + c2 = c2.getParent(); } - /* - * This does not seem to happen in tk5, but remember this - * case: else if (p instanceof Component) { if (((Component) - * p).getParent() == null || ((Component) - * p).getApplication() == null) { // Component requested - * repaint, but is no // longer attached: skip - * paintablePainted(p); continue; } } - */ - - // TODO we may still get changes that have been - // rendered already (changes with only cached flag) - if (paintTarget.needsToBePainted(p)) { - paintTarget.startTag("change"); - paintTarget.addAttribute("format", "uidl"); - final String pid = getPaintableId(p); - paintTarget.addAttribute("pid", pid); - - p.paint(paintTarget); - - paintTarget.endTag("change"); + if (d1 < d2) { + return -1; } - paintablePainted(p); - - if (analyzeLayouts) { - Window w = (Window) p; - invalidComponentRelativeSizes = ComponentSizeValidator - .validateComponentRelativeSizes(w.getContent(), - null, null); - - // Also check any existing subwindows - if (w.getChildWindows() != null) { - for (Window subWindow : w.getChildWindows()) { - invalidComponentRelativeSizes = ComponentSizeValidator - .validateComponentRelativeSizes( - subWindow.getContent(), - invalidComponentRelativeSizes, - null); - } - } + if (d1 > d2) { + return 1; } + return 0; } - } + }); - paintTarget.close(); - outWriter.print("]"); // close changes + for (final Iterator<Paintable> i = paintables.iterator(); i + .hasNext();) { + final Paintable p = i.next(); - outWriter.print(", \"meta\" : {"); - boolean metaOpen = false; + // TODO CLEAN + if (p instanceof Window) { + final Window w = (Window) p; + if (w.getTerminal() == null) { + w.setTerminal(application.getMainWindow().getTerminal()); + } + } + /* + * This does not seem to happen in tk5, but remember this case: + * else if (p instanceof Component) { if (((Component) + * p).getParent() == null || ((Component) p).getApplication() == + * null) { // Component requested repaint, but is no // longer + * attached: skip paintablePainted(p); continue; } } + */ + + // TODO we may still get changes that have been + // rendered already (changes with only cached flag) + if (paintTarget.needsToBePainted(p)) { + paintTarget.startTag("change"); + paintTarget.addAttribute("format", "uidl"); + final String pid = getPaintableId(p); + paintTarget.addAttribute("pid", pid); + + p.paint(paintTarget); + + paintTarget.endTag("change"); + } + paintablePainted(p); - if (repaintAll) { - metaOpen = true; - outWriter.write("\"repaintAll\":true"); if (analyzeLayouts) { - outWriter.write(", \"invalidLayouts\":"); - outWriter.write("["); - if (invalidComponentRelativeSizes != null) { - boolean first = true; - for (InvalidLayout invalidLayout : invalidComponentRelativeSizes) { - if (!first) { - outWriter.write(","); - } else { - first = false; - } - invalidLayout.reportErrors(outWriter, this, - System.err); + Window w = (Window) p; + invalidComponentRelativeSizes = ComponentSizeValidator + .validateComponentRelativeSizes(w.getContent(), + null, null); + + // Also check any existing subwindows + if (w.getChildWindows() != null) { + for (Window subWindow : w.getChildWindows()) { + invalidComponentRelativeSizes = ComponentSizeValidator + .validateComponentRelativeSizes( + subWindow.getContent(), + invalidComponentRelativeSizes, null); } } - outWriter.write("]"); } } + } - SystemMessages ci = null; - try { - Method m = application.getClass().getMethod( - "getSystemMessages", (Class[]) null); - ci = (Application.SystemMessages) m.invoke(null, - (Object[]) null); - } catch (NoSuchMethodException e1) { - e1.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } + paintTarget.close(); + outWriter.print("]"); // close changes + + outWriter.print(", \"meta\" : {"); + boolean metaOpen = false; - // meta instruction for client to enable auto-forward to - // sessionExpiredURL after timer expires. - if (ci != null && ci.getSessionExpiredMessage() == null - && ci.getSessionExpiredCaption() == null - && ci.isSessionExpiredNotificationEnabled()) { - int newTimeoutInterval = request.getSession() - .getMaxInactiveInterval(); - if (repaintAll || (timeoutInterval != newTimeoutInterval)) { - String escapedURL = ci.getSessionExpiredURL() == null ? "" - : ci.getSessionExpiredURL().replace("/", "\\/"); - if (metaOpen) { - outWriter.write(","); + if (repaintAll) { + metaOpen = true; + outWriter.write("\"repaintAll\":true"); + if (analyzeLayouts) { + outWriter.write(", \"invalidLayouts\":"); + outWriter.write("["); + if (invalidComponentRelativeSizes != null) { + boolean first = true; + for (InvalidLayout invalidLayout : invalidComponentRelativeSizes) { + if (!first) { + outWriter.write(","); + } else { + first = false; + } + invalidLayout.reportErrors(outWriter, this, System.err); } - outWriter.write("\"timedRedirect\":{\"interval\":" - + (newTimeoutInterval + 15) + ",\"url\":\"" - + escapedURL + "\"}"); - metaOpen = true; } - timeoutInterval = newTimeoutInterval; + outWriter.write("]"); } + } - outWriter.print("}, \"resources\" : {"); - - // Precache custom layouts - String themeName = window.getTheme(); - String requestThemeName = request.getParameter("theme"); + SystemMessages ci = null; + try { + Method m = application.getClass().getMethod("getSystemMessages", + (Class[]) null); + ci = (Application.SystemMessages) m.invoke(null, (Object[]) null); + } catch (NoSuchMethodException e) { + logger.log(Level.WARNING, + "getSystemMessages() failed - continuing", e); + } catch (IllegalArgumentException e) { + logger.log(Level.WARNING, + "getSystemMessages() failed - continuing", e); + } catch (IllegalAccessException e) { + logger.log(Level.WARNING, + "getSystemMessages() failed - continuing", e); + } catch (InvocationTargetException e) { + logger.log(Level.WARNING, + "getSystemMessages() failed - continuing", e); + } - if (requestThemeName != null) { - themeName = requestThemeName; + // meta instruction for client to enable auto-forward to + // sessionExpiredURL after timer expires. + if (ci != null && ci.getSessionExpiredMessage() == null + && ci.getSessionExpiredCaption() == null + && ci.isSessionExpiredNotificationEnabled()) { + int newTimeoutInterval = getTimeoutInterval(); + if (repaintAll || (timeoutInterval != newTimeoutInterval)) { + String escapedURL = ci.getSessionExpiredURL() == null ? "" : ci + .getSessionExpiredURL().replace("/", "\\/"); + if (metaOpen) { + outWriter.write(","); + } + outWriter.write("\"timedRedirect\":{\"interval\":" + + (newTimeoutInterval + 15) + ",\"url\":\"" + + escapedURL + "\"}"); + metaOpen = true; } - if (themeName == null) { - themeName = AbstractApplicationServlet.getDefaultTheme(); + timeoutInterval = newTimeoutInterval; + } + + outWriter.print("}, \"resources\" : {"); + + // Precache custom layouts + + // TODO We should only precache the layouts that are not + // cached already (plagiate from usedPaintableTypes) + int resourceIndex = 0; + for (final Iterator<Object> i = paintTarget.getUsedResources() + .iterator(); i.hasNext();) { + final String resource = (String) i.next(); + InputStream is = null; + try { + is = callback.getThemeResourceAsStream(getTheme(window), + resource); + } catch (final Exception e) { + // FIXME: Handle exception + logger.log(Level.FINER, "Failed to get theme resource stream.", + e); } + if (is != null) { + + outWriter.print((resourceIndex++ > 0 ? ", " : "") + "\"" + + resource + "\" : "); + final StringBuffer layout = new StringBuffer(); - // TODO We should only precache the layouts that are not - // cached already (plagiate from usedPaintableTypes) - int resourceIndex = 0; - for (final Iterator<Object> i = paintTarget.getUsedResources() - .iterator(); i.hasNext();) { - final String resource = (String) i.next(); - InputStream is = null; try { - is = callback.getThemeResourceAsStream(themeName, resource); - } catch (final Exception e) { - // FIXME: Handle exception - e.printStackTrace(); - } - if (is != null) { - - outWriter.print((resourceIndex++ > 0 ? ", " : "") + "\"" - + resource + "\" : "); - final StringBuffer layout = new StringBuffer(); - - try { - final InputStreamReader r = new InputStreamReader(is, - "UTF-8"); - final char[] buffer = new char[20000]; - int charsRead = 0; - while ((charsRead = r.read(buffer)) > 0) { - layout.append(buffer, 0, charsRead); - } - r.close(); - } catch (final java.io.IOException e) { - // FIXME: Handle exception - System.err.println("Resource transfer failed: " - + request.getRequestID() + ". (" - + e.getMessage() + ")"); + final InputStreamReader r = new InputStreamReader(is, + "UTF-8"); + final char[] buffer = new char[20000]; + int charsRead = 0; + while ((charsRead = r.read(buffer)) > 0) { + layout.append(buffer, 0, charsRead); } - outWriter.print("\"" - + JsonPaintTarget.escapeJSON(layout.toString()) - + "\""); - } else { + r.close(); + } catch (final java.io.IOException e) { // FIXME: Handle exception - System.err.println("CustomLayout not found: " + resource); + logger.log(Level.INFO, "Resource transfer failed", e); } + outWriter.print("\"" + + JsonPaintTarget.escapeJSON(layout.toString()) + "\""); + } else { + // FIXME: Handle exception + logger.severe("CustomLayout not found: " + resource); } - outWriter.print("}"); - - Collection<Class<? extends Paintable>> usedPaintableTypes = paintTarget - .getUsedPaintableTypes(); - boolean typeMappingsOpen = false; - for (Class<? extends Paintable> class1 : usedPaintableTypes) { - if (windowCache.cache(class1)) { - // client does not know the mapping key for this type, send - // mapping to client - if (!typeMappingsOpen) { - typeMappingsOpen = true; - outWriter.print(", \"typeMappings\" : { "); - } else { - outWriter.print(" , "); - } - String canonicalName = class1.getCanonicalName(); - outWriter.print("\""); - outWriter.print(canonicalName); - outWriter.print("\" : "); - outWriter.print(getTagForType(class1)); + } + outWriter.print("}"); + + Collection<Class<? extends Paintable>> usedPaintableTypes = paintTarget + .getUsedPaintableTypes(); + boolean typeMappingsOpen = false; + for (Class<? extends Paintable> class1 : usedPaintableTypes) { + if (windowCache.cache(class1)) { + // client does not know the mapping key for this type, send + // mapping to client + if (!typeMappingsOpen) { + typeMappingsOpen = true; + outWriter.print(", \"typeMappings\" : { "); + } else { + outWriter.print(" , "); } + String canonicalName = class1.getCanonicalName(); + outWriter.print("\""); + outWriter.print(canonicalName); + outWriter.print("\" : "); + outWriter.print(getTagForType(class1)); } - if (typeMappingsOpen) { - outWriter.print(" }"); - } + } + if (typeMappingsOpen) { + outWriter.print(" }"); + } - // add any pending locale definitions requested by the client - printLocaleDeclarations(outWriter); + // add any pending locale definitions requested by the client + printLocaleDeclarations(outWriter); - if (dragAndDropService != null) { - dragAndDropService.printJSONResponse(outWriter); - } + if (dragAndDropService != null) { + dragAndDropService.printJSONResponse(outWriter); + } + } + + private int getTimeoutInterval() { + return maxInactiveInterval; + } - outWriter.print("}]"); + private String getTheme(Window window) { + String themeName = window.getTheme(); + String requestThemeName = getRequestTheme(); + + if (requestThemeName != null) { + themeName = requestThemeName; } - outWriter.close(); + if (themeName == null) { + themeName = AbstractApplicationServlet.getDefaultTheme(); + } + return themeName; + } + private String getRequestTheme() { + return requestThemeName; + } + + public void makeAllPaintablesDirty(Window window) { + // If repaint is requested, clean all ids in this root window + for (final Iterator<String> it = idPaintableMap.keySet().iterator(); it + .hasNext();) { + final Component c = (Component) idPaintableMap.get(it.next()); + if (isChildOf(window, c)) { + it.remove(); + paintableIdMap.remove(c); + } + } + // clean WindowCache + OpenWindowCache openWindowCache = currentlyOpenWindowsInClient + .get(window.getName()); + if (openWindowCache != null) { + openWindowCache.clear(); + } + } + + /** + * Called when communication manager stops listening for repaints for given + * component. + * + * @param p + */ + protected void unregisterPaintable(Component p) { + p.removeListener(this); } /** @@ -1023,111 +1281,9 @@ public abstract class AbstractCommunicationManager implements } for (int bi = 1; bi < bursts.length; bi++) { - - // extract variables to two dim string array - final String[] tmp = bursts[bi].split(VAR_RECORD_SEPARATOR); - final String[][] variableRecords = new String[tmp.length][4]; - for (int i = 0; i < tmp.length; i++) { - variableRecords[i] = tmp[i].split(VAR_FIELD_SEPARATOR); - } - - for (int i = 0; i < variableRecords.length; i++) { - String[] variable = variableRecords[i]; - String[] nextVariable = null; - if (i + 1 < variableRecords.length) { - nextVariable = variableRecords[i + 1]; - } - final VariableOwner owner = getVariableOwner(variable[VAR_PID]); - if (owner != null && owner.isEnabled()) { - // TODO this should be Map<String, Object>, but the - // VariableOwner API does not guarantee the key is a - // string - Map<String, Object> m; - if (nextVariable != null - && variable[VAR_PID] - .equals(nextVariable[VAR_PID])) { - // we have more than one value changes in row for - // one variable owner, collect em in HashMap - m = new HashMap<String, Object>(); - m.put(variable[VAR_NAME], - convertVariableValue( - variable[VAR_TYPE].charAt(0), - variable[VAR_VALUE])); - } else { - // use optimized single value map - m = Collections.singletonMap( - variable[VAR_NAME], - convertVariableValue( - variable[VAR_TYPE].charAt(0), - variable[VAR_VALUE])); - } - - // collect following variable changes for this owner - while (nextVariable != null - && variable[VAR_PID] - .equals(nextVariable[VAR_PID])) { - i++; - variable = nextVariable; - if (i + 1 < variableRecords.length) { - nextVariable = variableRecords[i + 1]; - } else { - nextVariable = null; - } - m.put(variable[VAR_NAME], - convertVariableValue( - variable[VAR_TYPE].charAt(0), - variable[VAR_VALUE])); - } - try { - owner.changeVariables(request, m); - - // Special-case of closing browser-level windows: - // track browser-windows currently open in client - if (owner instanceof Window - && ((Window) owner).getParent() == null) { - final Boolean close = (Boolean) m.get("close"); - if (close != null && close.booleanValue()) { - closingWindowName = ((Window) owner) - .getName(); - } - } - } catch (Exception e) { - if (owner instanceof Component) { - handleChangeVariablesError(application2, - (Component) owner, e, m); - } else { - // TODO DragDropService error handling - throw new RuntimeException(e); - } - } - } else { - - // Handle special case where window-close is called - // after the window has been removed from the - // application or the application has closed - if ("close".equals(variable[VAR_NAME]) - && "true".equals(variable[VAR_VALUE])) { - // Silently ignore this - continue; - } - - // Ignore variable change - String msg = "Warning: Ignoring variable change for "; - if (owner != null) { - msg += "disabled component " + owner.getClass(); - String caption = ((Component) owner).getCaption(); - if (caption != null) { - msg += ", caption=" + caption; - } - } else { - msg += "non-existent component, VAR_PID=" - + variable[VAR_PID]; - success = false; - } - System.err.println(msg); - continue; - } - } + final String burst = bursts[bi]; + success = handleVariableBurst(request, application2, success, + burst); // In case that there were multiple bursts, we know that this is // a special synchronous case for closing window. Thus we are @@ -1151,7 +1307,106 @@ public abstract class AbstractCommunicationManager implements return success; } - private VariableOwner getVariableOwner(String string) { + public boolean handleVariableBurst(Object source, Application app, + boolean success, final String burst) { + // extract variables to two dim string array + final String[] tmp = burst.split(VAR_RECORD_SEPARATOR); + final String[][] variableRecords = new String[tmp.length][4]; + for (int i = 0; i < tmp.length; i++) { + variableRecords[i] = tmp[i].split(VAR_FIELD_SEPARATOR); + } + + for (int i = 0; i < variableRecords.length; i++) { + String[] variable = variableRecords[i]; + String[] nextVariable = null; + if (i + 1 < variableRecords.length) { + nextVariable = variableRecords[i + 1]; + } + final VariableOwner owner = getVariableOwner(variable[VAR_PID]); + if (owner != null && owner.isEnabled()) { + Map<String, Object> m; + if (nextVariable != null + && variable[VAR_PID].equals(nextVariable[VAR_PID])) { + // we have more than one value changes in row for + // one variable owner, collect em in HashMap + m = new HashMap<String, Object>(); + m.put(variable[VAR_NAME], + convertVariableValue(variable[VAR_TYPE].charAt(0), + variable[VAR_VALUE])); + } else { + // use optimized single value map + m = Collections.singletonMap( + variable[VAR_NAME], + convertVariableValue(variable[VAR_TYPE].charAt(0), + variable[VAR_VALUE])); + } + + // collect following variable changes for this owner + while (nextVariable != null + && variable[VAR_PID].equals(nextVariable[VAR_PID])) { + i++; + variable = nextVariable; + if (i + 1 < variableRecords.length) { + nextVariable = variableRecords[i + 1]; + } else { + nextVariable = null; + } + m.put(variable[VAR_NAME], + convertVariableValue(variable[VAR_TYPE].charAt(0), + variable[VAR_VALUE])); + } + try { + owner.changeVariables(source, m); + + // Special-case of closing browser-level windows: + // track browser-windows currently open in client + if (owner instanceof Window + && ((Window) owner).getParent() == null) { + final Boolean close = (Boolean) m.get("close"); + if (close != null && close.booleanValue()) { + closingWindowName = ((Window) owner).getName(); + } + } + } catch (Exception e) { + if (owner instanceof Component) { + handleChangeVariablesError(app, (Component) owner, e, m); + } else { + // TODO DragDropService error handling + throw new RuntimeException(e); + } + } + } else { + + // Handle special case where window-close is called + // after the window has been removed from the + // application or the application has closed + if ("close".equals(variable[VAR_NAME]) + && "true".equals(variable[VAR_VALUE])) { + // Silently ignore this + continue; + } + + // Ignore variable change + String msg = "Warning: Ignoring variable change for "; + if (owner != null) { + msg += "disabled component " + owner.getClass(); + String caption = ((Component) owner).getCaption(); + if (caption != null) { + msg += ", caption=" + caption; + } + } else { + msg += "non-existent component, VAR_PID=" + + variable[VAR_PID]; + success = false; + } + logger.warning(msg); + continue; + } + } + return success; + } + + protected VariableOwner getVariableOwner(String string) { VariableOwner owner = (VariableOwner) idPaintableMap.get(string); if (owner == null && string.startsWith("DD")) { return getDragAndDropService(); @@ -1230,7 +1485,7 @@ public abstract class AbstractCommunicationManager implements * map from variable names to values */ private void handleChangeVariablesError(Application application, - Component owner, Exception e, Map<? extends Object, Object> m) { + Component owner, Exception e, Map<String, Object> m) { boolean handled = false; ChangeVariablesErrorEvent errorEvent = new ChangeVariablesErrorEvent( owner, e, m); @@ -1417,9 +1672,8 @@ public abstract class AbstractCommunicationManager implements DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, l); if (!(dateFormat instanceof SimpleDateFormat)) { - System.err - .println("Unable to get default date pattern for locale " - + l.toString()); + logger.warning("Unable to get default date pattern for locale " + + l.toString()); dateFormat = new SimpleDateFormat(); } final String df = ((SimpleDateFormat) dateFormat).toPattern(); @@ -1690,7 +1944,7 @@ public abstract class AbstractCommunicationManager implements } if (componentsRoot.getParent() != null) { // this is a subwindow - componentsRoot = (Window) componentsRoot.getParent(); + componentsRoot = componentsRoot.getParent(); } if (componentsRoot != w) { resultset.remove(p); @@ -1810,30 +2064,6 @@ public abstract class AbstractCommunicationManager implements } } - /* - * Upload progress listener notifies upload component once when Jakarta - * FileUpload can determine content length. Used to detect files total size, - * uploads progress can be tracked inside upload. - */ - private class UploadProgressListener implements ProgressListener, - Serializable { - - Upload uploadComponent; - - boolean updated = false; - - public void setUpload(Upload u) { - uploadComponent = u; - } - - public void update(long bytesRead, long contentLength, int items) { - if (!updated && uploadComponent != null) { - uploadComponent.setUploadSize(contentLength); - updated = true; - } - } - } - /** * Helper method to test if a component contains another * @@ -1879,6 +2109,7 @@ public abstract class AbstractCommunicationManager implements * should be suppressed, null otherwise. * @see com.vaadin.terminal.URIHandler */ + @SuppressWarnings("deprecation") protected DownloadStream handleURI(Window window, Request request, Response response, Callback callback) { @@ -1930,7 +2161,7 @@ public abstract class AbstractCommunicationManager implements } } - private HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>(); + private final HashMap<Class<? extends Paintable>, Integer> typeToKey = new HashMap<Class<? extends Paintable>, Integer>(); private int nextTypeKey = 0; String getTagForType(Class<? extends Paintable> class1) { @@ -1950,7 +2181,7 @@ public abstract class AbstractCommunicationManager implements */ class OpenWindowCache implements Serializable { - private Set<Object> res = new HashSet<Object>(); + private final Set<Object> res = new HashSet<Object>(); /** * @@ -1966,4 +2197,10 @@ public abstract class AbstractCommunicationManager implements } } + + abstract String getStreamVariableTargetUrl(VariableOwner owner, + String name, StreamVariable value); + + abstract protected void cleanStreamVariable(VariableOwner owner, String name); + } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java b/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java new file mode 100644 index 0000000000..83ba45789d --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/AbstractStreamingEvent.java @@ -0,0 +1,39 @@ +package com.vaadin.terminal.gwt.server; + +import com.vaadin.terminal.StreamVariable.StreamingEvent; + +/** + * Abstract base class for StreamingEvent implementations. + */ +@SuppressWarnings("serial") +abstract class AbstractStreamingEvent implements StreamingEvent { + private final String type; + private final String filename; + private final long contentLength; + private final long bytesReceived; + + public final String getFileName() { + return filename; + } + + public final String getMimeType() { + return type; + } + + protected AbstractStreamingEvent(String filename, String type, long length, + long bytesReceived) { + this.filename = filename; + this.type = type; + contentLength = length; + this.bytesReceived = bytesReceived; + } + + public final long getContentLength() { + return contentLength; + } + + public final long getBytesReceived() { + return bytesReceived; + } + +} diff --git a/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java b/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java index 1baad53dad..0504e02787 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractWebApplicationContext.java @@ -12,6 +12,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; @@ -27,6 +29,9 @@ import com.vaadin.terminal.ApplicationResource; public abstract class AbstractWebApplicationContext implements ApplicationContext, HttpSessionBindingListener, Serializable { + private static final Logger logger = Logger + .getLogger(AbstractWebApplicationContext.class.getName()); + protected Collection<TransactionListener> listeners = Collections .synchronizedList(new LinkedList<TransactionListener>()); @@ -128,8 +133,8 @@ public abstract class AbstractWebApplicationContext implements // remove same application here. Possible if you got e.g. session // lifetime 1 min but socket write may take longer than 1 min. // FIXME: Handle exception - System.err.println("Could not remove application, leaking memory."); - e.printStackTrace(); + logger.log(Level.SEVERE, + "Could not remove application, leaking memory.", e); } } diff --git a/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java b/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java index fc03ff9590..5e660ab82c 100644 --- a/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java +++ b/src/com/vaadin/terminal/gwt/server/ApplicationRunnerServlet.java @@ -6,6 +6,8 @@ package com.vaadin.terminal.gwt.server; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -17,12 +19,15 @@ import com.vaadin.Application; @SuppressWarnings("serial") public class ApplicationRunnerServlet extends AbstractApplicationServlet { + private static final Logger logger = Logger + .getLogger(ApplicationRunnerServlet.class.getName()); + /** * The name of the application class currently used. Only valid within one * request. */ private String[] defaultPackages; - private ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>(); + private final ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>(); @Override public void init(ServletConfig servletConfig) throws ServletException { @@ -60,8 +65,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { // Creates a new application instance try { - final Application application = (Application) getApplicationClass() - .newInstance(); + final Application application = getApplicationClass().newInstance(); return application; } catch (final IllegalAccessException e) { throw new ServletException(e); @@ -83,9 +87,9 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { private static class URIS { String staticFilesPath; - String applicationURI; - String context; - String runner; + // String applicationURI; + // String context; + // String runner; String applicationClassname; } @@ -109,46 +113,47 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { final String[] urlParts = request.getRequestURI().toString() .split("\\/"); String context = null; - String runner = null; + // String runner = null; URIS uris = new URIS(); String applicationClassname = null; String contextPath = request.getContextPath(); if (urlParts[1].equals(contextPath.replaceAll("\\/", ""))) { // class name comes after web context and runner application context = urlParts[1]; - runner = urlParts[2]; + // runner = urlParts[2]; if (urlParts.length == 3) { throw new IllegalArgumentException("No application specified"); } applicationClassname = urlParts[3]; uris.staticFilesPath = "/" + context; - uris.applicationURI = "/" + context + "/" + runner + "/" - + applicationClassname; - uris.context = context; - uris.runner = runner; + // uris.applicationURI = "/" + context + "/" + runner + "/" + // + applicationClassname; + // uris.context = context; + // uris.runner = runner; uris.applicationClassname = applicationClassname; } else { // no context context = ""; - runner = urlParts[1]; + // runner = urlParts[1]; if (urlParts.length == 2) { throw new IllegalArgumentException("No application specified"); } applicationClassname = urlParts[2]; uris.staticFilesPath = "/"; - uris.applicationURI = "/" + runner + "/" + applicationClassname; - uris.context = context; - uris.runner = runner; + // uris.applicationURI = "/" + runner + "/" + applicationClassname; + // uris.context = context; + // uris.runner = runner; uris.applicationClassname = applicationClassname; } return uris; } - // @Override + @SuppressWarnings("unchecked") @Override - protected Class getApplicationClass() throws ClassNotFoundException { + protected Class<? extends Application> getApplicationClass() + throws ClassNotFoundException { // TODO use getClassLoader() ? Class<? extends Application> appClass = null; @@ -171,7 +176,10 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { // Ignore as this is expected for many packages } catch (Exception e2) { // TODO: handle exception - e2.printStackTrace(); + logger.log( + Level.FINE, + "Failed to find application class in the default package.", + e2); } if (appClass != null) { return appClass; diff --git a/src/com/vaadin/terminal/gwt/server/ChangeVariablesErrorEvent.java b/src/com/vaadin/terminal/gwt/server/ChangeVariablesErrorEvent.java index b19abe163b..089b811662 100644 --- a/src/com/vaadin/terminal/gwt/server/ChangeVariablesErrorEvent.java +++ b/src/com/vaadin/terminal/gwt/server/ChangeVariablesErrorEvent.java @@ -14,10 +14,10 @@ public class ChangeVariablesErrorEvent implements ComponentErrorEvent { private Throwable throwable; private Component component; - private Map variableChanges; + private Map<String, Object> variableChanges; public ChangeVariablesErrorEvent(Component component, Throwable throwable, - Map variableChanges) { + Map<String, Object> variableChanges) { this.component = component; this.throwable = throwable; this.variableChanges = variableChanges; @@ -31,7 +31,7 @@ public class ChangeVariablesErrorEvent implements ComponentErrorEvent { return component; } - public Map getVariableChanges() { + public Map<String, Object> getVariableChanges() { return variableChanges; } diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index c48af80305..111f43b31f 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -7,6 +7,9 @@ package com.vaadin.terminal.gwt.server; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -14,12 +17,12 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.vaadin.Application; -import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator; -import com.vaadin.external.org.apache.commons.fileupload.FileUpload; -import com.vaadin.external.org.apache.commons.fileupload.FileUploadException; -import com.vaadin.external.org.apache.commons.fileupload.servlet.ServletFileUpload; import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.DownloadStream; +import com.vaadin.terminal.Paintable; +import com.vaadin.terminal.StreamVariable; +import com.vaadin.terminal.VariableOwner; +import com.vaadin.ui.Component; import com.vaadin.ui.Window; /** @@ -202,34 +205,61 @@ public class CommunicationManager extends AbstractCommunicationManager { super(application); } - @Override - protected FileUpload createFileUpload() { - return new ServletFileUpload(); - } - - @Override - protected FileItemIterator getUploadItemIterator(FileUpload upload, - Request request) throws IOException, FileUploadException { - return ((ServletFileUpload) upload) - .getItemIterator((HttpServletRequest) request - .getWrappedRequest()); - } - /** * Handles file upload request submitted via Upload component. * - * TODO document + * @see #getStreamVariableTargetUrl(ReceiverOwner, String, StreamVariable) * * @param request * @param response * @throws IOException - * @throws FileUploadException + * @throws InvalidUIDLSecurityKeyException */ public void handleFileUpload(HttpServletRequest request, HttpServletResponse response) throws IOException, - FileUploadException { - doHandleFileUpload(new HttpServletRequestWrapper(request), - new HttpServletResponseWrapper(response)); + InvalidUIDLSecurityKeyException { + + /* + * URI pattern: APP/UPLOAD/[PID]/[NAME]/[SECKEY] See #createReceiverUrl + */ + + String pathInfo = request.getPathInfo(); + // strip away part until the data we are interested starts + int startOfData = pathInfo + .indexOf(AbstractApplicationServlet.UPLOAD_URL_PREFIX) + + AbstractApplicationServlet.UPLOAD_URL_PREFIX.length(); + String uppUri = pathInfo.substring(startOfData); + String[] parts = uppUri.split("/", 3); // 0 = pid, 1= name, 2 = sec key + String variableName = parts[1]; + String paintableId = parts[0]; + + StreamVariable streamVariable = pidToNameToStreamVariable.get( + paintableId).get(variableName); + String secKey = streamVariableToSeckey.get(streamVariable); + if (secKey.equals(parts[2])) { + + VariableOwner source = getVariableOwner(paintableId); + String contentType = request.getContentType(); + if (request.getContentType().contains("boundary")) { + // Multipart requests contain boundary string + doHandleSimpleMultipartFileUpload( + new HttpServletRequestWrapper(request), + new HttpServletResponseWrapper(response), + streamVariable, variableName, source, + contentType.split("boundary=")[1]); + } else { + // if boundary string does not exist, the posted file is from + // XHR2.post(File) + doHandleXhrFilePost(new HttpServletRequestWrapper(request), + new HttpServletResponseWrapper(response), + streamVariable, variableName, source, + request.getContentLength()); + } + } else { + throw new InvalidUIDLSecurityKeyException( + "Security key in upload post did not match!"); + } + } /** @@ -308,4 +338,78 @@ public class CommunicationManager extends AbstractCommunicationManager { new AbstractApplicationServletWrapper(applicationServlet)); } + @Override + protected void unregisterPaintable(Component p) { + /* Cleanup possible receivers */ + if (pidToNameToStreamVariable != null) { + Map<String, StreamVariable> removed = pidToNameToStreamVariable + .remove(getPaintableId(p)); + if (removed != null) { + for (String key : removed.keySet()) { + streamVariableToSeckey.remove(removed.get(key)); + } + } + } + super.unregisterPaintable(p); + + } + + private Map<String, Map<String, StreamVariable>> pidToNameToStreamVariable; + + private Map<StreamVariable, String> streamVariableToSeckey; + + @Override + String getStreamVariableTargetUrl(VariableOwner owner, String name, + StreamVariable value) { + /* + * We will use the same APP/* URI space as ApplicationResources but + * prefix url with UPLOAD + * + * eg. APP/UPLOAD/[PID]/[NAME]/[SECKEY] + * + * SECKEY is created on each paint to make URL's unpredictable (to + * prevent CSRF attacks). + * + * NAME and PID from URI forms a key to fetch StreamVariable when + * handling post + */ + String paintableId = getPaintableId((Paintable) owner); + String key = paintableId + "/" + name; + + if (pidToNameToStreamVariable == null) { + pidToNameToStreamVariable = new HashMap<String, Map<String, StreamVariable>>(); + } + Map<String, StreamVariable> nameToStreamVariable = pidToNameToStreamVariable + .get(paintableId); + if (nameToStreamVariable == null) { + nameToStreamVariable = new HashMap<String, StreamVariable>(); + pidToNameToStreamVariable.put(paintableId, nameToStreamVariable); + } + nameToStreamVariable.put(name, value); + + if (streamVariableToSeckey == null) { + streamVariableToSeckey = new HashMap<StreamVariable, String>(); + } + String seckey = streamVariableToSeckey.get(value); + if (seckey == null) { + seckey = UUID.randomUUID().toString(); + streamVariableToSeckey.put(value, seckey); + } + + return getApplication().getURL() + + AbstractApplicationServlet.UPLOAD_URL_PREFIX + key + "/" + + seckey; + + } + + @Override + protected void cleanStreamVariable(VariableOwner owner, String name) { + Map<String, StreamVariable> nameToStreamVar = pidToNameToStreamVariable + .get(getPaintableId((Paintable) owner)); + nameToStreamVar.remove("name"); + if (nameToStreamVar.isEmpty()) { + pidToNameToStreamVariable.remove(getPaintableId((Paintable) owner)); + } + } + } diff --git a/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java b/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java index 4ba0008252..fd51d66d7c 100644 --- a/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java +++ b/src/com/vaadin/terminal/gwt/server/ComponentSizeValidator.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Map; import java.util.Stack; import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.terminal.Sizeable; import com.vaadin.ui.AbstractOrderedLayout; @@ -30,9 +32,12 @@ import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -@SuppressWarnings("serial") +@SuppressWarnings({ "serial", "deprecation" }) public class ComponentSizeValidator implements Serializable { + private final static Logger logger = Logger + .getLogger(ComponentSizeValidator.class.getName()); + private final static int LAYERS_SHOWN = 4; /** @@ -70,10 +75,10 @@ public class ComponentSizeValidator implements Serializable { parent); } else if (component instanceof ComponentContainer) { ComponentContainer lo = (ComponentContainer) component; - Iterator it = lo.getComponentIterator(); + Iterator<Component> it = lo.getComponentIterator(); while (it.hasNext()) { - errors = validateComponentRelativeSizes((Component) it.next(), - errors, parent); + errors = validateComponentRelativeSizes(it.next(), errors, + parent); } } else if (component instanceof Form) { Form form = (Form) component; @@ -130,7 +135,8 @@ public class ComponentSizeValidator implements Serializable { return parentCanDefineHeight(component); } catch (Exception e) { - e.printStackTrace(); + logger.log(Level.FINER, + "An exception occurred while validating sizes.", e); return true; } } @@ -149,19 +155,20 @@ public class ComponentSizeValidator implements Serializable { return parentCanDefineWidth(component); } catch (Exception e) { - e.printStackTrace(); + logger.log(Level.FINER, + "An exception occurred while validating sizes.", e); return true; } } public static class InvalidLayout implements Serializable { - private Component component; + private final Component component; - private boolean invalidHeight; - private boolean invalidWidth; + private final boolean invalidHeight; + private final boolean invalidWidth; - private Vector<InvalidLayout> subErrors = new Vector<InvalidLayout>(); + private final Vector<InvalidLayout> subErrors = new Vector<InvalidLayout>(); public InvalidLayout(Component component, boolean height, boolean width) { this.component = component; @@ -173,7 +180,6 @@ public class ComponentSizeValidator implements Serializable { subErrors.add(error); } - @SuppressWarnings("deprecation") public void reportErrors(PrintWriter clientJSON, AbstractCommunicationManager communicationManager, PrintStream serverErrorStream) { @@ -393,16 +399,15 @@ public class ComponentSizeValidator implements Serializable { private static boolean hasNonRelativeHeightComponent( AbstractOrderedLayout ol) { - Iterator it = ol.getComponentIterator(); + Iterator<Component> it = ol.getComponentIterator(); while (it.hasNext()) { - if (!hasRelativeHeight((Component) it.next())) { + if (!hasRelativeHeight(it.next())) { return true; } } return false; } - @SuppressWarnings("deprecation") public static boolean parentCanDefineHeight(Component component) { Component parent = component.getParent(); if (parent == null) { @@ -488,9 +493,9 @@ public class ComponentSizeValidator implements Serializable { } private static boolean hasNonRelativeWidthComponent(AbstractOrderedLayout ol) { - Iterator it = ol.getComponentIterator(); + Iterator<Component> it = ol.getComponentIterator(); while (it.hasNext()) { - if (!hasRelativeWidth((Component) it.next())) { + if (!hasRelativeWidth(it.next())) { return true; } } @@ -502,7 +507,6 @@ public class ComponentSizeValidator implements Serializable { && paintable.getWidthUnits() == Sizeable.UNITS_PERCENTAGE; } - @SuppressWarnings("deprecation") public static boolean parentCanDefineWidth(Component component) { Component parent = component.getParent(); if (parent == null) { @@ -649,7 +653,7 @@ public class ComponentSizeValidator implements Serializable { private static void setLocation(Map<Object, FileLocation> map, Object object) { StackTraceElement[] traceLines = Thread.currentThread().getStackTrace(); for (StackTraceElement traceElement : traceLines) { - Class cls; + Class<?> cls; try { String className = traceElement.getClassName(); if (className.startsWith("java.") @@ -671,7 +675,8 @@ public class ComponentSizeValidator implements Serializable { return; } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + logger.log(Level.FINER, + "An exception occurred while validating sizes.", e); } } diff --git a/src/com/vaadin/terminal/gwt/server/Constants.java b/src/com/vaadin/terminal/gwt/server/Constants.java index 2d4135ebf7..b23a9c1284 100644 --- a/src/com/vaadin/terminal/gwt/server/Constants.java +++ b/src/com/vaadin/terminal/gwt/server/Constants.java @@ -11,19 +11,19 @@ package com.vaadin.terminal.gwt.server; */ public interface Constants { - static final String NOT_PRODUCTION_MODE_INFO = "" + static final String NOT_PRODUCTION_MODE_INFO = "\n" + "=================================================================\n" + "Vaadin is running in DEBUG MODE.\nAdd productionMode=true to web.xml " + "to disable debug features.\nTo show debug window, add ?debug to " + "your application URL.\n" + "================================================================="; - static final String WARNING_XSRF_PROTECTION_DISABLED = "" + static final String WARNING_XSRF_PROTECTION_DISABLED = "\n" + "===========================================================\n" + "WARNING: Cross-site request forgery protection is disabled!\n" + "==========================================================="; - static final String WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC = "" + static final String WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC = "\n" + "===========================================================\n" + "WARNING: resourceCacheTime has been set to a non integer value " + "in web.xml. The default of 1h will be used.\n" diff --git a/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index a741d6dfed..61e1fcad11 100644 --- a/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -5,6 +5,7 @@ package com.vaadin.terminal.gwt.server; import java.io.PrintWriter; import java.util.Map; +import java.util.logging.Logger; import com.vaadin.event.Transferable; import com.vaadin.event.TransferableImpl; @@ -22,9 +23,10 @@ import com.vaadin.ui.Component; public class DragAndDropService implements VariableOwner { - private int lastVisitId; + private static final Logger logger = Logger + .getLogger(DragAndDropService.class.getName()); - private int currentEventId; + private int lastVisitId; private boolean lastVisitAccepted = false; @@ -43,7 +45,7 @@ public class DragAndDropService implements VariableOwner { // Validate drop handler owner if (!(owner instanceof DropTarget)) { - System.err.println("DropHandler owner " + owner + logger.severe("DropHandler owner " + owner + " must implement DropTarget"); return; } @@ -74,9 +76,8 @@ public class DragAndDropService implements VariableOwner { DropHandler dropHandler = (dropTarget).getDropHandler(); if (dropHandler == null) { // No dropHandler returned so no drop can be performed. - System.err - .println("DropTarget.getDropHandler() returned null for owner: " - + dropTarget); + logger.fine("DropTarget.getDropHandler() returned null for owner: " + + dropTarget); return; } @@ -158,9 +159,6 @@ public class DragAndDropService implements VariableOwner { @SuppressWarnings("unchecked") private Transferable constructTransferable(DropTarget dropHandlerOwner, Map<String, Object> variables) { - int eventId = (Integer) variables.get("eventId"); - currentEventId = eventId; - final Component sourceComponent = (Component) variables .get("component"); diff --git a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java index 754cc50d13..5f8e59e056 100644 --- a/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/GAEApplicationServlet.java @@ -9,11 +9,10 @@ import java.io.IOException; import java.io.NotSerializableException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; @@ -95,7 +94,7 @@ import com.vaadin.service.ApplicationContext; */ public class GAEApplicationServlet extends ApplicationServlet { - private static final Logger log = Logger + private static final Logger logger = Logger .getLogger(GAEApplicationServlet.class.getName()); // memcache mutex is MUTEX_BASE + sessio id @@ -210,7 +209,7 @@ public class GAEApplicationServlet extends ApplicationServlet { try { Thread.sleep(RETRY_AFTER_MILLISECONDS); } catch (InterruptedException e) { - log.info("Thread.sleep() interrupted while waiting for lock. Trying again. " + logger.finer("Thread.sleep() interrupted while waiting for lock. Trying again. " + e); } } @@ -253,16 +252,17 @@ public class GAEApplicationServlet extends ApplicationServlet { ds.put(entity); } catch (DeadlineExceededException e) { - log.severe("DeadlineExceeded for " + session.getId()); + logger.warning("DeadlineExceeded for " + session.getId()); sendDeadlineExceededNotification(request, response); } catch (NotSerializableException e) { - log.severe("NotSerializableException: " + getStackTraceAsString(e)); + logger.log(Level.SEVERE, "Not serializable!", e); // TODO this notification is usually not shown - should we redirect // in some other way - can we? sendNotSerializableNotification(request, response); } catch (Exception e) { - log.severe(e + ": " + getStackTraceAsString(e)); + logger.log(Level.WARNING, + "An exception occurred while servicing request.", e); sendCriticalErrorNotification(request, response); } finally { @@ -308,13 +308,15 @@ public class GAEApplicationServlet extends ApplicationServlet { session.setAttribute(WebApplicationContext.class.getName(), applicationContext); } catch (IOException e) { - log.warning("Could not de-serialize ApplicationContext for " - + session.getId() + " A new one will be created. " - + getStackTraceAsString(e)); + logger.log(Level.WARNING, + "Could not de-serialize ApplicationContext for " + + session.getId() + + " A new one will be created. ", e); } catch (ClassNotFoundException e) { - log.warning("Could not de-serialize ApplicationContext for " - + session.getId() + " A new one will be created. " - + getStackTraceAsString(e)); + logger.log(Level.WARNING, + "Could not de-serialize ApplicationContext for " + + session.getId() + + " A new one will be created. ", e); } } // will create new context if the above did not @@ -366,7 +368,7 @@ public class GAEApplicationServlet extends ApplicationServlet { List<Entity> entities = pq.asList(Builder .withLimit(CLEANUP_LIMIT)); if (entities != null) { - log.info("Vaadin cleanup deleting " + entities.size() + logger.info("Vaadin cleanup deleting " + entities.size() + " expired Vaadin sessions."); List<Key> keys = new ArrayList<Key>(); for (Entity e : entities) { @@ -385,7 +387,7 @@ public class GAEApplicationServlet extends ApplicationServlet { List<Entity> entities = pq.asList(Builder .withLimit(CLEANUP_LIMIT)); if (entities != null) { - log.info("Vaadin cleanup deleting " + entities.size() + logger.info("Vaadin cleanup deleting " + entities.size() + " expired appengine sessions."); List<Key> keys = new ArrayList<Key>(); for (Entity e : entities) { @@ -395,15 +397,7 @@ public class GAEApplicationServlet extends ApplicationServlet { } } } catch (Exception e) { - log.warning("Exception while cleaning: " + getStackTraceAsString(e)); + logger.log(Level.WARNING, "Exception while cleaning.", e); } } - - private String getStackTraceAsString(Throwable t) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - t.printStackTrace(pw); - return sw.toString(); - } - } diff --git a/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java b/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java deleted file mode 100644 index 40b5d41004..0000000000 --- a/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java +++ /dev/null @@ -1,90 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.terminal.gwt.server; - -import java.io.InputStream; - -/** - * AjaxAdapter implementation of the UploadStream interface. - * - * @author IT Mill Ltd. - * @version - * @VERSION@ - * @since 5.0 - */ -@SuppressWarnings("serial") -public class HttpUploadStream implements com.vaadin.terminal.UploadStream { - - /** - * Holds value of property variableName. - */ - private final String streamName; - - private final String contentName; - - private final String contentType; - - /** - * Holds value of property variableValue. - */ - private final InputStream stream; - - /** - * Creates a new instance of UploadStreamImpl. - * - * @param name - * the name of the stream. - * @param stream - * the input stream. - * @param contentName - * the name of the content. - * @param contentType - * the type of the content. - */ - public HttpUploadStream(String name, InputStream stream, - String contentName, String contentType) { - streamName = name; - this.stream = stream; - this.contentName = contentName; - this.contentType = contentType; - } - - /** - * Gets the name of the stream. - * - * @return the name of the stream. - */ - public String getStreamName() { - return streamName; - } - - /** - * Gets the input stream. - * - * @return the Input stream. - */ - public InputStream getStream() { - return stream; - } - - /** - * Gets the input stream content type. - * - * @return the content type of the input stream. - */ - public String getContentType() { - return contentType; - } - - /** - * Gets the stream content name. Stream content name usually differs from - * the actual stream name. It is used to identify the content of the stream. - * - * @return the Name of the stream content. - */ - public String getContentName() { - return contentName; - } -} diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index ee9db805b2..8c8ab1e1be 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -20,6 +20,8 @@ import java.util.Map; import java.util.Set; import java.util.Stack; import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.Application; import com.vaadin.terminal.ApplicationResource; @@ -28,6 +30,7 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Paintable; import com.vaadin.terminal.Resource; +import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.VariableOwner; import com.vaadin.ui.Alignment; @@ -49,6 +52,9 @@ import com.vaadin.ui.CustomLayout; @SuppressWarnings("serial") public class JsonPaintTarget implements PaintTarget { + private static final Logger logger = Logger.getLogger(JsonPaintTarget.class + .getName()); + /* Document type declarations */ private final static String UIDL_ARG_NAME = "name"; @@ -65,7 +71,7 @@ public class JsonPaintTarget implements PaintTarget { private int changes = 0; - private Set<Object> usedResources = new HashSet<Object>(); + private final Set<Object> usedResources = new HashSet<Object>(); private boolean customLayoutArgumentsOpen = false; @@ -75,11 +81,11 @@ public class JsonPaintTarget implements PaintTarget { private boolean cacheEnabled = false; - private Collection<Paintable> paintedComponents = new HashSet<Paintable>(); + private final Collection<Paintable> paintedComponents = new HashSet<Paintable>(); private Collection<Paintable> identifiersCreatedDueRefPaint; - private Collection<Class<? extends Paintable>> usedPaintableTypes = new LinkedList<Class<? extends Paintable>>(); + private final Collection<Class<? extends Paintable>> usedPaintableTypes = new LinkedList<Class<? extends Paintable>>(); /** * Creates a new XMLPrintWriter, without automatic line flushing. @@ -351,6 +357,7 @@ public class JsonPaintTarget implements PaintTarget { tag.addAttribute("\"" + name + "\":" + (value ? "true" : "false")); } + @SuppressWarnings("deprecation") public void addAttribute(String name, Resource value) throws PaintException { if (value instanceof ExternalResource) { @@ -1019,11 +1026,10 @@ public class JsonPaintTarget implements PaintTarget { && Paintable.class.isAssignableFrom(superclass)) { class1 = (Class<? extends Paintable>) superclass; } else { - System.out - .append("Warning: no superclass of " - + paintable.getClass().getName() - + " has a @ClientWidget" - + " annotation. Component will not be mapped correctly on client side."); + logger.warning("No superclass of " + + paintable.getClass().getName() + + " has a @ClientWidget" + + " annotation. Component will not be mapped correctly on client side."); break; } } @@ -1074,20 +1080,23 @@ public class JsonPaintTarget implements PaintTarget { // TODO could optize to quit at the end attribute } } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + logger.log( + Level.SEVERE, + "An error occurred while finding widget mapping.", + e1); } finally { try { bufferedReader.close(); } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + logger.log(Level.SEVERE, "Could not close reader.", + e1); } } } catch (Throwable e2) { - // TODO Auto-generated catch block - e2.printStackTrace(); + logger.log(Level.SEVERE, + "An error occurred while finding widget mapping.", + e2); } return false; @@ -1101,4 +1110,14 @@ public class JsonPaintTarget implements PaintTarget { Collection<Class<? extends Paintable>> getUsedPaintableTypes() { return usedPaintableTypes; } + + public void addVariable(VariableOwner owner, String name, + StreamVariable value) throws PaintException { + String url = manager.getStreamVariableTargetUrl(owner, name, value); + if (url != null) { + addVariable(owner, name, url); + } // else { //NOP this was just a cleanup by component } + + } + } diff --git a/src/com/vaadin/terminal/gwt/server/NoInputStreamException.java b/src/com/vaadin/terminal/gwt/server/NoInputStreamException.java new file mode 100644 index 0000000000..72b99342cf --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/NoInputStreamException.java @@ -0,0 +1,6 @@ +package com.vaadin.terminal.gwt.server; + +@SuppressWarnings("serial") +public class NoInputStreamException extends Exception { + +} diff --git a/src/com/vaadin/terminal/gwt/server/NoOutputStreamException.java b/src/com/vaadin/terminal/gwt/server/NoOutputStreamException.java new file mode 100644 index 0000000000..6c33dab33e --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/NoOutputStreamException.java @@ -0,0 +1,6 @@ +package com.vaadin.terminal.gwt.server; + +@SuppressWarnings("serial") +public class NoOutputStreamException extends Exception { + +} diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java index 03de2fffd4..fac1f17ba7 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java @@ -26,7 +26,6 @@ import com.vaadin.Application; /** * @author marc */ -@SuppressWarnings({ "serial", "unchecked" }) public class PortletApplicationContext extends WebApplicationContext implements Serializable { diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index ceb26d1fb1..1f5c04ebe5 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -10,6 +10,8 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; @@ -47,6 +49,9 @@ import com.vaadin.ui.Window; @SuppressWarnings("serial") public class PortletApplicationContext2 extends AbstractWebApplicationContext { + private static final Logger logger = Logger + .getLogger(PortletApplicationContext2.class.getName()); + protected Map<Application, Set<PortletListener>> portletListeners = new HashMap<Application, Set<PortletListener>>(); protected transient PortletSession session; @@ -56,11 +61,11 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { private PortletResponse response; - private Map<String, QName> eventActionDestinationMap = new HashMap<String, QName>(); - private Map<String, Serializable> eventActionValueMap = new HashMap<String, Serializable>(); + private final Map<String, QName> eventActionDestinationMap = new HashMap<String, QName>(); + private final Map<String, Serializable> eventActionValueMap = new HashMap<String, Serializable>(); - private Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>(); - private Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>(); + private final Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>(); + private final Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>(); public File getBaseDirectory() { String resultPath = session.getPortletContext().getRealPath("/"); @@ -72,7 +77,11 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { return new File(url.getFile()); } catch (final Exception e) { // FIXME: Handle exception - e.printStackTrace(); + logger.log( + Level.INFO, + "Cannot access base directory, possible security issue " + + "with Application Server or Servlet Container", + e); } } return null; @@ -250,6 +259,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { return resourceURL.toString(); } else { // in a background thread or otherwise outside a request + // TODO exception ?? return null; } } diff --git a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index 57226588f9..0a8b7a78a5 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -7,9 +7,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; import javax.portlet.ClientDataRequest; import javax.portlet.MimeResponse; import javax.portlet.PortletRequest; @@ -17,15 +17,16 @@ import javax.portlet.PortletResponse; import javax.portlet.PortletSession; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; +import javax.portlet.ResourceURL; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequestWrapper; import com.vaadin.Application; -import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator; -import com.vaadin.external.org.apache.commons.fileupload.FileUpload; -import com.vaadin.external.org.apache.commons.fileupload.FileUploadException; -import com.vaadin.external.org.apache.commons.fileupload.portlet.PortletFileUpload; import com.vaadin.terminal.DownloadStream; +import com.vaadin.terminal.Paintable; +import com.vaadin.terminal.StreamVariable; +import com.vaadin.terminal.VariableOwner; +import com.vaadin.ui.Component; import com.vaadin.ui.Window; /** @@ -37,7 +38,7 @@ import com.vaadin.ui.Window; @SuppressWarnings("serial") public class PortletCommunicationManager extends AbstractCommunicationManager { - protected String dummyURL; + private ResourceResponse currentUidlResponse; private static class PortletRequestWrapper implements Request { @@ -191,39 +192,33 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { super(application); } - @Override - protected FileUpload createFileUpload() { - return new PortletFileUpload(); - } - - @Override - protected FileItemIterator getUploadItemIterator(FileUpload upload, - Request request) throws IOException, FileUploadException { - return ((PortletFileUpload) upload) - .getItemIterator((ActionRequest) request.getWrappedRequest()); - } + public void handleFileUpload(ResourceRequest request, + ResourceResponse response) throws IOException { + String contentType = request.getContentType(); + String name = request.getParameter("name"); + String ownerId = request.getParameter("rec-owner"); + VariableOwner variableOwner = getVariableOwner(ownerId); + StreamVariable streamVariable = ownerToNameToStreamVariable.get( + variableOwner).get(name); + + if (contentType.contains("boundary")) { + doHandleSimpleMultipartFileUpload( + new PortletRequestWrapper(request), + new PortletResponseWrapper(response), streamVariable, name, + variableOwner, contentType.split("boundary=")[1]); + } else { + doHandleXhrFilePost(new PortletRequestWrapper(request), + new PortletResponseWrapper(response), streamVariable, name, + variableOwner, request.getContentLength()); + } - public void handleFileUpload(ActionRequest request, ActionResponse response) - throws FileUploadException, IOException { - doHandleFileUpload(new PortletRequestWrapper(request), - new PortletResponseWrapper(response)); } @Override - protected void sendUploadResponse(Request request, Response response) - throws IOException { - if (response.getWrappedResponse() instanceof ActionResponse) { - /* - * If we do not redirect to some other page, the entire portal page - * will be re-printed into the target of the upload request (an - * IFRAME), which in turn will cause very strange side effects. - */ - System.out.println("Redirecting to dummyURL: " + dummyURL); - ((ActionResponse) response.getWrappedResponse()) - .sendRedirect(dummyURL == null ? "http://www.google.com" - : dummyURL); - } else { - super.sendUploadResponse(request, response); + protected void unregisterPaintable(Component p) { + super.unregisterPaintable(p); + if (ownerToNameToStreamVariable != null) { + ownerToNameToStreamVariable.remove(p); } } @@ -231,10 +226,12 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { ResourceResponse response, AbstractApplicationPortlet applicationPortlet, Window window) throws InvalidUIDLSecurityKeyException, IOException { + currentUidlResponse = response; doHandleUidlRequest(new PortletRequestWrapper(request), new PortletResponseWrapper(response), new AbstractApplicationPortletWrapper(applicationPortlet), window); + currentUidlResponse = null; } DownloadStream handleURI(Window window, ResourceRequest request, @@ -265,9 +262,44 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { Window getApplicationWindow(PortletRequest request, AbstractApplicationPortlet applicationPortlet, Application application, Window assumedWindow) { + return doGetApplicationWindow(new PortletRequestWrapper(request), new AbstractApplicationPortletWrapper(applicationPortlet), application, assumedWindow); } + private Map<VariableOwner, Map<String, StreamVariable>> ownerToNameToStreamVariable; + + @Override + String getStreamVariableTargetUrl(VariableOwner owner, String name, + StreamVariable value) { + if (ownerToNameToStreamVariable == null) { + ownerToNameToStreamVariable = new HashMap<VariableOwner, Map<String, StreamVariable>>(); + } + Map<String, StreamVariable> nameToReceiver = ownerToNameToStreamVariable + .get(owner); + if (nameToReceiver == null) { + nameToReceiver = new HashMap<String, StreamVariable>(); + ownerToNameToStreamVariable.put(owner, nameToReceiver); + } + nameToReceiver.put(name, value); + ResourceURL resurl = currentUidlResponse.createResourceURL(); + resurl.setResourceID("UPLOAD"); + resurl.setParameter("name", name); + resurl.setParameter("rec-owner", getPaintableId((Paintable) owner)); + resurl.setProperty("name", name); + resurl.setProperty("rec-owner", getPaintableId((Paintable) owner)); + return resurl.toString(); + } + + @Override + protected void cleanStreamVariable(VariableOwner owner, String name) { + Map<String, StreamVariable> map = ownerToNameToStreamVariable + .get(owner); + map.remove(name); + if (map.isEmpty()) { + ownerToNameToStreamVariable.remove(owner); + } + } + } diff --git a/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java new file mode 100644 index 0000000000..e6290cbf9a --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/StreamingEndEventImpl.java @@ -0,0 +1,13 @@ +package com.vaadin.terminal.gwt.server; + +import com.vaadin.terminal.StreamVariable.StreamingEndEvent; + +@SuppressWarnings("serial") +final class StreamingEndEventImpl extends AbstractStreamingEvent implements + StreamingEndEvent { + + public StreamingEndEventImpl(String filename, String type, long totalBytes) { + super(filename, type, totalBytes, totalBytes); + } + +} diff --git a/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java new file mode 100644 index 0000000000..367b4be277 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/StreamingErrorEventImpl.java @@ -0,0 +1,21 @@ +package com.vaadin.terminal.gwt.server; + +import com.vaadin.terminal.StreamVariable.StreamingErrorEvent; + +@SuppressWarnings("serial") +final class StreamingErrorEventImpl extends AbstractStreamingEvent implements + StreamingErrorEvent { + + private final Exception exception; + + public StreamingErrorEventImpl(final String filename, final String type, + long contentLength, long bytesReceived, final Exception exception) { + super(filename, type, contentLength, bytesReceived); + this.exception = exception; + } + + public final Exception getException() { + return exception; + } + +} diff --git a/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java new file mode 100644 index 0000000000..a6308f67a1 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/StreamingProgressEventImpl.java @@ -0,0 +1,14 @@ +package com.vaadin.terminal.gwt.server; + +import com.vaadin.terminal.StreamVariable.StreamingProgressEvent; + +@SuppressWarnings("serial") +final class StreamingProgressEventImpl extends AbstractStreamingEvent implements + StreamingProgressEvent { + + public StreamingProgressEventImpl(final String filename, final String type, + long contentLength, long bytesReceived) { + super(filename, type, contentLength, bytesReceived); + } + +} diff --git a/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java b/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java new file mode 100644 index 0000000000..113c69cc08 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/StreamingStartEventImpl.java @@ -0,0 +1,24 @@ +package com.vaadin.terminal.gwt.server; + +import com.vaadin.terminal.StreamVariable.StreamingStartEvent; + +@SuppressWarnings("serial") +final class StreamingStartEventImpl extends AbstractStreamingEvent implements + StreamingStartEvent { + + private boolean disposed; + + public StreamingStartEventImpl(final String filename, final String type, + long contentLength) { + super(filename, type, contentLength, 0); + } + + public void disposeStreamVariable() { + disposed = true; + } + + boolean isDisposed() { + return disposed; + } + +} diff --git a/src/com/vaadin/terminal/gwt/server/UploadException.java b/src/com/vaadin/terminal/gwt/server/UploadException.java new file mode 100644 index 0000000000..ef3b2554d2 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/UploadException.java @@ -0,0 +1,12 @@ +package com.vaadin.terminal.gwt.server; + +@SuppressWarnings("serial") +public class UploadException extends Exception { + public UploadException(Exception e) { + super("Upload failed", e); + } + + public UploadException(String msg) { + super(msg); + } +} diff --git a/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java b/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java index 116667f582..dbb44d51d2 100644 --- a/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java +++ b/src/com/vaadin/terminal/gwt/server/WebApplicationContext.java @@ -31,7 +31,7 @@ public class WebApplicationContext extends AbstractWebApplicationContext { * Creates a new Web Application Context. * */ - WebApplicationContext() { + protected WebApplicationContext() { } @@ -92,14 +92,14 @@ public class WebApplicationContext extends AbstractWebApplicationContext { * @param application * @return CommunicationManager */ - protected CommunicationManager getApplicationManager( - Application application, AbstractApplicationServlet servlet) { + public CommunicationManager getApplicationManager(Application application, + AbstractApplicationServlet servlet) { CommunicationManager mgr = (CommunicationManager) applicationToAjaxAppMgrMap .get(application); if (mgr == null) { // Creates new manager - mgr = new CommunicationManager(application, servlet); + mgr = servlet.createCommunicationManager(application); applicationToAjaxAppMgrMap.put(application, mgr); } return mgr; diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java index b215717ee0..0fa618ec4f 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java @@ -54,8 +54,10 @@ import com.vaadin.ui.ClientWidget; */ public class ClassPathExplorer { - private static Logger logger = Logger - .getLogger("com.vaadin.terminal.gwt.widgetsetutils"); + private static Logger logger = Logger.getLogger(ClassPathExplorer.class + .getName()); + + private static final String VAADIN_ADDON_VERSION_ATTRIBUTE = "Vaadin-Package-Version"; /** * File filter that only accepts directories. @@ -101,12 +103,18 @@ public class ClassPathExplorer { * @return a collection of {@link Paintable} classes */ public static Collection<Class<? extends Paintable>> getPaintablesHavingWidgetAnnotation() { - + logger.info("Searching for paintables.."); + long start = System.currentTimeMillis(); Collection<Class<? extends Paintable>> paintables = new HashSet<Class<? extends Paintable>>(); Set<String> keySet = classpathLocations.keySet(); for (String url : keySet) { + logger.fine("Searching for paintables in " + + classpathLocations.get(url)); searchForPaintables(classpathLocations.get(url), url, paintables); } + long end = System.currentTimeMillis(); + + logger.info("Search took " + (end - start) + "ms"); return paintables; } @@ -132,11 +140,14 @@ public class ClassPathExplorer { * @return map from widgetset classname to widgetset location URL */ public static Map<String, URL> getAvailableWidgetSets() { + long start = System.currentTimeMillis(); Map<String, URL> widgetsets = new HashMap<String, URL>(); Set<String> keySet = classpathLocations.keySet(); for (String location : keySet) { searchForWidgetSets(location, widgetsets); } + long end = System.currentTimeMillis(); + StringBuilder sb = new StringBuilder(); sb.append("Widgetsets found from classpath:\n"); for (String ws : widgetsets.keySet()) { @@ -147,6 +158,7 @@ public class ClassPathExplorer { sb.append("\n"); } logger.info(sb.toString()); + logger.info("Search took " + (end - start) + "ms"); return widgetsets; } @@ -196,7 +208,10 @@ public class ClassPathExplorer { } catch (MalformedURLException e) { // should never happen as based on an existing URL, // only changing end of file name/path part - e.printStackTrace(); + logger.log( + Level.SEVERE, + "Error locating the widgetset " + classname, + e); } } } @@ -286,12 +301,17 @@ public class ClassPathExplorer { */ private final static Map<String, URL> getClasspathLocations( List<String> rawClasspathEntries) { + long start = System.currentTimeMillis(); // try to keep the order of the classpath Map<String, URL> locations = new LinkedHashMap<String, URL>(); for (String classpathEntry : rawClasspathEntries) { File file = new File(classpathEntry); include(null, file, locations); } + long end = System.currentTimeMillis(); + if (logger.isLoggable(Level.FINE)) { + logger.fine("getClassPathLocations took " + (end - start) + "ms"); + } return locations; } @@ -340,11 +360,9 @@ public class ClassPathExplorer { } } } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.log(Level.FINEST, "Failed to inspect JAR file", e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.log(Level.FINEST, "Failed to inspect JAR file", e); } return false; @@ -469,6 +487,11 @@ public class ClassPathExplorer { JarFile jarFile = conn.getJarFile(); + // Only scan for paintables in Vaadin add-ons + if (!isVaadinAddon(jarFile)) { + return; + } + Enumeration<JarEntry> e = jarFile.entries(); while (e.hasMoreElements()) { JarEntry entry = e.nextElement(); @@ -521,6 +544,7 @@ public class ClassPathExplorer { * the collection to which to add server side classes with * {@link ClientWidget} annotation */ + @SuppressWarnings("unchecked") private static void tryToAdd(final String fullclassName, Collection<Class<? extends Paintable>> paintables) { PrintStream out = System.out; @@ -602,10 +626,10 @@ public class ClassPathExplorer { try { return new URL("file://" + directory.getCanonicalPath()); } catch (MalformedURLException e) { - e.printStackTrace(); + logger.log(Level.FINEST, "Ignoring exception", e); // ignore: continue to the next classpath entry } catch (IOException e) { - e.printStackTrace(); + logger.log(Level.FINEST, "Ignoring exception", e); // ignore: continue to the next classpath entry } } @@ -614,6 +638,26 @@ public class ClassPathExplorer { } /** + * Checks if the given jarFile is a Vaadin add-on. + * + * @param jarFile + * @return true if the file is an add-on, false otherwise + * @throws IOException + */ + private static boolean isVaadinAddon(JarFile jarFile) throws IOException { + Manifest manifest = jarFile.getManifest(); + if (manifest == null) { + return false; + } + Attributes mainAttributes = manifest.getMainAttributes(); + if (mainAttributes == null) { + return false; + } + + return (mainAttributes.getValue(VAADIN_ADDON_VERSION_ATTRIBUTE) != null); + } + + /** * Test method for helper tool */ public static void main(String[] args) { diff --git a/src/com/vaadin/tools/WidgetsetCompiler.java b/src/com/vaadin/tools/WidgetsetCompiler.java index ab5e4ad9d3..9fe97ba12a 100644 --- a/src/com/vaadin/tools/WidgetsetCompiler.java +++ b/src/com/vaadin/tools/WidgetsetCompiler.java @@ -4,6 +4,8 @@ package com.vaadin.tools; import java.lang.reflect.Method; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder; @@ -31,6 +33,9 @@ import com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder; */ public class WidgetsetCompiler { + private static final Logger logger = Logger + .getLogger(WidgetsetCompiler.class.getName()); + /** * @param args * same arguments as for com.google.gwt.dev.Compiler @@ -67,7 +72,8 @@ public class WidgetsetCompiler { String[].class); method.invoke(null, new Object[] { args }); } catch (Throwable thr) { - thr.printStackTrace(); + logger.log(Level.SEVERE, + "Widgetset compilation failed", thr); } } }; @@ -76,7 +82,7 @@ public class WidgetsetCompiler { runThread.join(); System.out.println("Widgetset compilation finished"); } catch (Throwable thr) { - thr.printStackTrace(); + logger.log(Level.SEVERE, "Widgetset compilation failed", thr); } } } diff --git a/src/com/vaadin/ui/AbsoluteLayout.java b/src/com/vaadin/ui/AbsoluteLayout.java index 15ef32d4a4..538cc26c77 100644 --- a/src/com/vaadin/ui/AbsoluteLayout.java +++ b/src/com/vaadin/ui/AbsoluteLayout.java @@ -51,6 +51,16 @@ public class AbsoluteLayout extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Replaces one component with another one. The new component inherits the * old components position. */ @@ -556,8 +566,9 @@ public class AbsoluteLayout extends AbstractLayout { * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ + @SuppressWarnings("unchecked") @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey(CLICK_EVENT)) { fireClick((Map<String, Object>) variables.get(CLICK_EVENT)); diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java index 78e73845ad..f0938780fe 100644 --- a/src/com/vaadin/ui/AbstractComponent.java +++ b/src/com/vaadin/ui/AbstractComponent.java @@ -941,6 +941,17 @@ public abstract class AbstractComponent implements Component, MethodEventSource } /** + * Checks if the given {@link Event} type is listened for this component. + * + * @param eventType + * the event type to be checked + * @return true if a listener is registered for the given event type + */ + protected boolean hasListeners(Class<?> eventType) { + return eventRouter != null && eventRouter.hasListeners(eventType); + } + + /** * Removes all registered listeners matching the given parameters. Since * this method receives the event type and the listener object as * parameters, it will unregister all <code>object</code>'s methods that are @@ -1000,7 +1011,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * @param method * the activation method. */ - public void addListener(Class eventType, Object target, Method method) { + public void addListener(Class<?> eventType, Object target, Method method) { if (eventRouter == null) { eventRouter = new EventRouter(); } @@ -1041,7 +1052,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * @param methodName * the name of the activation method. */ - public void addListener(Class eventType, Object target, String methodName) { + public void addListener(Class<?> eventType, Object target, String methodName) { if (eventRouter == null) { eventRouter = new EventRouter(); } @@ -1066,7 +1077,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * the target object that has registered to listen to events of * type <code>eventType</code> with one or more methods. */ - public void removeListener(Class eventType, Object target) { + public void removeListener(Class<?> eventType, Object target) { if (eventRouter != null) { eventRouter.removeListener(eventType, target); } @@ -1091,7 +1102,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource * the method owned by <code>target</code> that's registered to * listen to events of type <code>eventType</code>. */ - public void removeListener(Class eventType, Object target, Method method) { + public void removeListener(Class<?> eventType, Object target, Method method) { if (eventRouter != null) { eventRouter.removeListener(eventType, target, method); } @@ -1125,7 +1136,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource * the name of the method owned by <code>target</code> that's * registered to listen to events of type <code>eventType</code>. */ - public void removeListener(Class eventType, Object target, String methodName) { + public void removeListener(Class<?> eventType, Object target, + String methodName) { if (eventRouter != null) { eventRouter.removeListener(eventType, target, methodName); } diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index fb3065df99..faa2dad5a1 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -8,7 +8,6 @@ import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; @@ -174,7 +173,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Gets the field type Don't add a JavaDoc comment here, we use the default * documentation from the implemented interface. */ - public abstract Class getType(); + public abstract Class<?> getType(); /** * The abstract field is read only also if the data source is in read only @@ -1014,29 +1013,14 @@ public abstract class AbstractField extends AbstractComponent implements Field, * * @param propertyType * the Type of the property, that needs to be edited. - */ - public static AbstractField constructField(Class propertyType) { - - // Null typed properties can not be edited - if (propertyType == null) { - return null; - } - - // Date field - if (Date.class.isAssignableFrom(propertyType)) { - return new DateField(); - } - - // Boolean field - if (Boolean.class.isAssignableFrom(propertyType)) { - final Button button = new Button(""); - button.setSwitchMode(true); - button.setImmediate(false); - return button; - } - - // Text field is used by default - return new TextField(); + * @deprecated use e.g. + * {@link DefaultFieldFactory#createFieldByPropertyType(Class)} + * instead + */ + @Deprecated + public static AbstractField constructField(Class<?> propertyType) { + return (AbstractField) DefaultFieldFactory + .createFieldByPropertyType(propertyType); } /* diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java index b0587f8d38..7bd52f8feb 100644 --- a/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -127,6 +127,16 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Paints the content of this component. * * @param target @@ -161,8 +171,8 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements int oldLocation = -1; int newLocation = -1; int location = 0; - for (final Iterator i = components.iterator(); i.hasNext();) { - final Component component = (Component) i.next(); + for (final Iterator<Component> i = components.iterator(); i.hasNext();) { + final Component component = i.next(); if (component == oldComponent) { oldLocation = location; @@ -324,12 +334,25 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements return (ratio == null) ? 0 : ratio.floatValue(); } + /** + * Sets the component alignment using a short hand string notation. + * + * @deprecated Replaced by + * {@link #setComponentAlignment(Component, Alignment)} + * + * @param component + * A child component in this layout + * @param alignment + * A short hand notation described in {@link AlignmentUtils} + */ + @Deprecated public void setComponentAlignment(Component component, String alignment) { AlignmentUtils.setComponentAlignment(this, component, alignment); } + @SuppressWarnings("unchecked") @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey(CLICK_EVENT)) { fireClick((Map<String, Object>) variables.get(CLICK_EVENT)); diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index 0e2364db56..ef09becb00 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -164,12 +164,12 @@ public abstract class AbstractSelect extends AbstractField implements /** * Item icons. */ - private final HashMap itemIcons = new HashMap(); + private final HashMap<Object, Resource> itemIcons = new HashMap<Object, Resource>(); /** * Item captions. */ - private final HashMap itemCaptions = new HashMap(); + private final HashMap<Object, String> itemCaptions = new HashMap<Object, String>(); /** * Item caption mode. @@ -189,12 +189,12 @@ public abstract class AbstractSelect extends AbstractField implements /** * List of property set change event listeners. */ - private Set propertySetEventListeners = null; + private Set<Container.PropertySetChangeListener> propertySetEventListeners = null; /** * List of item set change event listeners. */ - private Set itemSetEventListeners = null; + private Set<Container.ItemSetChangeListener> itemSetEventListeners = null; /** * Item id that represents null selection of this select. @@ -252,12 +252,12 @@ public abstract class AbstractSelect extends AbstractField implements * @param options * the Collection containing the options. */ - public AbstractSelect(String caption, Collection options) { + public AbstractSelect(String caption, Collection<?> options) { // Creates the options container and add given options to it final Container c = new IndexedContainer(); if (options != null) { - for (final Iterator i = options.iterator(); i.hasNext();) { + for (final Iterator<?> i = options.iterator(); i.hasNext();) { c.addItem(i.next()); } } @@ -299,7 +299,7 @@ public abstract class AbstractSelect extends AbstractField implements // Constructs selected keys array String[] selectedKeys; if (isMultiSelect()) { - selectedKeys = new String[((Set) getValue()).size()]; + selectedKeys = new String[((Set<?>) getValue()).size()]; } else { selectedKeys = new String[(getValue() == null && getNullSelectionItemId() == null ? 0 : 1)]; @@ -313,7 +313,7 @@ public abstract class AbstractSelect extends AbstractField implements target.startTag("options"); int keyIndex = 0; // Support for external null selection item id - final Collection ids = getItemIds(); + final Collection<?> ids = getItemIds(); if (isNullSelectionAllowed() && getNullSelectionItemId() != null && !ids.contains(getNullSelectionItemId())) { final Object id = getNullSelectionItemId(); @@ -326,7 +326,7 @@ public abstract class AbstractSelect extends AbstractField implements target.endTag("so"); } - final Iterator i = getItemIds().iterator(); + final Iterator<?> i = getItemIds().iterator(); // Paints the available selection options from data source while (i.hasNext()) { // Gets the option attribute values @@ -404,7 +404,7 @@ public abstract class AbstractSelect extends AbstractField implements // TODO Optimize by adding repaintNotNeeded when applicable // Converts the key-array to id-set - final LinkedList s = new LinkedList(); + final LinkedList<Object> s = new LinkedList<Object>(); for (int i = 0; i < ka.length; i++) { final Object id = itemIdMapper.get(ka[i]); if (!isNullSelectionAllowed() @@ -424,13 +424,14 @@ public abstract class AbstractSelect extends AbstractField implements // Limits the deselection to the set of visible items // (non-visible items can not be deselected) - final Collection visible = getVisibleItemIds(); + final Collection<?> visible = getVisibleItemIds(); if (visible != null) { - Set newsel = (Set) getValue(); + @SuppressWarnings("unchecked") + Set<Object> newsel = (Set<Object>) getValue(); if (newsel == null) { - newsel = new HashSet(); + newsel = new HashSet<Object>(); } else { - newsel = new HashSet(newsel); + newsel = new HashSet<Object>(newsel); } newsel.removeAll(visible); newsel.addAll(s); @@ -447,7 +448,7 @@ public abstract class AbstractSelect extends AbstractField implements // Allows deselection only if the deselected item is // visible final Object current = getValue(); - final Collection visible = getVisibleItemIds(); + final Collection<?> visible = getVisibleItemIds(); if (visible != null && visible.contains(current)) { setValue(null, true); } @@ -541,7 +542,7 @@ public abstract class AbstractSelect extends AbstractField implements * but can be overriden in subclasses if they paint only part of the items * to the terminal or null if no items is visible. */ - public Collection getVisibleItemIds() { + public Collection<?> getVisibleItemIds() { if (isVisible()) { return getItemIds(); } @@ -559,7 +560,7 @@ public abstract class AbstractSelect extends AbstractField implements * @return the Type of the property. */ @Override - public Class getType() { + public Class<?> getType() { if (isMultiSelect()) { return Set.class; } else { @@ -580,14 +581,14 @@ public abstract class AbstractSelect extends AbstractField implements // If the return value is not a set if (retValue == null) { - return new HashSet(); + return new HashSet<Object>(); } if (retValue instanceof Set) { - return Collections.unmodifiableSet((Set) retValue); + return Collections.unmodifiableSet((Set<?>) retValue); } else if (retValue instanceof Collection) { - return new HashSet((Collection) retValue); + return new HashSet<Object>((Collection<?>) retValue); } else { - final Set s = new HashSet(); + final Set<Object> s = new HashSet<Object>(); if (items.containsId(retValue)) { s.add(retValue); } @@ -644,9 +645,9 @@ public abstract class AbstractSelect extends AbstractField implements if (isMultiSelect()) { if (newValue == null) { - super.setValue(new HashSet(), repaintIsNotNeeded); + super.setValue(new HashSet<Object>(), repaintIsNotNeeded); } else if (Collection.class.isAssignableFrom(newValue.getClass())) { - super.setValue(new HashSet((Collection) newValue), + super.setValue(new HashSet<Object>((Collection<?>) newValue), repaintIsNotNeeded); } } else if (newValue == null || items.containsId(newValue)) { @@ -673,7 +674,7 @@ public abstract class AbstractSelect extends AbstractField implements * * @return the Collection of item ids. */ - public Collection getItemIds() { + public Collection<?> getItemIds() { return items.getItemIds(); } @@ -682,7 +683,7 @@ public abstract class AbstractSelect extends AbstractField implements * * @return the Collection of property ids. */ - public Collection getContainerPropertyIds() { + public Collection<?> getContainerPropertyIds() { return items.getContainerPropertyIds(); } @@ -693,7 +694,7 @@ public abstract class AbstractSelect extends AbstractField implements * the Id identifying the property. * @see com.vaadin.data.Container#getType(java.lang.Object) */ - public Class getType(Object propertyId) { + public Class<?> getType(Object propertyId) { return items.getType(propertyId); } @@ -959,13 +960,13 @@ public abstract class AbstractSelect extends AbstractField implements // Convert the value type if (multiSelect) { - final Set s = new HashSet(); + final Set<Object> s = new HashSet<Object>(); if (oldValue != null) { s.add(oldValue); } setValue(s); } else { - final Set s = (Set) oldValue; + final Set<?> s = (Set<?>) oldValue; if (s == null || s.isEmpty()) { setValue(null); } else { @@ -1065,11 +1066,11 @@ public abstract class AbstractSelect extends AbstractField implements break; case ITEM_CAPTION_MODE_EXPLICIT: - caption = (String) itemCaptions.get(itemId); + caption = itemCaptions.get(itemId); break; case ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID: - caption = (String) itemCaptions.get(itemId); + caption = itemCaptions.get(itemId); if (caption == null) { caption = itemId.toString(); } @@ -1115,7 +1116,7 @@ public abstract class AbstractSelect extends AbstractField implements * @return the Icon for the item or null, if not specified. */ public Resource getItemIcon(Object itemId) { - final Resource explicit = (Resource) itemIcons.get(itemId); + final Resource explicit = itemIcons.get(itemId); if (explicit != null) { return explicit; } @@ -1328,7 +1329,7 @@ public abstract class AbstractSelect extends AbstractField implements return false; } if (isMultiSelect()) { - return ((Set) getValue()).contains(itemId); + return ((Set<?>) getValue()).contains(itemId); } else { final Object value = getValue(); return itemId.equals(value == null ? getNullSelectionItemId() @@ -1355,7 +1356,7 @@ public abstract class AbstractSelect extends AbstractField implements setValue(itemId); } else if (!isSelected(itemId) && itemId != null && items.containsId(itemId)) { - final Set s = new HashSet((Set) getValue()); + final Set<Object> s = new HashSet<Object>((Set<?>) getValue()); s.add(itemId); setValue(s); } @@ -1373,7 +1374,7 @@ public abstract class AbstractSelect extends AbstractField implements public void unselect(Object itemId) { if (isSelected(itemId)) { if (isMultiSelect()) { - final Set s = new HashSet((Set) getValue()); + final Set<Object> s = new HashSet<Object>((Set<?>) getValue()); s.remove(itemId); setValue(s); } else { @@ -1399,7 +1400,7 @@ public abstract class AbstractSelect extends AbstractField implements */ public void addListener(Container.PropertySetChangeListener listener) { if (propertySetEventListeners == null) { - propertySetEventListeners = new LinkedHashSet(); + propertySetEventListeners = new LinkedHashSet<Container.PropertySetChangeListener>(); } propertySetEventListeners.add(listener); } @@ -1425,7 +1426,7 @@ public abstract class AbstractSelect extends AbstractField implements */ public void addListener(Container.ItemSetChangeListener listener) { if (itemSetEventListeners == null) { - itemSetEventListeners = new LinkedHashSet(); + itemSetEventListeners = new LinkedHashSet<Container.ItemSetChangeListener>(); } itemSetEventListeners.add(listener); } @@ -1535,7 +1536,7 @@ public abstract class AbstractSelect extends AbstractField implements } else { Object value = getValue(); return super.isEmpty() - || (value instanceof Collection && ((Collection) value) + || (value instanceof Collection && ((Collection<?>) value) .isEmpty()); } } @@ -1653,7 +1654,9 @@ public abstract class AbstractSelect extends AbstractField implements protected class CaptionChangeListener implements Item.PropertySetChangeListener, Property.ValueChangeListener { - HashSet captionChangeNotifiers = new HashSet(); + // TODO clean this up - type is either Item.PropertySetChangeNotifier or + // Property.ValueChangeNotifier + HashSet<Object> captionChangeNotifiers = new HashSet<Object>(); public void addNotifierForItem(Object itemId) { switch (getItemCaptionMode()) { @@ -1667,9 +1670,9 @@ public abstract class AbstractSelect extends AbstractField implements .addListener(getCaptionChangeListener()); captionChangeNotifiers.add(i); } - Collection pids = i.getItemPropertyIds(); + Collection<?> pids = i.getItemPropertyIds(); if (pids != null) { - for (Iterator it = pids.iterator(); it.hasNext();) { + for (Iterator<?> it = pids.iterator(); it.hasNext();) { Property p = i.getItemProperty(it.next()); if (p != null && p instanceof Property.ValueChangeNotifier) { @@ -1695,7 +1698,8 @@ public abstract class AbstractSelect extends AbstractField implements } public void clear() { - for (Iterator it = captionChangeNotifiers.iterator(); it.hasNext();) { + for (Iterator<Object> it = captionChangeNotifiers.iterator(); it + .hasNext();) { Object notifier = it.next(); if (notifier instanceof Item.PropertySetChangeNotifier) { ((Item.PropertySetChangeNotifier) notifier) diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java new file mode 100644 index 0000000000..7fe1306ea4 --- /dev/null +++ b/src/com/vaadin/ui/AbstractTextField.java @@ -0,0 +1,349 @@ +package com.vaadin.ui; + +import java.text.Format; +import java.util.Map; + +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.terminal.PaintException; +import com.vaadin.terminal.PaintTarget; + +public abstract class AbstractTextField extends AbstractField { + + /** + * Value formatter used to format the string contents. + */ + private Format format; + + /** + * Null representation. + */ + private String nullRepresentation = "null"; + /** + * Is setting to null from non-null value allowed by setting with null + * representation . + */ + private boolean nullSettingAllowed = false; + /** + * Maximum character count in text field. + */ + private int maxLength = -1; + + public AbstractTextField() { + super(); + } + + @Override + public void paintContent(PaintTarget target) throws PaintException { + super.paintContent(target); + + if (getMaxLength() >= 0) { + target.addAttribute("maxLength", getMaxLength()); + } + + // Adds the content as variable + String value = getFormattedValue(); + if (value == null) { + value = getNullRepresentation(); + } + if (value == null) { + throw new IllegalStateException( + "Null values are not allowed if the null-representation is null"); + } + target.addVariable(this, "text", value); + } + + /** + * 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 Object getValue() { + Object v = super.getValue(); + if (format == null || v == null) { + return v; + } + try { + return format.format(v); + } catch (final IllegalArgumentException e) { + return v; + } + } + + @Override + public void changeVariables(Object source, Map<String, Object> variables) { + + super.changeVariables(source, variables); + + // Sets the text + if (variables.containsKey("text") && !isReadOnly()) { + + // Only do the setting if the string representation of the value + // has been updated + String newValue = (String) variables.get("text"); + + // server side check for max length + if (getMaxLength() != -1 && newValue.length() > getMaxLength()) { + newValue = newValue.substring(0, getMaxLength()); + } + final String oldValue = getFormattedValue(); + if (newValue != null + && (oldValue == null || isNullSettingAllowed()) + && newValue.equals(getNullRepresentation())) { + newValue = null; + } + if (newValue != oldValue + && (newValue == null || !newValue.equals(oldValue))) { + boolean wasModified = isModified(); + setValue(newValue, true); + + // If the modified status changes, or if we have a formatter, + // repaint is needed after all. + if (format != null || wasModified != isModified()) { + requestRepaint(); + } + } + } + + if (variables.containsKey(FocusEvent.EVENT_ID)) { + fireEvent(new FocusEvent(this)); + } + if (variables.containsKey(BlurEvent.EVENT_ID)) { + fireEvent(new BlurEvent(this)); + } + + } + + /** + * Sets the height of the {@link TextField} instance. + * + * <p> + * Setting height for {@link TextField} also has a side-effect that puts + * {@link TextField} into multiline mode (aka "textarea"). Multiline mode + * can also be achieved by calling {@link #setRows(int)}. The height value + * overrides the number of rows set by {@link #setRows(int)}. + * <p> + * If you want to set height of single line {@link TextField}, call + * {@link #setRows(int)} with value 0 after setting the height. Setting rows + * to 0 resets the side-effect. + * + * @see com.vaadin.ui.AbstractComponent#setHeight(float, int) + */ + @Override + public void setHeight(float height, int unit) { + super.setHeight(height, unit); + if (height > 1 && this instanceof TextField) { + /* + * In html based terminals we most commonly want to make component + * to be textarea if height is defined. Setting row field above 0 + * will render component as textarea. + */ + + ((TextField) this).setRows(2); + } + } + + /** + * Sets the height of the {@link TextField} instance. + * + * <p> + * Setting height for {@link TextField} also has a side-effect that puts + * {@link TextField} into multiline mode (aka "textarea"). Multiline mode + * can also be achieved by calling {@link #setRows(int)}. The height value + * overrides the number of rows set by {@link #setRows(int)}. + * <p> + * If you want to set height of single line {@link TextField}, call + * {@link #setRows(int)} with value 0 after setting the height. Setting rows + * to 0 resets the side-effect. + * + * @see com.vaadin.ui.AbstractComponent#setHeight(java.lang.String) + */ + @Override + public void setHeight(String height) { + // will call setHeight(float, int) the actually does the magic. Method + // is overridden just to document side-effects. + super.setHeight(height); + } + + @Override + public Class getType() { + return String.class; + } + + /** + * Gets the null-string representation. + * + * <p> + * The null-valued strings are represented on the user interface by + * replacing the null value with this string. If the null representation is + * set null (not 'null' string), painting null value throws exception. + * </p> + * + * <p> + * The default value is string 'null'. + * </p> + * + * @return the String Textual representation for null strings. + * @see TextField#isNullSettingAllowed() + */ + public String getNullRepresentation() { + return nullRepresentation; + } + + /** + * Is setting nulls with null-string representation allowed. + * + * <p> + * If this property is true, writing null-representation string to text + * field always sets the field value to real null. If this property is + * false, null setting is not made, but the null values are maintained. + * Maintenance of null-values is made by only converting the textfield + * contents to real null, if the text field matches the null-string + * representation and the current value of the field is null. + * </p> + * + * <p> + * By default this setting is false + * </p> + * + * @return boolean Should the null-string represenation be always converted + * to null-values. + * @see TextField#getNullRepresentation() + */ + public boolean isNullSettingAllowed() { + return nullSettingAllowed; + } + + /** + * Sets the null-string representation. + * + * <p> + * The null-valued strings are represented on the user interface by + * replacing the null value with this string. If the null representation is + * set null (not 'null' string), painting null value throws exception. + * </p> + * + * <p> + * The default value is string 'null' + * </p> + * + * @param nullRepresentation + * Textual representation for null strings. + * @see TextField#setNullSettingAllowed(boolean) + */ + public void setNullRepresentation(String nullRepresentation) { + this.nullRepresentation = nullRepresentation; + } + + /** + * Sets the null conversion mode. + * + * <p> + * If this property is true, writing null-representation string to text + * field always sets the field value to real null. If this property is + * false, null setting is not made, but the null values are maintained. + * Maintenance of null-values is made by only converting the textfield + * contents to real null, if the text field matches the null-string + * representation and the current value of the field is null. + * </p> + * + * <p> + * By default this setting is false. + * </p> + * + * @param nullSettingAllowed + * Should the null-string represenation be always converted to + * null-values. + * @see TextField#getNullRepresentation() + */ + public void setNullSettingAllowed(boolean nullSettingAllowed) { + 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() || toString().length() == 0; + } + + /** + * Returns the maximum number of characters in the field. Value -1 is + * considered unlimited. Terminal may however have some technical limits. + * + * @return the maxLength + */ + public int getMaxLength() { + return maxLength; + } + + /** + * Sets the maximum number of characters in the field. Value -1 is + * considered unlimited. Terminal may however have some technical limits. + * + * @param maxLength + * the maxLength to set + */ + public void setMaxLength(int maxLength) { + this.maxLength = maxLength; + requestRepaint(); + } + + public void addListener(FocusListener listener) { + addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, + FocusListener.focusMethod); + } + + public void removeListener(FocusListener listener) { + removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + } + + public void addListener(BlurListener listener) { + addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, + BlurListener.blurMethod); + } + + public void removeListener(BlurListener listener) { + removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); + } + +}
\ No newline at end of file diff --git a/src/com/vaadin/ui/AlignmentUtils.java b/src/com/vaadin/ui/AlignmentUtils.java index e4641ce5a2..72c7b9e2de 100644 --- a/src/com/vaadin/ui/AlignmentUtils.java +++ b/src/com/vaadin/ui/AlignmentUtils.java @@ -26,18 +26,21 @@ import com.vaadin.ui.Layout.AlignmentHandler; * * r,right for right alignment * + * @deprecated {@code AlignmentUtils} has been replaced by {@link Alignment}. */ -@SuppressWarnings("serial") +@SuppressWarnings({ "serial" }) +@Deprecated public class AlignmentUtils implements Serializable { private static int horizontalMask = AlignmentHandler.ALIGNMENT_LEFT | AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER | AlignmentHandler.ALIGNMENT_RIGHT; + private static int verticalMask = AlignmentHandler.ALIGNMENT_TOP | AlignmentHandler.ALIGNMENT_VERTICAL_CENTER | AlignmentHandler.ALIGNMENT_BOTTOM; - private static Map<String, Integer> alignmentStrings = new HashMap(); + private static Map<String, Integer> alignmentStrings = new HashMap<String, Integer>(); private static void addMapping(int alignment, String... values) { for (String s : values) { diff --git a/src/com/vaadin/ui/BaseFieldFactory.java b/src/com/vaadin/ui/BaseFieldFactory.java index 50478f4310..73602700f5 100644 --- a/src/com/vaadin/ui/BaseFieldFactory.java +++ b/src/com/vaadin/ui/BaseFieldFactory.java @@ -40,7 +40,7 @@ public class BaseFieldFactory implements FieldFactory { * * @see com.vaadin.ui.FieldFactory#createField(Class, Component) */ - public Field createField(Class type, Component uiContext) { + public Field createField(Class<?> type, Component uiContext) { return DefaultFieldFactory.createFieldByPropertyType(type); } diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 35843365f2..af85513692 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -49,7 +49,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, */ public Button() { setValue(Boolean.FALSE); - setSwitchMode(false); } /** @@ -105,7 +104,9 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, * @param state * the Initial state of the switch-button. * @param initialState + * @deprecated use {@link CheckBox} instead of Button in "switchmode" */ + @Deprecated public Button(String caption, boolean initialState) { setCaption(caption); setValue(Boolean.valueOf(initialState)); @@ -118,7 +119,9 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, * @param state * the Initial state of the switch-button. * @param dataSource + * @deprecated use {@link CheckBox} instead of Button in "switchmode" */ + @Deprecated public Button(String caption, Property dataSource) { setCaption(caption); setSwitchMode(true); @@ -211,6 +214,8 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, * * @param switchMode * The switchMode to set. + * @deprecated the {@link CheckBox} component should be used instead of + * Button in switch mode */ public void setSwitchMode(boolean switchMode) { this.switchMode = switchMode; diff --git a/src/com/vaadin/ui/CheckBox.java b/src/com/vaadin/ui/CheckBox.java index 0ffafe3d02..e8b46c1d83 100644 --- a/src/com/vaadin/ui/CheckBox.java +++ b/src/com/vaadin/ui/CheckBox.java @@ -91,6 +91,7 @@ public class CheckBox extends Button { super(caption, false); } + @Deprecated @Override public void setSwitchMode(boolean switchMode) throws UnsupportedOperationException { diff --git a/src/com/vaadin/ui/ComboBox.java b/src/com/vaadin/ui/ComboBox.java index a9cdf21bd1..688f750e2b 100644 --- a/src/com/vaadin/ui/ComboBox.java +++ b/src/com/vaadin/ui/ComboBox.java @@ -30,7 +30,7 @@ public class ComboBox extends Select { setNewItemsAllowed(false);
}
- public ComboBox(String caption, Collection options) {
+ public ComboBox(String caption, Collection<?> options) {
super(caption, options);
setMultiSelect(false);
setNewItemsAllowed(false);
diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java index 462ed569c9..db5bae678b 100644 --- a/src/com/vaadin/ui/CssLayout.java +++ b/src/com/vaadin/ui/CssLayout.java @@ -148,6 +148,16 @@ public class CssLayout extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Paints the content of this component. * * @param target @@ -205,8 +215,8 @@ public class CssLayout extends AbstractLayout { int oldLocation = -1; int newLocation = -1; int location = 0; - for (final Iterator i = components.iterator(); i.hasNext();) { - final Component component = (Component) i.next(); + for (final Iterator<Component> i = components.iterator(); i.hasNext();) { + final Component component = i.next(); if (component == oldComponent) { oldLocation = location; @@ -240,8 +250,9 @@ public class CssLayout extends AbstractLayout { } } + @SuppressWarnings("unchecked") @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey(CLICK_EVENT)) { diff --git a/src/com/vaadin/ui/CustomComponent.java b/src/com/vaadin/ui/CustomComponent.java index e06fb321e3..a598b5b3bb 100644 --- a/src/com/vaadin/ui/CustomComponent.java +++ b/src/com/vaadin/ui/CustomComponent.java @@ -175,6 +175,16 @@ public class CustomComponent extends AbstractComponentContainer { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components (zero or one) + */ + public int getComponentCount() { + return (root != null ? 1 : 0); + } + + /** * This method is not supported by CustomComponent. * * @see com.vaadin.ui.ComponentContainer#replaceComponent(com.vaadin.ui.Component, diff --git a/src/com/vaadin/ui/CustomLayout.java b/src/com/vaadin/ui/CustomLayout.java index 1d08860b50..0c11ff6114 100644 --- a/src/com/vaadin/ui/CustomLayout.java +++ b/src/com/vaadin/ui/CustomLayout.java @@ -185,6 +185,16 @@ public class CustomLayout extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return slots.values().size(); + } + + /** * Gets the child-component by its location. * * @param location diff --git a/src/com/vaadin/ui/DateField.java b/src/com/vaadin/ui/DateField.java index 2e61699ac7..0300315dd7 100644 --- a/src/com/vaadin/ui/DateField.java +++ b/src/com/vaadin/ui/DateField.java @@ -85,21 +85,6 @@ public class DateField extends AbstractField implements public static final int RESOLUTION_YEAR = 6; /** - * Popup date selector (calendar). - */ - protected static final String TYPE_POPUP = "popup"; - - /** - * Inline date selector (calendar). - */ - protected static final String TYPE_INLINE = "inline"; - - /** - * Specified widget type. - */ - protected String type = TYPE_POPUP; - - /** * Specified smallest modifiable unit. */ private int resolution = RESOLUTION_MSEC; @@ -227,7 +212,6 @@ public class DateField extends AbstractField implements target.addAttribute("strict", true); } - target.addAttribute("type", type); target.addAttribute(VDateField.WEEK_NUMBERS, isShowISOWeekNumbers()); target.addAttribute("parsable", parsingSucceeded); @@ -287,7 +271,7 @@ public class DateField extends AbstractField implements * interface. */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); setComponentError(null); diff --git a/src/com/vaadin/ui/DragAndDropWrapper.java b/src/com/vaadin/ui/DragAndDropWrapper.java index 87ff571f36..aebdde975a 100644 --- a/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/src/com/vaadin/ui/DragAndDropWrapper.java @@ -3,12 +3,11 @@ */ package com.vaadin.ui; -import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; -import java.io.Serializable; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import com.vaadin.event.Transferable; import com.vaadin.event.TransferableImpl; @@ -19,15 +18,11 @@ import com.vaadin.event.dd.TargetDetails; import com.vaadin.event.dd.TargetDetailsImpl; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.UploadStream; +import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper; import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation; import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; -import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; -import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File; -import com.vaadin.ui.Upload.Receiver; -import com.vaadin.ui.Upload.UploadException; @SuppressWarnings("serial") @ClientWidget(VDragAndDropWrapper.class) @@ -45,13 +40,14 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, if (fc != null) { files = new Html5File[fc]; for (int i = 0; i < fc; i++) { - Html5File file = new Html5File(); + Html5File file = new Html5File( + (String) rawVariables.get("fn" + i), // name + (Integer) rawVariables.get("fs" + i), // size + (String) rawVariables.get("ft" + i)); // mime String id = (String) rawVariables.get("fi" + i); - file.name = (String) rawVariables.get("fn" + i); - file.size = (Integer) rawVariables.get("fs" + i); - file.type = (String) rawVariables.get("ft" + i); files[i] = file; receivers.put(id, file); + requestRepaint(); // paint Receivers } } } @@ -96,50 +92,6 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, return data; } - /** - * {@link DragAndDropWrapper} can receive also files from client - * computer if appropriate HTML 5 features are supported on client side. - * This class wraps information about dragged file on server side. - */ - public class Html5File implements Serializable { - - public String name; - private int size; - private Receiver receiver; - private String type; - - public String getFileName() { - return name; - } - - public int getFileSize() { - return size; - } - - public String getType() { - return type; - } - - /** - * Sets the {@link Receiver} that into which the file contents will - * be written. Usage of Reveiver is similar to {@link Upload} - * component. - * - * <p> - * <em>Note!</em> receiving file contents is experimental feature - * depending on HTML 5 API's. It is supported only by Firefox 3.6 at - * this time. - * - * @param receiver - * the callback that returns stream where the - * implementation writes the file contents as it arrives. - */ - public void setReceiver(Receiver receiver) { - this.receiver = receiver; - } - - } - } private Map<String, Html5File> receivers = new HashMap<String, Html5File>(); @@ -220,6 +172,25 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, if (getDropHandler() != null) { getDropHandler().getAcceptCriterion().paint(target); } + if (receivers != null && receivers.size() > 0) { + for (Iterator<Entry<String, Html5File>> it = receivers.entrySet() + .iterator(); it.hasNext();) { + Entry<String, com.vaadin.ui.Html5File> entry = it.next(); + String id = entry.getKey(); + Html5File html5File = entry.getValue(); + if (html5File.getStreamVariable() != null) { + target.addVariable(this, "rec-" + id, new ProxyReceiver( + html5File)); + // these are cleaned from receivers once the upload has + // started + } else { + // instructs the client side not to send the file + target.addVariable(this, "rec-" + id, (String) null); + // forget the file from subsequent paints + it.remove(); + } + } + } } private DropHandler dropHandler; @@ -251,38 +222,114 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, return dragStartMode; } - /** - * This method should only be used by Vaadin terminal implementation. This - * is not end user api. - * - * TODO should fire progress events + end/succes events like upload. Not - * critical until we have a wider browser support for HTML5 File API - * - * @param upstream - * @param fileId - * @throws UploadException - */ - public void receiveFile(UploadStream upstream, String fileId) - throws UploadException { - Html5File file = receivers.get(fileId); - if (file != null && file.receiver != null) { - OutputStream receiveUpload = file.receiver.receiveUpload( - file.getFileName(), "TODO"); - - InputStream stream = upstream.getStream(); - byte[] buf = new byte[AbstractApplicationServlet.MAX_BUFFER_SIZE]; - int bytesRead; - try { - while ((bytesRead = stream.read(buf)) != -1) { - receiveUpload.write(buf, 0, bytesRead); + final class ProxyReceiver implements StreamVariable { + + private Html5File file; + + public ProxyReceiver(Html5File file) { + this.file = file; + } + + private boolean listenProgressOfUploadedFile; + + public OutputStream getOutputStream() { + if (file.getStreamVariable() == null) { + return null; + } + return file.getStreamVariable().getOutputStream(); + } + + public boolean listenProgress() { + return file.getStreamVariable().listenProgress(); + } + + public void onProgress(StreamingProgressEvent event) { + file.getStreamVariable().onProgress( + new ReceivingEventWrapper(event)); + } + + public void streamingStarted(StreamingStartEvent event) { + listenProgressOfUploadedFile = file.getStreamVariable() != null; + if (listenProgressOfUploadedFile) { + file.getStreamVariable().streamingStarted( + new ReceivingEventWrapper(event)); + } + // no need tell to the client about this receiver on next paint + receivers.remove(file); + // let the terminal GC the streamvariable and not to accept other + // file uploads to this variable + event.disposeStreamVariable(); + } + + public void streamingFinished(StreamingEndEvent event) { + if (listenProgressOfUploadedFile) { + file.getStreamVariable().streamingFinished( + new ReceivingEventWrapper(event)); + } + } + + public void streamingFailed(final StreamingErrorEvent event) { + if (listenProgressOfUploadedFile) { + file.getStreamVariable().streamingFailed( + new ReceivingEventWrapper(event)); + } + } + + public boolean isInterrupted() { + return file.getStreamVariable().isInterrupted(); + } + + /* + * With XHR2 file posts we can't provide as much information from the + * terminal as with multipart request. This helper class wraps the + * terminal event and provides the lacking information from the + * Html5File. + */ + class ReceivingEventWrapper implements StreamingErrorEvent, + StreamingEndEvent, StreamingStartEvent, StreamingProgressEvent { + + private StreamingEvent wrappedEvent; + + ReceivingEventWrapper(StreamingEvent e) { + wrappedEvent = e; + } + + public String getMimeType() { + return file.getType(); + } + + public String getFileName() { + return file.getFileName(); + } + + public long getContentLength() { + return file.getFileSize(); + } + + public StreamVariable getReceiver() { + return ProxyReceiver.this; + } + + public Exception getException() { + if (wrappedEvent instanceof StreamingErrorEvent) { + return ((StreamingErrorEvent) wrappedEvent).getException(); } - receiveUpload.close(); - } catch (IOException e) { - throw new UploadException(e); + return null; + } + + public long getBytesReceived() { + return wrappedEvent.getBytesReceived(); + } + + /** + * Calling this method has no effect. DD files are receive only once + * anyway. + */ + public void disposeStreamVariable() { + } - // clean up the reference when file is downloaded - receivers.remove(fileId); } } + } diff --git a/src/com/vaadin/ui/Embedded.java b/src/com/vaadin/ui/Embedded.java index f906e696df..2945c84afa 100644 --- a/src/com/vaadin/ui/Embedded.java +++ b/src/com/vaadin/ui/Embedded.java @@ -447,6 +447,7 @@ public class Embedded extends AbstractComponent { removeListener(CLICK_EVENT, ClickEvent.class, listener); } + @SuppressWarnings("unchecked") @Override public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); diff --git a/src/com/vaadin/ui/FieldFactory.java b/src/com/vaadin/ui/FieldFactory.java index 0bdd30612f..e8351e52dd 100644 --- a/src/com/vaadin/ui/FieldFactory.java +++ b/src/com/vaadin/ui/FieldFactory.java @@ -30,7 +30,7 @@ public interface FieldFactory extends FormFieldFactory, TableFieldFactory { * @return Field the field suitable for editing the specified data. * */ - Field createField(Class type, Component uiContext); + Field createField(Class<?> type, Component uiContext); /** * Creates a field based on the property datasource. diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java index c79b62e539..82bf9e948f 100644 --- a/src/com/vaadin/ui/Form.java +++ b/src/com/vaadin/ui/Form.java @@ -114,7 +114,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, /** * Visible item properties. */ - private Collection<Object> visibleItemProperties; + private Collection<?> visibleItemProperties; /** * Form needs to repaint itself if child fields value changes due possible @@ -622,7 +622,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } /* Documented in interface */ - public Collection getItemPropertyIds() { + public Collection<?> getItemPropertyIds() { return Collections.unmodifiableCollection(propertyIds); } @@ -639,7 +639,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, if (field != null) { propertyIds.remove(id); fields.remove(id); - layout.removeComponent(field); + detachField(field); field.removeListener(fieldValueChangeListener); return true; } @@ -648,6 +648,24 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } /** + * Called when a form field is detached from a Form. Typically when a new + * Item is assigned to Form via {@link #setItemDataSource(Item)}. + * <p> + * Override this method to control how the fields are removed from the + * layout. + * </p> + * + * @param field + * the field to be detached from the forms layout. + */ + protected void detachField(final Field field) { + Component p = field.getParent(); + if (p instanceof ComponentContainer) { + ((ComponentContainer) p).removeComponent(field); + } + } + + /** * Removes all properties and fields from the form. * * @return the Success of the operation. Removal of all fields succeeded if @@ -699,7 +717,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item) */ - public void setItemDataSource(Item newDataSource, Collection propertyIds) { + public void setItemDataSource(Item newDataSource, Collection<?> propertyIds) { if (layout instanceof GridLayout) { GridLayout gl = (GridLayout) layout; @@ -726,7 +744,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } // Adds all the properties to this form - for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) { final Object id = i.next(); final Property property = itemDatasource.getItemProperty(id); if (id != null && property != null) { @@ -781,7 +799,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, final Object[] properties = propertyIds.toArray(); for (int i = 0; i < properties.length; i++) { Field f = getField(properties[i]); - layout.removeComponent(f); + detachField(f); if (newLayout instanceof CustomLayout) { ((CustomLayout) newLayout).addComponent(f, properties[i].toString()); @@ -847,7 +865,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } if (value != null && !found) { if (value instanceof Collection) { - for (final Iterator it = ((Collection) value).iterator(); it + for (final Iterator<?> it = ((Collection<?>) value).iterator(); it .hasNext();) { final Object val = it.next(); found = false; @@ -1001,7 +1019,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, @Override public void setReadOnly(boolean readOnly) { super.setReadOnly(readOnly); - for (final Iterator i = propertyIds.iterator(); i.hasNext();) { + for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) { (fields.get(i.next())).setReadOnly(readOnly); } } @@ -1052,7 +1070,11 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * Get the field factory of the form. * * @return the FieldFactory Factory used to create the fields. + * @deprecated Use {@link #getFormFieldFactory()} instead. Set the + * FormFieldFactory using + * {@link #setFormFieldFactory(FormFieldFactory)}. */ + @Deprecated public FieldFactory getFieldFactory() { if (fieldFactory instanceof FieldFactory) { return (FieldFactory) fieldFactory; @@ -1067,7 +1089,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @see com.vaadin.ui.AbstractField#getType() */ @Override - public Class getType() { + public Class<?> getType() { if (getPropertyDataSource() != null) { return getPropertyDataSource().getType(); } @@ -1131,14 +1153,14 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @param data * @param properties */ - protected void setFormDataSource(Object data, Collection properties) { + protected void setFormDataSource(Object data, Collection<?> properties) { // If data is an item use it. Item item = null; if (data instanceof Item) { item = (Item) data; } else if (data != null) { - item = new BeanItem(data); + item = new BeanItem<Object>(data); } // Sets the datasource to form @@ -1156,7 +1178,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * * @return the Collection of visible Item properites. */ - public Collection getVisibleItemProperties() { + public Collection<?> getVisibleItemProperties() { return visibleItemProperties; } @@ -1166,7 +1188,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @param visibleProperties * the visibleProperties to set. */ - public void setVisibleItemProperties(Collection visibleProperties) { + public void setVisibleItemProperties(Collection<?> visibleProperties) { visibleItemProperties = visibleProperties; Object value = getValue(); if (value == null) { @@ -1210,7 +1232,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, @Override public void setTabIndex(int tabIndex) { super.setTabIndex(tabIndex); - for (final Iterator i = getItemPropertyIds().iterator(); i.hasNext();) { + for (final Iterator<?> i = getItemPropertyIds().iterator(); i.hasNext();) { (getField(i.next())).setTabIndex(tabIndex); } } diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java index 9b37065712..fc16daa7c7 100644 --- a/src/com/vaadin/ui/GridLayout.java +++ b/src/com/vaadin/ui/GridLayout.java @@ -18,7 +18,6 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VGridLayout; -import com.vaadin.ui.GridLayout.OverlapsException; /** * <p> @@ -73,7 +72,7 @@ public class GridLayout extends AbstractLayout implements * Contains all items that are placed on the grid. These are components with * grid area definition. */ - private final LinkedList areas = new LinkedList(); + private final LinkedList<Area> areas = new LinkedList<Area>(); /** * Mapping from components to their respective areas. @@ -188,11 +187,11 @@ public class GridLayout extends AbstractLayout implements // Inserts the component to right place at the list // Respect top-down, left-right ordering // component.setParent(this); - final Iterator i = areas.iterator(); + final Iterator<Area> i = areas.iterator(); int index = 0; boolean done = false; while (!done && i.hasNext()) { - final Area existingArea = (Area) i.next(); + final Area existingArea = i.next(); if ((existingArea.row1 >= row1 && existingArea.column1 > column1) || existingArea.row1 > row1) { areas.add(index, area); @@ -244,8 +243,8 @@ public class GridLayout extends AbstractLayout implements * if <code>area</code> overlaps with any existing area. */ private void checkExistingOverlaps(Area area) throws OverlapsException { - for (final Iterator i = areas.iterator(); i.hasNext();) { - final Area existingArea = (Area) i.next(); + for (final Iterator<Area> i = areas.iterator(); i.hasNext();) { + final Area existingArea = i.next(); if (existingArea.overlaps(area)) { // Component not added, overlaps with existing component throw new OverlapsException(existingArea); @@ -348,8 +347,9 @@ public class GridLayout extends AbstractLayout implements } Area area = null; - for (final Iterator i = areas.iterator(); area == null && i.hasNext();) { - final Area a = (Area) i.next(); + for (final Iterator<Area> i = areas.iterator(); area == null + && i.hasNext();) { + final Area a = i.next(); if (a.getComponent() == component) { area = a; } @@ -378,8 +378,8 @@ public class GridLayout extends AbstractLayout implements public void removeComponent(int column, int row) { // Finds the area - for (final Iterator i = areas.iterator(); i.hasNext();) { - final Area area = (Area) i.next(); + for (final Iterator<Area> i = areas.iterator(); i.hasNext();) { + final Area area = i.next(); if (area.getColumn1() == column && area.getRow1() == row) { removeComponent(area.getComponent()); return; @@ -398,6 +398,16 @@ public class GridLayout extends AbstractLayout implements } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Paints the contents of this component. * * @param target @@ -422,13 +432,13 @@ public class GridLayout extends AbstractLayout implements } // Area iterator - final Iterator areaiterator = areas.iterator(); + final Iterator<Area> areaiterator = areas.iterator(); // Current item to be processed (fetch first item) Area area = areaiterator.hasNext() ? (Area) areaiterator.next() : null; // Collects rowspan related information here - final HashMap cellUsed = new HashMap(); + final HashMap<Integer, Integer> cellUsed = new HashMap<Integer, Integer>(); // Empty cell collector int emptyCells = 0; @@ -527,7 +537,7 @@ public class GridLayout extends AbstractLayout implements // Fetch next item if (areaiterator.hasNext()) { - area = (Area) areaiterator.next(); + area = areaiterator.next(); } else { area = null; } @@ -554,8 +564,8 @@ public class GridLayout extends AbstractLayout implements // Current column contains already an item, // check if rowspan affects at current x,y position - final int rowspanDepth = ((Integer) cellUsed - .get(new Integer(curx))).intValue(); + final int rowspanDepth = cellUsed + .get(new Integer(curx)).intValue(); if (rowspanDepth >= cury) { @@ -950,8 +960,8 @@ public class GridLayout extends AbstractLayout implements // Checks for overlaps if (cols > columns) { - for (final Iterator i = areas.iterator(); i.hasNext();) { - final Area area = (Area) i.next(); + for (final Iterator<Area> i = areas.iterator(); i.hasNext();) { + final Area area = i.next(); if (area.column2 >= columns) { throw new OutOfBoundsException(area); } @@ -994,8 +1004,8 @@ public class GridLayout extends AbstractLayout implements // Checks for overlaps if (this.rows > rows) { - for (final Iterator i = areas.iterator(); i.hasNext();) { - final Area area = (Area) i.next(); + for (final Iterator<Area> i = areas.iterator(); i.hasNext();) { + final Area area = i.next(); if (area.row2 >= rows) { throw new OutOfBoundsException(area); } @@ -1066,8 +1076,8 @@ public class GridLayout extends AbstractLayout implements // Gets the locations Area oldLocation = null; Area newLocation = null; - for (final Iterator i = areas.iterator(); i.hasNext();) { - final Area location = (Area) i.next(); + for (final Iterator<Area> i = areas.iterator(); i.hasNext();) { + final Area location = i.next(); final Component component = location.getComponent(); if (component == oldComponent) { oldLocation = location; @@ -1099,7 +1109,7 @@ public class GridLayout extends AbstractLayout implements @Override public void removeAllComponents() { super.removeAllComponents(); - componentToAlignment = new HashMap(); + componentToAlignment = new HashMap<Component, Alignment>(); cursorX = 0; cursorY = 0; } @@ -1164,8 +1174,8 @@ public class GridLayout extends AbstractLayout implements + " in a gridlayout with height " + rows); } - for (Iterator i = areas.iterator(); i.hasNext();) { - Area existingArea = (Area) i.next(); + for (Iterator<Area> i = areas.iterator(); i.hasNext();) { + Area existingArea = i.next(); // Areas ending below the row needs to be moved down or stretched if (existingArea.row2 >= row) { existingArea.row2++; @@ -1212,8 +1222,8 @@ public class GridLayout extends AbstractLayout implements } // Shrink or remove areas in the selected row - for (Iterator i = areas.iterator(); i.hasNext();) { - Area existingArea = (Area) i.next(); + for (Iterator<Area> i = areas.iterator(); i.hasNext();) { + Area existingArea = i.next(); if (existingArea.row2 >= row) { existingArea.row2--; @@ -1321,8 +1331,9 @@ public class GridLayout extends AbstractLayout implements * @return Component in given cell or null if empty */ public Component getComponent(int x, int y) { - for (final Iterator iterator = areas.iterator(); iterator.hasNext();) { - final Area area = (Area) iterator.next(); + for (final Iterator<Area> iterator = areas.iterator(); iterator + .hasNext();) { + final Area area = iterator.next(); if (area.getColumn1() <= x && x <= area.getColumn2() && area.getRow1() <= y && y <= area.getRow2()) { return area.getComponent(); @@ -1341,8 +1352,9 @@ public class GridLayout extends AbstractLayout implements * in the grid */ public Area getComponentArea(Component component) { - for (final Iterator iterator = areas.iterator(); iterator.hasNext();) { - final Area area = (Area) iterator.next(); + for (final Iterator<Area> iterator = areas.iterator(); iterator + .hasNext();) { + final Area area = iterator.next(); if (area.getComponent() == component) { return area; } @@ -1350,12 +1362,25 @@ public class GridLayout extends AbstractLayout implements return null; } + /** + * Sets the component alignment using a short hand string notation. + * + * @deprecated Replaced by + * {@link #setComponentAlignment(Component, Alignment)} + * + * @param component + * A child component in this layout + * @param alignment + * A short hand notation described in {@link AlignmentUtils} + */ + @Deprecated public void setComponentAlignment(Component component, String alignment) { AlignmentUtils.setComponentAlignment(this, component, alignment); } + @SuppressWarnings("unchecked") @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey(CLICK_EVENT)) { diff --git a/src/com/vaadin/ui/HorizontalSplitPanel.java b/src/com/vaadin/ui/HorizontalSplitPanel.java new file mode 100644 index 0000000000..2cb7d2ec51 --- /dev/null +++ b/src/com/vaadin/ui/HorizontalSplitPanel.java @@ -0,0 +1,29 @@ +package com.vaadin.ui; + +import com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal; + +/** + * A horizontal split panel contains two components and lays them horizontally. + * The first component is on the left side. + * + * <pre> + * + * +---------------------++----------------------+ + * | || | + * | The first component || The second component | + * | || | + * +---------------------++----------------------+ + * + * ^ + * | + * the splitter + * + * </pre> + */ +@ClientWidget(VSplitPanelHorizontal.class) +public class HorizontalSplitPanel extends SplitPanel { + @SuppressWarnings("deprecation") + public HorizontalSplitPanel() { + super(ORIENTATION_HORIZONTAL); + } +} diff --git a/src/com/vaadin/ui/Html5File.java b/src/com/vaadin/ui/Html5File.java new file mode 100644 index 0000000000..1eb048783c --- /dev/null +++ b/src/com/vaadin/ui/Html5File.java @@ -0,0 +1,63 @@ +package com.vaadin.ui; + +import java.io.Serializable; + +import com.vaadin.event.dd.DropHandler; +import com.vaadin.terminal.StreamVariable; + +/** + * {@link DragAndDropWrapper} can receive also files from client computer if + * appropriate HTML 5 features are supported on client side. This class wraps + * information about dragged file on server side. + */ +public class Html5File implements Serializable { + + private String name; + private long size; + private StreamVariable streamVariable; + private String type; + + Html5File(String name, long size, String mimeType) { + this.name = name; + this.size = size; + type = mimeType; + } + + public String getFileName() { + return name; + } + + public long getFileSize() { + return size; + } + + public String getType() { + return type; + } + + /** + * Sets the {@link StreamVariable} that into which the file contents will be + * written. Usage of StreamVariable is similar to {@link Upload} component. + * <p> + * If the {@link StreamVariable} is not set in the {@link DropHandler} the file + * contents will not be sent to server. + * <p> + * <em>Note!</em> receiving file contents is experimental feature depending + * on HTML 5 API's. It is supported only by modern web browsers like Firefox + * 3.6 and above and recent webkit based browsers (Safari 5, Chrome 6) at + * this time. + * + * @param streamVariable + * the callback that returns stream where the implementation + * writes the file contents as it arrives. + */ + public void setStreamVariable(StreamVariable streamVariable) { + this.streamVariable = streamVariable; + } + + public StreamVariable getStreamVariable() { + return streamVariable; + } + + +}
\ No newline at end of file diff --git a/src/com/vaadin/ui/InlineDateField.java b/src/com/vaadin/ui/InlineDateField.java index 88f0c3e0b4..d1066dc28a 100644 --- a/src/com/vaadin/ui/InlineDateField.java +++ b/src/com/vaadin/ui/InlineDateField.java @@ -7,6 +7,7 @@ package com.vaadin.ui; import java.util.Date;
import com.vaadin.data.Property;
+import com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar;
/**
* <p>
@@ -21,32 +22,27 @@ import com.vaadin.data.Property; * @VERSION@
* @since 5.0
*/
-@SuppressWarnings("serial")
+@ClientWidget(VDateFieldCalendar.class)
public class InlineDateField extends DateField {
public InlineDateField() {
super();
- type = TYPE_INLINE;
}
public InlineDateField(Property dataSource) throws IllegalArgumentException {
super(dataSource);
- type = TYPE_INLINE;
}
public InlineDateField(String caption, Date value) {
super(caption, value);
- type = TYPE_INLINE;
}
public InlineDateField(String caption, Property dataSource) {
super(caption, dataSource);
- type = TYPE_INLINE;
}
public InlineDateField(String caption) {
super(caption);
- type = TYPE_INLINE;
}
}
diff --git a/src/com/vaadin/ui/Label.java b/src/com/vaadin/ui/Label.java index 6a295f7bc1..d1952dc2b3 100644 --- a/src/com/vaadin/ui/Label.java +++ b/src/com/vaadin/ui/Label.java @@ -42,7 +42,7 @@ import com.vaadin.ui.ClientWidget.LoadStyle; @ClientWidget(value = VLabel.class, loadStyle = LoadStyle.EAGER) public class Label extends AbstractComponent implements Property, Property.Viewer, Property.ValueChangeListener, - Property.ValueChangeNotifier, Comparable { + Property.ValueChangeNotifier, Comparable<Object> { /** * Content mode, where the label contains only plain text. The getValue() @@ -134,7 +134,7 @@ public class Label extends AbstractComponent implements Property, * @param contentMode */ public Label(String content, int contentMode) { - this(new ObjectProperty(content, String.class), contentMode); + this(new ObjectProperty<String>(content, String.class), contentMode); } /** diff --git a/src/com/vaadin/ui/ListSelect.java b/src/com/vaadin/ui/ListSelect.java index b2c4866b4a..9aabc7514a 100644 --- a/src/com/vaadin/ui/ListSelect.java +++ b/src/com/vaadin/ui/ListSelect.java @@ -26,7 +26,7 @@ public class ListSelect extends AbstractSelect { super(); } - public ListSelect(String caption, Collection options) { + public ListSelect(String caption, Collection<?> options) { super(caption, options); } diff --git a/src/com/vaadin/ui/LoginForm.java b/src/com/vaadin/ui/LoginForm.java index a77fde1368..6c1edb8171 100644 --- a/src/com/vaadin/ui/LoginForm.java +++ b/src/com/vaadin/ui/LoginForm.java @@ -40,6 +40,10 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; */ public class LoginForm extends CustomComponent { + private String usernameCaption = "Username"; + private String passwordCaption = "Password"; + private String loginButtonCaption = "Login"; + private Embedded iframe = new Embedded(); private ApplicationResource loginPage = new ApplicationResource() { @@ -129,7 +133,6 @@ public class LoginForm extends CustomComponent { * @return byte array containing login page html */ protected byte[] getLoginHTML() { - String appUri = getApplication().getURL().toString() + getWindow().getName() + "/"; @@ -164,11 +167,16 @@ public class LoginForm extends CustomComponent { + "<iframe name='logintarget' style='width:0;height:0;" + "border:0;margin:0;padding:0;'></iframe>" + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">" - + "<div>Username</div><div >" + + "<div>" + + usernameCaption + + "</div><div >" + "<input class='v-textfield' style='display:block;' type='text' name='username'></div>" - + "<div>Password</div>" + + "<div>" + + passwordCaption + + "</div>" + "<div><input class='v-textfield' style='display:block;' type='password' name='password'></div>" - + "<div><div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\" ><span class=\"v-button-wrap\"><span class=\"v-button-caption\">Login</span></span></div></div></form></div>" + "</body></html>") + + "<div><div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\" ><span class=\"v-button-wrap\"><span class=\"v-button-caption\">" + + loginButtonCaption + "</span></span></div></div></form></div>" + "</body></html>") .getBytes(); } @@ -292,4 +300,61 @@ public class LoginForm extends CustomComponent { } } + /** + * Returns the caption for the user name field. + * + * @return String + */ + public String getUsernameCaption() { + return usernameCaption; + } + + /** + * Sets the caption to show for the user name field. The caption cannot be + * changed after the form has been shown to the user. + * + * @param usernameCaption + */ + public void setUsernameCaption(String usernameCaption) { + this.usernameCaption = usernameCaption; + } + + /** + * Returns the caption for the password field. + * + * @return String + */ + public String getPasswordCaption() { + return passwordCaption; + } + + /** + * Sets the caption to show for the password field. The caption cannot be + * changed after the form has been shown to the user. + * + * @param passwordCaption + */ + public void setPasswordCaption(String passwordCaption) { + this.passwordCaption = passwordCaption; + } + + /** + * Returns the caption for the login button. + * + * @return String + */ + public String getLoginButtonCaption() { + return loginButtonCaption; + } + + /** + * Sets the caption (button text) to show for the login button. The caption + * cannot be changed after the form has been shown to the user. + * + * @param loginButtonCaption + */ + public void setLoginButtonCaption(String loginButtonCaption) { + this.loginButtonCaption = loginButtonCaption; + } + } diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java index 3a1ee020b2..b7da82675e 100644 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@ -115,6 +115,11 @@ public class MenuBar extends AbstractComponent { target.addAttribute("disabled", true); } + String description = item.getDescription(); + if (description != null && description.length() > 0) { + target.addAttribute("description", description); + } + if (item.hasChildren()) { for (MenuItem child : item.getChildren()) { paintItem(target, child); @@ -390,6 +395,7 @@ public class MenuBar extends AbstractComponent { private boolean visible = true; private boolean isSeparator = false; private String styleName; + private String description; /** * Constructs a new menu item that can optionally have an icon and a @@ -699,6 +705,80 @@ public class MenuBar extends AbstractComponent { return styleName; } + /** + * Sets the items's description. See {@link #getDescription()} for more + * information on what the description is. This method will trigger a + * {@link com.vaadin.terminal.Paintable.RepaintRequestEvent + * RepaintRequestEvent}. + * + * @param description + * the new description string for the component. + */ + public void setDescription(String description) { + this.description = description; + requestRepaint(); + } + + /** + * <p> + * Gets the items's description. The description can be used to briefly + * describe the state of the item to the user. The description string + * may contain certain XML tags: + * </p> + * + * <p> + * <table border=1> + * <tr> + * <td width=120><b>Tag</b></td> + * <td width=120><b>Description</b></td> + * <td width=120><b>Example</b></td> + * </tr> + * <tr> + * <td><b></td> + * <td>bold</td> + * <td><b>bold text</b></td> + * </tr> + * <tr> + * <td><i></td> + * <td>italic</td> + * <td><i>italic text</i></td> + * </tr> + * <tr> + * <td><u></td> + * <td>underlined</td> + * <td><u>underlined text</u></td> + * </tr> + * <tr> + * <td><br></td> + * <td>linebreak</td> + * <td>N/A</td> + * </tr> + * <tr> + * <td><ul><br> + * <li>item1<br> + * <li>item1<br> + * </ul></td> + * <td>item list</td> + * <td> + * <ul> + * <li>item1 + * <li>item2 + * </ul> + * </td> + * </tr> + * </table> + * </p> + * + * <p> + * These tags may be nested. + * </p> + * + * @return item's description <code>String</code> + */ + public String getDescription() { + return description; + } + }// class MenuItem }// class MenuBar diff --git a/src/com/vaadin/ui/NativeButton.java b/src/com/vaadin/ui/NativeButton.java index f84f270b26..6d128b4bb4 100644 --- a/src/com/vaadin/ui/NativeButton.java +++ b/src/com/vaadin/ui/NativeButton.java @@ -32,7 +32,9 @@ public class NativeButton extends Button { * @param state * the Initial state of the switch-button. * @param initialState + * @deprecated use the {@link CheckBox} component instead */ + @Deprecated public NativeButton(String caption, boolean initialState) { super(caption, initialState); } @@ -43,7 +45,9 @@ public class NativeButton extends Button { * @param state * the Initial state of the switch-button. * @param dataSource + * @deprecated use the {@link CheckBox} component instead */ + @Deprecated public NativeButton(String caption, Property dataSource) { super(caption, dataSource); } diff --git a/src/com/vaadin/ui/NativeSelect.java b/src/com/vaadin/ui/NativeSelect.java index e57daeda55..a99373dae8 100644 --- a/src/com/vaadin/ui/NativeSelect.java +++ b/src/com/vaadin/ui/NativeSelect.java @@ -28,7 +28,7 @@ public class NativeSelect extends AbstractSelect { super(); } - public NativeSelect(String caption, Collection options) { + public NativeSelect(String caption, Collection<?> options) { super(caption, options); } diff --git a/src/com/vaadin/ui/OptionGroup.java b/src/com/vaadin/ui/OptionGroup.java index 7d6fac1721..c1b52c4a82 100644 --- a/src/com/vaadin/ui/OptionGroup.java +++ b/src/com/vaadin/ui/OptionGroup.java @@ -33,7 +33,7 @@ public class OptionGroup extends AbstractSelect implements super(); } - public OptionGroup(String caption, Collection options) { + public OptionGroup(String caption, Collection<?> options) { super(caption, options); } @@ -101,8 +101,8 @@ public class OptionGroup extends AbstractSelect implements * has selected a disabled item. */ if (isMultiSelect()) { - Set currentValueSet = (Set) getValue(); - Set newValueSet = (Set) newValue; + Set<?> currentValueSet = (Set<?>) getValue(); + Set<?> newValueSet = (Set<?>) newValue; for (Object itemId : currentValueSet) { if (!isItemEnabled(itemId) && !newValueSet.contains(itemId)) { requestRepaint(); diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java index 9a3d24a53d..4d00cddfdd 100644 --- a/src/com/vaadin/ui/Panel.java +++ b/src/com/vaadin/ui/Panel.java @@ -282,8 +282,8 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } /** - * Gets the component container iterator for going trough all the components - * in the container. + * Gets the component container iterator for going through all the + * components in the container. * * @return the Iterator of the components inside the container. * @see com.vaadin.ui.ComponentContainer#getComponentIterator() @@ -298,8 +298,9 @@ public class Panel extends AbstractComponentContainer implements Scrollable, * * @see com.vaadin.terminal.VariableOwner#changeVariables(Object, Map) */ + @SuppressWarnings("unchecked") @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey(CLICK_EVENT)) { diff --git a/src/com/vaadin/ui/PasswordField.java b/src/com/vaadin/ui/PasswordField.java new file mode 100644 index 0000000000..0c9da78cd5 --- /dev/null +++ b/src/com/vaadin/ui/PasswordField.java @@ -0,0 +1,65 @@ +package com.vaadin.ui; + +import com.vaadin.data.Property; +import com.vaadin.terminal.gwt.client.ui.VPasswordField; + +/** + * A field that is used to enter secret text information like passwords. The + * clear text is not displayed in the screen. + */ +@ClientWidget(VPasswordField.class) +@SuppressWarnings("serial") +public class PasswordField extends TextField { + + /** + * Constructs an empty PasswordField. + */ + public PasswordField() { + super(); + } + + /** + * Constructs a PasswordField with given property data source. + * + * @param dataSource + * the property dato source for the field + */ + public PasswordField(Property dataSource) { + super(dataSource); + } + + /** + * Constructs a PasswordField with given caption and property data source. + * + * @param caption + * the caption for the field + * @param dataSource + * the property data source for the field + */ + public PasswordField(String caption, Property dataSource) { + super(caption, dataSource); + } + + /** + * Constructs a PasswordField with given value and caption. + * + * @param caption + * the caption for the field + * @param value + * the value for the field + */ + public PasswordField(String caption, String value) { + super(caption, value); + } + + /** + * Constructs a PasswordField with given caption. + * + * @param caption + * the caption for the field + */ + public PasswordField(String caption) { + super(caption); + } + +} diff --git a/src/com/vaadin/ui/PopupDateField.java b/src/com/vaadin/ui/PopupDateField.java index e975cb23d2..7501c9fe15 100644 --- a/src/com/vaadin/ui/PopupDateField.java +++ b/src/com/vaadin/ui/PopupDateField.java @@ -23,34 +23,28 @@ import com.vaadin.terminal.PaintTarget; * @VERSION@
* @since 5.0
*/
-@SuppressWarnings("serial")
public class PopupDateField extends DateField {
private String inputPrompt = null;
public PopupDateField() {
super();
- type = TYPE_POPUP;
}
public PopupDateField(Property dataSource) throws IllegalArgumentException {
super(dataSource);
- type = TYPE_POPUP;
}
public PopupDateField(String caption, Date value) {
super(caption, value);
- type = TYPE_POPUP;
}
public PopupDateField(String caption, Property dataSource) {
super(caption, dataSource);
- type = TYPE_POPUP;
}
public PopupDateField(String caption) {
super(caption);
- type = TYPE_POPUP;
}
@Override
diff --git a/src/com/vaadin/ui/PopupView.java b/src/com/vaadin/ui/PopupView.java index 7879b04ee4..4e1f387504 100644 --- a/src/com/vaadin/ui/PopupView.java +++ b/src/com/vaadin/ui/PopupView.java @@ -227,6 +227,16 @@ public class PopupView extends AbstractComponentContainer { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components (zero or one) + */ + public int getComponentCount() { + return (visibleComponent != null ? 1 : 0); + } + + /** * Not supported in this implementation. * * @see com.vaadin.ui.AbstractComponentContainer#removeAllComponents() @@ -325,7 +335,7 @@ public class PopupView extends AbstractComponentContainer { * java.util.Map) */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("popupVisibility")) { setPopupVisible(((Boolean) variables.get("popupVisibility")) .booleanValue()); diff --git a/src/com/vaadin/ui/ProgressIndicator.java b/src/com/vaadin/ui/ProgressIndicator.java index b896634cd9..c4fd759eed 100644 --- a/src/com/vaadin/ui/ProgressIndicator.java +++ b/src/com/vaadin/ui/ProgressIndicator.java @@ -50,7 +50,8 @@ public class ProgressIndicator extends AbstractField implements Property, * Creates an a new ProgressIndicator. */ public ProgressIndicator() { - setPropertyDataSource(new ObjectProperty(new Float(0), Float.class)); + setPropertyDataSource(new ObjectProperty<Float>(new Float(0), + Float.class)); } /** @@ -59,7 +60,7 @@ public class ProgressIndicator extends AbstractField implements Property, * @param value */ public ProgressIndicator(Float value) { - setPropertyDataSource(new ObjectProperty(value, Float.class)); + setPropertyDataSource(new ObjectProperty<Float>(value, Float.class)); } /** @@ -162,7 +163,7 @@ public class ProgressIndicator extends AbstractField implements Property, * @see com.vaadin.ui.AbstractField#getType() */ @Override - public Class getType() { + public Class<?> getType() { if (dataSource == null) { throw new IllegalStateException("Datasource must be set"); } diff --git a/src/com/vaadin/ui/RichTextArea.java b/src/com/vaadin/ui/RichTextArea.java index bb7b6e58c1..10e5259bc2 100644 --- a/src/com/vaadin/ui/RichTextArea.java +++ b/src/com/vaadin/ui/RichTextArea.java @@ -17,15 +17,17 @@ import com.vaadin.ui.ClientWidget.LoadStyle; * {@link RichTextArea} may produce unexpected results as formatting is counted * into length of field. */ -@SuppressWarnings("serial") +@SuppressWarnings({ "serial", "unchecked" }) @ClientWidget(value = VRichTextArea.class, loadStyle = LoadStyle.LAZY) -public class RichTextArea extends TextField { +public class RichTextArea extends AbstractTextField { + + private boolean selectAll; /** * Constructs an empty <code>RichTextArea</code> with no caption. */ public RichTextArea() { - super(); + setValue(""); } /** @@ -36,7 +38,8 @@ public class RichTextArea extends TextField { * the caption for the editor. */ public RichTextArea(String caption) { - super(caption); + this(); + setCaption(caption); } /** @@ -47,7 +50,7 @@ public class RichTextArea extends TextField { * the data source for the editor value */ public RichTextArea(Property dataSource) { - super(dataSource); + setPropertyDataSource(dataSource); } /** @@ -60,7 +63,8 @@ public class RichTextArea extends TextField { * the data source for the editor value */ public RichTextArea(String caption, Property dataSource) { - super(caption, dataSource); + this(dataSource); + setCaption(caption); } /** @@ -73,24 +77,19 @@ public class RichTextArea extends TextField { * the initial text content of the editor. */ public RichTextArea(String caption, String value) { - super(caption, value); + setValue(value); + setCaption(caption); } @Override public void paintContent(PaintTarget target) throws PaintException { - target.addAttribute("richtext", true); + if (selectAll) { + target.addAttribute("selectAll", true); + selectAll = false; + } super.paintContent(target); } - /** - * RichTextArea does not support input prompt. - */ - @Override - public void setInputPrompt(String inputPrompt) { - throw new UnsupportedOperationException( - "RichTextArea does not support inputPrompt"); - } - @Override public void setReadOnly(boolean readOnly) { super.setReadOnly(readOnly); @@ -102,4 +101,24 @@ public class RichTextArea extends TextField { } } + /** + * Selects all text in the rich text area. As a side effect, focuses the + * rich text area. + * + * @since 6.5 + */ + public void selectAll() { + /* + * Set selection range functionality is currently being + * planned/developed for GWT RTA. Only selecting all is currently + * supported. Consider moving selectAll and other selection related + * functions to AbstractTextField at that point to share the + * implementation. Some third party components extending + * AbstractTextField might however not want to support them. + */ + selectAll = true; + focus(); + requestRepaint(); + } + } diff --git a/src/com/vaadin/ui/Select.java b/src/com/vaadin/ui/Select.java index bd7ec39bdb..0eefdeacb4 100644 --- a/src/com/vaadin/ui/Select.java +++ b/src/com/vaadin/ui/Select.java @@ -60,7 +60,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, private String filterstring; private String prevfilterstring; - private List filteredOptions; + private List<Object> filteredOptions; /** * Flag to indicate that request repaint is called by filter request only @@ -75,7 +75,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, super(); } - public Select(String caption, Collection options) { + public Select(String caption, Collection<?> options) { super(caption, options); } @@ -141,7 +141,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, // Constructs selected keys array String[] selectedKeys; if (isMultiSelect()) { - selectedKeys = new String[((Set) getValue()).size()]; + selectedKeys = new String[((Set<?>) getValue()).size()]; } else { selectedKeys = new String[(getValue() == null && getNullSelectionItemId() == null ? 0 : 1)]; @@ -164,7 +164,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, filterstring = ""; } - List options = getFilteredOptions(); + List<?> options = getFilteredOptions(); boolean nullFilteredOut = filterstring != null && !"".equals(filterstring) && filteringMode != FILTERINGMODE_OFF; @@ -181,7 +181,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, target.endTag("so"); } - final Iterator i = options.iterator(); + final Iterator<?> i = options.iterator(); // Paints the available selection options from data source while (i.hasNext()) { @@ -259,7 +259,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, * flag to indicate if nullselect option needs to be taken into * consideration */ - private List sanitetizeList(List options, boolean needNullSelectOption) { + private List<?> sanitetizeList(List<?> options, boolean needNullSelectOption) { if (pageLength != 0 && options.size() > pageLength) { // Not all options are visible, find out which ones are on the @@ -303,11 +303,11 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, } } - protected List getFilteredOptions() { + protected List<?> getFilteredOptions() { if (filterstring == null || filterstring.equals("") || filteringMode == FILTERINGMODE_OFF) { prevfilterstring = null; - filteredOptions = new LinkedList(getItemIds()); + filteredOptions = new LinkedList<Object>(getItemIds()); return filteredOptions; } @@ -315,7 +315,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, return filteredOptions; } - Collection items; + Collection<?> items; if (prevfilterstring != null && filterstring.startsWith(prevfilterstring)) { items = filteredOptions; @@ -324,8 +324,8 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, } prevfilterstring = filterstring; - filteredOptions = new LinkedList(); - for (final Iterator it = items.iterator(); it.hasNext();) { + filteredOptions = new LinkedList<Object>(); + for (final Iterator<?> it = items.iterator(); it.hasNext();) { final Object itemId = it.next(); String caption = getItemCaption(itemId); if (caption == null || caption.equals("")) { @@ -358,7 +358,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, * java.util.Map) */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { // Not calling super.changeVariables due the history of select // component hierarchy @@ -372,7 +372,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, // TODO Optimize by adding repaintNotNeeded whan applicaple // Converts the key-array to id-set - final LinkedList s = new LinkedList(); + final LinkedList<Object> s = new LinkedList<Object>(); for (int i = 0; i < ka.length; i++) { final Object id = itemIdMapper.get(ka[i]); if (id != null && containsId(id)) { @@ -382,13 +382,14 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, // Limits the deselection to the set of visible items // (non-visible items can not be deselected) - final Collection visible = getVisibleItemIds(); + final Collection<?> visible = getVisibleItemIds(); if (visible != null) { - Set newsel = (Set) getValue(); + @SuppressWarnings("unchecked") + Set<Object> newsel = (Set<Object>) getValue(); if (newsel == null) { - newsel = new HashSet(); + newsel = new HashSet<Object>(); } else { - newsel = new HashSet(newsel); + newsel = new HashSet<Object>(newsel); } newsel.removeAll(visible); newsel.addAll(s); @@ -400,7 +401,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, // Allows deselection only if the deselected item is visible final Object current = getValue(); - final Collection visible = getVisibleItemIds(); + final Collection<?> visible = getVisibleItemIds(); if (visible != null && visible.contains(current)) { setValue(null, true); } @@ -517,4 +518,25 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, } + /** + * @deprecated use {@link ListSelect}, {@link OptionGroup} or + * {@link TwinColSelect} instead + * @see com.vaadin.ui.AbstractSelect#setMultiSelect(boolean) + */ + @Override + public void setMultiSelect(boolean multiSelect) { + super.setMultiSelect(multiSelect); + } + + /** + * @deprecated use {@link ListSelect}, {@link OptionGroup} or + * {@link TwinColSelect} instead + * + * @see com.vaadin.ui.AbstractSelect#isMultiSelect() + */ + @Override + public boolean isMultiSelect() { + return super.isMultiSelect(); + } + } diff --git a/src/com/vaadin/ui/Slider.java b/src/com/vaadin/ui/Slider.java index 55ff48b48a..ab1d76729e 100644 --- a/src/com/vaadin/ui/Slider.java +++ b/src/com/vaadin/ui/Slider.java @@ -442,7 +442,7 @@ public class Slider extends AbstractField { * @param variables */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey("value")) { final Object value = variables.get("value"); diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java index d38dc06f9e..704b04c94c 100644 --- a/src/com/vaadin/ui/SplitPanel.java +++ b/src/com/vaadin/ui/SplitPanel.java @@ -1,4 +1,4 @@ -/* +/* @ITMillApache2LicenseForJavaFiles@ */ @@ -60,6 +60,8 @@ public class SplitPanel extends AbstractLayout { private int posUnit = UNITS_PERCENTAGE; + private boolean posReversed = false; + private boolean locked = false; private static final String SPLITTER_CLICK_EVENT = VSplitPanel.SPLITTER_CLICK_EVENT_IDENTIFIER; @@ -74,8 +76,7 @@ public class SplitPanel extends AbstractLayout { int i = 0; public boolean hasNext() { - if (i < (firstComponent == null ? 0 : 1) - + (secondComponent == null ? 0 : 1)) { + if (i < getComponentCount()) { return true; } return false; @@ -112,7 +113,12 @@ public class SplitPanel extends AbstractLayout { /** * Creates a new split panel. The orientation of the panels is * <code>ORIENTATION_VERTICAL</code>. + * + * @deprecated this class will become abstract in a becoming version. Use + * {@link HorizontalSplitPanel} and {@link VerticalSplitPanel} + * instead. */ + @Deprecated public SplitPanel() { orientation = ORIENTATION_VERTICAL; setSizeFull(); @@ -124,7 +130,12 @@ public class SplitPanel extends AbstractLayout { * * @param orientation * the Orientation of the layout. + * + * @deprecated this class will become abstract in a becoming version. Use + * {@link HorizontalSplitPanel} and {@link VerticalSplitPanel} + * instead. */ + @Deprecated public SplitPanel(int orientation) { this(); setOrientation(orientation); @@ -221,6 +232,23 @@ public class SplitPanel extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components (zero, one or two) + */ + public int getComponentCount() { + int count = 0; + if (firstComponent != null) { + count++; + } + if (secondComponent != null) { + count++; + } + return count; + } + + /** * Paints the content of this component. * * @param target @@ -243,6 +271,8 @@ public class SplitPanel extends AbstractLayout { if (isLocked()) { target.addAttribute("locked", true); } + + target.addAttribute("reversed", posReversed); if (firstComponent != null) { firstComponent.paint(target); @@ -264,7 +294,12 @@ public class SplitPanel extends AbstractLayout { * Gets the orientation of the container. * * @return the Value of property orientation. + * + * @deprecated this class will become abstract in a becoming version. Use + * {@link HorizontalSplitPanel} and {@link VerticalSplitPanel} + * instead. */ + @Deprecated public int getOrientation() { return orientation; } @@ -274,7 +309,12 @@ public class SplitPanel extends AbstractLayout { * * @param orientation * the New value of property orientation. + * + * @deprecated this class will become abstract in a becoming version. Use + * {@link HorizontalSplitPanel} and {@link VerticalSplitPanel} + * instead. */ + @Deprecated public void setOrientation(int orientation) { // Checks the validity of the argument @@ -305,7 +345,21 @@ public class SplitPanel extends AbstractLayout { * used (default is percentage) */ public void setSplitPosition(int pos) { - setSplitPosition(pos, posUnit, true); + setSplitPosition(pos, posUnit, true, false); + } + + /** + * Moves the position of the splitter. + * + * @param pos + * the new size of the region in the unit that was last used + * (default is percentage) + * @param reverse + * if set to true the split splitter position is measured by the + * second region else it is measured by the first region + */ + public void setSplitPosition(int pos, boolean reverse) { + setSplitPosition(pos, posUnit, true, reverse); } /** @@ -317,7 +371,23 @@ public class SplitPanel extends AbstractLayout { * the unit (from {@link Sizeable}) in which the size is given. */ public void setSplitPosition(int pos, int unit) { - setSplitPosition(pos, unit, true); + setSplitPosition(pos, unit, true, false); + } + + /** + * Moves the position of the splitter with given position and unit. + * + * @param pos + * size of the first region + * @param unit + * the unit (from {@link Sizeable}) in which the size is given. + * @param reverse + * if set to true the split splitter position is measured by the + * second region else it is measured by the first region + * + */ + public void setSplitPosition(int pos, int unit, boolean reverse) { + setSplitPosition(pos, unit, true, reverse); } /** @@ -351,13 +421,15 @@ public class SplitPanel extends AbstractLayout { * position info has come from the client side, thus it already * knows the position. */ - private void setSplitPosition(int pos, int unit, boolean repaintNeeded) { + private void setSplitPosition(int pos, int unit, boolean repaintNeeded, + boolean reverse) { if (unit != UNITS_PERCENTAGE && unit != UNITS_PIXELS) { throw new IllegalArgumentException( "Only percentage and pixel units are allowed"); } this.pos = pos; posUnit = unit; + posReversed = reverse; if (repaintNeeded) { requestRepaint(); } @@ -390,14 +462,15 @@ public class SplitPanel extends AbstractLayout { * comment here, we use the default documentation from implemented * interface. */ + @SuppressWarnings("unchecked") @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); if (variables.containsKey("position") && !isLocked()) { Integer newPos = (Integer) variables.get("position"); - setSplitPosition(newPos, posUnit, false); + setSplitPosition(newPos, posUnit, posReversed); } if (variables.containsKey(SPLITTER_CLICK_EVENT)) { diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index d25e68a7f9..9b4b6f7abb 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -21,8 +21,6 @@ import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; import com.vaadin.terminal.gwt.client.ui.VTabsheet; import com.vaadin.terminal.gwt.server.CommunicationManager; -import com.vaadin.ui.TabSheet.CloseHandler; -import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.themes.Reindeer; import com.vaadin.ui.themes.Runo; @@ -124,6 +122,16 @@ public class TabSheet extends AbstractComponentContainer { } /** + * Gets the number of contained components (tabs). Consistent with the + * iterator returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Removes a component and its corresponding tab. * * If the tab was selected, the first eligible (visible and enabled) @@ -547,7 +555,7 @@ public class TabSheet extends AbstractComponentContainer { // inherits javadoc @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("selected")) { setSelectedTab((Component) keyMapper.get((String) variables .get("selected"))); diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 775470e048..56662112e3 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -17,6 +17,8 @@ import java.util.LinkedList; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.data.Container; import com.vaadin.data.Item; @@ -28,6 +30,7 @@ import com.vaadin.event.Action.Handler; import com.vaadin.event.DataBoundTransferable; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; +import com.vaadin.event.ItemClickEvent.ItemClickNotifier; import com.vaadin.event.ItemClickEvent.ItemClickSource; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.dd.DragAndDropEvent; @@ -67,11 +70,14 @@ import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers; * @VERSION@ * @since 3.0 */ -@SuppressWarnings("serial") +@SuppressWarnings({ "serial", "deprecation" }) @ClientWidget(VScrollTable.class) public class Table extends AbstractSelect implements Action.Container, - Container.Ordered, Container.Sortable, ItemClickSource, DragSource, - DropTarget { + Container.Ordered, Container.Sortable, ItemClickSource, + ItemClickNotifier, DragSource, DropTarget { + + private static final Logger logger = Logger + .getLogger(Table.class.getName()); /** * Modes that Table support as drag sourse. @@ -456,7 +462,7 @@ public class Table extends AbstractSelect implements Action.Container, // Checks that the new visible columns contains no nulls and properties // exist - final Collection properties = getContainerPropertyIds(); + final Collection<?> properties = getContainerPropertyIds(); for (int i = 0; i < visibleColumns.length; i++) { if (visibleColumns[i] == null) { throw new NullPointerException("Ids must be non-nulls"); @@ -1108,12 +1114,13 @@ public class Table extends AbstractSelect implements Action.Container, * the propertyID identifying the column. * @param collapsed * the desired collapsedness. - * @throws IllegalAccessException + * @throws IllegalStateException + * if column collapsing is not allowed */ public void setColumnCollapsed(Object propertyId, boolean collapsed) - throws IllegalAccessException { + throws IllegalStateException { if (!isColumnCollapsingAllowed()) { - throw new IllegalAccessException("Column collapsing not allowed!"); + throw new IllegalStateException("Column collapsing not allowed!"); } if (collapsed) { @@ -1823,7 +1830,8 @@ public class Table extends AbstractSelect implements Action.Container, // columnGenerators 'override' properties, don't add the same id twice Collection<Object> col = new LinkedList<Object>(); - for (Iterator it = getContainerPropertyIds().iterator(); it.hasNext();) { + for (Iterator<?> it = getContainerPropertyIds().iterator(); it + .hasNext();) { Object id = it.next(); if (columnGenerators == null || !columnGenerators.containsKey(id)) { col.add(id); @@ -1874,6 +1882,7 @@ public class Table extends AbstractSelect implements Action.Container, Set<Object> renderedItemIds = getCurrentlyRenderedItemIds(); + @SuppressWarnings("unchecked") HashSet<Object> newValue = new HashSet<Object>( (Collection<Object>) getValue()); @@ -2000,7 +2009,8 @@ public class Table extends AbstractSelect implements Action.Container, .get("lastToBeRendered")).intValue(); } catch (Exception e) { // FIXME: Handle exception - e.printStackTrace(); + logger.log(Level.FINER, + "Could not parse the first and/or last rows.", e); } // respect suggested rows only if table is not otherwise updated @@ -2064,7 +2074,8 @@ public class Table extends AbstractSelect implements Action.Container, } } catch (final Exception e) { // FIXME: Handle exception - e.printStackTrace(); + logger.log(Level.FINER, + "Could not determine column collapsing state", e); } clientNeedsContentRefresh = true; } @@ -2082,8 +2093,8 @@ public class Table extends AbstractSelect implements Action.Container, setColumnOrder(idsTemp); } catch (final Exception e) { // FIXME: Handle exception - e.printStackTrace(); - + logger.log(Level.FINER, + "Could not determine column reordering state", e); } clientNeedsContentRefresh = true; } @@ -2284,9 +2295,9 @@ public class Table extends AbstractSelect implements Action.Container, // selection support LinkedList<String> selectedKeys = new LinkedList<String>(); if (isMultiSelect()) { - HashSet sel = new HashSet((Set) getValue()); - Collection vids = getVisibleItemIds(); - for (Iterator it = vids.iterator(); it.hasNext();) { + HashSet<?> sel = new HashSet<Object>((Set<?>) getValue()); + Collection<?> vids = getVisibleItemIds(); + for (Iterator<?> it = vids.iterator(); it.hasNext();) { Object id = it.next(); if (sel.contains(id)) { selectedKeys.add(itemIdMapper.key(id)); @@ -2338,7 +2349,7 @@ public class Table extends AbstractSelect implements Action.Container, target.addAttribute("colfooters", columnFootersVisible); // Visible column order - final Collection sortables = getSortableContainerPropertyIds(); + final Collection<?> sortables = getSortableContainerPropertyIds(); final ArrayList<String> visibleColOrder = new ArrayList<String>(); for (final Iterator<Object> it = visibleColumns.iterator(); it .hasNext();) { @@ -2360,7 +2371,7 @@ public class Table extends AbstractSelect implements Action.Container, if (columnGenerators.containsKey(columnId)) { iscomponent[iscomponentIndex++] = true; } else { - final Class colType = getType(columnId); + final Class<?> colType = getType(columnId); iscomponent[iscomponentIndex++] = colType != null && Component.class.isAssignableFrom(colType); } @@ -3023,7 +3034,7 @@ public class Table extends AbstractSelect implements Action.Container, * @see com.vaadin.ui.Select#getVisibleItemIds() */ @Override - public Collection getVisibleItemIds() { + public Collection<?> getVisibleItemIds() { final LinkedList<Object> visible = new LinkedList<Object>(); @@ -3366,12 +3377,12 @@ public class Table extends AbstractSelect implements Action.Container, * * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() */ - public Collection getSortableContainerPropertyIds() { + public Collection<?> getSortableContainerPropertyIds() { final Container c = getContainerDataSource(); if (c instanceof Container.Sortable && !isSortDisabled()) { return ((Container.Sortable) c).getSortableContainerPropertyIds(); } else { - return new LinkedList(); + return new LinkedList<Object>(); } } @@ -3818,7 +3829,7 @@ public class Table extends AbstractSelect implements Action.Container, } // The property id of the column which header was pressed - private Object columnPropertyId; + private final Object columnPropertyId; public HeaderClickEvent(Component source, Object propertyId, MouseEventDetails details) { @@ -3858,7 +3869,7 @@ public class Table extends AbstractSelect implements Action.Container, } // The property id of the column which header was pressed - private Object columnPropertyId; + private final Object columnPropertyId; /** * Constructor diff --git a/src/com/vaadin/ui/TextArea.java b/src/com/vaadin/ui/TextArea.java new file mode 100644 index 0000000000..9665a7a98c --- /dev/null +++ b/src/com/vaadin/ui/TextArea.java @@ -0,0 +1,119 @@ +package com.vaadin.ui; + +import com.vaadin.data.Property; +import com.vaadin.terminal.gwt.client.ui.VTextArea; + +/** + * A text field that supports multiline editing. + */ +@ClientWidget(VTextArea.class) +public class TextArea extends TextField { + + private static final int DEFAULT_ROWS = 5; + + /** + * Constructs an empty TextArea. + */ + public TextArea() { + setRows(DEFAULT_ROWS); + } + + /** + * Constructs an empty TextArea with given caption. + * + * @param caption + * the caption for the field. + */ + public TextArea(String caption) { + super(caption); + setRows(DEFAULT_ROWS); + } + + /** + * Constructs a TextArea with given property data source. + * + * @param dataSource + * the data source for the field + */ + public TextArea(Property dataSource) { + super(dataSource); + setRows(DEFAULT_ROWS); + } + + /** + * Constructs a TextArea with given caption and property data source. + * + * @param caption + * the caption for the field + * @param dataSource + * the dato source for the field + */ + public TextArea(String caption, Property dataSource) { + super(caption, dataSource); + setRows(DEFAULT_ROWS); + } + + /** + * Constructs a TextArea with given caption and value. + * + * @param caption + * the caption for the field + * @param value + * the value for the field + */ + public TextArea(String caption, String value) { + super(caption, value); + setRows(DEFAULT_ROWS); + } + + /** + * Sets the number of rows in the editor. + * + * @param rows + * the number of rows for this editor. + */ + @Override + public void setRows(int rows) { + // TODO implement here once the API from TextField is removed + super.setRows(rows); + } + + /** + * Gets the number of rows in the editor. If the number of rows is set to 0, + * the actual number of displayed rows is determined implicitly by the + * adapter. + * + * @return number of explicitly set rows. + */ + @Override + public int getRows() { + // TODO implement here once the API from TextField is removed + return super.getRows(); + } + + /** + * Sets the editor's word-wrap mode on or off. + * + * @param wordwrap + * the boolean value specifying if the editor should be in + * word-wrap mode after the call or not. + */ + @Override + public void setWordwrap(boolean wordwrap) { + // TODO implement here once the API from TextField is removed + super.setWordwrap(wordwrap); + } + + /** + * Tests if the editor is in word-wrap mode. + * + * @return <code>true</code> if the component is in the word-wrap mode, + * <code>false</code> if not. + */ + @Override + public boolean isWordwrap() { + // TODO implement here once the API from TextField is removed + return super.isWordwrap(); + } + +} diff --git a/src/com/vaadin/ui/TextField.java b/src/com/vaadin/ui/TextField.java index fff0beaf0c..64dbf933b2 100644 --- a/src/com/vaadin/ui/TextField.java +++ b/src/com/vaadin/ui/TextField.java @@ -4,15 +4,12 @@ package com.vaadin.ui; -import java.text.Format; import java.util.Map; import com.vaadin.data.Property; import com.vaadin.event.FieldEvents; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.event.FieldEvents.TextChangeEvent; +import com.vaadin.event.FieldEvents.TextChangeListener; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.VTextField; @@ -40,20 +37,17 @@ import com.vaadin.ui.ClientWidget.LoadStyle; */ @SuppressWarnings("serial") @ClientWidget(value = VTextField.class, loadStyle = LoadStyle.EAGER) -public class TextField extends AbstractField implements - FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { +public class TextField extends AbstractTextField implements + FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, + FieldEvents.TextChangeNotifier { - /* Private members */ + private static final String VAR_TEXT_CONTENT_DIFF = "tcd"; /** - * Value formatter used to format the string contents. - */ - private Format format; - - /** - * Number of visible columns in the TextField. + * Tells if input is used to enter sensitive information that is not echoed + * to display. Typically passwords. */ - private int columns = 0; + private boolean secret = false; /** * Number of visible rows in a multiline TextField. Value 0 implies a @@ -67,34 +61,37 @@ public class TextField extends AbstractField implements private boolean wordwrap = true; /** - * Tells if input is used to enter sensitive information that is not echoed - * to display. Typically passwords. + * Number of visible columns in the TextField. */ - private boolean secret = false; + private int columns = 0; - /** - * Null representation. - */ - private String nullRepresentation = "null"; + private String inputPrompt = null; + + private int selectionPosition = -1; + private int selectionLength; + + private int lastKnownCursorPosition; + + private String lastKnownTextContent; /** - * Is setting to null from non-null value allowed by setting with null - * representation . + * Flag indicating that a text change event is pending to be triggered. + * Cleared by {@link #setInternalValue(Object)} and when the event is fired. */ - private boolean nullSettingAllowed = false; - - private String inputPrompt = null; + private boolean textChangeEventPending; /** - * Maximum character count in text field. + * Flag used to determine wheter we are currently handling a state change + * triggered by a user. Used to properly fire text change event before value + * change event triggered by the client side. */ - private int maxLength = -1; + private boolean changingVariables; - private int selectionPosition = -1; + private TextChangeEventMode textChangeEventMode = TextChangeEventMode.LAZY; - private int selectionLength; + private final int DEFAULT_TEXTCHANGE_TIMEOUT = 400; - /* Constructors */ + private int textChangeEventTimeout = DEFAULT_TEXTCHANGE_TIMEOUT; /** * Constructs an empty <code>TextField</code> with no caption. @@ -110,7 +107,7 @@ public class TextField extends AbstractField implements * the caption <code>String</code> for the editor. */ public TextField(String caption) { - setValue(""); + this(); setCaption(caption); } @@ -156,173 +153,76 @@ public class TextField extends AbstractField implements setCaption(caption); } - /* Component basic features */ + /** + * Gets the secret property on and off. If a field is used to enter + * secretinformation the information is not echoed to display. + * + * @return <code>true</code> if the field is used to enter secret + * information, <code>false</code> otherwise. + * + * @deprecated in 6.5 use {@link PasswordField} instead + */ + @Deprecated + public boolean isSecret() { + return secret; + } - /* - * Paints this component. Don't add a JavaDoc comment here, we use the - * default documentation from implemented interface. + /** + * Sets the secret property on and off. If a field is used to enter + * secretinformation the information is not echoed to display. + * + * @param secret + * the value specifying if the field is used to enter secret + * information. + * @deprecated in 6.5 use {@link PasswordField} instead */ + @Deprecated + public void setSecret(boolean secret) { + if (this.secret != secret) { + this.secret = secret; + requestRepaint(); + } + } + @Override public void paintContent(PaintTarget target) throws PaintException { - super.paintContent(target); - - // Sets the secret attribute if (isSecret()) { target.addAttribute("secret", true); } - - if (getMaxLength() >= 0) { - target.addAttribute("maxLength", getMaxLength()); - } - - if (inputPrompt != null) { - target.addAttribute("prompt", inputPrompt); - } - if (selectionPosition != -1) { - target.addAttribute("selpos", selectionPosition); - target.addAttribute("sellen", selectionLength); - selectionPosition = -1; - } - // Adds the number of column and rows final int columns = getColumns(); - final int rows = getRows(); if (columns != 0) { target.addAttribute("cols", String.valueOf(columns)); } + final int rows = getRows(); if (rows != 0) { target.addAttribute("rows", String.valueOf(rows)); target.addAttribute("multiline", true); - if (!wordwrap) { + + // Optimization: the default true is assumed if not painted + if (!isWordwrap()) { target.addAttribute("wordwrap", false); } } - // Adds the content as variable - String value = getFormattedValue(); - if (value == null) { - value = getNullRepresentation(); - } - if (value == null) { - throw new IllegalStateException( - "Null values are not allowed if the null-representation is null"); - } - target.addVariable(this, "text", value); - } - - /** - * 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(); - } - - /* - * Gets the value of the field, but uses formatter is given. Don't add a - * JavaDoc comment here, we use the default documentation from implemented - * interface. - */ - @Override - public Object getValue() { - Object v = super.getValue(); - if (format == null || v == null) { - return v; - } - try { - return format.format(v); - } catch (final IllegalArgumentException e) { - return v; - } - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.AbstractField#changeVariables(java.lang.Object, - * java.util.Map) - */ - @Override - public void changeVariables(Object source, Map<String, Object> variables) { - - super.changeVariables(source, variables); - - // Sets the text - if (variables.containsKey("text") && !isReadOnly()) { - - // Only do the setting if the string representation of the value - // has been updated - String newValue = (String) variables.get("text"); - - // server side check for max length - if (getMaxLength() != -1 && newValue.length() > getMaxLength()) { - newValue = newValue.substring(0, getMaxLength()); - } - final String oldValue = getFormattedValue(); - if (newValue != null - && (oldValue == null || isNullSettingAllowed()) - && newValue.equals(getNullRepresentation())) { - newValue = null; - } - if (newValue != oldValue - && (newValue == null || !newValue.equals(oldValue))) { - boolean wasModified = isModified(); - setValue(newValue, true); - - // If the modified status changes, or if we have a formatter, - // repaint is needed after all. - if (format != null || wasModified != isModified()) { - requestRepaint(); - } - } + if (getInputPrompt() != null) { + target.addAttribute("prompt", getInputPrompt()); } - if (variables.containsKey(FocusEvent.EVENT_ID)) { - fireEvent(new FocusEvent(this)); + if (selectionPosition != -1) { + target.addAttribute("selpos", selectionPosition); + target.addAttribute("sellen", selectionLength); + selectionPosition = -1; } - if (variables.containsKey(BlurEvent.EVENT_ID)) { - fireEvent(new BlurEvent(this)); + if (hasListeners(TextChangeEvent.class)) { + target.addAttribute(VTextField.ATTR_TEXTCHANGE_EVENTMODE, + getTextChangeEventMode().toString()); + target.addAttribute(VTextField.ATTR_TEXTCHANGE_TIMEOUT, + getTextChangeTimeout()); } - } - - /* Text field configuration */ - - /** - * Gets 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. - * - * @return the number of columns in the editor. - */ - public int getColumns() { - return columns; - } + super.paintContent(target); - /** - * 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. - * - * @param columns - * the number of columns to set. - */ - public void setColumns(int columns) { - if (columns < 0) { - columns = 0; - } - this.columns = columns; - requestRepaint(); } /** @@ -331,7 +231,12 @@ public class TextField extends AbstractField implements * adapter. * * @return number of explicitly set rows. + * @deprecated use {@link TextArea} component and the same method there. + * This method will be removed from TextField that is to be used + * for one line text input only in the next versions. + * */ + @Deprecated public int getRows() { return rows; } @@ -341,7 +246,12 @@ public class TextField extends AbstractField implements * * @param rows * the number of rows for this editor. + * + * @deprecated in 6.5 use {@link TextArea} component and the same method + * there. This method will be removed from TextField that is to + * be used for one line text input only in the next versions. */ + @Deprecated public void setRows(int rows) { if (rows < 0) { rows = 0; @@ -353,61 +263,15 @@ public class TextField extends AbstractField implements } /** - * Sets the height of the {@link TextField} instance. - * - * <p> - * Setting height for {@link TextField} also has a side-effect that puts - * {@link TextField} into multiline mode (aka "textarea"). Multiline mode - * can also be achieved by calling {@link #setRows(int)}. The height value - * overrides the number of rows set by {@link #setRows(int)}. - * <p> - * If you want to set height of single line {@link TextField}, call - * {@link #setRows(int)} with value 0 after setting the height. Setting rows - * to 0 resets the side-effect. - * - * @see com.vaadin.ui.AbstractComponent#setHeight(float, int) - */ - @Override - public void setHeight(float height, int unit) { - super.setHeight(height, unit); - if (height > 1) { - /* - * In html based terminals we most commonly want to make component - * to be textarea if height is defined. Setting row field above 0 - * will render component as textarea. - */ - rows = 2; - } - } - - /** - * Sets the height of the {@link TextField} instance. - * - * <p> - * Setting height for {@link TextField} also has a side-effect that puts - * {@link TextField} into multiline mode (aka "textarea"). Multiline mode - * can also be achieved by calling {@link #setRows(int)}. The height value - * overrides the number of rows set by {@link #setRows(int)}. - * <p> - * If you want to set height of single line {@link TextField}, call - * {@link #setRows(int)} with value 0 after setting the height. Setting rows - * to 0 resets the side-effect. - * - * @see com.vaadin.ui.AbstractComponent#setHeight(java.lang.String) - */ - @Override - public void setHeight(String height) { - // will call setHeight(float, int) the actually does the magic. Method - // is overridden just to document side-effects. - super.setHeight(height); - } - - /** * Tests if the editor is in word-wrap mode. * * @return <code>true</code> if the component is in the word-wrap mode, * <code>false</code> if not. + * @deprecated in 6.5 use {@link TextArea} component and the same method + * there. This method will be removed from TextField that is to + * be used for one line text input only in the next versions. */ + @Deprecated public boolean isWordwrap() { return wordwrap; } @@ -418,7 +282,12 @@ public class TextField extends AbstractField implements * @param wordwrap * the boolean value specifying if the editor should be in * word-wrap mode after the call or not. + * + * @deprecated in 6.5 use {@link TextArea} component and the same method + * there. This method will be removed from TextField that is to + * be used for one line text input only in the next versions. */ + @Deprecated public void setWordwrap(boolean wordwrap) { if (this.wordwrap != wordwrap) { this.wordwrap = wordwrap; @@ -426,264 +295,315 @@ public class TextField extends AbstractField implements } } - /* Property features */ - - /* - * Gets the edited property's type. Don't add a JavaDoc comment here, we use - * the default documentation from implemented interface. - */ - @Override - public Class getType() { - return String.class; - } - /** - * Gets the secret property on and off. If a field is used to enter - * secretinformation the information is not echoed to display. + * Gets 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. * - * @return <code>true</code> if the field is used to enter secret - * information, <code>false</code> otherwise. + * @return the number of columns in the editor. */ - public boolean isSecret() { - return secret; + public int getColumns() { + return columns; } /** - * Sets the secret property on and off. If a field is used to enter - * secretinformation the information is not echoed to display. + * 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. * - * @param secret - * the value specifying if the field is used to enter secret - * information. + * @param columns + * the number of columns to set. */ - public void setSecret(boolean secret) { - if (this.secret != secret) { - this.secret = secret; - requestRepaint(); + public void setColumns(int columns) { + if (columns < 0) { + columns = 0; } + this.columns = columns; + requestRepaint(); } /** - * Gets the null-string representation. - * - * <p> - * The null-valued strings are represented on the user interface by - * replacing the null value with this string. If the null representation is - * set null (not 'null' string), painting null value throws exception. - * </p> - * - * <p> - * The default value is string 'null'. - * </p> + * Gets the current input prompt. * - * @return the String Textual representation for null strings. - * @see TextField#isNullSettingAllowed() + * @see #setInputPrompt(String) + * @return the current input prompt, or null if not enabled */ - public String getNullRepresentation() { - return nullRepresentation; + public String getInputPrompt() { + return inputPrompt; } /** - * Is setting nulls with null-string representation allowed. - * - * <p> - * If this property is true, writing null-representation string to text - * field always sets the field value to real null. If this property is - * false, null setting is not made, but the null values are maintained. - * Maintenance of null-values is made by only converting the textfield - * contents to real null, if the text field matches the null-string - * representation and the current value of the field is null. - * </p> - * - * <p> - * By default this setting is false - * </p> + * Sets the input prompt - a textual prompt that is displayed when the field + * would otherwise be empty, to prompt the user for input. * - * @return boolean Should the null-string represenation be always converted - * to null-values. - * @see TextField#getNullRepresentation() + * @param inputPrompt */ - public boolean isNullSettingAllowed() { - return nullSettingAllowed; + public void setInputPrompt(String inputPrompt) { + this.inputPrompt = inputPrompt; + requestRepaint(); } /** - * Sets the null-string representation. - * - * <p> - * The null-valued strings are represented on the user interface by - * replacing the null value with this string. If the null representation is - * set null (not 'null' string), painting null value throws exception. - * </p> - * - * <p> - * The default value is string 'null' - * </p> + * Selects all text in the field. * - * @param nullRepresentation - * Textual representation for null strings. - * @see TextField#setNullSettingAllowed(boolean) + * @since 6.4 */ - public void setNullRepresentation(String nullRepresentation) { - this.nullRepresentation = nullRepresentation; + public void selectAll() { + String text = getValue() == null ? "" : getValue().toString(); + setSelectionRange(0, text.length()); } /** - * Sets the null conversion mode. + * Sets the range of text to be selected. * - * <p> - * If this property is true, writing null-representation string to text - * field always sets the field value to real null. If this property is - * false, null setting is not made, but the null values are maintained. - * Maintenance of null-values is made by only converting the textfield - * contents to real null, if the text field matches the null-string - * representation and the current value of the field is null. - * </p> + * As a side effect the field will become focused. * - * <p> - * By default this setting is false. - * </p> + * @since 6.4 * - * @param nullSettingAllowed - * Should the null-string represenation be always converted to - * null-values. - * @see TextField#getNullRepresentation() + * @param pos + * the position of the first character to be selected + * @param length + * the number of characters to be selected */ - public void setNullSettingAllowed(boolean nullSettingAllowed) { - this.nullSettingAllowed = nullSettingAllowed; + public void setSelectionRange(int pos, int length) { + selectionPosition = pos; + selectionLength = length; + focus(); + requestRepaint(); } /** - * Gets the current input prompt. + * Sets the cursor position in the field. As a side effect the field will + * become focused. * - * @see #setInputPrompt(String) - * @return the current input prompt, or null if not enabled - */ - public String getInputPrompt() { - return inputPrompt; + * @since 6.4 + * + * @param pos + * the position for the cursor + * */ + public void setCursorPosition(int pos) { + setSelectionRange(pos, 0); + lastKnownCursorPosition = pos; } /** - * Sets the input prompt - a textual prompt that is displayed when the field - * would otherwise be empty, to prompt the user for input. + * Returns the last known cursor position of the field. * - * @param inputPrompt + * <p> + * Note that due to the client server nature or the GWT terminal, Vaadin + * cannot provide the exact value of the cursor position in most situations. + * The value is updated only when the client side terminal communicates to + * TextField, like on {@link ValueChangeEvent}s and {@link TextChangeEvent} + * s. This may change later if a deep push integration is built to Vaadin. + * + * @return the cursor position */ - public void setInputPrompt(String inputPrompt) { - this.inputPrompt = inputPrompt; - requestRepaint(); + public int getCursorPosition() { + return lastKnownCursorPosition; } /** - * 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 current (or the last known) text content in the field. + * <p> + * Note the text returned by this method is not necessary the same what is + * returned by the {@link #getValue()} method. The value is updated when the + * terminal fires a value change event via e.g. blurring the field or by + * pressing enter. The value returned by this method is updated also on + * {@link TextChangeEvent}s. Due to this high dependency to the terminal + * implementation this method is (at least at this point) not published. + * + * @return the text which is currently displayed in the field. + */ + private String getCurrentTextContent() { + if (lastKnownTextContent != null) { + return lastKnownTextContent; + } else { + Object text = getValue(); + if (text == null) { + return getNullRepresentation(); + } + return text.toString(); + } } - /** - * 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 + public void changeVariables(Object source, Map<String, Object> variables) { + if (variables.containsKey(VTextField.VAR_CURSOR)) { + Integer object = (Integer) variables.get(VTextField.VAR_CURSOR); + lastKnownCursorPosition = object.intValue(); + } + if (variables.containsKey(VTextField.VAR_CUR_TEXT)) { + /* + * NOTE, we might want to develop this further so that on a value + * change event the whole text content don't need to be sent from + * the client to server. Just "commit" the value from currentText to + * the value. + */ + textChangeEventPending = true; + handleInputEventTextChange(variables); + } + + changingVariables = true; + try { + super.changeVariables(source, variables); + } finally { + changingVariables = false; + } + firePendingTextChangeEvent(); + } + + private void firePendingTextChangeEvent() { + if (textChangeEventPending) { + fireEvent(new TextChangeEventImpl(this)); + textChangeEventPending = false; + } } @Override - protected boolean isEmpty() { - return super.isEmpty() || toString().length() == 0; + protected void setInternalValue(Object newValue) { + if (changingVariables + && !newValue.toString().equals(lastKnownTextContent)) { + /* + * Fire text change event before value change event if change is + * coming from the client side. + */ + lastKnownTextContent = newValue.toString(); + textChangeEventPending = true; + firePendingTextChangeEvent(); + } + + super.setInternalValue(newValue); + } + + private void handleInputEventTextChange(Map<String, Object> variables) { + /* + * TODO we could vastly optimize the communication of values by using + * some sort of diffs instead of always sending the whole text content. + * Also on value change events we could use the mechanism. + */ + String object = (String) variables.get(VTextField.VAR_CUR_TEXT); + lastKnownTextContent = object; + textChangeEventPending = true; } + /* ** Text Change Events ** */ + /** - * Returns the maximum number of characters in the field. Value -1 is - * considered unlimited. Terminal may however have some technical limits. + * Sets the mode how the TextField triggers {@link TextChangeEvent}s. + * + * @param inputEventMode + * the new mode * - * @return the maxLength + * @see TextChangeEventMode */ - public int getMaxLength() { - return maxLength; + public void setTextChangeEventMode(TextChangeEventMode inputEventMode) { + textChangeEventMode = inputEventMode; } /** - * Sets the maximum number of characters in the field. Value -1 is - * considered unlimited. Terminal may however have some technical limits. - * - * @param maxLength - * the maxLength to set + * @return the mode used to trigger {@link TextChangeEvent}s. */ - public void setMaxLength(int maxLength) { - this.maxLength = maxLength; - requestRepaint(); + public TextChangeEventMode getTextChangeEventMode() { + return textChangeEventMode; } - public void addListener(FocusListener listener) { - addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, - FocusListener.focusMethod); - } + /** + * Different modes how the TextField can trigger {@link TextChangeEvent}s. + */ + public enum TextChangeEventMode { - public void removeListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + /** + * An event is triggered on each text content change, most commonly key + * press events. + */ + EAGER, + /** + * Each text change event in the UI causes the event to be communicated + * to the application after a timeout. The length of the timeout can be + * controlled with {@link TextField#setInputEventTimeout(int)}. Only the + * last input event is reported to the server side if several text + * change events happen during the timeout. + * <p> + * In case of a {@link ValueChangeEvent} the schedule is not kept + * strictly. Before a {@link ValueChangeEvent} a {@link TextChangeEvent} + * is triggered if the text content has changed since the previous + * TextChangeEvent regardless of the schedule. + */ + TIMEOUT, + /** + * An event is triggered when there is a pause of text modifications. + * The length of the pause can be modified with + * {@link TextField#setInputEventTimeout(int)}. Like with the + * {@link #TIMEOUT} mode, an event is forced before + * {@link ValueChangeEvent}s, even if the user did not keep a pause + * while entering the text. + * <p> + * This is the default mode. + */ + LAZY } - public void addListener(BlurListener listener) { - addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, - BlurListener.blurMethod); + public void addListener(TextChangeListener listener) { + addListener(TextChangeListener.EVENT_ID, TextChangeEvent.class, + listener, TextChangeListener.EVENT_METHOD); } - public void removeListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); + public void removeListener(TextChangeListener listener) { + removeListener(TextChangeListener.EVENT_ID, TextChangeEvent.class, + listener); } /** - * Selects all text in the field. + * The text change timeout modifies how often text change events are + * communicated to the application when {@link #getTextChangeEventMode()} is + * {@link TextChangeEventMode#LAZY} or {@link TextChangeEventMode#TIMEOUT}. * - * @since 6.4 + * + * @see #getTextChangeEventMode() + * + * @param timeout + * the timeout in milliseconds */ - public void selectAll() { - String text = getValue() == null ? "" : getValue().toString(); - setSelectionRange(0, text.length()); + public void setTextChangeTimeout(int timeout) { + textChangeEventTimeout = timeout; } /** - * Sets the range of text to be selected. + * Gets the timeout used to fire {@link TextChangeEvent}s when the + * {@link #getTextChangeEventMode()} is {@link TextChangeEventMode#LAZY} or + * {@link TextChangeEventMode#TIMEOUT}. * - * As a side effect the field will become focused. - * - * @since 6.4 - * - * @param pos - * the position of the first character to be selected - * @param length - * the number of characters to be selected + * @return the timeout value in milliseconds */ - public void setSelectionRange(int pos, int length) { - selectionPosition = pos; - selectionLength = length; - focus(); - requestRepaint(); + public int getTextChangeTimeout() { + return textChangeEventTimeout; } - /** - * Sets the cursor position in the field. As a side effect the field will - * become focused. - * - * @since 6.4 - * - * @param pos - * the position for the cursor - * */ - public void setCursorPosition(int pos) { - setSelectionRange(pos, 0); + public class TextChangeEventImpl extends TextChangeEvent { + private String curText; + private int cursorPosition; + + private TextChangeEventImpl(final TextField tf) { + super(tf); + curText = tf.getCurrentTextContent(); + cursorPosition = tf.getCursorPosition(); + } + + @Override + public TextField getComponent() { + return (TextField) super.getComponent(); + } + + @Override + public String getText() { + return curText; + } + + @Override + public int getCursorPosition() { + return cursorPosition; + } + } } diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index 04d1c89dcc..79ce7cf47f 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -26,6 +26,7 @@ import com.vaadin.event.Action; import com.vaadin.event.DataBoundTransferable; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; +import com.vaadin.event.ItemClickEvent.ItemClickNotifier; import com.vaadin.event.ItemClickEvent.ItemClickSource; import com.vaadin.event.Transferable; import com.vaadin.event.dd.DragAndDropEvent; @@ -57,10 +58,11 @@ import com.vaadin.tools.ReflectTools; * @VERSION@ * @since 3.0 */ -@SuppressWarnings("serial") +@SuppressWarnings({ "serial", "deprecation" }) @ClientWidget(VTree.class) public class Tree extends AbstractSelect implements Container.Hierarchical, - Action.Container, ItemClickSource, DragSource, DropTarget { + Action.Container, ItemClickSource, ItemClickNotifier, DragSource, + DropTarget { /* Private members */ @@ -237,7 +239,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, boolean result = true; // Initial stack - final Stack todo = new Stack(); + final Stack<Object> todo = new Stack<Object>(); todo.add(startItemId); // Expands recursively @@ -290,7 +292,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, boolean result = true; // Initial stack - final Stack todo = new Stack(); + final Stack<Object> todo = new Stack<Object>(); todo.add(startItemId); // Collapse recursively @@ -373,7 +375,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * java.util.Map) */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("clickedKey")) { String key = (String) variables.get("clickedKey"); @@ -390,7 +392,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!isSelectable() && variables.containsKey("selected")) { // Not-selectable is a special case, AbstractSelect does not support // TODO could be optimized. - variables = new HashMap(variables); + variables = new HashMap<String, Object>(variables); variables.remove("selected"); } @@ -462,7 +464,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final String[] ka = (String[]) variables.get("selected"); // Converts the key-array to id-set - final LinkedList s = new LinkedList(); + final LinkedList<Object> s = new LinkedList<Object>(); for (int i = 0; i < ka.length; i++) { final Object id = itemIdMapper.get(ka[i]); if (!isNullSelectionAllowed() @@ -537,8 +539,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final LinkedList<String> expandedKeys = new LinkedList<String>(); // Iterates through hierarchical tree using a stack of iterators - final Stack<Iterator> iteratorStack = new Stack<Iterator>(); - Collection ids; + final Stack<Iterator<?>> iteratorStack = new Stack<Iterator<?>>(); + Collection<?> ids; if (partialUpdate) { ids = getChildren(expandedItemId); } else { @@ -552,7 +554,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, while (!iteratorStack.isEmpty()) { // Gets the iterator for current tree level - final Iterator i = iteratorStack.peek(); + final Iterator<?> i = iteratorStack.peek(); // If the level is finished, back to previous tree level if (!i.hasNext()) { @@ -694,7 +696,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#getChildren(Object) */ - public Collection getChildren(Object itemId) { + public Collection<?> getChildren(Object itemId) { return ((Container.Hierarchical) items).getChildren(itemId); } @@ -730,7 +732,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * * @see com.vaadin.data.Container.Hierarchical#rootItemIds() */ - public Collection rootItemIds() { + public Collection<?> rootItemIds() { return ((Container.Hierarchical) items).rootItemIds(); } @@ -1030,20 +1032,20 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @see com.vaadin.ui.Select#getVisibleItemIds() */ @Override - public Collection getVisibleItemIds() { + public Collection<?> getVisibleItemIds() { - final LinkedList visible = new LinkedList(); + final LinkedList<Object> visible = new LinkedList<Object>(); // Iterates trough hierarchical tree using a stack of iterators - final Stack<Iterator> iteratorStack = new Stack<Iterator>(); - final Collection ids = rootItemIds(); + final Stack<Iterator<?>> iteratorStack = new Stack<Iterator<?>>(); + final Collection<?> ids = rootItemIds(); if (ids != null) { iteratorStack.push(ids.iterator()); } while (!iteratorStack.isEmpty()) { // Gets the iterator for current tree level - final Iterator i = iteratorStack.peek(); + final Iterator<?> i = iteratorStack.peek(); // If the level is finished, back to previous tree level if (!i.hasNext()) { @@ -1241,7 +1243,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, VerticalDropLocation dropLocation = getDropLocation(); if (VerticalDropLocation.TOP == dropLocation) { // if on top of the caption area, add before - Collection children; + Collection<?> children; Object itemIdInto = getItemIdInto(); if (itemIdInto != null) { // seek the previous from child list diff --git a/src/com/vaadin/ui/TwinColSelect.java b/src/com/vaadin/ui/TwinColSelect.java index bcbc86a275..768b17911a 100644 --- a/src/com/vaadin/ui/TwinColSelect.java +++ b/src/com/vaadin/ui/TwinColSelect.java @@ -95,7 +95,7 @@ public class TwinColSelect extends AbstractSelect { * @param caption * @param options */ - public TwinColSelect(String caption, Collection options) { + public TwinColSelect(String caption, Collection<?> options) { super(caption, options); setMultiSelect(true); } diff --git a/src/com/vaadin/ui/Upload.java b/src/com/vaadin/ui/Upload.java index 60c31fbc67..23baf14ec2 100644 --- a/src/com/vaadin/ui/Upload.java +++ b/src/com/vaadin/ui/Upload.java @@ -4,8 +4,6 @@ package com.vaadin.ui; -import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; import java.lang.reflect.Method; @@ -13,11 +11,11 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; -import com.vaadin.Application; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.UploadStream; import com.vaadin.terminal.gwt.client.ui.VUpload; +import com.vaadin.terminal.gwt.server.NoInputStreamException; +import com.vaadin.terminal.gwt.server.NoOutputStreamException; import com.vaadin.ui.ClientWidget.LoadStyle; /** @@ -65,11 +63,6 @@ import com.vaadin.ui.ClientWidget.LoadStyle; public class Upload extends AbstractComponent implements Component.Focusable { /** - * Upload buffer size. - */ - private static final int BUFFER_SIZE = 64 * 1024; // 64k - - /** * Should the field be focused on next repaint? */ private final boolean focus = false; @@ -93,10 +86,9 @@ public class Upload extends AbstractComponent implements Component.Focusable { private String buttonCaption = "Upload"; /** - * ProgressListener to which information about progress is sent during + * ProgressListeners to which information about progress is sent during * upload */ - private ProgressListener progressListener; private LinkedHashSet<ProgressListener> progressListeners; private boolean interrupted = false; @@ -105,8 +97,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { private int nextid; - /* TODO: Add a default constructor, receive to temp file. */ - /** * Creates a new instance of Upload. * @@ -115,128 +105,19 @@ public class Upload extends AbstractComponent implements Component.Focusable { public Upload() { } - /** - * Creates a new instance of Upload that redirects the uploaded data to - * stream given by the Receiver. - * - * @param caption - * Normal component caption. You can set the caption of the - * upload submit button with setButtonCaption(). - * @param uploadReceiver - * Receiver to call to retrieve output stream when upload starts. - */ public Upload(String caption, Receiver uploadReceiver) { setCaption(caption); receiver = uploadReceiver; } /** - * This method is called by terminal when upload is received. - * - * Note, this method is called outside synchronized (Application) block, so - * overriding this may be dangerous. - * - * @param upload - */ - public void receiveUpload(UploadStream upload) throws UploadException { - if (receiver == null) { - throw new IllegalStateException( - "Receiver not set for the Upload component"); - } - - if (!isUploading) { - throw new IllegalStateException("uploading not started"); - } - - // Gets file properties - final String filename = upload.getContentName(); - final String type = upload.getContentType(); - - final Application application = getApplication(); - - synchronized (application) { - fireStarted(filename, type); - } - - // Gets the output target stream - final OutputStream out = receiver.receiveUpload(filename, type); - if (out == null) { - synchronized (application) { - fireNoOutputStream(filename, type, 0); - endUpload(); - } - return; - } - - final InputStream in = upload.getStream(); - - if (null == in) { - // No file, for instance non-existent filename in html upload - synchronized (application) { - fireNoInputStream(filename, type, 0); - endUpload(); - } - return; - } - - final byte buffer[] = new byte[BUFFER_SIZE]; - int bytesRead = 0; - totalBytes = 0; - try { - while ((bytesRead = in.read(buffer)) > 0) { - out.write(buffer, 0, bytesRead); - totalBytes += bytesRead; - if (contentLength > 0 - && (progressListeners != null || progressListener != null)) { - // update progress if listener set and contentLength - // received - synchronized (application) { - fireUpdateProgress(totalBytes, contentLength); - } - } - if (interrupted) { - throw new UploadInterruptedException(); - } - } - - // upload successful - out.close(); - synchronized (application) { - fireUploadSuccess(filename, type, totalBytes); - endUpload(); - requestRepaint(); - } - - } catch (final Exception e) { - synchronized (application) { - if (e instanceof UploadInterruptedException) { - // Download interrupted - try { - // still try to close output stream - out.close(); - } catch (IOException e1) { - // NOP - } - } - fireUploadInterrupted(filename, type, totalBytes, e); - endUpload(); - interrupted = false; - if (!(e instanceof UploadInterruptedException)) { - // throw exception for terminal to be handled - throw new UploadException(e); - } - } - } - } - - /** * Invoked when the value of a variable has changed. * * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, * java.util.Map) */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { if (variables.containsKey("pollForStart")) { int id = (Integer) variables.get("pollForStart"); if (!isUploading && id == nextid) { @@ -278,6 +159,9 @@ public class Upload extends AbstractComponent implements Component.Focusable { target.addAttribute("nextid", nextid); + // Post file to this strean variable + target.addVariable(this, "action", getStreamVariable()); + } /** @@ -290,18 +174,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @since 3.0 */ public interface Receiver extends Serializable { - - /** - * Invoked when a new upload arrives. - * - * @param filename - * the desired filename of the upload, usually as specified - * by the client. - * @param MIMEType - * the MIME type of the uploaded file. - * @return Stream to which the uploaded file should be written. - */ - public OutputStream receiveUpload(String filename, String MIMEType); + public OutputStream receiveUpload(String filename, String mimetype); } /* Upload events */ @@ -332,19 +205,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { } } - private class UploadInterruptedException extends Exception { - public UploadInterruptedException() { - super("Upload interrupted by other thread"); - } - - } - - public static class UploadException extends Exception { - public UploadException(Exception e) { - super("Upload failed", e); - } - } - /** * Upload.Received event is sent when the upload receives a file, regardless * of whether the reception was successful or failed. If you wish to @@ -356,7 +216,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public class FinishedEvent extends Component.Event { + public static class FinishedEvent extends Component.Event { /** * Length of the received file. @@ -439,7 +299,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public class FailedEvent extends FinishedEvent { + public static class FailedEvent extends FinishedEvent { private Exception reason = null; @@ -484,7 +344,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { /** * FailedEvent that indicates that an output stream could not be obtained. */ - public class NoOutputStreamEvent extends FailedEvent { + public static class NoOutputStreamEvent extends FailedEvent { /** * @@ -502,7 +362,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { /** * FailedEvent that indicates that an input stream could not be obtained. */ - public class NoInputStreamEvent extends FailedEvent { + public static class NoInputStreamEvent extends FailedEvent { /** * @@ -526,7 +386,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public class SucceededEvent extends FinishedEvent { + public static class SucceededEvent extends FinishedEvent { /** * @@ -550,10 +410,14 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 5.0 */ - public class StartedEvent extends Component.Event { + public static class StartedEvent extends Component.Event { private final String filename; private final String type; + /** + * Length of the received file. + */ + private final long length; /** * @@ -562,10 +426,12 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @param MIMEType * @param length */ - public StartedEvent(Upload source, String filename, String MIMEType) { + public StartedEvent(Upload source, String filename, String MIMEType, + long contentLength) { super(source); this.filename = filename; type = MIMEType; + length = contentLength; } /** @@ -595,6 +461,13 @@ public class Upload extends AbstractComponent implements Component.Focusable { return type; } + /** + * @return the length of the file that is being uploaded + */ + public long getContentLength() { + return length; + } + } /** @@ -786,19 +659,8 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @param length */ protected void fireStarted(String filename, String MIMEType) { - fireEvent(new Upload.StartedEvent(this, filename, MIMEType)); - } - - /** - * Emit upload finished event. - * - * @param filename - * @param MIMEType - * @param length - */ - protected void fireUploadReceived(String filename, String MIMEType, - long length) { - fireEvent(new Upload.FinishedEvent(this, filename, MIMEType, length)); + fireEvent(new Upload.StartedEvent(this, filename, MIMEType, + contentLength)); } /** @@ -862,16 +724,12 @@ public class Upload extends AbstractComponent implements Component.Focusable { l.updateProgress(totalBytes, contentLength); } } - // deprecated: - if (progressListener != null) { - progressListener.updateProgress(totalBytes, contentLength); - } } /** * Returns the current receiver. * - * @return the Receiver. + * @return the StreamVariable. */ public Receiver getReceiver() { return receiver; @@ -914,15 +772,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { } /** - * Sets the size of the file currently being uploaded. - * - * @param contentLength - */ - public void setUploadSize(long contentLength) { - this.contentLength = contentLength; - } - - /** * Go into upload state. This is to prevent double uploading on same * component. * @@ -959,6 +808,8 @@ public class Upload extends AbstractComponent implements Component.Focusable { private void endUpload() { isUploading = false; contentLength = -1; + interrupted = false; + requestRepaint(); } public boolean isUploading() { @@ -992,7 +843,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ @Deprecated public void setProgressListener(ProgressListener progressListener) { - this.progressListener = progressListener; + addListener(progressListener); } /** @@ -1004,7 +855,11 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ @Deprecated public ProgressListener getProgressListener() { - return progressListener; + if (progressListeners == null || progressListeners.isEmpty()) { + return null; + } else { + return progressListeners.iterator().next(); + } } /** @@ -1046,4 +901,70 @@ public class Upload extends AbstractComponent implements Component.Focusable { this.buttonCaption = buttonCaption; } + /* + * Handle to terminal via Upload monitors and controls the upload during it + * is being streamed. + */ + private com.vaadin.terminal.StreamVariable streamVariable; + + protected com.vaadin.terminal.StreamVariable getStreamVariable() { + if (streamVariable == null) { + streamVariable = new com.vaadin.terminal.StreamVariable() { + private StreamingStartEvent lastStartedEvent; + + public boolean listenProgress() { + return (progressListeners != null && !progressListeners + .isEmpty()); + } + + public void onProgress(StreamingProgressEvent event) { + fireUpdateProgress(event.getBytesReceived(), + event.getContentLength()); + } + + public boolean isInterrupted() { + return interrupted; + } + + public OutputStream getOutputStream() { + OutputStream receiveUpload = receiver.receiveUpload( + lastStartedEvent.getFileName(), + lastStartedEvent.getMimeType()); + lastStartedEvent = null; + return receiveUpload; + } + + public void streamingStarted(StreamingStartEvent event) { + startUpload(); + contentLength = event.getContentLength(); + fireStarted(event.getFileName(), event.getMimeType()); + lastStartedEvent = event; + } + + public void streamingFinished(StreamingEndEvent event) { + fireUploadSuccess(event.getFileName(), event.getMimeType(), + event.getContentLength()); + endUpload(); + requestRepaint(); + } + + public void streamingFailed(StreamingErrorEvent event) { + Exception exception = event.getException(); + if (exception instanceof NoInputStreamException) { + fireNoInputStream(event.getFileName(), + event.getMimeType(), 0); + } else if (exception instanceof NoOutputStreamException) { + fireNoOutputStream(event.getFileName(), + event.getMimeType(), 0); + } else { + fireUploadInterrupted(event.getFileName(), + event.getMimeType(), 0, exception); + } + endUpload(); + } + }; + } + return streamVariable; + } + } diff --git a/src/com/vaadin/ui/UriFragmentUtility.java b/src/com/vaadin/ui/UriFragmentUtility.java index 7835dcf90e..de21aff9ea 100644 --- a/src/com/vaadin/ui/UriFragmentUtility.java +++ b/src/com/vaadin/ui/UriFragmentUtility.java @@ -96,7 +96,7 @@ public class UriFragmentUtility extends AbstractComponent { } @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { super.changeVariables(source, variables); fragment = (String) variables.get("fragment"); fireEvent(new FragmentChangedEvent(this)); diff --git a/src/com/vaadin/ui/VerticalSplitPanel.java b/src/com/vaadin/ui/VerticalSplitPanel.java new file mode 100644 index 0000000000..6afc66920f --- /dev/null +++ b/src/com/vaadin/ui/VerticalSplitPanel.java @@ -0,0 +1,28 @@ +package com.vaadin.ui; + +import com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical; + +/** + * A vertical split panel contains two components and lays them vertically. The + * first component is above the second component. + * + * <pre> + * +--------------------------+ + * | | + * | The first component | + * | | + * +==========================+ <-- splitter + * | | + * | The second component | + * | | + * +--------------------------+ + * </pre> + * + */ +@ClientWidget(VSplitPanelVertical.class) +public class VerticalSplitPanel extends SplitPanel { + @SuppressWarnings("deprecation") + public VerticalSplitPanel() { + super(ORIENTATION_VERTICAL); + } +} diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 8e407fe5ad..1ce4af154f 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -1042,7 +1042,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * @see com.vaadin.ui.Panel#changeVariables(java.lang.Object, java.util.Map) */ @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, Map<String, Object> variables) { boolean sizeHasChanged = false; // size is handled in super class, but resize events only in windows -> @@ -1102,11 +1102,9 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * </p> * * <p> - * If one wants change the default behavior, register a window close - * listenter and do something else. For example, you could re-open the - * browser-level window with mainWindow.open(), re-add the removed - * sub-window back to its parent or remove browser-level window - * automatically from the application. + * To explicitly close a sub-window, use {@link #removeWindow(Window)}. To + * react to a window being closed (after it is closed), register a + * {@link CloseListener}. * </p> */ protected void close() { @@ -1116,7 +1114,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler { } else { // subwindow is removed from parent parent.removeWindow(this); - fireClose(); } } @@ -1250,8 +1247,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * user closes the window. * * <p> - * Note that removing windows using {@link #removeWindow(Window)} will not - * fire the CloseListener. + * Since Vaadin 6.5, removing windows using {@link #removeWindow(Window)} + * does fire the CloseListener. * </p> */ public interface CloseListener extends Serializable { @@ -1277,8 +1274,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * mean it will be destroyed. * * <p> - * Note that removing windows using {@link #removeWindow(Window)} will not - * fire the CloseListener. + * Since Vaadin 6.5, removing windows using {@link #removeWindow(Window)} + * does fire the CloseListener. * </p> * * @param listener @@ -1431,14 +1428,26 @@ public class Window extends Panel implements URIHandler, ParameterHandler { /** * Remove the given subwindow from this window. * + * Since Vaadin 6.5, {@link CloseListener}s are called also when explicitly + * removing a window by calling this method. + * + * Since Vaadin 6.5, returns a boolean indicating if the window was removed + * or not. + * * @param window * Window to be removed. + * @return true if the subwindow was removed, false otherwise */ - public void removeWindow(Window window) { - subwindows.remove(window); + public boolean removeWindow(Window window) { + if (!subwindows.remove(window)) { + // Window window is not a subwindow of this window. + return false; + } window.setParent(null); + window.fireClose(); requestRepaint(); + return true; } /** diff --git a/tests/src/com/vaadin/tests/BasicRandomTest.java b/tests/src/com/vaadin/tests/BasicRandomTest.java index 8b5a9d01ab..ad961a60c6 100644 --- a/tests/src/com/vaadin/tests/BasicRandomTest.java +++ b/tests/src/com/vaadin/tests/BasicRandomTest.java @@ -13,12 +13,13 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -44,7 +45,6 @@ import com.vaadin.ui.Window; * @author IT Mill Ltd. * */ -@SuppressWarnings("unchecked") public class BasicRandomTest extends com.vaadin.Application implements Button.ClickListener { @@ -56,7 +56,7 @@ public class BasicRandomTest extends com.vaadin.Application implements private static int COMPONENT_MAX_GROUPED_NUMBER = 5; - private final OrderedLayout mainLayout = new OrderedLayout(); + private final VerticalLayout mainLayout = new VerticalLayout(); private Layout testingLayout; @@ -78,7 +78,7 @@ public class BasicRandomTest extends com.vaadin.Application implements private long captionCounter = 0; - private ArrayList components; + private ArrayList<Component> components; private long eventCounter = 0; @@ -86,7 +86,7 @@ public class BasicRandomTest extends com.vaadin.Application implements // Store button object => real value map // needed because button captions are randomized - private HashMap buttonValues; + private HashMap<Button, String> buttonValues; private RandomComponents randomComponents; @@ -124,10 +124,9 @@ public class BasicRandomTest extends com.vaadin.Application implements + "through X buttons and ensure that Result label " + "contains correct value.", Label.CONTENT_XHTML)); - final OrderedLayout setupLayout = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final HorizontalLayout setupLayout = new HorizontalLayout(); final Panel statusPanel = new Panel("Status"); - statusPanel.setWidth(200); + statusPanel.setWidth("200px"); setupLayout.addComponent(statusPanel); statusPanel.addComponent(statusLabel); setupLayout.addComponent(randomSeedValue); @@ -191,7 +190,7 @@ public class BasicRandomTest extends com.vaadin.Application implements // // Create components that have UUID defined // - components = new ArrayList(); + components = new ArrayList<Component>(); // create label final Label userLabel = new Label("user"); @@ -213,7 +212,7 @@ public class BasicRandomTest extends com.vaadin.Application implements "minus", "multiple", "divisor", "equals", "clear" } }; // final String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" }; // String[] randomizedCaptions = { "X" }; - buttonValues = new HashMap(); + buttonValues = new HashMap<Button, String>(); for (int i = 0; i > calcValues[0].length; i++) { final Button button = new Button("", this); // Test requirement: ATF must not rely on caption @@ -244,7 +243,7 @@ public class BasicRandomTest extends com.vaadin.Application implements if (components.size() > 0) { // components found, return any final int i = rand.nextInt(components.size()); - final Component c = (Component) components.get(i); + final Component c = components.get(i); components.remove(i); return c; } else { @@ -287,7 +286,7 @@ public class BasicRandomTest extends com.vaadin.Application implements } public void buttonClick(Button.ClickEvent event) { - final String value = (String) buttonValues.get(event.getButton()); + final String value = buttonValues.get(event.getButton()); eventCounter++; try { // Number button pressed diff --git a/tests/src/com/vaadin/tests/LayoutDemo.java b/tests/src/com/vaadin/tests/LayoutDemo.java index 1cdf4de298..a06e7e4da2 100644 --- a/tests/src/com/vaadin/tests/LayoutDemo.java +++ b/tests/src/com/vaadin/tests/LayoutDemo.java @@ -8,11 +8,12 @@ import com.vaadin.terminal.ClassResource; import com.vaadin.ui.Component; import com.vaadin.ui.Embedded; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -36,16 +37,14 @@ public class LayoutDemo extends com.vaadin.Application { // // Create horizontal ordered layout // - final OrderedLayout layoutA = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final HorizontalLayout layoutA = new HorizontalLayout(); // Add 4 panels fillLayout(layoutA, 4); // // Create vertical ordered layout // - final OrderedLayout layoutB = new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL); + final VerticalLayout layoutB = new VerticalLayout(); // Add 4 panels fillLayout(layoutB, 4); @@ -113,7 +112,7 @@ public class LayoutDemo extends com.vaadin.Application { // loads image from package com.vaadin.demo final ClassResource cr = new ClassResource("m-bullet-blue.gif", this); final Embedded em = new Embedded("Embedded " + caption, cr); - em.setWidth(170); + em.setWidth("170px"); return em; } @@ -126,7 +125,7 @@ public class LayoutDemo extends com.vaadin.Application { + " Panel contains an layout where the actual contained components are added, " + "this layout may be switched on the fly.", Label.CONTENT_XHTML)); - panel.setWidth(222); + panel.setWidth("222px"); return panel; } diff --git a/tests/src/com/vaadin/tests/ListenerOrder.java b/tests/src/com/vaadin/tests/ListenerOrder.java index 3b7329c384..c1d6245222 100644 --- a/tests/src/com/vaadin/tests/ListenerOrder.java +++ b/tests/src/com/vaadin/tests/ListenerOrder.java @@ -24,7 +24,7 @@ public class ListenerOrder extends com.vaadin.Application implements Select s1; - HashMap buttonListeners = new HashMap(); + HashMap<String, Integer> buttonListeners = new HashMap<String, Integer>(); @Override public void init() { @@ -88,7 +88,7 @@ public class ListenerOrder extends com.vaadin.Application implements s1.addListener((ValueChangeListener) this); Item i = s1.getItem("second"); - for (Iterator it = i.getItemPropertyIds().iterator(); it.hasNext();) { + for (Iterator<?> it = i.getItemPropertyIds().iterator(); it.hasNext();) { Object o = it.next(); System.out.println("[" + o + "]"); } @@ -119,7 +119,7 @@ public class ListenerOrder extends com.vaadin.Application implements public MyClickListener(String name) { Integer count = null; try { - count = (Integer) buttonListeners.get(name); + count = buttonListeners.get(name); count = new Integer(count.intValue() + 1); buttonListeners.put(name, count); } catch (Exception e) { diff --git a/tests/src/com/vaadin/tests/NativeWindowing.java b/tests/src/com/vaadin/tests/NativeWindowing.java index e1cf608763..877aeceae1 100644 --- a/tests/src/com/vaadin/tests/NativeWindowing.java +++ b/tests/src/com/vaadin/tests/NativeWindowing.java @@ -30,11 +30,11 @@ public class NativeWindowing extends Application { main.addWindow(w); w.setPositionX(100); w.setPositionY(100); - w.setWidth(200); - w.setHeight(200); + w.setWidth("200px"); + w.setHeight("200px"); - w.setWidth(100); - w.setHeight(400); + w.setWidth("100px"); + w.setHeight("400px"); final Button closebutton = new Button("Close " + w.getCaption(), new Button.ClickListener() { diff --git a/tests/src/com/vaadin/tests/OrderedLayoutSwapComponents.java b/tests/src/com/vaadin/tests/OrderedLayoutSwapComponents.java index 1c21cb25bd..34ec439010 100644 --- a/tests/src/com/vaadin/tests/OrderedLayoutSwapComponents.java +++ b/tests/src/com/vaadin/tests/OrderedLayoutSwapComponents.java @@ -6,11 +6,13 @@ package com.vaadin.tests; import java.util.ArrayList; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; /** * @@ -21,13 +23,13 @@ import com.vaadin.ui.OrderedLayout; */ public class OrderedLayoutSwapComponents extends CustomComponent { - private final OrderedLayout main; + private final AbstractOrderedLayout main; - ArrayList order = new ArrayList(); + ArrayList<MyComponent> order = new ArrayList<MyComponent>(); public OrderedLayoutSwapComponents() { - main = new OrderedLayout(); + main = new VerticalLayout(); // main.setSizeFull(); setCompositionRoot(main); createNewView(); @@ -53,15 +55,14 @@ public class OrderedLayoutSwapComponents extends CustomComponent { private Button down; MyComponent(String name) { - OrderedLayout ol = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout ol = new HorizontalLayout(); ol.setDebugId(name.replaceAll(" ", "")); ol.addComponent(new Label(name)); up = new Button("up"); up.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { int newIndex = order.indexOf(MyComponent.this) - 1; - MyComponent old = (MyComponent) order.get(newIndex); + MyComponent old = order.get(newIndex); main.replaceComponent(old, MyComponent.this); order.remove(MyComponent.this); order.add(newIndex, MyComponent.this); @@ -78,7 +79,7 @@ public class OrderedLayoutSwapComponents extends CustomComponent { down.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { int newIndex = order.indexOf(MyComponent.this) + 1; - MyComponent old = (MyComponent) order.get(newIndex); + MyComponent old = order.get(newIndex); main.replaceComponent(old, MyComponent.this); order.remove(MyComponent.this); order.add(newIndex, MyComponent.this); diff --git a/tests/src/com/vaadin/tests/Parameters.java b/tests/src/com/vaadin/tests/Parameters.java index bb026a8955..34b32a8808 100644 --- a/tests/src/com/vaadin/tests/Parameters.java +++ b/tests/src/com/vaadin/tests/Parameters.java @@ -12,11 +12,12 @@ import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.ParameterHandler; import com.vaadin.terminal.URIHandler; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -36,7 +37,6 @@ public class Parameters extends com.vaadin.Application implements URIHandler, private final Table params = new Table(); @Override - @SuppressWarnings("deprecation") public void init() { final Window main = new Window("Parameters demo"); setMainWindow(main); @@ -45,7 +45,7 @@ public class Parameters extends com.vaadin.Application implements URIHandler, main.addURIHandler(this); main.addParameterHandler(this); - final ExpandLayout layout = new ExpandLayout(); + final VerticalLayout layout = new VerticalLayout(); final Label info = new Label("To test URI and Parameter Handlers, " + "add get parameters to URL. For example try examples below: "); info.setCaption("Usage info"); @@ -76,20 +76,20 @@ public class Parameters extends com.vaadin.Application implements URIHandler, params.addContainerProperty("Value", String.class, ""); final Panel panel2 = new Panel("Parameter Handler"); params.setSizeFull(); - panel2.setLayout(new ExpandLayout()); - panel2.getLayout().setMargin(true); + panel2.setContent(new VerticalLayout()); + ((Layout) panel2.getContent()).setMargin(true); params.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID); panel2.addComponent(params); layout.addComponent(panel2); // expand parameter panel and its table - layout.expand(panel2); + layout.setExpandRatio(panel2, 1); layout.setMargin(true); layout.setSpacing(true); - main.setLayout(layout); + main.setContent(layout); } /** @@ -108,11 +108,12 @@ public class Parameters extends com.vaadin.Application implements URIHandler, * Handles GET parameters, in this demo GET parameteres are used to * communicate with EmbeddedToolkit.jsp */ - public void handleParameters(Map parameters) { + public void handleParameters(Map<String, String[]> parameters) { params.removeAllItems(); - for (final Iterator i = parameters.keySet().iterator(); i.hasNext();) { - final String name = (String) i.next(); - final String[] values = (String[]) parameters.get(name); + for (final Iterator<String> i = parameters.keySet().iterator(); i + .hasNext();) { + final String name = i.next(); + final String[] values = parameters.get(name); String v = ""; for (int j = 0; j < values.length; j++) { if (v.length() > 0) { diff --git a/tests/src/com/vaadin/tests/PerformanceTestBasicComponentRendering.java b/tests/src/com/vaadin/tests/PerformanceTestBasicComponentRendering.java index be0e64dd79..7258df1879 100644 --- a/tests/src/com/vaadin/tests/PerformanceTestBasicComponentRendering.java +++ b/tests/src/com/vaadin/tests/PerformanceTestBasicComponentRendering.java @@ -13,16 +13,16 @@ import com.vaadin.ui.ComboBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.DateField; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class PerformanceTestBasicComponentRendering extends CustomComponent { - private final OrderedLayout main; + private final VerticalLayout main; - private final OrderedLayout testContainer; + private final VerticalLayout testContainer; private Date startTime; @@ -34,21 +34,22 @@ public class PerformanceTestBasicComponentRendering extends CustomComponent { public PerformanceTestBasicComponentRendering() { - main = new OrderedLayout(); + main = new VerticalLayout(); setCompositionRoot(main); addInfo(); result = new Label(); main.addComponent(result); - testContainer = new OrderedLayout(); + testContainer = new VerticalLayout(); final Table t = TestForTablesInitialColumnWidthLogicRendering .getTestTable(5, 200); Table t2 = new Table("Test Table with 199 rows rendered initially") { @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, + Map<String, Object> variables) { super.changeVariables(source, variables); // end timing on cache row request endTest(); diff --git a/tests/src/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java b/tests/src/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java index f5dcc43d5e..ff2ed51c57 100644 --- a/tests/src/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java +++ b/tests/src/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java @@ -6,17 +6,18 @@ package com.vaadin.tests; import java.util.Date; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { - private final OrderedLayout main; + private final AbstractOrderedLayout main; - private final OrderedLayout testContainer; + private final AbstractOrderedLayout testContainer; private Date startTime; @@ -27,7 +28,7 @@ public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { private static final int INITIAL_COMPONENTS = 1000; public PerformanceTestLabelsAndOrderedLayouts() { - main = new OrderedLayout(); + main = new VerticalLayout(); setCompositionRoot(main); addInfo(); @@ -50,7 +51,7 @@ public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { } })); - testContainer = new OrderedLayout(); + testContainer = new VerticalLayout(); for (int i = 0; i < INITIAL_COMPONENTS; i++) { Label l = new Label("foo" + i); diff --git a/tests/src/com/vaadin/tests/PerformanceTestSubTreeCaching.java b/tests/src/com/vaadin/tests/PerformanceTestSubTreeCaching.java index 8d39562101..a746ed45bf 100644 --- a/tests/src/com/vaadin/tests/PerformanceTestSubTreeCaching.java +++ b/tests/src/com/vaadin/tests/PerformanceTestSubTreeCaching.java @@ -9,14 +9,14 @@ import java.util.Date; import com.vaadin.ui.Button; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; public class PerformanceTestSubTreeCaching extends CustomComponent { - private final OrderedLayout main; + private final VerticalLayout main; - private final OrderedLayout testContainer; + private final VerticalLayout testContainer; private Date startTime; @@ -32,7 +32,7 @@ public class PerformanceTestSubTreeCaching extends CustomComponent { private static final int INITIAL_COMPONENTS = 40; public PerformanceTestSubTreeCaching() { - main = new OrderedLayout(); + main = new VerticalLayout(); setCompositionRoot(main); addInfo(); @@ -46,7 +46,7 @@ public class PerformanceTestSubTreeCaching extends CustomComponent { result = new Label(); main.addComponent(result); - testContainer = new OrderedLayout(); + testContainer = new VerticalLayout(); populateContainer(testContainer, INITIAL_COMPONENTS); main.addComponent(testContainer); } @@ -67,7 +67,7 @@ public class PerformanceTestSubTreeCaching extends CustomComponent { * * @param testContainer2 */ - private void populateContainer(OrderedLayout container, int n) { + private void populateContainer(VerticalLayout container, int n) { for (int i = 0; i < n; i++) { // array_type array_element = [i]; final Table t = TestForTablesInitialColumnWidthLogicRendering diff --git a/tests/src/com/vaadin/tests/RandomLayoutStress.java b/tests/src/com/vaadin/tests/RandomLayoutStress.java index 327e34418e..7e4daa47dc 100644 --- a/tests/src/com/vaadin/tests/RandomLayoutStress.java +++ b/tests/src/com/vaadin/tests/RandomLayoutStress.java @@ -12,14 +12,15 @@ import com.vaadin.ui.Button; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.DateField; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -53,8 +54,7 @@ public class RandomLayoutStress extends com.vaadin.Application { // Create horizontal ordered layout final Panel panelA = new Panel( "Panel containing horizontal ordered layout"); - OrderedLayout layoutA = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout layoutA = new HorizontalLayout(); // Add 4 random components fillLayout(layoutA, componentCountA); // Add layout to panel @@ -63,8 +63,7 @@ public class RandomLayoutStress extends com.vaadin.Application { // Create vertical ordered layout final Panel panelB = new Panel( "Panel containing vertical ordered layout"); - OrderedLayout layoutB = new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL); + VerticalLayout layoutB = new VerticalLayout(); // Add 4 random components fillLayout(layoutB, componentCountB); // Add layout to panel @@ -83,11 +82,11 @@ public class RandomLayoutStress extends com.vaadin.Application { // Create TabSheet final TabSheet tabsheet = new TabSheet(); tabsheet.setCaption("Tabsheet, above layouts are added to this component"); - layoutA = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); + layoutA = new HorizontalLayout(); // Add 4 random components fillLayout(layoutA, componentCountA); tabsheet.addTab(layoutA, "Horizontal ordered layout", null); - layoutB = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); + layoutB = new VerticalLayout(); // Add 4 random components fillLayout(layoutB, componentCountB); tabsheet.addTab(layoutB, "Vertical ordered layout", null); @@ -154,7 +153,7 @@ public class RandomLayoutStress extends com.vaadin.Application { + "extremities and may have a caption to clarify the nature of the contained components' purpose." + " Panel contains an layout where the actual contained components are added, " + "this layout may be switched on the fly.")); - ((Panel) result).setWidth(250); + ((Panel) result).setWidth("250px"); break; case 6: // Datefield diff --git a/tests/src/com/vaadin/tests/ScrollbarStressTest.java b/tests/src/com/vaadin/tests/ScrollbarStressTest.java index d7b8cdd8bf..b2ea3dbf3d 100644 --- a/tests/src/com/vaadin/tests/ScrollbarStressTest.java +++ b/tests/src/com/vaadin/tests/ScrollbarStressTest.java @@ -14,6 +14,7 @@ import com.vaadin.ui.SplitPanel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; public class ScrollbarStressTest extends Application { @@ -21,7 +22,7 @@ public class ScrollbarStressTest extends Application { final Window main = new Window("Scrollbar Stress Test"); final Panel panel = new Panel("Panel"); - final SplitPanel splitPanel = new SplitPanel(); + final SplitPanel splitPanel = new VerticalSplitPanel(); final Accordion accordion = new Accordion(); final TabSheet tabsheet = new TabSheet(); final Window subwindow = new Window("Subwindow"); diff --git a/tests/src/com/vaadin/tests/StressComponentsInTable.java b/tests/src/com/vaadin/tests/StressComponentsInTable.java index 790d01ec71..75b4916b37 100644 --- a/tests/src/com/vaadin/tests/StressComponentsInTable.java +++ b/tests/src/com/vaadin/tests/StressComponentsInTable.java @@ -10,13 +10,13 @@ import java.util.Vector; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
public class StressComponentsInTable extends CustomComponent {
public StressComponentsInTable() {
- final OrderedLayout main = new OrderedLayout();
+ final VerticalLayout main = new VerticalLayout();
setCompositionRoot(main);
main.addComponent(getTestTable(4, 1000));
@@ -31,7 +31,7 @@ public class StressComponentsInTable extends CustomComponent { }
t.addContainerProperty("button", Button.class, null);
for (int i = 0; i < rows; i++) {
- final Vector content = new Vector();
+ final Vector<Object> content = new Vector<Object>();
for (int j = 0; j < cols; j++) {
content.add(rndString());
}
@@ -40,7 +40,7 @@ public class StressComponentsInTable extends CustomComponent { public void buttonClick(ClickEvent event) {
Button b = event.getButton();
System.out.println(b.getCaption() + " click: "
- + (new Date()).toGMTString());
+ + (new Date()).toString());
System.out.println(b.getApplication());
}
diff --git a/tests/src/com/vaadin/tests/TableChangingDatasource.java b/tests/src/com/vaadin/tests/TableChangingDatasource.java index 722fd48d01..2b9639b32d 100644 --- a/tests/src/com/vaadin/tests/TableChangingDatasource.java +++ b/tests/src/com/vaadin/tests/TableChangingDatasource.java @@ -9,8 +9,8 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
public class TableChangingDatasource extends CustomComponent implements
ClickListener {
@@ -19,15 +19,15 @@ public class TableChangingDatasource extends CustomComponent implements private int mode = 0;
public TableChangingDatasource() {
- final OrderedLayout main = new OrderedLayout();
+ final VerticalLayout main = new VerticalLayout();
main.addComponent(new Label(
"Table should look sane after data source changes"));
t = new Table();
- t.setWidth(500);
- t.setHeight(300);
+ t.setWidth("500px");
+ t.setHeight("300px");
ta[0] = TestForTablesInitialColumnWidthLogicRendering
.getTestTable(3, 0);
diff --git a/tests/src/com/vaadin/tests/TableSelectTest.java b/tests/src/com/vaadin/tests/TableSelectTest.java index 69363bd0bc..d5196d2a2a 100644 --- a/tests/src/com/vaadin/tests/TableSelectTest.java +++ b/tests/src/com/vaadin/tests/TableSelectTest.java @@ -7,14 +7,14 @@ package com.vaadin.tests; import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
public class TableSelectTest extends CustomComponent implements
Table.ValueChangeListener {
public TableSelectTest() {
- final OrderedLayout main = new OrderedLayout();
+ final VerticalLayout main = new VerticalLayout();
setCompositionRoot(main);
main.addComponent(new Label("Hello World!"));
diff --git a/tests/src/com/vaadin/tests/TestBench.java b/tests/src/com/vaadin/tests/TestBench.java index a670d40708..510d03624d 100644 --- a/tests/src/com/vaadin/tests/TestBench.java +++ b/tests/src/com/vaadin/tests/TestBench.java @@ -18,6 +18,7 @@ import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; @@ -45,20 +46,21 @@ public class TestBench extends com.vaadin.Application implements // Add here packages which are used for finding testable classes String[] testablePackages = { "com.vaadin.tests", "com.vaadin.demo", "com.vaadin.demo.colorpicker", "com.vaadin.demo.features", - "com.vaadin.tests.tickets", "com.vaadin.tests.book" }; + "com.vaadin.tests.tickets" }; HierarchicalContainer testables = new HierarchicalContainer(); Window mainWindow = new Window("TestBench window"); // Main layout consists of tree menu and body layout - SplitPanel mainLayout = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + SplitPanel mainLayout = new HorizontalSplitPanel(); Tree menu; Panel bodyLayout = new Panel(); - HashMap itemCaptions = new HashMap(); + // TODO this could probably be a simple Set + HashMap<Class<?>, String> itemCaptions = new HashMap<Class<?>, String>(); @Override public void init() { @@ -67,10 +69,10 @@ public class TestBench extends com.vaadin.Application implements for (int p = 0; p < testablePackages.length; p++) { testables.addItem(testablePackages[p]); try { - final List testableClasses = getTestableClassesForPackage(testablePackages[p]); - for (final Iterator it = testableClasses.iterator(); it + final List<Class<?>> testableClasses = getTestableClassesForPackage(testablePackages[p]); + for (final Iterator<Class<?>> it = testableClasses.iterator(); it .hasNext();) { - final Class t = (Class) it.next(); + final Class<?> t = it.next(); // ignore TestBench itself if (t.equals(TestBench.class)) { continue; @@ -100,15 +102,16 @@ public class TestBench extends com.vaadin.Application implements menu = new Tree("Testables", testables); - for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) { - final Class testable = (Class) i.next(); + for (final Iterator<Class<?>> i = itemCaptions.keySet().iterator(); i + .hasNext();) { + final Class<?> testable = i.next(); // simplify captions final String name = testable.getName().substring( testable.getName().lastIndexOf('.') + 1); menu.setItemCaption(testable, name); } // expand all root items - for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) { + for (final Iterator<?> i = menu.rootItemIds().iterator(); i.hasNext();) { menu.expandItemsRecursively(i.next()); } @@ -128,11 +131,11 @@ public class TestBench extends com.vaadin.Application implements // try to find a proper test class // exact match - Iterator iterator = menu.getItemIds().iterator(); + Iterator<?> iterator = menu.getItemIds().iterator(); while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof Class) { - Class c = (Class) next; + Class<?> c = (Class<?>) next; String string = c.getName(); if (string.equals(fragment)) { menu.setValue(c); @@ -147,7 +150,7 @@ public class TestBench extends com.vaadin.Application implements while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof Class) { - Class c = (Class) next; + Class<?> c = (Class<?>) next; String string = c.getSimpleName(); if (string.equals(fragment)) { menu.setValue(c); @@ -161,7 +164,7 @@ public class TestBench extends com.vaadin.Application implements while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof Class) { - Class c = (Class) next; + Class<?> c = (Class<?>) next; String string = c.getSimpleName(); if (string.startsWith("Ticket" + fragment)) { menu.setValue(c); @@ -176,7 +179,7 @@ public class TestBench extends com.vaadin.Application implements while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof Class) { - Class c = (Class) next; + Class<?> c = (Class<?>) next; String string = c.getSimpleName(); if (string.toLowerCase().contains( fragment.toLowerCase())) { @@ -210,11 +213,11 @@ public class TestBench extends com.vaadin.Application implements setMainWindow(mainWindow); } - private Component createTestable(Class c) { + private Component createTestable(Class<?> c) { try { final Application app = (Application) c.newInstance(); app.init(); - Layout lo = app.getMainWindow().getLayout(); + Layout lo = (Layout) app.getMainWindow().getContent(); lo.setParent(null); return lo; } catch (final Exception e) { @@ -245,7 +248,7 @@ public class TestBench extends com.vaadin.Application implements final Object o = menu.getValue(); if (o != null && o instanceof Class) { - final Class c = (Class) o; + final Class<?> c = (Class<?>) o; final String title = c.getName(); bodyLayout.setCaption(title); bodyLayout.addComponent(createTestable(c)); @@ -262,9 +265,9 @@ public class TestBench extends com.vaadin.Application implements * @return * @throws ClassNotFoundException */ - public static List getTestableClassesForPackage(String packageName) + public static List<Class<?>> getTestableClassesForPackage(String packageName) throws Exception { - final ArrayList directories = new ArrayList(); + final ArrayList<File> directories = new ArrayList<File>(); try { final ClassLoader cld = Thread.currentThread() .getContextClassLoader(); @@ -273,9 +276,9 @@ public class TestBench extends com.vaadin.Application implements } final String path = packageName.replace('.', '/'); // Ask for all resources for the path - final Enumeration resources = cld.getResources(path); + final Enumeration<URL> resources = cld.getResources(path); while (resources.hasMoreElements()) { - final URL url = (URL) resources.nextElement(); + final URL url = resources.nextElement(); directories.add(new File(url.getFile())); } } catch (final Exception x) { @@ -283,10 +286,10 @@ public class TestBench extends com.vaadin.Application implements + " does not appear to be a valid package."); } - final ArrayList classes = new ArrayList(); + final ArrayList<Class<?>> classes = new ArrayList<Class<?>>(); // For every directory identified capture all the .class files - for (final Iterator it = directories.iterator(); it.hasNext();) { - final File directory = (File) it.next(); + for (final Iterator<File> it = directories.iterator(); it.hasNext();) { + final File directory = it.next(); if (directory.exists()) { // Get the list of the files contained in the package final String[] files = directory.list(); @@ -296,7 +299,7 @@ public class TestBench extends com.vaadin.Application implements // removes the .class extension final String p = packageName + '.' + files[j].substring(0, files[j].length() - 6); - final Class c = Class.forName(p); + final Class<?> c = Class.forName(p); if (c.getSuperclass() != null) { if ((c.getSuperclass() .equals(com.vaadin.Application.class))) { diff --git a/tests/src/com/vaadin/tests/TestComponentAddAndRecursion.java b/tests/src/com/vaadin/tests/TestComponentAddAndRecursion.java index a63575e177..5203a7055f 100644 --- a/tests/src/com/vaadin/tests/TestComponentAddAndRecursion.java +++ b/tests/src/com/vaadin/tests/TestComponentAddAndRecursion.java @@ -8,8 +8,8 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
/**
@@ -25,7 +25,7 @@ public class TestComponentAddAndRecursion extends CustomComponent { public TestComponentAddAndRecursion() {
- OrderedLayout main = new OrderedLayout();
+ VerticalLayout main = new VerticalLayout();
setCompositionRoot(main);
l = new Label("A");
@@ -43,9 +43,9 @@ public class TestComponentAddAndRecursion extends CustomComponent { Button b = new Button("use gridlayout", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- p.setLayout(new GridLayout());
- p2.setLayout(new GridLayout());
- p3.setLayout(new GridLayout());
+ p.setContent(new GridLayout());
+ p2.setContent(new GridLayout());
+ p3.setContent(new GridLayout());
}
});
@@ -53,9 +53,9 @@ public class TestComponentAddAndRecursion extends CustomComponent { b = new Button("use orderedlayout", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- p.setLayout(new OrderedLayout());
- p2.setLayout(new OrderedLayout());
- p3.setLayout(new OrderedLayout());
+ p.setContent(new VerticalLayout());
+ p2.setContent(new VerticalLayout());
+ p3.setContent(new VerticalLayout());
}
});
diff --git a/tests/src/com/vaadin/tests/TestContainerChanges.java b/tests/src/com/vaadin/tests/TestContainerChanges.java index 86ff9649d3..c3a1a98665 100644 --- a/tests/src/com/vaadin/tests/TestContainerChanges.java +++ b/tests/src/com/vaadin/tests/TestContainerChanges.java @@ -12,12 +12,14 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.ListSelect;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
/**
* @author marc
@@ -36,22 +38,21 @@ public class TestContainerChanges extends CustomComponent { cont.addContainerProperty("Asd", String.class, "qwe");
cont.addContainerProperty("Bar", String.class, "foo");
- OrderedLayout main = new OrderedLayout();
+ VerticalLayout main = new VerticalLayout();
setCompositionRoot(main);
main.addComponent(new Label(
"The same IndexedContainer is wrapped in a ordered/hierarchical wrapper and is set as data source for all components . The buttons only affect the 'original' IndexedContainer."));
- OrderedLayout h = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout h = new HorizontalLayout();
main.addComponent(h);
- OrderedLayout v = new OrderedLayout();
+ VerticalLayout v = new VerticalLayout();
h.addComponent(v);
tbl = new Table();
- tbl.setHeight(200);
- tbl.setWidth(300);
+ tbl.setHeight("200px");
+ tbl.setWidth("300px");
v.addComponent(tbl);
tbl.setSelectable(true);
tbl.setMultiSelect(false);
@@ -62,8 +63,8 @@ public class TestContainerChanges extends CustomComponent { tbl.setContainerDataSource(hierarchical);
Table tbl2 = new Table();
- tbl2.setHeight(200);
- tbl2.setWidth(300);
+ tbl2.setHeight("200px");
+ tbl2.setWidth("300px");
v.addComponent(tbl2);
tbl2.setSelectable(true);
tbl2.setMultiSelect(false);
@@ -79,7 +80,7 @@ public class TestContainerChanges extends CustomComponent { // non-ordered container will get wrapped
tbl2.setContainerDataSource(hierarchical);
- OrderedLayout buttons = new OrderedLayout();
+ VerticalLayout buttons = new VerticalLayout();
v.addComponent(buttons);
Button b = new Button("table.commit()", new Button.ClickListener() {
@@ -167,7 +168,7 @@ public class TestContainerChanges extends CustomComponent { buttons.addComponent(b);
Panel p = new Panel("Tree");
- p.setStyleName(Panel.STYLE_LIGHT);
+ p.setStyleName(Reindeer.PANEL_LIGHT);
h.addComponent(p);
Tree tree = new Tree("ITEM_CAPTION_MODE_PROPERTY");
tree.setContainerDataSource(ordered);
@@ -181,7 +182,7 @@ public class TestContainerChanges extends CustomComponent { p.addComponent(tree);
p = new Panel("ComboBox");
- p.setStyleName(Panel.STYLE_LIGHT);
+ p.setStyleName(Reindeer.PANEL_LIGHT);
h.addComponent(p);
ComboBox c = new ComboBox("ITEM_CAPTION_MODE_PROPERTY");
c.setImmediate(true);
@@ -196,7 +197,7 @@ public class TestContainerChanges extends CustomComponent { p.addComponent(c);
p = new Panel("ListBox");
- p.setStyleName(Panel.STYLE_LIGHT);
+ p.setStyleName(Reindeer.PANEL_LIGHT);
h.addComponent(p);
ListSelect l = new ListSelect("ITEM_CAPTION_MODE_PROPERTY");
l.setContainerDataSource(cont);
diff --git a/tests/src/com/vaadin/tests/TestDateField.java b/tests/src/com/vaadin/tests/TestDateField.java index f84b37fe6d..287007bad6 100644 --- a/tests/src/com/vaadin/tests/TestDateField.java +++ b/tests/src/com/vaadin/tests/TestDateField.java @@ -12,7 +12,7 @@ import com.vaadin.terminal.UserError; import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.VerticalLayout;
/**
*
@@ -20,7 +20,7 @@ import com.vaadin.ui.OrderedLayout; */
public class TestDateField extends CustomComponent {
- OrderedLayout main = new OrderedLayout();
+ VerticalLayout main = new VerticalLayout();
DateField df;
diff --git a/tests/src/com/vaadin/tests/TestForAlignments.java b/tests/src/com/vaadin/tests/TestForAlignments.java index d8c7c0d59c..4296744224 100644 --- a/tests/src/com/vaadin/tests/TestForAlignments.java +++ b/tests/src/com/vaadin/tests/TestForAlignments.java @@ -4,17 +4,19 @@ package com.vaadin.tests; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.DateField; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class TestForAlignments extends CustomComponent { public TestForAlignments() { - final OrderedLayout main = new OrderedLayout(); + final VerticalLayout main = new VerticalLayout(); final Button b1 = new Button("Right"); final Button b2 = new Button("Left"); @@ -25,36 +27,26 @@ public class TestForAlignments extends CustomComponent { final DateField d1 = new DateField("Center aligned"); final DateField d2 = new DateField("Center aligned"); - final OrderedLayout vert = new OrderedLayout(); + final VerticalLayout vert = new VerticalLayout(); vert.addComponent(b1); vert.addComponent(b2); vert.addComponent(t1); vert.addComponent(d1); // vert.getSize().setWidth(500); - vert.setComponentAlignment(b1, OrderedLayout.ALIGNMENT_RIGHT, - OrderedLayout.ALIGNMENT_TOP); - vert.setComponentAlignment(b2, OrderedLayout.ALIGNMENT_LEFT, - OrderedLayout.ALIGNMENT_TOP); - vert.setComponentAlignment(t1, OrderedLayout.ALIGNMENT_RIGHT, - OrderedLayout.ALIGNMENT_TOP); - vert.setComponentAlignment(d1, - OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER, - OrderedLayout.ALIGNMENT_TOP); - final OrderedLayout hori = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + vert.setComponentAlignment(b1, Alignment.TOP_RIGHT); + vert.setComponentAlignment(b2, Alignment.TOP_LEFT); + vert.setComponentAlignment(t1, Alignment.TOP_RIGHT); + vert.setComponentAlignment(d1, Alignment.TOP_CENTER); + final HorizontalLayout hori = new HorizontalLayout(); hori.addComponent(b3); hori.addComponent(b4); hori.addComponent(t2); hori.addComponent(d2); // hori.getSize().setHeight(200); - hori.setComponentAlignment(b3, OrderedLayout.ALIGNMENT_LEFT, - OrderedLayout.ALIGNMENT_BOTTOM); - hori.setComponentAlignment(b4, OrderedLayout.ALIGNMENT_LEFT, - OrderedLayout.ALIGNMENT_TOP); - hori.setComponentAlignment(t2, OrderedLayout.ALIGNMENT_LEFT, - OrderedLayout.ALIGNMENT_BOTTOM); - hori.setComponentAlignment(d2, OrderedLayout.ALIGNMENT_LEFT, - OrderedLayout.ALIGNMENT_VERTICAL_CENTER); + hori.setComponentAlignment(b3, Alignment.BOTTOM_LEFT); + hori.setComponentAlignment(b4, Alignment.TOP_LEFT); + hori.setComponentAlignment(t2, Alignment.BOTTOM_LEFT); + hori.setComponentAlignment(d2, Alignment.MIDDLE_LEFT); main.addComponent(vert); main.addComponent(hori); diff --git a/tests/src/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java b/tests/src/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java index 6de6d3c046..fc7d631ddd 100644 --- a/tests/src/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java +++ b/tests/src/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java @@ -5,10 +5,12 @@ package com.vaadin.tests; import com.vaadin.Application; -import com.vaadin.ui.ExpandLayout; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends @@ -16,7 +18,7 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends Window main = new Window("Windowing test"); - ExpandLayout rootLayout; + VerticalLayout rootLayout; SplitPanel firstLevelSplit; @@ -24,38 +26,37 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends public void init() { setMainWindow(main); - rootLayout = new ExpandLayout(); - main.setLayout(rootLayout); + rootLayout = new VerticalLayout(); + main.setContent(rootLayout); rootLayout.addComponent(new Label("header")); - firstLevelSplit = new SplitPanel(); + firstLevelSplit = new VerticalSplitPanel(); - final SplitPanel secondSplitPanel = new SplitPanel( - SplitPanel.ORIENTATION_HORIZONTAL); + final SplitPanel secondSplitPanel = new HorizontalSplitPanel(); secondSplitPanel.setFirstComponent(new Label("left")); - final ExpandLayout topRight = new ExpandLayout(); + final VerticalLayout topRight = new VerticalLayout(); topRight.addComponent(new Label("topright header")); final Table t = TestForTablesInitialColumnWidthLogicRendering .getTestTable(4, 100); t.setSizeFull(); topRight.addComponent(t); - topRight.expand(t); + topRight.setExpandRatio(t, 1); topRight.addComponent(new Label("topright footer")); secondSplitPanel.setSecondComponent(topRight); - final ExpandLayout el = new ExpandLayout(); + final VerticalLayout el = new VerticalLayout(); el.addComponent(new Label("B��")); firstLevelSplit.setFirstComponent(secondSplitPanel); firstLevelSplit.setSecondComponent(el); rootLayout.addComponent(firstLevelSplit); - rootLayout.expand(firstLevelSplit); + rootLayout.setExpandRatio(firstLevelSplit, 1); rootLayout.addComponent(new Label("footer")); diff --git a/tests/src/com/vaadin/tests/TestForBasicApplicationLayout.java b/tests/src/com/vaadin/tests/TestForBasicApplicationLayout.java index 22f2c0d998..989655acea 100644 --- a/tests/src/com/vaadin/tests/TestForBasicApplicationLayout.java +++ b/tests/src/com/vaadin/tests/TestForBasicApplicationLayout.java @@ -11,13 +11,14 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
-import com.vaadin.ui.ExpandLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
public class TestForBasicApplicationLayout extends CustomComponent {
@@ -30,7 +31,7 @@ public class TestForBasicApplicationLayout extends CustomComponent { click = new Button("Set height -1", new ClickListener() {
public void buttonClick(ClickEvent event) {
- tab.setHeight(-1);
+ tab.setHeight(null);
}
});
@@ -43,10 +44,10 @@ public class TestForBasicApplicationLayout extends CustomComponent { });
- final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+ final SplitPanel sp = new HorizontalSplitPanel();
sp.setSplitPosition(290, SplitPanel.UNITS_PIXELS);
- final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);
+ final SplitPanel sp2 = new HorizontalSplitPanel();
sp2.setSplitPosition(255, SplitPanel.UNITS_PIXELS);
final Panel p = new Panel("Accordion Panel");
@@ -56,8 +57,8 @@ public class TestForBasicApplicationLayout extends CustomComponent { tab.setSizeFull();
final Panel report = new Panel("Monthly Program Runs",
- new ExpandLayout());
- final OrderedLayout controls = new OrderedLayout();
+ new VerticalLayout());
+ final VerticalLayout controls = new VerticalLayout();
controls.setMargin(true);
controls.addComponent(new Label("Report tab"));
controls.addComponent(click);
@@ -67,8 +68,8 @@ public class TestForBasicApplicationLayout extends CustomComponent { cal.setResolution(DateField.RESOLUTION_DAY);
cal.setLocale(new Locale("en", "US"));
report.addComponent(cal);
- ((ExpandLayout) report.getLayout()).expand(controls);
- report.addStyleName(Panel.STYLE_LIGHT);
+ ((VerticalLayout) report.getContent()).setExpandRatio(controls, 1);
+ report.addStyleName(Reindeer.PANEL_LIGHT);
report.setHeight(100, SplitPanel.UNITS_PERCENTAGE);
sp2.setFirstComponent(report);
diff --git a/tests/src/com/vaadin/tests/TestForChildComponentRendering.java b/tests/src/com/vaadin/tests/TestForChildComponentRendering.java index 9b5d02e945..2aafe6b38c 100644 --- a/tests/src/com/vaadin/tests/TestForChildComponentRendering.java +++ b/tests/src/com/vaadin/tests/TestForChildComponentRendering.java @@ -13,8 +13,8 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; /** * @@ -25,11 +25,11 @@ import com.vaadin.ui.Select; */ public class TestForChildComponentRendering extends CustomComponent { - private final OrderedLayout main; + private final VerticalLayout main; public TestForChildComponentRendering() { - main = new OrderedLayout(); + main = new VerticalLayout(); setCompositionRoot(main); createNewView(); } @@ -64,31 +64,31 @@ public class TestForChildComponentRendering extends CustomComponent { } public void randomReorder() { - final Iterator it = main.getComponentIterator(); - final ArrayList components = new ArrayList(); + final Iterator<Component> it = main.getComponentIterator(); + final ArrayList<Component> components = new ArrayList<Component>(); while (it.hasNext()) { components.add(it.next()); } - final OrderedLayout v = main; + final VerticalLayout v = main; v.removeAllComponents(); for (int i = components.size(); i > 0; i--) { final int index = (int) (Math.random() * i); - v.addComponent((Component) components.get(index)); + v.addComponent(components.get(index)); components.remove(index); } } public void removeRandomComponent() { - final Iterator it = main.getComponentIterator(); - final ArrayList components = new ArrayList(); + final Iterator<Component> it = main.getComponentIterator(); + final ArrayList<Component> components = new ArrayList<Component>(); while (it.hasNext()) { components.add(it.next()); } final int size = components.size(); final int index = (int) (Math.random() * size); - main.removeComponent((Component) components.get(index)); + main.removeComponent(components.get(index)); } diff --git a/tests/src/com/vaadin/tests/TestForContainerFilterable.java b/tests/src/com/vaadin/tests/TestForContainerFilterable.java index 51b144d4b1..7b5124b4f3 100644 --- a/tests/src/com/vaadin/tests/TestForContainerFilterable.java +++ b/tests/src/com/vaadin/tests/TestForContainerFilterable.java @@ -8,15 +8,16 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class TestForContainerFilterable extends CustomComponent { - OrderedLayout lo = new OrderedLayout(); + VerticalLayout lo = new VerticalLayout(); IndexedContainer ic = new IndexedContainer(); Table t = new Table(); private static String parts[] = { "Neo", "Sa", "rem", "the", "adi", "za", @@ -39,8 +40,7 @@ public class TestForContainerFilterable extends CustomComponent { } // Init filtering view - final Panel filterPanel = new Panel("Filter", new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL)); + final Panel filterPanel = new Panel("Filter", new HorizontalLayout()); filterPanel.setWidth(100, Panel.UNITS_PERCENTAGE); lo.addComponent(filterPanel); filterPanel.addComponent(fooFilter); diff --git a/tests/src/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java b/tests/src/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java index 9ff23e62ca..5c121dd3d3 100644 --- a/tests/src/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java +++ b/tests/src/com/vaadin/tests/TestForGridLayoutChildComponentRendering.java @@ -65,8 +65,8 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { } public void randomReorder() { - final Iterator it = main.getComponentIterator(); - final ArrayList components = new ArrayList(); + final Iterator<Component> it = main.getComponentIterator(); + final ArrayList<Component> components = new ArrayList<Component>(); while (it.hasNext()) { components.add(it.next()); } @@ -79,24 +79,24 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent { for (int i = components.size(); i > 0; i--) { final int index = (int) (Math.random() * i); if (i == colspanIndex) { - main.addComponent((Component) components.get(index), 0, - (size - i) / 2, 1, (size - i) / 2); + main.addComponent(components.get(index), 0, (size - i) / 2, 1, + (size - i) / 2); } else { - main.addComponent((Component) components.get(index)); + main.addComponent(components.get(index)); } components.remove(index); } } public void removeRandomComponent() { - final Iterator it = main.getComponentIterator(); - final ArrayList components = new ArrayList(); + final Iterator<Component> it = main.getComponentIterator(); + final ArrayList<Component> components = new ArrayList<Component>(); while (it.hasNext()) { components.add(it.next()); } final int size = components.size(); final int index = (int) (Math.random() * size); - main.removeComponent((Component) components.get(index)); + main.removeComponent(components.get(index)); } diff --git a/tests/src/com/vaadin/tests/TestForMultipleStyleNames.java b/tests/src/com/vaadin/tests/TestForMultipleStyleNames.java index a0facecd56..7bad629913 100644 --- a/tests/src/com/vaadin/tests/TestForMultipleStyleNames.java +++ b/tests/src/com/vaadin/tests/TestForMultipleStyleNames.java @@ -13,8 +13,8 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TwinColSelect; +import com.vaadin.ui.VerticalLayout; /** * TODO: Note you need to add Theme under WebContent/VAADIN/Themes/mytheme in @@ -26,13 +26,13 @@ import com.vaadin.ui.TwinColSelect; public class TestForMultipleStyleNames extends CustomComponent implements ValueChangeListener { - private final OrderedLayout main = new OrderedLayout(); + private final VerticalLayout main = new VerticalLayout(); private Label l; private final TwinColSelect s = new TwinColSelect(); - private ArrayList styleNames2; + private ArrayList<String> styleNames2; public TestForMultipleStyleNames() { setCompositionRoot(main); @@ -49,7 +49,7 @@ public class TestForMultipleStyleNames extends CustomComponent implements + " on the browser. Currently changes are" + " visible only by inspecting DOM.")); - styleNames2 = new ArrayList(); + styleNames2 = new ArrayList<String>(); styleNames2.add("red"); styleNames2.add("bold"); @@ -67,18 +67,18 @@ public class TestForMultipleStyleNames extends CustomComponent implements public void valueChange(ValueChangeEvent event) { - final String currentStyle = l.getStyle(); + final String currentStyle = l.getStyleName(); final String[] tmp = currentStyle.split(" "); - final ArrayList curStyles = new ArrayList(); + final ArrayList<String> curStyles = new ArrayList<String>(); for (int i = 0; i < tmp.length; i++) { if (tmp[i] != "") { curStyles.add(tmp[i]); } } - final Collection styles = (Collection) s.getValue(); + final Collection<?> styles = (Collection<?>) s.getValue(); - for (final Iterator iterator = styles.iterator(); iterator.hasNext();) { + for (final Iterator<?> iterator = styles.iterator(); iterator.hasNext();) { final String styleName = (String) iterator.next(); if (curStyles.contains(styleName)) { // already added @@ -87,9 +87,9 @@ public class TestForMultipleStyleNames extends CustomComponent implements l.addStyleName(styleName); } } - for (final Iterator iterator2 = curStyles.iterator(); iterator2 + for (final Iterator<String> iterator2 = curStyles.iterator(); iterator2 .hasNext();) { - final String object = (String) iterator2.next(); + final String object = iterator2.next(); l.removeStyleName(object); } } diff --git a/tests/src/com/vaadin/tests/TestForNativeWindowing.java b/tests/src/com/vaadin/tests/TestForNativeWindowing.java index 9728214163..38fbb42aa2 100644 --- a/tests/src/com/vaadin/tests/TestForNativeWindowing.java +++ b/tests/src/com/vaadin/tests/TestForNativeWindowing.java @@ -30,11 +30,11 @@ public class TestForNativeWindowing extends Application { main.addWindow(w); w.setPositionX(100); w.setPositionY(100); - w.setWidth(200); - w.setHeight(200); + w.setWidth("200px"); + w.setHeight("200px"); - w.setWidth(100); - w.setHeight(400); + w.setWidth("100px"); + w.setHeight("400px"); final Button closebutton = new Button("Close " + w.getCaption(), new Button.ClickListener() { diff --git a/tests/src/com/vaadin/tests/TestForPreconfiguredComponents.java b/tests/src/com/vaadin/tests/TestForPreconfiguredComponents.java index bfc9ef0abf..e009489683 100644 --- a/tests/src/com/vaadin/tests/TestForPreconfiguredComponents.java +++ b/tests/src/com/vaadin/tests/TestForPreconfiguredComponents.java @@ -13,13 +13,14 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Tree; import com.vaadin.ui.TwinColSelect; +import com.vaadin.ui.VerticalLayout; /** * @author IT Mill Ltd. @@ -34,7 +35,7 @@ public class TestForPreconfiguredComponents extends CustomComponent implements "Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding", "Einstein" }; - private final OrderedLayout main = new OrderedLayout(); + private final VerticalLayout main = new VerticalLayout(); private final Action[] actions = new Action[] { new Action("edit"), new Action("delete") }; @@ -133,12 +134,11 @@ public class TestForPreconfiguredComponents extends CustomComponent implements public Panel createTestBench(Component t) { final Panel ol = new Panel(); - ol.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL)); + ol.setContent(new HorizontalLayout()); ol.addComponent(t); - final OrderedLayout ol2 = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final HorizontalLayout ol2 = new HorizontalLayout(); final Panel status = new Panel("Events"); final Button clear = new Button("clear event log"); clear.addListener(new ClickListener() { @@ -152,8 +152,8 @@ public class TestForPreconfiguredComponents extends CustomComponent implements ol2.addComponent(commit); status.addComponent(ol2); - status.setHeight(300); - status.setWidth(400); + status.setHeight("300px"); + status.setWidth("400px"); ol.addComponent(status); diff --git a/tests/src/com/vaadin/tests/TestForRichTextEditor.java b/tests/src/com/vaadin/tests/TestForRichTextEditor.java index 4e9dfba2b4..50b7be91ef 100644 --- a/tests/src/com/vaadin/tests/TestForRichTextEditor.java +++ b/tests/src/com/vaadin/tests/TestForRichTextEditor.java @@ -8,10 +8,11 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.RichTextArea; +import com.vaadin.ui.VerticalLayout; /** * @@ -20,7 +21,7 @@ import com.vaadin.ui.RichTextArea; public class TestForRichTextEditor extends CustomComponent implements ValueChangeListener { - private final OrderedLayout main = new OrderedLayout(); + private final VerticalLayout main = new VerticalLayout(); private Label l; @@ -47,8 +48,7 @@ public class TestForRichTextEditor extends CustomComponent implements l = new Label("", Label.CONTENT_XHTML); main.addComponent(l); - Button b = new Button("enabled"); - b.setSwitchMode(true); + CheckBox b = new CheckBox("enabled"); b.setImmediate(true); b.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { diff --git a/tests/src/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java b/tests/src/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java index c009f9c768..d849ab37a0 100644 --- a/tests/src/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java +++ b/tests/src/com/vaadin/tests/TestForTablesInitialColumnWidthLogicRendering.java @@ -13,8 +13,8 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; /** * @@ -26,7 +26,7 @@ import com.vaadin.ui.Table; public class TestForTablesInitialColumnWidthLogicRendering extends CustomComponent { - private final OrderedLayout main = new OrderedLayout(); + private final VerticalLayout main = new VerticalLayout(); public TestForTablesInitialColumnWidthLogicRendering() { @@ -41,7 +41,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends Table t; - Layout lo = new OrderedLayout(); + Layout lo = new VerticalLayout(); lo.setWidth("600px"); lo.setHeight("250px"); @@ -65,7 +65,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends t = getTestTable(5, 5); t.setCaption("Table with some cols and rows rows, some col widths fixed"); - Iterator it = t.getContainerPropertyIds().iterator(); + Iterator<?> it = t.getContainerPropertyIds().iterator(); it.next(); it.next(); t.setColumnWidth(it.next(), 30); @@ -79,7 +79,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends t = getTestTable(3, 40); t.setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)"); - t.setWidth(1000); + t.setWidth("1000px"); main.addComponent(t); t = getTestTable(12, 4); @@ -99,7 +99,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends t = getTestTable(4, 4); t.setCaption("Table with some rows and width = 200px"); - t.setWidth(200); + t.setWidth("200px"); main.addComponent(t); final Button b = new Button("refresh view", this, "createNewView"); @@ -115,7 +115,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends } t.addContainerProperty("button", Button.class, null); for (int i = 0; i < rows; i++) { - final Vector content = new Vector(); + final Vector<Object> content = new Vector<Object>(); for (int j = 0; j < cols; j++) { content.add(rndString()); } diff --git a/tests/src/com/vaadin/tests/TestForTrees.java b/tests/src/com/vaadin/tests/TestForTrees.java index 93579c8ae7..32139511e1 100644 --- a/tests/src/com/vaadin/tests/TestForTrees.java +++ b/tests/src/com/vaadin/tests/TestForTrees.java @@ -6,15 +6,17 @@ package com.vaadin.tests; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Tree; +import com.vaadin.ui.VerticalLayout; /** * Some test cases for trees. Events panel logs events that happen server side. @@ -30,7 +32,7 @@ public class TestForTrees extends CustomComponent implements Handler { "Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding", "Einstein" }; - private final OrderedLayout main = new OrderedLayout(); + private final VerticalLayout main = new VerticalLayout(); private final Action[] actions = new Action[] { new Action("edit"), new Action("delete") }; @@ -78,7 +80,7 @@ public class TestForTrees extends CustomComponent implements Handler { t.setCaption("with actions"); t.setImmediate(true); t.addActionHandler(this); - final OrderedLayout ol = (OrderedLayout) createTestBench(t); + final AbstractOrderedLayout ol = (AbstractOrderedLayout) createTestBench(t); al = new Panel("action log"); ol.addComponent(al); main.addComponent(ol); @@ -118,8 +120,7 @@ public class TestForTrees extends CustomComponent implements Handler { } public Component createTestBench(Tree t) { - final OrderedLayout ol = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final HorizontalLayout ol = new HorizontalLayout(); ol.addComponent(t); diff --git a/tests/src/com/vaadin/tests/TestForUpload.java b/tests/src/com/vaadin/tests/TestForUpload.java index e80a3f4581..3fed6b233e 100644 --- a/tests/src/com/vaadin/tests/TestForUpload.java +++ b/tests/src/com/vaadin/tests/TestForUpload.java @@ -179,7 +179,7 @@ public class TestForUpload extends CustomComponent implements } }); - uploadBufferSelector = new Select("Receiver type"); + uploadBufferSelector = new Select("StreamVariable type"); uploadBufferSelector.setImmediate(true); uploadBufferSelector.addItem("memory"); uploadBufferSelector.setValue("memory"); diff --git a/tests/src/com/vaadin/tests/TestForWindowOpen.java b/tests/src/com/vaadin/tests/TestForWindowOpen.java index 41af299bf3..74e3af46ea 100644 --- a/tests/src/com/vaadin/tests/TestForWindowOpen.java +++ b/tests/src/com/vaadin/tests/TestForWindowOpen.java @@ -8,13 +8,13 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class TestForWindowOpen extends CustomComponent { public TestForWindowOpen() { - final OrderedLayout main = new OrderedLayout(); + final VerticalLayout main = new VerticalLayout(); setCompositionRoot(main); main.addComponent(new Button("Open in this window", diff --git a/tests/src/com/vaadin/tests/TestForWindowing.java b/tests/src/com/vaadin/tests/TestForWindowing.java index c2dac3d529..fb7c388567 100644 --- a/tests/src/com/vaadin/tests/TestForWindowing.java +++ b/tests/src/com/vaadin/tests/TestForWindowing.java @@ -14,9 +14,9 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; import com.vaadin.ui.Slider; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class TestForWindowing extends CustomComponent { @@ -25,7 +25,7 @@ public class TestForWindowing extends CustomComponent { public TestForWindowing() { - final OrderedLayout main = new OrderedLayout(); + final VerticalLayout main = new VerticalLayout(); main.addComponent(new Label( "Click the button to create a new inline window.")); diff --git a/tests/src/com/vaadin/tests/TestIFrames.java b/tests/src/com/vaadin/tests/TestIFrames.java index b955a023f7..dea306b1bf 100644 --- a/tests/src/com/vaadin/tests/TestIFrames.java +++ b/tests/src/com/vaadin/tests/TestIFrames.java @@ -6,11 +6,11 @@ package com.vaadin.tests; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class TestIFrames extends CustomComponent { - OrderedLayout main = new OrderedLayout(); + VerticalLayout main = new VerticalLayout(); public TestIFrames() { setCompositionRoot(main); diff --git a/tests/src/com/vaadin/tests/TestMethodProperty.java b/tests/src/com/vaadin/tests/TestMethodProperty.java index d92006da6c..49a3c110fa 100644 --- a/tests/src/com/vaadin/tests/TestMethodProperty.java +++ b/tests/src/com/vaadin/tests/TestMethodProperty.java @@ -11,8 +11,8 @@ public class TestMethodProperty { MyTest myTest = new MyTest(); - MethodProperty methodProperty2 = new MethodProperty(Integer.TYPE, - myTest, "getInt", "setInt", new Object[0], + MethodProperty<Integer> methodProperty2 = new MethodProperty<Integer>( + Integer.TYPE, myTest, "getInt", "setInt", new Object[0], new Object[] { null }, 0); methodProperty2.setValue("3"); diff --git a/tests/src/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java b/tests/src/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java index b85c629295..5a72a34be9 100644 --- a/tests/src/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java +++ b/tests/src/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java @@ -7,13 +7,13 @@ package com.vaadin.tests; import java.util.Collection; import java.util.Vector; -import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.DateField; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; /** * This test has a somewhat deep layout within one page. At the bottom, Select @@ -27,7 +27,7 @@ import com.vaadin.ui.Select; public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { public TestSelectAndDatefieldInDeepLayouts() { - final OrderedLayout root = (OrderedLayout) getOrderedLayout(); + final AbstractOrderedLayout root = getOrderedLayout(); setCompositionRoot(root); root.addComponent(getSelect()); @@ -43,7 +43,7 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { p1.addComponent(getSelect()); p1.addComponent(getDateField()); - final OrderedLayout l1 = (OrderedLayout) getOrderedLayout(); + final AbstractOrderedLayout l1 = getOrderedLayout(); p1.addComponent(l1); l1.addComponent(getSelect()); @@ -61,8 +61,8 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { } - AbstractLayout getOrderedLayout() { - final OrderedLayout l = new OrderedLayout(); + VerticalLayout getOrderedLayout() { + final VerticalLayout l = new VerticalLayout(); l.setCaption(getCaption("orderedlayout")); return l; } @@ -81,8 +81,8 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent { return new DateField(getCaption("datefield")); } - private Collection getSelectOptions() { - final Collection opts = new Vector(3); + private Collection<String> getSelectOptions() { + final Collection<String> opts = new Vector<String>(3); opts.add(getCaption("opt 1")); opts.add(getCaption("opt 2")); opts.add(getCaption("opt 3")); diff --git a/tests/src/com/vaadin/tests/TestSizeableIncomponents.java b/tests/src/com/vaadin/tests/TestSizeableIncomponents.java index c1e8aa137a..5d3a6e77cd 100644 --- a/tests/src/com/vaadin/tests/TestSizeableIncomponents.java +++ b/tests/src/com/vaadin/tests/TestSizeableIncomponents.java @@ -135,7 +135,7 @@ public class TestSizeableIncomponents extends Application { && (f.indexOf("Window") == -1)) { f = f.replaceAll(".class", ""); String className = "com.vaadin.ui." + f; - Class c; + Class<?> c; try { c = Class.forName(className); Object o = c.newInstance(); @@ -213,10 +213,10 @@ public class TestSizeableIncomponents extends Application { class Testable { - private Class classToTest; - private ArrayList configurations = new ArrayList(); + private Class<?> classToTest; + private ArrayList<Configuration> configurations = new ArrayList<Configuration>(); - Testable(Class c) { + Testable(Class<?> c) { classToTest = c; } @@ -228,8 +228,9 @@ public class TestSizeableIncomponents extends Application { StringBuffer sb = new StringBuffer(); sb.append(classToTest.getName().replaceAll("com.vaadin.ui.", "")); sb.append("["); - for (Iterator i = configurations.iterator(); i.hasNext();) { - sb.append(((Configuration) i.next()).getDescription()); + for (Iterator<Configuration> i = configurations.iterator(); i + .hasNext();) { + sb.append((i.next()).getDescription()); if (i.hasNext()) { sb.append(","); } @@ -280,8 +281,9 @@ public class TestSizeableIncomponents extends Application { ((Label) c).setValue("Test label"); } - for (Iterator i = configurations.iterator(); i.hasNext();) { - Configuration conf = (Configuration) i.next(); + for (Iterator<Configuration> i = configurations.iterator(); i + .hasNext();) { + Configuration conf = i.next(); conf.configure(c); } return c; diff --git a/tests/src/com/vaadin/tests/TestSplitPanel.java b/tests/src/com/vaadin/tests/TestSplitPanel.java index 628fec96d2..b7d6f6dba6 100644 --- a/tests/src/com/vaadin/tests/TestSplitPanel.java +++ b/tests/src/com/vaadin/tests/TestSplitPanel.java @@ -6,13 +6,14 @@ package com.vaadin.tests; import com.vaadin.ui.Label; import com.vaadin.ui.SplitPanel; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; public class TestSplitPanel extends com.vaadin.Application { // SplitPanel verticalSplit = new // SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); - SplitPanel verticalSplit = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); + SplitPanel verticalSplit = new VerticalSplitPanel(); @Override public void init() { @@ -22,7 +23,7 @@ public class TestSplitPanel extends com.vaadin.Application { verticalSplit.setFirstComponent(new Label("vertical first")); verticalSplit.setSecondComponent(new Label("vertical second")); - mainWindow.setLayout(verticalSplit); + mainWindow.setContent(verticalSplit); } diff --git a/tests/src/com/vaadin/tests/TreeFilesystem.java b/tests/src/com/vaadin/tests/TreeFilesystem.java index c5ff1cb51d..d39c6008f6 100644 --- a/tests/src/com/vaadin/tests/TreeFilesystem.java +++ b/tests/src/com/vaadin/tests/TreeFilesystem.java @@ -42,7 +42,7 @@ public class TreeFilesystem extends com.vaadin.Application implements // configure file structure panel main.addComponent(explorerPanel); explorerPanel.addComponent(tree); - explorerPanel.setHeight(400); + explorerPanel.setHeight("400px"); // "this" handles tree's expand event tree.addListener(this); diff --git a/tests/src/com/vaadin/tests/UpgradingSample.java b/tests/src/com/vaadin/tests/UpgradingSample.java index 3819b33a3c..55a17d705b 100644 --- a/tests/src/com/vaadin/tests/UpgradingSample.java +++ b/tests/src/com/vaadin/tests/UpgradingSample.java @@ -17,10 +17,10 @@ import com.vaadin.ui.Button; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -60,7 +60,7 @@ public class UpgradingSample extends Application implements setMainWindow(main); // Add menu and loginbox to the application - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); layout.addComponent(l, 0, 0); l.addComponent(menu); l.addComponent(new LoginBox()); diff --git a/tests/src/com/vaadin/tests/UsingObjectsInSelect.java b/tests/src/com/vaadin/tests/UsingObjectsInSelect.java index 2fc0fc5eac..c9b0939eef 100644 --- a/tests/src/com/vaadin/tests/UsingObjectsInSelect.java +++ b/tests/src/com/vaadin/tests/UsingObjectsInSelect.java @@ -21,7 +21,7 @@ public class UsingObjectsInSelect extends com.vaadin.Application implements private final Label selectedTask = new Label("Selected task", Label.CONTENT_XHTML); - public LinkedList exampleTasks = new LinkedList(); + public LinkedList<?> exampleTasks = new LinkedList<Object>(); public static Random random = new Random(1); diff --git a/tests/src/com/vaadin/tests/book/BookTestApplication.java b/tests/src/com/vaadin/tests/book/BookTestApplication.java deleted file mode 100644 index cba0f15e01..0000000000 --- a/tests/src/com/vaadin/tests/book/BookTestApplication.java +++ /dev/null @@ -1,1893 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import java.net.URL; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import com.vaadin.data.Item; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.data.Validator; -import com.vaadin.data.util.QueryContainer; -import com.vaadin.data.validator.StringLengthValidator; -import com.vaadin.terminal.ClassResource; -import com.vaadin.terminal.DownloadStream; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.ParameterHandler; -import com.vaadin.terminal.Sizeable; -import com.vaadin.terminal.StreamResource; -import com.vaadin.terminal.URIHandler; -import com.vaadin.terminal.UserError; -import com.vaadin.terminal.gwt.server.WebApplicationContext; -import com.vaadin.ui.AbsoluteLayout; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Component; -import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.DateField; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.Form; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.InlineDateField; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout.AlignmentHandler; -import com.vaadin.ui.Link; -import com.vaadin.ui.MenuBar; -import com.vaadin.ui.MenuBar.MenuItem; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Panel; -import com.vaadin.ui.PopupDateField; -import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.Select; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; - -public class BookTestApplication extends com.vaadin.Application { - Window main = new Window("Application window"); - - TheButton butts1; - TheButtons butts2; - TheButtons2 butts3; - - Label mylabel1; - Label mylabel2; - Label mylabel3; - - StreamResource strres; - VerticalLayout ol; - int getwincount = 0; - - @Override - public void init() { - setTheme("tests-book"); - - setMainWindow(main); - - main.getContent().setSizeFull(); - - // Demo the use of parameter and URI handlers - main.addParameterHandler(new MyParameterHandler()); - main.addURIHandler(new MyURIHandler()); - - MyDynamicResource myresource = new MyDynamicResource(); - main.addParameterHandler(myresource); - main.addURIHandler(myresource); - - main.addURIHandler(new BookTestURIHandler()); - } - - class MyParameterHandler implements ParameterHandler { - public void handleParameters(Map parameters) { - // Print out the parameters to standard output - for (Iterator it = parameters.keySet().iterator(); it.hasNext();) { - String key = (String) it.next(); - String value = ((String[]) parameters.get(key))[0]; - System.out.println("Key: " + key + ", value: " + value); - } - } - } - - class MyURIHandler implements URIHandler { - public DownloadStream handleURI(URL context, String relativeUri) { - System.out.println("Context: " + context.toString() - + ", relative: " + relativeUri); - return null; // Let the Application provide the response - } - } - - class BookTestURIHandler implements URIHandler { - public DownloadStream handleURI(URL context, String relativeUri) { - String example; - String param = null; - - final int slashPos = relativeUri.indexOf("/"); - if (slashPos > 0) { - example = relativeUri.substring(0, slashPos); - param = relativeUri.substring(slashPos + 1); - } else { - example = relativeUri; - } - - /* Remove existing components and windows. */ - main.removeAllComponents(); - final Set childwindows = main.getChildWindows(); - for (final Iterator cwi = childwindows.iterator(); cwi.hasNext();) { - final Window child = (Window) cwi.next(); - main.removeWindow(child); - } - - // The index is listed inside a grid layout - main.setLayout(new VerticalLayout()); - GridLayout grid = new GridLayout(4, 4); - grid.addStyleName("index"); - main.addComponent(grid); - - if (example.equals("index")) { - final String examples[] = { "defaultbutton", "label", - "labelcontent", "tree", "embedded", "textfield", - "textfieldvalidation", "datefield", "button", - "select/select", "select/native", "select/optiongroup", - "select/twincol", "filterselect", "validator", "table", - "table/select", "table/component", "table/paging", - "table/editable", "upload", "link", "gridlayout", - "orderedlayout", "formlayout", "form", "form/simple", - "form/layout", "panel", "expandlayout", - "expandlayout/root", "tabsheet", "alignment", - "alignment/grid", "window", "window/opener", - "window/multiple", "classresource", "usererror", - "progress/window", "progress/thread", "progress", - "customlayout", "spacing", "margin", "clientinfo", - "fillinform/templates", "notification", "print", - "richtextfield", "querycontainer", "menubar", - "absolutelayout", "layout/intro" }; - for (int i = 0; i < examples.length; i++) { - grid.addComponent(new Label("<a href='" - + context.toString() + examples[i] + "'>" - + examples[i] + "</a>", Label.CONTENT_XHTML)); - } - return null; - } - - if (example.equals("defaultbutton")) { - example_defaultButton(main, param); - } else if (example.equals("label")) { - example_Label(main, param); - } else if (example.equals("labelcontent")) { - example_LabelContent(main, param); - } else if (example.equals("tree")) { - example_Tree(main, param); - } else if (example.equals("embedded")) { - example_Embedded(main, param); - } else if (example.equals("textfield")) { - example_TextField(main, param); - } else if (example.equals("textfieldvalidation")) { - example_TextFieldValidation(main, param); - } else if (example.equals("usererror")) { - example_UserError(main, param); - } else if (example.equals("datefield")) { - example_DateField(main, param); - } else if (example.equals("button")) { - example_Button(main, param); - } else if (example.equals("checkbox")) { - example_CheckBox(main, param); - } else if (example.equals("select")) { - example_Select(main, param); - } else if (example.equals("filterselect")) { - example_FilterSelect(main, param); - } else if (example.equals("validator")) { - example_Validator(main, param); - } else if (example.equals("table")) { - example_Table(main, param); - } else if (example.equals("upload")) { - example_Upload(main, param); - } else if (example.equals("link")) { - example_Link(main, param); - } else if (example.equals("gridlayout")) { - example_GridLayout(main, param); - } else if (example.equals("orderedlayout")) { - example_OrderedLayout(main, param); - } else if (example.equals("formlayout")) { - example_FormLayout(main, param); - } else if (example.equals("form")) { - example_Form(main, param); - } else if (example.equals("tabsheet")) { - example_TabSheet(main, param); - } else if (example.equals("panel")) { - example_Panel(main, param); - } else if (example.equals("expandlayout")) { - example_ExpandLayout(main, param); - } else if (example.equals("alignment")) { - example_Alignment(main, param); - } else if (example.equals("window")) { - example_Window(main, param); - } else if (example.equals("classresource")) { - example_ClassResource(main, param); - } else if (example.equals("progress")) { - example_ProgressIndicator(main, param); - } else if (example.equals("customlayout")) { - example_CustomLayout(main, param); - } else if (example.equals("spacing")) { - example_Spacing(main, param); - } else if (example.equals("margin")) { - example_Margin(main, param); - } else if (example.equals("clientinfo")) { - example_ClientInfo(main, param); - } else if (example.equals("fillinform")) { - example_FillInForm(main, param); - } else if (example.equals("notification")) { - example_Notification(main, param); - } else if (example.equals("print")) { - example_Print(main, param); - } else if (example.equals("richtextfield")) { - example_RichTextArea(main, param); - } else if (example.equals("querycontainer")) { - example_QueryContainer(main, param); - } else if (example.equals("menubar")) { - example_MenuBar(main, param); - } else if (example.equals("absolutelayout")) { - example_AbsoluteLayout(main, param); - } else if (example.equals("layout")) { - example_Layout(main, param); - } else { - ; // main.addComponent(new - // Label("Unknown test '"+example+"'.")); - } - - return null; - } - } - - /* - * public Window getWindow(String name) { Window superwin = - * super.getWindow(name); if (superwin != null) return superwin; - * - * main.addComponent(new Label("Request 2 for window '"+name+"'.")); if - * (name.equals("panel")) { Window window = new Window("Other Window " + - * getwincount++); example_Panel(window, null); return window; } return - * null; } - */ - public void handleButton(Button.ClickEvent event) { - ol.addStyleName("myLayout2"); - } - - void example_defaultButton(Window main, String param) { - main.addComponent(new DefaultButtonExample()); - } - - void example_Label(Window main, String param) { - /* Some container for the Label. */ - final Panel panel = new Panel("Panel Containing a Label"); - main.addComponent(panel); - - panel.addComponent(new Label( - "This is a Label inside a Panel. There is enough " - + "text in the label to make the text wrap if it " - + "exceeds the width of the panel.")); - } - - void example_LabelContent(Window main, String param) { - final GridLayout labelgrid = new GridLayout(2, 1); - labelgrid.addStyleName("labelgrid"); - labelgrid.addComponent(new Label("CONTENT_DEFAULT")); - labelgrid.addComponent(new Label( - "This is a label in default mode: <plain text>", - Label.CONTENT_DEFAULT)); - labelgrid.addComponent(new Label("CONTENT_PREFORMATTED")); - labelgrid - .addComponent(new Label( - "This is a preformatted label.\nThe newline character \\n breaks the line.", - Label.CONTENT_PREFORMATTED)); - labelgrid.addComponent(new Label("CONTENT_RAW")); - labelgrid - .addComponent(new Label( - "This is a label in raw mode.<br>It can contain, for example, unbalanced markup.", - Label.CONTENT_RAW)); - labelgrid.addComponent(new Label("CONTENT_TEXT")); - labelgrid.addComponent(new Label( - "This is a label in (plain) text mode", Label.CONTENT_TEXT)); - labelgrid.addComponent(new Label("CONTENT_XHTML")); - labelgrid.addComponent(new Label( - "<i>This</i> is an <b>XHTML<b> formatted label", - Label.CONTENT_XHTML)); - labelgrid.addComponent(new Label("CONTENT_XML")); - labelgrid.addComponent(new Label( - "This is an <myelement>XML</myelement> formatted label", - Label.CONTENT_XML)); - main.addComponent(labelgrid); - - final ClassResource labelimage = new ClassResource("smiley.jpg", this); - main.addComponent(new Label("Here we have an image <img src=\"" - + getRelativeLocation(labelimage) + "\"/> within some text.", - Label.CONTENT_XHTML)); - } - - void example_Tree(Window main, String param) { - final Object[][] planets = new Object[][] { - new Object[] { "Mercury" }, - new Object[] { "Venus" }, - new Object[] { "Earth", "The Moon" }, - new Object[] { "Mars", "Phobos", "Deimos" }, - new Object[] { "Jupiter", "Io", "Europa", "Ganymedes", - "Callisto" }, - new Object[] { "Saturn", "Titan", "Tethys", "Dione", "Rhea", - "Iapetus" }, - new Object[] { "Uranus", "Miranda", "Ariel", "Umbriel", - "Titania", "Oberon" }, - new Object[] { "Neptune", "Triton", "Proteus", "Nereid", - "Larissa" } }; - - final Tree tree = new Tree(); - - // Add planets as root items in the tree. - for (int i = 0; i < planets.length; i++) { - final String planet = (String) (planets[i][0]); - tree.addItem(planet); - - if (planets[i].length == 1) { - // The planet has no moons so make it a leaf. - tree.setChildrenAllowed(planet, false); - } else { - // Add children (moons) under the planets. - for (int j = 1; j < planets[i].length; j++) { - final String moon = (String) planets[i][j]; - - // Add the item as a regular item. - tree.addItem(moon); - - // Set it to be a child. - tree.setParent(moon, planet); - - // Make the moons look like leaves. - tree.setChildrenAllowed(moon, false); - } - - // Expand the subtree. - tree.expandItemsRecursively(planet); - } - } - - // Horizontal layout with the tree on the left and a details panel on - // the right. - final HorizontalLayout horlayout = new HorizontalLayout(); - horlayout.addStyleName("treeexample"); - horlayout.setSizeFull(); - - final Panel treepanel = new Panel("The Planets and Major Moons"); - treepanel.addComponent(tree); - horlayout.addComponent(treepanel); - - final Panel detailspanel = new Panel("Details"); - horlayout.addComponent(detailspanel); - horlayout.setExpandRatio(detailspanel, 1); - - final VerticalLayout detailslayout = new VerticalLayout(); - detailspanel.setLayout(detailslayout); - - // Allow null selection - this is the default actually. - tree.setNullSelectionAllowed(true); - - // When a tree item (planet or moon) is clicked, open the item in - // Details view. - tree.setImmediate(true); - tree.addListener(new ValueChangeListener() { - String lastselected = null; - - public void valueChange(ValueChangeEvent event) { - String planet = (String) tree.getValue(); - - // Reselect a selected item if it is unselected by clicking it. - if (planet == null) { - planet = lastselected; - tree.setValue(planet); - } - lastselected = planet; - - detailspanel.setCaption("Details on " + planet); - detailslayout.removeAllComponents(); - - // Put some stuff in the Details view. - detailslayout.addComponent(new Label("Where is the cat?")); - detailslayout.addComponent(new Label("The cat is in " + planet - + ".")); - - } - }); - - main.setLayout(horlayout); - } - - void example_Select(Window main, String param) { - final HorizontalLayout layout = new HorizontalLayout(); - layout.addStyleName("aligntop"); - - if (param.equals("twincol")) { - final SelectExample select1 = new SelectExample(this, param, - "Select some items", true); - layout.addComponent(select1); - } else if (param.equals("filter")) { - final SelectExample select1 = new SelectExample(this, param, - "Enter containing substring", false); - layout.addComponent(select1); - } else { - final SelectExample select1 = new SelectExample(this, param, - "Single Selection Mode", false); - final SelectExample select2 = new SelectExample(this, param, - "Multiple Selection Mode", true); - layout.addComponent(select1); - layout.addComponent(select2); - } - main.addComponent(layout); - } - - void example_FilterSelect(Window main, String param) { - final Select select = new Select("Enter containing substring"); - main.addComponent(select); - - select.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS); - - /* Fill the component with some items. */ - final String[] planets = new String[] { "Mercury", "Venus", "Earth", - "Mars", "Jupiter", "Saturn", "Uranus", "Neptune" }; - - for (int i = 0; i < planets.length; i++) { - for (int j = 0; j < planets.length; j++) { - select.addItem(planets[j] + " to " + planets[i]); - } - } - } - - void example_TextField(Window main, String param) { - /* Add a single-line text field. */ - final TextField subject = new TextField("Subject"); - subject.setColumns(40); - main.addComponent(subject); - - /* Add a multi-line text field. */ - final TextField message = new TextField("Message"); - message.setRows(7); - message.setColumns(40); - main.addComponent(message); - } - - void example_TextFieldValidation(Window main, String param) { - // Create a text field with a label - final TextField username = new TextField("Username"); - main.addComponent(username); - - // Set visible length to 16 characters - username.setColumns(16); - - // Set content length to minimum of 6 and maximum of 16 characters. - // The string also may not be null. - username.addValidator(new StringLengthValidator( - "Must be 6 to 16 characters long", 6, 16, false)); - - // Setting component immediate causes a ValueChangeEvent to occur - // when the TextField loses focus. - username.setImmediate(true); - - // Listen for ValueChangeEvents and handle them - username.addListener(new ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - // Get the source of the event - final TextField username = (TextField) (event.getProperty()); - - try { - // Validate the field value. - username.validate(); - } catch (final Validator.InvalidValueException e) { - // The value was not ok. The error was set. - } - } - }); - } - - void example_UserError(final Window main, String param) { - if (param != null) { - if (param.equals("form")) { - - final FormLayout layout = new FormLayout(); - main.addComponent(layout); - - final TextField textfield = new TextField("Enter code"); - layout.addComponent(textfield); - textfield.setComponentError(null); - - final Button button = new Button("Ok!"); - layout.addComponent(button); - - button.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - if (((String) textfield.getValue()).length() == 0) { - textfield.setComponentError(new UserError( - "Must be letters and numbers.")); - } else { - textfield.setComponentError(null); - } - } - }); - } - } else { - main.setLayout(new HorizontalLayout()); - - // Create a field. - final TextField textfield = new TextField("Enter code"); - main.addComponent(textfield); - - // Let the component error be initially clear. (It actually is by - // default.) - textfield.setComponentError(null); - - // Have a button right of the field (and align it properly). - final Button button = new Button("Ok!"); - main.addComponent(button); - ((HorizontalLayout) main.getLayout()).setComponentAlignment(button, - HorizontalLayout.ALIGNMENT_LEFT, - HorizontalLayout.ALIGNMENT_BOTTOM); - - // Handle button clicks - button.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - // If the field value is bad, set its error. - // (Here the content must be only alphanumeric characters.) - if (!((String) textfield.getValue()).matches("^\\w*$")) { - // Put the component in error state and set the error - // message. - textfield.setComponentError(new UserError( - "Must be letters and numbers")); - } else { - // Otherwise clear it. - textfield.setComponentError(null); - } - } - }); - } - } - - void example_DateField(Window main, String param) { - HorizontalLayout layout = new HorizontalLayout(); - - /* Create a DateField with the calendar style. */ - final DateField popupdate = new PopupDateField("Popup calendar field"); - - /* Set resolution of the date/time display. */ - popupdate.setResolution(DateField.RESOLUTION_MIN); - - /* Set the date and time to present. */ - popupdate.setValue(new java.util.Date()); - - /* Create a DateField with the calendar style. */ - final DateField inlinedate = new InlineDateField( - "Inline calendar field"); - - /* Set locale of the DateField to American English. */ - inlinedate.setLocale(new Locale("en", "US")); - - /* Set the date and time to present. */ - inlinedate.setValue(new java.util.Date()); - - /* Set resolution of the date/time display. */ - inlinedate.setResolution(DateField.RESOLUTION_MIN); - - layout.addComponent(popupdate); - layout.addComponent(inlinedate); - layout.setSpacing(true); - main.addComponent(layout); - } - - void example_Validator(Window main, String param) { - if (param != null && param.equals("required")) { - Form form = new Form(); - form.setCaption("My Form"); - form.setRequired(true); - main.addComponent(form); - - TextField text = new TextField("This is a required text field"); - text.setRequired(true); - text.setImmediate(true); - form.getLayout().addComponent(text); - return; - } - main.addComponent(new SSNField()); - } - - // TODO add ClientWidget annotation if test is in use - class PagingTable extends Table { - } - - void example_Table(Window main, String param) { - if (param != null) { - if (param.equals("select")) { - main.addComponent(new TableExample2()); - } else if (param.equals("component")) { - main.addComponent(new TableExample3()); - } else if (param.equals("editable")) { - main.addComponent(new TableEditable()); - } else if (param.equals("bean")) { - main.addComponent(new TableEditableBean()); - } else if (param.equals("long")) { - main.addComponent(new TableExample()); - } else if (param.equals("cellstyle")) { - main.addComponent(new TableCellStyle()); - } else if (param.equals("huge")) { - main.addComponent(new TableHuge()); - } else if (param.equals("paging")) { - PagingTable table = new PagingTable(); - table.addContainerProperty("Column 1", String.class, null); - for (int i = 0; i < 100; i++) { - table.addItem(new Object[] { "Item " + i }, new Integer(i)); - } - main.addComponent(table); - } - } else { - main.addComponent(new TableExample1()); - } - } - - void example_Upload(Window main, String param) { - main.addComponent(new MyUploader()); - } - - void example_Link(Window main, String param) { - - /* Create a link that opens the popup window. */ - final Link alink = new Link(); - - /* Set the resource to be opened in the window. */ - alink.setResource(new ExternalResource("http://www.vaadin.com/")); - - main.addComponent(alink); - - final ClassResource mydocument = new ClassResource("mydocument.pdf", - this); - main.addComponent(new Link("The document (pdf)", mydocument)); - main.addComponent(new Link("link to a resource", new ExternalResource( - "http://www.vaadin.com/"))); - } - - void example_Button(Window main, String param) { - if (param != null) { - if (param.equals("buttons")) { - main.addComponent(new TheButton()); - } - return; - } - - // butts1 = new TheButton (); - // main.addComponent(butts1); - - // butts2 = new TheButtons (main); - // butts3 = new TheButtons2 (main); - - // Button checkbox = new Button ("This is a checkbox"); - - // main.addComponent(checkbox); - final Button button = new Button("My Button"); - main.addComponent(button); - } - - void example_CheckBox(Window main, String param) { - /* A check box with default state (not checked, i.e., false). */ - final CheckBox checkbox1 = new CheckBox("My CheckBox"); - checkbox1.addStyleName("mybox"); - main.addComponent(checkbox1); - - /* Another check box with explicitly set checked state. */ - final CheckBox checkbox2 = new CheckBox("Checked CheckBox"); - /* - * @TODO: Build fails here, why? checkbox2.setValue(true); - */ - main.addComponent(checkbox2); - - /* - * Make some application logic. We use anynymous listener classes here. - * The above references were defined as "final" to allow accessing them - * from inside anonymous classes. - */ - checkbox1.addListener(new ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - /* Copy the value to the other checkbox. */ - checkbox2.setValue(checkbox1.getValue()); - } - }); - checkbox2.addListener(new ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - /* Copy the value to the other checkbox. */ - checkbox1.setValue(checkbox2.getValue()); - } - }); - } - - void example_Panel(Window main, String param) { - // Create a panel with a caption. - final Panel panel = new Panel("Contact Information"); - - // Create a layout inside the panel - final FormLayout form = new FormLayout(); - - // Set the layout as the root layout of the panel - panel.setLayout(form); - - // Add some components - form.addComponent(new TextField("Name")); - form.addComponent(new TextField("Email")); - - // Add the panel to the main window - final ClassResource icon = new ClassResource("smiley.jpg", - main.getApplication()); - form.addComponent(new Embedded("Image", icon)); - panel.setIcon(icon); - panel.addComponent(form); - main.addComponent(panel); - } - - void example_GridLayout(Window main, String param) { - if (param.equals("embedded")) { - final GridLayout grid = new GridLayout(3, 3); - for (int i = 0; i < 3 * 3; i++) { - ClassResource img = new ClassResource("smiley.jpg", - main.getApplication()); - Embedded embedded = new Embedded("", img); - grid.addComponent(embedded); - } - main.addComponent(grid); - return; - } - /* Create a 4 by 4 grid layout. */ - final GridLayout grid = new GridLayout(4, 4); - grid.addStyleName("example-gridlayout"); - - /* Fill out the first row using the cursor. */ - grid.addComponent(new Button("R/C 1")); - for (int i = 0; i < 3; i++) { - grid.addComponent(new Button("Col " + (grid.getCursorX() + 1))); - } - - /* Fill out the first column using coordinates. */ - for (int i = 1; i < 4; i++) { - grid.addComponent(new Button("Row " + i), 0, i); - } - - /* Add some components of various shapes. */ - grid.addComponent(new Button("3x1 button"), 1, 1, 3, 1); - grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3); - final InlineDateField date = new InlineDateField("A 2x2 date field"); - date.setResolution(DateField.RESOLUTION_DAY); - grid.addComponent(date, 2, 2, 3, 3); - - main.addComponent(grid); - } - - void example_Alignment(Window main, String param) { - if (param.equals("grid")) { - /* Create a 3 by 3 grid layout. */ - final GridLayout layout = new GridLayout(3, 3); - // OrderedLayout layout = new - // OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - main.setLayout(layout); - layout.addStyleName("example-alignment"); - - layout.setWidth(400, Sizeable.UNITS_PIXELS); - layout.setHeight(400, Sizeable.UNITS_PIXELS); - - /* Define cells and their layouts to create. */ - - Object cells[][] = { - { new Button("Top Left"), - new Integer(AlignmentHandler.ALIGNMENT_LEFT), - new Integer(AlignmentHandler.ALIGNMENT_TOP) }, - { - new Label("Top Center"), - new Integer( - AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER), - new Integer(AlignmentHandler.ALIGNMENT_TOP) }, - { new Label("Top Right"), - new Integer(AlignmentHandler.ALIGNMENT_RIGHT), - new Integer(AlignmentHandler.ALIGNMENT_TOP) }, - { - new Button("Center Left"), - new Integer(AlignmentHandler.ALIGNMENT_LEFT), - new Integer( - AlignmentHandler.ALIGNMENT_VERTICAL_CENTER) }, - { - new Button("Center Center"), - new Integer( - AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER), - new Integer( - AlignmentHandler.ALIGNMENT_VERTICAL_CENTER) }, - { - new Button("Center Right"), - new Integer(AlignmentHandler.ALIGNMENT_RIGHT), - new Integer( - AlignmentHandler.ALIGNMENT_VERTICAL_CENTER) }, - { new Button("Bottom Left"), - new Integer(AlignmentHandler.ALIGNMENT_LEFT), - new Integer(AlignmentHandler.ALIGNMENT_BOTTOM) }, - { - new Button("Bottom Center"), - new Integer( - AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER), - new Integer(AlignmentHandler.ALIGNMENT_BOTTOM) }, - { new Button("Bottom Right"), - new Integer(AlignmentHandler.ALIGNMENT_RIGHT), - new Integer(AlignmentHandler.ALIGNMENT_BOTTOM) } }; - - for (int i = 0; i < 9; i++) { - HorizontalLayout celllayout = new HorizontalLayout(); - celllayout.addComponent((Component) cells[i][0]); - if (i == 0) { - celllayout.setExpandRatio((Component) cells[i][0], 1); - } - - celllayout.setComponentAlignment((Component) cells[i][0], - ((Integer) cells[i][1]).intValue(), - ((Integer) cells[i][2]).intValue()); - layout.addComponent(celllayout); - // layout.setComponentAlignment((Component)cells[i][0], - // ((Integer)cells[i][1]).intValue(), - // ((Integer)cells[i][2]).intValue()); - } - } else { - final Panel panel = new Panel("A Panel with a Layout"); - main.addComponent(panel); - - // panel.addComponent(new ) - } - } - - void example_OrderedLayout(Window main, String param) { - final VerticalLayout layout = new VerticalLayout(); - layout.addComponent(new TextField("Name")); - layout.addComponent(new TextField("Street address")); - layout.addComponent(new TextField("Postal code")); - main.addComponent(layout); - } - - void example_FormLayout(Window main, String param) { - final FormLayout layout = new FormLayout(); - layout.addComponent(new TextField("Text Field")); - layout.addComponent(new CheckBox("Check Box")); - layout.addComponent(new Select("Select")); - main.addComponent(layout); - } - - void example_Form(Window main, String param) { - if (param != null && param.equals("simple")) { - main.addComponent(new FormExample2()); - } else if (param != null && param.equals("layout")) { - Form form = new Form(); - form.setCaption("Form Caption"); - form.setDescription("This is a description of the Form that is " - + "displayed in the upper part of the form. You normally enter some " - + "descriptive text about the form and its use here."); - - // Add a field directly to the layout. This field will not be bound - // to - // the data source Item of the form. - form.getLayout().addComponent(new TextField("A Field")); - - // Add a field and bind it to an named item property. - form.addField("another", new TextField("Another Field")); - - form.setComponentError(new UserError( - "This is the error indicator of the Form.")); - - // Set the footer layout and add some text. - form.setFooter(new VerticalLayout()); - form.getFooter() - .addComponent( - new Label( - "This is the footer area of the Form. " - + "You can use any layout here. This is nice for buttons.")); - - // Add an Ok (commit), Reset (discard), and Cancel buttons for the - // form. - HorizontalLayout okbar = new HorizontalLayout(); - okbar.setHeight("25px"); - Button okbutton = new Button("OK", form, "commit"); - okbar.addComponent(okbutton); - okbar.setExpandRatio(okbutton, 1); - okbar.setComponentAlignment(okbutton, - AlignmentHandler.ALIGNMENT_RIGHT, - AlignmentHandler.ALIGNMENT_TOP); - okbar.addComponent(new Button("Reset", form, "discard")); - okbar.addComponent(new Button("Cancel")); - form.getFooter().addComponent(okbar); - - main.addComponent(form); - } else { - main.addComponent(new FormExample()); - } - } - - void example_ExpandLayout(Window main, String param) { - if (param != null && param.equals("centered")) { - Label widget = new Label("Here is text"); - - HorizontalLayout layout = new HorizontalLayout(); - layout.addComponent(widget); - layout.setExpandRatio(widget, 1); - layout.setComponentAlignment(widget, - AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, - AlignmentHandler.ALIGNMENT_VERTICAL_CENTER); - layout.setWidth(100, Sizeable.UNITS_PERCENTAGE); - layout.setHeight(100, Sizeable.UNITS_PERCENTAGE); - - main.setLayout(layout); - - return; - } else if (param != null && param.equals("window")) { - Window window = new Window("Progress"); - window.setHeight(100, Sizeable.UNITS_PIXELS); - window.setWidth(200, Sizeable.UNITS_PIXELS); - main.addWindow(window); - - ProgressIndicator progress = new ProgressIndicator(new Float(0.4)); - progress.addStyleName("fullwidth"); - progress.setPollingInterval(1000000); - progress.setIndeterminate(false); - - HorizontalLayout layout = new HorizontalLayout(); - layout.setHeight(100, Sizeable.UNITS_PERCENTAGE); - layout.setComponentAlignment(progress, - HorizontalLayout.ALIGNMENT_HORIZONTAL_CENTER, - HorizontalLayout.ALIGNMENT_VERTICAL_CENTER); - window.setLayout(layout); - window.addComponent(progress); - - return; - } else if (param != null && param.equals("root")) { - final Window mainwin = main; - - // Layout to switch to - final VerticalLayout expand2 = new VerticalLayout(); - expand2.addComponent(new Label("I am layout too.")); - - // Original layout - final VerticalLayout expand1 = new VerticalLayout(); - Button switchButton = new Button("Switch to other layout"); - switchButton.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - mainwin.setLayout(null); - mainwin.setLayout(expand2); - } - }); - expand1.addComponent(switchButton); - main.setLayout(expand1); - - return; - } else if (param != null && param.equals("size")) { - VerticalLayout layout = new VerticalLayout(); - layout.setSizeFull(); - main.setLayout(layout); - - Button button = new Button("This is a button in middle of nowhere"); - layout.addComponent(button); - layout.setComponentAlignment(button, - VerticalLayout.ALIGNMENT_HORIZONTAL_CENTER, - VerticalLayout.ALIGNMENT_VERTICAL_CENTER); - layout.setExpandRatio(button, 1.0f); - return; - } - - for (int w = 0; w < 2; w++) { - final VerticalLayout layout = new VerticalLayout(); - - /* Set the expanding layout as the root layout of a child window. */ - final Window window = new Window("A Child Window", layout); - main.addWindow(window); - - /* Add some component above the expanding one. */ - layout.addComponent(new Label("Here be some component.")); - - /* Create the expanding component. */ - final Table table = new Table("My Ever-Expanding Table"); - /* - * FIXME Java 5 -> 1.4 for (int i=0; i<5; i++) - * table.addContainerProperty("col "+(i+1), Integer.class, 0); for - * (int j=0; j<20; j++) table.addItem(new Object[]{1j,2j,3j,4j,5j}, - * j); - */ - layout.addComponent(table); - - /* Designate the table to be the expanding component. */ - layout.setExpandRatio(table, 1.0f); - - /* Set it to use all available area. */ - table.setSizeFull(); - - /* Add some component below the expanding one. */ - final Button button2 = new Button("Ok"); - layout.addComponent(button2); - layout.setComponentAlignment(button2, - AlignmentHandler.ALIGNMENT_RIGHT, 0); - } - } - - void example_TabSheet(Window main, String param) { - if (param != null) { - if (param.equals("simple")) { - // Create an empty tab sheet. - TabSheet tabsheet = new TabSheet(); - - // Create a component to put in a tab and put - // some content in it. - VerticalLayout myTab = new VerticalLayout(); - myTab.addComponent(new Label("Hello, I am a Tab!")); - - // Add the component to the tab sheet as a new tab. - tabsheet.addTab(myTab); - - // Get the Tab holding the component and set its caption. - tabsheet.getTab(myTab).setCaption("My Tab"); - - } else if (param.equals("icon")) { - final TabSheet tabsheet = new TabSheet(); - - tabsheet.addTab( - new Label("Contents of the first tab"), - "First Tab", - new ClassResource("images/Mercury_small.png", main - .getApplication())); - tabsheet.addTab(new Label("Contents of the second tab"), - "Second Tab", new ClassResource( - "images/Venus_small.png", this)); - tabsheet.addTab(new Label("Contents of the third tab"), - "Third tab", new ClassResource( - "images/Earth_small.png", this)); - - main.addComponent(tabsheet); - // main.addComponent(new Embedded("Emb", new ClassResource - // ("images/Mercury_small.png", this))); - } else if (param.equals("expanding")) { - // Create the layout - VerticalLayout layout = new VerticalLayout(); - - // It is important to set the expanding layout as the root - // layout - // of the containing window, in this case the main window, and - // not - // use addComponent(), which would place the layout inside the - // default root layout. - main.setLayout(layout); - - // Create a tab sheet that fills the expanding layout - final TabSheet tabsheet = new TabSheet(); - tabsheet.addTab(new Label("Contents of the first tab"), - "First Tab", null); - tabsheet.addTab(new Label("Contents of the second tab"), - "Second Tab", null); - tabsheet.addTab(new Label("Contents of the third tab"), - "Third tab", null); - - // Set the tabsheet to scale to full size inside its container - tabsheet.setWidth(100, Sizeable.UNITS_PERCENTAGE); - tabsheet.setHeight(100, Sizeable.UNITS_PERCENTAGE); - - // Add the tab sheet to the layout as usual - layout.addComponent(tabsheet); - - // Set the tab sheet to be the expanding component - layout.setExpandRatio(tabsheet, 1); - } else if (param.equals("ordered")) { - // Create the layout - VerticalLayout layout = new VerticalLayout(); - - // It is important to set the expanding layout as the root - // layout - // of the containing window, in this case the main window, and - // not - // use addComponent(), which would place the layout inside the - // default root layout. - main.setLayout(layout); - - // Create a tab sheet that fills the expanding layout - final TabSheet tabsheet = new TabSheet(); - tabsheet.addTab(new Label("Contents of the first tab"), - "First Tab", null); - tabsheet.addTab(new Label("Contents of the second tab"), - "Second Tab", null); - tabsheet.addTab(new Label("Contents of the third tab"), - "Third tab", null); - - // Set the tabsheet to scale to full size inside its container - tabsheet.setWidth(100, Sizeable.UNITS_PERCENTAGE); - // tabsheet().setHeight(100, Sizeable.UNITS_PERCENTAGE); - - // Add the tab sheet to the layout as usual - layout.addComponent(tabsheet); - } - } else { - main.addComponent(new TabSheetExample()); - } - } - - void example_Embedded(Window main, String param) { - final Embedded image = new Embedded("", new ClassResource("smiley.jpg", - this)); - image.addStyleName("omaimage"); - main.addComponent(image); - - final EmbeddedButton button = new EmbeddedButton(new ClassResource( - "smiley.jpg", this)); - main.addComponent(button); - } - - void example_Window(Window main, String param) { - if (param != null) { - if (param.equals("opener")) { - main.addComponent(new WindowOpener("Window Opener", main)); - } else if (param.equals("multiple")) { - /* Create a new window. */ - final Window mywindow = new Window("Second Window"); - mywindow.setName("mywindow"); - mywindow.addComponent(new Label("This is a second window.")); - - /* Add the window to the application. */ - main.getApplication().addWindow(mywindow); - - /* Add link to the second window in the main window. */ - main.addComponent(new Label("Second window: <a href='" - + mywindow.getURL() + "'>middle-click to open</a>", - Label.CONTENT_XHTML)); - main.addComponent(new Label( - "The second window can be accessed through URL: " - + mywindow.getURL())); - } - return; - } - - /* Create a new window. */ - final Window mywindow = new Window("My Window"); - mywindow.setName("mywindow"); - - /* Add some components in the window. */ - mywindow.addComponent(new Label("A text label in the window.")); - final Button okbutton = new Button("OK"); - mywindow.addComponent(okbutton); - - /* Set window size. */ - mywindow.setHeight("200px"); - mywindow.setWidth("400px"); - - /* Set window position. */ - mywindow.setPositionX(200); - mywindow.setPositionY(50); - - /* Add the window to the Application object. */ - main.addWindow(mywindow); - - } - - void example_ClassResource(Window main, String param) { - final DateField df = new DateField(); - main.addComponent(df); - df.setIcon(new ClassResource("smiley.jpg", main.getApplication())); - main.addComponent(new Embedded("This is Embedded", new ClassResource( - "smiley.jpg", main.getApplication()))); - } - - void example_ProgressIndicator(final Window main, String param) { - if (param != null) { - if (param.equals("thread")) { - - // Create the indicator - final ProgressIndicator indicator = new ProgressIndicator( - new Float(0.0)); - main.addComponent(indicator); - - // Set polling frequency to 0.5 seconds. - indicator.setPollingInterval(1000); - - // indicator.addStyleName("invisible"); - final Label text = new Label("-- Not running --"); - main.addComponent(text); - - // Add a button to start the progress - final Button button = new Button("Click to start"); - main.addComponent(button); - - // Another thread to do some work - class WorkThread extends Thread { - @Override - public void run() { - double current = 0.0; - while (true) { - // Do some "heavy work" - try { - sleep(50); // Sleep for 50 milliseconds - } catch (InterruptedException e) { - } - - // Grow the progress value until it reaches 1.0. - current += 0.01; - if (current > 1.0) { - indicator.setValue(new Float(1.0)); - } else { - indicator.setValue(new Float(current)); - } - - // After the progress is full for a while, stop. - if (current > 1.2) { - // Restore the state to initial. - indicator.setValue(new Float(0.0)); - button.setVisible(true); - break; - } - } - } - } - - // Clicking the button creates and runs a work thread - button.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - final WorkThread thread = new WorkThread(); - thread.start(); - - // The button hides until the work is done. - button.setVisible(false); - } - }); - } else if (param.equals("window")) { - // Create a table in the main window to hold items added in the - // second window - final Table table = new Table(); - table.setPageLength(5); - table.setWidth(100, Sizeable.UNITS_PERCENTAGE); - table.addContainerProperty("Name", String.class, ""); - main.addComponent(table); - - // Create the second window - final Window adderWindow = new Window("Add Items"); - adderWindow.setName("win-adder"); - main.getApplication().addWindow(adderWindow); - - // Create selection component to add items to the table - final NativeSelect select = new NativeSelect( - "Select item to add"); - select.setImmediate(true); - adderWindow.addComponent(select); - - // Add some items to the selection - String items[] = new String[] { "-- Select --", "Mercury", - "Venus", "Earth", "Mars", "Jupiter", "Saturn", - "Uranus", "Neptune" }; - for (int i = 0; i < items.length; i++) { - select.addItem(items[i]); - } - select.setNullSelectionItemId(items[0]); - - // When an item is selected in the second window, add - // table in the main window - select.addListener(new ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - // If the selected value is something else but null - // selection item. - if (select.getValue() != null) { - // Add the selected item to the table in the main - // window - table.addItem(new Object[] { select.getValue() }, - new Integer(table.size())); - } - } - }); - - // Link to open the selection window - Link link = new Link("Click to open second window", - new ExternalResource(adderWindow.getURL()), "_new", 50, - 200, Link.TARGET_BORDER_DEFAULT); - main.addComponent(link); - - // Enable polling to update the main window - ProgressIndicator poller = new ProgressIndicator(); - poller.addStyleName("invisible"); - main.addComponent(poller); - } else if (param.equals("centered")) { - /* - * GridLayout grid = new GridLayout(3,3); main.setLayout(grid); - * grid().setWidth(100, Sizeable.UNITS_PERCENTAGE); - * - * ExpandLayout layout2 = new - * ExpandLayout(OrderedLayout.ORIENTATION_HORIZONTAL); - * layout2().setWidth(50, Sizeable.UNITS_PERCENTAGE); - * - * ProgressIndicator poller = new ProgressIndicator(new - * Float(0.4)); poller.setPollingInterval(1000000); - * poller.setIndeterminate(false); layout2.addComponent(poller); - * - * grid.addComponent(layout2, 1, 1); - */ - - // ExpandLayout layout2 = new - // ExpandLayout(OrderedLayout.ORIENTATION_HORIZONTAL); - /* - * ProgressIndicator poller = new ProgressIndicator(new - * Float(0.4)); poller.setPollingInterval(1000000); - * poller.setIndeterminate(false); - */ - /* - * layout2.addComponent(poller); layout2().setWidth(50, - * Sizeable.UNITS_PERCENTAGE); - */ - - // layout.setComponentAlignment(poller, - // AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, - // AlignmentHandler.ALIGNMENT_VERTICAL_CENTER); - /* - * GridLayout grid = new GridLayout(1,1); - * grid.addComponent(layout2, 0, 0); grid().setWidth(100, - * Sizeable.UNITS_PERCENTAGE); - */ - - /* - * GridLayout layout = new GridLayout(1,1); - * //OrderedLayout.ORIENTATION_HORIZONTAL); - * layout.addComponent(poller); //layout.expand(poller); - * layout.setComponentAlignment(poller, - * AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, - * AlignmentHandler.ALIGNMENT_VERTICAL_CENTER); - * layout().setWidth(100, Sizeable.UNITS_PERCENTAGE); - * layout().setHeight(100, Sizeable.UNITS_PERCENTAGE); - */ - - } - } else { - ProgressIndicator poller = new ProgressIndicator(new Float(0.0)); - poller.setPollingInterval(1000000); - poller.setIndeterminate(true); - main.addComponent(poller); - } - } - - void example_CustomLayout(final Window main, String param) { - Window sub = new Window("Login"); - sub.setModal(true); - main.addWindow(sub); - - // Create the custom layout and set it as the root layout of - // the containing window. - final CustomLayout custom = new CustomLayout("layoutname"); - sub.setLayout(custom); - - // Create components and bind them to the location tags - // in the custom layout. - TextField username = new TextField(); - custom.addComponent(username, "username"); - - TextField password = new TextField(); - custom.addComponent(password, "password"); - - final Button ok = new Button("Login"); - custom.addComponent(ok, "okbutton"); - - final Button deny = new Button("No can do!"); - - Button.ClickListener listener = new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - // Switch between ok and deny - if (custom.getComponent("okbutton") == ok) { - System.out.println("Changing to deny button."); - custom.addComponent(deny, "okbutton"); - } else { - System.out.println("Changing to ok button."); - custom.addComponent(ok, "okbutton"); - } - } - }; - - ok.addListener(listener); - deny.addListener(listener); - } - - void example_Spacing(final Window main, String param) { - VerticalLayout containinglayout = new VerticalLayout(); - main.setLayout(containinglayout); - - GridLayout grid = new GridLayout(4, 3); - grid.addStyleName("spacingexample"); - containinglayout.addComponent(grid); - grid.addComponent(new Label(""), 0, 0); - grid.addComponent(new Label(""), 1, 0); - - grid.addComponent(new Label("No spacing:"), 0, 1); - HorizontalLayout layout1 = new HorizontalLayout(); - grid.addComponent(layout1, 1, 1); - layout1.addStyleName("spacingexample"); - layout1.addComponent(new Button("Component 1")); - layout1.addComponent(new Button("Component 2")); - layout1.addComponent(new Button("Component 3")); - - grid.addComponent(new Label("Horizontal spacing:"), 0, 2); - HorizontalLayout layout2 = new HorizontalLayout(); - grid.addComponent(layout2, 1, 2); - layout2.addStyleName("spacingexample"); - layout2.setSpacing(true); - layout2.addComponent(new Button("Component 1")); - layout2.addComponent(new Button("Component 2")); - layout2.addComponent(new Button("Component 3")); - - grid.addComponent(new Label("No spacing:"), 2, 0); - VerticalLayout layout3 = new VerticalLayout(); - grid.addComponent(layout3, 2, 1, 2, 2); - layout3.addStyleName("spacingexample"); - layout3.addComponent(new Button("Component 1")); - layout3.addComponent(new Button("Component 2")); - layout3.addComponent(new Button("Component 3")); - - grid.addComponent(new Label("Vertical spacing:"), 3, 0); - VerticalLayout layout4 = new VerticalLayout(); - grid.addComponent(layout4, 3, 1, 3, 2); - layout4.addStyleName("spacingexample"); - layout4.setSpacing(true); - layout4.addComponent(new Button("Component 1")); - layout4.addComponent(new Button("Component 2")); - layout4.addComponent(new Button("Component 3")); - } - - void example_Margin(final Window main, String param) { - HorizontalLayout hor = new HorizontalLayout(); - main.setLayout(hor); - - VerticalLayout containinglayout = new VerticalLayout(); - hor.addComponent(containinglayout); - - VerticalLayout layout1 = new VerticalLayout(); - containinglayout.addComponent(new Label("Regular layout margins:")); - containinglayout.addComponent(layout1); - layout1.addStyleName("marginexample1"); - layout1.addComponent(new Button("Component 1")); - layout1.addComponent(new Button("Component 2")); - layout1.addComponent(new Button("Component 3")); - - // Create a layout - VerticalLayout layout2 = new VerticalLayout(); - containinglayout.addComponent(new Label( - "Layout with a special margin element:")); - containinglayout.addComponent(layout2); - - // Set style name for the layout to allow styling it - layout2.addStyleName("marginexample2"); - - // Have margin on all sides around the layout - layout2.setMargin(true); - - // Put something inside the layout - layout2.addComponent(new Button("Component 1")); - layout2.addComponent(new Button("Component 2")); - layout2.addComponent(new Button("Component 3")); - } - - void example_ClientInfo(final Window main, String param) { - // Get the client identification string - WebApplicationContext context2 = (WebApplicationContext) getContext(); - String browserApplication = context2.getBrowser() - .getBrowserApplication(); - - // Add a browser-dependent style name for the main window - if (browserApplication.indexOf("Firefox/2") != -1) { - main.addStyleName("firefox2"); - } - - // Display the client identification string - main.addComponent(new Label(browserApplication)); - } - - void example_FillInForm(final Window main, String param) { - if (param.equals("templates")) { - // Create a custom layout from the fill-in-form.html template. - CustomLayout fillinlayout = new CustomLayout("fill-in-form"); - - // The style will set the display to be "inline". - fillinlayout.addStyleName("fillinlayout"); - - // Create the fields that occur in the text. - TextField field1 = new TextField(); - TextField field2 = new TextField(); - fillinlayout.addComponent(field1, "q1"); - fillinlayout.addComponent(field2, "q2"); - - main.addComponent(fillinlayout); - } else { - String fillintext = "The <q1> is mightier than <q2>."; - int pos = 0; - while (pos < fillintext.length()) { - int nexttag = fillintext.indexOf("<", pos); - if (nexttag == -1) { - - } - } - } - } - - void example_Notification(final Window main, String param) { - // final Window sub1 = new Window(""); - // main.addWindow(sub1); - if (param.equals("example")) { - main.showNotification("This is the caption", - "This is the description"); - return; - } else if (param.equals("type")) { - main.showNotification("This is a warning", - "<br/>This is the <i>last</i> warning", - Window.Notification.TYPE_WARNING_MESSAGE); - return; - } else if (param.equals("pos")) { - // Create a notification with the default settings for a warning. - Window.Notification notif = new Window.Notification("Be warned!", - "This message lurks in the top-left corner!", - Window.Notification.TYPE_WARNING_MESSAGE); - - // Set the position. - notif.setPosition(Window.Notification.POSITION_TOP_LEFT); - - // Let it stay there until the user clicks it - notif.setDelayMsec(-1); - - // Show it in the main window. - main.showNotification(notif); - return; - } - - main.setLayout(new HorizontalLayout()); - - final Integer type_humanized = Window.Notification.TYPE_HUMANIZED_MESSAGE; - final Integer type_warning = Window.Notification.TYPE_WARNING_MESSAGE; - final Integer type_error = Window.Notification.TYPE_ERROR_MESSAGE; - final Integer type_tray = Window.Notification.TYPE_TRAY_NOTIFICATION; - final NativeSelect types = new NativeSelect(); - main.addComponent(types); - types.addItem(type_humanized); - types.addItem(type_warning); - types.addItem(type_error); - types.addItem(type_tray); - types.setItemCaption(type_humanized, "Humanized"); - types.setItemCaption(type_warning, "Warning"); - types.setItemCaption(type_error, "Error"); - types.setItemCaption(type_tray, "Tray"); - - Button show = new Button("Show Notification"); - main.addComponent(show); - - show.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - String caption = ""; - String description = ""; - switch (((Integer) types.getValue()).intValue()) { - case Window.Notification.TYPE_HUMANIZED_MESSAGE: - caption = "Humanized message"; - description = "<br/>For minimal annoyance"; - break; - case Window.Notification.TYPE_WARNING_MESSAGE: - caption = "Warning message"; - description = "<br/>For notifications of medium importance"; - break; - case Window.Notification.TYPE_ERROR_MESSAGE: - caption = "Error message"; - description = "<br/>For important notifications"; - break; - case Window.Notification.TYPE_TRAY_NOTIFICATION: - caption = "Tray notification"; - description = "<br/>Stays up longer - but away"; - } - // main.showNotification("The default notification"); - Window.Notification notif = new Window.Notification(caption, - description, (Integer) types.getValue()); - // notif.setPosition(Window.Notification.POSITION_TOP_LEFT); - notif.setDelayMsec(-1); - main.showNotification(notif); - } - }); - - // Notification notif = new Notification("Title"); - } - - void example_Print(final Window main, String param) { - if (param != null && param.equals("simple")) { - main.addComponent(new Label( - "<input type='button' onClick='print()' value='Click to Print'/>", - Label.CONTENT_XHTML)); - return; - } - - // A button to open the printer-friendly page. - Button printButton = new Button("Click to Print"); - main.addComponent(printButton); - printButton.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - // Create a window that contains stuff you want to print. - Window printWindow = new Window("Window to Print"); - - // Have some content to print. - printWindow.addComponent(new Label( - "Here's some dynamic content.")); - - // To execute the print() JavaScript, we need to run it - // from a custom layout. - CustomLayout scriptLayout = new CustomLayout("printpage"); - printWindow.addComponent(scriptLayout); - - // Add the printing window as an application-level window. - main.getApplication().addWindow(printWindow); - - // Open the printing window as a new browser window - main.open(new ExternalResource(printWindow.getURL()), "_new"); - } - }); - - // main.addComponent(new - // Label("<p>Print this!</p>\n<script type='text/javascript'>print();</script>", - // Label.CONTENT_XHTML)); - } - - void example_RichTextArea(final Window main, String param) { - main.setLayout(new HorizontalLayout()); - - // Create a rich text area - final RichTextArea rtarea = new RichTextArea(); - rtarea.addStyleName("richtextexample"); - // rtarea.setCaption("My Rich Text Area"); - - // Set initial content as HTML - rtarea.setValue("<h1>Hello</h1>\n<p>This rich text area contains some text.</p>"); - - // Show the text edited in the rich text area as HTML. - final Button show = new Button("Show HTML"); - final Label html = new Label((String) rtarea.getValue()); - show.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - html.setValue(rtarea.getValue()); - } - }); - - Panel rtPanel = new Panel("Rich Text Area"); - rtPanel.addComponent(rtarea); - rtPanel.addComponent(show); - - Panel valuePanel = new Panel("Value"); - valuePanel.addComponent(html); - - main.addComponent(rtPanel); - main.addComponent(valuePanel); - } - - void example_QueryContainer(final Window main, String param) { - try { - // Create a database connection - Class.forName("org.hsqldb.jdbcDriver"); - final Connection connection = DriverManager.getConnection( - "jdbc:hsqldb:mem:qcexample", "sa", ""); - - // Create an example table and put some data in it. - Statement st = connection.createStatement(); - st.executeQuery("CREATE TABLE Prisoners (id INTEGER, name VARCHAR)"); - st.close(); - for (int i = 0; i < 100; i++) { - st = connection.createStatement(); - st.executeQuery("INSERT INTO Prisoners (id, name) VALUES (" + i - + ",'I am number " + (i + 1) + "')"); - st.close(); - } - - // Query the database - final QueryContainer qc = new QueryContainer( - "SELECT id,name FROM Prisoners", connection); - - // Create a component for selecting a query result item. - Select select = new Select("Select an item"); - - // The items shown in the selection component are obtained from the - // query. - select.setContainerDataSource(qc); - - // The item captions are obtained from a field in the query result. - select.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY); - - // Set the name of the field from which the item captions are - // obtained. - select.setItemCaptionPropertyId("name"); - - // When selection changes, display the selected item. - select.setImmediate(true); - final Label selection = new Label("Currently selected: -"); - select.addListener(new ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - // Get the item id of the currently selected item - Integer itemId = (Integer) event.getProperty().getValue(); - - // Use the item ID to get the actual row from the query - // result. - Item qrItem = qc.getItem(itemId); - - // Display the item ID - selection.setValue("Currently selected: result row " - + itemId.intValue() + " (id=" - + qrItem.getItemProperty("id") + ", " + "name=" - + qrItem.getItemProperty("name") + ")"); - } - }); - - main.addComponent(select); - main.addComponent(selection); - } catch (SQLException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - - void example_MenuBar(final Window main, String param) { - // Create a menu bar - final MenuBar menubar = new MenuBar(); - main.addComponent(menubar); - - // A feedback component - final Label selection = new Label(""); - main.addComponent(selection); - - // Define a common menu command for all the menu items. - MenuBar.Command mycommand = new MenuBar.Command() { - public void menuSelected(MenuItem selectedItem) { - selection.setValue("Ordered a " + selectedItem.getText() - + " from menu."); - } - }; - - // Put some items in the menu hierarchically - MenuBar.MenuItem beverages = menubar.addItem("Beverages", null, null); - MenuBar.MenuItem hot_beverages = beverages.addItem("Hot", null, null); - hot_beverages.addItem("Tea", null, mycommand); - hot_beverages.addItem("Coffee", null, mycommand); - MenuBar.MenuItem cold_beverages = beverages.addItem("Cold", null, null); - cold_beverages.addItem("Milk", null, mycommand); - - // Another top-level item - MenuBar.MenuItem snacks = menubar.addItem("Snacks", null, null); - snacks.addItem("Weisswurst", null, mycommand); - snacks.addItem("Salami", null, mycommand); - - // Yet another top-level item - MenuBar.MenuItem services = menubar.addItem("Services", null, null); - services.addItem("Car Service", null, mycommand); - } - - void example_AbsoluteLayout(final Window main, String param) { - AbsoluteLayout layout = new AbsoluteLayout(); - layout.setWidth("400px"); - layout.setHeight("400px"); - main.setContent(layout); - - final Button button = new Button("This could be anywhere"); - layout.addComponent(button, "top: 100px; left: 50px;"); - } - - void example_Layout(final Window main, String param) { - if (param.equals("intro")) { - // Set the root layout (VerticalLayout is actually the default). - VerticalLayout root = new VerticalLayout(); - main.setContent(root); - - // Add some components. - Label title = new Label("The Ultimate Cat Finder"); - main.addComponent(title); - - // Horizontal layout with selection tree on the left and - // a details panel on the right. - HorizontalLayout horlayout = new HorizontalLayout(); - main.addComponent(horlayout); - - // Layout for the left-hand side - VerticalLayout treeContainer = new VerticalLayout(); - horlayout.addComponent(treeContainer); - - // Add some instructions. - treeContainer - .addComponent(new Label("The Planets and Major Moons")); - - // A selection tree, fill it later. - Tree tree = new Tree(); - treeContainer.addComponent(tree); - - // A panel for the right size area. - Panel detailspanel = new Panel("Details"); - detailspanel.setSizeFull(); - horlayout.addComponent(detailspanel); - - // Have a vertical layout in the Details panel. - VerticalLayout detailslayout = new VerticalLayout(); - detailspanel.setContent(detailslayout); - - // Put some stuff in the Details view. - detailslayout.addComponent(new Label("Where is the cat?")); - detailslayout.addComponent(new Label("I don't know!")); - - // // // // // // - - horlayout.setExpandRatio(detailspanel, 1); - horlayout.setExpandRatio(treeContainer, 0); - horlayout.setSizeFull(); - horlayout.setSpacing(true); - - root.addStyleName("layoutexample"); - root.setSizeFull(); - root.setExpandRatio(horlayout, 1); - - title.addStyleName("title"); - tree.setSizeUndefined(); - tree.setHeight("100%"); - treeContainer.addStyleName("treecontainer"); - treeContainer.setSizeUndefined(); - treeContainer.setHeight("100%"); - treeContainer.setExpandRatio(tree, 1); - detailspanel.addStyleName("light"); - - for (Iterator i = detailslayout.getComponentIterator(); i.hasNext();) { - Label c = (Label) i.next(); - detailslayout.setComponentAlignment(c, Alignment.MIDDLE_CENTER); - c.setSizeUndefined(); - } - - final Object[][] planets = new Object[][] { - new Object[] { "Mercury" }, - new Object[] { "Venus" }, - new Object[] { "Earth", "The Moon" }, - new Object[] { "Mars", "Phobos", "Deimos" }, - new Object[] { "Jupiter", "Io", "Europa", "Ganymedes", - "Callisto" }, - new Object[] { "Saturn", "Titan", "Tethys", "Dione", - "Rhea", "Iapetus" }, - new Object[] { "Uranus", "Miranda", "Ariel", "Umbriel", - "Titania", "Oberon" }, - new Object[] { "Neptune", "Triton", "Proteus", "Nereid", - "Larissa" } }; - - // Add planets as root items in the tree. - for (int i = 0; i < planets.length; i++) { - final String planet = (String) (planets[i][0]); - tree.addItem(planet); - - if (planets[i].length == 1) { - // The planet has no moons so make it a leaf. - tree.setChildrenAllowed(planet, false); - } else { - // Add children (moons) under the planets. - for (int j = 1; j < planets[i].length; j++) { - final String moon = (String) planets[i][j]; - - // Add the item as a regular item. - tree.addItem(moon); - - // Set it to be a child. - tree.setParent(moon, planet); - - // Make the moons look like leaves. - tree.setChildrenAllowed(moon, false); - } - - // Expand the subtree. - tree.expandItemsRecursively(planet); - } - } - - } - } -} diff --git a/tests/src/com/vaadin/tests/book/ChatApplication.java b/tests/src/com/vaadin/tests/book/ChatApplication.java deleted file mode 100644 index d6470dcc4f..0000000000 --- a/tests/src/com/vaadin/tests/book/ChatApplication.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.vaadin.tests.book; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import com.vaadin.Application; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Window; - -public class ChatApplication extends Application implements - Button.ClickListener { - /* - * ChatApplication instances of different users. Warning: a hack, not safe, - * because sessions can expire. - */ - static List users = new ArrayList(); - - /* Messages as a shared list. */ - static List messages = new ArrayList(); - int localSize = 0; - - /* User interface. */ - Table messageTable = new Table(); - TextField username = new TextField("Username:"); - TextField message = new TextField("Message:"); - - @Override - public void init() { - final Window main = new Window("Chat"); - setMainWindow(main); - setTheme("tests-magi"); - users.add(this); - - main.addComponent(username); - - main.addComponent(messageTable); - messageTable.addContainerProperty("Sender", String.class, ""); - messageTable.addContainerProperty("Message", String.class, ""); - updateTable(); - - main.addComponent(message); - - Button send = new Button("Send"); - send.addListener(this); - main.addComponent(send); - - // Poll for new messages once a second. - ProgressIndicator poller = new ProgressIndicator(); - poller.addStyleName("invisible"); - main.addComponent(poller); - } - - public void buttonClick(ClickEvent event) { - synchronized (users) { - // Create the new message in the shared list. - messages.add(new String[] { - new String((String) username.getValue()), - new String((String) message.getValue()) }); - - // Update the message tables for all users. - for (Iterator i = users.iterator(); i.hasNext();) { - ((ChatApplication) i.next()).updateTable(); - } - } - } - - void updateTable() { - if (localSize == messages.size()) { - return; // No updating needed - } - - // Add new messages to the table - while (localSize < messages.size()) { - messageTable.addItem((Object[]) messages.get(localSize++), - new Integer(localSize - 1)); - } - } -} diff --git a/tests/src/com/vaadin/tests/book/DefaultButtonExample.java b/tests/src/com/vaadin/tests/book/DefaultButtonExample.java deleted file mode 100644 index c1520c208d..0000000000 --- a/tests/src/com/vaadin/tests/book/DefaultButtonExample.java +++ /dev/null @@ -1,94 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.event.Action; -import com.vaadin.event.Action.Handler; -import com.vaadin.event.ShortcutAction; -import com.vaadin.ui.Button; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TextField; - -public class DefaultButtonExample extends CustomComponent implements Handler { - // Define and create user interface components - Panel panel = new Panel("Login"); - FormLayout formlayout = new FormLayout(); - TextField username = new TextField("Username"); - TextField password = new TextField("Password"); - HorizontalLayout buttons = new HorizontalLayout(); - - // Create buttons and define their listener methods. - Button ok = new Button("OK", this, "okHandler"); - Button cancel = new Button("Cancel", this, "cancelHandler"); - - // Have the unmodified Enter key cause an event - Action action_ok = new ShortcutAction("Default key", - ShortcutAction.KeyCode.ENTER, null); - - // Have the C key modified with Alt cause an event - Action action_cancel = new ShortcutAction("Alt+C", - ShortcutAction.KeyCode.C, - new int[] { ShortcutAction.ModifierKey.ALT }); - - public DefaultButtonExample() { - // Set up the user interface - setCompositionRoot(panel); - panel.addComponent(formlayout); - formlayout.addComponent(username); - formlayout.addComponent(password); - formlayout.addComponent(buttons); - buttons.addComponent(ok); - buttons.addComponent(cancel); - - // Set focus to username - username.focus(); - - // Set this object as the action handler - System.out.println("adding ah"); - panel.addActionHandler(this); - - System.out.println("start done."); - } - - /** - * Retrieve actions for a specific component. This method will be called for - * each object that has a handler; in this example just for login panel. The - * returned action list might as well be static list. - */ - public Action[] getActions(Object target, Object sender) { - System.out.println("getActions()"); - return new Action[] { action_ok, action_cancel }; - } - - /** - * Handle actions received from keyboard. This simply directs the actions to - * the same listener methods that are called with ButtonClick events. - */ - public void handleAction(Action action, Object sender, Object target) { - if (action == action_ok) { - okHandler(); - } - if (action == action_cancel) { - cancelHandler(); - } - } - - public void okHandler() { - // Do something: report the click - formlayout.addComponent(new Label("OK clicked. " + "User=" - + username.getValue() + ", password=" + password.getValue())); - // - } - - public void cancelHandler() { - // Do something: report the click - formlayout.addComponent(new Label("Cancel clicked. User=" - + username.getValue() + ", password=" + password.getValue())); - } -} diff --git a/tests/src/com/vaadin/tests/book/EmbeddedButton.java b/tests/src/com/vaadin/tests/book/EmbeddedButton.java deleted file mode 100644 index 2ed67f0305..0000000000 --- a/tests/src/com/vaadin/tests/book/EmbeddedButton.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.terminal.Resource; -import com.vaadin.ui.Button; -import com.vaadin.ui.CustomComponent; - -public class EmbeddedButton extends CustomComponent implements - Button.ClickListener { - Button thebutton; - - public EmbeddedButton(Resource icon) { - /* Create a Button without a caption. */ - thebutton = new Button(); - - /* Set the icon of the button from a resource. */ - thebutton.setIcon(icon); - - /* - * Set the style to link; this leaves out the button frame so you just - * have the image in the link. - */ - thebutton.setStyle("link"); - - /* Listen for ClickEvents. */ - thebutton.addListener(this); - - setCompositionRoot(thebutton); - } - - /** Handle button click events from the button. */ - public void buttonClick(Button.ClickEvent event) { - thebutton.setIcon(null); - thebutton.setCaption("You successfully clicked on the icon"); - } -} diff --git a/tests/src/com/vaadin/tests/book/FormExample.java b/tests/src/com/vaadin/tests/book/FormExample.java deleted file mode 100644 index 0c50df736b..0000000000 --- a/tests/src/com/vaadin/tests/book/FormExample.java +++ /dev/null @@ -1,228 +0,0 @@ -package com.vaadin.tests.book; - -import java.util.Vector; - -import com.vaadin.data.Container; -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Validator; -import com.vaadin.data.util.BeanItem; -import com.vaadin.ui.Button; -import com.vaadin.ui.Component; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.ExpandLayout; -import com.vaadin.ui.Field; -import com.vaadin.ui.FieldFactory; -import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Select; -import com.vaadin.ui.TextField; - -/** - * This example demonstrates the most important features of the Form component: - * binding Form to a JavaBean so that form fields are automatically generated - * from the bean properties, creation of fields with proper types for each bean - * properly using a FieldFactory, buffering (commit/discard), and validation. - * - * The Form is used with a FormLayout, which automatically lays the components - * out in a format typical for forms. - */ -public class FormExample extends CustomComponent { - /** Contact information data model. */ - public class Contact { - String name = ""; - String address = ""; - int postalCode = 20540; - String city; - } - - /** Bean wrapper for the data model. */ - public class ContactBean extends Contact { - public ContactBean() { - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getAddress() { - return address; - } - - public void setPostalCode(String postalCode) { - try { - if (postalCode != null) { - this.postalCode = Integer.parseInt(postalCode); - } else { - this.postalCode = 0; - } - } catch (NumberFormatException e) { - this.postalCode = 0; - } - } - - public String getPostalCode() { - if (postalCode > 0) { - return String.valueOf(postalCode); - } else { - return ""; - } - } - - public void setCity(String city) { - this.city = city; - } - - public String getCity() { - return city; - } - } - - /** - * Factory to create the proper type of field for each property type. We - * need to implement just one of the factory methods. - */ - class MyFieldFactory implements FieldFactory { - - public Field createField(Class type, Component uiContext) { - return null; - } - - public Field createField(Property property, Component uiContext) { - return null; - } - - public Field createField(Item item, Object propertyId, - Component uiContext) { - String pid = (String) propertyId; - - if (pid.equals("name")) { - return new TextField("Name"); - } - - if (pid.equals("address")) { - return new TextField("Street Address"); - } - - if (pid.equals("postalCode")) { - TextField field = new TextField("Postal Code"); - field.setColumns(5); - Validator postalCodeValidator = new Validator() { - - public boolean isValid(Object value) { - if (value == null || !(value instanceof String)) { - return false; - } - - return ((String) value).matches("[0-9]{5}"); - } - - public void validate(Object value) - throws InvalidValueException { - if (!isValid(value)) { - throw new InvalidValueException( - "Postal code must be a number 10000-99999."); - } - } - }; - field.addValidator(postalCodeValidator); - return field; - } - - if (pid.equals("city")) { - Select select = new Select("City"); - final String cities[] = new String[] { "Amsterdam", "Berlin", - "Helsinki", "Hong Kong", "London", "Luxemburg", - "New York", "Oslo", "Paris", "Rome", "Stockholm", - "Tokyo", "Turku" }; - for (int i = 0; i < cities.length; i++) { - select.addItem(cities[i]); - } - return select; - } - return null; - } - - public Field createField(Container container, Object itemId, - Object propertyId, Component uiContext) { - return null; - } - } - - public FormExample() { - // Create a form. It will use FormLayout as its layout by default. - final Form form = new Form(); - - // Set form caption and description texts. - form.setCaption("Contact Information"); - form.setDescription("Please enter valid name and address. Fields marked with * are required."); - - // Use custom field factory to create the fields in the form. - form.setFieldFactory(new MyFieldFactory()); - - // Create the custom bean. - ContactBean bean = new ContactBean(); - - // Create a bean item that is bound to the bean. - BeanItem item = new BeanItem(bean); - - // Bind the bean item as the data source for the form. - form.setItemDataSource(item); - - // Set the order of the items in the form. - Vector order = new Vector(); - order.add("name"); - order.add("address"); - order.add("postalCode"); - order.add("city"); - form.setVisibleItemProperties(order); - - // Set required fields. The required error is displayed in - // the error indication are of the Form if a required - // field is empty. If it is not set, no error is displayed - // about an empty required field. - form.getField("name").setRequired(true); - form.getField("name").setRequiredError("Name is missing"); - form.getField("address").setRequired(true); // No error message - - // Set the form to act immediately on user input. This is - // necessary for the validation of the fields to occur immediately when - // the input focus changes and not just on commit. - form.setImmediate(true); - - // Set buffering so that commit() must be called for the form - // before input is written to the data. (Input is not written - // immediately through). - form.setWriteThrough(false); - form.setReadThrough(false); - - // Add Commit and Discard controls to the form. - ExpandLayout footer = new ExpandLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); - - // The Commit button calls form.commit(). - Button commit = new Button("Commit", form, "commit"); - - // The Discard button calls form.discard(). - Button discard = new Button("Discard", form, "discard"); - footer.addComponent(commit); - footer.setComponentAlignment(commit, ExpandLayout.ALIGNMENT_RIGHT, - ExpandLayout.ALIGNMENT_TOP); - footer.setHeight("25px"); - footer.addComponent(discard); - form.setFooter(footer); - - OrderedLayout root = new OrderedLayout(); - root.setWidth(400, OrderedLayout.UNITS_PIXELS); - root.addComponent(form); - setCompositionRoot(root); - } -} diff --git a/tests/src/com/vaadin/tests/book/FormExample2.java b/tests/src/com/vaadin/tests/book/FormExample2.java deleted file mode 100644 index d19a317966..0000000000 --- a/tests/src/com/vaadin/tests/book/FormExample2.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.vaadin.tests.book; - -import java.util.Vector; - -import com.vaadin.data.Container; -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.util.BeanItem; -import com.vaadin.ui.Component; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Field; -import com.vaadin.ui.FieldFactory; -import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Select; -import com.vaadin.ui.TextField; - -/** - * This example demonstrates the most important features of the Form component: - * binding Form to a JavaBean so that form fields are automatically generated - * from the bean properties, creation of fields with proper types for each bean - * properly using a FieldFactory, buffering (commit/discard), and validation. - * - * The Form is used with a FormLayout, which automatically lays the components - * out in a format typical for forms. - */ -public class FormExample2 extends CustomComponent { - /** A simple JavaBean. */ - public class PersonBean { - String name = ""; - String city = ""; - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setCity(String city) { - this.city = city; - } - - public String getCity() { - return city; - } - } - - /** - * Factory to create the proper type of field for each property type. We - * need to implement just one of the factory methods. - */ - class MyFieldFactory implements FieldFactory { - - public Field createField(Class type, Component uiContext) { - return null; - } - - public Field createField(Property property, Component uiContext) { - return null; - } - - public Field createField(Item item, Object propertyId, - Component uiContext) { - String pid = (String) propertyId; - if (pid.equals("name")) { - return new TextField("Name"); - } else if (pid.equals("city")) { - Select select = new Select("City"); - select.addItem("Berlin"); - select.addItem("Helsinki"); - select.addItem("London"); - select.addItem("New York"); - select.addItem("Turku"); - select.setNewItemsAllowed(true); - return select; - } - return null; - } - - public Field createField(Container container, Object itemId, - Object propertyId, Component uiContext) { - return null; - } - } - - public FormExample2() { - // Create a form and use FormLayout as its layout. - final Form form = new Form(); - - // Set form caption and description texts - form.setCaption("Contact Information"); - form.setDescription("Please specify name of the person and the city where the person lives in."); - - // Use the custom field factory to create the fields in the form. - form.setFieldFactory(new MyFieldFactory()); - - // Create the custom bean. - PersonBean bean = new PersonBean(); - - // Create a bean item that is bound to the bean. - BeanItem item = new BeanItem(bean); - - // Bind the bean item as the data source for the form. - form.setItemDataSource(item); - - // Set the order of the items in the form. - Vector order = new Vector(); - order.add("name"); - order.add("city"); - form.setVisibleItemProperties(order); - - form.getField("name").setRequired(true); - form.getField("name").setRequiredError("You must enter a name."); - form.getField("city").setRequired(true); - - OrderedLayout root = new OrderedLayout(); - root.setWidth(300, OrderedLayout.UNITS_PIXELS); - root.addComponent(form); - setCompositionRoot(root); - } -} diff --git a/tests/src/com/vaadin/tests/book/MyDynamicResource.java b/tests/src/com/vaadin/tests/book/MyDynamicResource.java deleted file mode 100644 index db013df085..0000000000 --- a/tests/src/com/vaadin/tests/book/MyDynamicResource.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.vaadin.tests.book; - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.net.URL; -import java.util.Map; - -import javax.imageio.ImageIO; - -import com.vaadin.terminal.DownloadStream; -import com.vaadin.terminal.ParameterHandler; -import com.vaadin.terminal.URIHandler; - -/** - * Demonstrates handling URI parameters and the URI itself to create a dynamic - * resource. - */ -public class MyDynamicResource implements URIHandler, ParameterHandler { - String textToDisplay = "- no text given -"; - - /** - * Handle the URL parameters and store them for the URI handler to use. - */ - public void handleParameters(Map parameters) { - // Get and store the passed HTTP parameter. - if (parameters.containsKey("text")) { - textToDisplay = ((String[]) parameters.get("text"))[0]; - } - } - - /** - * Provides the dynamic resource if the URI matches the resource URI. The - * matching URI is "/myresource" under the application URI context. - * - * Returns null if the URI does not match. Otherwise returns a download - * stream that contains the response from the server. - */ - public DownloadStream handleURI(URL context, String relativeUri) { - // Catch the given URI that identifies the resource, otherwise let other - // URI handlers or the Application to handle the response. - if (!relativeUri.startsWith("myresource")) { - return null; - } - - // Create an image and draw some background on it. - BufferedImage image = new BufferedImage(200, 200, - BufferedImage.TYPE_INT_RGB); - Graphics drawable = image.getGraphics(); - drawable.setColor(Color.lightGray); - drawable.fillRect(0, 0, 200, 200); - drawable.setColor(Color.yellow); - drawable.fillOval(25, 25, 150, 150); - drawable.setColor(Color.blue); - drawable.drawRect(0, 0, 199, 199); - - // Use the parameter to create dynamic content. - drawable.setColor(Color.black); - drawable.drawString("Text: " + textToDisplay, 75, 100); - - try { - // Write the image to a buffer. - ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream(); - ImageIO.write(image, "png", imagebuffer); - - // Return a stream from the buffer. - ByteArrayInputStream istream = new ByteArrayInputStream( - imagebuffer.toByteArray()); - return new DownloadStream(istream, null, null); - } catch (IOException e) { - return null; - } - } -} diff --git a/tests/src/com/vaadin/tests/book/MyUploader.java b/tests/src/com/vaadin/tests/book/MyUploader.java deleted file mode 100644 index cc953e79cf..0000000000 --- a/tests/src/com/vaadin/tests/book/MyUploader.java +++ /dev/null @@ -1,81 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; - -import com.vaadin.terminal.FileResource; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.Upload; - -public class MyUploader extends CustomComponent implements - Upload.SucceededListener, Upload.FailedListener, Upload.Receiver { - Panel root; // Root element for contained components. - Panel imagePanel; // Panel that contains the uploaded image. - File file; // File to write to. - - MyUploader() { - root = new Panel("My Upload Component"); - setCompositionRoot(root); - - // Create the Upload component. - final Upload upload = new Upload("Upload the file here", this); - upload.setButtonCaption("Upload Now"); - - // Listen for Upload.SucceededEvent and FailedEvent events. - upload.addListener((Upload.SucceededListener) this); - upload.addListener((Upload.FailedListener) this); - - root.addComponent(upload); - root.addComponent(new Label( - "Click 'Browse' to select a file and then click 'Upload'.")); - - // Create a panel for displaying the uploaded file (image). - imagePanel = new Panel("Uploaded image"); - imagePanel.addComponent(new Label("No image uploaded yet")); - root.addComponent(imagePanel); - } - - // Callback method to begin receiving the upload. - public OutputStream receiveUpload(String filename, String MIMEType) { - FileOutputStream fos = null; // Output stream to write to. - file = new File("/tmp/uploads/" + filename); - try { - // Open the file for writing. - fos = new FileOutputStream(file); - } catch (final java.io.FileNotFoundException e) { - // Error while opening the file. Not reported here. - e.printStackTrace(); - return null; - } - - return fos; // Return the output stream to write to - } - - // This is called if the upload is finished successfully. - public void uploadSucceeded(Upload.SucceededEvent event) { - // Log the upload on screen. - root.addComponent(new Label("File " + event.getFilename() - + " of type '" + event.getMIMEType() + "' uploaded.")); - - // Display the uploaded file in the image panel. - final FileResource imageResource = new FileResource(file, - getApplication()); - imagePanel.removeAllComponents(); - imagePanel.addComponent(new Embedded("", imageResource)); - } - - // This is called if the upload fails. - public void uploadFailed(Upload.FailedEvent event) { - // Log the failure on screen. - root.addComponent(new Label("Uploading " + event.getFilename() - + " of type '" + event.getMIMEType() + "' failed.")); - } -} diff --git a/tests/src/com/vaadin/tests/book/SSNField.java b/tests/src/com/vaadin/tests/book/SSNField.java deleted file mode 100644 index 029b905eed..0000000000 --- a/tests/src/com/vaadin/tests/book/SSNField.java +++ /dev/null @@ -1,98 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Validator; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.FormLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.TextField; - -/* Finnish Social Security Number input field that validates the value. */ -public class SSNField extends CustomComponent implements - Property.ValueChangeListener { - OrderedLayout layout = new FormLayout(); - // new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); //;new - // FormLayout(); - TextField myfield; - Label myerror; - - /** Validator for Finnish Social Security Number. */ - class SSNValidator implements Validator { - - /** The isValid() is simply a wrapper for the validate() method. */ - public boolean isValid(Object value) { - try { - validate(value); - } catch (final InvalidValueException e) { - return false; - } - return true; - } - - /** Validate the given SSN. */ - public void validate(Object value) throws InvalidValueException { - final String ssn = (String) value; - if (ssn.length() == 0) { - return; - } - - if (ssn.length() != 11) { - throw new InvalidValueException("Invalid SSN length"); - } - - final String numbers = ssn.substring(0, 6) + ssn.substring(7, 10); - final int checksum = new Integer(numbers).intValue() % 31; - if (!ssn.substring(10).equals( - "0123456789ABCDEFHJKLMNPRSTUVWXY".substring(checksum, - checksum + 1))) { - throw new InvalidValueException("Invalid SSN checksum"); - } - } - } - - SSNField() { - setCompositionRoot(layout); - layout.setOrientation(FormLayout.ORIENTATION_VERTICAL); - - /* Create the text field for the SSN. */ - myfield = new TextField("Social Security Number"); - myfield.setColumns(11); - - /* Create and set the validator object for the field. */ - myfield.addValidator(new SSNValidator()); - - /* - * ValueChageEvent will be generated immediately when the component - * loses focus. - */ - myfield.setImmediate(true); - - /* Listen for ValueChangeEvent events. */ - myfield.addListener(this); - - layout.addComponent(myfield); - - /* The field will have an error label, normally invisible. */ - myerror = new Label(); - layout.addComponent(myerror); - } - - public void valueChange(ValueChangeEvent event) { - try { - /* Validate the field value. */ - myfield.validate(); - - /* The value was correct. */ - myerror.setValue("Ok"); - } catch (final Validator.InvalidValueException e) { - /* Report the error message to the user. */ - myerror.setValue(e.getMessage()); - } - } -} diff --git a/tests/src/com/vaadin/tests/book/SelectExample.java b/tests/src/com/vaadin/tests/book/SelectExample.java deleted file mode 100644 index f301e85c3f..0000000000 --- a/tests/src/com/vaadin/tests/book/SelectExample.java +++ /dev/null @@ -1,119 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.Application; -import com.vaadin.data.Property; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Select; -import com.vaadin.ui.TwinColSelect; - -/* Let us add an implementation of the ValueChangeListener interface. */ -public class SelectExample extends CustomComponent implements - Property.ValueChangeListener { - - class Planet extends Object { - String planetName; - - Planet(String name) { - planetName = name; - } - - @Override - public String toString() { - return "The Planet " + planetName; - } - } - - /* Create the Select object with a caption. */ - AbstractSelect select; - - OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - Label status = new Label(""); - - SelectExample(Application application, String param, String caption, - boolean multiselect) { - if (param.equals("optiongroup")) { - select = new OptionGroup(caption); - select.setMultiSelect(multiselect); - } else if (param.equals("twincol")) { - select = new TwinColSelect(caption); - } else if (param.equals("native")) { - select = new NativeSelect(caption); - } else if (param.equals("filter")) { - select = new Select(caption); - ((Select) select) - .setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS); - } else { - select = new Select(caption); - select.setMultiSelect(multiselect); - } - - layout.addComponent(select); - setCompositionRoot(layout); - - /* Fill the component with some items. */ - final String[] planets = new String[] { "Mercury", "Venus", "Earth", - "Mars", "Jupiter", "Saturn", "Uranus", "Neptune" }; - - for (int i = 0; i < planets.length; i++) { - select.addItem(planets[i]); - - /* Create an item with an Integer as the Item ID. */ - // select.addItem(i); - // select.addItem(new Planet(planets[i])); - /* Set the visible caption of the item. */ - // select.setItemCaption(i, planets[i]); - /* - * ClassResource icon = new ClassResource - * ("images/"+planets[i]+"_symbol.png", application); - * layout.addComponent(new Embedded ("Icon", icon)); - * select.setItemIcon(i, icon); - */ - } - - /* - * By default, the change event is not triggered immediately when the - * selection changes. This enables it. - */ - select.setImmediate(true); - - /* Listen for changes in the selection. */ - select.addListener(this); - - // select.setStyle("twincol"); - // select.setMultiSelect(true); - // select.setNewItemsAllowed(true); - // int a=1; - - // select.setItemCaptionMode(Select.ITEM_CAPTION_MODE_ICON_ONLY); - // select.setNullSelectionItemId("-- select somethingd --"); - // select.setNullSelectionAllowed(false); - - layout.addComponent(status); - } - - /* Respond to change in the selection. */ - public void valueChange(Property.ValueChangeEvent event) { - /* - * The event.getProperty() returns the component. The currently selected - * item is the property of the component, retrievable with getValue(). - */ - if (false) { - status.setValue("Currently selected item ID: " - + event.getProperty().getValue() + "<br/>" - + "Class of the Item ID: " - + event.getProperty().getValue().getClass().getName() - + "<br/>" + "Caption: " - + select.getItemCaption(event.getProperty().getValue())); - status.setContentMode(Label.CONTENT_XHTML); - } - } -} diff --git a/tests/src/com/vaadin/tests/book/TabSheetExample.java b/tests/src/com/vaadin/tests/book/TabSheetExample.java deleted file mode 100644 index 766f20ff0c..0000000000 --- a/tests/src/com/vaadin/tests/book/TabSheetExample.java +++ /dev/null @@ -1,70 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; - -public class TabSheetExample extends CustomComponent implements - Button.ClickListener, TabSheet.SelectedTabChangeListener { - TabSheet tabsheet = new TabSheet(); - Button tab1 = new Button("Push this button"); - Label tab2 = new Label("Contents of Second Tab"); - Label tab3 = new Label("Contents of Third Tab"); - - TabSheetExample() { - setCompositionRoot(tabsheet); - - // Listen for changes in tab selection. - tabsheet.addListener(this); - - // First tab contains a button, for which we - // listen button click events. - tab1.addListener(this); - - // This will cause a selectedTabChange() call. - tabsheet.addTab(tab1, "First Tab", null); - - // A tab that is initially invisible. - tabsheet.addTab(tab2, "Second Tab", null); - tabsheet.getTab(tab2).setVisible(false); - - // A tab that is initially disabled. - tabsheet.addTab(tab3, "Third tab", null); - tabsheet.getTab(tab3).setEnabled(false); - } - - public void buttonClick(ClickEvent event) { - // Enable the invisible and disabled tabs. - tabsheet.getTab(tab2).setVisible(true); - tabsheet.getTab(tab3).setEnabled(true); - - // Change selection automatically to second tab. - tabsheet.setSelectedTab(tab2); - } - - public void selectedTabChange(SelectedTabChangeEvent event) { - // Cast to a TabSheet. This isn't really necessary in - // this example, as we have only one TabSheet component, - // but would be useful if there were multiple TabSheets. - final TabSheet source = (TabSheet) event.getSource(); - - if (source == tabsheet) { - // If the first tab was selected. - if (source.getSelectedTab() == tab1) { - // The 2. and 3. tabs may not have been set yet. - if (tabsheet.getTab(tab2) != null - && tabsheet.getTab(tab3) != null) { - tabsheet.getTab(tab2).setVisible(false); - tabsheet.getTab(tab3).setEnabled(false); - } - } - } - } -} diff --git a/tests/src/com/vaadin/tests/book/TableCellStyle.java b/tests/src/com/vaadin/tests/book/TableCellStyle.java deleted file mode 100644 index d61b590a1d..0000000000 --- a/tests/src/com/vaadin/tests/book/TableCellStyle.java +++ /dev/null @@ -1,62 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Table; - -public class TableCellStyle extends CustomComponent { - public TableCellStyle() { - Table table = new Table("Table with Cell Styles"); - table.addStyleName("checkerboard"); - - // Add some columns in the table. In this example, the property IDs - // of the container are integers so we can determine the column number - // easily. - table.addContainerProperty("0", String.class, null, "", null, null); // Row - // header - for (int i = 0; i < 8; i++) { - table.addContainerProperty("" + (i + 1), String.class, null, - String.valueOf((char) (65 + i)), null, null); - } - - // Add some items in the table. - table.addItem(new Object[] { "1", "R", "N", "B", "Q", "K", "B", "N", - "R" }, new Integer(0)); - table.addItem(new Object[] { "2", "P", "P", "P", "P", "P", "P", "P", - "P" }, new Integer(1)); - for (int i = 2; i < 6; i++) { - table.addItem(new Object[] { String.valueOf(i + 1), "", "", "", "", - "", "", "", "" }, new Integer(i)); - } - table.addItem(new Object[] { "7", "P", "P", "P", "P", "P", "P", "P", - "P" }, new Integer(6)); - table.addItem(new Object[] { "8", "R", "N", "B", "Q", "K", "B", "N", - "R" }, new Integer(7)); - table.setPageLength(8); - - // Set cell style generator - table.setCellStyleGenerator(new Table.CellStyleGenerator() { - public String getStyle(Object itemId, Object propertyId) { - int row = ((Integer) itemId).intValue(); - int col = Integer.parseInt((String) propertyId); - - // The first column. - if (col == 0) { - return "rowheader"; - } - - // Other cells. - if ((row + col) % 2 == 1) { - return "black"; - } else { - return "white"; - } - } - }); - - setCompositionRoot(table); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableEditable.java b/tests/src/com/vaadin/tests/book/TableEditable.java deleted file mode 100644 index 3e5dc0e613..0000000000 --- a/tests/src/com/vaadin/tests/book/TableEditable.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Table; - -public class TableEditable extends CustomComponent { - /* A layout needed for the example. */ - OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - - TableEditable() { - setCompositionRoot(layout); - - // Create a table. It is by default not editable. - final Table table = new Table(); - - // Define the names and data types of columns. - table.addContainerProperty("Date", Date.class, null); - table.addContainerProperty("Work", Boolean.class, null); - table.addContainerProperty("Comments", String.class, null); - - // Add a few items in the table. - for (int i = 0; i < 100; i++) { - Calendar calendar = new GregorianCalendar(2008, 0, 1); - calendar.add(Calendar.DAY_OF_YEAR, i); - - // Create the table row. - table.addItem( - new Object[] { calendar.getTime(), Boolean.FALSE, "" }, - new Integer(i)); // Item identifier - } - - table.setPageLength(8); - layout.addComponent(table); - - final CheckBox switchEditable = new CheckBox("Editable"); - switchEditable.addListener(new Property.ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - table.setEditable(((Boolean) event.getProperty().getValue()) - .booleanValue()); - } - }); - switchEditable.setImmediate(true); - layout.addComponent(switchEditable); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableEditableBean.java b/tests/src/com/vaadin/tests/book/TableEditableBean.java deleted file mode 100644 index e3828d29ee..0000000000 --- a/tests/src/com/vaadin/tests/book/TableEditableBean.java +++ /dev/null @@ -1,242 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import java.util.Collection; -import java.util.Vector; - -import com.vaadin.data.Container; -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.BeanItem; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.BaseFieldFactory; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Component; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Field; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Table; - -/** - * Shows how to bind a bean to a table and make it editable. - */ -public class TableEditableBean extends CustomComponent { - /** - * Let's have a simple example bean. - */ - public class MyBean { - boolean selected; - String text; - - public MyBean() { - selected = false; - text = ""; - } - - public boolean isSelected() { - System.out.println("isSelected() called: " + selected); - return selected; - } - - public void setSelected(boolean selected) { - this.selected = selected; - System.out.println("setSelected1(" + selected + ") called."); - } - - public String getText() { - System.out.println("getText() called: " + text); - return text; - } - - public void setText(String text) { - this.text = text; - System.out.println("setText(" + text + ") called."); - } - }; - - /** - * Custom field factory that sets the fields as immediate for debugging - * purposes. This is not normally necessary, unless you want to have some - * interaction that requires it. - */ - public class MyFieldFactory extends BaseFieldFactory { - @Override - public Field createField(Class type, Component uiContext) { - // Let the BaseFieldFactory create the fields - Field field = super.createField(type, uiContext); - - // ...and just set them as immediate - ((AbstractField) field).setImmediate(true); - - return field; - } - } - - /** - * This is a custom container that allows adding BeanItems inside it. The - * BeanItem objects must be bound to a MyBean object. The item ID is an - * Integer from 0 to 99. - * - * Most of the interface methods are implemented with just dummy - * implementations, as they are not needed in this example. - */ - public class MyContainer implements Container { - Item[] items; - int current = 0; - - public MyContainer() { - items = new Item[100]; // Yeah this is just a test - } - - public boolean addContainerProperty(Object propertyId, Class<?> type, - Object defaultValue) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public Item addItem(Object itemId) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public Object addItem() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * This addItem method is specific for this container and allows adding - * BeanItem objects. The BeanItems must be bound to MyBean objects. - */ - public void addItem(BeanItem item) throws UnsupportedOperationException { - items[current++] = item; - } - - public boolean containsId(Object itemId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < 100) { - return items[pos] != null; - } - } - return false; - } - - /** - * The Table will call this method to get the property objects for the - * columns. It uses the property objects to determine the data types of - * the columns. - */ - public Property getContainerProperty(Object itemId, Object propertyId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < 100) { - Item item = items[pos]; - - // The BeanItem provides the property objects for the items. - return item.getItemProperty(propertyId); - } - } - return null; - } - - /** Table calls this to get the column names. */ - public Collection getContainerPropertyIds() { - // This container can contain only BeanItems bound to MyBeans. - Item item = new BeanItem(new MyBean()); - - // The BeanItem knows how to get the property names from the bean. - return item.getItemPropertyIds(); - } - - public Item getItem(Object itemId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < 100) { - return items[pos]; - } - } - return null; - } - - public Collection getItemIds() { - Vector ids = new Vector(); - for (int i = 0; i < 100; i++) { - ids.add(Integer.valueOf(i)); - } - return ids; - } - - public Class getType(Object propertyId) { - return BeanItem.class; - } - - public boolean removeAllItems() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public boolean removeContainerProperty(Object propertyId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public boolean removeItem(Object itemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public int size() { - return current; - } - - } - - TableEditableBean() { - /* A layout needed for the example. */ - OrderedLayout layout = new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL); - setCompositionRoot(layout); - - // Create a table. It is by default not editable. - final Table table = new Table(); - layout.addComponent(table); - table.setPageLength(8); - - // Use the custom container as the data source - MyContainer myContainer = new MyContainer(); - table.setContainerDataSource(myContainer); - - // Add a few items in the table. - for (int i = 0; i < 5; i++) { - // Create the bean - MyBean item = new MyBean(); - item.setText("MyBean " + i); - - // Have an Item that is bound to the bean - BeanItem bitem = new BeanItem(item); - - // Add the item directly to the container using the custom addItem() - // method. We could otherwise add it to the Table as well, but - // the Container interface of Table does not allow adding items - // as such, just item IDs. - myContainer.addItem(bitem); - } - - // Use custom field factory that sets the checkboxes in immediate mode. - // This is just for debugging purposes and is not normally necessary. - table.setFieldFactory(new MyFieldFactory()); - - // Have a check box to switch the table between normal and editable - // mode. - final CheckBox switchEditable = new CheckBox("Editable"); - switchEditable.addListener(new Property.ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - table.setEditable(((Boolean) event.getProperty().getValue()) - .booleanValue()); - } - }); - switchEditable.setImmediate(true); - layout.addComponent(switchEditable); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableExample.java b/tests/src/com/vaadin/tests/book/TableExample.java deleted file mode 100644 index 5ee1f8f952..0000000000 --- a/tests/src/com/vaadin/tests/book/TableExample.java +++ /dev/null @@ -1,76 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Table; - -public class TableExample extends CustomComponent { - /* Create the table with a caption. */ - Table table = new Table("This is my Table"); - - /* A layout needed for the example. */ - OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - - /* Feedback for selecting items from the table. */ - Label current = new Label("Selected: -"); - - TableExample() { - setCompositionRoot(layout); - layout.addComponent(table); - - /* Define the names, data types, and default values of columns. */ - table.addContainerProperty("First Name", String.class, - "(no first name)"); - table.addContainerProperty("Last Name", String.class, "(no last name)"); - table.addContainerProperty("Year", Integer.class, null); - - /* We use these entries to generate random items in a table. */ - final String[] firstnames = new String[] { "Donald", "Patty", "Sally", - "Douglas" }; - final String[] lastnames = new String[] { "Smith", "Jones", "Adams", - "Knuth" }; - - /* Add some items in the table and assign them an Item ID (IID). */ - for (int i = 0; i < 1000; i++) { - /* Add a randomly generated item in the Table. */ - table.addItem( - new Object[] { - firstnames[(int) (Math.random() * (firstnames.length - 0.01))], - lastnames[(int) (Math.random() * (lastnames.length - 0.01))], - new Integer((int) (1900 + Math.random() * 100)) }, - new Integer(i)); - } - - /* Set the number of items visible in the table. */ - table.setPageLength(10); - - /* Enable some UI features for the table. */ - table.setColumnReorderingAllowed(true); - table.setColumnCollapsingAllowed(true); - - /* Allow selecting items from the table. */ - table.setSelectable(true); - - /* - * When an item is selected, the selection is sent immediately to - * server. - */ - table.setImmediate(true); - - /* Handle selection change. */ - table.addListener(new Property.ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - current.setValue("Selected: " + table.getValue().toString()); - } - }); - - layout.addComponent(current); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableExample1.java b/tests/src/com/vaadin/tests/book/TableExample1.java deleted file mode 100644 index 62b189f4ff..0000000000 --- a/tests/src/com/vaadin/tests/book/TableExample1.java +++ /dev/null @@ -1,48 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Table; - -public class TableExample1 extends CustomComponent { - /* A layout needed for the example. */ - OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - - TableExample1() { - setCompositionRoot(layout); - - /* Create the table with a caption. */ - Table table = new Table("This is my Table"); - - /* - * Define the names and data types of columns. The "default value" - * parameter is meaningless here. - */ - table.addContainerProperty("First Name", String.class, null); - table.addContainerProperty("Last Name", String.class, null); - table.addContainerProperty("Year", Integer.class, null); - - /* Add a few items in the table. */ - table.addItem(new Object[] { "Nicolaus", "Copernicus", - new Integer(1473) }, new Integer(1)); - table.addItem(new Object[] { "Tycho", "Brahe", new Integer(1546) }, - new Integer(2)); - table.addItem(new Object[] { "Giordano", "Bruno", new Integer(1548) }, - new Integer(3)); - table.addItem(new Object[] { "Galileo", "Galilei", new Integer(1564) }, - new Integer(4)); - table.addItem(new Object[] { "Johannes", "Kepler", new Integer(1571) }, - new Integer(5)); - table.addItem(new Object[] { "Isaac", "Newton", new Integer(1643) }, - new Integer(6)); - - /* Set number of visible rows. */ - table.setPageLength(5); - - layout.addComponent(table); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableExample2.java b/tests/src/com/vaadin/tests/book/TableExample2.java deleted file mode 100644 index b2d8b2bc45..0000000000 --- a/tests/src/com/vaadin/tests/book/TableExample2.java +++ /dev/null @@ -1,73 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Table; - -public class TableExample2 extends CustomComponent { - /* A layout needed for the example. */ - OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - - TableExample2() { - setCompositionRoot(layout); - - /* Create the table with a caption. */ - final Table table = new Table(); - - /* - * Define the names and data types of columns. The "default value" - * parameter is meaningless here. - */ - table.addContainerProperty("First Name", String.class, null); - table.addContainerProperty("Last Name", String.class, null); - table.addContainerProperty("Year", Integer.class, null); - - /* Add a few items in the table. */ - table.addItem(new Object[] { "Nicolaus", "Copernicus", - new Integer(1473) }, new Integer(1)); - table.addItem(new Object[] { "Tycho", "Brahe", new Integer(1546) }, - new Integer(2)); - table.addItem(new Object[] { "Giordano", "Bruno", new Integer(1548) }, - new Integer(3)); - table.addItem(new Object[] { "Galileo", "Galilei", new Integer(1564) }, - new Integer(4)); - table.addItem(new Object[] { "Johannes", "Kepler", new Integer(1571) }, - new Integer(5)); - table.addItem(new Object[] { "Isaac", "Newton", new Integer(1643) }, - new Integer(6)); - - /* Set number of visible rows. */ - table.setPageLength(5); - - /* Allow selecting items from the table. */ - table.setSelectable(true); - - /* - * When an item is selected, the selection is sent immediately to - * server. - */ - table.setImmediate(true); - - /* Feedback from selection. */ - final Label current = new Label("Selected: -"); - - /* Handle selection change. */ - table.addListener(new Property.ValueChangeListener() { - public void valueChange(ValueChangeEvent event) { - current.setValue("Selected: " + table.getValue()); - } - }); - - table.setNullSelectionAllowed(false); - - layout.addComponent(table); - layout.addComponent(current); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableExample3.java b/tests/src/com/vaadin/tests/book/TableExample3.java deleted file mode 100644 index 2fba7ec469..0000000000 --- a/tests/src/com/vaadin/tests/book/TableExample3.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; - -public class TableExample3 extends CustomComponent { - /* A layout needed for the example. */ - OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - - TableExample3() { - setCompositionRoot(layout); - - // Create a table and add a style to allow setting the row height in - // theme. - final Table table = new Table(); - table.addStyleName("components-inside"); - - /* - * Define the names and data types of columns. The "default value" - * parameter is meaningless here. - */ - table.addContainerProperty("Sum", Label.class, null); - table.addContainerProperty("Is Transferred", CheckBox.class, null); - table.addContainerProperty("Comments", TextField.class, null); - table.addContainerProperty("Details", Button.class, null); - - /* Add a few items in the table. */ - for (int i = 0; i < 100; i++) { - // Create the fields for the current table row - Label sumField = new Label(String.format( - "Sum is <b>$%04.2f</b><br/><i>(VAT incl.)</i>", - new Object[] { new Double(Math.random() * 1000) }), - Label.CONTENT_XHTML); - CheckBox transferredField = new CheckBox("is transferred"); - - // Multiline text field. This required modifying the height of the - // table row. - TextField commentsField = new TextField(); - commentsField.setRows(3); - - // The Table item identifier for the row. - Integer itemId = new Integer(i); - - // Create a button and handle its click. A Button does not know - // the item it is contained in, so we have to store the item - // ID as user-defined data. - Button detailsField = new Button("show details"); - detailsField.setData(itemId); - detailsField.addListener(new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - // Get the item identifier from the user-defined data. - Integer itemId = (Integer) event.getButton().getData(); - getWindow().showNotification( - "Link " + itemId.intValue() + " clicked."); - } - }); - detailsField.addStyleName("link"); - - // Create the table row. - table.addItem(new Object[] { sumField, transferredField, - commentsField, detailsField }, itemId); - } - - // Show just three rows because they are so high. - table.setPageLength(3); - - // Initially show the 50th item in the top of the table. - table.setCurrentPageFirstItemIndex(50); - // table.setCurrentPageFirstItemId(initial); - - layout.addComponent(table); - } -} diff --git a/tests/src/com/vaadin/tests/book/TableHuge.java b/tests/src/com/vaadin/tests/book/TableHuge.java deleted file mode 100644 index 5648b9417e..0000000000 --- a/tests/src/com/vaadin/tests/book/TableHuge.java +++ /dev/null @@ -1,197 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import java.util.Collection; -import java.util.Vector; - -import com.vaadin.data.Container; -import com.vaadin.data.Container.Indexed; -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.util.BeanItem; -import com.vaadin.data.util.ObjectProperty; -import com.vaadin.data.util.PropertysetItem; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Table; - -public class TableHuge extends CustomComponent { - - /** - * This is a virtual container that generates the items on the fly when - * requested. - */ - public class HugeContainer implements Container, Indexed { - int numberofitems; - - public HugeContainer(int numberofitems) { - this.numberofitems = numberofitems; - } - - public boolean addContainerProperty(Object propertyId, Class<?> type, - Object defaultValue) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public Item addItem(Object itemId) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public Object addItem() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * This addItem method is specific for this container and allows adding - * BeanItem objects. The BeanItems must be bound to MyBean objects. - */ - public void addItem(BeanItem item) throws UnsupportedOperationException { - } - - public boolean containsId(Object itemId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < numberofitems) { - return true; - } - } - return false; - } - - /** - * The Table will call this method to get the property objects for the - * columns. It uses the property objects to determine the data types of - * the columns. - */ - public Property getContainerProperty(Object itemId, Object propertyId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < numberofitems) { - return new ObjectProperty("This is the item " + pos - + " in the huge table"); - } - } - return null; - } - - /** Table calls this to get the column names. */ - public Collection getContainerPropertyIds() { - Vector ids = new Vector(); - ids.add("id"); - return ids; - } - - public Item getItem(Object itemId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < numberofitems) { - Item item = new PropertysetItem(); - item.addItemProperty("id", new ObjectProperty( - "This is the item " + pos + " in the huge table")); - return item; - } - } - return null; - } - - public Collection getItemIds() { - System.out.println("We can't do this."); - return null; - } - - public Class getType(Object propertyId) { - return PropertysetItem.class; - } - - public boolean removeAllItems() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public boolean removeContainerProperty(Object propertyId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public boolean removeItem(Object itemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - public int size() { - return numberofitems; - } - - public Object addItemAt(int index) throws UnsupportedOperationException { - // TODO Auto-generated method stub - return null; - } - - public Item addItemAt(int index, Object newItemId) - throws UnsupportedOperationException { - // TODO Auto-generated method stub - return null; - } - - public Object getIdByIndex(int index) { - return Integer.valueOf(index); - } - - public int indexOfId(Object itemId) { - return ((Integer) itemId).intValue(); - } - - public Object addItemAfter(Object previousItemId) - throws UnsupportedOperationException { - // TODO Auto-generated method stub - return null; - } - - public Item addItemAfter(Object previousItemId, Object newItemId) - throws UnsupportedOperationException { - // TODO Auto-generated method stub - return null; - } - - public Object firstItemId() { - return new Integer(0); - } - - public boolean isFirstId(Object itemId) { - return ((Integer) itemId).intValue() == 0; - } - - public boolean isLastId(Object itemId) { - return ((Integer) itemId).intValue() == (numberofitems - 1); - } - - public Object lastItemId() { - return new Integer(numberofitems - 1); - } - - public Object nextItemId(Object itemId) { - int pos = indexOfId(itemId); - if (pos >= numberofitems - 1) { - return null; - } - return getIdByIndex(pos + 1); - } - - public Object prevItemId(Object itemId) { - int pos = indexOfId(itemId); - if (pos <= 0) { - return null; - } - return getIdByIndex(pos - 1); - } - } - - public TableHuge() { - Table table = new Table("HUGE table, REALLY HUGE"); - table.setContainerDataSource(new HugeContainer(500000)); - table.setPageLength(20); - - setCompositionRoot(table); - } -} diff --git a/tests/src/com/vaadin/tests/book/TheButton.java b/tests/src/com/vaadin/tests/book/TheButton.java deleted file mode 100644 index 716aaa64d7..0000000000 --- a/tests/src/com/vaadin/tests/book/TheButton.java +++ /dev/null @@ -1,27 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.Button; -import com.vaadin.ui.CustomComponent; - -public class TheButton extends CustomComponent implements Button.ClickListener { - Button thebutton; - - public TheButton() { - /* Create a Button with the given caption. */ - thebutton = new Button("Do not push this button"); - - /* Listen for ClickEvents. */ - thebutton.addListener(this); - - setCompositionRoot(thebutton); - } - - /** Handle button click events from the button. */ - public void buttonClick(Button.ClickEvent event) { - thebutton.setCaption("Do not push this button again"); - } -} diff --git a/tests/src/com/vaadin/tests/book/TheButtons.java b/tests/src/com/vaadin/tests/book/TheButtons.java deleted file mode 100644 index ed7ef00cc4..0000000000 --- a/tests/src/com/vaadin/tests/book/TheButtons.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.AbstractComponentContainer; -import com.vaadin.ui.Button; - -public class TheButtons implements Button.ClickListener { - Button thebutton; - Button secondbutton; - - /** Creates two buttons into given container. */ - public TheButtons(AbstractComponentContainer container) { - thebutton = new Button("Do not push this button"); - thebutton.addListener(this); - container.addComponent(thebutton); - - secondbutton = new Button("I am a button too"); - secondbutton.addListener(this); - container.addComponent(secondbutton); - } - - /** Handle button click events from the two buttons. */ - public void buttonClick(Button.ClickEvent event) { - if (event.getButton() == thebutton) { - thebutton.setCaption("Do not push this button again"); - } else if (event.getButton() == secondbutton) { - secondbutton.setCaption("I am not a number"); - } - } -} diff --git a/tests/src/com/vaadin/tests/book/TheButtons2.java b/tests/src/com/vaadin/tests/book/TheButtons2.java deleted file mode 100644 index c96ed51773..0000000000 --- a/tests/src/com/vaadin/tests/book/TheButtons2.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.AbstractComponentContainer; -import com.vaadin.ui.Button; - -public class TheButtons2 { - Button thebutton; - Button secondbutton; - - /** Creates two buttons in given container. */ - public TheButtons2(AbstractComponentContainer container) { - thebutton = new Button("Do not push this button"); - thebutton.addListener(Button.ClickEvent.class, this, "theButtonClick"); - container.addComponent(thebutton); - - secondbutton = new Button("I am a button too"); - secondbutton.addListener(Button.ClickEvent.class, this, - "secondButtonClick"); - container.addComponent(secondbutton); - } - - public void theButtonClick(Button.ClickEvent event) { - thebutton.setCaption("Do not push this button again"); - } - - public void secondButtonClick(Button.ClickEvent event) { - secondbutton.setCaption("I am not a number!"); - } -} diff --git a/tests/src/com/vaadin/tests/book/TheButtons3.java b/tests/src/com/vaadin/tests/book/TheButtons3.java deleted file mode 100644 index 9b77e7855a..0000000000 --- a/tests/src/com/vaadin/tests/book/TheButtons3.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.AbstractComponentContainer; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; - -/** This example demonstrates the use of inline classes for event listeners. */ -public class TheButtons3 { - Button thebutton; /* This component is stored as a member variable. */ - - /** Creates two buttons in given container. */ - public TheButtons3(AbstractComponentContainer container) { - thebutton = new Button("Do not push this button"); - thebutton.addListener(new Button.ClickListener() { - /* - * Define the method in the local class to handle the click. - */ - public void buttonClick(ClickEvent event) { - thebutton.setCaption("Do not push this button again"); - } - }); - container.addComponent(thebutton); - - /* - * Have the second button as a local variable in the constructor. Only - * "final" local variables can be accessed from an anonymous class. - */ - final Button secondbutton = new Button("I am a button too"); - secondbutton.addListener(new Button.ClickListener() { - /* - * Define the method in the local class to handle the click. - */ - public void buttonClick(ClickEvent event) { - secondbutton.setCaption("I am not a number!"); - } - }); - container.addComponent(secondbutton); - } -} diff --git a/tests/src/com/vaadin/tests/book/WindowOpener.java b/tests/src/com/vaadin/tests/book/WindowOpener.java deleted file mode 100644 index f159c48b30..0000000000 --- a/tests/src/com/vaadin/tests/book/WindowOpener.java +++ /dev/null @@ -1,80 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.book; - -import com.vaadin.ui.Button; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; - -/** Component contains a button that allows opening a window. */ -public class WindowOpener extends CustomComponent implements - Window.CloseListener { - Window mainwindow; // Reference to main window - Window mywindow; // The window to be opened - Button openbutton; // Button for opening the window - Button closebutton; // A button in the window - Label explanation; // A descriptive text - - public WindowOpener(String label, Window main) { - mainwindow = main; - - /* The component consists of a button that opens the window. */ - final VerticalLayout layout = new VerticalLayout(); - - openbutton = new Button("Open Window", this, "openButtonClick"); - explanation = new Label("Explanation"); - layout.addComponent(openbutton); - layout.addComponent(explanation); - - setCompositionRoot(layout); - } - - /** Handle the clicks for the two buttons. */ - public void openButtonClick(Button.ClickEvent event) { - /* Create a new window. */ - mywindow = new Window("My Dialog"); - mywindow.setPositionX(200); - mywindow.setPositionY(100); - mywindow.getLayout().setSizeUndefined(); - - /* Add the window inside the main window. */ - mainwindow.addWindow(mywindow); - - /* Listen for close events for the window. */ - mywindow.addListener(this); - - /* Add components in the window. */ - mywindow.addComponent(new Label("A text label in the window.")); - closebutton = new Button("Close", this, "closeButtonClick"); - mywindow.addComponent(closebutton); - - /* Allow opening only one window at a time. */ - openbutton.setEnabled(false); - - explanation.setValue("Window opened"); - } - - /** Handle Close button click and close the window. */ - public void closeButtonClick(Button.ClickEvent event) { - /* Windows are managed by the application object. */ - mainwindow.removeWindow(mywindow); - - /* Return to initial state. */ - openbutton.setEnabled(true); - - explanation.setValue("Closed with button"); - } - - /** In case the window is closed otherwise. */ - public void windowClose(CloseEvent e) { - /* Return to initial state. */ - openbutton.setEnabled(true); - - explanation.setValue("Closed with window controls"); - } -} diff --git a/tests/src/com/vaadin/tests/book/WindowTestApplication.java b/tests/src/com/vaadin/tests/book/WindowTestApplication.java deleted file mode 100644 index 4e80122b96..0000000000 --- a/tests/src/com/vaadin/tests/book/WindowTestApplication.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.vaadin.tests.book; - -import java.util.HashMap; - -import com.vaadin.Application; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.ui.Label; -import com.vaadin.ui.Link; -import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; - -public class WindowTestApplication extends Application { - Window anotherpage = null; - - // Storage for extra window objects - there could be many. - HashMap windows = new HashMap(); - - /* - * (non-Javadoc) - * - * @see com.vaadin.Application#init() - */ - @Override - public void init() { - final Window main = new Window("Window Test Application"); - setMainWindow(main); - setTheme("tests-book"); - - /* Create a new window. */ - final Window mywindow = new Window("Second Window"); - - /* Manually set the name of the window. */ - mywindow.setName("mywindow"); - - /* Add some content to the window. */ - mywindow.addComponent(new Label("This is a second window.")); - - /* Add the window to the application. */ - addWindow(mywindow); - - // /* Add a button to open a new window. */ - // main.addComponent(new Button("Click to open new window", - // new Button.ClickListener() { - // public void buttonClick(ClickEvent event) { - // // Open the window. - // main.open(new ExternalResource(mywindow.getURL()), - // "_new"); - // } - // })); - // - // /* Add a link to the second window. */ - // Link link = new Link("Click to open second window", - // new ExternalResource(mywindow.getURL())); - // link.setTargetName("_new"); - // main.addComponent(link); - // - // // Add the link manually inside a Label. - // main.addComponent(new Label("Second window: <a href='" - // + mywindow.getURL() + "' target='_new'>click to open</a>", - // Label.CONTENT_XHTML)); - // main.addComponent(new Label( - // "The second window can be accessed through URL: " - // + mywindow.getURL())); - - // Add links to windows that do not yet exist, but are created - // dynamically when the URL is called. - - main.addComponent(new Label("Click a link to open a new window:")); - - // Have some IDs for the separate windows. - final String[] items = new String[] { "mercury", "venus", "earth", - "mars", "jupiter", "saturn", "uranus", "neptune" }; - - // Create a list of links to each of the available window. - for (int i = 0; i < items.length; i++) { - // Create a URL for the window. - String windowUrl = getURL() + "planet-" + items[i]; - - // Create a link to the window URL. - // Using the window ID for the target also opens it in a new - // browser window (or tab). - main.addComponent(new Link("Open window about " + items[i], - new ExternalResource(windowUrl), items[i], -1, -1, - Window.BORDER_DEFAULT)); - } - } - - @Override - /* - * This method is called for every client request for this application. It - * needs to return the correct window for the given identifier. - */ - public Window getWindow(String name) { - // If a dynamically created window is requested, but it does - // not exist yet, create it. - if (name.startsWith("planet-") && super.getWindow(name) == null) { - System.out.println("New window " + name); - - String planetName = name.substring("planet-".length()); - - // Create the window object. - Window newWindow = new Window("Window about " + planetName); - - // We must set this explicitly or otherwise an automatically - // generated name is used. - newWindow.setName(name); - - // Put some content in it. - newWindow.addComponent(new Label( - "This window contains details about " + planetName + ".")); - - // Add it to the application as a regular application-level window. - addWindow(newWindow); - - newWindow.addListener(new Window.CloseListener() { - public void windowClose(CloseEvent e) { - System.out.println(e.getWindow().getName() + " was closed"); - getMainWindow().addComponent( - new Label("Window '" + e.getWindow().getName() - + "' was closed.")); - } - }); - - return newWindow; - } - - // Otherwise the Application object manages existing windows by their - // name. - return super.getWindow(name); - } -} diff --git a/tests/src/com/vaadin/tests/book/images/Earth_small.png b/tests/src/com/vaadin/tests/book/images/Earth_small.png Binary files differdeleted file mode 100644 index abe9227914..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Earth_small.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Earth_symbol.png b/tests/src/com/vaadin/tests/book/images/Earth_symbol.png Binary files differdeleted file mode 100644 index 6060358883..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Earth_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Jupiter_symbol.png b/tests/src/com/vaadin/tests/book/images/Jupiter_symbol.png Binary files differdeleted file mode 100644 index 7a973bec48..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Jupiter_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Mars_symbol.png b/tests/src/com/vaadin/tests/book/images/Mars_symbol.png Binary files differdeleted file mode 100644 index 7ab7616c75..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Mars_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Mercury_small.png b/tests/src/com/vaadin/tests/book/images/Mercury_small.png Binary files differdeleted file mode 100644 index ef69931a8f..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Mercury_small.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Mercury_symbol.png b/tests/src/com/vaadin/tests/book/images/Mercury_symbol.png Binary files differdeleted file mode 100644 index 97c09d1b29..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Mercury_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Neptune_symbol.png b/tests/src/com/vaadin/tests/book/images/Neptune_symbol.png Binary files differdeleted file mode 100644 index 2b84811c80..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Neptune_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Saturn_symbol.png b/tests/src/com/vaadin/tests/book/images/Saturn_symbol.png Binary files differdeleted file mode 100644 index f4b7e5c6ca..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Saturn_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Uranus_symbol.png b/tests/src/com/vaadin/tests/book/images/Uranus_symbol.png Binary files differdeleted file mode 100644 index 74f755fb97..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Uranus_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Venus_small.png b/tests/src/com/vaadin/tests/book/images/Venus_small.png Binary files differdeleted file mode 100644 index 7bcac3fa4f..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Venus_small.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/images/Venus_symbol.png b/tests/src/com/vaadin/tests/book/images/Venus_symbol.png Binary files differdeleted file mode 100644 index 6d08313e5d..0000000000 --- a/tests/src/com/vaadin/tests/book/images/Venus_symbol.png +++ /dev/null diff --git a/tests/src/com/vaadin/tests/book/smiley.jpg b/tests/src/com/vaadin/tests/book/smiley.jpg Binary files differdeleted file mode 100644 index dc1a399c76..0000000000 --- a/tests/src/com/vaadin/tests/book/smiley.jpg +++ /dev/null diff --git a/tests/src/com/vaadin/tests/components/MenuBasedComponentTestCase.java b/tests/src/com/vaadin/tests/components/AbstractComponentTest.java index dfe1b675a6..5000a48bb5 100644 --- a/tests/src/com/vaadin/tests/components/MenuBasedComponentTestCase.java +++ b/tests/src/com/vaadin/tests/components/AbstractComponentTest.java @@ -16,8 +16,7 @@ import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.MenuItem;
-//TODO swap the inheritance order so AbstractComponentTestCase refers to AbstractComponent and this is the base class. Can only be done when all old tests are converted to use this.
-public abstract class MenuBasedComponentTestCase<T extends AbstractComponent>
+public abstract class AbstractComponentTest<T extends AbstractComponent>
extends AbstractComponentTestCase<T> {
protected static final String TEXT_SHORT = "Short";
@@ -57,6 +56,7 @@ public abstract class MenuBasedComponentTestCase<T extends AbstractComponent> protected static final String CATEGORY_SELECTION = "Selection";
protected static final String CATEGORY_LISTENERS = "Listeners";
protected static final String CATEGORY_FEATURES = "Features";
+ protected static final String CATEGORY_ACTIONS = "Actions";
protected static final String CATEGORY_DECORATIONS = "Decorations";
@Override
@@ -99,6 +99,13 @@ public abstract class MenuBasedComponentTestCase<T extends AbstractComponent> });
setSelected(showEventLog, true);
+
+ settingsMenu.addItem("Clear log", new MenuBar.Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ log.clear();
+ }
+ });
}
protected void setLogVisible(boolean visible) {
@@ -283,7 +290,6 @@ public abstract class MenuBasedComponentTestCase<T extends AbstractComponent> DATATYPE value, Object data) {
MenuItem categoryItem = getCategoryMenuItem(category);
categoryItem.addItem(caption, menuClickCommand(command, value, data));
- doCommand(caption, command, value, data);
}
private MenuItem getCategoryMenuItem(String category) {
@@ -488,6 +494,41 @@ public abstract class MenuBasedComponentTestCase<T extends AbstractComponent> }
}
+ protected LinkedHashMap<String, Integer> createIntegerOptions(int max) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ for (int i = 0; i <= 9 && i <= max; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ for (int i = 10; i <= max; i *= 10) {
+ options.put(String.valueOf(i), i);
+ if (2 * i <= max) {
+ options.put(String.valueOf(2 * i), 2 * i);
+ }
+ if (5 * i <= max) {
+ options.put(String.valueOf(5 * i), 5 * i);
+ }
+ }
+
+ return options;
+ }
+
+ protected LinkedHashMap<String, Resource> createIconOptions(
+ boolean cacheable) {
+ LinkedHashMap<String, Resource> options = new LinkedHashMap<String, Resource>();
+ options.put("-", null);
+ if (cacheable) {
+ options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
+ options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
+ options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
+ } else {
+ options.put("16x16", ICON_16_USER_PNG_UNCACHEABLE);
+ options.put("32x32", ICON_32_ATTENTION_PNG_UNCACHEABLE);
+ options.put("64x64", ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE);
+
+ }
+ return options;
+ }
+
protected void log(String msg) {
log.log(msg);
}
diff --git a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java index c0c1a29598..a08f8999a6 100644 --- a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java +++ b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java @@ -26,7 +26,7 @@ public class AbstractFieldCommitWithInvalidValues extends TestBase { @Override protected void setup() { tf = new TextField("A field, must contain 1-2 chars", - new ObjectProperty("a")); + new ObjectProperty<String>("a")); tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false)); tf.setWriteThrough(false); tf.setRequired(true); diff --git a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java index 5eaf9c17a1..2a2fc0153a 100644 --- a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java +++ b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java @@ -10,13 +10,15 @@ import com.vaadin.ui.TextField; public class AbstractFieldDataSourceReadOnly extends TestBase {
private static class StateHolder {
- private ObjectProperty textField = new ObjectProperty("");
+ private ObjectProperty<String> textField = new ObjectProperty<String>(
+ "");
- public ObjectProperty getTextField() {
+ public ObjectProperty<String> getTextField() {
return textField;
}
- public void setTextField(ObjectProperty textField) {
+ @SuppressWarnings("unused")
+ public void setTextField(ObjectProperty<String> textField) {
this.textField = textField;
}
diff --git a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldTestCase.java b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java index d13e164b6e..26df5114b5 100644 --- a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldTestCase.java +++ b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.abstractfield;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.List;
import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
@@ -11,11 +13,11 @@ import com.vaadin.event.FieldEvents.BlurNotifier; import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.event.FieldEvents.FocusNotifier;
-import com.vaadin.tests.components.MenuBasedComponentTestCase;
+import com.vaadin.tests.components.AbstractComponentTest;
import com.vaadin.ui.AbstractField;
-public abstract class AbstractFieldTestCase<T extends AbstractField> extends
- MenuBasedComponentTestCase<T> implements ValueChangeListener,
+public abstract class AbstractFieldTest<T extends AbstractField> extends
+ AbstractComponentTest<T> implements ValueChangeListener,
ReadOnlyStatusChangeListener, FocusListener, BlurListener {
@Override
@@ -26,6 +28,21 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends createValueChangeListener(CATEGORY_LISTENERS);
createReadOnlyStatusChangeListener(CATEGORY_LISTENERS);
+
+ // * invalidcommitted
+ // * commit()
+ // * discard()
+ // * writethrough
+ // * readthrough
+ // * addvalidator
+ // * isvalid
+ // * invalidallowed
+ // * error indicator
+ //
+ // * tabindex
+ // * validation visible
+ // * ShortcutListener
+
}
private void createRequiredErrorSelect(String category) {
@@ -38,6 +55,14 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends createSelectAction("Required error message", category, options, "-",
requiredErrorMessageCommand);
+ if (FocusNotifier.class.isAssignableFrom(getTestClass())) {
+ createFocusListener(CATEGORY_LISTENERS);
+ }
+
+ if (BlurNotifier.class.isAssignableFrom(getTestClass())) {
+ createBlurListener(CATEGORY_LISTENERS);
+ }
+
}
private void createValueChangeListener(String category) {
@@ -52,13 +77,13 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends false, readonlyStatusChangeListenerCommand);
}
- protected void createFocusListener(String category) {
+ private void createFocusListener(String category) {
createBooleanAction("Focus listener", category, false,
focusListenerCommand);
}
- protected void createBlurListener(String category) {
+ private void createBlurListener(String category) {
createBooleanAction("Blur listener", category, false,
blurListenerCommand);
@@ -68,9 +93,9 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener((ValueChangeListener) AbstractFieldTestCase.this);
+ c.addListener((ValueChangeListener) AbstractFieldTest.this);
} else {
- c.removeListener((ValueChangeListener) AbstractFieldTestCase.this);
+ c.removeListener((ValueChangeListener) AbstractFieldTest.this);
}
}
};
@@ -78,9 +103,9 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener((ReadOnlyStatusChangeListener) AbstractFieldTestCase.this);
+ c.addListener((ReadOnlyStatusChangeListener) AbstractFieldTest.this);
} else {
- c.removeListener((ReadOnlyStatusChangeListener) AbstractFieldTestCase.this);
+ c.removeListener((ReadOnlyStatusChangeListener) AbstractFieldTest.this);
}
}
};
@@ -88,9 +113,9 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends public void execute(T c, Boolean value, Object data) {
if (value) {
- ((FocusNotifier) c).addListener(AbstractFieldTestCase.this);
+ ((FocusNotifier) c).addListener(AbstractFieldTest.this);
} else {
- ((FocusNotifier) c).removeListener(AbstractFieldTestCase.this);
+ ((FocusNotifier) c).removeListener(AbstractFieldTest.this);
}
}
};
@@ -98,16 +123,29 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends public void execute(T c, Boolean value, Object data) {
if (value) {
- ((BlurNotifier) c).addListener(AbstractFieldTestCase.this);
+ ((BlurNotifier) c).addListener(AbstractFieldTest.this);
} else {
- ((BlurNotifier) c).removeListener(AbstractFieldTestCase.this);
+ ((BlurNotifier) c).removeListener(AbstractFieldTest.this);
}
}
};
+ private Command<T, Object> setValueCommand = new Command<T, Object>() {
+
+ public void execute(T c, Object value, Object data) {
+ c.setValue(value);
+ }
+ };
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
- log(event.getClass().getSimpleName() + ", new value: "
- + event.getProperty().getValue());
+ Object o = event.getProperty().getValue();
+
+ // Distinguish between null and 'null'
+ String value = "null";
+ if (o != null) {
+ value = "'" + o.toString() + "'";
+ }
+
+ log(event.getClass().getSimpleName() + ", new value: " + value);
};
public void readOnlyStatusChange(ReadOnlyStatusChangeEvent event) {
@@ -121,4 +159,20 @@ public abstract class AbstractFieldTestCase<T extends AbstractField> extends public void blur(BlurEvent event) {
log(event.getClass().getSimpleName());
}
+
+ protected void createSetTextValueAction(String category) {
+ String subCategory = "Set text value";
+ createCategory(subCategory, category);
+ List<String> values = new ArrayList<String>();
+ values.add("Test");
+ values.add("A little longer value");
+ values.add("A very long value with very much text. All in all it is 74 characters long");
+
+ createClickAction("(empty string)", subCategory, setValueCommand, "");
+ createClickAction("(null)", subCategory, setValueCommand, null);
+ for (String value : values) {
+ createClickAction(value, subCategory, setValueCommand, value);
+ }
+ }
+
}
diff --git a/tests/src/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java b/tests/src/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java new file mode 100644 index 0000000000..849f808288 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java @@ -0,0 +1,61 @@ +package com.vaadin.tests.components.abstractfield;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.ui.AbstractTextField;
+
+public abstract class AbstractTextFieldTest<T extends AbstractTextField>
+ extends AbstractFieldTest<T> {
+
+ private Command<T, Integer> maxlengthCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.setMaxLength(value);
+ }
+ };
+ private Command<T, Boolean> nullSelectionAllowedCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setNullSettingAllowed(value);
+
+ }
+ };
+ private Command<T, String> nullRepresentationCommand = new Command<T, String>() {
+
+ public void execute(T c, String value, Object data) {
+ c.setNullRepresentation(value);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createNullSettingAllowedAction();
+ createNullRepresentationAction();
+ createMaxLengthAction();
+ }
+
+ private void createNullSettingAllowedAction() {
+ createBooleanAction("Null selection allowed", CATEGORY_FEATURES, true,
+ nullSelectionAllowedCommand);
+ }
+
+ private void createNullRepresentationAction() {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("null", "null");
+ options.put("This is empty", "This is empty");
+ options.put("- Nothing -", "- Nothing -");
+ createSelectAction("Null representation", CATEGORY_FEATURES, options,
+ "null", nullRepresentationCommand);
+ }
+
+ private void createMaxLengthAction() {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(100);
+ options.put("-", -1);
+ createSelectAction("Max length", CATEGORY_FEATURES, options, "-",
+ maxlengthCommand);
+
+ }
+}
diff --git a/tests/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java b/tests/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java index b4ced4622c..837256ff65 100644 --- a/tests/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java +++ b/tests/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java @@ -6,12 +6,12 @@ import com.vaadin.tests.util.Log; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.TextField;
+import com.vaadin.ui.TextArea;
public class ShortcutAddAndRemove extends TestBase {
private Log log;
- private TextField textArea;
+ private TextArea textArea;
@Override
protected void setup() {
@@ -41,7 +41,7 @@ public class ShortcutAddAndRemove extends TestBase { });
addComponent(log);
addComponent(logButton);
- textArea = new TextField("Enter key does not break lines ...");
+ textArea = new TextArea("Enter key does not break lines ...");
textArea.setRows(5);
textArea.setColumns(20);
addComponent(textArea);
diff --git a/tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java b/tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java index 28b06709ff..959d5eaf97 100644 --- a/tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java +++ b/tests/src/com/vaadin/tests/components/accordion/AccordionInactiveTabSize.java @@ -2,6 +2,7 @@ package com.vaadin.tests.components.accordion; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Accordion; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.TextField; @@ -20,7 +21,7 @@ public class AccordionInactiveTabSize extends TestBase { @Override protected void setup() { - SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + SplitPanel sp = new HorizontalSplitPanel(); sp.setSizeFull(); Accordion acc = new Accordion(); diff --git a/tests/src/com/vaadin/tests/components/accordion/RemoveTabs.java b/tests/src/com/vaadin/tests/components/accordion/RemoveTabs.java index 6e2a28857b..bc8bea1c56 100644 --- a/tests/src/com/vaadin/tests/components/accordion/RemoveTabs.java +++ b/tests/src/com/vaadin/tests/components/accordion/RemoveTabs.java @@ -95,18 +95,16 @@ public class RemoveTabs extends TestBase { accordion.removeComponent(accordion.getComponentIterator().next());
}
- @SuppressWarnings("unchecked")
private void closeLastTab() {
- Iterator i = accordion.getComponentIterator();
+ Iterator<Component> i = accordion.getComponentIterator();
Component last = null;
while (i.hasNext()) {
- last = (Component) i.next();
+ last = i.next();
}
accordion.removeComponent(last);
}
- @SuppressWarnings("unchecked")
private void reorder() {
AbstractComponentContainer container = accordion;
diff --git a/tests/src/com/vaadin/tests/components/button/Buttons2.java b/tests/src/com/vaadin/tests/components/button/Buttons2.java index ecb5d34fa4..b4cdbff73c 100644 --- a/tests/src/com/vaadin/tests/components/button/Buttons2.java +++ b/tests/src/com/vaadin/tests/components/button/Buttons2.java @@ -1,11 +1,11 @@ package com.vaadin.tests.components.button;
-import com.vaadin.tests.components.abstractfield.AbstractFieldTestCase;
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
-public class Buttons2 extends AbstractFieldTestCase<Button> implements
+public class Buttons2 extends AbstractFieldTest<Button> implements
ClickListener {
private Command<Button, Boolean> switchModeCommand = new Command<Button, Boolean>() {
@@ -36,9 +36,6 @@ public class Buttons2 extends AbstractFieldTestCase<Button> implements protected void createActions() {
super.createActions();
- createFocusListener(CATEGORY_LISTENERS);
- createBlurListener(CATEGORY_LISTENERS);
-
createBooleanAction("Switch mode", CATEGORY_FEATURES, false,
switchModeCommand);
addClickListener(CATEGORY_LISTENERS);
diff --git a/tests/src/com/vaadin/tests/components/checkbox/CheckBoxes2.java b/tests/src/com/vaadin/tests/components/checkbox/CheckBoxes2.java index 38307b5c4d..cad8263634 100644 --- a/tests/src/com/vaadin/tests/components/checkbox/CheckBoxes2.java +++ b/tests/src/com/vaadin/tests/components/checkbox/CheckBoxes2.java @@ -1,11 +1,11 @@ package com.vaadin.tests.components.checkbox;
-import com.vaadin.tests.components.abstractfield.AbstractFieldTestCase;
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CheckBox;
-public class CheckBoxes2 extends AbstractFieldTestCase<CheckBox> implements
+public class CheckBoxes2 extends AbstractFieldTest<CheckBox> implements
ClickListener {
// cannot extend Buttons2 because of Switch mode problems
@@ -38,8 +38,6 @@ public class CheckBoxes2 extends AbstractFieldTestCase<CheckBox> implements protected void createActions() {
super.createActions();
- createFocusListener(CATEGORY_LISTENERS);
- createBlurListener(CATEGORY_LISTENERS);
createBooleanAction("Switch mode", CATEGORY_FEATURES, true,
switchModeCommand);
addClickListener(CATEGORY_LISTENERS);
diff --git a/tests/src/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java b/tests/src/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java index a43d1fd8d6..5a488e5dc5 100644 --- a/tests/src/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java @@ -30,7 +30,8 @@ public class ComboBoxInPopupView extends TestBase { cb2.setWidth("260px"); PopupView pv2 = new PopupView("<u>2. focused (click)</u>", cb2) { @Override - public void changeVariables(Object source, Map variables) { + public void changeVariables(Object source, + Map<String, Object> variables) { super.changeVariables(source, variables); cb2.focus(); } diff --git a/tests/src/com/vaadin/tests/components/combobox/ComboBoxValueUpdate.java b/tests/src/com/vaadin/tests/components/combobox/ComboBoxValueUpdate.java index 75cefe9360..b8f7a9758d 100644 --- a/tests/src/com/vaadin/tests/components/combobox/ComboBoxValueUpdate.java +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxValueUpdate.java @@ -12,8 +12,6 @@ public class ComboBoxValueUpdate extends TestBase { return 2451; } - private Label selectedLabel; - @Override protected String getDescription() { return "Testcase for ComboBox. Test especially edge values(of page changes) when selecting items with keyboard only."; diff --git a/tests/src/com/vaadin/tests/components/combobox/ComboBoxes2.java b/tests/src/com/vaadin/tests/components/combobox/ComboBoxes2.java index c3c3bd8968..92e9c29595 100644 --- a/tests/src/com/vaadin/tests/components/combobox/ComboBoxes2.java +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxes2.java @@ -8,6 +8,12 @@ import com.vaadin.ui.ComboBox; public class ComboBoxes2 extends AbstractSelectTestCase<ComboBox> { + private Command<ComboBox, String> inputPromptCommand = new Command<ComboBox, String>() { + public void execute(ComboBox c, String value, Object data) { + c.setInputPrompt(value); + } + }; + @Override protected Class<ComboBox> getTestClass() { return ComboBox.class; @@ -17,17 +23,22 @@ public class ComboBoxes2 extends AbstractSelectTestCase<ComboBox> { protected void createActions() { super.createActions(); createItemIconSelect(CATEGORY_DATA_SOURCE); + createInputPromptAction(CATEGORY_FEATURES); } - private void createItemIconSelect(String category) { - - LinkedHashMap<String, Resource> options = new LinkedHashMap<String, Resource>(); + private void createInputPromptAction(String category) { + LinkedHashMap<String, String> options = new LinkedHashMap<String, String>(); options.put("-", null); - options.put("16x16", ICON_16_USER_PNG_UNCACHEABLE); - options.put("32x32", ICON_32_ATTENTION_PNG_UNCACHEABLE); - options.put("64x64", ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE); + options.put("Enter a value", "Enter a value"); + options.put("- Click here -", "- Click here -"); + createSelectAction("Input prompt", category, options, "-", + inputPromptCommand); + + } + + private void createItemIconSelect(String category) { - createSelectAction("Icon", category, options, "-", + createSelectAction("Icon", category, createIconOptions(false), "-", new Command<ComboBox, Resource>() { public void execute(ComboBox c, Resource value, Object data) { diff --git a/tests/src/com/vaadin/tests/components/combobox/NewItemsESCPress.java b/tests/src/com/vaadin/tests/components/combobox/NewItemsESCPress.java index 945b2b605b..d93db563e3 100644 --- a/tests/src/com/vaadin/tests/components/combobox/NewItemsESCPress.java +++ b/tests/src/com/vaadin/tests/components/combobox/NewItemsESCPress.java @@ -3,38 +3,38 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractSelect.NewItemHandler; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.TextField; +import com.vaadin.ui.TextArea; @SuppressWarnings("serial") public class NewItemsESCPress extends TestBase { - @Override - protected void setup() { - final TextField addedItems = new TextField("Last added items:"); - addedItems.setRows(10); - addComponent(addedItems); - - final ComboBox box = new ComboBox("New items are allowed"); - box.setNewItemsAllowed(true); - box.setNewItemHandler(new NewItemHandler() { - public void addNewItem(String newItemCaption) { - String value = (String) addedItems.getValue(); - addedItems.setValue(value + newItemCaption + "\n" ); - box.addItem(newItemCaption); - } - }); - box.setImmediate(true); - addComponent(box); - } + @Override + protected void setup() { + final TextArea addedItems = new TextArea("Last added items:"); + addedItems.setRows(10); + addComponent(addedItems); - @Override - protected String getDescription() { - return "Firefox flashes the previously entered value when holding the ESC-key."; - } + final ComboBox box = new ComboBox("New items are allowed"); + box.setNewItemsAllowed(true); + box.setNewItemHandler(new NewItemHandler() { + public void addNewItem(String newItemCaption) { + String value = (String) addedItems.getValue(); + addedItems.setValue(value + newItemCaption + "\n"); + box.addItem(newItemCaption); + } + }); + box.setImmediate(true); + addComponent(box); + } - @Override - protected Integer getTicketNumber() { - return 5694; - } + @Override + protected String getDescription() { + return "Firefox flashes the previously entered value when holding the ESC-key."; + } + + @Override + protected Integer getTicketNumber() { + return 5694; + } } diff --git a/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java b/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java index fa7ee7f8b4..b07a9b1ad8 100644 --- a/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java +++ b/tests/src/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java @@ -63,6 +63,7 @@ public class DateFieldEmptyValid extends TestBase { b = new Button("Set date to 4.5.1990");
b.addListener(new ClickListener() {
+ @SuppressWarnings("deprecation")
public void buttonClick(ClickEvent event) {
df.setValue(new Date(1990 - 1900, 5 - 1, 4));
}
@@ -72,9 +73,10 @@ public class DateFieldEmptyValid extends TestBase { b = new Button("Set date to 5.6.2000 using a property data source");
b.addListener(new ClickListener() {
+ @SuppressWarnings("deprecation")
public void buttonClick(ClickEvent event) {
- ObjectProperty dfProp = new ObjectProperty(new Date(
- 2000 - 1900, 6 - 1, 5), Date.class);
+ ObjectProperty<Date> dfProp = new ObjectProperty<Date>(
+ new Date(2000 - 1900, 6 - 1, 5), Date.class);
df.setPropertyDataSource(dfProp);
}
});
@@ -84,8 +86,10 @@ public class DateFieldEmptyValid extends TestBase { "Set date to 27.8.2005 by changing a property data source from null");
b.addListener(new ClickListener() {
+ @SuppressWarnings("deprecation")
public void buttonClick(ClickEvent event) {
- ObjectProperty dfProp = new ObjectProperty(null, Date.class);
+ ObjectProperty<Date> dfProp = new ObjectProperty<Date>(null,
+ Date.class);
df.setPropertyDataSource(dfProp);
dfProp.setValue(new Date(2005 - 1900, 8 - 1, 27));
}
diff --git a/tests/src/com/vaadin/tests/components/datefield/DateFieldTestCase.java b/tests/src/com/vaadin/tests/components/datefield/DateFieldTestCase.java index e8eeb97444..65e388633c 100644 --- a/tests/src/com/vaadin/tests/components/datefield/DateFieldTestCase.java +++ b/tests/src/com/vaadin/tests/components/datefield/DateFieldTestCase.java @@ -5,11 +5,11 @@ import java.text.SimpleDateFormat; import java.util.LinkedHashMap;
import java.util.Locale;
-import com.vaadin.tests.components.abstractfield.AbstractFieldTestCase;
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.DateField;
public abstract class DateFieldTestCase<T extends DateField> extends
- AbstractFieldTestCase<T> {
+ AbstractFieldTest<T> {
@Override
protected void createActions() {
@@ -19,8 +19,6 @@ public abstract class DateFieldTestCase<T extends DateField> extends createBooleanAction("Show week numbers", CATEGORY_FEATURES, false,
weekNumberCommand);
createDateFormatSelectAction(CATEGORY_FEATURES);
- createFocusListener(CATEGORY_LISTENERS);
- createBlurListener(CATEGORY_LISTENERS);
};
private void createDateFormatSelectAction(String category) {
diff --git a/tests/src/com/vaadin/tests/components/datefield/LenientMode.java b/tests/src/com/vaadin/tests/components/datefield/LenientMode.java index 96eaa2117f..cbe9ac613f 100644 --- a/tests/src/com/vaadin/tests/components/datefield/LenientMode.java +++ b/tests/src/com/vaadin/tests/components/datefield/LenientMode.java @@ -26,6 +26,7 @@ public class LenientMode extends TestBase implements ValueChangeListener { @Override protected void setup() { + @SuppressWarnings("deprecation") Date d = new Date(2009 - 1900, 12 - 1, 31, 23, 59, 59); DateField df = new DateField("Lenient "); diff --git a/tests/src/com/vaadin/tests/components/datefield/TestDatefieldYear.java b/tests/src/com/vaadin/tests/components/datefield/TestDatefieldYear.java index 8a1df36aa4..4fa7a6811a 100644 --- a/tests/src/com/vaadin/tests/components/datefield/TestDatefieldYear.java +++ b/tests/src/com/vaadin/tests/components/datefield/TestDatefieldYear.java @@ -20,6 +20,7 @@ public class TestDatefieldYear extends TestBase { @Override protected void setup() { + @SuppressWarnings("deprecation") DateField df = new DateField("Year", new Date(2009 - 1900, 4 - 1, 1)); df.setLocale(new Locale("en", "US")); df.setResolution(DateField.RESOLUTION_YEAR); diff --git a/tests/src/com/vaadin/tests/components/form/FormNotGettingSmaller.java b/tests/src/com/vaadin/tests/components/form/FormNotGettingSmaller.java index 488a97c2d7..a47ab944a2 100644 --- a/tests/src/com/vaadin/tests/components/form/FormNotGettingSmaller.java +++ b/tests/src/com/vaadin/tests/components/form/FormNotGettingSmaller.java @@ -14,9 +14,11 @@ public class FormNotGettingSmaller extends TestBase { @Override protected void setup() { Item item = new PropertysetItem(); - item.addItemProperty("name", new ObjectProperty("Charles Anthony")); - item.addItemProperty("city", new ObjectProperty("London")); - item.addItemProperty("isTallPerson", new ObjectProperty(Boolean.FALSE)); + item.addItemProperty("name", new ObjectProperty<String>( + "Charles Anthony")); + item.addItemProperty("city", new ObjectProperty<String>("London")); + item.addItemProperty("isTallPerson", new ObjectProperty<Boolean>( + Boolean.FALSE)); Label spacer = new Label(); HorizontalLayout buttons = new HorizontalLayout(); diff --git a/tests/src/com/vaadin/tests/components/form/FormRenderingFlicker.java b/tests/src/com/vaadin/tests/components/form/FormRenderingFlicker.java index 6956eee017..5858366a63 100644 --- a/tests/src/com/vaadin/tests/components/form/FormRenderingFlicker.java +++ b/tests/src/com/vaadin/tests/components/form/FormRenderingFlicker.java @@ -32,7 +32,7 @@ public class FormRenderingFlicker extends TestBase { form = new Form();
tablePanel = new Panel();
- tablePanel.setLayout(tableLayout);
+ tablePanel.setContent(tableLayout);
addComponent(tablePanel);
}
diff --git a/tests/src/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java b/tests/src/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java index 4c47c8a58d..cb616d4548 100644 --- a/tests/src/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java +++ b/tests/src/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.form; import com.vaadin.Application; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; @@ -29,7 +30,7 @@ public class UndefinedWideFormWithRelativeWideFooter extends Application { hl.setWidth("100%"); Button b = new Button("right aligned"); hl.addComponent(b); - hl.setComponentAlignment(b, "r"); + hl.setComponentAlignment(b, Alignment.TOP_RIGHT); f.setFooter(hl); } } diff --git a/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.html b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.html new file mode 100644 index 0000000000..5a2a0d839a --- /dev/null +++ b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.html @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>CustomizedLoginFormTest</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">CustomizedLoginFormTest</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.loginform.CustomizedLoginFormTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td>300</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>french</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.java b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.java new file mode 100644 index 0000000000..3fde281c20 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/loginform/CustomizedLoginFormTest.java @@ -0,0 +1,24 @@ +package com.vaadin.tests.components.loginform; + +public class CustomizedLoginFormTest extends LoginFormTest { + + @Override + protected void setup() { + super.setup(); + + loginForm.setUsernameCaption("Identifiant"); + loginForm.setPasswordCaption("Mot de passe"); + loginForm.setLoginButtonCaption("Se connecter"); + } + + @Override + protected String getDescription() { + return "Customization of the captions on the LoginForm component. Three login forms should be visible (undefined height, undefined width, defined height and width). Entering a username+password in a login form and clicking 'login' should replace the login form with a label telling the user name as password. Also a logout button should then be shown and pressing that takes the user back to the original screen with the LoginForm"; + } + + @Override + protected Integer getTicketNumber() { + return 5226; + } + +} diff --git a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java index 761800de5a..bbc7d2ca7e 100644 --- a/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java +++ b/tests/src/com/vaadin/tests/components/loginform/LoginFormTest.java @@ -14,7 +14,7 @@ import com.vaadin.ui.VerticalLayout; public class LoginFormTest extends TestBase { private HorizontalLayout loginFormLayout; - private LoginForm loginForm; + protected LoginForm loginForm; @Override protected void setup() { diff --git a/tests/src/com/vaadin/tests/components/menubar/MenuBarNavigation.java b/tests/src/com/vaadin/tests/components/menubar/MenuBarNavigation.java index f9f56ddbfe..54b2f986a4 100644 --- a/tests/src/com/vaadin/tests/components/menubar/MenuBarNavigation.java +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarNavigation.java @@ -10,7 +10,6 @@ public class MenuBarNavigation extends TestBase implements Command { private MenuItem edit;
private MenuItem file;
- private MenuItem help;
private Log log;
private MenuItem export;
@@ -30,7 +29,7 @@ public class MenuBarNavigation extends TestBase implements Command { edit.addItem("Copy", this);
edit.addItem("Cut", this);
edit.addItem("Paste", this);
- help = mb.addItem("Help", this);
+ mb.addItem("Help", this);
addComponent(mb);
diff --git a/tests/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.html b/tests/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.html new file mode 100755 index 0000000000..330a92898c --- /dev/null +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.html @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.menubar.MenuBarRunsOutOfBrowser?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>menu-top-right</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java b/tests/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java new file mode 100644 index 0000000000..314df2c8a4 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.components.menubar;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class MenuBarRunsOutOfBrowser extends AbstractTestCase {
+
+ @Override
+ public void init() {
+ setTheme("runo");
+ Window main = new Window("Test");
+ main.setSizeFull();
+ setMainWindow(main);
+ main.getContent().setSizeFull();
+
+ MenuBar menuBar = new MenuBar();
+ menuBar.addItem("Test", new ThemeResource("icons/16/calendar.png"),
+ null);
+ menuBar.addItem("ABC", new ThemeResource("icons/16/document.png"), null);
+ menuBar.addItem("123", new ThemeResource("icons/16/help.png"), null);
+
+ main.getContent().addComponent(menuBar);
+ ((VerticalLayout) main.getContent()).setComponentAlignment(menuBar,
+ Alignment.TOP_RIGHT);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The menubar should be right aligned but not run out of the browser";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5894;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html b/tests/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html new file mode 100644 index 0000000000..28bcc3a221 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.menubar.MenuBarToolTips?restartApplication</td> + <td></td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item0</td> + <td>0,0</td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>File menu</td> +</tr> +<tr> + <td>mouseOut</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item0</td> + <td>18,11</td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VOverlay[0]/VMenuBar[0]#item0</td> + <td>0,0</td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>File - Foo menu</td> +</tr> +<tr> + <td>mouseOut</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/domChild[0]/domChild[1]</td> + <td>830,200</td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item1</td> + <td>0,0</td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Edit menu</td> +</tr> +<tr> + <td>mouseOut</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/domChild[0]/domChild[1]</td> + <td>625,184</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item1</td> + <td>9,6</td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>0,0</td> +</tr> +<tr> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Edit - Bar menu</td> +</tr> +<tr> + <td>mouseOut</td> + <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/menubar/MenuBarToolTips.java b/tests/src/com/vaadin/tests/components/menubar/MenuBarToolTips.java new file mode 100644 index 0000000000..0ef31dc5dc --- /dev/null +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBarToolTips.java @@ -0,0 +1,50 @@ +package com.vaadin.tests.components.menubar; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.MenuItem; + +public class MenuBarToolTips extends TestBase { + + @Override + protected void setup() { + MenuBar bar = new MenuBar(); + bar.setDescription("Root Menu"); + + // File + final MenuItem file = bar.addItem("File", null); + file.setDescription("File menu"); + + MenuItem foo = file.addItem("Foo", null); + foo.setDescription("File - Foo menu"); + + MenuItem foobar = foo.addItem("Foobar", null); + foobar.setDescription("File - Foo menu - Foobar menu"); + + MenuItem bar2 = file.addItem("Bar", null); + bar2.setDescription("File - Bar menu"); + + // Edit + MenuItem edit = bar.addItem("Edit", null); + edit.setDescription("Edit menu"); + + MenuItem foo2 = edit.addItem("Foo", null); + foo2.setDescription("Edit - Foo menu"); + + MenuItem bar3 = edit.addItem("Bar", null); + bar3.setDescription("Edit - Bar menu"); + + addComponent(bar); + } + + @Override + protected String getDescription() { + return "There should be tooltips on the menubar and its items"; + } + + @Override + protected Integer getTicketNumber() { + return 5919; + } + +} diff --git a/tests/src/com/vaadin/tests/components/menubar/MenuBars2.java b/tests/src/com/vaadin/tests/components/menubar/MenuBars2.java new file mode 100644 index 0000000000..b533f2b59d --- /dev/null +++ b/tests/src/com/vaadin/tests/components/menubar/MenuBars2.java @@ -0,0 +1,299 @@ +package com.vaadin.tests.components.menubar;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class MenuBars2 extends AbstractComponentTest<MenuBar> {
+
+ private static final String CATEGORY_MENU_ITEMS = "Menu items";
+ private static final String CATEGORY_MENU_ITEM_STATES = "Menu item states";
+
+ private int rootItems = -1;
+ private int subItems = -1;
+ private int subLevels = -1;
+ private int subMenuDensity = -1;
+ private Integer subMenuSeparatorDensity = null;
+ private int iconInterval = -1;
+ private Integer iconSize;
+ private Integer disabledDensity;
+ private Integer invisibleDensity;
+
+ @Override
+ protected Class<MenuBar> getTestClass() {
+ return MenuBar.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createRootMenuItemSelect(CATEGORY_MENU_ITEMS);
+ createSubMenuItemSelect(CATEGORY_MENU_ITEMS);
+ createSubMenuLevelsSelect(CATEGORY_MENU_ITEMS);
+ createSubMenuDensitySelect(CATEGORY_MENU_ITEMS);
+ createSubMenuSeparatorDensitySelect(CATEGORY_MENU_ITEMS);
+
+ createMenuItemIconIntervalSelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuIconsSizeSelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuItemDisabledDensitySelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuItemInvisibleDensitySelect(CATEGORY_MENU_ITEM_STATES);
+
+ }
+
+ private void createRootMenuItemSelect(String category) {
+ createSelectAction("Root menu items", category,
+ createIntegerOptions(100), "10", createRootMenuItems);
+ }
+
+ private void createSubMenuItemSelect(String category) {
+ createSelectAction("Sub menu items", category,
+ createIntegerOptions(100), "10", createSubMenuItems);
+ }
+
+ private void createSubMenuLevelsSelect(String category) {
+ createSelectAction("Sub menu levels", category,
+ createIntegerOptions(100), "2", setSubMenuLevels);
+ }
+
+ private void createMenuIconsSizeSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("16x16", 16);
+ options.put("32x32", 32);
+ options.put("64x64", 64);
+ createSelectAction("Icon size", category, options, "16x16", selectIcon);
+ }
+
+ private void createMenuItemIconIntervalSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("None", 0);
+ options.put("All", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Icons", category, options, "None", setMenuIcons);
+ }
+
+ private void createSubMenuDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("All", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Sub sub menus", category, options, "Every third",
+ setSubMenuDensity);
+ }
+
+ private void createSubMenuSeparatorDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("No separators", null);
+ options.put("Between all", 1);
+ options.put("Between every second", 2);
+ options.put("Between every third", 3);
+
+ createSelectAction("Sub menu separators", category, options,
+ "No separators", setSubMenuSeparatorDensity);
+ }
+
+ private void createMenuItemDisabledDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("All enabled", null);
+ options.put("All disabled", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Enabled", category, options, "All enabled",
+ setMenuItemDisabledDensity);
+ }
+
+ private void createMenuItemInvisibleDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("All visible", null);
+ options.put("All invisible", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Visible", category, options, "All visible",
+ setMenuItemInvisibleDensity);
+ }
+
+ /* COMMANDS */
+ Command<MenuBar, Integer> createRootMenuItems = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ rootItems = value;
+ createRootItems(c);
+ }
+ };
+
+ Command<MenuBar, Integer> createSubMenuItems = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subItems = value;
+ createSubItems(c);
+ }
+ };
+
+ Command<MenuBar, Integer> setSubMenuLevels = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subLevels = value;
+ createSubItems(c);
+ }
+ };
+ private Command<MenuBar, Integer> setMenuIcons = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ iconInterval = value;
+ updateIcons(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setSubMenuDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subMenuDensity = value;
+ createSubItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setMenuItemDisabledDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ disabledDensity = value;
+ createRootItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setMenuItemInvisibleDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ invisibleDensity = value;
+ createRootItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setSubMenuSeparatorDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subMenuSeparatorDensity = value;
+ createSubItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> selectIcon = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ iconSize = value;
+ updateIcons(c);
+ }
+ };
+
+ /* End of commands */
+
+ private MenuBar.Command menuCommand = new MenuBar.Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ log("Menu item '" + selectedItem.getText() + "' selected");
+
+ }
+ };
+
+ protected void createSubItems(MenuBar c) {
+ for (MenuItem rootItem : c.getItems()) {
+ createSubItems(rootItem, 1);
+ }
+ updateIcons(c);
+
+ }
+
+ private void createSubItems(MenuItem parent, int level) {
+ if (level > subLevels) {
+ return;
+ }
+
+ parent.removeChildren();
+ for (int i = 0; i < subItems; i++) {
+ if (subMenuSeparatorDensity != null && i > 0
+ && i % subMenuSeparatorDensity == 0) {
+ parent.addSeparator();
+ }
+
+ MenuItem subMenuItem = parent.addItem("Sub menu " + parent.getId()
+ + "/" + (i + 1), menuCommand);
+
+ if (disabledDensity != null && i % disabledDensity == 0) {
+ subMenuItem.setEnabled(false);
+ }
+ if (invisibleDensity != null && i % invisibleDensity == 0) {
+ subMenuItem.setVisible(false);
+ }
+
+ if (i % subMenuDensity == 0 && level < subLevels) {
+ subMenuItem.setCommand(null);
+ createSubItems(subMenuItem, level + 1);
+ }
+ }
+
+ }
+
+ protected void updateIcons(MenuBar c) {
+ int idx = 0;
+ for (MenuItem rootItem : c.getItems()) {
+ updateIcons(rootItem, idx++);
+ }
+ }
+
+ private void updateIcons(MenuItem item, int idx) {
+ if (iconInterval > 0 && idx % iconInterval == 0) {
+ item.setIcon(getIcon());
+ } else {
+ item.setIcon(null);
+ }
+ if (item.getChildren() != null) {
+ int i = 0;
+ for (MenuItem child : item.getChildren()) {
+ updateIcons(child, i++);
+ }
+ }
+ }
+
+ private long iconCacheIndex = new Date().getTime();
+
+ private Resource getIcon() {
+ String resourceID = null;
+ if (iconSize == 16) {
+ resourceID = "../runo/icons/16/user.png";
+ } else if (iconSize == 32) {
+ resourceID = "../runo/icons/32/user.png";
+ } else if (iconSize == 64) {
+ resourceID = "../runo/icons/64/user.png";
+ }
+
+ if (resourceID != null) {
+ return new ThemeResource(resourceID + "?" + iconCacheIndex++);
+ }
+ return null;
+ }
+
+ protected void createRootItems(MenuBar c) {
+ // Remove all existing items
+ c.removeItems();
+ for (int i = 0; i < rootItems; i++) {
+ MenuItem rootItem = c.addItem("Root menu " + (i + 1), null);
+ if (disabledDensity != null && i % disabledDensity == 0) {
+ rootItem.setEnabled(false);
+ }
+ if (invisibleDensity != null && i % invisibleDensity == 0) {
+ rootItem.setVisible(false);
+ }
+ }
+ createSubItems(c);
+
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/optiongroup/OptionGroups.java b/tests/src/com/vaadin/tests/components/optiongroup/OptionGroups.java index e8eaa282b8..8e9766f421 100644 --- a/tests/src/com/vaadin/tests/components/optiongroup/OptionGroups.java +++ b/tests/src/com/vaadin/tests/components/optiongroup/OptionGroups.java @@ -13,8 +13,6 @@ public class OptionGroups extends AbstractSelectTestCase<OptionGroup> { @Override
protected void createActions() {
super.createActions();
- createFocusListener(CATEGORY_LISTENERS);
- createBlurListener(CATEGORY_LISTENERS);
createDisabledItemsMultiToggle("Disabled items");
}
diff --git a/tests/src/com/vaadin/tests/components/richtextarea/RichTextAreasGeneric.java b/tests/src/com/vaadin/tests/components/richtextarea/RichTextAreasGeneric.java new file mode 100644 index 0000000000..ca8b641e5f --- /dev/null +++ b/tests/src/com/vaadin/tests/components/richtextarea/RichTextAreasGeneric.java @@ -0,0 +1,13 @@ +package com.vaadin.tests.components.richtextarea;
+
+import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
+import com.vaadin.ui.RichTextArea;
+
+public class RichTextAreasGeneric extends AbstractTextFieldTest<RichTextArea> {
+
+ @Override
+ protected Class<RichTextArea> getTestClass() {
+ return RichTextArea.class;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java b/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java index c5b97d4e87..70624bf1d9 100644 --- a/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java +++ b/tests/src/com/vaadin/tests/components/select/AbstractSelectTestCase.java @@ -7,12 +7,12 @@ import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.event.ItemClickEvent.ItemClickSource;
-import com.vaadin.tests.components.abstractfield.AbstractFieldTestCase;
+import com.vaadin.event.ItemClickEvent.ItemClickNotifier;
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.AbstractSelect;
public abstract class AbstractSelectTestCase<T extends AbstractSelect> extends
- AbstractFieldTestCase<T> implements ItemClickListener {
+ AbstractFieldTest<T> implements ItemClickListener {
protected static final String CATEGORY_DATA_SOURCE = "Data source";
@@ -141,9 +141,10 @@ public abstract class AbstractSelectTestCase<T extends AbstractSelect> extends public void execute(T c, Boolean value, Object data) {
if (value) {
- ((ItemClickSource) c).addListener(AbstractSelectTestCase.this);
+ ((ItemClickNotifier) c)
+ .addListener(AbstractSelectTestCase.this);
} else {
- ((ItemClickSource) c)
+ ((ItemClickNotifier) c)
.removeListener(AbstractSelectTestCase.this);
}
diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java index 1def3c3154..cc30d2bbc0 100644 --- a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java @@ -6,6 +6,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.NativeButton;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.Window;
@@ -19,7 +20,7 @@ public class SplitPanelExtraScrollbars extends AbstractTestCase implements @Override
public void init() {
- sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+ sp = new HorizontalSplitPanel();
sp.setSizeFull();
sp.setSplitPosition(0, Sizeable.UNITS_PIXELS);
diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java index 4a9020e2bf..3d944f7af2 100644 --- a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java @@ -2,6 +2,7 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.terminal.Sizeable; import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -18,8 +19,7 @@ public class SplitPanelInModalWindow extends TestBase { modalWindow.setModal(true); // This line causes the problem getMainWindow().addWindow(modalWindow); - SplitPanel splitPanel = new SplitPanel( - SplitPanel.ORIENTATION_HORIZONTAL); + SplitPanel splitPanel = new HorizontalSplitPanel(); splitPanel.setSplitPosition(20); vl.addComponent(splitPanel); } diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.html b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.html new file mode 100644 index 0000000000..6bdc9dd5e7 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.html @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.splitpanel.SplitPanelReversePosition?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>right100pxbottom10percent</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelSplitPanelReversePosition::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>left100pxbottom10percent</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelSplitPanelReversePosition::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>left100pxtop10percent</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentssplitpanelSplitPanelReversePosition::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>right100pxtop10percent</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java new file mode 100644 index 0000000000..1d96ecf371 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java @@ -0,0 +1,97 @@ +package com.vaadin.tests.components.splitpanel; + +import com.vaadin.terminal.Sizeable; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.SplitPanel.SplitterClickEvent; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalSplitPanel; + +public class SplitPanelReversePosition extends TestBase { + + private boolean hsplitReversed = true; + private boolean vsplitReversed = true; + + @Override + protected void setup() { + getLayout().setSizeFull(); + getLayout().setSpacing(true); + + final HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); + hsplit.setSizeFull(); + hsplit.setImmediate(true); + hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, hsplitReversed); + hsplit.addListener(new HorizontalSplitPanel.SplitterClickListener() { + public void splitterClick(SplitterClickEvent event) { + getMainWindow().showNotification("Horizontal Splitter Clicked"); + } + }); + + TextField field = new TextField(""); + field.setSizeFull(); + hsplit.addComponent(field); + + final VerticalSplitPanel vsplit = new VerticalSplitPanel(); + vsplit.setSizeFull(); + vsplit.setImmediate(true); + vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, vsplitReversed); + vsplit.addListener(new VerticalSplitPanel.SplitterClickListener() { + public void splitterClick(SplitterClickEvent event) { + getMainWindow().showNotification("Vertical Splitter Clicked"); + } + }); + hsplit.addComponent(vsplit); + + addComponent(hsplit); + + field = new TextField(""); + field.setSizeFull(); + vsplit.addComponent(field); + + field = new TextField(""); + field.setSizeFull(); + vsplit.addComponent(field); + + HorizontalLayout buttons = new HorizontalLayout(); + buttons.setSpacing(true); + + buttons.addComponent(new Button("Swap horizontal positioning", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + hsplitReversed = !hsplitReversed; + hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, + hsplitReversed); + + } + })); + + buttons.addComponent(new Button("Swap vertical positioning", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + vsplitReversed = !vsplitReversed; + vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, + vsplitReversed); + } + })); + + addComponent(buttons); + + } + + @Override + protected String getDescription() { + return "The horizontal split panel should be splitted " + + "100px from the right and the vertical split panel should " + + "be splitted 10% from the bottom"; + + } + + @Override + protected Integer getTicketNumber() { + return 1588; + } + +} diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java index ae239cedc1..1c0a497cf0 100644 --- a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelSplitterWidth.java @@ -3,8 +3,10 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Panel; import com.vaadin.ui.SplitPanel; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window.Notification; public class SplitPanelSplitterWidth extends TestBase { @@ -21,8 +23,7 @@ public class SplitPanelSplitterWidth extends TestBase { @Override protected void setup() { - final SplitPanel split = new SplitPanel( - SplitPanel.ORIENTATION_HORIZONTAL); + final SplitPanel split = new HorizontalSplitPanel(); split.setWidth("200px"); split.setHeight("200px"); split.setLocked(true); @@ -33,7 +34,7 @@ public class SplitPanelSplitterWidth extends TestBase { p.setSizeFull(); split.addComponent(p); - final SplitPanel split2 = new SplitPanel(); + final SplitPanel split2 = new VerticalSplitPanel(); split2.setWidth("200px"); split2.setHeight("200px"); split2.setLocked(true); diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java index b49131b94f..dfbdac05f9 100644 --- a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java @@ -3,6 +3,7 @@ package com.vaadin.tests.components.splitpanel; import com.vaadin.terminal.Sizeable;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.NativeButton;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.TextField;
@@ -17,8 +18,7 @@ public class SplitPanelWidthOnResize extends AbstractTestCase { layout.setSizeFull();
Window w = new Window("", layout);
setMainWindow(w);
- SplitPanel splitPanel = new SplitPanel(
- SplitPanel.ORIENTATION_HORIZONTAL);
+ SplitPanel splitPanel = new HorizontalSplitPanel();
Button button = new NativeButton("A huge button");
button.setSizeFull();
TextField textField = new TextField("A small textfield");
diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java index f5e5435d45..303b2b2324 100644 --- a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java +++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java @@ -4,12 +4,13 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; import com.vaadin.ui.RichTextArea; import com.vaadin.ui.SplitPanel; +import com.vaadin.ui.VerticalSplitPanel; public class SplitPanelWithRichTextArea extends TestBase { @Override protected void setup() { - SplitPanel sp = new SplitPanel(); + SplitPanel sp = new VerticalSplitPanel(); sp.setSizeFull(); RichTextArea rta = new RichTextArea(); rta.setSizeFull(); diff --git a/tests/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java b/tests/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java index 271b6175f3..9bf77f42bd 100644 --- a/tests/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java +++ b/tests/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java @@ -35,13 +35,8 @@ public class ColumnCollapsingAndColumnExpansion extends TestBase { }
public void handleAction(Action action, Object sender, Object target) {
- try {
- table.setColumnCollapsed("Col2",
- !table.isColumnCollapsed("Col2"));
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ table.setColumnCollapsed("Col2",
+ !table.isColumnCollapsed("Col2"));
}
});
@@ -61,12 +56,7 @@ public class ColumnCollapsingAndColumnExpansion extends TestBase { Button hide = new Button("Collapse", new ClickListener() {
public void buttonClick(ClickEvent event) {
- try {
- table.setColumnCollapsed(tf.getValue(), true);
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ table.setColumnCollapsed(tf.getValue(), true);
}
});
@@ -74,12 +64,7 @@ public class ColumnCollapsingAndColumnExpansion extends TestBase { Button show = new Button("Show", new ClickListener() {
public void buttonClick(ClickEvent event) {
- try {
- table.setColumnCollapsed(tf.getValue(), false);
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ table.setColumnCollapsed(tf.getValue(), false);
}
});
diff --git a/tests/src/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java b/tests/src/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java index 58aa86eb31..d4fc313927 100644 --- a/tests/src/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java +++ b/tests/src/com/vaadin/tests/components/table/DisabledTableShouldNotSendPageLengthUpdates.java @@ -3,6 +3,7 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Table; @@ -13,7 +14,7 @@ public class DisabledTableShouldNotSendPageLengthUpdates extends TestBase { @Override protected void setup() { - SplitPanel split = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); + SplitPanel split = new HorizontalSplitPanel(); table.addContainerProperty("name", Integer.class, 0); Button button = new Button("Add items", new Button.ClickListener() { public void buttonClick(ClickEvent event) { diff --git a/tests/src/com/vaadin/tests/components/table/ItemClickEvents.java b/tests/src/com/vaadin/tests/components/table/ItemClickEvents.java index f8da70c55b..47f420407b 100644 --- a/tests/src/com/vaadin/tests/components/table/ItemClickEvents.java +++ b/tests/src/com/vaadin/tests/components/table/ItemClickEvents.java @@ -121,13 +121,16 @@ public class ItemClickEvents extends TestBase { private static HorizontalLayout createHorizontalLayout(Component c) { HorizontalLayout layout = new HorizontalLayout(); - Button b = new Button("immediate", new MethodProperty(c, "immediate")); + Button b = new Button("immediate", new MethodProperty<Boolean>(c, + "immediate")); layout.addComponent(b); - b = new Button("selectable", new MethodProperty(c, "selectable")); + b = new Button("selectable", new MethodProperty<Boolean>(c, + "selectable")); layout.addComponent(b); - b = new Button("nullsel", new MethodProperty(c, "nullSelectionAllowed")); + b = new Button("nullsel", new MethodProperty<Boolean>(c, + "nullSelectionAllowed")); layout.addComponent(b); - b = new Button("multi", new MethodProperty(c, "multiSelect")); + b = new Button("multi", new MethodProperty<Boolean>(c, "multiSelect")); layout.addComponent(b); return layout; } diff --git a/tests/src/com/vaadin/tests/components/table/KeyControl.java b/tests/src/com/vaadin/tests/components/table/KeyControl.java index 94c6375c30..e662db338c 100644 --- a/tests/src/com/vaadin/tests/components/table/KeyControl.java +++ b/tests/src/com/vaadin/tests/components/table/KeyControl.java @@ -42,6 +42,7 @@ public class KeyControl extends TestBase { table1.addListener(new Table.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { + @SuppressWarnings("unchecked") Set<String> value = (Set<String>) table1.getValue(); selected1.setValue(value.toString() + " TOTAL: " + value.size()); } @@ -86,6 +87,7 @@ public class KeyControl extends TestBase { table3.addListener(new Table.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { + @SuppressWarnings("unchecked") Set<String> value = (Set<String>) table3.getValue(); selected3.setValue(value.size() == 0 ? "No selected items" : value + ": Total " + value.size() + " items"); diff --git a/tests/src/com/vaadin/tests/components/table/KeyboardNavigationWithChangingContent.java b/tests/src/com/vaadin/tests/components/table/KeyboardNavigationWithChangingContent.java index da68a832c3..44a2dcd9a9 100644 --- a/tests/src/com/vaadin/tests/components/table/KeyboardNavigationWithChangingContent.java +++ b/tests/src/com/vaadin/tests/components/table/KeyboardNavigationWithChangingContent.java @@ -18,6 +18,7 @@ public class KeyboardNavigationWithChangingContent extends TestBase { ValueHolder<String> v1 = new ValueHolder<String>("test1"); ValueHolder<String> v2 = new ValueHolder<String>("test2"); ValueHolder<String> v3 = new ValueHolder<String>("test3"); + @SuppressWarnings("unchecked") final BeanItemContainer<ValueHolder<String>> bic = new BeanItemContainer<ValueHolder<String>>( Arrays.asList(v1, v2, v3)); final Table t = new Table(null, bic); diff --git a/tests/src/com/vaadin/tests/components/table/PropertyValueChange.java b/tests/src/com/vaadin/tests/components/table/PropertyValueChange.java index 4a676cc3b4..5975137976 100644 --- a/tests/src/com/vaadin/tests/components/table/PropertyValueChange.java +++ b/tests/src/com/vaadin/tests/components/table/PropertyValueChange.java @@ -7,15 +7,15 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.IndexedContainer; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractSelect.NewItemHandler; -import com.vaadin.ui.BaseFieldFactory; import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Component; +import com.vaadin.ui.DefaultFieldFactory; import com.vaadin.ui.Field; -import com.vaadin.ui.FieldFactory; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.Table.ColumnGenerator; +import com.vaadin.ui.TableFieldFactory; public class PropertyValueChange extends TestBase { @@ -65,7 +65,7 @@ public class PropertyValueChange extends TestBase { } }; - FieldFactory ff = new MyFieldFactory(); + TableFieldFactory ff = new MyFieldFactory(); @Override public void setup() { @@ -86,7 +86,7 @@ public class PropertyValueChange extends TestBase { t1.setPageLength(0); t1.setContainerDataSource(container); t1.addGeneratedColumn("integer x 3", multiplier); - t1.setFieldFactory(ff); + t1.setTableFieldFactory(ff); t1.setEditable(true); t1.setDebugId("editortable"); @@ -95,7 +95,7 @@ public class PropertyValueChange extends TestBase { t2.setDescription("This table is in editable mode." + " Updates to common datasource should not affect redraw for this " + "table. Only the components inside table should get updated."); - t2.setFieldFactory(ff); + t2.setTableFieldFactory(ff); t2.setEditable(true); t2.setEnabled(false); t2.setContainerDataSource(container); @@ -119,7 +119,7 @@ public class PropertyValueChange extends TestBase { } } -class MyFieldFactory extends BaseFieldFactory { +class MyFieldFactory extends DefaultFieldFactory { IndexedContainer texts = new IndexedContainer(); diff --git a/tests/src/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java b/tests/src/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java index 384bcecde6..38510f1c6c 100644 --- a/tests/src/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java +++ b/tests/src/com/vaadin/tests/components/table/SafariRenderingBugWhiteSpace.java @@ -3,6 +3,7 @@ package com.vaadin.tests.components.table; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Panel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Table; @@ -12,7 +13,7 @@ public class SafariRenderingBugWhiteSpace extends TestBase { @Override protected void setup() { - final SplitPanel split = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); + final SplitPanel split = new HorizontalSplitPanel(); final Table table = new Table(); table.addContainerProperty("name", String.class, ""); diff --git a/tests/src/com/vaadin/tests/components/table/TablePageLengthUpdate.java b/tests/src/com/vaadin/tests/components/table/TablePageLengthUpdate.java index fec830fd66..71dc987e56 100644 --- a/tests/src/com/vaadin/tests/components/table/TablePageLengthUpdate.java +++ b/tests/src/com/vaadin/tests/components/table/TablePageLengthUpdate.java @@ -55,7 +55,7 @@ public class TablePageLengthUpdate extends TestBase { addComponent(updateButton); TextField tableHeight = new TextField("Table height", - new MethodProperty(this, "tableHeight")); + new MethodProperty<String>(this, "tableHeight")); tableHeight.setImmediate(true); addComponent(tableHeight); } diff --git a/tests/src/com/vaadin/tests/components/table/TableRowHeight2.java b/tests/src/com/vaadin/tests/components/table/TableRowHeight2.java index 7dcc6f17d2..f79b834fb1 100644 --- a/tests/src/com/vaadin/tests/components/table/TableRowHeight2.java +++ b/tests/src/com/vaadin/tests/components/table/TableRowHeight2.java @@ -5,6 +5,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.themes.BaseTheme; public class TableRowHeight2 extends TestBase { @@ -44,7 +45,7 @@ public class TableRowHeight2 extends TestBase { Button b = new Button(); b.setWidth("100%"); - b.setStyleName(Button.STYLE_LINK); + b.setStyleName(BaseTheme.BUTTON_LINK); b.addStyleName("nowraplink"); b.setCaption("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper, elit quis elementum iaculis, dui est rutrum risus, at cursus sem leo eget arcu. Proin vel eros ut tortor luctus pretium. Nulla facilisi. Donec in dui. Proin ac diam vitae massa tempus faucibus. Fusce eu risus. Nunc ac risus. Cras libero."); diff --git a/tests/src/com/vaadin/tests/components/table/TableRowHeight3.java b/tests/src/com/vaadin/tests/components/table/TableRowHeight3.java index d7af764788..c31b87f9da 100644 --- a/tests/src/com/vaadin/tests/components/table/TableRowHeight3.java +++ b/tests/src/com/vaadin/tests/components/table/TableRowHeight3.java @@ -5,6 +5,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.themes.BaseTheme; public class TableRowHeight3 extends TestBase { @@ -36,7 +37,7 @@ public class TableRowHeight3 extends TestBase { Button b = new Button(); b.setWidth("100%"); - b.setStyleName(Button.STYLE_LINK); + b.setStyleName(BaseTheme.BUTTON_LINK); b.addStyleName("nowraplink"); if (i < 2) { b.setCaption("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper, elit quis elementum iaculis, dui est rutrum risus, at cursus sem leo eget arcu. Proin vel eros ut tortor luctus pretium. Nulla facilisi. Donec in dui. Proin ac diam vitae massa tempus faucibus. Fusce eu risus. Nunc ac risus. Cras libero."); diff --git a/tests/src/com/vaadin/tests/components/table/TableUndefinedSize.html b/tests/src/com/vaadin/tests/components/table/TableUndefinedSize.html new file mode 100644 index 0000000000..fbb6f4c7f9 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableUndefinedSize.html @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.TableUndefinedSize?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>UndefinedSizeTable</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>exact:1: Size 200x200 pixels</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>FixedSize200x200Table</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>exact:2: Size 600x200 pixels<br />1: Size 200x200 pixels</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>FixedSize600x200Table</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>exact:3: Size undefined<br />2: Size 600x200 pixels<br />1: Size 200x200 pixels</td> + <td></td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VNativeSelect[0]/domChild[0]</td> + <td>label=4</td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>exact:4: Page length: 4<br />3: Size undefined<br />2: Size 600x200 pixels<br />1: Size 200x200 pixels</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>PageLength4</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VNativeSelect[0]/domChild[0]</td> + <td>label=10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>PageLength10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[3]</td> + <td>1102,215</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>3,6</td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Column 2</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>Column 3</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>Column1Hidden</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTableUndefinedSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>3,3</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>AllColumnsShown</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/table/TableUndefinedSize.java b/tests/src/com/vaadin/tests/components/table/TableUndefinedSize.java new file mode 100644 index 0000000000..2b3204953b --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableUndefinedSize.java @@ -0,0 +1,165 @@ +package com.vaadin.tests.components.table; + +import java.util.Arrays; + +import com.vaadin.data.Container; +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Table; + +public class TableUndefinedSize extends TestBase { + + private ObjectProperty<String> output = new ObjectProperty<String>(""); + + private int counter = 1; + + @Override + protected void setup() { + + HorizontalLayout controls = new HorizontalLayout(); + controls.setSpacing(true); + addComponent(controls); + + HorizontalLayout visibilities = new HorizontalLayout(); + visibilities.setSpacing(true); + addComponent(visibilities); + + final Table tbl = new Table("", createDataSource()); + tbl.setImmediate(true); + tbl.setColumnCollapsingAllowed(true); + + Label output = new Label(this.output); + output.setWidth("400px"); + output.setHeight("100px"); + output.setContentMode(Label.CONTENT_XHTML); + + controls.addComponent(new Button("Fixed size (200x200)", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tbl.setWidth("200px"); + tbl.setHeight("200px"); + print("Size 200x200 pixels"); + } + })); + + controls.addComponent(new Button("Fixed size (600x200)", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tbl.setWidth("600px"); + tbl.setHeight("200px"); + print("Size 600x200 pixels"); + } + })); + + controls.addComponent(new Button("Undefined size", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tbl.setSizeUndefined(); + print("Size undefined"); + } + })); + + NativeSelect pageLength = new NativeSelect("PageLength", Arrays.asList( + 0, 1, 2, 4, 8, 10)); + pageLength.setImmediate(true); + pageLength.setNullSelectionAllowed(false); + pageLength.addListener(new Property.ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + int pageLength = Integer.valueOf(event.getProperty().getValue() + .toString()); + tbl.setPageLength(pageLength); + print("Page length: " + pageLength); + } + }); + controls.addComponent(pageLength); + + CheckBox cb = new CheckBox("Column 1", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tbl.setColumnCollapsed("Column 1", !event.getButton() + .booleanValue()); + if (event.getButton().booleanValue()) { + print("Column 1 visible"); + } else { + print("Column 1 hidden"); + } + } + }); + cb.setImmediate(true); + cb.setValue(true); + visibilities.addComponent(cb); + + cb = new CheckBox("Column 2", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tbl.setColumnCollapsed("Column 2", !event.getButton() + .booleanValue()); + + if (event.getButton().booleanValue()) { + print("Column 2 visible"); + } else { + print("Column 2 hidden"); + } + } + }); + cb.setImmediate(true); + cb.setValue(true); + visibilities.addComponent(cb); + + cb = new CheckBox("Column 3", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tbl.setColumnCollapsed("Column 3", !event.getButton() + .booleanValue()); + + if (event.getButton().booleanValue()) { + print("Column 3 visible"); + } else { + print("Column 3 hidden"); + } + } + }); + cb.setImmediate(true); + cb.setValue(true); + visibilities.addComponent(cb); + + addComponent(output); + addComponent(tbl); + + } + + protected void print(String message) { + output.setValue(counter + ": " + message + "<br/>" + output.getValue()); + counter++; + } + + protected Container createDataSource() { + IndexedContainer c = new IndexedContainer(); + c.addContainerProperty("Column 1", String.class, "Column 1"); + c.addContainerProperty("Column 2", String.class, "Column 2"); + c.addContainerProperty("Column 3", String.class, "Column 3"); + + for (int i = 0; i < 50; i++) { + c.addItem(); + } + + return c; + } + + @Override + protected String getDescription() { + return ""; + } + + @Override + protected Integer getTicketNumber() { + return 5789; + } + +} diff --git a/tests/src/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java b/tests/src/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java index 90add959f1..9c3b2de3e0 100644 --- a/tests/src/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java +++ b/tests/src/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java @@ -28,7 +28,7 @@ public class TestCurrentPageFirstItem extends Application implements main.setSizeFull();
// setTheme("testtheme");
VerticalLayout baseLayout = new VerticalLayout();
- main.setLayout(baseLayout);
+ main.setContent(baseLayout);
table = new Table();
container.addContainerProperty("row", String.class, "");
diff --git a/tests/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java b/tests/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java index a2c96d291a..13ca9f8cf3 100644 --- a/tests/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java +++ b/tests/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java @@ -57,7 +57,8 @@ public class TextFieldRelativeWidth extends TestBase { public void valueChange(
com.vaadin.data.Property.ValueChangeEvent event) {
- IndexedContainer idc = (IndexedContainer) getContainerDataSource();
+ // IndexedContainer idc = (IndexedContainer)
+ // getContainerDataSource();
}
diff --git a/tests/src/com/vaadin/tests/components/tabsheet/RemoveTabs.java b/tests/src/com/vaadin/tests/components/tabsheet/RemoveTabs.java index b0d462f4d8..8602a9a3b4 100644 --- a/tests/src/com/vaadin/tests/components/tabsheet/RemoveTabs.java +++ b/tests/src/com/vaadin/tests/components/tabsheet/RemoveTabs.java @@ -114,18 +114,16 @@ public class RemoveTabs extends TestBase { tabsheet.removeComponent(tabsheet.getComponentIterator().next());
}
- @SuppressWarnings("unchecked")
private void closeLastTab() {
- Iterator i = tabsheet.getComponentIterator();
+ Iterator<Component> i = tabsheet.getComponentIterator();
Component last = null;
while (i.hasNext()) {
- last = (Component) i.next();
+ last = i.next();
}
tabsheet.removeComponent(last);
}
- @SuppressWarnings("unchecked")
private void reorder() {
AbstractComponentContainer container = tabsheet;
diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java index 3d624df709..8449dd42bf 100644 --- a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java +++ b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java @@ -36,15 +36,16 @@ public class TabSheetCaptions extends TestBase { panel1 = new Panel("Panel initial caption (should also be tab caption)");
panel1.setSizeFull();
- panel1.getLayout().setSizeFull();
+ panel1.getContent().setSizeFull();
panel1.addComponent(new Label("This is a panel"));
tabSheet.addTab(panel1);
Button button = new Button("Update tab caption");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- tabSheet.setTabCaption(panel1, "This is a new tab caption "
- + dateFormatter.format(date));
+ tabSheet.getTab(panel1).setCaption(
+ "This is a new tab caption "
+ + dateFormatter.format(date));
}
});
diff --git a/tests/src/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java b/tests/src/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java index 08478c4930..b6e00a1e59 100644 --- a/tests/src/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java +++ b/tests/src/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java @@ -2,6 +2,7 @@ package com.vaadin.tests.components.tabsheet; import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
public class VerticalScrollbarPosition extends TestBase {
@@ -21,7 +22,7 @@ public class VerticalScrollbarPosition extends TestBase { TabSheet tabsheet = new TabSheet();
tabsheet.setWidth(null);
tabsheet.setHeight("200px");
- TextField tf = new TextField();
+ TextArea tf = new TextArea();
tf.setRows(2);
tf.setHeight("300px");
tf.setWidth("200px");
diff --git a/tests/src/com/vaadin/tests/components/textarea/TextAreaWordwrap.html b/tests/src/com/vaadin/tests/components/textarea/TextAreaWordwrap.html new file mode 100644 index 0000000000..780e95a358 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textarea/TextAreaWordwrap.html @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://artur-laptop.office.itmill.com:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.textarea.Wordwrap?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>wrap-nowrap</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextareaWordwrap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td>
+ <td>98,2</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextareaWordwrap::</td>
+ <td>396,331</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>wrap-wrap</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextareaWordwrap::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td>
+ <td>98,2</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextareaWordwrap::/VVerticalLayout[0]/domChild[0]/domChild[0]</td>
+ <td>387,96</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>wrap-nowrap</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/textarea/Wordwrap.java b/tests/src/com/vaadin/tests/components/textarea/Wordwrap.java new file mode 100644 index 0000000000..9a443ea757 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textarea/Wordwrap.java @@ -0,0 +1,59 @@ +package com.vaadin.tests.components.textarea;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.LoremIpsum;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextArea;
+
+public class Wordwrap extends TestBase {
+
+ @Override
+ public void setup() {
+ HorizontalLayout layout = new HorizontalLayout();
+
+ TextArea area1 = new TextArea("Wrapping");
+ area1.setWordwrap(true); // The default
+ area1.setValue(LoremIpsum.get(50) + "\n" + "Another row");
+
+ final TextArea area2 = new TextArea("Nonwrapping");
+ area2.setWordwrap(false);
+ area2.setValue(LoremIpsum.get(50) + "\n" + "Another row");
+
+ layout.addComponent(area1);
+ layout.addComponent(area2);
+ layout.setSpacing(true);
+
+ addComponent(layout);
+
+ CheckBox onoff = new CheckBox("Wrap state for the right field");
+ onoff.setValue(false);
+ onoff.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ boolean wrap = (Boolean) event.getProperty().getValue();
+ area2.setWordwrap(wrap);
+ if (wrap) {
+ area2.setCaption("Wrapping");
+ } else {
+ area2.setCaption("Nonwrapping");
+ }
+
+ }
+ });
+ onoff.setImmediate(true);
+
+ addComponent(onoff);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6003;
+ }
+}
diff --git a/tests/src/com/vaadin/tests/components/textfield/TextChangeEvents.java b/tests/src/com/vaadin/tests/components/textfield/TextChangeEvents.java new file mode 100644 index 0000000000..4317000812 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textfield/TextChangeEvents.java @@ -0,0 +1,138 @@ +package com.vaadin.tests.components.textfield; + +import com.vaadin.event.FieldEvents.TextChangeEvent; +import com.vaadin.event.FieldEvents.TextChangeListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Log; +import com.vaadin.tests.util.TestUtils; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.TextField.TextChangeEventMode; + +public class TextChangeEvents extends TestBase { + Log l = new Log(10); + + @Override + protected void setup() { + + TextField tf = new TextField("Default"); + + TextChangeListener inputEventListener = new TextChangeListener() { + + public void textChange(TextChangeEvent event) { + l.log("Text change event for " + + event.getComponent().getCaption() + + ", text content currently:'" + + event.getText() + "' Cursor at index:" + + event.getCursorPosition()); + } + }; + + tf.addListener(inputEventListener); + + getLayout().addComponent(tf); + + TextField eager = new TextField("Eager"); + eager.addListener(inputEventListener); + eager.setTextChangeEventMode(TextChangeEventMode.EAGER); + getLayout().addComponent(eager); + + TextField to = new TextField("Timeout 3s"); + to.addListener(inputEventListener); + to.setTextChangeEventMode(TextChangeEventMode.TIMEOUT); + to.setTextChangeTimeout(3000); + getLayout().addComponent(to); + + TextArea ta = new TextArea("Default text area"); + ta.addListener(inputEventListener); + getLayout().addComponent(ta); + + VaadinDeveloeprNameField vd = new VaadinDeveloeprNameField(); + vd.addListener(inputEventListener); + getLayout().addComponent(vd); + + getLayout().addComponent(l); + } + + @Override + protected String getDescription() { + return "Simple TextChangeEvent test cases."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + /** + * "Autosuggest" + * + * Known issue is timing if suggestion comes while typing more content. IMO + * we will not support this kind of features in default TextField, but + * hopefully make it easily extendable to perfect suggest feature. MT + * 2010-10 + * + */ + private class VaadinDeveloeprNameField extends TextField implements + TextChangeListener { + private String[] names = new String[] { "Matti Tahvonen", + "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita", + "Marko Grönroos", "Artur Signell" }; + + public VaadinDeveloeprNameField() { + setCaption("Start typing 'old' Vaadin developers."); + addListener((TextChangeListener) this); + setStyleName("nomatch"); + } + + @Override + public void attach() { + super.attach(); + TestUtils.injectCSS(getWindow(), ".match { background:green ;} " + + ".nomatch {background:red;}"); + } + + public void textChange(TextChangeEvent event) { + boolean atTheEndOfText = event.getText().length() == getCursorPosition(); + String match = findMatch(event.getText()); + if (match != null) { + setStyleName("match"); + String curText = event.getText(); + int matchlenght = curText.length(); + // autocomplete if garret is at the end of the text + if (atTheEndOfText) { + suggest(match, matchlenght); + } else { + keepCurrentText(event.getText()); + } + } else { + keepCurrentText(event.getText()); + setStyleName("nomatch"); + } + } + + private void keepCurrentText(String curText) { + // keep the current text in the field despite the repaint due to + // classname change + setValue(curText); + setCursorPosition(getCursorPosition()); + } + + private void suggest(String match, int matchlenght) { + setValue(match); + setSelectionRange(matchlenght, match.length() - matchlenght); + } + + private String findMatch(String currentTextContent) { + if (currentTextContent.length() > 0) { + for (int i = 0; i < names.length; i++) { + if (names[i].startsWith(currentTextContent)) { + return names[i]; + } + } + } + return null; + } + } + +}
\ No newline at end of file diff --git a/tests/src/com/vaadin/tests/components/textfield/TextChangeEvents2.java b/tests/src/com/vaadin/tests/components/textfield/TextChangeEvents2.java new file mode 100644 index 0000000000..523d8f4057 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textfield/TextChangeEvents2.java @@ -0,0 +1,175 @@ +package com.vaadin.tests.components.textfield; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.event.FieldEvents.TextChangeEvent; +import com.vaadin.event.FieldEvents.TextChangeListener; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.TextField.TextChangeEventMode; + +public class TextChangeEvents2 extends TestBase { + @Override + protected void setup() { + + { + final TextField tf = new TextField("Debug"); + getLayout().addComponent(tf); + + tf.addListener(new TextChangeListener() { + public void textChange(TextChangeEvent event) { + System.err.println(tf.getCaption() + " textChange"); + } + }); + + tf.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + System.err.println(tf.getCaption() + " valueChange"); + } + }); + + tf.addListener(new BlurListener() { + + public void blur(BlurEvent event) { + System.err.println(tf.getCaption() + " blur"); + } + }); + + tf.addListener(new FocusListener() { + public void focus(FocusEvent event) { + System.err.println(tf.getCaption() + " focus"); + } + }); + + } + + { + final TextField tf = new TextField("Label"); + getLayout().addComponent(tf); + final Label l = new Label(); + getLayout().addComponent(l); + tf.addListener(new TextChangeListener() { + public void textChange(TextChangeEvent event) { + l.setValue(event.getText()); + } + }); + + tf.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + System.err.println(tf.getCaption() + " valueChange"); + } + }); + + } + + { + final TextField tf = new TextField("Slow label"); + tf.setTextChangeTimeout(2000); + tf.setImmediate(true); + getLayout().addComponent(tf); + final Label l = new Label(); + getLayout().addComponent(l); + tf.addListener(new TextChangeListener() { + + public void textChange(TextChangeEvent event) { + l.setValue(event.getText()); + } + }); + + tf.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + System.err.println(tf.getCaption() + " valueChange"); + } + }); + + } + + { + final TextField tf = new TextField("Uppercase"); + tf.setTextChangeTimeout(1); + getLayout().addComponent(tf); + final Label l = new Label(); + getLayout().addComponent(l); + tf.addListener(new TextChangeListener() { + + public void textChange(TextChangeEvent event) { + tf.setValue(event.getText().toUpperCase()); + } + }); + + tf.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + System.err.println(tf.getCaption() + " valueChange"); + } + }); + + } + + { + final TextField[] tfs = new TextField[] { new TextField(), + new TextField(), new TextField(), new TextField() }; + HorizontalLayout hl = new HorizontalLayout(); + hl.setCaption("Blää"); + getLayout().addComponent(hl); + for (TextField tf : tfs) { + tf.setColumns(4); + tf.setTextChangeEventMode(TextChangeEventMode.EAGER); + hl.addComponent(tf); + + tf.addListener(new TextChangeListener() { + + public void textChange(TextChangeEvent event) { + String txt = event.getText(); + int len = txt.length(); + if (len >= 4) { + int idx = 0; + while (tfs[idx] != event.getComponent()) { + idx++; + } + tfs[idx].setValue(""); + tfs[idx].setValue(txt.substring(0, 4)); + if (idx < tfs.length - 1) { + TextField next = tfs[idx + 1]; + next.focus(); + if (len > 4) { + next.setValue(txt.substring(4, len > 8 ? 8 + : len)); + } else { + next.selectAll(); + } + } + } + } + }); + tf.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + TextField tf = (TextField) event.getProperty(); + String val = (String) tf.getValue(); + if (val != null && val.length() > 4) { + tf.setValue(val.substring(0, 4)); + } + } + }); + } + + } + } + + @Override + protected String getDescription() { + return "Another set of simple use case/tests for TextChangeEvents"; + } + + @Override + protected Integer getTicketNumber() { + return 2387; + } + +}
\ No newline at end of file diff --git a/tests/src/com/vaadin/tests/components/textfield/TextFieldsGeneric.java b/tests/src/com/vaadin/tests/components/textfield/TextFieldsGeneric.java new file mode 100644 index 0000000000..8116c23b5e --- /dev/null +++ b/tests/src/com/vaadin/tests/components/textfield/TextFieldsGeneric.java @@ -0,0 +1,230 @@ +package com.vaadin.tests.components.textfield;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.TextField.TextChangeEventMode;
+
+public class TextFieldsGeneric extends AbstractTextFieldTest<TextField>
+ implements TextChangeListener {
+
+ private Command<TextField, Boolean> secretCommand = new Command<TextField, Boolean>() {
+ public void execute(TextField c, Boolean value, Object data) {
+ c.setSecret(value);
+ }
+ };
+
+ private Command<TextField, Boolean> wordwrapCommand = new Command<TextField, Boolean>() {
+ public void execute(TextField c, Boolean value, Object data) {
+ c.setWordwrap(value);
+ }
+ };
+
+ private Command<TextField, Integer> rowsCommand = new Command<TextField, Integer>() {
+ public void execute(TextField c, Integer value, Object data) {
+ c.setRows(value);
+ }
+ };
+
+ private Command<TextField, Integer> colsCommand = new Command<TextField, Integer>() {
+ public void execute(TextField c, Integer value, Object data) {
+ c.setColumns(value);
+ }
+ };
+
+ private Command<TextField, String> inputPromptCommand = new Command<TextField, String>() {
+ public void execute(TextField c, String value, Object data) {
+ c.setInputPrompt(value);
+ }
+ };
+
+ private Command<TextField, Boolean> textChangeListenerCommand = new Command<TextField, Boolean>() {
+ public void execute(TextField c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((TextChangeListener) TextFieldsGeneric.this);
+ } else {
+ c.removeListener((TextChangeListener) TextFieldsGeneric.this);
+ }
+ }
+ };
+
+ private Command<TextField, TextChangeEventMode> textChangeEventModeCommand = new Command<TextField, TextChangeEventMode>() {
+ public void execute(TextField c, TextChangeEventMode value, Object data) {
+ c.setTextChangeEventMode(value);
+ }
+ };
+
+ private Command<TextField, Integer> textChangeTimeoutCommand = new Command<TextField, Integer>() {
+ public void execute(TextField c, Integer value, Object data) {
+ c.setTextChangeTimeout(value);
+ }
+ };
+
+ private Command<TextField, Range> selectionRangeCommand = new Command<TextField, Range>() {
+ public void execute(TextField c, Range value, Object data) {
+ c.setSelectionRange(value.getStart(),
+ value.getEnd() - value.getStart());
+
+ }
+ };
+ private Command<TextField, Object> selectAllCommand = new Command<TextField, Object>() {
+ public void execute(TextField c, Object value, Object data) {
+ c.selectAll();
+ }
+ };
+
+ private Command<TextField, Integer> setCursorPositionCommand = new Command<TextField, Integer>() {
+
+ public void execute(TextField c, Integer value, Object data) {
+ c.setCursorPosition(value);
+ }
+ };
+
+ @Override
+ protected Class<TextField> getTestClass() {
+ return TextField.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createSecretAction(CATEGORY_STATE);
+ createWordwrapAction(CATEGORY_STATE);
+ createInputPromptAction(CATEGORY_FEATURES);
+ createRowsAction(CATEGORY_STATE);
+ createColsAction(CATEGORY_STATE);
+
+ createTextChangeListener(CATEGORY_LISTENERS);
+ createTextChangeEventModeAction(CATEGORY_FEATURES);
+ createTextChangeEventTimeoutAction(CATEGORY_FEATURES);
+
+ createSetTextValueAction(CATEGORY_ACTIONS);
+ createCursorPositionAction(CATEGORY_ACTIONS);
+ createSelectionRangeAction(CATEGORY_ACTIONS);
+ }
+
+ public class Range {
+ private int start;
+ private int end;
+
+ public Range(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ @Override
+ public String toString() {
+ return start + "-" + end;
+ }
+ }
+
+ private void createSelectionRangeAction(String category) {
+ List<Range> options = new ArrayList<Range>();
+ options.add(new Range(0, 10));
+ options.add(new Range(0, 1));
+ options.add(new Range(0, 2));
+ options.add(new Range(1, 2));
+ options.add(new Range(2, 5));
+ options.add(new Range(5, 10));
+
+ createCategory("Select range", category);
+
+ createClickAction("All", "Select range", selectAllCommand, null);
+ for (Range range : options) {
+ createClickAction(range.toString(), "Select range",
+ selectionRangeCommand, range);
+ }
+
+ }
+
+ private void createCursorPositionAction(String category) {
+ String subCategory = "Set cursor position";
+ createCategory(subCategory, category);
+ for (int i = 0; i < 20; i++) {
+ createClickAction(String.valueOf(i), subCategory,
+ setCursorPositionCommand, Integer.valueOf(i));
+ }
+
+ }
+
+ private void createTextChangeEventTimeoutAction(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ options.put("100ms", 100);
+ options.put("500ms", 500);
+ options.put("1s", 1000);
+ options.put("2s", 2000);
+ options.put("5s", 5000);
+
+ createSelectAction("TextChange timeout", category, options, "0",
+ textChangeTimeoutCommand);
+ }
+
+ private void createTextChangeEventModeAction(String category) {
+ LinkedHashMap<String, TextChangeEventMode> options = new LinkedHashMap<String, TextField.TextChangeEventMode>();
+ for (TextChangeEventMode m : TextChangeEventMode.values()) {
+ options.put(m.toString(), m);
+ }
+
+ createSelectAction("TextChange event mode", category, options,
+ TextChangeEventMode.EAGER.toString(),
+ textChangeEventModeCommand);
+
+ }
+
+ private void createTextChangeListener(String category) {
+ createBooleanAction("Text change listener", category, false,
+ textChangeListenerCommand);
+
+ }
+
+ private void createRowsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Rows", category, options, "0", rowsCommand);
+ }
+
+ private void createColsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Columns", category, options, "0", colsCommand);
+ }
+
+ private void createSecretAction(String category) {
+ createBooleanAction("Secret", category, false, secretCommand);
+ }
+
+ private void createWordwrapAction(String category) {
+ createBooleanAction("Wordwrap", category, false, wordwrapCommand);
+ }
+
+ private void createInputPromptAction(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("Enter a value", "Enter a value");
+ options.put("- Click here -", "- Click here -");
+ createSelectAction("Input prompt", category, options, "-",
+ inputPromptCommand);
+
+ }
+
+ public void textChange(TextChangeEvent event) {
+ TextField tf = (TextField) event.getComponent();
+ log("TextChangeEvent: text='" + event.getText() + "', cursor position="
+ + event.getCursorPosition() + " (field cursor pos: "
+ + tf.getCursorPosition() + ")");
+
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java b/tests/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java index 7febfa14d5..69956e4d2c 100644 --- a/tests/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java +++ b/tests/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java @@ -32,6 +32,8 @@ public class CtrlShiftMultiselect extends TestBase { tree.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (tree.getValue() instanceof Set) { + @SuppressWarnings("unchecked") + // safe cast after instanceof check Set<Object> itemIds = (Set<Object>) tree.getValue(); if (itemIds.size() == 0) { valueLbl.setValue("No selection"); diff --git a/tests/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java b/tests/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java index b812e4f629..e23213fafc 100644 --- a/tests/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java +++ b/tests/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java @@ -32,6 +32,8 @@ public class ExpandCollapseTree extends TestBase { tree.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (tree.getValue() instanceof Set) { + @SuppressWarnings("unchecked") + // safe cast after instanceof check Set<Object> itemIds = (Set<Object>) tree.getValue(); if (itemIds.size() == 0) { valueLbl.setValue("No selection"); diff --git a/tests/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java b/tests/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java index c4299ec939..f2ca2a85bd 100644 --- a/tests/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java +++ b/tests/src/com/vaadin/tests/components/tree/ItemStyleGenerator.java @@ -1,8 +1,5 @@ package com.vaadin.tests.components.tree; -import java.io.IOException; -import java.io.StringBufferInputStream; - import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Component; import com.vaadin.ui.CustomLayout; @@ -29,11 +26,7 @@ public class ItemStyleGenerator extends TestBase { @Override protected void setup() { - try { - styles = new CustomLayout(new StringBufferInputStream(css)); - } catch (IOException e) { - e.printStackTrace(); - } + styles = new CustomLayout(css); addComponent(styles); Tree tree = new Tree(); diff --git a/tests/src/com/vaadin/tests/components/tree/TreeScrolling.java b/tests/src/com/vaadin/tests/components/tree/TreeScrolling.java index 4406f1c68d..38bf07ef59 100644 --- a/tests/src/com/vaadin/tests/components/tree/TreeScrolling.java +++ b/tests/src/com/vaadin/tests/components/tree/TreeScrolling.java @@ -1,6 +1,5 @@ package com.vaadin.tests.components.tree;
-import com.vaadin.data.Item;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.TextField;
@@ -22,10 +21,12 @@ public class TreeScrolling extends AbstractTestCase { Tree tree = new Tree();
for (int i = 0; i < 20; i++) {
String parentId = "Item " + i;
- Item parentItem = tree.addItem(parentId);
+ // Item parentItem =
+ tree.addItem(parentId);
for (int j = 0; j < 20; j++) {
String subId = "Item " + i + " - " + j;
- Item subItem = tree.addItem(subId);
+ // Item subItem =
+ tree.addItem(subId);
tree.setParent(subId, parentId);
}
diff --git a/tests/src/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java b/tests/src/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java index befc8ae955..d1a77d0e49 100644 --- a/tests/src/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java +++ b/tests/src/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java @@ -43,7 +43,7 @@ public class TestImmediateUploadInFormLayout extends @Override
protected List<Component> createActions() {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
public OutputStream receiveUpload(String filename, String MIMEType) {
diff --git a/tests/src/com/vaadin/tests/components/window/CenteredWindowWithUndefinedSize.java b/tests/src/com/vaadin/tests/components/window/CenteredWindowWithUndefinedSize.java index 51b6568f94..a7fcda3cf1 100644 --- a/tests/src/com/vaadin/tests/components/window/CenteredWindowWithUndefinedSize.java +++ b/tests/src/com/vaadin/tests/components/window/CenteredWindowWithUndefinedSize.java @@ -20,7 +20,7 @@ public class CenteredWindowWithUndefinedSize extends TestBase { protected void setup() { Window centered = new Window("A window"); centered.setSizeUndefined(); - centered.getLayout().setSizeFull(); + centered.getContent().setSizeFull(); centered.center(); Label l = new Label("This window should be centered"); diff --git a/tests/src/com/vaadin/tests/components/window/CloseSubWindow.html b/tests/src/com/vaadin/tests/components/window/CloseSubWindow.html new file mode 100644 index 0000000000..3701613054 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/CloseSubWindow.html @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>CloseSubWindow</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">CloseSubWindow</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.window.CloseSubWindow?restartApplication</td> + <td></td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_Sopennative</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VWindow[0]/ScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_SLog/ChildComponentContainer[0]/VLabel[0]</td> + <td>1. Window 'Sub-window' closed</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_Sopennative</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VWindow[0]/ScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_SLog/ChildComponentContainer[0]/VLabel[0]</td> + <td>2. Window 'Sub-window' closed</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>waitForPopUp</td> + <td>nativewindow</td> + <td>30000</td> +</tr> +<tr> + <td>selectWindow</td> + <td>name=nativewindow</td> + <td></td> +</tr> +<tr> + <td>close</td> + <td></td> + <td></td> +</tr> +<tr> + <td>selectWindow</td> + <td>title=com.vaadin.tests.components.window.CloseSubWindow</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_Spoll/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_SLog/ChildComponentContainer[0]/VLabel[0]</td> + <td>3. Browser window closed</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/window/CloseSubWindow.java b/tests/src/com/vaadin/tests/components/window/CloseSubWindow.java new file mode 100644 index 0000000000..9a5fff18ed --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/CloseSubWindow.java @@ -0,0 +1,129 @@ +package com.vaadin.tests.components.window;
+
+import java.net.URL;
+
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class CloseSubWindow extends TestBase {
+
+ private Window browserWindow;
+ private Log log = new Log(5);
+
+ @Override
+ protected void setup() {
+ Button openWindowButton = new Button("Open sub-window");
+ openWindowButton.setDebugId("opensub");
+ openWindowButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Window sub = createClosableSubWindow("Sub-window");
+ getMainWindow().addWindow(sub);
+ }
+ });
+
+ addComponent(log);
+ addComponent(openWindowButton);
+
+ Button openBrowserWindowButton = new Button("Open browser window");
+ openWindowButton.setDebugId("opennative");
+ openBrowserWindowButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ browserWindow = new Window("Window");
+ Button closeButton = new Button("Close this window",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ event.getButton().getWindow()
+ .executeJavaScript("window.close();");
+
+ }
+ });
+ browserWindow.addComponent(closeButton);
+
+ browserWindow.addListener(new CloseListener() {
+ public void windowClose(CloseEvent e) {
+ logBrowserWindowClosed();
+ // there is no push, so the user needs to click a button
+ // to see the notification
+
+ // Opera does not send a notification about the window
+ // having been closed
+ }
+
+ });
+
+ addWindow(browserWindow);
+ URL windowUrl = browserWindow.getURL();
+ // named for easier access by test tools
+ getMainWindow().open(new ExternalResource(windowUrl),
+ "nativewindow");
+ if (getBrowser().isOpera()) {
+ // Immediately log a close event in Opera so this test can
+ // be run for all browsers. Vaadin ticket #5687.
+ logBrowserWindowClosed();
+ }
+ }
+ });
+
+ addComponent(openBrowserWindowButton);
+
+ Button pollButton = new Button("Poll server");
+ pollButton.setDebugId("poll");
+ addComponent(pollButton);
+
+ }
+
+ private Window createClosableSubWindow(final String title) {
+ final Window window = new Window(title);
+ window.setSizeUndefined();
+ window.getContent().setSizeFull();
+ window.setClosable(true);
+
+ Button closeButton = new Button("Close");
+ closeButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ window.getParent().removeWindow(window);
+ }
+ });
+ window.addComponent(closeButton);
+
+ Button removeButton = new Button("Remove from parent");
+ removeButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ window.getParent().removeWindow(window);
+ }
+ });
+ window.addComponent(closeButton);
+
+ window.addListener(new CloseListener() {
+ public void windowClose(CloseEvent e) {
+ log.log("Window '" + title + "' closed");
+ }
+ });
+
+ return window;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Close sub-windows both from code and with the close button in the window title bar, and check for close events. Contains an ugly workaround for the Opera bug (Opera does not send close events)";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3865;
+ }
+
+ private void logBrowserWindowClosed() {
+ log.log("Browser window closed");
+
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/window/EmbeddedInSubWindow.java b/tests/src/com/vaadin/tests/components/window/EmbeddedInSubWindow.java index f2159c0780..cd990f94b7 100644 --- a/tests/src/com/vaadin/tests/components/window/EmbeddedInSubWindow.java +++ b/tests/src/com/vaadin/tests/components/window/EmbeddedInSubWindow.java @@ -32,12 +32,6 @@ public class EmbeddedInSubWindow extends TestBase { zoom.setModal(true); zoom.setResizable(false); - zoom.addListener(new Window.CloseListener() { - public void windowClose(Window.CloseEvent closeEvent) { - getMainWindow().removeWindow(closeEvent.getWindow()); - } - }); - getMainWindow().addWindow(zoom); } diff --git a/tests/src/com/vaadin/tests/components/window/ExtraWindowShown.html b/tests/src/com/vaadin/tests/components/window/ExtraWindowShown.html new file mode 100644 index 0000000000..ba1682b96d --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/ExtraWindowShown.html @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.window.ExtraWindowShown?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShown::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShown::/VWindow[0]/ScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>1000</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShown::/VWindow[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShown::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShown::/VWindow[0]/ScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>1000</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShown::/VWindow[0]</td>
+ <td></td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/window/ExtraWindowShown.java b/tests/src/com/vaadin/tests/components/window/ExtraWindowShown.java new file mode 100644 index 0000000000..a7079b2d99 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/ExtraWindowShown.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.window;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Window;
+
+public class ExtraWindowShown extends TestBase {
+
+ @Override
+ protected void setup() {
+ Button b = new Button("Open window", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+
+ final Window w = new Window("Sub window");
+ w.center();
+ w.addComponent(new Button("Close", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Window main = w.getParent();
+ // main = w.getWindow();
+ main.removeWindow(w);
+ }
+ }));
+ Button iconButton = new Button("A button with icon");
+ iconButton
+ .setIcon(new ThemeResource("../runo/icons/16/ok.png"));
+ w.addComponent(iconButton);
+ event.getButton().getWindow().addWindow(w);
+ }
+
+ });
+ getLayout().setHeight("100%");
+ getLayout().addComponent(b);
+ getLayout().setComponentAlignment(b, Alignment.MIDDLE_CENTER);
+ }
+
+ @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/src/com/vaadin/tests/components/window/WindowResizeListener.java b/tests/src/com/vaadin/tests/components/window/WindowResizeListener.java index a6c4b21b70..62f998e20e 100644 --- a/tests/src/com/vaadin/tests/components/window/WindowResizeListener.java +++ b/tests/src/com/vaadin/tests/components/window/WindowResizeListener.java @@ -80,7 +80,7 @@ class ResizeListenerWindow extends Window { super("Subwindow"); setWidth("400px"); - Layout hl = getLayout(); + Layout hl = (Layout) getContent(); hl.addComponent(new Label("Current size: ")); hl.addComponent(sizeLabel); diff --git a/tests/src/com/vaadin/tests/dd/DDTest1.java b/tests/src/com/vaadin/tests/dd/DDTest1.java index 21ae600934..0d709844e9 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest1.java +++ b/tests/src/com/vaadin/tests/dd/DDTest1.java @@ -124,9 +124,10 @@ public class DDTest1 extends TestBase { */ DropHandler itemSorter = new DropHandler() { + @SuppressWarnings("unused") private void populateSubTree(HierarchicalContainer idx, HierarchicalContainer subtree, Object itemId) { - Collection children = subtree.getChildren(itemId); + Collection<?> children = subtree.getChildren(itemId); if (children != null) { for (Object childId : children) { @@ -150,10 +151,12 @@ public class DDTest1 extends TestBase { } + @SuppressWarnings("unused") private HierarchicalContainer getSubTree(HierarchicalContainer idx, Object itemId) { HierarchicalContainer hierarchicalContainer = new HierarchicalContainer(); - Collection containerPropertyIds = idx.getContainerPropertyIds(); + Collection<?> containerPropertyIds = idx + .getContainerPropertyIds(); for (Object object : containerPropertyIds) { hierarchicalContainer.addContainerProperty(object, idx.getType(object), null); @@ -165,7 +168,7 @@ public class DDTest1 extends TestBase { private void copyChildren(HierarchicalContainer source, HierarchicalContainer target, Object itemId) { - Collection children = source.getChildren(itemId); + Collection<?> children = source.getChildren(itemId); if (children != null) { for (Object childId : children) { Item item = source.getItem(childId); diff --git a/tests/src/com/vaadin/tests/dd/DDTest2.java b/tests/src/com/vaadin/tests/dd/DDTest2.java index f21eb23f16..690b44ff74 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest2.java +++ b/tests/src/com/vaadin/tests/dd/DDTest2.java @@ -82,7 +82,7 @@ public class DDTest2 extends TestBase { @Override protected Set<Object> getAllowedItemIds(DragAndDropEvent dragEvent, Tree tree) { - return new HashSet(tree.getItemIds()); + return new HashSet<Object>(tree.getItemIds()); } }; @@ -127,6 +127,7 @@ public class DDTest2 extends TestBase { final Or fromTree1OrTable = new Or(fromTable, fromTree); // Or could in the case be replaced with, keeping here as an example and // test + @SuppressWarnings("unused") SourceIs treeOrTable = new SourceIs(table, tree1); final And and = new And(fromTree1OrTable, onNode); @@ -217,7 +218,7 @@ public class DDTest2 extends TestBase { } private void copySubTree(Object itemId, Object itemIdTo) { - Collection children = tree1.getChildren(itemId); + Collection<?> children = tree1.getChildren(itemId); if (children != null) { for (Object childId : children) { Object newItemId = tree2.addItem(); diff --git a/tests/src/com/vaadin/tests/dd/DDTest4.java b/tests/src/com/vaadin/tests/dd/DDTest4.java index f0f5f9bf34..8685c6f5de 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest4.java +++ b/tests/src/com/vaadin/tests/dd/DDTest4.java @@ -11,7 +11,6 @@ import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.SourceIs; -import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.TestUtils; @@ -92,7 +91,7 @@ public class DDTest4 extends TestBase { newIndex = 0; } Object idAfter = containerDataSource.getIdByIndex(newIndex); - Collection selections = (Collection) table.getValue(); + Collection<?> selections = (Collection<?>) table.getValue(); if (selections != null && selections.contains(itemId)) { // dragged a selected item, if multiple rows selected, drag // them too (functionality similar to apple mail) @@ -149,11 +148,6 @@ public class DDTest4 extends TestBase { } - private final static ThemeResource FOLDER = new ThemeResource( - "../runo/icons/16/folder.png"); - private final static ThemeResource DOC = new ThemeResource( - "../runo/icons/16/document.png"); - @Override protected String getDescription() { return "dd"; diff --git a/tests/src/com/vaadin/tests/dd/DDTest5.java b/tests/src/com/vaadin/tests/dd/DDTest5.java index e1884060b9..e4f3d5335d 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest5.java +++ b/tests/src/com/vaadin/tests/dd/DDTest5.java @@ -7,7 +7,6 @@ import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.acceptcriteria.AcceptAll; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.terminal.ThemeResource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; @@ -165,11 +164,6 @@ public class DDTest5 extends TestBase { } - private final static ThemeResource FOLDER = new ThemeResource( - "../runo/icons/16/folder.png"); - private final static ThemeResource DOC = new ThemeResource( - "../runo/icons/16/document.png"); - @Override protected String getDescription() { return "dd: DragAndDropWrapper to build various use cases completely on server side"; diff --git a/tests/src/com/vaadin/tests/dd/DDTest6.java b/tests/src/com/vaadin/tests/dd/DDTest6.java index b8540167c8..ecd7f91192 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest6.java +++ b/tests/src/com/vaadin/tests/dd/DDTest6.java @@ -2,7 +2,6 @@ package com.vaadin.tests.dd; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Collection; @@ -26,10 +25,10 @@ import com.vaadin.event.dd.acceptcriteria.AcceptAll; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.event.dd.acceptcriteria.Not; import com.vaadin.event.dd.acceptcriteria.SourceIsTarget; -import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.Resource; import com.vaadin.terminal.StreamResource; import com.vaadin.terminal.StreamResource.StreamSource; +import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.tests.components.TestBase; @@ -39,15 +38,15 @@ import com.vaadin.ui.AbsoluteLayout.ComponentPosition; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.DragAndDropWrapper; -import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File; import com.vaadin.ui.Embedded; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.Html5File; import com.vaadin.ui.Label; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Table; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.TreeDragMode; import com.vaadin.ui.Tree.TreeTargetDetails; -import com.vaadin.ui.Upload.Receiver; import com.vaadin.ui.Window; public class DDTest6 extends TestBase { @@ -58,16 +57,12 @@ public class DDTest6 extends TestBase { new Folder("Images"), new File("document.doc"), new File("song.mp3"), new File("photo.jpg") }; - private DropHandler dh; - private static Tree tree1; private SplitPanel sp; private BeanItemContainer<File> fs1; - private static int count; - private static DDTest6 instance; @Override @@ -76,7 +71,7 @@ public class DDTest6 extends TestBase { // get() // not converted to thread local - sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + sp = new HorizontalSplitPanel(); sp.setSplitPosition(20); CssLayout l = new CssLayout(); sp.setFirstComponent(l); @@ -226,7 +221,6 @@ public class DDTest6 extends TestBase { byte[] byteArray = bas.toByteArray(); return new ByteArrayInputStream(byteArray); } - // TODO Auto-generated method stub return null; } }; @@ -267,13 +261,15 @@ public class DDTest6 extends TestBase { } private void showSpreadsheet(File file) { - ApplicationResource resource = (ApplicationResource) file.getResource(); + // ApplicationResource resource = (ApplicationResource) + // file.getResource(); String string = new String(file.bas.toByteArray()); String[] rows = string.split("\n"); String[] cols = rows[0].split(","); Table table = new Table(); for (String string2 : cols) { - String col = string2.replaceAll("\"", ""); // remove surrounding "" + // String col = + string2.replaceAll("\"", ""); // remove surrounding "" table.addContainerProperty(string2, String.class, ""); } for (int i = 1; i < rows.length; i++) { @@ -285,7 +281,6 @@ public class DDTest6 extends TestBase { table.setEditable(true); w.addComponent(table); getMainWindow().addWindow(w); - // TODO saving would be nice demo } @@ -402,21 +397,39 @@ public class DDTest6 extends TestBase { for (Html5File html5File : files2) { String fileName = html5File.getFileName(); // int bytes = html5File.getFileSize(); - final ByteArrayOutputStream bas = new ByteArrayOutputStream() { - @Override - public void close() throws IOException { - super.close(); - } - }; + final ByteArrayOutputStream bas = new ByteArrayOutputStream(); + + StreamVariable streamVariable = new StreamVariable() { - Receiver receiver = new Receiver() { - public OutputStream receiveUpload(String filename, - String MIMEType) { + public OutputStream getOutputStream() { return bas; } + + public boolean listenProgress() { + return false; + } + + public void onProgress(StreamingProgressEvent event) { + } + + public void streamingStarted( + StreamingStartEvent event) { + } + + public void streamingFinished( + StreamingEndEvent event) { + } + + public void streamingFailed( + StreamingErrorEvent event) { + } + + public boolean isInterrupted() { + return false; + } }; - html5File.setReceiver(receiver); + html5File.setStreamVariable(streamVariable); File file = new File(fileName, bas); file.setType(html5File.getType()); diff --git a/tests/src/com/vaadin/tests/dd/DDTest7.java b/tests/src/com/vaadin/tests/dd/DDTest7.java index f6eced1121..8efaff8759 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest7.java +++ b/tests/src/com/vaadin/tests/dd/DDTest7.java @@ -12,7 +12,6 @@ import com.vaadin.event.DataBoundTransferable; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.terminal.ThemeResource; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; @@ -122,7 +121,7 @@ public class DDTest7 extends TestBase { newIndex = 0; } Object idAfter = containerDataSource.getIdByIndex(newIndex); - Collection selections = (Collection) table.getValue(); + Collection<?> selections = (Collection<?>) table.getValue(); if (selections != null && selections.contains(itemId)) { // dragged a selected item, if multiple rows selected, drag // them too (functionality similar to apple mail) @@ -177,11 +176,6 @@ public class DDTest7 extends TestBase { } - private final static ThemeResource FOLDER = new ThemeResource( - "../runo/icons/16/folder.png"); - private final static ThemeResource DOC = new ThemeResource( - "../runo/icons/16/document.png"); - @Override protected String getDescription() { return "dd"; diff --git a/tests/src/com/vaadin/tests/dd/DDTest8.java b/tests/src/com/vaadin/tests/dd/DDTest8.java index 7582d92be4..fed889b5c1 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest8.java +++ b/tests/src/com/vaadin/tests/dd/DDTest8.java @@ -49,9 +49,10 @@ public class DDTest8 extends TestBase { */ DropHandler itemSorter = new DropHandler() { + @SuppressWarnings("unused") private void populateSubTree(HierarchicalContainer idx, HierarchicalContainer subtree, Object itemId) { - Collection children = subtree.getChildren(itemId); + Collection<?> children = subtree.getChildren(itemId); if (children != null) { for (Object childId : children) { @@ -75,10 +76,12 @@ public class DDTest8 extends TestBase { } + @SuppressWarnings("unused") private HierarchicalContainer getSubTree(HierarchicalContainer idx, Object itemId) { HierarchicalContainer hierarchicalContainer = new HierarchicalContainer(); - Collection containerPropertyIds = idx.getContainerPropertyIds(); + Collection<?> containerPropertyIds = idx + .getContainerPropertyIds(); for (Object object : containerPropertyIds) { hierarchicalContainer.addContainerProperty(object, idx.getType(object), null); @@ -90,7 +93,7 @@ public class DDTest8 extends TestBase { private void copyChildren(HierarchicalContainer source, HierarchicalContainer target, Object itemId) { - Collection children = source.getChildren(itemId); + Collection<?> children = source.getChildren(itemId); if (children != null) { for (Object childId : children) { Item item = source.getItem(childId); diff --git a/tests/src/com/vaadin/tests/dd/DragAndDropFiles.java b/tests/src/com/vaadin/tests/dd/DragAndDropFiles.java new file mode 100644 index 0000000000..ad23338bbf --- /dev/null +++ b/tests/src/com/vaadin/tests/dd/DragAndDropFiles.java @@ -0,0 +1,124 @@ +package com.vaadin.tests.dd; + +import java.io.OutputStream; + +import org.apache.commons.io.output.NullOutputStream; + +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.terminal.StreamVariable; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; +import com.vaadin.ui.Html5File; +import com.vaadin.ui.Label; + +public class DragAndDropFiles extends TestBase { + + @Override + protected void setup() { + CssLayout cssLayout = new CssLayout() { + @Override + protected String getCss(Component c) { + return "display: block; padding:20px; border: 2px dotted black; background: #aaa;"; + } + }; + Component l = new Label("Drag file on me"); + l.setSizeUndefined(); + cssLayout.addComponent(l); + DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper( + cssLayout); + dragAndDropWrapper.setSizeUndefined(); + dragAndDropWrapper.setDropHandler(new DropHandler() { + + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + public void drop(DragAndDropEvent event) { + WrapperTransferable transferable = (WrapperTransferable) event + .getTransferable(); + Html5File[] files = transferable.getFiles(); + if (files != null) { + + for (int i = 0; i < files.length; i++) { + Html5File file = files[i]; + // Max 1 MB files are uploaded + if (file.getFileSize() > 1024 * 1024) { + getMainWindow() + .showNotification( + "File " + + file.getFileName() + + " was too large, not transferred to the server side."); + continue; + } + + StreamVariable streamVariable = new StreamVariable() { + + public OutputStream getOutputStream() { + return new NullOutputStream(); + } + + public boolean listenProgress() { + return true; + } + + public void onProgress( + StreamingProgressEvent event) { + System.err.println("Progress" + + event.getBytesReceived()); + } + + public void streamingStarted( + StreamingStartEvent event) { + getMainWindow().showNotification( + "Started uploading " + + event.getFileName()); + } + + public void streamingFinished( + StreamingEndEvent event) { + getMainWindow().showNotification( + "Finished uploading " + + event.getFileName()); + } + + public void streamingFailed( + StreamingErrorEvent event) { + getMainWindow().showNotification( + "Failed uploading " + + event.getFileName()); + } + + public boolean isInterrupted() { + return false; + } + }; + file.setStreamVariable(streamVariable); + } + } + + } + }); + + addComponent(dragAndDropWrapper); + } + + /* + * TODO implement 'handbrake' for testing, progresss listener, interrupting. + */ + @Override + protected String getDescription() { + return "Should work. Over 1 MB files will not be posted. TODO implement 'handbrake' for testing, progresss listener, interrupting."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + +} diff --git a/tests/src/com/vaadin/tests/dd/DragDropPane.java b/tests/src/com/vaadin/tests/dd/DragDropPane.java index ec9015679c..1b7b7b997b 100644 --- a/tests/src/com/vaadin/tests/dd/DragDropPane.java +++ b/tests/src/com/vaadin/tests/dd/DragDropPane.java @@ -1,7 +1,6 @@ package com.vaadin.tests.dd; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.OutputStream; import com.vaadin.event.DataBoundTransferable; @@ -10,14 +9,14 @@ import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.acceptcriteria.AcceptAll; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.AbsoluteLayout.ComponentPosition; import com.vaadin.ui.Component; import com.vaadin.ui.DragAndDropWrapper; -import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable.Html5File; +import com.vaadin.ui.Html5File; import com.vaadin.ui.Label; -import com.vaadin.ui.Upload.Receiver; /** * replacement for a proto class to keep tests working @@ -91,7 +90,6 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler { root.getPosition(component).setLeftValue( Float.valueOf(clientX - left)); } catch (Exception e) { - // TODO: handle exception } } else { // drag started and ended inside the this Pane @@ -116,8 +114,8 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler { WrapperTransferable wtr = (WrapperTransferable) ctr; String object = wtr.getText(); - String html = wtr.getHtml(); - String url = (String) ctr.getData("Url"); + // String html = wtr.getHtml(); + // String url = (String) ctr.getData("Url"); final Label l = new Label(); l.setCaption("Generated from HTML5 drag:"); @@ -134,20 +132,34 @@ public class DragDropPane extends DragAndDropWrapper implements DropHandler { if (files != null) { for (Html5File html5File : files) { l.setCaption(html5File.getFileName()); - html5File.setReceiver(new Receiver() { - public OutputStream receiveUpload(String filename, - String MIMEType) { - - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream() { - @Override - public void close() throws IOException { - super.close(); - l.setValue((new String(toByteArray()) - .substring(0, 80) + "...")); - } - }; + html5File.setStreamVariable(new StreamVariable() { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + public OutputStream getOutputStream() { return byteArrayOutputStream; } + + public boolean listenProgress() { + return false; + } + + public void onProgress(StreamingProgressEvent event) { + } + + public void streamingStarted(StreamingStartEvent event) { + } + + public void streamingFinished(StreamingEndEvent event) { + l.setValue((new String(byteArrayOutputStream + .toByteArray()).substring(0, 80) + "...")); + } + + public void streamingFailed(StreamingErrorEvent event) { + } + + public boolean isInterrupted() { + return false; + } }); } } diff --git a/tests/src/com/vaadin/tests/dd/VMyDragSource.java b/tests/src/com/vaadin/tests/dd/VMyDragSource.java index a5f52522ad..350ee064f3 100644 --- a/tests/src/com/vaadin/tests/dd/VMyDragSource.java +++ b/tests/src/com/vaadin/tests/dd/VMyDragSource.java @@ -24,6 +24,7 @@ public class VMyDragSource extends Composite implements Paintable, private boolean mouseDown; private MouseDownEvent mDownEvent; + @SuppressWarnings("unused") private ApplicationConnection client; public VMyDragSource() { diff --git a/tests/src/com/vaadin/tests/featurebrowser/Feature.java b/tests/src/com/vaadin/tests/featurebrowser/Feature.java index 241be04e21..01ad8934fc 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/Feature.java +++ b/tests/src/com/vaadin/tests/featurebrowser/Feature.java @@ -9,9 +9,10 @@ import com.vaadin.terminal.Resource; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Embedded; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TabSheet; +import com.vaadin.ui.VerticalLayout; public abstract class Feature extends CustomComponent { @@ -22,7 +23,7 @@ public abstract class Feature extends CustomComponent { private boolean propsReminder = true; - private final OrderedLayout layout; + private final VerticalLayout layout; private TabSheet ts; @@ -38,7 +39,7 @@ public abstract class Feature extends CustomComponent { /** Constuctor for the feature component */ public Feature() { - layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); + layout = new VerticalLayout(); setCompositionRoot(layout); } @@ -83,10 +84,8 @@ public abstract class Feature extends CustomComponent { // Description tab final String title = getTitle(); if (getDescriptionXHTML() != null) { - final OrderedLayout mainLayout = new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL); - final OrderedLayout layout = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final VerticalLayout mainLayout = new VerticalLayout(); + final HorizontalLayout layout = new HorizontalLayout(); mainLayout.addComponent(layout); if (getImage() != null) { layout.addComponent(new Embedded("", new ClassResource( @@ -119,7 +118,7 @@ public abstract class Feature extends CustomComponent { // Code Sample tab final String example = getExampleSrc(); if (example != null) { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); if (getTitle() != null) { l.addComponent(new Label( "<b>// " + getTitle() + " example</b>", diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureBrowser.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureBrowser.java index d4eb6867a1..2f1e111b99 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureBrowser.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureBrowser.java @@ -8,7 +8,6 @@ import java.util.Iterator; import java.util.StringTokenizer; import com.vaadin.data.Property; -import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -50,7 +49,7 @@ public class FeatureBrowser extends CustomComponent implements features.setItemCaptionPropertyId("name"); features.addListener(this); features.setImmediate(true); - features.setStyle("menu"); + features.setStyleName("menu"); // Configure component layout mainlayout = new CustomLayout("featurebrowser-mainlayout"); @@ -67,7 +66,7 @@ public class FeatureBrowser extends CustomComponent implements // Restart button final Button close = new Button("restart", getApplication(), "close"); - close.setStyle("link"); + close.setStyleName("link"); mainlayout.addComponent(close, "restart"); // Test component @@ -120,7 +119,8 @@ public class FeatureBrowser extends CustomComponent implements // new FeatureParameters()); // Pre-open all menus - for (final Iterator i = features.getItemIds().iterator(); i.hasNext();) { + for (final Iterator<?> i = features.getItemIds().iterator(); i + .hasNext();) { features.expandItem(i.next()); } @@ -162,15 +162,15 @@ public class FeatureBrowser extends CustomComponent implements // FIXME: navigation statistics try { if ((event.getProperty().toString() == null) - && ((AbstractComponent) event.getProperty()).getTag() - .equals("tree")) { + && (event.getProperty() instanceof Tree)) { // ignore tree initialization } else { FeatureUtil.debug( getApplication().getUser().toString(), "valueChange " - + ((AbstractComponent) event.getProperty()) - .getTag() + ", " + event.getProperty()); + + event.getProperty().getClass() + .getSimpleName() + ", " + + event.getProperty()); } } catch (final Exception e) { // ignored, should never happen @@ -212,8 +212,9 @@ public class FeatureBrowser extends CustomComponent implements // FIXME: navigation statistics try { FeatureUtil.debug(getApplication().getUser().toString(), - "buttonClick " + event.getButton().getTag() + ", " - + event.getButton().getCaption() + ", " + "buttonClick " + + event.getButton().getClass().getSimpleName() + + ", " + event.getButton().getCaption() + ", " + event.getButton().getValue()); } catch (final Exception e) { // ignored, should never happen @@ -240,7 +241,7 @@ public class FeatureBrowser extends CustomComponent implements } @Override - public Iterator getComponentIterator() { + public Iterator<Component> getComponentIterator() { // TODO Auto-generated method stub return null; } diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureBuffering.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureBuffering.java index adb563e6d4..7428f8d8d5 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureBuffering.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureBuffering.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureBuffering extends Feature { @@ -38,7 +38,7 @@ public class FeatureBuffering extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Buffering"); l.addComponent(panel); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureButton.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureButton.java index 58c4a1cea8..7dc3be661a 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureButton.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureButton.java @@ -7,8 +7,8 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureButton extends Feature { @@ -19,7 +19,7 @@ public class FeatureButton extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Button b = new Button("Caption"); l.addComponent(b); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureContainers.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureContainers.java index 06732c0325..5d4b09e722 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureContainers.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureContainers.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureContainers extends Feature { @@ -43,7 +43,7 @@ public class FeatureContainers extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Containers"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureCustomLayout.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureCustomLayout.java index e016ebaf4e..02e29f8ee3 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureCustomLayout.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureCustomLayout.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureCustomLayout extends Feature { @@ -29,7 +29,7 @@ public class FeatureCustomLayout extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Custom Layout"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureDateField.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureDateField.java index 8fda0597e7..ca81581153 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureDateField.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureDateField.java @@ -10,8 +10,8 @@ import com.vaadin.ui.Component; import com.vaadin.ui.DateField; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureDateField extends Feature { @@ -31,7 +31,7 @@ public class FeatureDateField extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); l.addComponent(new Label("Your default locale is: " + getApplication().getLocale().toString().replace('_', '-'))); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureEmbedded.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureEmbedded.java index 65453a8ecc..8edaecee6d 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureEmbedded.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureEmbedded.java @@ -8,7 +8,7 @@ import com.vaadin.terminal.ClassResource; import com.vaadin.ui.Component; import com.vaadin.ui.Embedded; import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class FeatureEmbedded extends Feature { @@ -19,15 +19,15 @@ public class FeatureEmbedded extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final ClassResource flashResource = new ClassResource( "vaadin_spin.swf", getApplication()); final Embedded emb = new Embedded("Embedded Caption", flashResource); emb.setType(Embedded.TYPE_OBJECT); emb.setMimeType("application/x-shockwave-flash"); - emb.setWidth(250); - emb.setHeight(100); + emb.setWidth("250px"); + emb.setHeight("100px"); l.addComponent(emb); // Properties diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureForm.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureForm.java index 8c0d01752d..0bb0a02530 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureForm.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureForm.java @@ -11,15 +11,16 @@ import com.vaadin.ui.Component; import com.vaadin.ui.DateField; import com.vaadin.ui.Form; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class FeatureForm extends Feature implements Property.ValueChangeListener { - OrderedLayout demo = null; + VerticalLayout demo = null; Form test; @@ -33,7 +34,7 @@ public class FeatureForm extends Feature implements protected Component getDemoComponent() { if (demo == null) { - demo = new OrderedLayout(); + demo = new VerticalLayout(); createDemo(); } @@ -54,8 +55,7 @@ public class FeatureForm extends Feature implements } demo.addComponent(test); - final OrderedLayout actions = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final HorizontalLayout actions = new HorizontalLayout(); demo.addComponent(actions); // form adder @@ -97,8 +97,7 @@ public class FeatureForm extends Feature implements formLayout = new GridLayout(2, 1); } if (value.equals("Horizontal (OrderedLayout)")) { - formLayout = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + formLayout = new HorizontalLayout(); } createDemo(); @@ -118,13 +117,13 @@ public class FeatureForm extends Feature implements final DateField d = new DateField("Time", new Date()); d.setDescription("This is a DateField-component with text-style"); d.setResolution(DateField.RESOLUTION_MIN); - d.setStyle("text"); + d.setStyleName("text"); test.addField(new Object(), d); } if (value.equals("Calendar")) { final DateField c = new DateField("Calendar", new Date()); c.setDescription("DateField-component with calendar-style and day-resolution"); - c.setStyle("calendar"); + c.setStyleName("calendar"); c.setResolution(DateField.RESOLUTION_DAY); test.addField(new Object(), c); } @@ -135,7 +134,7 @@ public class FeatureForm extends Feature implements s.addItem("Windows"); s.addItem("Solaris"); s.addItem("Symbian"); - s.setStyle("optiongroup"); + s.setStyleName("optiongroup"); test.addField(new Object(), s); } diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureGridLayout.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureGridLayout.java index 297248001e..4573b13248 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureGridLayout.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureGridLayout.java @@ -11,8 +11,8 @@ import com.vaadin.ui.Component; import com.vaadin.ui.DateField; import com.vaadin.ui.Form; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class FeatureGridLayout extends Feature { @@ -23,11 +23,11 @@ public class FeatureGridLayout extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final GridLayout gl = new GridLayout(3, 3); final DateField cal = new DateField("Test component 1", new Date()); - cal.setStyle("calendar"); + cal.setStyleName("calendar"); gl.addComponent(cal, 1, 0, 2, 1); for (int i = 2; i < 7; i++) { gl.addComponent(new TextField("Test component " + i)); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureItems.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureItems.java index 47fdc2d71f..e577861a49 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureItems.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureItems.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureItems extends Feature { @@ -33,7 +33,7 @@ public class FeatureItems extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Items"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureLabel.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureLabel.java index f12a76b39b..01d30f74e9 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureLabel.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureLabel.java @@ -7,7 +7,7 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class FeatureLabel extends Feature { @@ -18,7 +18,7 @@ public class FeatureLabel extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Label lab = new Label("Label text"); l.addComponent(lab); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureLink.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureLink.java index c20f8fe456..74e7eed7cf 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureLink.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureLink.java @@ -8,7 +8,7 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Link; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class FeatureLink extends Feature { @@ -19,7 +19,7 @@ public class FeatureLink extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Link lnk = new Link("Link caption", new ExternalResource( "http://www.vaadin.com")); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureOrderedLayout.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureOrderedLayout.java index cd7c5f9092..06ab57f6ec 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureOrderedLayout.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureOrderedLayout.java @@ -5,10 +5,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; -import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class FeatureOrderedLayout extends Feature { @@ -19,9 +18,9 @@ public class FeatureOrderedLayout extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); - final OrderedLayout ol = new OrderedLayout(); + final VerticalLayout ol = new VerticalLayout(); for (int i = 1; i < 5; i++) { ol.addComponent(new TextField("Test component " + i)); } @@ -29,17 +28,17 @@ public class FeatureOrderedLayout extends Feature { // Properties propertyPanel = new PropertyPanel(ol); - final Form ap = propertyPanel - .createBeanPropertySet(new String[] { "orientation" }); - ap.replaceWithSelect("orientation", new Object[] { - new Integer(OrderedLayout.ORIENTATION_HORIZONTAL), - new Integer(OrderedLayout.ORIENTATION_VERTICAL) }, - new Object[] { "Horizontal", "Vertical" }); + // final Form ap = propertyPanel.createBeanPropertySet(new String[] { + // "orientation" }); + // ap.replaceWithSelect("orientation", new Object[] { new + // Integer(AbstractOrderedLayout.ORIENTATION_HORIZONTAL), new + // Integer(AbstractOrderedLayout.ORIENTATION_VERTICAL) }, new Object[] { + // "Horizontal", "Vertical" }); final Select themes = (Select) propertyPanel.getField("style"); themes.addItem("form") .getItemProperty(themes.getItemCaptionPropertyId()) .setValue("form"); - propertyPanel.addProperties("OrderedLayout Properties", ap); + // propertyPanel.addProperties("OrderedLayout Properties", ap); setJavadocURL("ui/OrderedLayout.html"); @@ -48,7 +47,7 @@ public class FeatureOrderedLayout extends Feature { @Override protected String getExampleSrc() { - return "OrderedLayout ol = new OrderedLayout(OrderedLayout.ORIENTATION_FLOW);\n" + return "OrderedLayout ol = new OrderedLayout(AbstractOrderedLayout.ORIENTATION_FLOW);\n" + "ol.addComponent(new TextField(\"Textfield caption\"));\n" + "ol.addComponent(new Label(\"Label\"));\n"; diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeaturePanel.java b/tests/src/com/vaadin/tests/featurebrowser/FeaturePanel.java index dd5b7a431a..d1e1258e27 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeaturePanel.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeaturePanel.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeaturePanel extends Feature { @@ -20,7 +20,7 @@ public class FeaturePanel extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); // Example panel final Panel show = new Panel("Panel caption"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureParameters.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureParameters.java index 80c3296651..f37be2c372 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureParameters.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureParameters.java @@ -16,10 +16,10 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; public class FeatureParameters extends Feature implements URIHandler, ParameterHandler { @@ -38,7 +38,7 @@ public class FeatureParameters extends Feature implements URIHandler, @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Label info = new Label("To test this feature, try to " + "add some get parameters to URL. For example if you have " @@ -151,11 +151,12 @@ public class FeatureParameters extends Feature implements URIHandler, * * @see com.vaadin.terminal.ParameterHandler#handleParameters(Map) */ - public void handleParameters(Map parameters) { + public void handleParameters(Map<String, String[]> parameters) { params.removeAllItems(); - for (final Iterator i = parameters.keySet().iterator(); i.hasNext();) { - final String name = (String) i.next(); - final String[] values = (String[]) parameters.get(name); + for (final Iterator<String> i = parameters.keySet().iterator(); i + .hasNext();) { + final String name = i.next(); + final String[] values = parameters.get(name); String v = ""; for (int j = 0; j < values.length; j++) { if (v.length() > 0) { diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureProperties.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureProperties.java index 718ebbd9e4..e314c574f6 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureProperties.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureProperties.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureProperties extends Feature { @@ -41,7 +41,7 @@ public class FeatureProperties extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Data Model"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureSelect.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureSelect.java index f4386e762d..2ea564476b 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureSelect.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureSelect.java @@ -5,8 +5,8 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureSelect extends Feature { @@ -27,7 +27,7 @@ public class FeatureSelect extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Select s = new Select("Select employee"); for (int i = 0; i < 50; i++) { diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureTabSheet.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureTabSheet.java index ab015297a9..46d8e0f974 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureTabSheet.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureTabSheet.java @@ -6,8 +6,8 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TabSheet; +import com.vaadin.ui.VerticalLayout; public class FeatureTabSheet extends Feature { @@ -18,7 +18,7 @@ public class FeatureTabSheet extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final TabSheet ts = new TabSheet(); ts.addTab( diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureTable.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureTable.java index 7c58bf89ee..928b7e3f88 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureTable.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureTable.java @@ -8,9 +8,9 @@ import com.vaadin.event.Action; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; public class FeatureTable extends Feature implements Action.Handler { @@ -52,7 +52,7 @@ public class FeatureTable extends Feature implements Action.Handler { protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); // Sample table t = new Table("Corporate Employees"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureTextField.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureTextField.java index f2612ec857..eef09b23d0 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureTextField.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureTextField.java @@ -6,7 +6,7 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; public class FeatureTextField extends Feature { @@ -18,9 +18,7 @@ public class FeatureTextField extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); - + final HorizontalLayout l = new HorizontalLayout(); // Test component final TextField tf = new TextField("Caption"); l.addComponent(tf); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureTree.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureTree.java index c5ccb3ef5f..82a8b77b65 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureTree.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureTree.java @@ -10,9 +10,9 @@ import com.vaadin.event.Action; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; import com.vaadin.ui.Tree; +import com.vaadin.ui.VerticalLayout; public class FeatureTree extends Feature implements Action.Handler { @@ -47,13 +47,13 @@ public class FeatureTree extends Feature implements Action.Handler { } public void expandAll() { - for (final Iterator i = t.rootItemIds().iterator(); i.hasNext();) { + for (final Iterator<?> i = t.rootItemIds().iterator(); i.hasNext();) { t.expandItemsRecursively(i.next()); } } public void collapseAll() { - for (final Iterator i = t.rootItemIds().iterator(); i.hasNext();) { + for (final Iterator<?> i = t.rootItemIds().iterator(); i.hasNext();) { t.collapseItemsRecursively(i.next()); } } @@ -61,7 +61,7 @@ public class FeatureTree extends Feature implements Action.Handler { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final String[] names = new String[100]; for (int i = 0; i < names.length; i++) { diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureUpload.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureUpload.java index 64cd29eba5..fdd51e7efd 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureUpload.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureUpload.java @@ -13,10 +13,10 @@ import com.vaadin.terminal.StreamResource; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Upload; import com.vaadin.ui.Upload.FinishedEvent; +import com.vaadin.ui.VerticalLayout; public class FeatureUpload extends Feature implements Upload.FinishedListener { Buffer buffer = new Buffer(); @@ -30,7 +30,7 @@ public class FeatureUpload extends Feature implements Upload.FinishedListener { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Upload up = new Upload("Upload", buffer); up.setImmediate(true); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureValidators.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureValidators.java index 2b2fbae805..6d28163c12 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureValidators.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureValidators.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class FeatureValidators extends Feature { @@ -33,7 +33,7 @@ public class FeatureValidators extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Validators"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeatureWindow.java b/tests/src/com/vaadin/tests/featurebrowser/FeatureWindow.java index 0153bf5a0e..760ca5211a 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeatureWindow.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeatureWindow.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Window.CloseEvent; @@ -30,9 +30,9 @@ public class FeatureWindow extends Feature implements Window.CloseListener { @Override protected Component getDemoComponent() { - final OrderedLayout layoutRoot = new OrderedLayout(); - final OrderedLayout layoutUpper = new OrderedLayout(); - final OrderedLayout layoutLower = new OrderedLayout(); + final VerticalLayout layoutRoot = new VerticalLayout(); + final VerticalLayout layoutUpper = new VerticalLayout(); + final VerticalLayout layoutLower = new VerticalLayout(); demoWindow = new Window("Feature Test Window"); demoWindow.addListener(this); diff --git a/tests/src/com/vaadin/tests/featurebrowser/FeaturesApplication.java b/tests/src/com/vaadin/tests/featurebrowser/FeaturesApplication.java index 2b1f48075c..8bbbad5d31 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/FeaturesApplication.java +++ b/tests/src/com/vaadin/tests/featurebrowser/FeaturesApplication.java @@ -17,7 +17,7 @@ public class FeaturesApplication extends com.vaadin.Application { final Window main = new Window("Vaadin Features Tour"); setMainWindow(main); - main.setLayout(new FeatureBrowser()); + main.setContent(new FeatureBrowser()); } /** diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroBasic.java b/tests/src/com/vaadin/tests/featurebrowser/IntroBasic.java index 9543b89d0f..ae16c5c0cc 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroBasic.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroBasic.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroBasic extends Feature { @@ -25,7 +25,7 @@ public class IntroBasic extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Basic UI components"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroComponents.java b/tests/src/com/vaadin/tests/featurebrowser/IntroComponents.java index ceb36324ad..46dad74ad7 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroComponents.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroComponents.java @@ -9,9 +9,9 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Embedded; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroComponents extends Feature { @@ -26,7 +26,7 @@ public class IntroComponents extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("UI component diagram"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroDataHandling.java b/tests/src/com/vaadin/tests/featurebrowser/IntroDataHandling.java index 3e5b013f8d..384404a75a 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroDataHandling.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroDataHandling.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroDataHandling extends Feature { @@ -25,7 +25,7 @@ public class IntroDataHandling extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Data Handling"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroDataModel.java b/tests/src/com/vaadin/tests/featurebrowser/IntroDataModel.java index 9bc199dc34..4b9d208d7e 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroDataModel.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroDataModel.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroDataModel extends Feature { @@ -26,7 +26,7 @@ public class IntroDataModel extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Data Model"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroItemContainers.java b/tests/src/com/vaadin/tests/featurebrowser/IntroItemContainers.java index ff8b029fbd..024f05fabd 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroItemContainers.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroItemContainers.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroItemContainers extends Feature { @@ -25,7 +25,7 @@ public class IntroItemContainers extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Item Containers"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroLayouts.java b/tests/src/com/vaadin/tests/featurebrowser/IntroLayouts.java index c0dd0e305a..724d2c2ee2 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroLayouts.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroLayouts.java @@ -7,9 +7,9 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroLayouts extends Feature { @@ -27,7 +27,7 @@ public class IntroLayouts extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Panel panel = new Panel(); panel.setCaption("Layouts"); diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroTerminal.java b/tests/src/com/vaadin/tests/featurebrowser/IntroTerminal.java index 8bb4a3f145..177f8bcb53 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroTerminal.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroTerminal.java @@ -6,7 +6,7 @@ package com.vaadin.tests.featurebrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class IntroTerminal extends Feature { @@ -17,10 +17,10 @@ public class IntroTerminal extends Feature { @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); final Label lab = new Label(); - lab.setStyle("featurebrowser-none"); + lab.setStyleName("featurebrowser-none"); l.addComponent(lab); // Properties diff --git a/tests/src/com/vaadin/tests/featurebrowser/IntroWelcome.java b/tests/src/com/vaadin/tests/featurebrowser/IntroWelcome.java index 16437c8f4c..b0dbc22232 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/IntroWelcome.java +++ b/tests/src/com/vaadin/tests/featurebrowser/IntroWelcome.java @@ -16,9 +16,9 @@ import com.vaadin.terminal.gwt.server.ApplicationServlet; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; public class IntroWelcome extends Feature implements URIHandler, ParameterHandler { @@ -62,7 +62,7 @@ public class IntroWelcome extends Feature implements URIHandler, @Override protected Component getDemoComponent() { - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); panel.setCaption("Welcome to the Vaadin feature tour!"); l.addComponent(panel); @@ -158,9 +158,10 @@ public class IntroWelcome extends Feature implements URIHandler, * * @see com.vaadin.terminal.ParameterHandler#handleParameters(Map) */ - public void handleParameters(Map parameters) { - for (final Iterator i = parameters.keySet().iterator(); i.hasNext();) { - final String name = (String) i.next(); + public void handleParameters(Map<String, String[]> parameters) { + for (final Iterator<String> i = parameters.keySet().iterator(); i + .hasNext();) { + final String name = i.next(); if (name.equals("systemStatus")) { String status = ""; status += "timestamp=" + new Date() + " "; diff --git a/tests/src/com/vaadin/tests/featurebrowser/PropertyPanel.java b/tests/src/com/vaadin/tests/featurebrowser/PropertyPanel.java index 7139202485..32cef16e22 100644 --- a/tests/src/com/vaadin/tests/featurebrowser/PropertyPanel.java +++ b/tests/src/com/vaadin/tests/featurebrowser/PropertyPanel.java @@ -19,7 +19,6 @@ import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.SystemError; import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.UserError; -import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractComponentContainer; import com.vaadin.ui.AbstractField; import com.vaadin.ui.Button; @@ -27,23 +26,26 @@ import com.vaadin.ui.Component; import com.vaadin.ui.DateField; import com.vaadin.ui.Field; import com.vaadin.ui.Form; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Layout; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; +import com.vaadin.ui.themes.Reindeer; public class PropertyPanel extends Panel implements Button.ClickListener, Property.ValueChangeListener { private Select addComponent; - private final OrderedLayout formsLayout = new OrderedLayout(); + private final VerticalLayout formsLayout = new VerticalLayout(); - private final LinkedList forms = new LinkedList(); + private final LinkedList<Form> forms = new LinkedList<Form>(); private final Button setButton = new Button("Set", this); @@ -53,14 +55,14 @@ public class PropertyPanel extends Panel implements Button.ClickListener, private final Object objectToConfigure; - private final BeanItem config; + private final BeanItem<Object> config; protected static final int COLUMNS = 3; /** Contruct new property panel for configuring given object. */ public PropertyPanel(Object objectToConfigure) { super(); - getLayout().setMargin(false); + ((Layout) getContent()).setMargin(false); // Layout setCaption("Properties"); @@ -70,11 +72,10 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // Target object this.objectToConfigure = objectToConfigure; - config = new BeanItem(objectToConfigure); + config = new BeanItem<Object>(objectToConfigure); // Control buttons - final OrderedLayout buttons = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + final HorizontalLayout buttons = new HorizontalLayout(); buttons.setMargin(false, true, true, true); buttons.addComponent(setButton); buttons.addComponent(discardButton); @@ -113,7 +114,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // Create new panel containing the form final Panel p = new Panel(); p.setCaption(propertySetCaption); - p.setStyleName(Panel.STYLE_LIGHT); + p.setStyleName(Reindeer.PANEL_LIGHT); p.addComponent(properties); formsLayout.addComponent(p); @@ -134,9 +135,9 @@ public class PropertyPanel extends Panel implements Button.ClickListener, allProperties.removeAllItems(); // Collect demoed properties - final HashSet listed = new HashSet(); - for (final Iterator i = forms.iterator(); i.hasNext();) { - listed.addAll(((Form) i.next()).getItemPropertyIds()); + final HashSet<Object> listed = new HashSet<Object>(); + for (final Iterator<Form> i = forms.iterator(); i.hasNext();) { + listed.addAll(i.next().getItemPropertyIds()); } // Resolve all properties @@ -319,8 +320,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, * container */ private void addComponentContainerProperties() { - final Form set = new Form(new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL)); + final Form set = new Form(new VerticalLayout()); addComponent = new Select(); addComponent.setImmediate(true); @@ -343,11 +343,10 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // FIXME: navigation statistics try { - FeatureUtil.debug( - getApplication().getUser().toString(), + FeatureUtil.debug(getApplication().getUser().toString(), "valueChange " - + ((AbstractComponent) event.getProperty()) - .getTag() + ", " + event.getProperty()); + + event.getProperty().getClass().getSimpleName() + + ", " + event.getProperty()); } catch (final Exception e) { // ignored, should never happen } @@ -420,8 +419,9 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // FIXME: navigation statistics try { FeatureUtil.debug(getApplication().getUser().toString(), - "buttonClick " + event.getButton().getTag() + ", " - + event.getButton().getCaption() + ", " + "buttonClick " + + event.getButton().getClass().getSimpleName() + + ", " + event.getButton().getCaption() + ", " + event.getButton().getValue()); } catch (final Exception e) { // ignored, should never happen @@ -433,8 +433,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener, // Discard all changed on all forms if (event.getButton() == discardButton) { - for (final Iterator i = forms.iterator(); i.hasNext();) { - ((Form) i.next()).discard(); + for (final Iterator<Form> i = forms.iterator(); i.hasNext();) { + i.next().discard(); } } @@ -445,8 +445,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener, */ protected Form createBeanPropertySet(String names[]) { - final Form set = new Form(new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL)); + final Form set = new Form(new VerticalLayout()); for (int i = 0; i < names.length; i++) { final Property p = config.getItemProperty(names[i]); @@ -469,8 +468,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener, /** Find a field from all forms */ public Field getField(Object propertyId) { - for (final Iterator i = forms.iterator(); i.hasNext();) { - final Form f = (Form) i.next(); + for (final Iterator<Form> i = forms.iterator(); i.hasNext();) { + final Form f = i.next(); final Field af = f.getField(propertyId); if (af != null) { return af; @@ -484,8 +483,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener, } protected void commit() { - for (final Iterator i = forms.iterator(); i.hasNext();) { - ((Form) i.next()).commit(); + for (final Iterator<Form> i = forms.iterator(); i.hasNext();) { + i.next().commit(); } } diff --git a/tests/src/com/vaadin/tests/gwtadapter/applicationconnection/URLGeneration.java b/tests/src/com/vaadin/tests/gwtadapter/applicationconnection/URLGeneration.java new file mode 100644 index 0000000000..0ccc455379 --- /dev/null +++ b/tests/src/com/vaadin/tests/gwtadapter/applicationconnection/URLGeneration.java @@ -0,0 +1,77 @@ +package com.vaadin.tests.gwtadapter.applicationconnection;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+
+public class URLGeneration {
+
+ private static final String[] URIS = new String[] {
+ "http://demo.vaadin.com/", //
+ "https://demo.vaadin.com/",
+ "http://demo.vaadin.com/foo",
+ "http://demo.vaadin.com/foo?f",
+ "http://demo.vaadin.com/foo?f=1",
+ "http://demo.vaadin.com:1234/foo?a",
+ "http://demo.vaadin.com:1234/foo#frag?fakeparam",
+ // Jetspeed
+ "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__",
+ // Liferay generated url
+ "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1",
+
+ };
+ private static final String[] URIS_WITH_ABCD_PARAM = new String[] {
+ "http://demo.vaadin.com/?a=b&c=d",
+ "https://demo.vaadin.com/?a=b&c=d",
+ "http://demo.vaadin.com/foo?a=b&c=d",
+ "http://demo.vaadin.com/foo?f&a=b&c=d",
+ "http://demo.vaadin.com/foo?f=1&a=b&c=d",
+ "http://demo.vaadin.com:1234/foo?a&a=b&c=d",
+ "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam",
+ "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d",
+ "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d",
+
+ };
+
+ private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = new String[] {
+ "http://demo.vaadin.com/?a=b&c=d#fragment",
+ "https://demo.vaadin.com/?a=b&c=d#fragment",
+ "http://demo.vaadin.com/foo?a=b&c=d#fragment",
+ "http://demo.vaadin.com/foo?f&a=b&c=d#fragment",
+ "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment",
+ "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment",
+ "",
+ "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment",
+ "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d#fragment",
+
+ };
+
+ @Test
+ public void testParameterAdding() {
+ for (int i = 0; i < URIS.length; i++) {
+ // Adding nothing
+ assertEquals(URIS[i],
+ ApplicationConnection.addGetParameters(URIS[i], ""));
+
+ // Adding a=b&c=d
+ assertEquals(URIS_WITH_ABCD_PARAM[i],
+ ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d"));
+
+ // Fragments
+ if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) {
+ assertEquals(
+ URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i],
+ ApplicationConnection.addGetParameters(URIS[i]
+ + "#fragment", "a=b&c=d"));
+
+ // Empty fragment
+ assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace(
+ "#fragment", "#"),
+ ApplicationConnection.addGetParameters(URIS[i] + "#",
+ "a=b&c=d"));
+ }
+ }
+ }
+}
diff --git a/tests/src/com/vaadin/tests/layouts/CaptionsInLayouts.java b/tests/src/com/vaadin/tests/layouts/CaptionsInLayouts.java index 131c724f27..ec825a3404 100644 --- a/tests/src/com/vaadin/tests/layouts/CaptionsInLayouts.java +++ b/tests/src/com/vaadin/tests/layouts/CaptionsInLayouts.java @@ -177,7 +177,8 @@ public class CaptionsInLayouts extends TestBase { }
- private Layout getLayout(String caption, Class layoutClass, String width) {
+ private Layout getLayout(String caption,
+ Class<? extends Layout> layoutClass, String width) {
Layout l;
if (layoutClass == VerticalLayout.class) {
if (verticalLayout == null) {
@@ -249,14 +250,14 @@ public class CaptionsInLayouts extends TestBase { layoutSelect.setImmediate(true);
layoutSelect.addListener(new ValueChangeListener() {
+ @SuppressWarnings("unchecked")
public void valueChange(ValueChangeEvent event) {
Item i = layoutSelect.getItem(event.getProperty().getValue());
setLayout(getLayout((String) i.getItemProperty(CAPTION)
- .getValue(), (Class) i.getItemProperty(CLASS)
- .getValue(), (String) i.getItemProperty(WIDTH)
- .getValue()));
-
+ .getValue(), (Class<? extends Layout>) i
+ .getItemProperty(CLASS).getValue(), (String) i
+ .getItemProperty(WIDTH).getValue()));
}
});
diff --git a/tests/src/com/vaadin/tests/layouts/DeepComponentTrees.java b/tests/src/com/vaadin/tests/layouts/DeepComponentTrees.java index fc280c0ce2..3a6414cff5 100644 --- a/tests/src/com/vaadin/tests/layouts/DeepComponentTrees.java +++ b/tests/src/com/vaadin/tests/layouts/DeepComponentTrees.java @@ -33,7 +33,7 @@ public class DeepComponentTrees extends TestBase { protected void setup() {
Layout main = getLayout();
main.setSizeUndefined();
- getMainWindow().getLayout().setHeight(null);
+ getMainWindow().getContent().setHeight(null);
Label l = new Label(
"This is a nice game to guess how many Layouts your FF2 (or any other browser) can deal with. Due to the worldwide attempt to decrease energy consumption, playing this game is only allowed above 60° longitude betwheen August and May (as excess energy consumed by you CPU is used to heat your room). It is considered wise to save all your work before starting the game.");
@@ -90,7 +90,7 @@ public class DeepComponentTrees extends TestBase { }
layout.addComponent(new Label(
"FF did it! Vaadin, Mozilla and you win! Dare to try again?"));
- root.setLayout(r);
+ root.setContent(r);
}
Layout getTestLayout() {
diff --git a/tests/src/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java b/tests/src/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java index 0a50dc326d..e9d206009a 100644 --- a/tests/src/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java +++ b/tests/src/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java @@ -23,7 +23,7 @@ public class GridLayoutExpandRatioModification extends TestBase implements public void setup() { Window main = new Window("The Main Window"); mainLayout = new GridLayout(3, 3); - main.setLayout(mainLayout); + main.setContent(mainLayout); setMainWindow(main); // The upper layout diff --git a/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel.java b/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel.java index bc2e8c01cb..1c864fdb47 100644 --- a/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel.java +++ b/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel.java @@ -3,6 +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.Panel; public class GridLayoutInsidePanel extends TestBase { @@ -26,9 +27,9 @@ public class GridLayoutInsidePanel extends TestBase { "A label which defines the size of the GL")); Panel p = new Panel("Panel 1"); - p.getLayout().setMargin(false); + ((Layout) p.getContent()).setMargin(false); p.setSizeUndefined(); - p.getLayout().setSizeUndefined(); + p.getContent().setSizeUndefined(); p.addComponent(gl); addComponent(p); @@ -40,9 +41,9 @@ public class GridLayoutInsidePanel extends TestBase { "A label which defines the size of the GL")); Panel p = new Panel("Panel 2", gl); - p.getLayout().setMargin(false); + ((Layout) p.getContent()).setMargin(false); p.setSizeUndefined(); - p.getLayout().setSizeUndefined(); + p.getContent().setSizeUndefined(); addComponent(p); } diff --git a/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java b/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java index 22fabab4d7..8fb42948fc 100644 --- a/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java +++ b/tests/src/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java @@ -14,7 +14,7 @@ public class GridLayoutInsidePanel2 extends Application { public void init() { Window w = new Window("Main"); setMainWindow(w); - layout = w.getLayout(); + layout = (Layout) w.getContent(); GridLayout gl = new GridLayout(1, 1); gl.setSizeUndefined(); Label l = new Label("This should be visible"); diff --git a/tests/src/com/vaadin/tests/layouts/OrderedLayoutBasics.java b/tests/src/com/vaadin/tests/layouts/OrderedLayoutBasics.java index c70ac5dfa8..815f480665 100644 --- a/tests/src/com/vaadin/tests/layouts/OrderedLayoutBasics.java +++ b/tests/src/com/vaadin/tests/layouts/OrderedLayoutBasics.java @@ -16,18 +16,15 @@ import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.AlignmentHandler;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Select;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
public class OrderedLayoutBasics extends TestBase {
String valignName[] = new String[] { "top", "middle", "bottom" };
- int valign[] = new int[] { AlignmentHandler.ALIGNMENT_TOP,
- AlignmentHandler.ALIGNMENT_VERTICAL_CENTER,
- AlignmentHandler.ALIGNMENT_BOTTOM };
Set<AbstractOrderedLayout> layouts = new HashSet<AbstractOrderedLayout>();
private AbstractOrderedLayout layoutContainer;
@@ -45,7 +42,7 @@ public class OrderedLayoutBasics extends TestBase { @Override
public void setup() {
- getMainWindow().getLayout().setHeight(null);
+ getMainWindow().getContent().setHeight(null);
layoutContainer = new VerticalLayout();
createUI(layoutContainer);
@@ -106,6 +103,7 @@ public class OrderedLayoutBasics extends TestBase { /* LAYOUTS */
+ @SuppressWarnings("unused")
private Layout layout1() {
HorizontalLayout ol = new HorizontalLayout();
ol.setHeight("200px");
@@ -146,6 +144,7 @@ public class OrderedLayoutBasics extends TestBase { }
+ @SuppressWarnings("unused")
private Layout layout2() {
HorizontalLayout ol = new HorizontalLayout();
ol.setHeight("70px");
@@ -192,6 +191,7 @@ public class OrderedLayoutBasics extends TestBase { return ol;
}
+ @SuppressWarnings("unused")
private Layout layout3() {
HorizontalLayout ol = new HorizontalLayout();
ol.setHeight("");
@@ -243,8 +243,9 @@ public class OrderedLayoutBasics extends TestBase { return ol;
}
+ @SuppressWarnings("unused")
private Layout layout3New() {
- AbstractOrderedLayout ol = new HorizontalLayout();
+ HorizontalLayout ol = new HorizontalLayout();
ol.setHeight("300px");
// ol.setWidth("500px");
ol.setWidth("");
@@ -295,6 +296,7 @@ public class OrderedLayoutBasics extends TestBase { return ol;
}
+ @SuppressWarnings("unused")
private Layout layout4(AbstractOrderedLayout ol) {
// ol.setHeight("300px");
// ol.setWidth("500px");
@@ -302,9 +304,9 @@ public class OrderedLayoutBasics extends TestBase { ol.setSpacing(true);
ol.setWidth("");
ol.setCaption("Dynamic width and dynamic height");
- TextField tf;
+ TextArea tf;
- tf = new TextField("100% high TextField");
+ tf = new TextArea("100% high TextField");
tf.setCaption(null);
tf.setRequired(true);
tf.setValue("100% high Field");
@@ -313,7 +315,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setRows(2);
ol.addComponent(tf);
- tf = new TextField("100% high TextField");
+ tf = new TextArea("100% high TextField");
tf.setCaption("100% high TextField");
tf.setRequired(true);
tf.setValue("100% high Field");
@@ -324,19 +326,24 @@ public class OrderedLayoutBasics extends TestBase { for (int i = 1; i < 4; i++) {
int w = i * 100;
- tf = new TextField("Field " + i);
+ tf = new TextArea("Field " + i);
tf.setRows(2);
tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
+ valignName[i % 3]);
tf.setWidth(w + "px");
tf.setHeight(w + "px");
ol.addComponent(tf);
- ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_LEFT,
- valign[i % 3]);
+ if (i % 3 == 0) {
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+ } else if (i % 3 == 1) {
+ ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
+ } else {
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+ }
}
- tf = new TextField("100% high TextField");
+ tf = new TextArea("100% high TextField");
tf.setValue("100% high 100px wide");
tf.setRows(2);
tf.setHeight("100%");
@@ -355,9 +362,9 @@ public class OrderedLayoutBasics extends TestBase { ol.setCaption("Fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight()
+ "px) / layout_field_100pct_button_field");
- TextField tf;
+ TextArea tf;
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("300x300 field");
tf.setRows(2);
@@ -375,7 +382,7 @@ public class OrderedLayoutBasics extends TestBase { ol.setExpandRatio(b, 1.0f);
ol.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("300x300 field");
tf.setRows(2);
@@ -397,9 +404,9 @@ public class OrderedLayoutBasics extends TestBase { ol.setCaption("Fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight()
+ "px) / layout_basic_test");
- TextField tf;
+ TextArea tf;
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("300x300 field");
tf.setRows(2);
@@ -409,7 +416,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
- Button b;
+ // Button b;
// b = new Button("This is a 100%x50% valign middle button");
// b.setSizeFull();
// b.setHeight("50%");
@@ -417,7 +424,7 @@ public class OrderedLayoutBasics extends TestBase { // ol.setComponentAlignment(b, AlignmentHandler.ALIGNMENT_RIGHT,
// AlignmentHandler.ALIGNMENT_VERTICAL_CENTER);
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("300x300 field");
tf.setRows(2);
@@ -439,9 +446,9 @@ public class OrderedLayoutBasics extends TestBase { ol.setCaption("Fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight()
+ "px) / layout_symmetric_fields");
- TextField tf;
+ TextArea tf;
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
tf.setValue("300x300 field");
tf.setRows(2);
tf.setHeight("300px");
@@ -449,7 +456,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
tf.setValue("300x300 field");
tf.setRows(2);
tf.setHeight("300px");
@@ -457,7 +464,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
tf.setValue("300x300 field");
tf.setRows(2);
tf.setHeight("300px");
@@ -478,7 +485,7 @@ public class OrderedLayoutBasics extends TestBase { ol.setCaption("Fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight()
+ "px) / layout_leftAndRight");
- TextField tf;
+ TextArea tf;
// tf = new TextField("100%x100% Field");
// tf.setCaption(null);
@@ -522,7 +529,7 @@ public class OrderedLayoutBasics extends TestBase { // AlignmentHandler.ALIGNMENT_TOP);
// ol.addComponent(tf);
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("300x300 field");
tf.setRows(2);
@@ -532,7 +539,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
- tf = new TextField("300px x 300px Field");
+ tf = new TextArea("300px x 300px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("300x300 field");
tf.setRows(2);
@@ -553,9 +560,9 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth("");
ol.setCaption("Filled with fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight() + "px)");
- TextField tf;
+ TextArea tf;
- tf = new TextField("60%x100% Field");
+ tf = new TextArea("60%x100% Field");
tf.setCaption("This one has a caption");
tf.setValue("60% x 100% TextField");
tf.setWidth("100%");
@@ -570,7 +577,7 @@ public class OrderedLayoutBasics extends TestBase { ol.setExpandRatio(tf, 1f);
//
- tf = new TextField("60%x60% Field");
+ tf = new TextArea("60%x60% Field");
tf.setCaption(null);
tf.setValue("60% x 60% TextField");
tf.setWidth("100%");
@@ -578,8 +585,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setRequired(true);
ol.addComponent(tf);
ol.setExpandRatio(tf, 1f);
- ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_LEFT,
- AlignmentHandler.ALIGNMENT_VERTICAL_CENTER);
+ ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
// tf.setComponentError(new UserError("It's broken!"));
// tf.setHeight("100%");
@@ -616,7 +622,7 @@ public class OrderedLayoutBasics extends TestBase { // AlignmentHandler.ALIGNMENT_TOP);
// ol.addComponent(tf);
- tf = new TextField("200px x 200px Field");
+ tf = new TextArea("200px x 200px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("200x200 field");
tf.setRows(2);
@@ -626,7 +632,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
- tf = new TextField("200px x 200px Field");
+ tf = new TextArea("200px x 200px Field");
// tf.setIcon(new ThemeResource("icons/16/document-add.png"));
tf.setValue("200x200 field");
tf.setRows(2);
@@ -647,10 +653,10 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth("");
ol.setCaption("OverFilled with fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight() + "px)");
- TextField tf;
+ TextArea tf;
for (int i = 0; i < 5; i++) {
- tf = new TextField("200x200px Field");
+ tf = new TextArea("200x200px Field");
tf.setCaption("This one has a caption");
tf.setValue("200x200 TextField");
tf.setWidth("200px");
@@ -676,10 +682,10 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth("");
ol.setCaption("OverFilled with fixed width (" + ol.getWidth()
+ "px) and dynamic height");
- TextField tf;
+ TextArea tf;
for (int i = 0; i < 10; i++) {
- tf = new TextField("200x200px Field");
+ tf = new TextArea("200x200px Field");
tf.setCaption("This one has a caption");
tf.setWidth("200px");
tf.setHeight(((i + 1) * 50) + "px");
@@ -1041,7 +1047,7 @@ public class OrderedLayoutBasics extends TestBase { protected void addBefore(AbstractOrderedLayout ol, Component c, String width) {
int index = 0;
- Iterator iter = ol.getComponentIterator();
+ Iterator<Component> iter = ol.getComponentIterator();
while (iter.hasNext()) {
if (iter.next() == c) {
break;
@@ -1068,47 +1074,48 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth("");
ol.setCaption("100 % filled with fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight() + "px)");
- TextField tf;
-
- tf = new TextField();
- tf.setCaption("This one has a caption");
- tf.setValue("60% expand TextField");
- tf.setWidth("100%");
- tf.setHeight("100%");
- // tf.setRequired(true);
- // tf.setComponentError(new UserError("It's broken!"));
-
- // tf.setHeight("100%");
- // tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
- ol.setExpandRatio(tf, 60);
-
- tf = new TextField();
- tf.setValue("100px 100px TextField");
- tf.setWidth("100px");
- tf.setHeight("100px");
- tf.setRows(2);
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
+ TextArea ta;
+
+ ta = new TextArea();
+ ta.setCaption("This one has a caption");
+ ta.setValue("60% expand TextField");
+ ta.setWidth("100%");
+ ta.setHeight("100%");
+ // ta.setRequired(true);
+ // ta.setComponentError(new UserError("It's broken!"));
+
+ // ta.setHeight("100%");
+ // ta.setWidth("100px");
+ ta.setRows(2);
+ ol.addComponent(ta);
+ ol.setExpandRatio(ta, 60);
+
+ ta = new TextArea();
+ ta.setValue("100px 100px TextField");
+ ta.setWidth("100px");
+ ta.setHeight("100px");
+ ta.setRows(2);
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
//
- tf = new TextField("40%x40% Field");
- // tf.setCaption(null);
- tf.setValue("40% expand (40% height) TextField");
- tf.setWidth("100%");
- tf.setHeight("40%");
- ol.addComponent(tf);
- ol.setExpandRatio(tf, 40);
- // tf.setRequired(true);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ ta = new TextArea("40%x40% Field");
+ // ta.setCaption(null);
+ ta.setValue("40% expand (40% height) TextField");
+ ta.setWidth("100%");
+ ta.setHeight("40%");
+ ol.addComponent(ta);
+ ol.setExpandRatio(ta, 40);
+ // ta.setRequired(true);
+ ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
- tf.setRows(2);
+ ta.setRows(2);
return ol;
}
+ @SuppressWarnings("unused")
private Layout layout_pctFilled2(AbstractOrderedLayout ol) {
ol.setHeight("600px");
ol.setWidth("600px");
@@ -1118,32 +1125,32 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth("");
ol.setCaption("100 % filled with fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight() + "px)");
- TextField tf;
-
- tf = new TextField();
- // tf.setCaption("This one has a caption");
- tf.setValue("80% x 20% TextField");
- tf.setWidth("80%");
- tf.setHeight("20%");
- // tf.setRequired(true);
- // tf.setComponentError(new UserError("It's broken!"));
-
- // tf.setHeight("100%");
- // tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
+ TextArea ta;
+
+ ta = new TextArea();
+ // ta.setCaption("This one has a caption");
+ ta.setValue("80% x 20% TextField");
+ ta.setWidth("80%");
+ ta.setHeight("20%");
+ // ta.setRequired(true);
+ // ta.setComponentError(new UserError("It's broken!"));
+
+ // ta.setHeight("100%");
+ // ta.setWidth("100px");
+ ta.setRows(2);
+ ol.addComponent(ta);
//
- tf = new TextField("20%x60% Field");
- tf.setCaption(null);
- tf.setValue("20% x 60% TextField");
- tf.setWidth("20%");
- tf.setHeight("60%");
- // tf.setRequired(true);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ ta = new TextArea("20%x60% Field");
+ ta.setCaption(null);
+ ta.setValue("20% x 60% TextField");
+ ta.setWidth("20%");
+ ta.setHeight("60%");
+ // ta.setRequired(true);
+ ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
- tf.setRows(2);
- ol.addComponent(tf);
+ ta.setRows(2);
+ ol.addComponent(ta);
return ol;
}
@@ -1157,38 +1164,38 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth("");
ol.setCaption("Underfilled with fixed width (" + ol.getWidth()
+ "px) and fixed height (" + ol.getHeight() + "px)");
- TextField tf;
-
- tf = new TextField("60%x100% Field");
- tf.setCaption("Short capt");
- tf.setValue("60% x 100% TextField");
- tf.setWidth("60%");
- tf.setHeight("100%");
- tf.setRequired(true);
- tf.setRows(2);
-
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
-
- tf = new TextField("200px x 200px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("200x200 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("200px");
- tf.setWidth("200px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- tf = new TextField("200px x 200px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("200x200 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("200px");
- tf.setWidth("200px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ TextArea ta;
+
+ ta = new TextArea("60%x100% Field");
+ ta.setCaption("Short capt");
+ ta.setValue("60% x 100% TextField");
+ ta.setWidth("60%");
+ ta.setHeight("100%");
+ ta.setRequired(true);
+ ta.setRows(2);
+
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
+
+ ta = new TextArea("200px x 200px Field");
+ // ta.setIcon(new ThemeResource("icons/16/document-add.png"));
+ ta.setValue("200x200 field");
+ ta.setRows(2);
+ // ta.setSizeFull();
+ ta.setHeight("200px");
+ ta.setWidth("200px");
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.TOP_LEFT);
+
+ ta = new TextArea("200px x 200px Field");
+ // ta.setIcon(new ThemeResource("icons/16/document-add.png"));
+ ta.setValue("200x200 field");
+ ta.setRows(2);
+ // ta.setSizeFull();
+ ta.setHeight("200px");
+ ta.setWidth("200px");
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
return ol;
}
diff --git a/tests/src/com/vaadin/tests/layouts/OrderedLayoutCSSCompatibility.java b/tests/src/com/vaadin/tests/layouts/OrderedLayoutCSSCompatibility.java index 6073edf249..41f1de2c4a 100644 --- a/tests/src/com/vaadin/tests/layouts/OrderedLayoutCSSCompatibility.java +++ b/tests/src/com/vaadin/tests/layouts/OrderedLayoutCSSCompatibility.java @@ -1,7 +1,7 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; public class OrderedLayoutCSSCompatibility extends TestBase { @@ -18,8 +18,7 @@ public class OrderedLayoutCSSCompatibility extends TestBase { @Override protected void setup() { - OrderedLayout l = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout l = new HorizontalLayout(); l.setMargin(true); l.setSpacing(true); l.addComponent(new TextField("abc")); diff --git a/tests/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java b/tests/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java index 1225874a44..baf8218922 100644 --- a/tests/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java +++ b/tests/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java @@ -14,29 +14,29 @@ import com.vaadin.data.util.BeanItem; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.BaseFieldFactory;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Component;
+import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
-import com.vaadin.ui.FieldFactory;
import com.vaadin.ui.Form;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.TextField;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.Window;
public class TestAbsoluteLayout extends TestBase {
- private static class MFieldFactory extends BaseFieldFactory {
+ private static class MFieldFactory extends DefaultFieldFactory {
@Override
public Field createField(Item item, Object propertyId,
Component uiContext) {
if (propertyId.equals("CSSString")) {
- TextField f = new TextField();
+ TextArea f = new TextArea();
f.setRows(5);
f.setHeight("8em");
f.setCaption("CSS string");
@@ -60,7 +60,7 @@ public class TestAbsoluteLayout extends TestBase { private static MFieldFactory instance;
- public static FieldFactory get() {
+ public static DefaultFieldFactory get() {
if (instance == null) {
instance = new MFieldFactory();
}
@@ -132,7 +132,7 @@ public class TestAbsoluteLayout extends TestBase { componentChooser.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
final Window chooser = new Window("Choose component");
- chooser.getLayout().setSizeUndefined();
+ chooser.getContent().setSizeUndefined();
chooser.setModal(true);
NativeSelect select = new NativeSelect(
@@ -149,7 +149,7 @@ public class TestAbsoluteLayout extends TestBase { .next();
Item item = container.addItem(next);
- String caption = next.getTag();
+ String caption = next.getClass().getSimpleName();
caption += "; cap: " + next.getCaption() + "; debugid"
+ getDebugId();
@@ -187,7 +187,7 @@ public class TestAbsoluteLayout extends TestBase { public void buttonClick(ClickEvent event) {
final Window chooser = new Window(
"Choose component type to add");
- chooser.getLayout().setSizeUndefined();
+ chooser.getContent().setSizeUndefined();
chooser.setModal(true);
NativeSelect select = new NativeSelect(
@@ -212,7 +212,7 @@ public class TestAbsoluteLayout extends TestBase { files[j].length() - 6);
p = p.replaceAll(".*classes/", "");
p = p.replaceAll("/", ".");
- Class c;
+ Class<?> c;
try {
c = Class.forName(p);
if (AbstractComponent.class
@@ -235,7 +235,8 @@ public class TestAbsoluteLayout extends TestBase { select.addListener(new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
- Class c = (Class) event.getProperty().getValue();
+ Class<?> c = (Class<?>) event.getProperty()
+ .getValue();
try {
Component newInstance = (Component) c
@@ -267,13 +268,13 @@ public class TestAbsoluteLayout extends TestBase { componentEditor = new Form();
componentEditor.setWriteThrough(false);
componentEditor.setCaption("Component properties:");
- componentEditor.setFieldFactory(MFieldFactory.get());
+ componentEditor.setFormFieldFactory(MFieldFactory.get());
addComponent(componentEditor);
positionEditor = new Form();
positionEditor.setCaption("Component position");
positionEditor.setWriteThrough(false);
- positionEditor.setFieldFactory(MFieldFactory.get());
+ positionEditor.setFormFieldFactory(MFieldFactory.get());
addComponent(positionEditor);
Button b = new Button("Commit changes", new Button.ClickListener() {
@@ -288,7 +289,7 @@ public class TestAbsoluteLayout extends TestBase { private void editcomponent(Component value) {
- BeanItem beanItem = new BeanItem(value);
+ BeanItem<Component> beanItem = new BeanItem<Component>(value);
String c = "Component properties for "
+ value.getClass().getSimpleName();
ArrayList<String> fields = new ArrayList<String>(
@@ -301,10 +302,11 @@ public class TestAbsoluteLayout extends TestBase { componentEditor.setItemDataSource(beanItem, fields);
- beanItem = new BeanItem(l.getPosition(value));
+ BeanItem<ComponentPosition> positionItem = new BeanItem<ComponentPosition>(
+ l.getPosition(value));
componentEditor.setCaption(c);
- positionEditor.setItemDataSource(beanItem);
+ positionEditor.setItemDataSource(positionItem);
}
}
diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java index c6891e9d68..93c51d6b4a 100644 --- a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java +++ b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -2,6 +2,7 @@ package com.vaadin.tests.layouts; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Log; import com.vaadin.ui.AbsoluteLayout; @@ -141,9 +142,9 @@ public class TestLayoutClickListeners extends AbstractTestCase { } } String button = "left"; - if (event.getButton() == event.BUTTON_RIGHT) { + if (event.getButton() == ClickEvent.BUTTON_RIGHT) { button = "right"; - } else if (event.getButton() == event.BUTTON_MIDDLE) { + } else if (event.getButton() == ClickEvent.BUTTON_MIDDLE) { button = "middle"; } diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutPerformance.java b/tests/src/com/vaadin/tests/layouts/TestLayoutPerformance.java index 6cae2a7679..31ee15983e 100644 --- a/tests/src/com/vaadin/tests/layouts/TestLayoutPerformance.java +++ b/tests/src/com/vaadin/tests/layouts/TestLayoutPerformance.java @@ -91,7 +91,7 @@ public class TestLayoutPerformance extends TestBase { }
private Layout getCurrentLayout() {
- Class value = (Class) ns.getValue();
+ Class<?> value = (Class<?>) ns.getValue();
if (value == GridLayout.class) {
return new GridLayout(10, 1);
}
@@ -110,7 +110,7 @@ public class TestLayoutPerformance extends TestBase { }
private Component newTestComponent() {
- Class componentClass = (Class) ns2.getValue();
+ Class<?> componentClass = (Class<?>) ns2.getValue();
AbstractComponent newInstance = null;
try {
newInstance = (AbstractComponent) componentClass.newInstance();
diff --git a/tests/src/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java b/tests/src/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java index 699522e18b..bbac07d20f 100644 --- a/tests/src/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java +++ b/tests/src/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java @@ -22,7 +22,7 @@ public class VerticalLayoutExpandRatioModification extends TestBase implements public void setup() {
Window main = new Window("The Main Window");
mainLayout = new VerticalLayout();
- main.setLayout(mainLayout);
+ main.setContent(mainLayout);
setMainWindow(main);
// The upper layout
diff --git a/tests/src/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java b/tests/src/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java index 8ff742c179..361707a86c 100644 --- a/tests/src/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java +++ b/tests/src/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java @@ -19,7 +19,7 @@ public class VerticalLayoutWithRelativeSizeComponents extends TestBase { @Override
protected void setup() {
getLayout().setSizeUndefined();
- getMainWindow().getLayout().setHeight(null);
+ getMainWindow().getContent().setHeight(null);
Label l = new Label(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc condimentum urna quis leo. In hac habitasse platea dictumst. Pellentesque tincidunt. Sed libero nisl, faucibus in, laoreet pellentesque, consectetur non, dolor. Sed tortor. Ut pretium sapien. Cras elementum enim non lacus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla velit est, aliquam a, pellentesque a, iaculis nec, sapien. Ut ultrices ligula vitae nulla. Morbi sem pede, iaculis ac, condimentum a, ornare eget, nisi. Aliquam hendrerit pulvinar massa. Vestibulum pretium purus eu augue. Sed posuere elit ut magna. Cras consequat faucibus nunc. Vestibulum quis diam.");
diff --git a/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java index b3fc2f80d5..283e9f7a54 100644 --- a/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java +++ b/tests/src/com/vaadin/tests/layouts/WidgetImplementationSwap.java @@ -11,6 +11,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; +@SuppressWarnings("deprecation") public class WidgetImplementationSwap extends TestBase { @Override diff --git a/tests/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java b/tests/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java index d8ee2e46b9..8985f1cf97 100644 --- a/tests/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java +++ b/tests/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java @@ -30,12 +30,10 @@ import com.vaadin.ui.themes.Reindeer; public class GridLayoutTests extends AbstractLayoutTests {
- private Application application;
private AbstractComponent rc1, col1, col2, col3, row1, row2, row3, x3, x22;
public GridLayoutTests(Application application) {
super();
- this.application = application;
}
@Override
diff --git a/tests/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/tests/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java index 711469e79e..9db1f7f44f 100644 --- a/tests/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ b/tests/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java @@ -26,11 +26,8 @@ import com.vaadin.ui.themes.Reindeer; public class HorizontalLayoutTests extends AbstractLayoutTests {
- private Application application;
-
public HorizontalLayoutTests(Application application) {
super();
- this.application = application;
}
@Override
diff --git a/tests/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/tests/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java index 6edd121576..cb52ab1051 100644 --- a/tests/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ b/tests/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java @@ -25,11 +25,8 @@ import com.vaadin.ui.VerticalLayout; public class VerticalLayoutTests extends AbstractLayoutTests {
- private Application application;
-
public VerticalLayoutTests(Application application) {
super();
- this.application = application;
}
@Override
diff --git a/tests/src/com/vaadin/tests/robustness/Robustness.java b/tests/src/com/vaadin/tests/robustness/Robustness.java index 8ee06ec4e0..52cc5b789d 100644 --- a/tests/src/com/vaadin/tests/robustness/Robustness.java +++ b/tests/src/com/vaadin/tests/robustness/Robustness.java @@ -68,7 +68,7 @@ public abstract class Robustness extends com.vaadin.Application implements create = null; label = null; stressLayout = null; - System.out.println("main.getLayout()=" + main.getLayout()); + System.out.println("main.getLayout()=" + main.getContent()); System.out.println(getMemoryStatistics()); } else if (event.getButton() == close) { System.out.println("Before close, memory statistics:"); diff --git a/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java b/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java index e99fe4b5e7..31540fe9cf 100644 --- a/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java +++ b/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java @@ -2,7 +2,7 @@ package com.vaadin.tests.robustness; import com.vaadin.ui.Button; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; public class RobustnessSimple extends Robustness implements Button.ClickListener { @@ -18,7 +18,7 @@ public class RobustnessSimple extends Robustness implements } // create new stress layout - stressLayout = new OrderedLayout(); + stressLayout = new VerticalLayout(); // CASE single orderedlayout with a label containing 1Mb of data // fill with random components diff --git a/tests/src/com/vaadin/tests/server/TestClassesSerializable.java b/tests/src/com/vaadin/tests/server/TestClassesSerializable.java index bebb629aa8..f7beafb927 100644 --- a/tests/src/com/vaadin/tests/server/TestClassesSerializable.java +++ b/tests/src/com/vaadin/tests/server/TestClassesSerializable.java @@ -63,7 +63,7 @@ public class TestClassesSerializable extends TestCase { classes.addAll(findServerClasses(location));
}
- List<Class> nonSerializableClasses = new ArrayList<Class>();
+ ArrayList<Class<?>> nonSerializableClasses = new ArrayList<Class<?>>();
for (String className : classes) {
Class<?> cls = Class.forName(className);
// skip annotations and synthetic classes
@@ -82,7 +82,7 @@ public class TestClassesSerializable extends TestCase { // interfaces
if (!nonSerializableClasses.isEmpty()) {
String nonSerializableString = "";
- Iterator<Class> it = nonSerializableClasses.iterator();
+ Iterator<Class<?>> it = nonSerializableClasses.iterator();
nonSerializableString = it.next().getName();
while (it.hasNext()) {
nonSerializableString += ", " + it.next().getName();
@@ -146,7 +146,7 @@ public class TestClassesSerializable extends TestCase { classes = findClassesInJar(file);
} else {
System.out.println("Ignoring " + classpathEntry);
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
List<String> filteredClasses = new ArrayList<String>();
@@ -212,7 +212,7 @@ public class TestClassesSerializable extends TestCase { String parentPackage, File parent) {
if (parent.isHidden()
|| parent.getPath().contains(File.separator + ".")) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
if (parentPackage == null) {
diff --git a/tests/src/com/vaadin/tests/server/TestSerialization.java b/tests/src/com/vaadin/tests/server/TestSerialization.java index a938ab3a32..03a9d3e262 100644 --- a/tests/src/com/vaadin/tests/server/TestSerialization.java +++ b/tests/src/com/vaadin/tests/server/TestSerialization.java @@ -27,7 +27,7 @@ public class TestSerialization extends TestCase { public void testForm() throws Exception { Form f = new Form(); String propertyId = "My property"; - f.addItemProperty(propertyId, new MethodProperty(new Data(), + f.addItemProperty(propertyId, new MethodProperty<Object>(new Data(), "dummyGetterAndSetter")); f.replaceWithSelect(propertyId, new Object[] { "a", "b", null }, new String[] { "Item a", "ITem b", "Null item" }); @@ -49,18 +49,20 @@ public class TestSerialization extends TestCase { } public void testMethodPropertyGetter() throws Exception { - MethodProperty mp = new MethodProperty(new Data(), "dummyGetter"); + MethodProperty<?> mp = new MethodProperty<Object>(new Data(), + "dummyGetter"); serializeAndDeserialize(mp); } public void testMethodPropertyGetterAndSetter() throws Exception { - MethodProperty mp = new MethodProperty(new Data(), + MethodProperty<?> mp = new MethodProperty<Object>(new Data(), "dummyGetterAndSetter"); serializeAndDeserialize(mp); } public void testMethodPropertyInt() throws Exception { - MethodProperty mp = new MethodProperty(new Data(), "dummyInt"); + MethodProperty<?> mp = new MethodProperty<Object>(new Data(), + "dummyInt"); serializeAndDeserialize(mp); } diff --git a/tests/src/com/vaadin/tests/server/applicationservlet/TestStaticFilesLocation.java b/tests/src/com/vaadin/tests/server/applicationservlet/TestStaticFilesLocation.java index ed743ccedc..29ef40e546 100644 --- a/tests/src/com/vaadin/tests/server/applicationservlet/TestStaticFilesLocation.java +++ b/tests/src/com/vaadin/tests/server/applicationservlet/TestStaticFilesLocation.java @@ -54,7 +54,7 @@ public class TestStaticFilesLocation extends TestCase { return null; } - public Enumeration getInitParameterNames() { + public Enumeration<Object> getInitParameterNames() { return new Enumeration<Object>() { public boolean hasMoreElements() { diff --git a/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java b/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java index e95e78ddea..391ef02e3c 100644 --- a/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java +++ b/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java @@ -26,7 +26,7 @@ public class TestListeners extends TestCase implements ExpandListener, public void testExpandListener() {
Tree tree = createTree(10, 20, false);
tree.addListener((ExpandListener) this);
- List<String> rootIds = new ArrayList<String>(tree.rootItemIds());
+ List<Object> rootIds = new ArrayList<Object>(tree.rootItemIds());
assertEquals(10, rootIds.size());
assertEquals(10 + 10 * 20 + 10, tree.size());
@@ -97,7 +97,7 @@ public class TestListeners extends TestCase implements ExpandListener, Tree tree = createTree(7, 15, true);
tree.addListener((CollapseListener) this);
- List<String> rootIds = new ArrayList<String>(tree.rootItemIds());
+ List<Object> rootIds = new ArrayList<Object>(tree.rootItemIds());
assertEquals(7, rootIds.size());
assertEquals(7 + 7 * 15 + 7, tree.size());
diff --git a/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java new file mode 100644 index 0000000000..afc050b981 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java @@ -0,0 +1,83 @@ +package com.vaadin.tests.server.component.window;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Window;
+
+public class AddRemoveSubWindow {
+
+ public class TestApp extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window("Main window");
+ setMainWindow(w);
+ }
+ }
+
+ @Test
+ public void addSubWindow() {
+ TestApp app = new TestApp();
+ app.init();
+ Window subWindow = new Window("Sub window");
+ Window mainWindow = app.getMainWindow();
+
+ mainWindow.addWindow(subWindow);
+ // Added to main window so the parent of the sub window should be the
+ // main window
+ assertEquals(subWindow.getParent(), mainWindow);
+
+ try {
+ mainWindow.addWindow(subWindow);
+ assertTrue("Window.addWindow did not throw the expected exception",
+ false);
+ } catch (IllegalArgumentException e) {
+ // Should throw an exception as it has already been added to the
+ // main window
+ }
+
+ // Try to add the same sub window to another window
+ try {
+ Window w = new Window();
+ w.addWindow(subWindow);
+ assertTrue("Window.addWindow did not throw the expected exception",
+ false);
+ } catch (IllegalArgumentException e) {
+ // Should throw an exception as it has already been added to the
+ // main window
+ }
+
+ }
+
+ @Test
+ public void removeSubWindow() {
+ TestApp app = new TestApp();
+ app.init();
+ Window subWindow = new Window("Sub window");
+ Window mainWindow = app.getMainWindow();
+ mainWindow.addWindow(subWindow);
+
+ // Added to main window so the parent of the sub window should be the
+ // main window
+ assertEquals(subWindow.getParent(), mainWindow);
+
+ // Remove from the wrong window, should result in an exception
+ boolean removed = subWindow.removeWindow(subWindow);
+ assertFalse("Window was removed even though it should not have been",
+ removed);
+
+ // Parent should still be set
+ assertEquals(subWindow.getParent(), mainWindow);
+
+ // Remove from the main window and assert it has been removed
+ removed = mainWindow.removeWindow(subWindow);
+ assertTrue("Window was not removed correctly", removed);
+ assertNull(subWindow.getParent());
+ }
+}
diff --git a/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java index 756db0eabf..45b5c0b0b2 100644 --- a/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java +++ b/tests/src/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java @@ -37,7 +37,7 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * Test that listeners are not called when they have been unregistered.
*/
public void testRemoveListener() {
- getField().setPropertyDataSource(new ObjectProperty(""));
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
getField().setWriteThrough(true);
getField().setReadThrough(true);
@@ -73,7 +73,7 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * source behind the field.
*/
public void testWriteThroughReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty(""));
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
getField().setWriteThrough(true);
getField().setReadThrough(true);
@@ -88,7 +88,7 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * not the original data source value changes.
*/
public void testNoWriteThroughNoReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty(""));
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
getField().setWriteThrough(false);
getField().setReadThrough(false);
@@ -106,7 +106,7 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * source value through the text field or the (notifying) property.
*/
public void testWriteThroughNoReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty(""));
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
getField().setWriteThrough(true);
getField().setReadThrough(false);
@@ -125,7 +125,7 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * not the original data source value changes.
*/
public void testNoWriteThroughReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty(""));
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
getField().setWriteThrough(false);
getField().setReadThrough(true);
diff --git a/tests/src/com/vaadin/tests/server/container/ObjectPropertyTest.java b/tests/src/com/vaadin/tests/server/container/ObjectPropertyTest.java new file mode 100644 index 0000000000..0cdd659afd --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/ObjectPropertyTest.java @@ -0,0 +1,99 @@ +package com.vaadin.tests.server.container;
+
+import junit.framework.TestCase;
+
+import org.junit.Assert;
+
+import com.vaadin.data.util.ObjectProperty;
+
+public class ObjectPropertyTest extends TestCase {
+
+ public static class TestSuperClass {
+ private String name;
+
+ public TestSuperClass(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+ }
+
+ public static class TestSubClass extends TestSuperClass {
+ public TestSubClass(String name) {
+ super("Subclass: " + name);
+ }
+ }
+
+ private TestSuperClass super1 = new TestSuperClass("super1");
+ private TestSubClass sub1 = new TestSubClass("sub1");
+
+ public void testSimple() {
+ ObjectProperty<TestSuperClass> prop1 = new ObjectProperty<TestSuperClass>(
+ super1, TestSuperClass.class);
+ Assert.assertEquals("super1", prop1.getValue().getName());
+ prop1 = new ObjectProperty<TestSuperClass>(super1);
+ Assert.assertEquals("super1", prop1.getValue().getName());
+
+ ObjectProperty<TestSubClass> prop2 = new ObjectProperty<TestSubClass>(
+ sub1, TestSubClass.class);
+ Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
+ prop2 = new ObjectProperty<TestSubClass>(sub1);
+ Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
+ }
+
+ public void testSetValueObjectSuper() {
+ ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
+ super1, TestSuperClass.class);
+ Assert.assertEquals("super1", prop.getValue().getName());
+ prop.setValue(new TestSuperClass("super2"));
+ Assert.assertEquals("super1", super1.getName());
+ Assert.assertEquals("super2", prop.getValue().getName());
+ }
+
+ public void testSetValueObjectSub() {
+ ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
+ sub1, TestSubClass.class);
+ Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
+ prop.setValue(new TestSubClass("sub2"));
+ Assert.assertEquals("Subclass: sub1", sub1.getName());
+ Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
+ }
+
+ public void testSetValueStringSuper() {
+ ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
+ super1, TestSuperClass.class);
+ Assert.assertEquals("super1", prop.getValue().getName());
+ prop.setValue("super2");
+ Assert.assertEquals("super1", super1.getName());
+ Assert.assertEquals("super2", prop.getValue().getName());
+ }
+
+ public void testSetValueStringSub() {
+ ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
+ sub1, TestSubClass.class);
+ Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
+ prop.setValue("sub2");
+ Assert.assertEquals("Subclass: sub1", sub1.getName());
+ Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
+ }
+
+ public void testMixedGenerics() {
+ ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
+ sub1);
+ Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
+ Assert.assertEquals(prop.getType(), TestSubClass.class);
+ // create correct subclass based on the runtime type of the instance
+ // given to ObjectProperty constructor, which is a subclass of the type
+ // parameter
+ prop.setValue("sub2");
+ Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/server/container/PropertySetItemTest.java b/tests/src/com/vaadin/tests/server/container/PropertySetItemTest.java new file mode 100644 index 0000000000..5a2af14b7e --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/PropertySetItemTest.java @@ -0,0 +1,407 @@ +package com.vaadin.tests.server.container; + +import java.util.Iterator; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.easymock.EasyMock; + +import com.vaadin.data.Item.PropertySetChangeEvent; +import com.vaadin.data.Item.PropertySetChangeListener; +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.data.util.PropertysetItem; + +public class PropertySetItemTest extends TestCase { + + private static final String ID1 = "id1"; + private static final String ID2 = "id2"; + private static final String ID3 = "id3"; + + private static final String VALUE1 = "value1"; + private static final String VALUE2 = "value2"; + private static final String VALUE3 = "value3"; + + private ObjectProperty<String> prop1; + private ObjectProperty<String> prop2; + private ObjectProperty<String> prop3; + + private PropertySetChangeListener propertySetListenerMock; + private PropertySetChangeListener propertySetListenerMock2; + + @Override + protected void setUp() throws Exception { + prop1 = new ObjectProperty<String>(VALUE1, String.class); + prop2 = new ObjectProperty<String>(VALUE2, String.class); + prop3 = new ObjectProperty<String>(VALUE3, String.class); + + propertySetListenerMock = EasyMock + .createStrictMock(PropertySetChangeListener.class); + propertySetListenerMock2 = EasyMock + .createMock(PropertySetChangeListener.class); + } + + @Override + protected void tearDown() throws Exception { + prop1 = null; + prop2 = null; + prop3 = null; + + propertySetListenerMock = null; + propertySetListenerMock2 = null; + } + + private PropertysetItem createPropertySetItem() { + return new PropertysetItem(); + } + + public void testEmptyItem() { + PropertysetItem item = createPropertySetItem(); + Assert.assertNotNull(item.getItemPropertyIds()); + Assert.assertEquals(0, item.getItemPropertyIds().size()); + } + + public void testGetProperty() { + PropertysetItem item = createPropertySetItem(); + + Assert.assertNull(item.getItemProperty(ID1)); + + item.addItemProperty(ID1, prop1); + + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + Assert.assertNull(item.getItemProperty(ID2)); + } + + public void testAddSingleProperty() { + PropertysetItem item = createPropertySetItem(); + + item.addItemProperty(ID1, prop1); + Assert.assertEquals(1, item.getItemPropertyIds().size()); + Object firstValue = item.getItemPropertyIds().iterator().next(); + Assert.assertEquals(ID1, firstValue); + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + } + + public void testAddMultipleProperties() { + PropertysetItem item = createPropertySetItem(); + + item.addItemProperty(ID1, prop1); + Assert.assertEquals(1, item.getItemPropertyIds().size()); + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + + item.addItemProperty(ID2, prop2); + Assert.assertEquals(2, item.getItemPropertyIds().size()); + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + Assert.assertEquals(prop2, item.getItemProperty(ID2)); + + item.addItemProperty(ID3, prop3); + Assert.assertEquals(3, item.getItemPropertyIds().size()); + } + + public void testAddedPropertyOrder() { + PropertysetItem item = createPropertySetItem(); + item.addItemProperty(ID1, prop1); + item.addItemProperty(ID2, prop2); + item.addItemProperty(ID3, prop3); + + Iterator<?> it = item.getItemPropertyIds().iterator(); + Assert.assertEquals(ID1, it.next()); + Assert.assertEquals(ID2, it.next()); + Assert.assertEquals(ID3, it.next()); + } + + public void testAddPropertyTwice() { + PropertysetItem item = createPropertySetItem(); + Assert.assertTrue(item.addItemProperty(ID1, prop1)); + Assert.assertFalse(item.addItemProperty(ID1, prop1)); + + Assert.assertEquals(1, item.getItemPropertyIds().size()); + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + } + + public void testCannotChangeProperty() { + PropertysetItem item = createPropertySetItem(); + Assert.assertTrue(item.addItemProperty(ID1, prop1)); + + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + + Assert.assertFalse(item.addItemProperty(ID1, prop2)); + + Assert.assertEquals(1, item.getItemPropertyIds().size()); + Assert.assertEquals(prop1, item.getItemProperty(ID1)); + } + + public void testRemoveProperty() { + PropertysetItem item = createPropertySetItem(); + item.addItemProperty(ID1, prop1); + item.removeItemProperty(ID1); + + Assert.assertEquals(0, item.getItemPropertyIds().size()); + Assert.assertNull(item.getItemProperty(ID1)); + } + + public void testRemovePropertyOrder() { + PropertysetItem item = createPropertySetItem(); + item.addItemProperty(ID1, prop1); + item.addItemProperty(ID2, prop2); + item.addItemProperty(ID3, prop3); + + item.removeItemProperty(ID2); + + Iterator<?> it = item.getItemPropertyIds().iterator(); + Assert.assertEquals(ID1, it.next()); + Assert.assertEquals(ID3, it.next()); + } + + public void testRemoveNonExistentListener() { + PropertysetItem item = createPropertySetItem(); + item.removeListener(propertySetListenerMock); + } + + public void testRemoveListenerTwice() { + PropertysetItem item = createPropertySetItem(); + item.addListener(propertySetListenerMock); + item.removeListener(propertySetListenerMock); + item.removeListener(propertySetListenerMock); + } + + public void testAddPropertyNotification() { + // exactly one notification each time + PropertysetItem item = createPropertySetItem(); + + // Expectations and start test + propertySetListenerMock.itemPropertySetChange(EasyMock + .isA(PropertySetChangeEvent.class)); + EasyMock.replay(propertySetListenerMock); + + // Add listener and add a property -> should end up in listener once + item.addListener(propertySetListenerMock); + item.addItemProperty(ID1, prop1); + + // Ensure listener was called once + EasyMock.verify(propertySetListenerMock); + + // Remove the listener -> should not end up in listener when adding a + // property + item.removeListener(propertySetListenerMock); + item.addItemProperty(ID2, prop2); + + // Ensure listener still has been called only once + EasyMock.verify(propertySetListenerMock); + } + + public void testRemovePropertyNotification() { + // exactly one notification each time + PropertysetItem item = createPropertySetItem(); + item.addItemProperty(ID1, prop1); + item.addItemProperty(ID2, prop2); + + // Expectations and start test + propertySetListenerMock.itemPropertySetChange(EasyMock + .isA(PropertySetChangeEvent.class)); + EasyMock.replay(propertySetListenerMock); + + // Add listener and add a property -> should end up in listener once + item.addListener(propertySetListenerMock); + item.removeItemProperty(ID1); + + // Ensure listener was called once + EasyMock.verify(propertySetListenerMock); + + // Remove the listener -> should not end up in listener + item.removeListener(propertySetListenerMock); + item.removeItemProperty(ID2); + + // Ensure listener still has been called only once + EasyMock.verify(propertySetListenerMock); + } + + public void testItemEqualsNull() { + PropertysetItem item = createPropertySetItem(); + + Assert.assertFalse(item.equals(null)); + } + + public void testEmptyItemEquals() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + Assert.assertTrue(item1.equals(item2)); + } + + public void testItemEqualsSingleProperty() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + item2.addItemProperty(ID1, prop1); + PropertysetItem item3 = createPropertySetItem(); + item3.addItemProperty(ID1, prop1); + PropertysetItem item4 = createPropertySetItem(); + item4.addItemProperty(ID1, prop2); + PropertysetItem item5 = createPropertySetItem(); + item5.addItemProperty(ID2, prop2); + + Assert.assertFalse(item1.equals(item2)); + Assert.assertFalse(item1.equals(item3)); + Assert.assertFalse(item1.equals(item4)); + Assert.assertFalse(item1.equals(item5)); + + Assert.assertTrue(item2.equals(item3)); + Assert.assertFalse(item2.equals(item4)); + Assert.assertFalse(item2.equals(item5)); + + Assert.assertFalse(item3.equals(item4)); + Assert.assertFalse(item3.equals(item5)); + + Assert.assertFalse(item4.equals(item5)); + + Assert.assertFalse(item2.equals(item1)); + } + + public void testItemEqualsMultipleProperties() { + PropertysetItem item1 = createPropertySetItem(); + item1.addItemProperty(ID1, prop1); + + PropertysetItem item2 = createPropertySetItem(); + item2.addItemProperty(ID1, prop1); + item2.addItemProperty(ID2, prop2); + + PropertysetItem item3 = createPropertySetItem(); + item3.addItemProperty(ID1, prop1); + item3.addItemProperty(ID2, prop2); + + Assert.assertFalse(item1.equals(item2)); + + Assert.assertTrue(item2.equals(item3)); + } + + public void testItemEqualsPropertyOrder() { + PropertysetItem item1 = createPropertySetItem(); + item1.addItemProperty(ID1, prop1); + item1.addItemProperty(ID2, prop2); + + PropertysetItem item2 = createPropertySetItem(); + item2.addItemProperty(ID2, prop2); + item2.addItemProperty(ID1, prop1); + + Assert.assertFalse(item1.equals(item2)); + } + + public void testEqualsSingleListener() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + item1.addListener(propertySetListenerMock); + + Assert.assertFalse(item1.equals(item2)); + Assert.assertFalse(item2.equals(item1)); + + item2.addListener(propertySetListenerMock); + + Assert.assertTrue(item1.equals(item2)); + Assert.assertTrue(item2.equals(item1)); + } + + public void testEqualsMultipleListeners() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + item1.addListener(propertySetListenerMock); + item1.addListener(propertySetListenerMock2); + + item2.addListener(propertySetListenerMock); + + Assert.assertFalse(item1.equals(item2)); + Assert.assertFalse(item2.equals(item1)); + + item2.addListener(propertySetListenerMock2); + + Assert.assertTrue(item1.equals(item2)); + Assert.assertTrue(item2.equals(item1)); + } + + public void testEqualsAddRemoveListener() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + item1.addListener(propertySetListenerMock); + item1.removeListener(propertySetListenerMock); + + Assert.assertTrue(item1.equals(item2)); + Assert.assertTrue(item2.equals(item1)); + } + + public void testItemHashCodeEmpty() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + } + + public void testItemHashCodeAddProperties() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + + item1.addItemProperty(ID1, prop1); + item1.addItemProperty(ID2, prop2); + // hashCodes can be equal even if items are different + + item2.addItemProperty(ID1, prop1); + item2.addItemProperty(ID2, prop2); + // but here hashCodes must be equal + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + } + + public void testItemHashCodeAddListeners() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + + item1.addListener(propertySetListenerMock); + // hashCodes can be equal even if items are different + + item2.addListener(propertySetListenerMock); + // but here hashCodes must be equal + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + } + + public void testItemHashCodeAddRemoveProperty() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + item1.addItemProperty(ID1, prop1); + item1.removeItemProperty(ID1); + + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + } + + public void testItemHashCodeAddRemoveListener() { + PropertysetItem item1 = createPropertySetItem(); + PropertysetItem item2 = createPropertySetItem(); + + item1.addListener(propertySetListenerMock); + item1.removeListener(propertySetListenerMock); + + Assert.assertEquals(item1.hashCode(), item2.hashCode()); + } + + public void testToString() { + // toString() behavior is specified in the class javadoc + PropertysetItem item = createPropertySetItem(); + + Assert.assertEquals("", item.toString()); + + item.addItemProperty(ID1, prop1); + + Assert.assertEquals(String.valueOf(prop1), item.toString()); + + item.addItemProperty(ID2, prop2); + + Assert.assertEquals( + String.valueOf(prop1) + " " + String.valueOf(prop2), + item.toString()); + } + +} diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1225.java b/tests/src/com/vaadin/tests/tickets/Ticket1225.java index 5244308f45..998b81ac77 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1225.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1225.java @@ -2,11 +2,13 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; -import com.vaadin.ui.ExpandLayout; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Label; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; /** @@ -23,11 +25,11 @@ public class Ticket1225 extends Application { "Test app to break layout fuction in IE7"); setMainWindow(mainWin); - SplitPanel sp = new SplitPanel(); + SplitPanel sp = new VerticalSplitPanel(); sp.setFirstComponent(new Label("First")); - ExpandLayout el = new ExpandLayout(); + VerticalLayout el = new VerticalLayout(); sp.setSecondComponent(el); el.setMargin(true); @@ -49,20 +51,19 @@ public class Ticket1225 extends Application { // red.setSizeFull(); // el.addComponent(testTable); - // el.expand(testTable); + // el.setExpandRatio(testTable,1); el.addComponent(ts); - el.expand(ts); + el.setExpandRatio(ts, 1); ts.addComponent(red); - ts.setTabCaption(red, "REd tab"); + ts.getTab(red).setCaption("REd tab"); Label l = new Label("<div style='background:blue;'>sdf</div>", Label.CONTENT_XHTML); el.addComponent(l); - el.setComponentAlignment(l, ExpandLayout.ALIGNMENT_RIGHT, - ExpandLayout.ALIGNMENT_VERTICAL_CENTER); + el.setComponentAlignment(l, Alignment.MIDDLE_RIGHT); - mainWin.setLayout(sp); + mainWin.setContent(sp); } }
\ No newline at end of file diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1230.java b/tests/src/com/vaadin/tests/tickets/Ticket1230.java index 03e89aa355..740f79337a 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1230.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1230.java @@ -22,7 +22,7 @@ public class Ticket1230 extends Application { setMainWindow(w); GridLayout layout = new GridLayout(5, 5); - w.setLayout(layout); + w.setContent(layout); layout.setSpacing(true); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1245.java b/tests/src/com/vaadin/tests/tickets/Ticket1245.java index c2a150b8ba..e83ac6aded 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1245.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1245.java @@ -5,11 +5,11 @@ import com.vaadin.data.Property; import com.vaadin.ui.AbstractSelect;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
-import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
public class Ticket1245 extends com.vaadin.Application {
@@ -35,12 +35,12 @@ class TreeExample extends CustomComponent { Tree tree;
public TreeExample() {
- final OrderedLayout main = new OrderedLayout();
+ final VerticalLayout main = new VerticalLayout();
setCompositionRoot(main);
// Panel w/ Tree
- main.setStyleName(Panel.STYLE_LIGHT);
- main.setWidth(200);
+ main.setStyleName(Reindeer.PANEL_LIGHT);
+ main.setWidth("200px");
// // Description, this is needed. Works in first slot
main.addComponent(new Label(desc));
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1362Login.java b/tests/src/com/vaadin/tests/tickets/Ticket1362Login.java index 6d20b7c1cd..d8fdefbd38 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1362Login.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1362Login.java @@ -16,9 +16,9 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Embedded; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Window.Notification; @@ -89,23 +89,22 @@ public class Ticket1362Login extends Application { private ParameterHandler paramHandler = new ParameterHandler() { - public void handleParameters(Map parameters) { + public void handleParameters(Map<String, String[]> parameters) { if (parameters.containsKey("username")) { getWindow().addURIHandler(uriHandler); - HashMap params = new HashMap(); + HashMap<String, String> params = new HashMap<String, String>(); // expecting single params - for (Iterator it = parameters.keySet().iterator(); it + for (Iterator<String> it = parameters.keySet().iterator(); it .hasNext();) { - String key = (String) it.next(); - String value = ((String[]) parameters.get(key))[0]; + String key = it.next(); + String value = (parameters.get(key))[0]; params.put(key, value); } LoginEvent event = new LoginEvent(params); - for (Iterator iterator = listeners.iterator(); iterator - .hasNext();) { - LoginListener listener = (LoginListener) iterator - .next(); + for (Iterator<LoginListener> iterator = listeners + .iterator(); iterator.hasNext();) { + LoginListener listener = iterator.next(); listener.onLogin(event); } } @@ -125,7 +124,7 @@ public class Ticket1362Login extends Application { } }; - private LinkedList listeners = new LinkedList(); + private LinkedList<LoginListener> listeners = new LinkedList<LoginListener>(); private Window window; @@ -159,9 +158,9 @@ public class Ticket1362Login extends Application { */ public class LoginEvent { - private Map params; + private Map<String, String> params; - private LoginEvent(Map params) { + private LoginEvent(Map<String, String> params) { this.params = params; } @@ -173,7 +172,7 @@ public class Ticket1362Login extends Application { */ public String getLoginParameter(String name) { if (params.containsKey(name)) { - return (String) params.get(name); + return params.get(name); } else { return null; } @@ -221,7 +220,7 @@ public class Ticket1362Login extends Application { private Panel mainPanel; - private ExpandLayout el; + private VerticalLayout el; @Override public void init() { @@ -229,15 +228,15 @@ public class Ticket1362Login extends Application { final Window mainWin = new Window( "Test app with password manager savvy login functionality"); - el = new ExpandLayout(); + el = new VerticalLayout(); currentUser.setCaption("Currennt user"); el.addComponent(currentUser); el.addComponent(loginBox); - el.expand(loginBox); + el.setExpandRatio(loginBox, 1); - mainWin.setLayout(el); + mainWin.setContent(el); setMainWindow(mainWin); @@ -260,9 +259,9 @@ public class Ticket1362Login extends Application { currentUser.setValue(username); currentUser.getWindow().showNotification( "Logged in user: " + username); - getMainWindow().getLayout().replaceComponent(loginBox, + getMainWindow().getContent().replaceComponent(loginBox, mainPanel); - el.expand(mainPanel); + el.setExpandRatio(mainPanel, 1); } else { getMainWindow().showNotification( "Wrong password. Hint, try '1234' ", diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1397.java b/tests/src/com/vaadin/tests/tickets/Ticket1397.java index b56620365c..282df33d89 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1397.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1397.java @@ -26,7 +26,8 @@ public class Ticket1397 extends Application { Panel panel = new Panel("PopupTest"); // First test component - final ObjectProperty prop = new ObjectProperty("fooTextField"); + final ObjectProperty<String> prop = new ObjectProperty<String>( + "fooTextField"); PopupView.Content content = new PopupView.Content() { public String getMinimizedValueAsHTML() { @@ -48,16 +49,15 @@ public class Ticket1397 extends Application { panel.addComponent(pe2); // Third test component - final ObjectProperty prop2 = new ObjectProperty(new StringBuffer( - "Text for button")); + final ObjectProperty<StringBuffer> prop2 = new ObjectProperty<StringBuffer>( + new StringBuffer("Text for button")); class myButton extends Button { public myButton() { super("Reverse the property"); this.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { - StringBuffer getContents = (StringBuffer) prop2 - .getValue(); + StringBuffer getContents = prop2.getValue(); getContents.reverse(); } @@ -83,7 +83,8 @@ public class Ticket1397 extends Application { // Fourth test component final Panel panel3 = new Panel("Editor popup for a property"); TextField tf2 = new TextField("TextField for editing a property"); - final ObjectProperty op = new ObjectProperty("This is property text."); + final ObjectProperty<String> op = new ObjectProperty<String>( + "This is property text."); tf2.setPropertyDataSource(op); panel3.addComponent(tf2); PopupView.Content content3 = new PopupView.Content() { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1435.java b/tests/src/com/vaadin/tests/tickets/Ticket1435.java index 2d406e5a18..b961c0d6b1 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1435.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1435.java @@ -1,17 +1,18 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.ExpandLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1435 extends Application { @@ -23,7 +24,7 @@ public class Ticket1435 extends Application { final Window mainWin = new Window("ButtonPanel containing a table test"); setMainWindow(mainWin); - ((OrderedLayout) mainWin.getLayout()).setSpacing(true); + ((AbstractOrderedLayout) mainWin.getContent()).setSpacing(true); ButtonPanel dataCardView1 = buildButtonPanel("My Tickets"); ButtonPanel dataCardView2 = buildButtonPanel("My Tickets 2"); @@ -42,12 +43,11 @@ public class Ticket1435 extends Application { */ public class ButtonPanel extends CustomComponent { - ExpandLayout root = new ExpandLayout(); + VerticalLayout root = new VerticalLayout(); // In header are the panel's title and the control buttons. // Panel title is expanded by default. - ExpandLayout header = new ExpandLayout( - ExpandLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout header = new HorizontalLayout(); // This is where the actual data is put. Panel container = new Panel(); @@ -81,8 +81,7 @@ public class Ticket1435 extends Application { buttonContainer = header; } else { - buttonContainer = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + buttonContainer = new HorizontalLayout(); header.addComponent(buttonContainer); } @@ -157,10 +156,10 @@ public class Ticket1435 extends Application { private void initContainer() { container.setStyleName("custompanel"); container.setSizeFull(); - container.getLayout().setMargin(false); - container.getLayout().setSizeFull(); + ((Layout) container.getContent()).setMargin(false); + container.getContent().setSizeFull(); root.addComponent(container); - root.expand(container); + root.setExpandRatio(container, 1); } public void setHeight(int height, int unit) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1444.java b/tests/src/com/vaadin/tests/tickets/Ticket1444.java index 2944f460f6..003b50240b 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1444.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1444.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1444 extends Application { @@ -14,7 +14,7 @@ public class Ticket1444 extends Application { "Test app to break layout fuction in IE7"); setMainWindow(mainWin); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); ol.setHeight("250px"); ol.setWidth("500px"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1506_Panel.java b/tests/src/com/vaadin/tests/tickets/Ticket1506_Panel.java index edbfd8928d..37690612ed 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1506_Panel.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1506_Panel.java @@ -14,15 +14,16 @@ import com.vaadin.ui.Select; public class Ticket1506_Panel extends Panel {
public Ticket1506_Panel() {
- ObjectProperty property1 = new ObjectProperty(null, String.class);
+ ObjectProperty<String> property1 = new ObjectProperty<String>(null,
+ String.class);
addComponent(initSelect(new Ticket1506_TestContainer(), "Test select",
property1));
addComponent(initButton(property1));
addComponent(initSelect(new Ticket1506_TestContainer2(),
- "Test select 2", new ObjectProperty(null, String.class)));
+ "Test select 2", new ObjectProperty<String>(null, String.class)));
}
- private Component initButton(final ObjectProperty property) {
+ private Component initButton(final ObjectProperty<?> property) {
Button button = new Button("Clear select");
button.addListener(new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
@@ -33,7 +34,7 @@ public class Ticket1506_Panel extends Panel { }
private Component initSelect(Container containerDataSource, String caption,
- ObjectProperty property) {
+ ObjectProperty<?> property) {
Select select = new Select(caption);
select.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
select.setImmediate(true);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer.java b/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer.java index a9423f5b3e..b8b6cfe5dd 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer.java @@ -16,7 +16,7 @@ import com.vaadin.data.util.PropertysetItem; * @version $Revision$, $Date$
*/
public class Ticket1506_TestContainer implements Container {
- private Map items = new HashMap();
+ private Map<String, PropertysetItem> items = new HashMap<String, PropertysetItem>();
public static final String ITEM_1_ID = "1";
public static final String ITEM_2_ID = "2";
public static final String PROPERTY_1_ID = "property 1";
@@ -24,17 +24,17 @@ public class Ticket1506_TestContainer implements Container { private void loadItems() {
final PropertysetItem item1 = new PropertysetItem();
- item1.addItemProperty(PROPERTY_1_ID, new ObjectProperty("value 1",
- String.class));
- item1.addItemProperty(PROPERTY_2_ID, new ObjectProperty("name 1",
- String.class));
+ item1.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
+ "value 1", String.class));
+ item1.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
+ "name 1", String.class));
items.put(ITEM_1_ID, item1);
final PropertysetItem item2 = new PropertysetItem();
- item2.addItemProperty(PROPERTY_1_ID, new ObjectProperty("value 2",
- String.class));
- item2.addItemProperty(PROPERTY_2_ID, new ObjectProperty("name 2",
- String.class));
+ item2.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
+ "value 2", String.class));
+ item2.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
+ "name 2", String.class));
items.put(ITEM_2_ID, item2);
}
@@ -42,24 +42,24 @@ public class Ticket1506_TestContainer implements Container { if (items.isEmpty()) {
loadItems();
}
- return (Item) items.get(itemId);
+ return items.get(itemId);
}
- public Collection getContainerPropertyIds() {
+ public Collection<String> getContainerPropertyIds() {
if (items.isEmpty()) {
loadItems();
}
- ArrayList a = new ArrayList();
+ ArrayList<String> a = new ArrayList<String>();
a.add(PROPERTY_1_ID);
a.add(PROPERTY_2_ID);
return a;
}
- public Collection getItemIds() {
+ public Collection<String> getItemIds() {
if (items.isEmpty()) {
loadItems();
}
- ArrayList a = new ArrayList();
+ ArrayList<String> a = new ArrayList<String>();
a.add(ITEM_1_ID);
a.add(ITEM_2_ID);
return a;
@@ -69,14 +69,14 @@ public class Ticket1506_TestContainer implements Container { if (items.isEmpty()) {
loadItems();
}
- Item item = (Item) items.get(itemId);
+ Item item = items.get(itemId);
if (item != null) {
return item.getItemProperty(propertyId);
}
return null;
}
- public Class getType(Object propertyId) {
+ public Class<String> getType(Object propertyId) {
if (items.isEmpty()) {
loadItems();
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java b/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java index 46be7e9fe4..c39454027a 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java @@ -16,7 +16,7 @@ import com.vaadin.data.util.PropertysetItem; * @version $Revision$, $Date$
*/
public class Ticket1506_TestContainer2 implements Container {
- private Map items = new HashMap();
+ private Map<String, PropertysetItem> items = new HashMap<String, PropertysetItem>();
public static final String ITEM_1_ID = "1";
public static final String ITEM_2_ID = "2";
public static final String PROPERTY_1_ID = "property 1";
@@ -25,10 +25,10 @@ public class Ticket1506_TestContainer2 implements Container { private void loadItems() {
for (int i = 1; i < 15; i++) {
final PropertysetItem item = new PropertysetItem();
- item.addItemProperty(PROPERTY_1_ID, new ObjectProperty(
+ item.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
"value " + i, String.class));
- item.addItemProperty(PROPERTY_2_ID, new ObjectProperty("name " + i,
- String.class));
+ item.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
+ "name " + i, String.class));
items.put(String.valueOf(i), item);
}
}
@@ -37,20 +37,20 @@ public class Ticket1506_TestContainer2 implements Container { if (items.isEmpty()) {
loadItems();
}
- return (Item) items.get(itemId);
+ return items.get(itemId);
}
- public Collection getContainerPropertyIds() {
+ public Collection<String> getContainerPropertyIds() {
if (items.isEmpty()) {
loadItems();
}
- ArrayList a = new ArrayList();
+ ArrayList<String> a = new ArrayList<String>();
a.add(PROPERTY_1_ID);
a.add(PROPERTY_2_ID);
return a;
}
- public Collection getItemIds() {
+ public Collection<String> getItemIds() {
if (items.isEmpty()) {
loadItems();
}
@@ -61,14 +61,14 @@ public class Ticket1506_TestContainer2 implements Container { if (items.isEmpty()) {
loadItems();
}
- Item item = (Item) items.get(itemId);
+ Item item = items.get(itemId);
if (item != null) {
return item.getItemProperty(propertyId);
}
return null;
}
- public Class getType(Object propertyId) {
+ public Class<String> getType(Object propertyId) {
if (items.isEmpty()) {
loadItems();
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1572.java b/tests/src/com/vaadin/tests/tickets/Ticket1572.java index b82c8469ad..a928e0f69c 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1572.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1572.java @@ -3,8 +3,8 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;
@@ -23,7 +23,7 @@ public class Ticket1572 extends com.vaadin.Application { Panel p = new Panel("Test wrapper for gridlayout margin/spacing");
- p.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
+ p.setContent(new HorizontalLayout());
gl = new GridLayout(3, 3);
gl.setMargin(true);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1710.java b/tests/src/com/vaadin/tests/tickets/Ticket1710.java index a19dde5b34..abf981f251 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1710.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1710.java @@ -1,75 +1,62 @@ package com.vaadin.tests.tickets;
import java.util.Iterator;
-import java.util.LinkedList;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.MethodProperty;
-import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.SystemError;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.DateField;
-import com.vaadin.ui.ExpandLayout;
import com.vaadin.ui.Form;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1710 extends com.vaadin.Application {
- LinkedList listOfAllFields = new LinkedList();
-
+ @Override
public void init() {
setTheme("tests-tickets");
- OrderedLayout lo = new OrderedLayout();
+ VerticalLayout lo = new VerticalLayout();
setMainWindow(new Window("#1710", lo));
lo.setMargin(true);
lo.setSpacing(true);
lo.setWidth("100%");
// Hiding controls
- OrderedLayout hidingControls = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout hidingControls = new HorizontalLayout();
lo.addComponent(hidingControls);
// OrderedLayout
- final OrderedLayout orderedLayout = new OrderedLayout();
+ final VerticalLayout orderedLayout = new VerticalLayout();
LayoutTestingPanel oltp = new LayoutTestingPanel("OrderedLayout",
orderedLayout);
- hidingControls.addComponent(new Button("OrderedLayout",
- new MethodProperty(oltp, "visible")));
+ hidingControls.addComponent(new CheckBox("OrderedLayout",
+ new MethodProperty<Boolean>(oltp, "visible")));
lo.addComponent(oltp);
orderedLayout.setSpacing(false);
addFields(orderedLayout);
- final Button orientationButton = new Button("horizontal orientation",
- false);
- orientationButton.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- orderedLayout.setOrientation(orientationButton.booleanValue() ? OrderedLayout.ORIENTATION_HORIZONTAL
- : OrderedLayout.ORIENTATION_VERTICAL);
- }
- });
- orientationButton.setImmediate(true);
- oltp.controls.addComponent(orientationButton);
// GridLayout
GridLayout grid = new GridLayout(1, 1);
Panel g1tp = new LayoutTestingPanel("Gridlayout with 1 column", grid);
- hidingControls.addComponent(new Button("GridLayout (1col)",
- new MethodProperty(g1tp, "visible")));
+ hidingControls.addComponent(new CheckBox("GridLayout (1col)",
+ new MethodProperty<Boolean>(g1tp, "visible")));
g1tp.setVisible(false);
lo.addComponent(g1tp);
grid.setSpacing(true);
@@ -77,59 +64,59 @@ public class Ticket1710 extends com.vaadin.Application { GridLayout grid2 = new GridLayout(2, 1);
Panel g2tp = new LayoutTestingPanel("Gridlayout with 2 columns", grid2);
hidingControls.addComponent(new Button("GridLayout (2cols)",
- new MethodProperty(g2tp, "visible")));
+ new MethodProperty<Boolean>(g2tp, "visible")));
g2tp.setVisible(false);
lo.addComponent(g2tp);
grid2.setSpacing(true);
addFields(grid2);
// ExpandLayout
- ExpandLayout el = new ExpandLayout();
+ VerticalLayout el = new VerticalLayout();
Panel elp = new LayoutTestingPanel(
"ExpandLayout width first component expanded", el);
hidingControls.addComponent(new Button("ExpandLayout (vertical)",
- new MethodProperty(elp, "visible")));
+ new MethodProperty<Boolean>(elp, "visible")));
elp.setVisible(false);
- el.setHeight(700);
+ el.setHeight("700px");
addFields(el);
- Component firstComponent = (Component) el.getComponentIterator().next();
+ Component firstComponent = el.getComponentIterator().next();
firstComponent.setSizeFull();
- el.expand(firstComponent);
+ el.setExpandRatio(firstComponent, 1);
lo.addComponent(elp);
- ExpandLayout elh = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout elh = new HorizontalLayout();
Panel elhp = new LayoutTestingPanel(
"ExpandLayout width first component expanded; horizontal", elh);
hidingControls.addComponent(new Button("ExpandLayout (horizontal)",
- new MethodProperty(elhp, "visible")));
+ new MethodProperty<Boolean>(elhp, "visible")));
elhp.setVisible(false);
elhp.setScrollable(true);
- elh.setWidth(2000);
- elh.setHeight(100);
+ elh.setWidth("2000px");
+ elh.setHeight("100px");
addFields(elh);
- Component firstComponentElh = (Component) elh.getComponentIterator()
- .next();
+ Component firstComponentElh = elh.getComponentIterator().next();
firstComponentElh.setSizeFull();
- elh.expand(firstComponentElh);
+ elh.setExpandRatio(firstComponentElh, 1);
lo.addComponent(elhp);
// CustomLayout
- OrderedLayout cl = new OrderedLayout();
+ VerticalLayout cl = new VerticalLayout();
Panel clp = new LayoutTestingPanel("CustomLayout", cl);
hidingControls.addComponent(new Button("CustomLayout",
- new MethodProperty(clp, "visible")));
+ new MethodProperty<Boolean>(clp, "visible")));
clp.setVisible(false);
lo.addComponent(clp);
cl.addComponent(new Label("<<< Add customlayout testcase here >>>"));
// Form
Panel formPanel = new Panel("Form");
- hidingControls.addComponent(new Button("Form", new MethodProperty(
- formPanel, "visible")));
+ hidingControls.addComponent(new Button("Form",
+ new MethodProperty<Boolean>(formPanel, "visible")));
formPanel.setVisible(false);
formPanel.addComponent(getFormPanelExample());
lo.addComponent(formPanel);
- for (Iterator i = hidingControls.getComponentIterator(); i.hasNext();) {
+ for (Iterator<Component> i = hidingControls.getComponentIterator(); i
+ .hasNext();) {
((AbstractComponent) i.next()).setImmediate(true);
}
@@ -141,7 +128,7 @@ public class Ticket1710 extends com.vaadin.Application { Button fb1 = new Button("Test button");
fb1.setComponentError(new SystemError("Test error"));
f.addField("fb1", fb1);
- Button fb2 = new Button("Test button", true);
+ CheckBox fb2 = new CheckBox("Test button", true);
fb2.setComponentError(new SystemError("Test error"));
f.addField("fb2", fb2);
TextField ft1 = new TextField("With caption");
@@ -163,9 +150,8 @@ public class Ticket1710 extends com.vaadin.Application { button.setComponentError(new SystemError("Test error"));
lo.addComponent(button);
- Button b2 = new Button("Test button");
+ CheckBox b2 = new CheckBox("Test button");
b2.setComponentError(new SystemError("Test error"));
- b2.setSwitchMode(true);
lo.addComponent(b2);
TextField t1 = new TextField("With caption");
@@ -202,16 +188,14 @@ public class Ticket1710 extends com.vaadin.Application { TextField t5 = new TextField();
t5.setValue("Without caption, WIDE");
t5.setComponentError(new SystemError("Error"));
- t5.setWidth(100);
- t5.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+ t5.setWidth("100%");
lo.addComponent(t5);
TextField t6 = new TextField();
t6.setValue("Without caption, With required, WIDE");
t6.setComponentError(new SystemError("Error"));
t6.setRequired(true);
- t6.setWidth(100);
- t6.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+ t6.setWidth("100%");
lo.addComponent(t6);
TextField t7 = new TextField();
@@ -238,20 +222,19 @@ public class Ticket1710 extends com.vaadin.Application { Layout testedLayout;
- OrderedLayout controls = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
- Button marginLeft = new Button("m-left", false);
- Button marginRight = new Button("m-right", false);
- Button marginTop = new Button("m-top", false);
- Button marginBottom = new Button("m-bottom", false);
- Button spacing = new Button("spacing", false);
- OrderedLayout testPanelLayout = new OrderedLayout();
+ HorizontalLayout controls = new HorizontalLayout();
+ CheckBox marginLeft = new CheckBox("m-left", false);
+ CheckBox marginRight = new CheckBox("m-right", false);
+ CheckBox marginTop = new CheckBox("m-top", false);
+ CheckBox marginBottom = new CheckBox("m-bottom", false);
+ CheckBox spacing = new CheckBox("spacing", false);
+ VerticalLayout testPanelLayout = new VerticalLayout();
LayoutTestingPanel(String caption, Layout layout) {
super(caption);
- OrderedLayout internalLayout = new OrderedLayout();
+ VerticalLayout internalLayout = new VerticalLayout();
internalLayout.setWidth("100%");
- setLayout(internalLayout);
+ setContent(internalLayout);
testedLayout = layout;
testPanelLayout.setWidth("100%");
Panel controlWrapper = new Panel();
@@ -269,15 +252,15 @@ public class Ticket1710 extends com.vaadin.Application { controls.setSpacing(true);
controls.setMargin(false);
controls.addComponent(new Label("width"));
- controls.addComponent(new TextField(new MethodProperty(
+ controls.addComponent(new TextField(new MethodProperty<Float>(
testedLayout, "width")));
- controls.addComponent(new Button("%", new MethodProperty(this,
- "widthPercents")));
+ controls.addComponent(new CheckBox("%",
+ new MethodProperty<Boolean>(this, "widthPercents")));
controls.addComponent(new Label("height"));
- controls.addComponent(new TextField(new MethodProperty(
+ controls.addComponent(new TextField(new MethodProperty<Float>(
testedLayout, "height")));
- controls.addComponent(new Button("%", new MethodProperty(this,
- "heightPercents")));
+ controls.addComponent(new CheckBox("%",
+ new MethodProperty<Boolean>(this, "heightPercents")));
controls.addComponent(marginLeft);
controls.addComponent(marginRight);
controls.addComponent(marginTop);
@@ -304,11 +287,13 @@ public class Ticket1710 extends com.vaadin.Application { testedLayout.setStyleName("tested-layout");
setStyleName("layout-testing-panel");
- for (Iterator i = controls.getComponentIterator(); i.hasNext();) {
+ for (Iterator<Component> i = controls.getComponentIterator(); i
+ .hasNext();) {
((AbstractComponent) i.next()).setImmediate(true);
}
}
+ @SuppressWarnings("deprecation")
private void addAlignmentControls() {
if (!(testedLayout instanceof Layout.AlignmentHandler)) {
return;
@@ -381,15 +366,17 @@ public class Ticket1710 extends com.vaadin.Application { public void valueChange(ValueChangeEvent event) {
testPanelLayout.setComponentAlignment(testedLayout,
((Integer) lAlign.getValue()).intValue(),
- OrderedLayout.ALIGNMENT_TOP);
+ VerticalLayout.ALIGNMENT_TOP);
}
});
}
+ @SuppressWarnings("deprecation")
private void updateAlignments(int h, int v) {
- for (Iterator i = testedLayout.getComponentIterator(); i.hasNext();) {
+ for (Iterator<Component> i = testedLayout.getComponentIterator(); i
+ .hasNext();) {
((Layout.AlignmentHandler) testedLayout).setComponentAlignment(
- (Component) i.next(), h, v);
+ i.next(), h, v);
}
}
@@ -406,22 +393,5 @@ public class Ticket1710 extends com.vaadin.Application { }
}
- public boolean getWidthPercents() {
- return testedLayout.getWidthUnits() == Sizeable.UNITS_PERCENTAGE;
- }
-
- public void setWidthPercents(boolean b) {
- testedLayout.setWidthUnits(b ? Sizeable.UNITS_PERCENTAGE
- : Sizeable.UNITS_PIXELS);
- }
-
- public boolean getHeightPercents() {
- return testedLayout.getHeightUnits() == Sizeable.UNITS_PERCENTAGE;
- }
-
- public void setHeightPercents(boolean b) {
- testedLayout.setHeightUnits(b ? Sizeable.UNITS_PERCENTAGE
- : Sizeable.UNITS_PIXELS);
- }
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1737.java b/tests/src/com/vaadin/tests/tickets/Ticket1737.java index cc44e43c46..5f8563599a 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1737.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1737.java @@ -6,9 +6,9 @@ import com.vaadin.terminal.ClassResource; import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.Resource; import com.vaadin.ui.Embedded; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1737 extends Application { @@ -32,8 +32,8 @@ public class Ticket1737 extends Application { getClass().getName().lastIndexOf(".") + 1)); setMainWindow(main); - ExpandLayout el = new ExpandLayout(); - main.setLayout(el); + VerticalLayout el = new VerticalLayout(); + main.setContent(el); Panel p = new Panel("Test panel"); p.setSizeFull(); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1804.java b/tests/src/com/vaadin/tests/tickets/Ticket1804.java index 42a9e49c98..265f3041e9 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1804.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1804.java @@ -5,7 +5,6 @@ import java.util.LinkedList; import com.vaadin.data.Validator;
import com.vaadin.data.util.MethodProperty;
-import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.SystemError;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Button;
@@ -16,7 +15,7 @@ import com.vaadin.ui.Window; public class Ticket1804 extends com.vaadin.Application {
- LinkedList listOfAllFields = new LinkedList();
+ LinkedList<Select> listOfAllFields = new LinkedList<Select>();
@Override
public void init() {
@@ -38,7 +37,7 @@ public class Ticket1804 extends com.vaadin.Application { s = new Select("Testcase from the ticket #1804");
s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty(new TestPojo(), "id"));
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
s.addValidator(new EmptyStringValidator(
"Selection required for test-field"));
s.setRequired(true);
@@ -46,14 +45,14 @@ public class Ticket1804 extends com.vaadin.Application { s = new Select("Testcase from the ticket #1804, but without validator");
s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty(new TestPojo(), "id"));
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
s.setRequired(true);
listOfAllFields.add(s);
s = new Select(
"Testcase from the ticket #1804, but with required=false");
s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty(new TestPojo(), "id"));
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
s.addValidator(new EmptyStringValidator(
"Selection required for test-field"));
listOfAllFields.add(s);
@@ -61,20 +60,20 @@ public class Ticket1804 extends com.vaadin.Application { s = new Select(
"Testcase from the ticket #1804, but without validator and with required=false");
s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty(new TestPojo(), "id"));
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
listOfAllFields.add(s);
s = new Select(
"Required=true, custom error message, null selection not allowed");
s.setRequired(true);
s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty(new TestPojo(), "id"));
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
s.setValue(null);
s.setComponentError(new SystemError("Test error message"));
listOfAllFields.add(s);
- for (Iterator i = listOfAllFields.iterator(); i.hasNext();) {
- s = (Select) i.next();
+ for (Iterator<Select> i = listOfAllFields.iterator(); i.hasNext();) {
+ s = i.next();
main.addComponent(s);
s.addItem("foo");
s.addItem("");
@@ -92,9 +91,9 @@ public class Ticket1804 extends com.vaadin.Application { public void buttonClick(ClickEvent event) {
StringBuffer msg = new StringBuffer();
- for (java.util.Iterator i = listOfAllFields.iterator(); i
+ for (Iterator<Select> i = listOfAllFields.iterator(); i
.hasNext();) {
- AbstractField af = (AbstractField) i.next();
+ AbstractField af = i.next();
msg.append("<h1>" + af.getCaption() + "</h1>\n");
msg.append("Value=" + af.getValue() + "<br/>\n");
if (af.isValid()) {
@@ -107,8 +106,7 @@ public class Ticket1804 extends com.vaadin.Application { Window w = new Window("Status of the fields");
w.setModal(true);
w.setScrollable(true);
- w.setHeight(80);
- w.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+ w.setHeight("80%");
w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
main.addWindow(w);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1805.java b/tests/src/com/vaadin/tests/tickets/Ticket1805.java index ef80904854..ad7a61d81f 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1805.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1805.java @@ -2,9 +2,11 @@ package com.vaadin.tests.tickets; import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
+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.TextField;
import com.vaadin.ui.Window;
@@ -15,7 +17,7 @@ public class Ticket1805 extends com.vaadin.Application { final Window main = new Window(getClass().getName().substring(
getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- main.getLayout().setMargin(false);
+ ((Layout) main.getContent()).setMargin(false);
Label description = new Label(
"GridLayout with 100% (no height), is wanted to "
@@ -48,8 +50,7 @@ public class Ticket1805 extends com.vaadin.Application { grid.addComponent(new Label("VEEEEEEEEEEERY_WIDE"));
Label label = new Label("|");
grid.addComponent(label);
- grid.setComponentAlignment(label, GridLayout.ALIGNMENT_RIGHT,
- GridLayout.ALIGNMENT_TOP);
+ grid.setComponentAlignment(label, Alignment.TOP_RIGHT);
main.addComponent(grid);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1806.java b/tests/src/com/vaadin/tests/tickets/Ticket1806.java index 9be7792c5d..f3406a9155 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1806.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1806.java @@ -14,7 +14,7 @@ public class Ticket1806 extends com.vaadin.Application { getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- final ObjectProperty prop = new ObjectProperty("");
+ final ObjectProperty<String> prop = new ObjectProperty<String>("");
final TextField tf1 = new TextField(
"Buffered TextField bound to ObjectProperty");
tf1.setWriteThrough(false);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1811.java b/tests/src/com/vaadin/tests/tickets/Ticket1811.java index 35c3992bf0..8f373de6bf 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1811.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1811.java @@ -13,7 +13,7 @@ import com.vaadin.ui.Window; public class Ticket1811 extends com.vaadin.Application {
- LinkedList listOfAllFields = new LinkedList();
+ LinkedList<TextField> listOfAllFields = new LinkedList<TextField>();
@Override
public void init() {
@@ -44,8 +44,8 @@ public class Ticket1811 extends com.vaadin.Application { tf4.addValidator(strLenValidator);
listOfAllFields.add(tf4);
- for (Iterator i = listOfAllFields.iterator(); i.hasNext();) {
- TextField tf = (TextField) i.next();
+ for (Iterator<TextField> i = listOfAllFields.iterator(); i.hasNext();) {
+ TextField tf = i.next();
main.addComponent(tf);
tf.setImmediate(true);
}
@@ -56,9 +56,9 @@ public class Ticket1811 extends com.vaadin.Application { public void buttonClick(ClickEvent event) {
StringBuffer msg = new StringBuffer();
- for (java.util.Iterator i = listOfAllFields.iterator(); i
+ for (Iterator<TextField> i = listOfAllFields.iterator(); i
.hasNext();) {
- TextField tf = (TextField) i.next();
+ TextField tf = i.next();
msg.append("<h1>" + tf.getCaption() + "</h1>\n");
if (tf.isValid()) {
msg.append("VALID\n<hr/>");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1819.java b/tests/src/com/vaadin/tests/tickets/Ticket1819.java index 836d6b4ae9..6f06055fc4 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1819.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1819.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Window; public class Ticket1819 extends com.vaadin.Application {
- LinkedList listOfAllFields = new LinkedList();
+ LinkedList<Select> listOfAllFields = new LinkedList<Select>();
@Override
public void init() {
@@ -30,8 +30,8 @@ public class Ticket1819 extends com.vaadin.Application { s.setNullSelectionAllowed(false);
listOfAllFields.add(s);
- for (Iterator i = listOfAllFields.iterator(); i.hasNext();) {
- s = (Select) i.next();
+ for (Iterator<Select> i = listOfAllFields.iterator(); i.hasNext();) {
+ s = i.next();
main.addComponent(s);
s.addItem("-null-");
s.addItem("");
@@ -47,9 +47,9 @@ public class Ticket1819 extends com.vaadin.Application { public void buttonClick(ClickEvent event) {
StringBuffer msg = new StringBuffer();
- for (java.util.Iterator i = listOfAllFields.iterator(); i
+ for (Iterator<Select> i = listOfAllFields.iterator(); i
.hasNext();) {
- AbstractField af = (AbstractField) i.next();
+ AbstractField af = i.next();
msg.append("<h1>" + af.getCaption() + "</h1>\n");
msg.append("Value=" + af.getValue() + "<br/>\n");
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java b/tests/src/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java index 985d52936b..7c9104e750 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java @@ -3,8 +3,8 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;
@@ -22,8 +22,7 @@ public class Ticket1834PanelScrolling extends com.vaadin.Application { getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- OrderedLayout currentState = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout currentState = new HorizontalLayout();
currentState.addComponent(state);
Button b = new Button("update");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1857.java b/tests/src/com/vaadin/tests/tickets/Ticket1857.java index 74278af70b..f82467b519 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1857.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1857.java @@ -5,10 +5,10 @@ import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; -import com.vaadin.ui.Button; -import com.vaadin.ui.ExpandLayout; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1857 extends Application implements Handler { @@ -18,7 +18,7 @@ public class Ticket1857 extends Application implements Handler { setTheme("tests-tickets"); - ExpandLayout el = new ExpandLayout(); + VerticalLayout el = new VerticalLayout(); Window main = new Window("Testcase for #1857", el); setMainWindow(main); el.setMargin(true); @@ -26,17 +26,17 @@ public class Ticket1857 extends Application implements Handler { final Table t = new Table(); el.addComponent(t); - el.expand(t); + el.setExpandRatio(t, 1); t.setSizeFull(); addContentsToTable(t); t.setStyleName("foo"); - OrderedLayout footer = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout footer = new HorizontalLayout(); el.addComponent(footer); footer.setSpacing(true); - final Button actionHandlerEnabler = new Button("Action handlers", false); + final CheckBox actionHandlerEnabler = new CheckBox("Action handlers", + false); footer.addComponent(actionHandlerEnabler); actionHandlerEnabler.setImmediate(true); actionHandlerEnabler.addListener(new Property.ValueChangeListener() { @@ -49,7 +49,7 @@ public class Ticket1857 extends Application implements Handler { } }); - final Button cellStylesEnabler = new Button("Cell styles", false); + final CheckBox cellStylesEnabler = new CheckBox("Cell styles", false); footer.addComponent(cellStylesEnabler); cellStylesEnabler.setImmediate(true); cellStylesEnabler.addListener(new Property.ValueChangeListener() { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1868.java b/tests/src/com/vaadin/tests/tickets/Ticket1868.java index 3b68146df3..edf9c1207d 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1868.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1868.java @@ -12,8 +12,8 @@ public class Ticket1868 extends com.vaadin.Application { Panel p = new Panel(
"This is a really long caption for the panel, too long in fact!");
- p.setWidth(300);
- p.setHeight(300);
+ p.setWidth("300px");
+ p.setHeight("300px");
getMainWindow().addComponent(p);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1869.java b/tests/src/com/vaadin/tests/tickets/Ticket1869.java index 6c101441a6..953217f907 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1869.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1869.java @@ -1,17 +1,14 @@ package com.vaadin.tests.tickets;
-import java.util.LinkedList;
-
import com.vaadin.ui.Button;
-import com.vaadin.ui.ExpandLayout;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1869 extends com.vaadin.Application {
- LinkedList listOfAllFields = new LinkedList();
-
@Override
public void init() {
@@ -20,38 +17,38 @@ public class Ticket1869 extends com.vaadin.Application { lo.setMargin(true);
lo.setSpacing(true);
- ExpandLayout el = new ExpandLayout();
+ VerticalLayout el = new VerticalLayout();
Panel elp = new Panel(
"Vertical ExpandLayout /w first component expanded", el);
- el.setHeight(1000);
+ el.setHeight("1000px");
for (int i = 0; i < 3; i++) {
Button b = new Button("x");
el.addComponent(b);
if (i == 0) {
b.setSizeFull();
- el.expand(b);
+ el.setExpandRatio(b, 1);
}
}
lo.addComponent(elp);
- elp.setWidth(300);
- elp.setHeight(300);
+ elp.setWidth("300px");
+ elp.setHeight("300px");
elp.setScrollable(true);
- ExpandLayout elh = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout elh = new HorizontalLayout();
Panel elph = new Panel(
"Horizontal ExpandLayout /w first component expanded", elh);
- elh.setWidth(1000);
+ elh.setWidth("1000px");
for (int i = 0; i < 3; i++) {
Button b = new Button("x");
elh.addComponent(b);
if (i == 0) {
b.setSizeFull();
- elh.expand(b);
+ elh.setExpandRatio(b, 1);
}
}
lo.addComponent(elph);
- elph.setWidth(300);
- elph.setHeight(300);
+ elph.setWidth("300px");
+ elph.setHeight("300px");
elph.setScrollable(true);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1878.java b/tests/src/com/vaadin/tests/tickets/Ticket1878.java index 711bb533f8..0bb631aab5 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1878.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1878.java @@ -10,19 +10,21 @@ import com.vaadin.data.validator.StringLengthValidator; import com.vaadin.terminal.Resource;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.UserError;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ExpandLayout;
+import com.vaadin.ui.Component;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1878 extends Application {
@@ -42,7 +44,7 @@ public class Ticket1878 extends Application { // setTheme("tests-tickets");
mainLayout = new GridLayout(1, 2);
- w.setLayout(mainLayout);
+ w.setContent(mainLayout);
orderedLayout = createOL();
gridLayout = createGL();
formLayout = createForms();
@@ -73,40 +75,34 @@ public class Ticket1878 extends Application { });
- OrderedLayout buttonLayout = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout buttonLayout = new HorizontalLayout();
buttonLayout.addComponent(switchToOrderedButton);
buttonLayout.addComponent(switchToGridButton);
buttonLayout.addComponent(switchToFormsButton);
mainLayout.addComponent(buttonLayout);
mainLayout.addComponent(orderedLayout);
- // w.setLayout(orderedLayout);
+ // w.setContent(orderedLayout);
}
private static Layout createOL() {
GridLayout layout = new GridLayout(1, 5);
GridLayout l1 = new GridLayout(1, 3);
- createLayout(l1,
- new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL),
- "1000px", "150px", "100%", null, true);
- createLayout(l1,
- new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL),
- "1000px", "150px", "50px", null, false);
+ createLayout(l1, new HorizontalLayout(), "1000px", "150px", "100%",
+ null, true);
+ createLayout(l1, new HorizontalLayout(), "1000px", "150px", "50px",
+ null, false);
GridLayout l2 = new GridLayout(6, 1);
- createLayout(l2, new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL),
- "200px", "500px", true);
- createLayout(l2, new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL),
- "200px", "500px", "100%", null, true);
- createLayout(l2, new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL),
- "150px", "500px", true);
- createLayout(l2, new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL),
- "150px", "500px", "100%", null, true);
- createLayout(l2, new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL),
- "100px", "500px", true);
- createLayout(l2, new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL),
- "100px", "500px", "100%", null, true);
+ createLayout(l2, new VerticalLayout(), "200px", "500px", true);
+ createLayout(l2, new VerticalLayout(), "200px", "500px", "100%", null,
+ true);
+ createLayout(l2, new VerticalLayout(), "150px", "500px", true);
+ createLayout(l2, new VerticalLayout(), "150px", "500px", "100%", null,
+ true);
+ createLayout(l2, new VerticalLayout(), "100px", "500px", true);
+ createLayout(l2, new VerticalLayout(), "100px", "500px", "100%", null,
+ true);
layout.addComponent(l1);
layout.addComponent(l2);
@@ -184,9 +180,9 @@ public class Ticket1878 extends Application { Random r = new Random();
GridLayout l1 = new GridLayout(1, 3);
form = createForm(l1, "200px", "500px");
- BeanItem item = new BeanItem(new FormObject());
+ BeanItem<FormObject> item = new BeanItem<FormObject>(new FormObject());
form.setItemDataSource(item);
- for (Iterator i = item.getItemPropertyIds().iterator(); i.hasNext();) {
+ for (Iterator<?> i = item.getItemPropertyIds().iterator(); i.hasNext();) {
Object property = i.next();
Field f = form.getField(property);
@@ -232,7 +228,7 @@ public class Ticket1878 extends Application { p.setWidth(w);
p.setHeight(h);
- p.getLayout().setSizeFull();
+ p.getContent().setSizeFull();
parentLayout.addComponent(p);
p.addComponent(form);
@@ -247,7 +243,7 @@ public class Ticket1878 extends Application { switchToFormsButton.setEnabled(true);
b.setEnabled(false);
- java.util.Iterator i = mainLayout.getComponentIterator();
+ Iterator<Component> i = mainLayout.getComponentIterator();
i.next();
Layout l = (Layout) i.next();
@@ -262,21 +258,19 @@ public class Ticket1878 extends Application { private static void createLayout(GridLayout parentLayout, Layout newLayout,
String w, String h, String componentWidth, String componentHeight,
boolean align) {
- int dir;
+ String dirText = "V";
String type;
- if (newLayout instanceof ExpandLayout) {
- dir = ((ExpandLayout) newLayout).getOrientation();
- type = "EL";
- } else if (newLayout instanceof OrderedLayout) {
- dir = ((OrderedLayout) newLayout).getOrientation();
+ if (newLayout instanceof VerticalLayout) {
+ type = "OL";
+ } else if (newLayout instanceof HorizontalLayout) {
+ dirText = "H";
type = "OL";
} else {
- dir = ((GridLayout) newLayout).getColumns() == 1 ? OrderedLayout.ORIENTATION_VERTICAL
- : OrderedLayout.ORIENTATION_HORIZONTAL;
+ if (((GridLayout) newLayout).getColumns() != 1) {
+ dirText = "H";
+ }
type = "GL";
}
- String dirText = (dir == OrderedLayout.ORIENTATION_HORIZONTAL ? "H"
- : "V");
String alignText = align ? "-A" : "";
String cWidth = componentWidth == null ? "" : " - " + componentWidth;
Panel p = new Panel(type + "/" + dirText + alignText + " " + w + "x"
@@ -313,8 +307,7 @@ public class Ticket1878 extends Application { if (align) {
((AlignmentHandler) newLayout).setComponentAlignment(
- tf, OrderedLayout.ALIGNMENT_RIGHT,
- OrderedLayout.ALIGNMENT_BOTTOM);
+ tf, Alignment.BOTTOM_RIGHT);
}
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1904.java b/tests/src/com/vaadin/tests/tickets/Ticket1904.java index 87ea8eeb1f..1d79158333 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1904.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1904.java @@ -1,9 +1,11 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1904 extends Application { @@ -19,7 +21,12 @@ public class Ticket1904 extends Application { } private void addOL(String descr, String style, boolean horizontal) { - OrderedLayout ol = new OrderedLayout(); + AbstractOrderedLayout ol; + if (horizontal) { + ol = new HorizontalLayout(); + } else { + ol = new VerticalLayout(); + } ol.setMargin(true); ol.setSpacing(true); if (style != null) { @@ -29,13 +36,10 @@ public class Ticket1904 extends Application { for (int i = 0; i < 3; i++) { Button b = new Button("Row " + (i + 1)); if (!horizontal) { - b.setWidth(500); + b.setWidth("500px"); } ol.addComponent(b); } - if (horizontal) { - ol.setOrientation(OrderedLayout.ORIENTATION_HORIZONTAL); - } getMainWindow().addComponent(ol); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1916.java b/tests/src/com/vaadin/tests/tickets/Ticket1916.java index 9976393664..d340bf144a 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1916.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1916.java @@ -2,7 +2,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.terminal.UserError; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -11,17 +12,14 @@ public class Ticket1916 extends Application { @Override public void init() { - OrderedLayout test = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout test = new HorizontalLayout(); test.setSizeFull(); TextField tf = new TextField(); tf.setComponentError(new UserError("Error message")); test.addComponent(tf); - test.setComponentAlignment(tf, - OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER, - OrderedLayout.ALIGNMENT_VERTICAL_CENTER); + test.setComponentAlignment(tf, Alignment.MIDDLE_CENTER); Window w = new Window("Test #1916", test); setMainWindow(w); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1919.java b/tests/src/com/vaadin/tests/tickets/Ticket1919.java index bf9b826b38..1e578cd8f5 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1919.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1919.java @@ -29,7 +29,7 @@ public class Ticket1919 extends com.vaadin.Application { lo.addComponent(getTestComponent());
lo.addComponent(getTestComponent());
- main.setLayout(lo);
+ main.setContent(lo);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1921.java b/tests/src/com/vaadin/tests/tickets/Ticket1921.java index 0bb79f224a..71c45c34ce 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1921.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1921.java @@ -6,7 +6,7 @@ import com.vaadin.Application; import com.vaadin.terminal.ParameterHandler; import com.vaadin.ui.Button; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1921 extends Application implements ParameterHandler { @@ -14,15 +14,15 @@ public class Ticket1921 extends Application implements ParameterHandler { int state = -1; int round = 1; Button button; - OrderedLayout outer, inner; + VerticalLayout outer, inner; @Override public void init() { - outer = new OrderedLayout(); + outer = new VerticalLayout(); setMainWindow(new Window("#1921", outer)); setTheme("tests-tickets"); - inner = new OrderedLayout(); + inner = new VerticalLayout(); outer.addComponent(inner); button = new Button("foo", this, "newState"); inner.addComponent(button); @@ -37,7 +37,7 @@ public class Ticket1921 extends Application implements ParameterHandler { public void newState() { - if (state >= 8) { + if (state >= 6) { state = 0; round++; } else { @@ -77,33 +77,14 @@ public class Ticket1921 extends Application implements ParameterHandler { break; case 6: - inner.setOrientation(inner.getOrientation() == OrderedLayout.ORIENTATION_HORIZONTAL ? OrderedLayout.ORIENTATION_VERTICAL - : OrderedLayout.ORIENTATION_HORIZONTAL); - getMainWindow() - .showNotification( - "inner swithed to " - + (inner.getOrientation() == OrderedLayout.ORIENTATION_HORIZONTAL ? "horizontal" - : "vertical")); - break; - - case 7: outer.addComponent(new Label("Added at " + button.getCaption())); break; - case 8: - outer.setOrientation(outer.getOrientation() == OrderedLayout.ORIENTATION_HORIZONTAL ? OrderedLayout.ORIENTATION_VERTICAL - : OrderedLayout.ORIENTATION_HORIZONTAL); - getMainWindow() - .showNotification( - "outer swithed to " - + (outer.getOrientation() == OrderedLayout.ORIENTATION_HORIZONTAL ? "horizontal" - : "vertical")); - break; } } - public void handleParameters(Map parameters) { - String[] s = (String[]) parameters.get("state"); + public void handleParameters(Map<String, String[]> parameters) { + String[] s = parameters.get("state"); if (s == null || s.length != 1) { return; } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1923.java b/tests/src/com/vaadin/tests/tickets/Ticket1923.java index cbbaed6c9d..9fc0ecc586 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1923.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1923.java @@ -1,8 +1,8 @@ package com.vaadin.tests.tickets;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1923 extends com.vaadin.Application {
@@ -20,7 +20,7 @@ public class Ticket1923 extends com.vaadin.Application { p = new Panel("TestPanel 250x300");
// p.getLayout().setWidth("100%");
p.setScrollable(true);
- // p.setLayout(new GridLayout(1, 100));
+ // p.setContent(new GridLayout(1, 100));
for (int i = 0; i < ROWS; i++) {
p.addComponent(new Label(
"Label"
@@ -38,14 +38,14 @@ public class Ticket1923 extends com.vaadin.Application { main.addComponent(p);
- OrderedLayout ol = new OrderedLayout();
+ VerticalLayout ol = new VerticalLayout();
p = new Panel("a");
p.addComponent(new Label("Longer than caption"));
ol.addComponent(p);
main.addComponent(ol);
- ol = new OrderedLayout();
+ ol = new VerticalLayout();
p = new Panel("captionasdfjahsdjfh this should be clipped god damn it");
// p.getLayout().setSizeFull();
p.setWidth("50px");
@@ -56,7 +56,7 @@ public class Ticket1923 extends com.vaadin.Application { main.addComponent(ol);
- ol = new OrderedLayout();
+ ol = new VerticalLayout();
p = new Panel("300x-1");
// p.getLayout().setSizeFull();
p.setWidth("300px");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1939.java b/tests/src/com/vaadin/tests/tickets/Ticket1939.java index cd1b844976..2970335d83 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1939.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1939.java @@ -3,8 +3,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1939 extends Application { @@ -14,9 +14,9 @@ public class Ticket1939 extends Application { Window w = new Window(getClass().getName()); setMainWindow(w); - final OrderedLayout l = new OrderedLayout(); - l.setWidth(400); - l.setHeight(100); + final VerticalLayout l = new VerticalLayout(); + l.setWidth("400px"); + l.setHeight("100px"); l.addComponent(new TextField("This one works fine")); TextField t = new TextField(); t.setRequired(true); @@ -27,7 +27,7 @@ public class Ticket1939 extends Application { w.addComponent(new Button("show me the bug", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - l.setWidth(-1); + l.setWidth(null); } })); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1940.java b/tests/src/com/vaadin/tests/tickets/Ticket1940.java index 129a761e1c..a3264ecba4 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1940.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1940.java @@ -1,8 +1,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1940 extends Application { @@ -12,9 +12,9 @@ public class Ticket1940 extends Application { final Window w = new Window(getClass().getName()); setMainWindow(w); - final OrderedLayout l = new OrderedLayout(); - l.setWidth(200); - l.setHeight(-1); + final VerticalLayout l = new VerticalLayout(); + l.setWidth("200px"); + l.setHeight(null); TextField t = new TextField(); l.addComponent(t); t.setRequired(true); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1966.java b/tests/src/com/vaadin/tests/tickets/Ticket1966.java index 2d0ec54992..5f1f152f3f 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1966.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1966.java @@ -1,44 +1,27 @@ package com.vaadin.tests.tickets;
-import java.util.HashMap;
-import java.util.Map;
-
import com.vaadin.Application;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1966 extends Application {
- private static final int LEFT = OrderedLayout.ALIGNMENT_LEFT;
- private static final int CENTER = OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER;
- private static final int RIGHT = OrderedLayout.ALIGNMENT_RIGHT;
- private static final int TOP = OrderedLayout.ALIGNMENT_TOP;
- private static final int VCENTER = OrderedLayout.ALIGNMENT_VERTICAL_CENTER;
- private static final int BOTTOM = OrderedLayout.ALIGNMENT_BOTTOM;
-
- private static Map names = new HashMap();
- static {
- names.put(new Integer(LEFT), "Left");
- names.put(new Integer(CENTER), "Center");
- names.put(new Integer(RIGHT), "Right");
- names.put(new Integer(BOTTOM), "Bottom");
- names.put(new Integer(VCENTER), "Vcenter");
- names.put(new Integer(TOP), "Top");
- }
-
@Override
public void init() {
Window w = new Window(getClass().getName());
setMainWindow(w);
// setTheme("tests-tickets");
- w.setLayout(new GridLayout(2, 2));
+ w.setContent(new GridLayout(2, 2));
// w.getLayout().setSizeFull();
- createUI(w.getLayout());
+ createUI((Layout) w.getContent());
}
private void createUI(Layout layout) {
@@ -70,7 +53,7 @@ public class Ticket1966 extends Application { addButtons(gl);
b = new Button("High button");
- b.setHeight(200);
+ b.setHeight("200px");
gl.addComponent(b);
p.addComponent(gl);
@@ -81,7 +64,7 @@ public class Ticket1966 extends Application { Panel p = new Panel("OrderedLayout");
layout.addComponent(p);
- OrderedLayout ol = new OrderedLayout();
+ AbstractOrderedLayout ol = new VerticalLayout();
ol.setCaption("Horizontal");
// ol.setWidth("100%");
@@ -96,12 +79,12 @@ public class Ticket1966 extends Application { /* VERTICAL */
- ol = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
+ ol = new HorizontalLayout();
ol.setCaption("Vertical");
addButtons(ol);
b = new Button("High button");
- b.setHeight(200);
+ b.setHeight("200px");
ol.addComponent(b);
p.addComponent(ol);
@@ -109,18 +92,18 @@ public class Ticket1966 extends Application { }
private void addButtons(Layout ol) {
- ol.addComponent(getButton(ol, LEFT, TOP));
- ol.addComponent(getButton(ol, CENTER, VCENTER));
- ol.addComponent(getButton(ol, RIGHT, BOTTOM));
+ ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
+ ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
+ ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
}
- private Button getButton(Layout l, int hAlign, int vAlign) {
+ private Button getButton(Layout l, Alignment align) {
Button b = new Button("Narrow Button - "
- + names.get(new Integer(hAlign)) + " - "
- + names.get(new Integer(vAlign)));
+ + align.getHorizontalAlignment() + " - "
+ + align.getVerticalAlignment());
b.setWidth("100px");
- ((AlignmentHandler) l).setComponentAlignment(b, hAlign, vAlign);
+ ((AlignmentHandler) l).setComponentAlignment(b, align);
return b;
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1966_2.java b/tests/src/com/vaadin/tests/tickets/Ticket1966_2.java index e325922abc..65fe2cc2ff 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1966_2.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1966_2.java @@ -1,47 +1,29 @@ package com.vaadin.tests.tickets;
-import java.util.HashMap;
-import java.util.Map;
-
import com.vaadin.Application;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
-import com.vaadin.ui.ExpandLayout;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1966_2 extends Application {
- private static final int LEFT = OrderedLayout.ALIGNMENT_LEFT;
- private static final int CENTER = OrderedLayout.ALIGNMENT_HORIZONTAL_CENTER;
- private static final int RIGHT = OrderedLayout.ALIGNMENT_RIGHT;
- private static final int TOP = OrderedLayout.ALIGNMENT_TOP;
- private static final int VCENTER = OrderedLayout.ALIGNMENT_VERTICAL_CENTER;
- private static final int BOTTOM = OrderedLayout.ALIGNMENT_BOTTOM;
-
- private static Map names = new HashMap();
- static {
- names.put(new Integer(LEFT), "Left");
- names.put(new Integer(CENTER), "Center");
- names.put(new Integer(RIGHT), "Right");
- names.put(new Integer(BOTTOM), "Bottom");
- names.put(new Integer(VCENTER), "Vcenter");
- names.put(new Integer(TOP), "Top");
- }
-
@Override
public void init() {
Window w = new Window(getClass().getName());
setMainWindow(w);
- w.setLayout(new GridLayout(2, 2));
+ w.setContent(new GridLayout(2, 2));
// Panel p = new Panel("test");
// p.setWidth(500);
// p.setHeight(500);
- // p.setLayout(new GridLayout(1, 2));
+ // p.setContent(new GridLayout(1, 2));
// p.getLayout().setSizeFull();
//
// p.addComponent(new Button("asjkdfhakshdf"));
@@ -57,7 +39,7 @@ public class Ticket1966_2 extends Application { // p.addComponent(gl);
// w.getLayout().addComponent(p);
- createUI(w.getLayout());
+ createUI((Layout) w.getContent());
}
private void createUI(Layout layout) {
@@ -68,9 +50,9 @@ public class Ticket1966_2 extends Application { private void gridLayout(Layout layout) {
Panel p = new Panel("GridLayout");
- p.setWidth(500);
- p.setHeight(500);
- p.getLayout().setSizeFull();
+ p.setWidth("500px");
+ p.setHeight("500px");
+ p.getContent().setSizeFull();
layout.addComponent(p);
GridLayout gl = new GridLayout(1, 4);
@@ -104,12 +86,12 @@ public class Ticket1966_2 extends Application { private void orderedLayout(Layout layout) {
Panel p = new Panel("OrderedLayout");
- p.setWidth(500);
- p.setHeight(500);
- p.getLayout().setWidth("100%");
+ p.setWidth("500px");
+ p.setHeight("500px");
+ p.getContent().setWidth("100%");
layout.addComponent(p);
- OrderedLayout ol = new OrderedLayout();
+ AbstractOrderedLayout ol = new VerticalLayout();
// ol.setCaption("Horizontal");
ol.setWidth("100%");
addButtons(ol);
@@ -117,9 +99,9 @@ public class Ticket1966_2 extends Application { /* VERTICAL */
- ol = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
+ ol = new HorizontalLayout();
// ol.setCaption("Vertical");
- ol.setHeight(200);
+ ol.setHeight("200px");
addButtons(ol);
// Button b = new Button("High button");
// b.setHeight(200);
@@ -131,10 +113,10 @@ public class Ticket1966_2 extends Application { private void expandLayout(Layout layout) {
Panel p = new Panel("ExpandLayout");
layout.addComponent(p);
- p.getLayout().setWidth("500");
- p.getLayout().setHeight("400");
+ p.getContent().setWidth("500");
+ p.getContent().setHeight("400");
- ExpandLayout el = new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL);
+ AbstractOrderedLayout el = new VerticalLayout();
// el.setCaption("Horizontal");
// el.setSizeUndefined();
// el.setWidth("100%");
@@ -144,7 +126,7 @@ public class Ticket1966_2 extends Application { b = new Button("Wide button");
b.setWidth("100%");
// b.setHeight(200);
- // el.expand(b);
+ // el.setExpandRatio(b,1);
// el.addComponent(b);
addButtons(el);
@@ -152,14 +134,14 @@ public class Ticket1966_2 extends Application { /* VERTICAL */
- el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
+ el = new HorizontalLayout();
// el.setHeight(400);
// el.setWidth("100%");
// el.setCaption("Vertical");
addButtons(el);
// b = new Button("High button");
- // el.expand(b);
+ // el.setExpandRatio(b,1);
// b.setHeight(100);
// el.addComponent(b);
@@ -168,17 +150,17 @@ public class Ticket1966_2 extends Application { }
private void addButtons(Layout ol) {
- ol.addComponent(getButton(ol, LEFT, TOP));
- ol.addComponent(getButton(ol, CENTER, VCENTER));
- ol.addComponent(getButton(ol, RIGHT, BOTTOM));
+ ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
+ ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
+ ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
}
- private Button getButton(Layout l, int hAlign, int vAlign) {
- Button b = new Button(names.get(new Integer(hAlign)) + " - "
- + names.get(new Integer(vAlign)));
+ private Button getButton(Layout l, Alignment align) {
+ Button b = new Button(align.getHorizontalAlignment() + " - "
+ + align.getVerticalAlignment());
// b.setWidth("100");
- ((AlignmentHandler) l).setComponentAlignment(b, hAlign, vAlign);
+ ((AlignmentHandler) l).setComponentAlignment(b, align);
return b;
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1966_3.java b/tests/src/com/vaadin/tests/tickets/Ticket1966_3.java index 6cd552b6b2..e4f99b9023 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1966_3.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1966_3.java @@ -3,10 +3,11 @@ package com.vaadin.tests.tickets; import com.vaadin.Application;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.UserError;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1966_3 extends Application {
@@ -17,31 +18,29 @@ public class Ticket1966_3 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
private void createUI(GridLayout layout) {
- OrderedLayout ol = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
+ VerticalLayout ol = new VerticalLayout();
Panel p = new Panel(ol);
p.setWidth("300px");
p.setHeight("300px");
- p.getLayout().setSizeFull();
+ p.getContent().setSizeFull();
TextField tf = new TextField("Long caption, longer than 100 pixels");
tf.setWidth("100px");
ol.addComponent(tf);
- ol.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_RIGHT,
- OrderedLayout.ALIGNMENT_TOP);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
tf = new TextField("Short caption");
tf.setWidth("100px");
tf.setComponentError(new UserError("error message"));
ol.addComponent(tf);
- ol.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_RIGHT,
- OrderedLayout.ALIGNMENT_TOP);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
tf = new TextField("Short caption");
tf.setComponentError(new UserError("error message"));
@@ -50,16 +49,14 @@ public class Ticket1966_3 extends Application { tf.setComponentError(new UserError("error message"));
ol.addComponent(tf);
- ol.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_RIGHT,
- OrderedLayout.ALIGNMENT_TOP);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
tf = new TextField();
tf.setValue("No caption");
tf.setWidth("100px");
ol.addComponent(tf);
- ol.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_RIGHT,
- OrderedLayout.ALIGNMENT_TOP);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
layout.addComponent(p);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1969.java b/tests/src/com/vaadin/tests/tickets/Ticket1969.java index a1528efc08..26c1c69470 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1969.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1969.java @@ -5,9 +5,9 @@ import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1969 extends com.vaadin.Application {
@@ -18,7 +18,7 @@ public class Ticket1969 extends com.vaadin.Application { getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- main.getLayout().setSizeFull();
+ main.getContent().setSizeFull();
TabSheet ts = new TabSheet();
ts.setSizeFull();
@@ -35,7 +35,7 @@ public class Ticket1969 extends com.vaadin.Application { ts.addTab(testContent);
- final OrderedLayout actions = new OrderedLayout();
+ final VerticalLayout actions = new VerticalLayout();
actions.setCaption("Test actions");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1970.java b/tests/src/com/vaadin/tests/tickets/Ticket1970.java index c39f28bb86..1442c9ea5b 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1970.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1970.java @@ -40,8 +40,9 @@ public class Ticket1970 extends Application { public void buttonClick(ClickEvent event) { String openWindows = ""; - for (Iterator i = getWindows().iterator(); i.hasNext();) { - Window t = (Window) i.next(); + for (Iterator<Window> i = getWindows().iterator(); i + .hasNext();) { + Window t = i.next(); openWindows += (openWindows.length() > 0 ? "," : "") + t.getName(); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1972.java b/tests/src/com/vaadin/tests/tickets/Ticket1972.java index 6cbbbb9f92..86d5b0f11d 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1972.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1972.java @@ -24,7 +24,7 @@ public class Ticket1972 extends Application { layout.space();
layout.addComponent(new Label("3-3"));
- w.setLayout(layout);
+ w.setContent(layout);
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1973.java b/tests/src/com/vaadin/tests/tickets/Ticket1973.java index 4e93ef57b4..c756ca12c3 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1973.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1973.java @@ -4,8 +4,8 @@ import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket1973 extends com.vaadin.Application {
@@ -43,7 +43,7 @@ public class Ticket1973 extends com.vaadin.Application { public void fill(IndexedContainer container, int size, String prefix) {
for (int i = 0; i < size; i++) {
Item item = container.addItem(new Integer(i));
- OrderedLayout layout = new OrderedLayout();
+ VerticalLayout layout = new VerticalLayout();
layout.addComponent(new Button(prefix + i));
item.getItemProperty("layout").setValue(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1973_2.java b/tests/src/com/vaadin/tests/tickets/Ticket1973_2.java index 875cc70bc6..5cffdbd5db 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1973_2.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1973_2.java @@ -5,8 +5,8 @@ import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket1973_2 extends Application { @@ -45,7 +45,7 @@ public class Ticket1973_2 extends Application { for (int i = 0; i < size; i++) { int randInt = i; Item item = container.addItem(new Integer(i)); - OrderedLayout layout = new OrderedLayout(); + VerticalLayout layout = new VerticalLayout(); layout.setDebugId("lo" + i); layout.addComponent(new Button("Test " + randInt)); item.getItemProperty("layout").setValue(layout); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1975.java b/tests/src/com/vaadin/tests/tickets/Ticket1975.java index 9a423c9056..d162606ba7 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1975.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1975.java @@ -24,7 +24,7 @@ public class Ticket1975 extends Application { setMainWindow(w);
setTheme("tests-tickets");
GridLayout layout = new GridLayout(1, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1982.java b/tests/src/com/vaadin/tests/tickets/Ticket1982.java index 8d0f22f6a3..53e5630353 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1982.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1982.java @@ -7,14 +7,14 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Window; public class Ticket1982 extends Application { - private List components = new ArrayList(); + private List<TitleBar> components = new ArrayList<TitleBar>(); @Override public void init() { @@ -23,7 +23,7 @@ public class Ticket1982 extends Application { GridLayout gl = new GridLayout(2, 2); gl.setSizeFull(); - main.setLayout(gl); + main.setContent(gl); gl.setMargin(true); TitleBar t1 = new TitleBar("Title 1", gl); @@ -41,20 +41,20 @@ public class Ticket1982 extends Application { private void restoreComponents(GridLayout gl) { gl.removeAllComponents(); - gl.addComponent((TitleBar) components.get(0)); - gl.addComponent((TitleBar) components.get(1)); - gl.addComponent((TitleBar) components.get(2)); - gl.addComponent((TitleBar) components.get(3)); + gl.addComponent(components.get(0)); + gl.addComponent(components.get(1)); + gl.addComponent(components.get(2)); + gl.addComponent(components.get(3)); } - private class TitleBar extends ExpandLayout { + private class TitleBar extends HorizontalLayout { private Button max = new Button("Max"); private Button min = new Button("Min"); private GridLayout layout; public TitleBar(String title, GridLayout layout) { - super(ExpandLayout.ORIENTATION_HORIZONTAL); + super(); this.layout = layout; addComponent(new Label(title)); addComponent(max); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1983.java b/tests/src/com/vaadin/tests/tickets/Ticket1983.java index ec26328f6f..12198ab247 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1983.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1983.java @@ -5,10 +5,12 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.terminal.Sizeable; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -19,18 +21,17 @@ public class Ticket1983 extends Application { @Override public void init() { Window main = new Window("Test for ticket 1983"); - main.setLayout(new TestLayout()); + main.setContent(new TestLayout()); setMainWindow(main); } - private static class TestLayout extends SplitPanel { + private static class TestLayout extends HorizontalSplitPanel { boolean isLong = true; final Table table = new MyTable(); final String propId = "col"; final String propId2 = "col2"; public TestLayout() { - super(ORIENTATION_HORIZONTAL); setSplitPosition(200, Sizeable.UNITS_PIXELS); setMargin(false); @@ -39,13 +40,13 @@ public class Ticket1983 extends Application { final SplitPanel leftSide = initLeftSide(); setFirstComponent(leftSide); - final Layout rightSide = new OrderedLayout(); + final Layout rightSide = new VerticalLayout(); rightSide.setHeight("100%"); setSecondComponent(rightSide); } private SplitPanel initLeftSide() { - final SplitPanel leftSide = new SplitPanel(ORIENTATION_VERTICAL); + final SplitPanel leftSide = new HorizontalSplitPanel(); leftSide.setHeight("100%"); final IndexedContainer dataSource = new IndexedContainer(); @@ -110,11 +111,11 @@ public class Ticket1983 extends Application { } }); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); ol.addComponent(button); leftSide.setFirstComponent(ol); - button = new Button("Two col"); + button = new CheckBox("Two col"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Button b = event.getButton(); @@ -127,7 +128,6 @@ public class Ticket1983 extends Application { } }); - button.setSwitchMode(true); ol.addComponent(button); return leftSide; diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1986.java b/tests/src/com/vaadin/tests/tickets/Ticket1986.java index 1b96f7bd39..f2a173bcb0 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket1986.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket1986.java @@ -72,7 +72,7 @@ public class Ticket1986 extends Application { layout.addComponent(f2);
layout.addComponent(f1);
- w.setLayout(layout);
+ w.setContent(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket20.java b/tests/src/com/vaadin/tests/tickets/Ticket20.java index 7adb2e932e..55fee95de3 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket20.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket20.java @@ -5,6 +5,7 @@ import com.vaadin.data.Validator; import com.vaadin.data.util.MethodProperty; import com.vaadin.data.validator.CompositeValidator; import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -79,8 +80,8 @@ public class Ticket20 extends Application { "readOnly", "readThrough", "invalidCommitted", "validationVisible" }; for (int i = 0; i < visibleProps.length; i++) { - Button b = new Button(visibleProps[i], new MethodProperty(tx, - visibleProps[i])); + CheckBox b = new CheckBox(visibleProps[i], + new MethodProperty<Boolean>(tx, visibleProps[i])); b.setImmediate(true); mainWin.addComponent(b); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2001.java b/tests/src/com/vaadin/tests/tickets/Ticket2001.java index f3fbb4c508..4796451dc0 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2001.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2001.java @@ -3,9 +3,9 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2001 extends Application { @@ -15,15 +15,19 @@ public class Ticket2001 extends Application { final Window w = new Window(getClass().getName()); setMainWindow(w); - final OrderedLayout l = new OrderedLayout(); + final VerticalLayout l = new VerticalLayout(); l.addComponent(new Label("row 1")); l.addComponent(new Label("row 2")); w.addComponent(l); - final Button b = new Button("fixed width: 30px", false); + final CheckBox b = new CheckBox("fixed width: 30px", false); b.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { - l.setWidth(b.booleanValue() ? 30 : -1); + if (b.booleanValue()) { + l.setWidth("30px"); + } else { + l.setWidth(null); + } } }); b.setImmediate(true); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2002.java b/tests/src/com/vaadin/tests/tickets/Ticket2002.java index 35f2c84872..4e07230f46 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2002.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2002.java @@ -35,17 +35,17 @@ public class Ticket2002 extends Application { layout.setSpacing(true);
TextField f1 = new TextField("Non-immediate/Long text field",
- new MethodProperty(this, "long1"));
+ new MethodProperty<Long>(this, "long1"));
f1.setImmediate(false);
f1.setNullSettingAllowed(true);
TextField f2 = new TextField("Immediate/Long text field",
- new MethodProperty(this, "long2"));
+ new MethodProperty<Long>(this, "long2"));
f2.setImmediate(true);
f2.setNullSettingAllowed(true);
layout.addComponent(f1);
layout.addComponent(f2);
- w.setLayout(layout);
+ w.setContent(layout);
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2009.java b/tests/src/com/vaadin/tests/tickets/Ticket2009.java index f6d01d284c..f726ff10de 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2009.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2009.java @@ -5,12 +5,13 @@ import com.vaadin.event.ItemClickEvent; import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2009 extends com.vaadin.Application {
@@ -23,9 +24,8 @@ public class Ticket2009 extends com.vaadin.Application { getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
- OrderedLayout ol = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
- main.setLayout(ol);
+ HorizontalLayout ol = new HorizontalLayout();
+ main.setContent(ol);
ol.setSizeFull();
Panel p = new Panel("Tree test");
@@ -36,7 +36,7 @@ public class Ticket2009 extends com.vaadin.Application { t.addItem("Foo");
t.addItem("Bar");
- final OrderedLayout events = new OrderedLayout();
+ final VerticalLayout events = new VerticalLayout();
t.addListener(new ItemClickEvent.ItemClickListener() {
public void itemClick(ItemClickEvent event) {
@@ -56,7 +56,7 @@ public class Ticket2009 extends com.vaadin.Application { Panel p2 = new Panel("Table test (try dbl click also)");
p2.setSizeFull();
- final OrderedLayout events2 = new OrderedLayout();
+ final VerticalLayout events2 = new VerticalLayout();
Table table = TestForTablesInitialColumnWidthLogicRendering
.getTestTable(5, 100);
table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
@@ -105,8 +105,8 @@ public class Ticket2009 extends com.vaadin.Application { addComponent(editor);
addComponent(done);
- setWidth(W);
- setHeight(H);
+ setWidth(W + "px");
+ setHeight(H + "px");
setPositionX(event.getClientX() - W / 2);
setPositionY(event.getClientY() - H / 2);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2011.java b/tests/src/com/vaadin/tests/tickets/Ticket2011.java index d4e5890635..e28ee9b4e2 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2011.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2011.java @@ -13,7 +13,7 @@ public class Ticket2011 extends Application { setMainWindow(w);
// setTheme("tests-ticket");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2014.java b/tests/src/com/vaadin/tests/tickets/Ticket2014.java index 74b3fa3641..b005eefd03 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2014.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2014.java @@ -7,13 +7,13 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;
public class Ticket2014 extends Application {
- private OrderedLayout innerLayout1;
+ private HorizontalLayout innerLayout1;
private Button b1;
private Panel panel;
@@ -23,7 +23,7 @@ public class Ticket2014 extends Application { setMainWindow(w);
// setTheme("tests-ticket");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
@@ -45,7 +45,7 @@ public class Ticket2014 extends Application { panel = new Panel("panel caption");
layout.addComponent(panel);
- innerLayout1 = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL);
+ innerLayout1 = new HorizontalLayout();
innerLayout1.setSpacing(true);
panel.addComponent(innerLayout1);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2021.java b/tests/src/com/vaadin/tests/tickets/Ticket2021.java index 5fb6f89baf..69858a57d6 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2021.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2021.java @@ -2,21 +2,21 @@ package com.vaadin.tests.tickets; import com.vaadin.Application;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ExpandLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2021 extends Application {
- private TextField tf1, tf2, tf3;
+ private TextArea tf1, tf2, tf3;
private String contents = "This TextField SHOULD FILL the panel and NOT CAUSE any scrollbars to appear in the Panel. Scrollbars SHOULD appear in the TextField AND the whole scrollbars (includinc arrow down) SHOULD be visible.\n\n"
+ ""
@@ -24,29 +24,27 @@ public class Ticket2021 extends Application { + "Nulla nisi. Sed blandit, ante vitae sagittis volutpat, arcu mauris vehicula risus, vitae posuere felis lectus sit amet purus. Donec nec magna et leo eleifend scelerisque. Suspendisse condimentum pharetra ligula. Curabitur lorem. Pellentesque a augue sit amet enim fermentum placerat. Phasellus ante risus, molestie at, iaculis at, pellentesque non, tellus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus non urna eget risus tempus imperdiet. Integer est diam, sagittis sit amet, posuere sit amet, bibendum sed, lacus. Aenean adipiscing cursus ipsum. Quisque at elit. Vestibulum vitae nunc. Praesent placerat metus viverra lorem. Cras nec elit congue nisi faucibus feugiat. Nam eget mi. Vestibulum condimentum. Nunc nisl ante, cursus in, dictum ac, lobortis rutrum, mi. Nulla eu nisi. In ultricies vehicula magna."
+ "Nunc eros dui, elementum at, ullamcorper eget, varius at, velit. Ut dictum. Cras ullamcorper ante vel tortor. Quisque viverra mauris vulputate quam. Nulla dui. Suspendisse non eros at ipsum faucibus hendrerit. Morbi dignissim pharetra tortor. Etiam malesuada. Mauris lacinia elementum erat. Duis mollis placerat metus. Nunc risus felis, cursus ac, cursus vel, convallis vel, metus. Ut vehicula nibh et nulla. Vivamus id pede. Quisque egestas arcu a ligula. Maecenas vehicula. Quisque sed ligula quis tellus tempus rutrum. Curabitur vel augue sed orci egestas pharetra. Duis pharetra.";
- private OrderedLayout orderedLayout;
-
@Override
public void init() {
Window w = new Window(getClass().getSimpleName());
- w.setLayout(new GridLayout(2, 2));
+ w.setContent(new GridLayout(2, 2));
setMainWindow(w);
Panel p = new Panel();
p.setCaption("ExpandLayout");
p.setWidth("500px");
p.setHeight("500px");
- p.setLayout(new ExpandLayout());
- p.getLayout().setSizeFull();
+ p.setContent(new VerticalLayout());
+ p.getContent().setSizeFull();
- w.getLayout().addComponent(p);
+ w.getContent().addComponent(p);
- tf1 = new TextField();
+ tf1 = new TextArea();
tf1.setRows(5);
tf1.setSizeFull();
tf1.setValue(contents);
tf1.setCaption("TextField caption");
- p.getLayout().addComponent(tf1);
+ p.getContent().addComponent(tf1);
/*
*
@@ -57,17 +55,17 @@ public class Ticket2021 extends Application { p2.setCaption("OrderedLayout");
p2.setWidth("500px");
p2.setHeight("500px");
- p2.setLayout(new OrderedLayout());
- p2.getLayout().setSizeFull();
+ p2.setContent(new VerticalLayout());
+ p2.getContent().setSizeFull();
- w.getLayout().addComponent(p2);
+ w.getContent().addComponent(p2);
- tf2 = new TextField();
+ tf2 = new TextArea();
tf2.setRows(5);
tf2.setSizeFull();
tf2.setValue(contents);
tf2.setCaption("TextField caption");
- p2.getLayout().addComponent(tf2);
+ p2.getContent().addComponent(tf2);
/*
*
@@ -76,34 +74,34 @@ public class Ticket2021 extends Application { Panel p3 = new Panel();
p3.setCaption("GridLayout");
- p3.setWidth(500);
- p3.setHeight(500);
- // p3.setLayout(new GridLayout());
- p3.getLayout().setSizeFull();
- p3.getLayout().setMargin(false);
+ p3.setWidth("500px");
+ p3.setHeight("500px");
+ // p3.setContent(new GridLayout());
+ p3.getContent().setSizeFull();
+ ((Layout) p3.getContent()).setMargin(false);
GridLayout gl = new GridLayout();
gl.setSizeFull();
gl.setMargin(false);
- p3.getLayout().addComponent(gl);
- w.getLayout().addComponent(p3);
+ p3.getContent().addComponent(gl);
+ w.getContent().addComponent(p3);
- tf3 = new TextField();
+ tf3 = new TextArea();
tf3.setRows(5);
tf3.setSizeFull();
tf3.setValue(contents);
tf3.setCaption("TextField caption");
- // p3.getLayout().addComponent(tf3);
+ // p3.getContent().addComponent(tf3);
gl.addComponent(tf3);
// Panel pp = new Panel();
// pp.setCaption("OrderedLayout");
// pp.setWidth("500px");
// pp.setHeight("500px");
- // pp.getLayout().setSizeFull();
- // orderedLayout = new OrderedLayout();
- // pp.getLayout().addComponent(orderedLayout);
- // w.getLayout().addComponent(pp);
+ // pp.getContent().setSizeFull();
+ // orderedLayout = new VerticalLayout();
+ // pp.getContent().addComponent(orderedLayout);
+ // w.getContent().addComponent(pp);
// createUI(orderedLayout);
}
@@ -135,8 +133,8 @@ public class Ticket2021 extends Application { layout.addComponent(b);
layout.addComponent(l2);
- if (layout instanceof ExpandLayout) {
- ((ExpandLayout) layout).expand(l);
+ if (layout instanceof AbstractOrderedLayout) {
+ ((AbstractOrderedLayout) layout).setExpandRatio(l, 1);
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2022.java b/tests/src/com/vaadin/tests/tickets/Ticket2022.java index 9dfcabc208..17df2a2700 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2022.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2022.java @@ -20,7 +20,7 @@ public class Ticket2022 extends Application { l = new CustomLayout("Ticket2022");
// try {
// l = new CustomLayout(new FileInputStream(f));
- w.setLayout(l);
+ w.setContent(l);
// } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2024.java b/tests/src/com/vaadin/tests/tickets/Ticket2024.java index ffc6022f0a..5f0b432790 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2024.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2024.java @@ -3,8 +3,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2024 extends Application {
@@ -17,18 +17,18 @@ public class Ticket2024 extends Application { GridLayout layout = new GridLayout(2, 2);
layout.setHeight("100%");
layout.setWidth("700");
- w.getLayout().setSizeFull();
- w.getLayout().setHeight("2000");
- w.getLayout().addComponent(layout);
+ w.getContent().setSizeFull();
+ w.getContent().setHeight("2000");
+ w.getContent().addComponent(layout);
layout.addComponent(new Label(
"This should NOT get stuck when scrolling down"));
layout.addComponent(new TextField("This should not get stuck either..."));
- OrderedLayout ol = new OrderedLayout();
+ VerticalLayout ol = new VerticalLayout();
ol.setHeight("1000");
ol.setWidth("200");
- w.getLayout().addComponent(ol);
+ w.getContent().addComponent(ol);
ol.addComponent(new Label("Just a label to enable the scrollbar"));
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2026.java b/tests/src/com/vaadin/tests/tickets/Ticket2026.java index 4bbb9057ff..be329eb5b5 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2026.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2026.java @@ -30,6 +30,6 @@ public class Ticket2026 extends Application { tf.setTabIndex(2);
layout.addComponent(tf);
- w.setLayout(layout);
+ w.setContent(layout);
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2029.java b/tests/src/com/vaadin/tests/tickets/Ticket2029.java index 4c53e2cd9e..cabbab2c32 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2029.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2029.java @@ -6,11 +6,14 @@ import com.vaadin.Application; import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.terminal.UserError;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2029 extends Application {
@@ -29,9 +32,9 @@ public class Ticket2029 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
Panel p = createPanel();
- w.getLayout().addComponent(p);
+ w.getContent().addComponent(p);
// w.getLayout().addComponent(createGLPanel());
- w.getLayout().addComponent(createPanelV());
+ w.getContent().addComponent(createPanelV());
}
private Panel createPanel() {
@@ -39,10 +42,9 @@ public class Ticket2029 extends Application { p.setWidth(DIM1 + "px");
p.setHeight(DIM2 + "px");
- OrderedLayout layout = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
- p.setLayout(layout);
- p.getLayout().setSizeFull();
+ HorizontalLayout layout = new HorizontalLayout();
+ p.setContent(layout);
+ p.getContent().setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextField tf = new TextField();
@@ -56,8 +58,7 @@ public class Ticket2029 extends Application { tf.setComponentError(new UserError("Error"));
}
tf.setWidth("100%");
- layout.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_LEFT,
- OrderedLayout.ALIGNMENT_BOTTOM);
+ layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
p.addComponent(tf);
}
@@ -65,14 +66,15 @@ public class Ticket2029 extends Application { return p;
}
+ @SuppressWarnings("unused")
private Panel createGLPanel() {
Panel p = new Panel("" + DIM1 + "x" + DIM2 + " GridLayout");
p.setWidth("" + DIM1 + "px");
p.setHeight("" + DIM2 + "px");
GridLayout layout = new GridLayout(COMPONENTS, 1);
- p.setLayout(layout);
- p.getLayout().setSizeFull();
+ p.setContent(layout);
+ p.getContent().setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextField tf = new TextField();
@@ -95,8 +97,7 @@ public class Ticket2029 extends Application { tf.setComponentError(new UserError("Error"));
}
tf.setWidth("100%");
- layout.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_LEFT,
- OrderedLayout.ALIGNMENT_VERTICAL_CENTER);
+ layout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
p.addComponent(tf);
}
@@ -109,13 +110,12 @@ public class Ticket2029 extends Application { p.setWidth("" + DIM2 + "px");
p.setHeight("" + DIM1 + "px");
- OrderedLayout layout = new OrderedLayout(
- OrderedLayout.ORIENTATION_VERTICAL);
- p.setLayout(layout);
- p.getLayout().setSizeFull();
+ VerticalLayout layout = new VerticalLayout();
+ p.setContent(layout);
+ p.getContent().setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
- TextField tf = new TextField();
+ TextArea tf = new TextArea();
if (r.nextBoolean()) {
tf.setCaption("Caption");
}
@@ -129,8 +129,7 @@ public class Ticket2029 extends Application { tf.setRows(2);
tf.setSizeFull();
- layout.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_LEFT,
- OrderedLayout.ALIGNMENT_BOTTOM);
+ layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
p.addComponent(tf);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2037.java b/tests/src/com/vaadin/tests/tickets/Ticket2037.java index 7cbb3802da..652983c423 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2037.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2037.java @@ -4,7 +4,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2037 extends com.vaadin.Application {
@@ -17,7 +17,7 @@ public class Ticket2037 extends com.vaadin.Application { main.addComponent(new Label(
"Use debug dialog and trac number of registered paintables. It should not grow on subsequant b clicks."));
- final Layout lo = new OrderedLayout();
+ final Layout lo = new VerticalLayout();
Button b = new Button("b");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2038.java b/tests/src/com/vaadin/tests/tickets/Ticket2038.java index ff5ceb22e7..85a5a4b701 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2038.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2038.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; import com.vaadin.ui.Window.Notification; @@ -29,7 +29,7 @@ public class Ticket2038 extends Application { }); w.addComponent(tf); - final Button b = new Button( + final CheckBox b = new CheckBox( "Field should use error message. (!) should be shown when invalid.", false); w.addComponent(b); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2040.java b/tests/src/com/vaadin/tests/tickets/Ticket2040.java index e5300d5eed..f1775da039 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2040.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2040.java @@ -2,6 +2,8 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Accordion;
import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
@@ -14,8 +16,8 @@ public class Ticket2040 extends com.vaadin.Application { Window main = new Window();
setMainWindow(main);
- main.getLayout().setSizeFull();
- main.getLayout().setMargin(true);
+ main.getContent().setSizeFull();
+ ((Layout) main.getContent()).setMargin(true);
setTheme("tests-tickets");
@@ -25,7 +27,7 @@ public class Ticket2040 extends com.vaadin.Application { ts.setSizeFull();
ts.setWidth("300px");
- TextField l = new TextField("DSFS");
+ TextArea l = new TextArea("DSFS");
l.setRows(2);
l.setStyleName("red");
l.setSizeFull();
@@ -45,7 +47,7 @@ public class Ticket2040 extends com.vaadin.Application { ts.setHeight("200px");
ts.setWidth("300px");
- l = new TextField("DSFS");
+ l = new TextArea("DSFS");
l.setRows(2);
l.setStyleName("red");
l.setSizeFull();
@@ -65,7 +67,7 @@ public class Ticket2040 extends com.vaadin.Application { ts.setHeight("50%");
ts.setWidth("300px");
- l = new TextField("DSFS");
+ l = new TextArea("DSFS");
l.setRows(2);
l.setStyleName("red");
l.setSizeFull();
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2042.java b/tests/src/com/vaadin/tests/tickets/Ticket2042.java index 0c7bede4b8..2dfe4a1cb5 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2042.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2042.java @@ -18,7 +18,7 @@ public class Ticket2042 extends Application { // setTheme("tests-tickets");
GridLayout layout = new GridLayout(1, 2);
layout.setHeight("2000px");
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2043.java b/tests/src/com/vaadin/tests/tickets/Ticket2043.java index aad3cb554a..faea096744 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2043.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2043.java @@ -14,7 +14,7 @@ public class Ticket2043 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2048.java b/tests/src/com/vaadin/tests/tickets/Ticket2048.java index 12cb4269a5..65b5f73b53 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2048.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2048.java @@ -9,18 +9,15 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
-import com.vaadin.ui.SplitPanel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2048 extends Application {
private Embedded embedded;
private Panel p;
- private SplitPanel splitPanel;
- private GridLayout gridLayout;
- private OrderedLayout orderedLayout;
+ private VerticalLayout orderedLayout;
@Override
public void init() {
@@ -28,17 +25,17 @@ public class Ticket2048 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
// splitPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
- // getMainWindow().setLayout(splitPanel);
+ // getMainWindow().setContent(splitPanel);
// GridLayout layout = new GridLayout(10, 10);
- // w.setLayout(layout);
+ // w.setContent(layout);
// gridLayout = new GridLayout(1, 1);
- orderedLayout = new OrderedLayout();
+ orderedLayout = new VerticalLayout();
- getMainWindow().setLayout(orderedLayout);
- // getMainWindow().setLayout(new GridLayout(1, 1));
+ getMainWindow().setContent(orderedLayout);
+ // getMainWindow().setContent(new GridLayout(1, 1));
getMainWindow().setSizeFull();
- getMainWindow().getLayout().setSizeFull();
+ getMainWindow().getContent().setSizeFull();
createUI(orderedLayout);
// createUI(gridLayout);
@@ -51,9 +48,9 @@ public class Ticket2048 extends Application { // public void buttonClick(ClickEvent event) {
// Layout l = getMainWindow().getLayout();
// if (l == orderedLayout) {
- // getMainWindow().setLayout(gridLayout);
+ // getMainWindow().setContent(gridLayout);
// } else {
- // getMainWindow().setLayout(orderedLayout);
+ // getMainWindow().setContent(orderedLayout);
// }
//
// }
@@ -77,7 +74,7 @@ public class Ticket2048 extends Application { public void buttonClick(ClickEvent event) {
Embedded newEmbedded = new Embedded(null,
new ThemeResource("icons/64/folder-add.png"));
- getMainWindow().getLayout().replaceComponent(embedded,
+ getMainWindow().getContent().replaceComponent(embedded,
newEmbedded);
embedded = newEmbedded;
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2051.java b/tests/src/com/vaadin/tests/tickets/Ticket2051.java index b31acbde11..e901ebc343 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2051.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2051.java @@ -22,7 +22,7 @@ public class Ticket2051 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2060.java b/tests/src/com/vaadin/tests/tickets/Ticket2060.java index 70f55afbf9..63bf5b3ff7 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2060.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2060.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Window;
public class Ticket2060 extends Application {
@@ -20,13 +20,12 @@ public class Ticket2060 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
private void createUI(GridLayout layout) {
- OrderedLayout buttonLayout = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout buttonLayout = new HorizontalLayout();
button1 = new Button("Button which is 50px wide");
button1.setWidth("50px");
button2 = new Button("Button without width");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2061.java b/tests/src/com/vaadin/tests/tickets/Ticket2061.java index b6c8f1fb38..c9cc3ce328 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2061.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2061.java @@ -8,9 +8,9 @@ import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.ui.Accordion; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2061 extends Application { @@ -21,7 +21,7 @@ public class Ticket2061 extends Application { public void init() { mainWindow = new Window("Ticket 2061"); mainWindow.setSizeFull(); - mainWindow.getLayout().setSizeFull(); + mainWindow.getContent().setSizeFull(); setMainWindow(mainWindow); MyTable table1 = new MyTable(24, "table1"); @@ -46,7 +46,7 @@ public class Ticket2061 extends Application { private Table table = new Table(); private String[] columns; - private ExpandLayout layout = new ExpandLayout(); + private VerticalLayout layout = new VerticalLayout(); public MyTable(int columnNumber, String id) { setDebugId(id); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2061b.java b/tests/src/com/vaadin/tests/tickets/Ticket2061b.java index 3cefb28841..32a08d0564 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2061b.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2061b.java @@ -5,12 +5,11 @@ import com.vaadin.data.Item; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.HierarchicalContainer; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Accordion; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.TabSheet; @@ -18,6 +17,8 @@ import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; public class Ticket2061b extends Application implements @@ -30,12 +31,13 @@ public class Ticket2061b extends Application implements public void init() { mainWindow = new Window("Ticket 2061b"); mainWindow.setSizeFull(); - OrderedLayout mainLayout = (OrderedLayout) mainWindow.getLayout(); + AbstractOrderedLayout mainLayout = (AbstractOrderedLayout) mainWindow + .getContent(); mainLayout.setSizeFull(); mainLayout.setMargin(false); setMainWindow(mainWindow); - SplitPanel sp = new SplitPanel(); + SplitPanel sp = new VerticalSplitPanel(); sp.setSizeFull(); sp.setSplitPosition(20, SplitPanel.UNITS_PIXELS); @@ -97,7 +99,7 @@ public class Ticket2061b extends Application implements private Table table = new Table(); private String[] columns; - private ExpandLayout layout = new ExpandLayout(); + private VerticalLayout layout = new VerticalLayout(); public MyTable(int columnNumber, String id) { setDebugId(id); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2062.java b/tests/src/com/vaadin/tests/tickets/Ticket2062.java index e5650ae18c..68c44a38c9 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2062.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2062.java @@ -1,6 +1,7 @@ package com.vaadin.tests.tickets;
import com.vaadin.Application;
+import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
@@ -15,9 +16,9 @@ public class Ticket2062 extends Application { setMainWindow(new Window("Ticket2062"));
getMainWindow().setSizeFull();
- SplitPanel p = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+ SplitPanel p = new HorizontalSplitPanel();
p.setSizeFull();
- getMainWindow().setLayout(p);
+ getMainWindow().setContent(p);
TextField tf1 = new TextField("Tab 1");
tf1.setValue("Field 1");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2083.java b/tests/src/com/vaadin/tests/tickets/Ticket2083.java index e074210fec..e722c6826c 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2083.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2083.java @@ -14,7 +14,7 @@ public class Ticket2083 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
@@ -22,7 +22,7 @@ public class Ticket2083 extends Application { Panel p = new Panel(
"This is a panel with a longer caption than it should have");
p.setWidth("100px");
- p.getLayout().addComponent(new Label("Contents"));
+ p.getContent().addComponent(new Label("Contents"));
layout.addComponent(p);
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2095.java b/tests/src/com/vaadin/tests/tickets/Ticket2095.java index 5fcab528c1..0911cb6830 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2095.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2095.java @@ -13,8 +13,8 @@ public class Ticket2095 extends Application { setMainWindow(w);
// uncomment to workaround iorderedlayout bug in current trunk
- // w.setLayout(new ExpandLayout());
- w.getLayout().setSizeFull();
+ // w.setContent(new ExpandLayout());
+ w.getContent().setSizeFull();
Embedded em = new Embedded();
em.setType(Embedded.TYPE_BROWSER);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2099.java b/tests/src/com/vaadin/tests/tickets/Ticket2099.java index f1add90886..4f79eb7e64 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2099.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2099.java @@ -6,14 +6,14 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2099 extends Application {
private Label l1, l2, l3;
- private OrderedLayout ol1, ol2, ol3;
+ private VerticalLayout ol1, ol2, ol3;
private Window popup;
@Override
@@ -22,7 +22,7 @@ public class Ticket2099 extends Application { setMainWindow(w);
// setTheme("tests-tickets");
GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
+ w.setContent(layout);
createUI(layout);
}
@@ -52,9 +52,9 @@ public class Ticket2099 extends Application { private Window createPopup() {
Window w = new Window("Popup");
TabSheet ts = new TabSheet();
- ol1 = new OrderedLayout();
- ol2 = new OrderedLayout();
- ol3 = new OrderedLayout();
+ ol1 = new VerticalLayout();
+ ol2 = new VerticalLayout();
+ ol3 = new VerticalLayout();
l1 = new Label("111");
l2 = new Label("222");
l3 = new Label("333");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2101.java b/tests/src/com/vaadin/tests/tickets/Ticket2101.java index 9a260635cf..8c12ca10ce 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2101.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2101.java @@ -15,7 +15,7 @@ public class Ticket2101 extends Application { "Button with a long text which will not fit on 50 pixels");
b.setWidth("50px");
- w.getLayout().addComponent(b);
+ w.getContent().addComponent(b);
}
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2103.java b/tests/src/com/vaadin/tests/tickets/Ticket2103.java index 3e655b6753..d65f4c1aec 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2103.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2103.java @@ -5,8 +5,8 @@ import com.vaadin.data.Item; import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.ui.Accordion; import com.vaadin.ui.Component; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2103 extends Application { @@ -15,9 +15,9 @@ public class Ticket2103 extends Application { @Override public void init() { mainWindow = new Window(getClass().getSimpleName()); - mainWindow.setLayout(new ExpandLayout()); + mainWindow.setContent(new VerticalLayout()); mainWindow.setSizeFull(); - mainWindow.getLayout().setSizeFull(); + mainWindow.getContent().setSizeFull(); MyTable table1 = new MyTable(4, "table1"); table1.loadTable(100); @@ -48,7 +48,7 @@ public class Ticket2103 extends Application { private Table table = this; private String[] columns; - private ExpandLayout layout = new ExpandLayout(); + private VerticalLayout layout = new VerticalLayout(); public MyTable(int columnNumber, String id) { setDebugId(id); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2104.java b/tests/src/com/vaadin/tests/tickets/Ticket2104.java index 63dd280d56..5df1780413 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2104.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2104.java @@ -7,8 +7,8 @@ import com.vaadin.event.ItemClickEvent.ItemClickListener; import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Table; import com.vaadin.ui.Tree; import com.vaadin.ui.Window; @@ -29,21 +29,22 @@ public class Ticket2104 extends Application { main.addComponent(info); - OrderedLayout ol = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout ol = new HorizontalLayout(); main.addComponent(ol); - Button b = new Button("immediate", - new MethodProperty(tree, "immediate")); + Button b = new Button("immediate", new MethodProperty<Boolean>(tree, + "immediate")); b.setImmediate(true); ol.addComponent(b); - b = new Button("selectable", new MethodProperty(tree, "selectable")); + b = new Button("selectable", new MethodProperty<Boolean>(tree, + "selectable")); b.setImmediate(true); ol.addComponent(b); - b = new Button("nullsel", new MethodProperty(tree, + b = new Button("nullsel", new MethodProperty<Boolean>(tree, "nullSelectionAllowed")); b.setImmediate(true); ol.addComponent(b); - b = new Button("multi", new MethodProperty(tree, "multiSelect")); + b = new Button("multi", + new MethodProperty<Boolean>(tree, "multiSelect")); b.setImmediate(true); ol.addComponent(b); b = new Button("icon", new Button.ClickListener() { @@ -84,19 +85,22 @@ public class Ticket2104 extends Application { } }); - ol = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); + ol = new HorizontalLayout(); main.addComponent(ol); - b = new Button("immediate", new MethodProperty(table, "immediate")); + b = new Button("immediate", new MethodProperty<Boolean>(table, + "immediate")); b.setImmediate(true); ol.addComponent(b); - b = new Button("selectable", new MethodProperty(table, "selectable")); + b = new Button("selectable", new MethodProperty<Boolean>(table, + "selectable")); b.setImmediate(true); ol.addComponent(b); - b = new Button("nullsel", new MethodProperty(table, + b = new Button("nullsel", new MethodProperty<Boolean>(table, "nullSelectionAllowed")); b.setImmediate(true); ol.addComponent(b); - b = new Button("multi", new MethodProperty(table, "multiSelect")); + b = new Button("multi", new MethodProperty<Boolean>(table, + "multiSelect")); b.setImmediate(true); ol.addComponent(b); main.addComponent(table); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2107.java b/tests/src/com/vaadin/tests/tickets/Ticket2107.java index 4c185801c3..199b278343 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2107.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2107.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Validator; -import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; import com.vaadin.ui.Window.Notification; @@ -44,7 +44,7 @@ public class Ticket2107 extends Application { }); w.addComponent(tf); - final Button b = new Button( + final CheckBox b = new CheckBox( "Field should use error message. (!) should be shown when empty.", false); w.addComponent(b); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2119.java b/tests/src/com/vaadin/tests/tickets/Ticket2119.java index 7e782dc2a0..c1e0d64dde 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2119.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2119.java @@ -7,8 +7,8 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; /** @@ -16,11 +16,11 @@ import com.vaadin.ui.Window; */ public class Ticket2119 extends Application { - private ObjectProperty globalValue; + private ObjectProperty<String> globalValue; @Override public void init() { - globalValue = new ObjectProperty(null, String.class); + globalValue = new ObjectProperty<String>(null, String.class); Window main = createWindow(); setMainWindow(main); } @@ -43,12 +43,12 @@ public class Ticket2119 extends Application { private Window createWindow() { Window main = new Window("Test for ticket XXX"); - main.setLayout(testLayout()); + main.setContent(testLayout()); return main; } private Layout testLayout() { - final Layout layout = new OrderedLayout(); + final Layout layout = new VerticalLayout(); final Label label = new Label( "Instructions to reproduce:\n" + " - Open this application in two browser windows\n" @@ -67,8 +67,8 @@ public class Ticket2119 extends Application { select.addItem("2"); select.addItem("3"); - final ObjectProperty valueProperty = new ObjectProperty("1", - String.class); + final ObjectProperty<String> valueProperty = new ObjectProperty<String>( + "1", String.class); select.setPropertyDataSource(valueProperty); layout.addComponent(select); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2125.java b/tests/src/com/vaadin/tests/tickets/Ticket2125.java index 914b951019..b296a4ff46 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2125.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2125.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.util.MethodProperty; -import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Table; @@ -52,8 +52,8 @@ public class Ticket2125 extends Application { } }); - Button b = new Button("editmode", new MethodProperty(table, - "editable")); + CheckBox b = new CheckBox("editmode", new MethodProperty<Boolean>( + table, "editable")); b.setImmediate(true); addComponent(b); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2151.java b/tests/src/com/vaadin/tests/tickets/Ticket2151.java index 06d1f15336..5a48156367 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2151.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2151.java @@ -2,10 +2,10 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.util.ObjectProperty; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Window; public class Ticket2151 extends Application { @@ -17,10 +17,10 @@ public class Ticket2151 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { Button b = new Button("This is a button"); CheckBox cb = new CheckBox("This is a checkbox"); cb.setImmediate(true); @@ -83,7 +83,8 @@ public class Ticket2151 extends Application { try { b.setWriteThrough(true); b.setReadThrough(true); - ObjectProperty prop = new ObjectProperty("ABC 123"); + ObjectProperty<String> prop = new ObjectProperty<String>( + "ABC 123"); /* * This should throw an exception or somehow tell that the * property was invalid (wrong type). See #2223. diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2157.java b/tests/src/com/vaadin/tests/tickets/Ticket2157.java index c4f6ff30d3..3d90907e50 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2157.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2157.java @@ -1,9 +1,10 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2157 extends Application { @@ -13,15 +14,15 @@ public class Ticket2157 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { - OrderedLayout ol; + private void createUI(AbstractOrderedLayout layout) { + VerticalLayout ol; Panel p; ComboBox cb; - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox without width"); // p.setWidth("100px"); @@ -31,7 +32,7 @@ public class Ticket2157 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox without width with caption"); // p.setWidth("100px"); @@ -42,7 +43,7 @@ public class Ticket2157 extends Application { layout.addComponent(p); // - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100px wide"); // p.setWidth("100px"); @@ -52,7 +53,7 @@ public class Ticket2157 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100px wide with caption"); // p.setWidth("100px"); @@ -62,7 +63,7 @@ public class Ticket2157 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 500px wide"); // p.setWidth("500px"); @@ -72,7 +73,7 @@ public class Ticket2157 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 500px wide with caption"); // p.setWidth("500px"); @@ -82,7 +83,7 @@ public class Ticket2157 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100% wide"); p.setWidth("200px"); @@ -93,7 +94,7 @@ public class Ticket2157 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100% wide with caption"); p.setWidth("200px"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2178.java b/tests/src/com/vaadin/tests/tickets/Ticket2178.java index c663b29778..a3461dd8b6 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2178.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2178.java @@ -1,9 +1,10 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2178 extends Application { @@ -13,15 +14,15 @@ public class Ticket2178 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { - OrderedLayout ol; + private void createUI(AbstractOrderedLayout layout) { + VerticalLayout ol; Panel p; ComboBox cb; - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox without width"); // p.setWidth("100px"); @@ -31,7 +32,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox without width with caption"); // p.setWidth("100px"); @@ -41,7 +42,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100px wide"); // p.setWidth("100px"); @@ -51,7 +52,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100px wide with caption"); // p.setWidth("100px"); @@ -61,7 +62,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 500px wide"); // p.setWidth("500px"); @@ -71,7 +72,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 500px wide with caption"); // p.setWidth("500px"); @@ -81,7 +82,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100% wide inside 200px panel"); p.setWidth("200px"); @@ -93,7 +94,7 @@ public class Ticket2178 extends Application { p.addComponent(cb); layout.addComponent(p); - ol = new OrderedLayout(); + ol = new VerticalLayout(); p = new Panel(ol); p.setCaption("Combobox 100% wide inside 200px panel with caption"); p.setWidth("200px"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2181.java b/tests/src/com/vaadin/tests/tickets/Ticket2181.java index 98bfdce04c..ea3d996b98 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2181.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2181.java @@ -12,8 +12,8 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2181 extends Application implements Button.ClickListener { @@ -41,12 +41,12 @@ public class Ticket2181 extends Application implements Button.ClickListener { @Override public void init() { setMainWindow(main); - OrderedLayout ol; - ol = new OrderedLayout(); + VerticalLayout ol; + ol = new VerticalLayout(); ol.addComponent(tf1); main.addComponent(ol); - ol = new OrderedLayout(); + ol = new VerticalLayout(); ol.setWidth("150px"); tf2.setWidth("150px"); ol.addComponent(tf2); @@ -76,6 +76,7 @@ public class Ticket2181 extends Application implements Button.ClickListener { } private void set() { + @SuppressWarnings("unchecked") Set<String> values = (Set<String>) options.getValue(); TextField[] tfs = new TextField[] { tf1, tf2 }; for (TextField tf : tfs) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2186.java b/tests/src/com/vaadin/tests/tickets/Ticket2186.java index 55eff60fef..bc9ff8c27d 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2186.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2186.java @@ -1,10 +1,11 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2186 extends Application { @@ -14,11 +15,10 @@ public class Ticket2186 extends Application { Window main = new Window("Quick test"); setMainWindow(main); - OrderedLayout base = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); - main.setLayout(base); + HorizontalLayout base = new HorizontalLayout(); + main.setContent(base); - OrderedLayout content = new OrderedLayout(); + VerticalLayout content = new VerticalLayout(); content.addComponent(new Label("Content.")); content.setWidth("500px"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2204.java b/tests/src/com/vaadin/tests/tickets/Ticket2204.java index 6401867289..3fdf61ac47 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2204.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2204.java @@ -6,10 +6,9 @@ import java.util.List; import java.util.Map; import com.vaadin.Application; -import com.vaadin.data.Container; import com.vaadin.data.Item; -import com.vaadin.data.Property; import com.vaadin.data.util.BeanItem; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -17,12 +16,11 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Field; -import com.vaadin.ui.FieldFactory; import com.vaadin.ui.Form; +import com.vaadin.ui.FormFieldFactory; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.RichTextArea; import com.vaadin.ui.SplitPanel; @@ -40,7 +38,7 @@ public class Ticket2204 extends Application { @Override public void init() { - classes.add(OrderedLayout.class); + classes.add(AbstractOrderedLayout.class); classes.add(GridLayout.class); classes.add(Accordion.class); classes.add(TabSheet.class); @@ -51,14 +49,14 @@ public class Ticket2204 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { ts = new TabSheet(); layout.addComponent(ts); - for (Class c : classes) { + for (Class<? extends Component> c : classes) { ts.addTab(createComponent(c), c.getSimpleName(), null); } rta = new RichTextArea(); @@ -95,7 +93,7 @@ public class Ticket2204 extends Application { c.setVisible(!c.isVisible()); } - private Component createComponent(Class c) { + private Component createComponent(Class<? extends Component> c) { RichTextArea textArea = new RichTextArea(); textArea.setVisible(false); textArea.setCaption("This is the textArea"); @@ -105,14 +103,14 @@ public class Ticket2204 extends Application { Component cc = null; try { - cc = (Component) c.newInstance(); + cc = c.newInstance(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } // if (c == OrderedLayout.class) { - // cc = new OrderedLayout(); + // cc = new VerticalLayout(); // } else if (c == Accordion.class) { // Label l = new Label("Filler"); @@ -122,40 +120,25 @@ public class Ticket2204 extends Application { if (c == Form.class) { Form f = (Form) cc; - f.setFieldFactory(new FieldFactory() { - - public Field createField(Class type, Component uiContext) { - return createField(); - } - - public Field createField(Property property, Component uiContext) { - return createField(); - } + f.setFormFieldFactory(new FormFieldFactory() { public Field createField(Item item, Object propertyId, Component uiContext) { - return createField(); - } - - private Field createField() { formTextArea = new RichTextArea(); formTextArea.setVisible(false); return formTextArea; } - public Field createField(Container container, Object itemId, - Object propertyId, Component uiContext) { - return createField(); - } - }); - f.setItemDataSource(new BeanItem(new Object() { + f.setItemDataSource(new BeanItem<Object>(new Object() { private int a; + @SuppressWarnings("unused") public int getA() { return a; } + @SuppressWarnings("unused") public void setA(int a) { this.a = a; } @@ -176,7 +159,7 @@ public class Ticket2204 extends Application { textArea.setSizeFull(); } if (c == Panel.class) { - Layout layout = ((Panel) cc).getLayout(); + Layout layout = (Layout) ((Panel) cc).getContent(); containerToComponent.put(cc, layout); layout.setVisible(false); textArea.setVisible(true); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2209OL.java b/tests/src/com/vaadin/tests/tickets/Ticket2209OL.java index b9a44f6d93..b7b7b8aba1 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2209OL.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2209OL.java @@ -6,20 +6,20 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2209OL extends Application {
- private OrderedLayout gl;
+ private VerticalLayout gl;
private ComboBox combo;
private Label labelLong;
@Override
public void init() {
setMainWindow(new Window());
- getMainWindow().getLayout().setWidth("250px");
- gl = new OrderedLayout();
+ getMainWindow().getContent().setWidth("250px");
+ gl = new VerticalLayout();
gl.setStyleName("borders");
getMainWindow().addComponent(gl);
setTheme("tests-tickets");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2209OL2.java b/tests/src/com/vaadin/tests/tickets/Ticket2209OL2.java index 0b8152b003..99103e7e42 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2209OL2.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2209OL2.java @@ -6,20 +6,20 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2209OL2 extends Application {
- private OrderedLayout gl;
+ private VerticalLayout gl;
private ComboBox combo;
private Label labelLong;
@Override
public void init() {
setMainWindow(new Window());
- getMainWindow().getLayout().setWidth("250px");
- gl = new OrderedLayout();
+ getMainWindow().getContent().setWidth("250px");
+ gl = new VerticalLayout();
gl.setSizeUndefined();
gl.setStyleName("borders");
getMainWindow().addComponent(gl);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2215.java b/tests/src/com/vaadin/tests/tickets/Ticket2215.java index 51b0236ad0..221f84f86f 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2215.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2215.java @@ -2,9 +2,10 @@ package com.vaadin.tests.tickets; import com.vaadin.Application;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
public class Ticket2215 extends Application {
@@ -12,12 +13,12 @@ public class Ticket2215 extends Application { public void init() {
setMainWindow(new Window());
- OrderedLayout ol = new OrderedLayout();
+ VerticalLayout ol = new VerticalLayout();
Panel p = new Panel("Test");
p.addComponent(new Label("Panel1"));
p.setHeight("500px");
p.setWidth("500px");
- p.setStyleName(Panel.STYLE_LIGHT);
+ p.setStyleName(Reindeer.PANEL_LIGHT);
ol.addComponent(p);
ol.addComponent(new Label("NextComponent"));
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2221.java b/tests/src/com/vaadin/tests/tickets/Ticket2221.java index 8d53951959..e6489da432 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2221.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2221.java @@ -1,15 +1,16 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Layout; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2221 extends Application { @@ -19,17 +20,17 @@ public class Ticket2221 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { layout.setSizeFull(); layout.addComponent(new Invoice()); } public class Invoice extends CustomComponent { - Layout main = new OrderedLayout(); + Layout main = new VerticalLayout(); private TextField tf; @@ -71,7 +72,7 @@ public class Ticket2221 extends Application { outerPanel.setHeight("1000px"); outerPanel.setWidth("1000px"); - outerPanel.getLayout().setSizeFull(); + outerPanel.getContent().setSizeFull(); Panel innerPanel = new Panel("Inner panel"); innerPanel.setSizeFull(); outerPanel.addComponent(innerPanel); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2222.java b/tests/src/com/vaadin/tests/tickets/Ticket2222.java index 40980fcef2..86dccede69 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2222.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2222.java @@ -1,9 +1,11 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2222 extends Application { @@ -13,12 +15,11 @@ public class Ticket2222 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { - OrderedLayout horiz = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + private void createUI(AbstractOrderedLayout layout) { + HorizontalLayout horiz = new HorizontalLayout(); horiz.setSpacing(true); horiz.setMargin(true); horiz.setStyleName("ticket2222"); @@ -30,8 +31,7 @@ public class Ticket2222 extends Application { horiz.addComponent(new Label("Margin-bottom: 30px;")); horiz.addStyleName("borders"); - OrderedLayout vert = new OrderedLayout( - OrderedLayout.ORIENTATION_VERTICAL); + VerticalLayout vert = new VerticalLayout(); vert.setSizeUndefined(); vert.setSpacing(true); vert.setMargin(false); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java b/tests/src/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java index a8b4867323..c93b26bec2 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java @@ -4,8 +4,9 @@ import com.vaadin.Application; import com.vaadin.data.Item; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.Layout; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; public class Ticket2227OrderedlayoutInTable extends Application { @@ -18,7 +19,7 @@ public class Ticket2227OrderedlayoutInTable extends Application { t.setHeight("200px"); t.addContainerProperty("pno", String.class, ""); t.addContainerProperty("testi", String.class, ""); - t.addContainerProperty("testi2", OrderedLayout.class, null); + t.addContainerProperty("testi2", Layout.class, null); t.addContainerProperty("komponentti", Component.class, null); t.addContainerProperty("nimi", String.class, ""); t.setVisibleColumns(new Object[] { "pno", "testi", "testi2", "nimi" }); @@ -28,7 +29,7 @@ public class Ticket2227OrderedlayoutInTable extends Application { Item i = t.addItem(1); i.getItemProperty("pno").setValue("1"); i.getItemProperty("testi").setValue("12.12.08"); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); ol.setWidth("100%"); ol.setHeight(null); ol.addComponent(new Label("monirivi testi")); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2231.java b/tests/src/com/vaadin/tests/tickets/Ticket2231.java index c9f773a4a4..ba12dd7abc 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2231.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2231.java @@ -1,8 +1,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Window; public class Ticket2231 extends Application { @@ -12,10 +12,10 @@ public class Ticket2231 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { layout.setSizeUndefined(); layout.setMargin(false); layout.setStyleName("borders"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2232.java b/tests/src/com/vaadin/tests/tickets/Ticket2232.java index 91e557fa84..6df6717c33 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2232.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2232.java @@ -6,7 +6,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Layout.SpacingHandler;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2232 extends Application {
@@ -22,7 +22,7 @@ public class Ticket2232 extends Application { "Defining spacing must be possible also with pure CSS"));
Layout gl;
- gl = new OrderedLayout();
+ gl = new VerticalLayout();
gl.setWidth("100%");
gl.setHeight("200px");
gl.setStyleName("t2232");
@@ -34,7 +34,7 @@ public class Ticket2232 extends Application { gl.setStyleName("t2232");
fillAndAdd(gl);
- gl = new OrderedLayout();
+ gl = new VerticalLayout();
gl.setWidth("100%");
gl.setHeight("200px");
((SpacingHandler) gl).setSpacing(true);
@@ -46,7 +46,7 @@ public class Ticket2232 extends Application { ((SpacingHandler) gl).setSpacing(true);
fillAndAdd(gl);
- gl = new OrderedLayout();
+ gl = new VerticalLayout();
gl.setWidth("100%");
gl.setHeight("200px");
fillAndAdd(gl);
@@ -66,7 +66,7 @@ public class Ticket2232 extends Application { }
String caption = gl.getClass().getSimpleName();
caption += " style: " + gl.getStyleName() + ", spacingFromServer:"
- + ((SpacingHandler) gl).isSpacingEnabled();
+ + ((SpacingHandler) gl).isSpacing();
gl.setCaption(caption);
getMainWindow().addComponent(gl);
}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2234.java b/tests/src/com/vaadin/tests/tickets/Ticket2234.java index 25d74e8574..5c6167fbfe 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2234.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2234.java @@ -2,8 +2,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.Item; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Window; public class Ticket2234 extends Application { @@ -13,10 +13,10 @@ public class Ticket2234 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { ComboBox combo = new ComboBox("Combobox caption"); combo.addContainerProperty("blah", String.class, ""); combo.setItemCaptionPropertyId("blah"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2235.java b/tests/src/com/vaadin/tests/tickets/Ticket2235.java index 98c618453d..72a77e502e 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2235.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2235.java @@ -1,8 +1,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.TextField; +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.TextArea; import com.vaadin.ui.Window; public class Ticket2235 extends Application { @@ -12,13 +12,13 @@ public class Ticket2235 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { layout.setSizeFull(); - TextField tf = new TextField(); + TextArea tf = new TextArea(); tf.setCaption("A text field"); tf.setSizeFull(); tf.setRows(2); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2240.java b/tests/src/com/vaadin/tests/tickets/Ticket2240.java index e28a463eed..6d70d89af8 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2240.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2240.java @@ -1,8 +1,8 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -28,10 +28,10 @@ public class Ticket2240 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { layout.setHeight(null); layout.setStyleName("borders"); // layout.setSizeFull(); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2242.java b/tests/src/com/vaadin/tests/tickets/Ticket2242.java index 9a59bc00a7..fa25ff55f1 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2242.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2242.java @@ -6,10 +6,10 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.ObjectProperty; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Table; import com.vaadin.ui.Window; @@ -18,17 +18,17 @@ public class Ticket2242 extends Application implements ValueChangeListener { private Object tableValue = null; private Table t; private String valueDataSource = "-"; - private ObjectProperty prop; + private ObjectProperty<String> prop; @Override public void init() { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { Button b = new Button("Change container datasource", new ClickListener() { @@ -44,7 +44,7 @@ public class Ticket2242 extends Application implements ValueChangeListener { layout.addComponent(b); t = new Table("A table"); - prop = new ObjectProperty(valueDataSource); + prop = new ObjectProperty<String>(valueDataSource); t.setPropertyDataSource(prop); t.setSelectable(true); t.setImmediate(true); @@ -70,43 +70,6 @@ public class Ticket2242 extends Application implements ValueChangeListener { return ic; } - private static class TestObject { - public TestObject(int a, String b, Long c) { - super(); - this.a = a; - this.b = b; - this.c = c; - } - - private int a; - private String b; - private Long c; - - public int getA() { - return a; - } - - public void setA(int a) { - this.a = a; - } - - public String getB() { - return b; - } - - public void setB(String b) { - this.b = b; - } - - public Long getC() { - return c; - } - - public void setC(Long c) { - this.c = c; - } - } - public void valueChange(ValueChangeEvent event) { System.out.println("Value change from " + tableValue + " to " + t.getValue()); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2244.java b/tests/src/com/vaadin/tests/tickets/Ticket2244.java index 1330116d80..e9ae3ac720 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2244.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2244.java @@ -25,7 +25,7 @@ public class Ticket2244 extends Application { gl.newLine(); form = new Form(gl); - form.setItemDataSource(new BeanItem(new MyBean())); + form.setItemDataSource(new BeanItem<MyBean>(new MyBean())); gl.addComponent(new Label("After form")); @@ -34,7 +34,7 @@ public class Ticket2244 extends Application { w.addComponent(new Button("new item", new Button.ClickListener() { public void buttonClick(ClickEvent event) { - form.setItemDataSource(new BeanItem(new MyBean())); + form.setItemDataSource(new BeanItem<MyBean>(new MyBean())); } @@ -43,7 +43,8 @@ public class Ticket2244 extends Application { new Button.ClickListener() { public void buttonClick(ClickEvent event) { - form.setItemDataSource(new BeanItem(new MyBiggerBean())); + form.setItemDataSource(new BeanItem<MyBean>( + new MyBiggerBean())); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2245.java b/tests/src/com/vaadin/tests/tickets/Ticket2245.java index 8232b7bc38..be119cde83 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2245.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2245.java @@ -1,6 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Window; @@ -9,9 +10,9 @@ public class Ticket2245 extends Application { @Override public void init() { Window main = new Window("The Main Window"); - main.getLayout().setSizeFull(); + main.getContent().setSizeFull(); setMainWindow(main); - SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL); + SplitPanel sp = new HorizontalSplitPanel(); main.addComponent(sp); } } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2267.java b/tests/src/com/vaadin/tests/tickets/Ticket2267.java index b55776be79..020ea5c7c6 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2267.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2267.java @@ -35,7 +35,7 @@ public class Ticket2267 extends Application { gl.addComponent(new Label("3")); gl.addComponent(new Label("4")); - w.setLayout(gl); + w.setContent(gl); } } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2271.java b/tests/src/com/vaadin/tests/tickets/Ticket2271.java index 50a5466645..50a99edb7a 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2271.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2271.java @@ -1,9 +1,9 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -14,10 +14,10 @@ public class Ticket2271 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { VerticalLayout ol = new VerticalLayout(); ol.setWidth(null); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2279.java b/tests/src/com/vaadin/tests/tickets/Ticket2279.java index 5a92f85b32..e3b446f242 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2279.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2279.java @@ -15,6 +15,8 @@ import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; +// This tests the deprecated setComponentAlignment(Component,String) API +@SuppressWarnings("deprecation") public class Ticket2279 extends Application { private Label label; @@ -62,7 +64,7 @@ public class Ticket2279 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); setTheme("tests-tickets"); - AbstractOrderedLayout layout = (AbstractOrderedLayout) w.getLayout(); + AbstractOrderedLayout layout = (AbstractOrderedLayout) w.getContent(); createUI(layout); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2282.java b/tests/src/com/vaadin/tests/tickets/Ticket2282.java index 14467cf483..c63faf2cef 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2282.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2282.java @@ -17,7 +17,7 @@ public class Ticket2282 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); setTheme("tests-tickets"); - w.getLayout().setSizeUndefined(); + w.getContent().setSizeUndefined(); layout1 = new FormLayout(); layout1.setSizeUndefined(); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2283.java b/tests/src/com/vaadin/tests/tickets/Ticket2283.java index 5831b9638f..89b90eaa01 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2283.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2283.java @@ -1,9 +1,9 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.Alignment; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.Window; public class Ticket2283 extends Application { @@ -21,9 +21,8 @@ public class Ticket2283 extends Application { gl.addComponent(new Label("Label 2 abc abc abc ")); Label l = new Label("Colspan2, align right"); gl.addComponent(l, 0, 1, 1, 1); - gl.setComponentAlignment(l, AlignmentHandler.ALIGNMENT_RIGHT, - AlignmentHandler.ALIGNMENT_TOP); - w.setLayout(gl); + gl.setComponentAlignment(l, Alignment.TOP_RIGHT); + w.setContent(gl); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2289.java b/tests/src/com/vaadin/tests/tickets/Ticket2289.java index 177ec74fc1..19574b50fb 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2289.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2289.java @@ -22,7 +22,7 @@ public class Ticket2289 extends Application { Window w = new Window(); setMainWindow(w); VerticalLayout ol = new VerticalLayout(); - w.setLayout(ol); + w.setContent(ol); Button b = new Button("close current tab"); b.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2294.java b/tests/src/com/vaadin/tests/tickets/Ticket2294.java index de18bf94ef..37c29ca5e0 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2294.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2294.java @@ -1,9 +1,9 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Label; -import com.vaadin.ui.Layout.AlignmentHandler; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Window; public class Ticket2294 extends Application { @@ -13,10 +13,10 @@ public class Ticket2294 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((OrderedLayout) w.getLayout()); + createUI((AbstractOrderedLayout) w.getContent()); } - private void createUI(OrderedLayout layout) { + private void createUI(AbstractOrderedLayout layout) { Label label1 = new Label(); Label label2 = null; Label label3 = new Label(); @@ -26,18 +26,14 @@ public class Ticket2294 extends Application { layout.addComponent(label1); try { - layout.setComponentAlignment(label1, - AlignmentHandler.ALIGNMENT_LEFT, - AlignmentHandler.ALIGNMENT_BOTTOM); + layout.setComponentAlignment(label1, Alignment.BOTTOM_LEFT); result1 = "OK"; } catch (Exception e) { result1 = "FAILED: " + e.getMessage(); } try { - layout.setComponentAlignment(label2, - AlignmentHandler.ALIGNMENT_LEFT, - AlignmentHandler.ALIGNMENT_BOTTOM); + layout.setComponentAlignment(label2, Alignment.BOTTOM_LEFT); result2 = "FAILED, no exception"; } catch (IllegalArgumentException e) { result2 = "OK"; @@ -46,9 +42,7 @@ public class Ticket2294 extends Application { } try { - layout.setComponentAlignment(label3, - AlignmentHandler.ALIGNMENT_LEFT, - AlignmentHandler.ALIGNMENT_BOTTOM); + layout.setComponentAlignment(label3, Alignment.BOTTOM_LEFT); result3 = "FAILED, no exception"; } catch (IllegalArgumentException e) { result3 = "OK"; diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2296.java b/tests/src/com/vaadin/tests/tickets/Ticket2296.java index e4eb3e7a1d..1503811341 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2296.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2296.java @@ -27,7 +27,7 @@ public class Ticket2296 extends Application { b.setHeight("50%"); cl.addComponent(b, "button3"); - w.setLayout(cl); + w.setContent(cl); } } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2303.java b/tests/src/com/vaadin/tests/tickets/Ticket2303.java index 36dd842140..21b33d5bb6 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2303.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2303.java @@ -6,7 +6,7 @@ import java.io.IOException; import com.vaadin.Application;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class Ticket2303 extends Application {
@@ -25,11 +25,11 @@ public class Ticket2303 extends Application { e.printStackTrace();
}
cl.setWidth("100%");
- w.setLayout(cl);
+ w.setContent(cl);
// VerticalLayout ol = new VerticalLayout();
- // w.setLayout(ol);
- OrderedLayout hugeLayout = new OrderedLayout();
+ // w.setContent(ol);
+ VerticalLayout hugeLayout = new VerticalLayout();
hugeLayout.setMargin(true);
hugeLayout.setSpacing(true);
for (int i = 0; i < 30; i++) {
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2304.java b/tests/src/com/vaadin/tests/tickets/Ticket2304.java index 57c7acefc1..1b356c73fb 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2304.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2304.java @@ -4,6 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.Window; +import com.vaadin.ui.themes.Reindeer; public class Ticket2304 extends Application { @@ -14,7 +15,7 @@ public class Ticket2304 extends Application { setMainWindow(main); Panel p = new Panel(); - p.setStyleName(Panel.STYLE_LIGHT); + p.setStyleName(Reindeer.PANEL_LIGHT); main.addComponent(p); p.setHeight("100px"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2310.java b/tests/src/com/vaadin/tests/tickets/Ticket2310.java index 82928d9c91..6363fddcaf 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2310.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2310.java @@ -6,6 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.Window; +import com.vaadin.ui.themes.Reindeer; public class Ticket2310 extends Application { @@ -20,7 +21,7 @@ public class Ticket2310 extends Application { + "flag) is sent to client. Label is grey when panel is shown.")); final Panel p = new Panel(); - p.setStyleName(Panel.STYLE_LIGHT); + p.setStyleName(Reindeer.PANEL_LIGHT); main.addComponent(p); p.setHeight("100px"); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2319.java b/tests/src/com/vaadin/tests/tickets/Ticket2319.java index b48302a1f4..a345bddbb0 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2319.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2319.java @@ -3,10 +3,12 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; public class Ticket2319 extends Application { @@ -39,7 +41,7 @@ public class Ticket2319 extends Application { hl.addComponent(panel2); mainw.addComponent(hl); - SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + SplitPanel sp = new HorizontalSplitPanel(); VerticalLayout first = new VerticalLayout(); first.addComponent(new Label("first")); @@ -49,7 +51,7 @@ public class Ticket2319 extends Application { sp.setFirstComponent(first); sp.setSecondComponent(second); - SplitPanel sp2 = new SplitPanel(); + SplitPanel sp2 = new VerticalSplitPanel(); Label label = new Label("first"); label.setSizeFull(); sp2.setFirstComponent(label); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2323.java b/tests/src/com/vaadin/tests/tickets/Ticket2323.java index 4def857112..503878ecad 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2323.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2323.java @@ -13,7 +13,7 @@ public class Ticket2323 extends Application { Window subWindow = new Window(""); subWindow.setSizeUndefined(); - subWindow.getLayout().setSizeUndefined(); + subWindow.getContent().setSizeUndefined(); subWindow.center(); subWindow.addComponent(new RichTextArea()); w.addWindow(subWindow); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2325.java b/tests/src/com/vaadin/tests/tickets/Ticket2325.java index 3b46d89a5e..1245254fa0 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2325.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2325.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; -import com.vaadin.ui.TextField; +import com.vaadin.ui.TextArea; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -15,7 +15,7 @@ public class Ticket2325 extends Application { final VerticalLayout lo = new VerticalLayout(); lo.setSizeUndefined(); lo.setWidth("100%"); - TextField tf = new TextField(); + TextArea tf = new TextArea(); tf.setValue("The textfield should fill the window." + "\n - Try to resize window\n - Try to push REdo button"); tf.setRows(10); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2329.java b/tests/src/com/vaadin/tests/tickets/Ticket2329.java index f7b47f6708..57dbeb4033 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2329.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2329.java @@ -16,7 +16,7 @@ public class Ticket2329 extends Application { public void init() { Window mainw = new Window(); setMainWindow(mainw); - mainLo = (VerticalLayout) mainw.getLayout(); + mainLo = (VerticalLayout) mainw.getContent(); table = new Table(); for (int i = 0; i < 10000; i++) { table.addItem(i); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2341.java b/tests/src/com/vaadin/tests/tickets/Ticket2341.java index b6dd4cc1f0..d7fbccfa4e 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2341.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2341.java @@ -11,7 +11,7 @@ public class Ticket2341 extends com.vaadin.Application { public void init() { Window main = new Window(); setMainWindow(main); - constructTables(main.getLayout()); + constructTables((Layout) main.getContent()); } private void constructTables(Layout layout) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2344.java b/tests/src/com/vaadin/tests/tickets/Ticket2344.java index cb36fbca9e..26ef216940 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2344.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2344.java @@ -4,15 +4,13 @@ import java.util.Random; import com.vaadin.Application; import com.vaadin.ui.Button; -import com.vaadin.ui.Panel; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; +import com.vaadin.ui.themes.BaseTheme; public class Ticket2344 extends Application { - private Panel p; - @Override public void init() { Window main = new Window("Quick test"); @@ -23,7 +21,7 @@ public class Ticket2344 extends Application { VerticalLayout hl = new VerticalLayout(); hl.setWidth("400px"); - main.setLayout(hl); + main.setContent(hl); Table t = new Table(); t.setWidth("100%"); @@ -41,7 +39,7 @@ public class Ticket2344 extends Application { VerticalLayout vl = new VerticalLayout(); // vl.setWidth(null); Button b = new Button("String 1 2 3"); - b.setStyleName(Button.STYLE_LINK); + b.setStyleName(BaseTheme.BUTTON_LINK); vl.addComponent(b); t.addItem(new Object[] { vl, "String 2", "String 3", "String 4", diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2347.java b/tests/src/com/vaadin/tests/tickets/Ticket2347.java index c591fb8f6a..76e59146db 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2347.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2347.java @@ -17,7 +17,7 @@ public class Ticket2347 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); setTheme("tests-tickets"); - createUI((VerticalLayout) w.getLayout()); + createUI((VerticalLayout) w.getContent()); } private void createUI(VerticalLayout layout) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2365.java b/tests/src/com/vaadin/tests/tickets/Ticket2365.java index bd8bbc05af..0c8a095ec9 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2365.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2365.java @@ -17,7 +17,7 @@ public class Ticket2365 extends Application { VerticalLayout lo = new VerticalLayout(); lo.setSizeFull(); - mainWin.setLayout(lo); + mainWin.setContent(lo); final Panel p = createMultilevelPanel(5, (Panel) null); @@ -43,10 +43,10 @@ public class Ticket2365 extends Application { if (panel == null) { panel = new Panel("Panel level " + i); panel.setSizeFull(); - panel.getLayout().setSizeFull(); + panel.getContent().setSizeFull(); } Panel p = new Panel("Panel level " + i--); - p.getLayout().setSizeFull(); + p.getContent().setSizeFull(); p.setSizeFull(); panel.addComponent(p); if (i > 0) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2405.java b/tests/src/com/vaadin/tests/tickets/Ticket2405.java index 174d6e5d6c..83ed55f9fc 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2405.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2405.java @@ -2,10 +2,13 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; 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.SplitPanel; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -29,8 +32,8 @@ public class Ticket2405 extends Application { // browser.addWindow(root); setMainWindow(root); - root.getLayout().setSizeFull(); - root.getLayout().setMargin(false); + root.getContent().setSizeFull(); + ((Layout) root.getContent()).setMargin(false); // Top area, containing playback and volume controls, play status, view // modes and search @@ -47,20 +50,20 @@ public class Ticket2405 extends Application { "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent porttitor porta lacus. Nulla tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin mollis turpis in mauris faucibus posuere. Nullam rutrum, nisi a fermentum tempus, lacus metus rutrum massa, a condimentum mauris justo a tortor. Mauris aliquet, ante quis ultricies posuere, sapien libero laoreet sem, a accumsan diam metus sed elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur vehicula metus nec turpis dignissim cursus. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam feugiat orci eget risus. Vestibulum at sem. "); label.setWidth("100%"); top.addComponent(label); - split = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL); + split = new HorizontalSplitPanel(); split.setHeight("100%"); Embedded image = new Embedded("An image", new ExternalResource( "http://dev.itmill.com/chrome/site/toolkit-logo.png")); image.setWidth("100%"); root.addComponent(split); - ((VerticalLayout) root.getLayout()).setExpandRatio(split, 1.0f); + ((VerticalLayout) root.getContent()).setExpandRatio(split, 1.0f); VerticalLayout vl = new VerticalLayout(); split.addComponent(vl); vl.addComponent(new TextField("abc")); vl.addComponent(image); vl.setExpandRatio(image, 1.0f); - vl.setComponentAlignment(image, "bottom center"); + vl.setComponentAlignment(image, Alignment.BOTTOM_CENTER); vl.setHeight("100%"); // We'll need one splitpanel to separate the sidebar and track listing Button bottomButton = new Button("Filler"); @@ -69,7 +72,7 @@ public class Ticket2405 extends Application { // The splitpanel is by default 100% x 100%, but we'll need to adjust // our main window layout to accomodate the height - root.getLayout().setHeight("100%"); + root.getContent().setHeight("100%"); // ((VerticalLayout) root.getLayout()).setExpandRatio(bottomButton, // 1.0F); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2406.java b/tests/src/com/vaadin/tests/tickets/Ticket2406.java index 22ff32d036..b7c9f902d2 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2406.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2406.java @@ -16,7 +16,7 @@ public class Ticket2406 extends Application { Window w = new Window(getClass().getSimpleName()); setMainWindow(w); // setTheme("tests-tickets"); - createUI((VerticalLayout) w.getLayout()); + createUI((VerticalLayout) w.getContent()); } private void createUI(VerticalLayout layout) { @@ -26,7 +26,7 @@ public class Ticket2406 extends Application { VerticalLayout l = new VerticalLayout(); l.setSizeFull(); - w.setLayout(l); + w.setContent(l); Button b = new Button("Button 1"); b.setSizeFull(); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2411.java b/tests/src/com/vaadin/tests/tickets/Ticket2411.java index b402ced300..3159be360b 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2411.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2411.java @@ -14,7 +14,7 @@ public class Ticket2411 extends Application { // VerticalLayout l = new VerticalLayout();
GridLayout l = new GridLayout();
- w.setLayout(l);
+ w.setContent(l);
l.setHeight("504px");
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2432.java b/tests/src/com/vaadin/tests/tickets/Ticket2432.java index c5465b917d..326f27d58a 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2432.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2432.java @@ -17,8 +17,8 @@ public class Ticket2432 extends Application { Window w = new Window(); setMainWindow(w); - w.getLayout().setSizeFull(); - ((SpacingHandler) w.getLayout()).setSpacing(true); + w.getContent().setSizeFull(); + ((SpacingHandler) w.getContent()).setSpacing(true); Layout layout = new GridLayout(3, 3); populateLayout(layout); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2901.java b/tests/src/com/vaadin/tests/tickets/Ticket2901.java index 61537488ca..b85d409a24 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2901.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2901.java @@ -4,6 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Label; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; /** @@ -19,7 +20,7 @@ public class Ticket2901 extends Application { final Window mainWin = new Window("Test app to break layout in IE6"); setMainWindow(mainWin); - SplitPanel sp = new SplitPanel(); + SplitPanel sp = new VerticalSplitPanel(); VerticalLayout l = new VerticalLayout(); for (int i = 0; i < 100; i++) { diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2998.java b/tests/src/com/vaadin/tests/tickets/Ticket2998.java index 11fc3194b0..81ffcf5a01 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2998.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2998.java @@ -25,6 +25,7 @@ import com.vaadin.ui.Table; import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
/**
* Table layout is very slow in Firefox 3.0.10 when the table contains
@@ -36,7 +37,6 @@ import com.vaadin.ui.Window; */
public class Ticket2998 extends Application {
private Table table;
- private WorkoutEditor editor = new WorkoutEditor(this);
private VerticalLayout mainLayout;
public class Workout implements Serializable {
@@ -104,16 +104,15 @@ public class Ticket2998 extends Application { private TextField kilomiters = new TextField("Kilometers");
private TextField title = new TextField("Title/note");
- private Workout run;
private Ticket2998 workoutLog;
public WorkoutEditor(Ticket2998 app) {
super("Edit workout");
workoutLog = app;
Layout main = new VerticalLayout();
- setLayout(main);
+ setContent(main);
main.setSizeUndefined();
- main.setStyleName(Panel.STYLE_LIGHT);
+ main.setStyleName(Reindeer.PANEL_LIGHT);
FormLayout form = new FormLayout();
form.setSizeUndefined();
@@ -136,17 +135,13 @@ public class Ticket2998 extends Application { workoutLog.getMainWindow().addWindow(this);
}
kilomiters.focus();
- this.run = run;
}
}
}
public class MyFieldFactory extends DefaultFieldFactory {
- private BeanItemContainer<String> trainingTypes;
-
public MyFieldFactory(Ticket2998 app) {
- trainingTypes = new BeanItemContainer<String>(String.class);
}
@Override
@@ -259,14 +254,14 @@ public class Ticket2998 extends Application { // set theme and some layout stuff
setMainWindow(w);
- w.getLayout().setSizeFull();
- w.getLayout().setMargin(false);
+ w.getContent().setSizeFull();
+ ((Layout) w.getContent()).setMargin(false);
Panel p = new Panel("Workout Log");
- p.setStyleName(Panel.STYLE_LIGHT);
+ p.setStyleName(Reindeer.PANEL_LIGHT);
w.addComponent(p);
mainLayout = new VerticalLayout();
- p.setLayout(mainLayout);
+ p.setContent(mainLayout);
populateAndConfigureTable();
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket3146.java b/tests/src/com/vaadin/tests/tickets/Ticket3146.java index 623b88f616..6afa25efda 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket3146.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket3146.java @@ -76,7 +76,7 @@ public class Ticket3146 extends Application { }
void clearSelection2() {
- table.setValue(new HashSet());
+ table.setValue(new HashSet<Object>());
}
void clearSelection3() {
@@ -87,7 +87,7 @@ public class Ticket3146 extends Application { void printSelection() {
String selection = "";
- for (Object item : (Collection) table.getValue()) {
+ for (Object item : (Collection<?>) table.getValue()) {
selection = selection + item + ' ';
}
result.setValue(selection);
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket34.java b/tests/src/com/vaadin/tests/tickets/Ticket34.java index 44328b0390..7d3baf78fa 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket34.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket34.java @@ -74,7 +74,7 @@ public class Ticket34 extends Application { for (String string : strings) { Panel p = new Panel(string); p.setSizeFull(); - ((VerticalLayout) p.getLayout()).setSpacing(true); + ((VerticalLayout) p.getContent()).setSpacing(true); p.addComponent(new Label("This is a simple test case for " + "UriFragmentReader that can be used for" + " adding linking, back/forward button " diff --git a/tests/src/com/vaadin/tests/tickets/Ticket6002.java b/tests/src/com/vaadin/tests/tickets/Ticket6002.java new file mode 100644 index 0000000000..888f1c05ca --- /dev/null +++ b/tests/src/com/vaadin/tests/tickets/Ticket6002.java @@ -0,0 +1,88 @@ +package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket6002 extends TestBase {
+
+ @Override
+ public void setup() {
+ Window main = new Window("The Main Window");
+ setMainWindow(main);
+
+ final VerticalLayout mainLayout = new VerticalLayout();
+ main.setContent(mainLayout);
+
+ mainLayout.addComponent(new Label(
+ "Replace the floating-point values with an integer"));
+
+ // ///////////////////////////////////////////////////
+ // Better working case
+
+ final ObjectProperty<Double> property1 = new ObjectProperty<Double>(
+ new Double(42.0));
+
+ // A text field that changes its caption
+ final TextField tf1 = new TextField(
+ "Changing this field modifies only the textfield", property1);
+ tf1.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // This value change event is called twice if the new
+ // input value is an integer. The second time is during
+ // paint() of AbstractOrderedLayout.
+
+ System.out.println("Value 2 is: " + property1.getValue());
+
+ tf1.setCaption("With caption " + property1.getValue());
+ }
+ });
+ tf1.setImmediate(true);
+ mainLayout.addComponent(tf1);
+
+ // ///////////////////////////////////////////////////
+ // Totally failing case
+
+ final ObjectProperty<Double> property2 = new ObjectProperty<Double>(
+ new Double(42.0));
+
+ // A text field that adds new components
+ final TextField tf2 = new TextField(
+ "Changing this field modifies the layout - do it twice",
+ property2);
+ tf2.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // This value change event is called twice if the new
+ // input value is an integer. The second time is during
+ // paint() of AbstractOrderedLayout.
+
+ System.out.println("Value 1 is: " + property2.getValue());
+
+ // When this listener is called the second time in paint(), the
+ // add operation causes a ConcurrentModificationException
+ mainLayout.addComponent(new Label(
+ "Added a component, value is " + property2.getValue()));
+ }
+ });
+ tf2.setImmediate(true);
+ mainLayout.addComponent(tf2);
+
+ mainLayout.setSpacing(true);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Change the numbers to integer value or add 0 in the decimal representation. "
+ + "This causes a secondary call during paint() to reformat the value, which causes ConcurrentModificationException in the second case.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6002;
+ }
+}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket677.java b/tests/src/com/vaadin/tests/tickets/Ticket677.java index ca9c9227b2..ee7320e59b 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket677.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket677.java @@ -5,16 +5,16 @@ import com.vaadin.data.Container; import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.util.BeanItem;
-import com.vaadin.ui.BaseFieldFactory;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
@@ -45,8 +45,7 @@ public class Ticket677 extends Application { main.addComponent(info);
- OrderedLayout l = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
+ HorizontalLayout l = new HorizontalLayout();
main.addComponent(l);
l.addComponent(new Button("Toggle root panel",
@@ -78,7 +77,7 @@ public class Ticket677 extends Application { }
}));
- root.setLayout(new GridLayout(2, 3));
+ root.setContent(new GridLayout(2, 3));
main.addComponent(root);
TextField tf = new TextField("Enabled");
@@ -109,7 +108,7 @@ public class Ticket677 extends Application { form = new Form();
form.setCaption("Enabled");
- form.setFieldFactory(new BaseFieldFactory() {
+ form.setFormFieldFactory(new DefaultFieldFactory() {
@Override
public Field createField(Item item, Object propertyId,
@@ -120,7 +119,7 @@ public class Ticket677 extends Application { }
});
- form.setItemDataSource(new BeanItem(new MyBean()));
+ form.setItemDataSource(new BeanItem<MyBean>(new MyBean()));
root.addComponent(form);
table = new Table("Enabled");
@@ -132,7 +131,7 @@ public class Ticket677 extends Application { p.setValue(i % 5 == 0 ? "enabled" : "disabled");
}
- table.setFieldFactory(new BaseFieldFactory() {
+ table.setTableFieldFactory(new DefaultFieldFactory() {
@Override
public Field createField(Container container, Object itemId,
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket736.java b/tests/src/com/vaadin/tests/tickets/Ticket736.java index e85ca3533a..ac7868cb48 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket736.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket736.java @@ -6,11 +6,12 @@ import com.vaadin.data.util.BeanItem; import com.vaadin.data.util.MethodProperty; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.ExpandLayout; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.Form; -import com.vaadin.ui.OrderedLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Window; @@ -28,8 +29,8 @@ public class Ticket736 extends Application { // Create form for editing address final Form f = new Form(); - f.setItemDataSource(new BeanItem(address, new String[] { "name", - "street", "zip", "city", "state", "country" })); + f.setItemDataSource(new BeanItem<Address>(address, new String[] { + "name", "street", "zip", "city", "state", "country" })); f.setCaption("Office address"); f.setIcon(new ThemeResource("../runo/icons/16/document.png")); f.setDescription("Jep jpe, this is form description."); @@ -40,11 +41,10 @@ public class Ticket736 extends Application { f.setReadThrough(false); Button commit = new Button("Commit", f, "commit"); Button discard = new Button("Discard", f, "discard"); - ExpandLayout ol = new ExpandLayout(OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout ol = new HorizontalLayout(); ol.setHeight("3em"); ol.addComponent(commit); - ol.setComponentAlignment(commit, ExpandLayout.ALIGNMENT_RIGHT, - ExpandLayout.ALIGNMENT_TOP); + ol.setComponentAlignment(commit, Alignment.TOP_RIGHT); ol.addComponent(discard); f.setFooter(ol); @@ -61,13 +61,13 @@ public class Ticket736 extends Application { // Debug form properties final Panel formProperties = new Panel("Form properties"); - formProperties.setWidth(200); + formProperties.setWidth("200px"); final String[] visibleProps = { "required", "invalidAllowed", "readOnly", "readThrough", "writeThrough", "invalidCommitted", "validationVisible", "immediate" }; for (int i = 0; i < visibleProps.length; i++) { - Button b = new Button(visibleProps[i], new MethodProperty(f, - visibleProps[i])); + CheckBox b = new CheckBox(visibleProps[i], + new MethodProperty<Boolean>(f, visibleProps[i])); b.setImmediate(true); formProperties.addComponent(b); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket846.java b/tests/src/com/vaadin/tests/tickets/Ticket846.java index 888906105d..23f3134308 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket846.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket846.java @@ -4,6 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Validator; import com.vaadin.data.util.MethodProperty; import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -40,8 +41,8 @@ public class Ticket846 extends Application { "readOnly", "readThrough", "invalidCommitted", "validationVisible" }; for (int i = 0; i < visibleProps.length; i++) { - Button b = new Button(visibleProps[i], new MethodProperty(tx, - visibleProps[i])); + CheckBox b = new CheckBox(visibleProps[i], + new MethodProperty<Boolean>(tx, visibleProps[i])); b.setImmediate(true); mainWin.addComponent(b); } @@ -56,8 +57,8 @@ public class Ticket846 extends Application { + (tx.isValid() ? "" : "not ") + "valid"); }; })); - TextField caption = new TextField("Caption", new MethodProperty(tx, - "caption")); + TextField caption = new TextField("Caption", + new MethodProperty<String>(tx, "caption")); caption.setImmediate(true); mainWin.addComponent(caption); } diff --git a/tests/src/com/vaadin/tests/tickets/Ticket932.java b/tests/src/com/vaadin/tests/tickets/Ticket932.java index d053cbbb2a..93f8dc3b6e 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket932.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket932.java @@ -5,6 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.RichTextArea; +import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -35,7 +36,7 @@ public class Ticket932 extends Application { mainWin.addComponent(tx); mainWin.addComponent(b); - final TextField tx2 = new TextField( + final TextArea tx2 = new TextArea( "Textfield with maxlenght 10, multirow "); mainWin.addComponent(tx2); tx2.setImmediate(true); diff --git a/tests/src/com/vaadin/tests/util/RandomComponents.java b/tests/src/com/vaadin/tests/util/RandomComponents.java index f857563cdd..c47c3787d6 100644 --- a/tests/src/com/vaadin/tests/util/RandomComponents.java +++ b/tests/src/com/vaadin/tests/util/RandomComponents.java @@ -33,13 +33,14 @@ import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.DateField; import com.vaadin.ui.Embedded; import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.Select; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; public class RandomComponents { @@ -65,13 +66,13 @@ public class RandomComponents { switch (randint) { case 0: - result = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); - ((OrderedLayout) result).setCaption("OrderedLayout_horizontal_" + result = new HorizontalLayout(); + ((HorizontalLayout) result).setCaption("OrderedLayout_horizontal_" + caption); break; case 1: - result = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - ((OrderedLayout) result).setCaption("OrderedLayout_vertical_" + result = new VerticalLayout(); + ((VerticalLayout) result).setCaption("OrderedLayout_vertical_" + caption); break; case 2: @@ -102,17 +103,16 @@ public class RandomComponents { ts.setCaption("TabSheet_" + caption); // randomly select one of the tabs final int selectedTab = seededRandom.nextInt(3); - final ArrayList tabs = new ArrayList(); + final ArrayList<ComponentContainer> tabs = new ArrayList<ComponentContainer>(); for (int i = 0; i < 3; i++) { String tabCaption = "tab" + i; if (selectedTab == i) { tabCaption = "tabX"; } - tabs.add(new OrderedLayout()); - ts.addTab((ComponentContainer) tabs.get(tabs.size() - 1), - tabCaption, null); + tabs.add(new VerticalLayout()); + ts.addTab(tabs.get(tabs.size() - 1), tabCaption, null); } - ts.setSelectedTab((ComponentContainer) tabs.get(selectedTab)); + ts.setSelectedTab(tabs.get(selectedTab)); result = ts; break; } @@ -175,7 +175,7 @@ public class RandomComponents { + "extremities and may have a caption to clarify the nature of the contained components' purpose." + " Panel contains an layout where the actual contained components are added, " + "this layout may be switched on the fly.")); - ((Panel) result).setWidth(250); + ((Panel) result).setWidth("250px"); break; case 6: // Datefield @@ -191,65 +191,66 @@ public class RandomComponents { result.setCaption("Calendar component " + caption); break; case 8: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ButtonExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new ButtonExample()); break; case 9: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ClientCachingExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new ClientCachingExample()); break; case 10: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ComboBoxExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new ComboBoxExample()); break; case 11: - result = new OrderedLayout(); + result = new VerticalLayout(); // TODO: disabled gwt bug with mixed up iframe's - ((OrderedLayout) result).addComponent(new EmbeddedBrowserExample()); + ((VerticalLayout) result) + .addComponent(new EmbeddedBrowserExample()); break; case 12: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new JavaScriptAPIExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new JavaScriptAPIExample()); break; case 13: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new LabelExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new LabelExample()); break; case 14: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new LayoutExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new LayoutExample()); break; case 15: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new NotificationExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new NotificationExample()); break; case 16: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new RichTextExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new RichTextExample()); break; case 17: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new SelectExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new SelectExample()); break; case 18: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ValueInputExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new ValueInputExample()); break; case 19: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new WindowingExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new WindowingExample()); break; case 20: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new TreeExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new TreeExample()); break; case 21: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new TableExample()); + result = new VerticalLayout(); + ((VerticalLayout) result).addComponent(new TableExample()); break; case 22: - result = new OrderedLayout(); - ((OrderedLayout) result) + result = new VerticalLayout(); + ((VerticalLayout) result) .addComponent(new StressComponentsInTable()); break; } diff --git a/tests/src/com/vaadin/tests/util/TestClickListener.java b/tests/src/com/vaadin/tests/util/TestClickListener.java index 730452ac72..95b9cf2d40 100644 --- a/tests/src/com/vaadin/tests/util/TestClickListener.java +++ b/tests/src/com/vaadin/tests/util/TestClickListener.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button.ClickEvent; public class TestClickListener implements Button.ClickListener { - private static final HashMap buttonListeners = new HashMap(); + private static final HashMap<String, Integer> buttonListeners = new HashMap<String, Integer>(); String name = ""; int count = 0; @@ -15,7 +15,7 @@ public class TestClickListener implements Button.ClickListener { public TestClickListener(String name) { Integer count = null; try { - count = (Integer) buttonListeners.get(name); + count = buttonListeners.get(name); count = new Integer(count.intValue() + 1); buttonListeners.put(name, count); } catch (Exception e) { diff --git a/tests/src/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java b/tests/src/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java index c8d79ecca0..b1d6a8f068 100644 --- a/tests/src/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java +++ b/tests/src/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java @@ -19,6 +19,7 @@ import com.vaadin.ui.Panel; import com.vaadin.ui.Select;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
public class EmptyFieldErrorIndicators extends TestBase {
@@ -42,7 +43,7 @@ public class EmptyFieldErrorIndicators extends TestBase { Panel panel = new Panel();
panel.setSizeFull();
- panel.setStyleName(Panel.STYLE_LIGHT);
+ panel.setStyleName(Reindeer.PANEL_LIGHT);
panel.addComponent(hl);
panel.setScrollable(true);
addComponent(panel);
diff --git a/tests/src/com/vaadin/tests/validation/TestReadOnlyValidation.java b/tests/src/com/vaadin/tests/validation/TestReadOnlyValidation.java new file mode 100644 index 0000000000..2765bf6b13 --- /dev/null +++ b/tests/src/com/vaadin/tests/validation/TestReadOnlyValidation.java @@ -0,0 +1,17 @@ +package com.vaadin.tests.validation;
+
+import org.junit.Test;
+
+import com.vaadin.data.validator.IntegerValidator;
+import com.vaadin.ui.TextField;
+
+public class TestReadOnlyValidation {
+
+ @Test
+ public void testIntegerValidation() {
+ TextField field = new TextField();
+ field.addValidator(new IntegerValidator("Enter a Valid Number"));
+ field.setValue(Integer.valueOf(10));
+ field.validate();
+ }
+}
diff --git a/tests/test.xml b/tests/test.xml index 137a569f47..5be9228862 100644 --- a/tests/test.xml +++ b/tests/test.xml @@ -5,14 +5,18 @@ <!-- Configuration --> <!-- ================================================================== --> <!-- Browsers to use for testing --> - <property name="browsers" value="winxp-ie6,winxp-ie7,winxp-ie8,winxp-firefox36,winxp-firefox4beta,winxp-safari4,winxp-safari5,winxp-googlechrome7,winxp-opera1060" /> + <property name="browsers-windows" value="winxp-ie6,winxp-ie7,winxp-ie8,winxp-firefox36,winxp-firefox4beta,winxp-safari4,winxp-safari5,winxp-googlechrome7,winxp-opera1060" /> + <property name="browsers-linux" value="linux-firefox3,linux-opera10,linux-googlechrome7" /> + <property name="browsers-mac" value="osx-firefox3,osx-opera10,osx-googlechrome7,osx-safari4,osx-safari5" /> + + <property name="browsers" value="${browsers-windows}" /> <!-- Screen shot base directory --> <fail unless="com.vaadin.testbench.screenshot.directory" message="The 'com.vaadin.testbench.screenshot.directory' property must be defined." /> - + <!-- Screen shot resolution --> - <property name="com.vaadin.testbench.screenshot.resolution" value="1500x850"/> - + <property name="com.vaadin.testbench.screenshot.resolution" value="1500x850" /> + <!-- Host running Testbench Hub --> <property name="com.vaadin.testbench.tester.host" value="192.168.1.48" /> @@ -23,7 +27,7 @@ <property name="class-dir" value="${test-output-dir}/classes" /> <taskdef resource="net/sf/antcontrib/antlib.xml"> <classpath> - <pathelement location="../build/lib/ant-contrib-1.0b3.jar"/> + <pathelement location="../build/lib/ant-contrib-1.0b3.jar" /> </classpath> </taskdef> @@ -56,7 +60,7 @@ <!-- This target complies the generated java junit tests. --> <target name="compile-tests" depends="create-tests"> <mkdir dir="${class-dir}" /> - <javac srcdir="${test-output-dir}" destdir="${class-dir}" debug="on" fork="yes" failonerror="false" encoding="UTF8" > + <javac srcdir="${test-output-dir}" destdir="${class-dir}" debug="on" fork="yes" failonerror="false" encoding="UTF8"> <classpath> <path refid="classpath" /> </classpath> @@ -136,7 +140,7 @@ <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" /> <!-- Resolution for screenshots --> <jvmarg value="-Dcom.vaadin.testbench.screenshot.resolution=${com.vaadin.testbench.screenshot.resolution}" /> - + <jvmarg value="-Djava.awt.headless=true" /> <!-- true/false system arguments --> @@ -148,7 +152,7 @@ <filelist dir="${test-output-dir}" files="${target}" /> </batchtest> </junit> - + </target> <!-- Remove temporary source and compiled java files --> @@ -176,9 +180,7 @@ <!-- ================================================================== --> <!-- The default target. --> - <target name="run-and-clean-up" - depends="check-parameters,remove-error-screens,run-tests,remove-temp-testclasses" - if="server.start.succeeded"> + <target name="run-and-clean-up" depends="check-parameters,remove-error-screens,run-tests,remove-temp-testclasses" if="server.start.succeeded"> </target> <!-- Also starts the server. --> |