diff options
123 files changed, 4296 insertions, 5058 deletions
diff --git a/WebContent/VAADIN/themes/base/csslayout/csslayout.css b/WebContent/VAADIN/themes/base/csslayout/csslayout.css index 12f1cd08fc..1f85d6f460 100644 --- a/WebContent/VAADIN/themes/base/csslayout/csslayout.css +++ b/WebContent/VAADIN/themes/base/csslayout/csslayout.css @@ -1,16 +1,15 @@ .v-csslayout { overflow: hidden; } - .v-csslayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-csslayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-csslayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-csslayout-margin-right { - padding-right: 2em; -} + padding-right: 12px; +}
\ No newline at end of file diff --git a/WebContent/VAADIN/themes/base/datefield/datefield.css b/WebContent/VAADIN/themes/base/datefield/datefield.css index 720a80716f..fd2730bf24 100644 --- a/WebContent/VAADIN/themes/base/datefield/datefield.css +++ b/WebContent/VAADIN/themes/base/datefield/datefield.css @@ -51,6 +51,9 @@ .v-datefield-time .v-label { display: inline; } +.v-datefield-popup { + background: #fff; +} /* Disabled by default .v-datefield-error .v-textfield, .v-datefield-error .v-datefield-calendarpanel { diff --git a/WebContent/VAADIN/themes/base/formlayout/formlayout.css b/WebContent/VAADIN/themes/base/formlayout/formlayout.css index 47ae45df52..9566ff1663 100644 --- a/WebContent/VAADIN/themes/base/formlayout/formlayout.css +++ b/WebContent/VAADIN/themes/base/formlayout/formlayout.css @@ -15,7 +15,7 @@ .v-formlayout-spacing .v-formlayout-row .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-contentcell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-errorcell { - padding-top: 1em; + padding-top: 6px; } .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-contentcell, @@ -25,18 +25,18 @@ .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-contentcell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-errorcell { - padding-top: 2em; + padding-top: 12px; } .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-captioncell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-contentcell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-errorcell { - padding-bottom: 2em; + padding-bottom: 12px; } .v-formlayout-margin-left .v-formlayout-captioncell { - padding-left: 2em; + padding-left: 12px; } .v-formlayout-margin-right .v-formlayout-contentcell { - padding-right: 2em; + padding-right: 12px; } .v-formlayout-captioncell .v-caption .v-required-field-indicator { float: none; diff --git a/WebContent/VAADIN/themes/base/gridlayout/gridlayout.css b/WebContent/VAADIN/themes/base/gridlayout/gridlayout.css index 039f080ac2..87cdcfd361 100644 --- a/WebContent/VAADIN/themes/base/gridlayout/gridlayout.css +++ b/WebContent/VAADIN/themes/base/gridlayout/gridlayout.css @@ -1,18 +1,18 @@ .v-gridlayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-gridlayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-gridlayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-gridlayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-gridlayout-spacing-on { - padding-left: 1em; - padding-top: 1em; + padding-left: 6px; + padding-top: 6px; overflow: hidden; } .v-gridlayout-spacing, diff --git a/WebContent/VAADIN/themes/base/orderedlayout/orderedlayout.css b/WebContent/VAADIN/themes/base/orderedlayout/orderedlayout.css index 6dafa2d252..9f91669385 100644 --- a/WebContent/VAADIN/themes/base/orderedlayout/orderedlayout.css +++ b/WebContent/VAADIN/themes/base/orderedlayout/orderedlayout.css @@ -1,28 +1,28 @@ .v-orderedlayout-margin-top, .v-horizontallayout-margin-top, .v-verticallayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-orderedlayout-margin-right, .v-horizontallayout-margin-right, .v-verticallayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-orderedlayout-margin-bottom, .v-horizontallayout-margin-bottom, .v-verticallayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-orderedlayout-margin-left, .v-horizontallayout-margin-left, .v-verticallayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-orderedlayout-spacing-on, .v-horizontallayout-spacing-on, .v-verticallayout-spacing-on { - padding-top: 1em; - padding-left: 1em; + padding-top: 6px; + padding-left: 6px; } /* This can be used to define spacing if spacing is off server side */ .v-orderedlayout-spacing-off, diff --git a/WebContent/VAADIN/themes/base/styles.css b/WebContent/VAADIN/themes/base/styles.css index 60fb294fa0..ae67ae2a7a 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_3_0_dev-20100304";} -.v-theme-version-6_3_0_dev-20100304 {display: none;} +.v-theme-version:after {content:"6_3_0_dev-20100305";} +.v-theme-version-6_3_0_dev-20100305 {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -484,18 +484,17 @@ div.v-app-loading { .v-csslayout { overflow: hidden; } - .v-csslayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-csslayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-csslayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-csslayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-customcomponent { @@ -559,6 +558,9 @@ div.v-app-loading { .v-datefield-time .v-label { display: inline; } +.v-datefield-popup { + background: #fff; +} /* Disabled by default .v-datefield-error .v-textfield, .v-datefield-error .v-datefield-calendarpanel { @@ -598,7 +600,7 @@ div.v-app-loading { .v-formlayout-spacing .v-formlayout-row .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-contentcell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-errorcell { - padding-top: 1em; + padding-top: 6px; } .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-contentcell, @@ -608,38 +610,38 @@ div.v-app-loading { .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-contentcell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-errorcell { - padding-top: 2em; + padding-top: 12px; } .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-captioncell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-contentcell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-errorcell { - padding-bottom: 2em; + padding-bottom: 12px; } .v-formlayout-margin-left .v-formlayout-captioncell { - padding-left: 2em; + padding-left: 12px; } .v-formlayout-margin-right .v-formlayout-contentcell { - padding-right: 2em; + padding-right: 12px; } .v-formlayout-captioncell .v-caption .v-required-field-indicator { float: none; } .v-gridlayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-gridlayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-gridlayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-gridlayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-gridlayout-spacing-on { - padding-left: 1em; - padding-top: 1em; + padding-left: 6px; + padding-top: 6px; overflow: hidden; } .v-gridlayout-spacing, @@ -796,28 +798,28 @@ div.v-app-loading { .v-orderedlayout-margin-top, .v-horizontallayout-margin-top, .v-verticallayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-orderedlayout-margin-right, .v-horizontallayout-margin-right, .v-verticallayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-orderedlayout-margin-bottom, .v-horizontallayout-margin-bottom, .v-verticallayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-orderedlayout-margin-left, .v-horizontallayout-margin-left, .v-verticallayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-orderedlayout-spacing-on, .v-horizontallayout-spacing-on, .v-verticallayout-spacing-on { - padding-top: 1em; - padding-left: 1em; + padding-top: 6px; + padding-left: 6px; } /* This can be used to define spacing if spacing is off server side */ .v-orderedlayout-spacing-off, @@ -1339,6 +1341,10 @@ div.v-progressindicator-indeterminate-disabled { .v-table-header-cell-desc .v-table-caption-container { background: transparent url(common/img/sprites.png) no-repeat right -10px; } +.v-table-caption-container .v-icon, +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-body { border: 1px solid #aaa; } @@ -1403,6 +1409,9 @@ div.v-progressindicator-indeterminate-disabled { margin-top: 20px; z-index: 30000; } +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-scrollposition { width: 160px; background: #eee; @@ -1694,7 +1703,10 @@ div.v-tree-node-leaf { right: 0; height: 21px; text-align: right; + border: none; + background: transparent; } + .v-upload-immediate button { position: relative; left: 0; diff --git a/WebContent/VAADIN/themes/base/table/table.css b/WebContent/VAADIN/themes/base/table/table.css index 213d090b52..e26d3aa22c 100644 --- a/WebContent/VAADIN/themes/base/table/table.css +++ b/WebContent/VAADIN/themes/base/table/table.css @@ -72,6 +72,10 @@ .v-table-header-cell-desc .v-table-caption-container { background: transparent url(../common/img/sprites.png) no-repeat right -10px; } +.v-table-caption-container .v-icon, +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-body { border: 1px solid #aaa; } @@ -136,6 +140,9 @@ margin-top: 20px; z-index: 30000; } +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-scrollposition { width: 160px; background: #eee; diff --git a/WebContent/VAADIN/themes/base/upload/upload.css b/WebContent/VAADIN/themes/base/upload/upload.css index 73f9490738..eb5a300296 100644 --- a/WebContent/VAADIN/themes/base/upload/upload.css +++ b/WebContent/VAADIN/themes/base/upload/upload.css @@ -12,7 +12,10 @@ right: 0; height: 21px; text-align: right; + border: none; + background: transparent; } + .v-upload-immediate button { position: relative; left: 0; diff --git a/WebContent/VAADIN/themes/reindeer/layouts/layouts.css b/WebContent/VAADIN/themes/reindeer/layouts/layouts.css index 1699baddf7..5920830086 100644 --- a/WebContent/VAADIN/themes/reindeer/layouts/layouts.css +++ b/WebContent/VAADIN/themes/reindeer/layouts/layouts.css @@ -24,6 +24,24 @@ padding-top: 7px; padding-left: 6px; } +/* Different for historical reasons: previously was inherited directly from Base theme */ +/* TODO unify these values in version 7 */ +.v-gridlayout-margin-top { + padding-top: 24px; +} +.v-gridlayout-margin-bottom { + padding-bottom: 24px; +} +.v-gridlayout-margin-left { + padding-left: 24px; +} +.v-gridlayout-margin-right { + padding-right: 24px; +} +.v-gridlayout-spacing-on { + padding-left: 12px; + padding-top: 12px; +} /* Blue background */ .v-verticallayout-blue, .v-horizontallayout-blue, diff --git a/WebContent/VAADIN/themes/reindeer/styles.css b/WebContent/VAADIN/themes/reindeer/styles.css index c2df4128e4..60451c64c7 100644 --- a/WebContent/VAADIN/themes/reindeer/styles.css +++ b/WebContent/VAADIN/themes/reindeer/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"6_3_0_dev-20100304";} -.v-theme-version-6_3_0_dev-20100304 {display: none;} +.v-theme-version:after {content:"6_3_0_dev-20100305";} +.v-theme-version-6_3_0_dev-20100305 {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -484,18 +484,17 @@ div.v-app-loading { .v-csslayout { overflow: hidden; } - .v-csslayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-csslayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-csslayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-csslayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-customcomponent { @@ -559,6 +558,9 @@ div.v-app-loading { .v-datefield-time .v-label { display: inline; } +.v-datefield-popup { + background: #fff; +} /* Disabled by default .v-datefield-error .v-textfield, .v-datefield-error .v-datefield-calendarpanel { @@ -598,7 +600,7 @@ div.v-app-loading { .v-formlayout-spacing .v-formlayout-row .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-contentcell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-errorcell { - padding-top: 1em; + padding-top: 6px; } .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-contentcell, @@ -608,38 +610,38 @@ div.v-app-loading { .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-contentcell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-errorcell { - padding-top: 2em; + padding-top: 12px; } .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-captioncell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-contentcell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-errorcell { - padding-bottom: 2em; + padding-bottom: 12px; } .v-formlayout-margin-left .v-formlayout-captioncell { - padding-left: 2em; + padding-left: 12px; } .v-formlayout-margin-right .v-formlayout-contentcell { - padding-right: 2em; + padding-right: 12px; } .v-formlayout-captioncell .v-caption .v-required-field-indicator { float: none; } .v-gridlayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-gridlayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-gridlayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-gridlayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-gridlayout-spacing-on { - padding-left: 1em; - padding-top: 1em; + padding-left: 6px; + padding-top: 6px; overflow: hidden; } .v-gridlayout-spacing, @@ -796,28 +798,28 @@ div.v-app-loading { .v-orderedlayout-margin-top, .v-horizontallayout-margin-top, .v-verticallayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-orderedlayout-margin-right, .v-horizontallayout-margin-right, .v-verticallayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-orderedlayout-margin-bottom, .v-horizontallayout-margin-bottom, .v-verticallayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-orderedlayout-margin-left, .v-horizontallayout-margin-left, .v-verticallayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-orderedlayout-spacing-on, .v-horizontallayout-spacing-on, .v-verticallayout-spacing-on { - padding-top: 1em; - padding-left: 1em; + padding-top: 6px; + padding-left: 6px; } /* This can be used to define spacing if spacing is off server side */ .v-orderedlayout-spacing-off, @@ -1339,6 +1341,10 @@ div.v-progressindicator-indeterminate-disabled { .v-table-header-cell-desc .v-table-caption-container { background: transparent url(../base/common/img/sprites.png) no-repeat right -10px; } +.v-table-caption-container .v-icon, +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-body { border: 1px solid #aaa; } @@ -1403,6 +1409,9 @@ div.v-progressindicator-indeterminate-disabled { margin-top: 20px; z-index: 30000; } +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-scrollposition { width: 160px; background: #eee; @@ -1694,7 +1703,10 @@ div.v-tree-node-leaf { right: 0; height: 21px; text-align: right; + border: none; + background: transparent; } + .v-upload-immediate button { position: relative; left: 0; @@ -3133,6 +3145,24 @@ td.v-datefield-calendarpanel-nextyear { padding-top: 7px; padding-left: 6px; } +/* Different for historical reasons: previously was inherited directly from Base theme */ +/* TODO unify these values in version 7 */ +.v-gridlayout-margin-top { + padding-top: 24px; +} +.v-gridlayout-margin-bottom { + padding-bottom: 24px; +} +.v-gridlayout-margin-left { + padding-left: 24px; +} +.v-gridlayout-margin-right { + padding-right: 24px; +} +.v-gridlayout-spacing-on { + padding-left: 12px; + padding-top: 12px; +} /* Blue background */ .v-verticallayout-blue, .v-horizontallayout-blue, diff --git a/WebContent/VAADIN/themes/runo/favicon.ico b/WebContent/VAADIN/themes/runo/favicon.ico Binary files differindex 2c731f8f85..e58158c02c 100644 --- a/WebContent/VAADIN/themes/runo/favicon.ico +++ b/WebContent/VAADIN/themes/runo/favicon.ico diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css index cf6236a886..493a7ea8eb 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_3_0_dev-20100304";} -.v-theme-version-6_3_0_dev-20100304 {display: none;} +.v-theme-version:after {content:"6_3_0_dev-20100305";} +.v-theme-version-6_3_0_dev-20100305 {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -484,18 +484,17 @@ div.v-app-loading { .v-csslayout { overflow: hidden; } - .v-csslayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-csslayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-csslayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-csslayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-customcomponent { @@ -559,6 +558,9 @@ div.v-app-loading { .v-datefield-time .v-label { display: inline; } +.v-datefield-popup { + background: #fff; +} /* Disabled by default .v-datefield-error .v-textfield, .v-datefield-error .v-datefield-calendarpanel { @@ -598,7 +600,7 @@ div.v-app-loading { .v-formlayout-spacing .v-formlayout-row .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-contentcell, .v-formlayout-spacing .v-formlayout-row .v-formlayout-errorcell { - padding-top: 1em; + padding-top: 6px; } .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-spacing .v-formlayout-firstrow .v-formlayout-contentcell, @@ -608,38 +610,38 @@ div.v-app-loading { .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-captioncell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-contentcell, .v-formlayout-margin-top .v-formlayout-firstrow .v-formlayout-errorcell { - padding-top: 2em; + padding-top: 12px; } .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-captioncell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-contentcell, .v-formlayout-margin-bottom .v-formlayout-lastrow .v-formlayout-errorcell { - padding-bottom: 2em; + padding-bottom: 12px; } .v-formlayout-margin-left .v-formlayout-captioncell { - padding-left: 2em; + padding-left: 12px; } .v-formlayout-margin-right .v-formlayout-contentcell { - padding-right: 2em; + padding-right: 12px; } .v-formlayout-captioncell .v-caption .v-required-field-indicator { float: none; } .v-gridlayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-gridlayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-gridlayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-gridlayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-gridlayout-spacing-on { - padding-left: 1em; - padding-top: 1em; + padding-left: 6px; + padding-top: 6px; overflow: hidden; } .v-gridlayout-spacing, @@ -796,28 +798,28 @@ div.v-app-loading { .v-orderedlayout-margin-top, .v-horizontallayout-margin-top, .v-verticallayout-margin-top { - padding-top: 2em; + padding-top: 12px; } .v-orderedlayout-margin-right, .v-horizontallayout-margin-right, .v-verticallayout-margin-right { - padding-right: 2em; + padding-right: 12px; } .v-orderedlayout-margin-bottom, .v-horizontallayout-margin-bottom, .v-verticallayout-margin-bottom { - padding-bottom: 2em; + padding-bottom: 12px; } .v-orderedlayout-margin-left, .v-horizontallayout-margin-left, .v-verticallayout-margin-left { - padding-left: 2em; + padding-left: 12px; } .v-orderedlayout-spacing-on, .v-horizontallayout-spacing-on, .v-verticallayout-spacing-on { - padding-top: 1em; - padding-left: 1em; + padding-top: 6px; + padding-left: 6px; } /* This can be used to define spacing if spacing is off server side */ .v-orderedlayout-spacing-off, @@ -1339,6 +1341,10 @@ div.v-progressindicator-indeterminate-disabled { .v-table-header-cell-desc .v-table-caption-container { background: transparent url(../base/common/img/sprites.png) no-repeat right -10px; } +.v-table-caption-container .v-icon, +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-body { border: 1px solid #aaa; } @@ -1403,6 +1409,9 @@ div.v-progressindicator-indeterminate-disabled { margin-top: 20px; z-index: 30000; } +.v-table-header-drag .v-icon { + vertical-align: middle; +} .v-table-scrollposition { width: 160px; background: #eee; @@ -1694,7 +1703,10 @@ div.v-tree-node-leaf { right: 0; height: 21px; text-align: right; + border: none; + background: transparent; } + .v-upload-immediate button { position: relative; left: 0; diff --git a/WebContent/VAADIN/themes/sampler-reindeer/favicon.ico b/WebContent/VAADIN/themes/sampler-reindeer/favicon.ico Binary files differnew file mode 100644 index 0000000000..e58158c02c --- /dev/null +++ b/WebContent/VAADIN/themes/sampler-reindeer/favicon.ico diff --git a/WebContent/VAADIN/themes/sampler-runo/favicon.ico b/WebContent/VAADIN/themes/sampler-runo/favicon.ico Binary files differnew file mode 100644 index 0000000000..e58158c02c --- /dev/null +++ b/WebContent/VAADIN/themes/sampler-runo/favicon.ico diff --git a/WebContent/WEB-INF/portlet.xml b/WebContent/WEB-INF/portlet.xml index b1a6d4722d..bab08d4eb1 100644 --- a/WebContent/WEB-INF/portlet.xml +++ b/WebContent/WEB-INF/portlet.xml @@ -2,7 +2,7 @@ <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"> - + <portlet> <portlet-name>PortletDemoPortlet</portlet-name> <display-name>Vaadin PortletDemo</display-name> @@ -120,7 +120,7 @@ <role-name>user</role-name> </security-role-ref> </portlet> - + <portlet> <portlet-name>HelloWorldPortlet</portlet-name> <display-name>Hello World</display-name> @@ -136,92 +136,75 @@ <portlet-info> <title>HelloWorld</title> <short-title>HelloWorld</short-title> - </portlet-info> + </portlet-info> </portlet> - <!-- - <portlet> - <portlet-name>VaadinInterPortletEventPortlet</portlet-name> + <!-- + <portlet> <portlet-name>VaadinInterPortletEventPortlet</portlet-name> <display-name>Hello World Event</display-name> <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class> - <init-param> - <name>application</name> - <value>com.vaadin.demo.portlet.VaadinInterPortletEventPortlet</value> - </init-param> - <init-param> - <name>widgetset</name> - <value>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</value> - </init-param> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - </supports> - <portlet-info> - <title>Inter-portlet events</title> - <short-title>Inter-portlet events</short-title> - </portlet-info> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> - </supported-processing-event> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> - </supported-processing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> - </supported-publishing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> + <init-param> <name>application</name> + <value>com.vaadin.demo.portlet.VaadinInterPortletEventPortlet</value> + </init-param> <init-param> <name>widgetset</name> + <value>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</value> + </init-param> <supports> <mime-type>text/html</mime-type> + <portlet-mode>view</portlet-mode> </supports> <portlet-info> + <title>Inter-portlet events</title> <short-title>Inter-portlet + events</short-title> </portlet-info> <supported-processing-event> + <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> + </supported-processing-event> <supported-processing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> + </supported-processing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> + </supported-publishing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> </supported-publishing-event> - <supported-public-render-parameter>HelloState</supported-public-render-parameter> - </portlet> - - <portlet> + <supported-public-render-parameter>HelloState</supported-public-render-parameter> + </portlet> <portlet> <portlet-name>InterPortletEventPortlet</portlet-name> <display-name>Hello World Event (non-Vaadin)</display-name> <portlet-class>com.vaadin.demo.portlet.InterPortletEventPortlet</portlet-class> + <supports> <mime-type>text/html</mime-type> + <portlet-mode>view</portlet-mode> </supports> <portlet-info> + <title>Inter-portlet events (non-Vaadin)</title> + <short-title>Inter-portlet events (non-Vaadin)</short-title> + </portlet-info> <supported-processing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> + </supported-processing-event> <supported-processing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> + </supported-processing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> + </supported-publishing-event> <supported-publishing-event> <qname + xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> + </supported-publishing-event> + <supported-public-render-parameter>HelloState</supported-public-render-parameter> + </portlet> + --> + <portlet> + <portlet-name>Portlet Mode Example</portlet-name> + <display-name>Portlet Mode Example</display-name> + <portlet-class>com.vaadin.demo.portlet.PortletModePortlet</portlet-class> + <init-param> + <name>widgetset</name> + <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> + </init-param> + <init-param> + <name>application</name> + <value>com.vaadin.demo.portlet.PortletModeExample</value> + </init-param> + <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> + <portlet-mode>edit</portlet-mode> + <portlet-mode>help</portlet-mode> + <portlet-mode>config</portlet-mode> </supports> <portlet-info> - <title>Inter-portlet events (non-Vaadin)</title> - <short-title>Inter-portlet events (non-Vaadin)</short-title> + <title>PortletModeExample</title> + <short-title>PortletModeExample</short-title> </portlet-info> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> - </supported-processing-event> - <supported-processing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:FromVaadin</qname> - </supported-processing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> - </supported-publishing-event> - <supported-publishing-event> - <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:ReplyToVaadin</qname> - </supported-publishing-event> - <supported-public-render-parameter>HelloState</supported-public-render-parameter> </portlet> - --> - <portlet> - <portlet-name>Portlet Mode Example</portlet-name> - <display-name>Portlet Mode Example</display-name> - <portlet-class>com.vaadin.demo.portlet.PortletModePortlet</portlet-class> - <init-param> - <name>widgetset</name> - <value>com.vaadin.portal.gwt.PortalDefaultWidgetSet</value> - </init-param> - <supports> - <mime-type>text/html</mime-type> - <portlet-mode>view</portlet-mode> - <portlet-mode>edit</portlet-mode> - <portlet-mode>help</portlet-mode> - <portlet-mode>config</portlet-mode> - </supports> - <portlet-info> - <title>PortletModeExample</title> - <short-title>PortletModeExample</short-title> - </portlet-info> - </portlet> <portlet> <portlet-name>AddressBookPortlet</portlet-name> @@ -238,9 +221,9 @@ <portlet-info> <title>Address Book</title> <short-title>Address Book</short-title> - </portlet-info> - </portlet> - + </portlet-info> + </portlet> + <portlet> <portlet-name>SamplerPortlet</portlet-name> <display-name>Sampler</display-name> @@ -260,9 +243,9 @@ <portlet-info> <title>Sampler</title> <short-title>Sampler</short-title> - </portlet-info> + </portlet-info> </portlet> - + <portlet> <portlet-name>CalcPortlet</portlet-name> <display-name>Calc</display-name> @@ -274,7 +257,7 @@ <init-param> <name>widgetset</name> <value>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</value> - </init-param> + </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> @@ -282,8 +265,8 @@ <portlet-info> <title>Calc</title> <short-title>Calc</short-title> - </portlet-info> - </portlet> + </portlet-info> + </portlet> <portlet> <portlet-name>ChatServletPortlet</portlet-name> <display-name>Vaadin ChatServlet</display-name> @@ -361,23 +344,23 @@ <role-name>user</role-name> </security-role-ref> </portlet> - + <!-- Used by the Portlet mode demo --> - <custom-portlet-mode> - <description>Custom mode</description> - <portlet-mode>config</portlet-mode> - <portal-managed>false</portal-managed> - </custom-portlet-mode> + <custom-portlet-mode> + <description>Custom mode</description> + <portlet-mode>config</portlet-mode> + <portal-managed>false</portal-managed> + </custom-portlet-mode> <!-- - These can be used to customize the event object types. - The types must be serializable and have JAXB binding. + These can be used to customize the event object types. The types must + be serializable and have JAXB binding. --> <event-definition> <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Hello</qname> <value-type>java.lang.String</value-type> - </event-definition> - + </event-definition> + <event-definition> <qname xmlns:vaadin="http://www.vaadin.com/hello">vaadin:Reply</qname> <value-type>java.lang.String</value-type> @@ -387,7 +370,7 @@ <identifier>HelloState</identifier> <qname xmlns:vaadin="http://www.vaadin.com/params">vaadin:HelloState</qname> </public-render-parameter> - + <!-- This can be used to work around an issue in liferay 5.0-5.1.1 diff --git a/build/GWT-VERSION.properties b/build/GWT-VERSION.properties index b796d79821..b36391604d 100644 --- a/build/GWT-VERSION.properties +++ b/build/GWT-VERSION.properties @@ -1 +1 @@ -gwt-version=2.0.0
\ No newline at end of file +gwt-version=2.0.3
\ No newline at end of file diff --git a/build/bin/mergetool.py b/build/bin/mergetool.py index 7ed1cb1579..c22fd952bc 100755 --- a/build/bin/mergetool.py +++ b/build/bin/mergetool.py @@ -82,7 +82,7 @@ def listChangedFiles(): line = line[:-1] # Extract the file state and name - (filestate, filename) = re.split(r'[ \+]+', line) + (filestate, filename) = re.split(r'[ \+]+', line.lstrip()) # Ignore files in build directory if (filename.startswith("build/merge/") \ diff --git a/build/build.xml b/build/build.xml index 771fe185d5..3d00e344ad 100644 --- a/build/build.xml +++ b/build/build.xml @@ -11,20 +11,9 @@ package-all * creates the release package, a war, and a Liferay war - package-windows - * vaadin-windows-<version>.zip - - package-linux - * vaadin-linux-<version>.tar.bz2 - - package-mac - * vaadin-mac-<version>.tar.gz - * vaadin-mac-<version>.dmg - In addition, the OOPHM package has the following target for building: package-oophm * vaadin-oophm-<version>.zip - --> <!-- @@ -39,6 +28,12 @@ <target name="package-jar" depends="clean-result, package-init, init, libs" description="Create vaadin-x.y.z.jar file."> </target> + <!-- Compiles only the default widgetset. --> + <target name="package-jar-quick" depends="clean-result, package-init, init" description="Create vaadin-x.y.z.jar file quick."> + <property name="compile.only.default-widgetset" value="1"/> + <antcall target="libs"/> + </target> + <target name="package-war" depends="clean-result, package-init, init, build, docs, internal-package-zip, internal-package-war"> </target> @@ -135,6 +130,10 @@ <target name="init" depends="check-java-version"> <property file="build/build.properties" /> <property file="build/VERSION.properties" /> + <antcontrib:propertyregex property="version.major" input="${version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\1"/> + <antcontrib:propertyregex property="version.minor" input="${version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\2"/> + <antcontrib:propertyregex property="version.revision" input="${version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\3"/> + <property file="build/GWT-VERSION.properties" /> <property file="build/html-style.properties" /> @@ -697,13 +696,13 @@ </antcall> </target> - <target name="compile-widgetset-portal-default"> + <target name="compile-widgetset-portal-default" unless="compile.only.default-widgetset"> <antcall target="compile-widgetset"> <param name="widgetset" value="com.vaadin.portal.gwt.PortalDefaultWidgetSet"/> </antcall> </target> - <target name="compile-widgetset-reserver"> + <target name="compile-widgetset-reserver" unless="compile.only.default-widgetset"> <condition property="googlemaps-jar" value="${output-dir}/WebContent/demo/lib/gwt-maps/gwt-maps.jar"> <available file="${output-dir}/WebContent/demo/lib/gwt-maps/gwt-maps.jar" /> </condition> @@ -734,17 +733,17 @@ <echo>Compiled ReservationWidgetSet</echo> </target> - <target name="compile-widgetset-sampler"> + <target name="compile-widgetset-sampler" unless="compile.only.default-widgetset"> <antcall target="compile-widgetset"> <param name="widgetset" value="com.vaadin.demo.sampler.gwt.SamplerWidgetSet"/> </antcall> </target> - <target name="compile-widgetset-coverflow"> + <target name="compile-widgetset-coverflow" unless="compile.only.default-widgetset"> <antcall target="compile-widgetset"> <param name="widgetset" value="com.vaadin.demo.coverflow.gwt.CoverflowWidgetSet"/> </antcall> </target> - <target name="compile-widgetset-colorpicker"> + <target name="compile-widgetset-colorpicker" unless="compile.only.default-widgetset"> <antcall target="compile-widgetset"> <param name="widgetset" value="com.vaadin.demo.colorpicker.gwt.ColorPickerWidgetSet"/> </antcall> @@ -757,7 +756,6 @@ <!-- We can't call these with 'depends' because of the 'unless' specifier. --> <antcall target="compile-widgetset-default"/> <antcall target="compile-widgetset-portal-default"/> - <antcall target="compile-widgetset-reserver"/> <antcall target="compile-widgetset-sampler"/> <antcall target="compile-widgetset-colorpicker"/> <antcall target="compile-widgetset-coverflow"/> @@ -770,7 +768,6 @@ <parallel threadsperprocessor="1"> <antcall target="compile-widgetset-default"/> <antcall target="compile-widgetset-portal-default"/> - <antcall target="compile-widgetset-reserver"/> <antcall target="compile-widgetset-sampler"/> <antcall target="compile-widgetset-colorpicker"/> <antcall target="compile-widgetset-coverflow"/> @@ -839,7 +836,6 @@ <exclude name="${toolkit-package}/demo/**" /> <exclude name="${toolkit-package}/tests/**"/> <exclude name="${toolkit-package}/launcher/**" /> - <exclude name="${toolkit-package}/automatedtests/**" /> </patternset> </fileset> <!-- fileupload, see build/external/fileupload/build.xml --> @@ -1076,7 +1072,22 @@ </target> - <target name="nightly-maven-publish" depends=""> + <target name="nightly-maven-pom.xml"> + <echo>Creating pom.xml for nightly build</echo> + <fail unless="version.major" message="Major version must be defined in version.major"/> + <fail unless="version.minor" message="Major version must be defined in version.minor"/> + <copy tofile="build/maven/pom.xml"> + <filterchain> + <expandproperties /> + <replacetokens begintoken="@" endtoken="@"> + <token key="VERSION-MAJOR.MINOR" value="${version.major}.${version.minor}" /> + </replacetokens> + </filterchain> + <fileset file="build/maven/pom-template.xml"/> + </copy> + </target> + + <target name="nightly-maven-publish" depends="nightly-maven-pom.xml"> <property file="${gpg.passphrase.file}" /> <echo>Publishing ${output-dir}/WebContent/${lib-jar-name} to Maven repository</echo> <artifact:mvn> diff --git a/build/maven/pom.xml b/build/maven/pom-template.xml index b03913baf8..5c2cb1a727 100644 --- a/build/maven/pom.xml +++ b/build/maven/pom-template.xml @@ -2,7 +2,7 @@ <modelVersion>4.0.0</modelVersion>
<groupId>com.vaadin</groupId>
<artifactId>vaadin</artifactId>
- <version>6.3-SNAPSHOT</version>
+ <version>@VERSION-MAJOR.MINOR@-SNAPSHOT</version>
<name>Vaadin</name>
<organization>
<name>Oy IT Mill Ltd</name>
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java index 67bc5e9da6..9a0c180a1d 100644 --- a/src/com/vaadin/Application.java +++ b/src/com/vaadin/Application.java @@ -1303,6 +1303,13 @@ public abstract class Application implements URIHandler, * <li><b>outOfSyncMessage</b> = "Something has caused us to be out of sync * with the server.<br/> * Take note of any unsaved data, and <u>click here</u> to re-sync."</li> + * <li><b>cookiesDisabledURL</b> = null</li> + * <li><b>cookiesDisabledNotificationEnabled</b> = true</li> + * <li><b>cookiesDisabledCaption</b> = "Cookies disabled"</li> + * <li><b>cookiesDisabledMessage</b> = "This application requires cookies to + * function.<br/> + * Please enable cookies in your browser and <u>click here</u> to try again. + * </li> * </ul> * </p> * @@ -1328,6 +1335,11 @@ public abstract class Application implements URIHandler, protected String outOfSyncCaption = "Out of sync"; protected String outOfSyncMessage = "Something has caused us to be out of sync with the server.<br/>Take note of any unsaved data, and <u>click here</u> to re-sync."; + protected String cookiesDisabledURL = null; + protected boolean cookiesDisabledNotificationEnabled = true; + protected String cookiesDisabledCaption = "Cookies disabled"; + protected String cookiesDisabledMessage = "This application requires cookies to function.<br/>Please enable cookies in your browser and <u>click here</u> to try again."; + /** * Use {@link CustomizedSystemMessages} to customize */ @@ -1462,6 +1474,52 @@ public abstract class Application implements URIHandler, return (outOfSyncNotificationEnabled ? outOfSyncMessage : null); } + /** + * Returns the URL the user should be redirected to after dismissing the + * "you have to enable your cookies" message. Typically null. + * + * @return A URL the user should be redirected to after dismissing the + * message or null to reload the current URL. + */ + public String getCookiesDisabledURL() { + return cookiesDisabledURL; + } + + /** + * Determines if "cookies disabled" messages should be shown to the end + * user or not. If the notification is disabled the user will be + * immediately redirected to the URL returned by + * {@link #getCookiesDisabledURL()}. + * + * @return true to show "cookies disabled" messages to the end user, + * false to redirect to the given URL directly + */ + public boolean isCookiesDisabledNotificationEnabled() { + return cookiesDisabledNotificationEnabled; + } + + /** + * Returns the caption of the message shown to the user when cookies are + * disabled in the browser. + * + * @return The caption of the "cookies disabled" message + */ + public String getCookiesDisabledCaption() { + return (cookiesDisabledNotificationEnabled ? cookiesDisabledCaption + : null); + } + + /** + * Returns the message shown to the user when cookies are disabled in + * the browser. + * + * @return The "cookies disabled" message + */ + public String getCookiesDisabledMessage() { + return (cookiesDisabledNotificationEnabled ? cookiesDisabledMessage + : null); + } + } /** @@ -1688,6 +1746,54 @@ public abstract class Application implements URIHandler, this.outOfSyncMessage = outOfSyncMessage; } + /** + * Sets the URL to redirect to when the browser has cookies disabled. + * + * @param cookiesDisabledURL + * the URL to redirect to, or null to reload the current URL + */ + public void setCookiesDisabledURL(String cookiesDisabledURL) { + this.cookiesDisabledURL = cookiesDisabledURL; + } + + /** + * Enables or disables the notification for "cookies disabled" messages. + * If disabled, the URL returned by {@link #getCookiesDisabledURL()} is + * loaded directly. + * + * @param cookiesDisabledNotificationEnabled + * true to enable "cookies disabled" messages, false + * otherwise + */ + public void setCookiesDisabledNotificationEnabled( + boolean cookiesDisabledNotificationEnabled) { + this.cookiesDisabledNotificationEnabled = cookiesDisabledNotificationEnabled; + } + + /** + * Sets the caption of the "cookies disabled" notification. Set to null + * for no caption. If both caption and message is null, the notification + * is disabled. + * + * @param cookiesDisabledCaption + * the caption for the "cookies disabled" notification + */ + public void setCookiesDisabledCaption(String cookiesDisabledCaption) { + this.cookiesDisabledCaption = cookiesDisabledCaption; + } + + /** + * Sets the message of the "cookies disabled" notification. Set to null + * for no message. If both caption and message is null, the notification + * is disabled. + * + * @param cookiesDisabledMessage + * the message for the "cookies disabled" notification + */ + public void setCookiesDisabledMessage(String cookiesDisabledMessage) { + this.cookiesDisabledMessage = cookiesDisabledMessage; + } + } /** diff --git a/src/com/vaadin/data/Container.java b/src/com/vaadin/data/Container.java index 5777bf2b05..6dbcfe779f 100644 --- a/src/com/vaadin/data/Container.java +++ b/src/com/vaadin/data/Container.java @@ -562,26 +562,34 @@ public interface Container extends Serializable { } /** - * Interface is implemented by containers that allow reducing their visible - * contents with set of filters. - * + * Interface that is implemented by containers which allow reducing their + * visible contents based on a set of filters. + * <p> * When a set of filters are set, only items that match the filters are * included in the visible contents of the container. Still new items that * do not match filters can be added to the container. Multiple filters can * be added and the container remembers the state of the filters. When * multiple filters are added, all filters must match for an item to be * visible in the container. - * + * </p> + * <p> * When an {@link com.vaadin.data.Ordered} or * {@link com.vaadin.data.Indexed} container is filtered, all operations of * these interfaces should only use the filtered contents and the filtered * indices to the container. - * + * </p> + * <p> + * How filtering is performed when a {@link Hierarchical} container + * implements {@link Filterable} is implementation specific and should be + * documented in the implementing class. + * </p> + * <p> * Adding items (if supported) to a filtered {@link com.vaadin.data.Ordered} * or {@link com.vaadin.data.Indexed} container should insert them * immediately after the indicated visible item. The unfiltered position of * items added at index 0, at index {@link com.vaadin.data.Container#size()} * or at an undefined position is up to the implementation. + * </p> * * @since 5.0 */ diff --git a/src/com/vaadin/data/util/BeanItemContainer.java b/src/com/vaadin/data/util/BeanItemContainer.java index 7848de5eed..6510229d5a 100644 --- a/src/com/vaadin/data/util/BeanItemContainer.java +++ b/src/com/vaadin/data/util/BeanItemContainer.java @@ -38,9 +38,23 @@ import com.vaadin.data.Property.ValueChangeNotifier; @SuppressWarnings("serial") public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, ItemSetChangeNotifier, ValueChangeListener { - // filtered and unfiltered item IDs - private ArrayList<BT> list = new ArrayList<BT>(); - private ArrayList<BT> allItems = new ArrayList<BT>(); + /** + * The filteredItems variable contains the items that are visible outside + * the container. If filters are enabled this contains a subset of allItems, + * if no filters are set this contains the same items as allItems. + */ + private ListSet<BT> filteredItems = new ListSet<BT>(); + + /** + * The allItems variable always contains all the items in the container. + * Some or all of these are also in the filteredItems list. + */ + private ListSet<BT> allItems = new ListSet<BT>(); + + /** + * Maps all pojos (item ids) in the container (including filtered) to their + * corresponding BeanItem. + */ private final Map<BT, BeanItem<BT>> beanToItem = new HashMap<BT, BeanItem<BT>>(); // internal data model to obtain property IDs etc. @@ -89,6 +103,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, * @throws IllegalArgumentException * If the collection is null or empty. */ + @SuppressWarnings("unchecked") public BeanItemContainer(Collection<BT> collection) throws IllegalArgumentException { if (collection == null || collection.isEmpty()) { @@ -98,10 +113,22 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, type = (Class<? extends BT>) collection.iterator().next().getClass(); model = BeanItem.getPropertyDescriptors(type); - int i = 0; - for (BT bt : collection) { - addItemAt(i++, bt); + addAll(collection); + } + + private void addAll(Collection<BT> collection) { + // Pre-allocate space for the collection + allItems.ensureCapacity(allItems.size() + collection.size()); + + int idx = size(); + for (BT bean : collection) { + if (internalAddAt(idx, bean) != null) { + idx++; + } } + + // Filter the contents when all items have been added + filterAll(); } /** @@ -147,36 +174,65 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, * @return Returns new item or null if the operation fails. */ private BeanItem<BT> addItemAtInternalIndex(int index, Object newItemId) { - // Make sure that the Item has not been created yet - if (allItems.contains(newItemId)) { + BeanItem<BT> beanItem = internalAddAt(index, (BT) newItemId); + if (beanItem != null) { + filterAll(); + } + + return beanItem; + } + + /** + * Adds the bean to all internal data structures at the given position. + * Fails if the bean is already in the container or is not assignable to the + * correct type. Returns the new BeanItem if the bean was added + * successfully. + * + * <p> + * Caller should call {@link #filterAll()} after calling this method to + * ensure the filtered list is updated. + * </p> + * + * @param position + * The position at which the bean should be inserted + * @param bean + * The bean to insert + * + * @return true if the bean was added successfully, false otherwise + */ + private BeanItem<BT> internalAddAt(int position, BT bean) { + // Make sure that the item has not been added previously + if (allItems.contains(bean)) { return null; } - if (type.isAssignableFrom(newItemId.getClass())) { - BT pojo = (BT) newItemId; - // "list" will be updated in filterAll() - allItems.add(index, pojo); - BeanItem<BT> beanItem = new BeanItem<BT>(pojo, model); - beanToItem.put(pojo, beanItem); - // add listeners to be able to update filtering on property changes - for (Filter filter : filters) { - // addValueChangeListener avoids adding duplicates - addValueChangeListener(beanItem, filter.propertyId); - } - // it is somewhat suboptimal to filter all items - filterAll(); - return beanItem; - } else { + if (!type.isAssignableFrom(bean.getClass())) { return null; } + + // "filteredList" will be updated in filterAll() which should be invoked + // by the caller after calling this method. + allItems.add(position, bean); + BeanItem<BT> beanItem = new BeanItem<BT>(bean, model); + beanToItem.put(bean, beanItem); + + // add listeners to be able to update filtering on property + // changes + for (Filter filter : filters) { + // addValueChangeListener avoids adding duplicates + addValueChangeListener(beanItem, filter.propertyId); + } + + return beanItem; } + @SuppressWarnings("unchecked") public BT getIdByIndex(int index) { - return list.get(index); + return filteredItems.get(index); } public int indexOfId(Object itemId) { - return list.indexOf(itemId); + return filteredItems.indexOf(itemId); } /** @@ -296,7 +352,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, public boolean containsId(Object itemId) { // only look at visible items after filtering - return list.contains(itemId); + return filteredItems.contains(itemId); } public Property getContainerProperty(Object itemId, Object propertyId) { @@ -311,8 +367,9 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return beanToItem.get(itemId); } + @SuppressWarnings("unchecked") public Collection<BT> getItemIds() { - return (Collection<BT>) list.clone(); + return (Collection<BT>) filteredItems.clone(); } public Class<?> getType(Object propertyId) { @@ -321,7 +378,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, public boolean removeAllItems() throws UnsupportedOperationException { allItems.clear(); - list.clear(); + filteredItems.clear(); // detach listeners from all BeanItems for (BeanItem<BT> item : beanToItem.values()) { removeAllValueChangeListeners(item); @@ -345,7 +402,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, removeAllValueChangeListeners(getItem(itemId)); // remove item beanToItem.remove(itemId); - list.remove(itemId); + filteredItems.remove(itemId); fireItemSetChange(); return true; } @@ -375,7 +432,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } public int size() { - return list.size(); + return filteredItems.size(); } public Collection<Object> getSortableContainerPropertyIds() { @@ -445,7 +502,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) { if (filters.isEmpty()) { - list = (ArrayList<BT>) allItems.clone(); + filteredItems = (ListSet<BT>) allItems.clone(); } // listen to change events to be able to update filtering for (BeanItem<BT> item : beanToItem.values()) { @@ -465,22 +522,22 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, */ protected void filterAll() { // avoid notification if the filtering had no effect - List<BT> originalItems = list; + List<BT> originalItems = filteredItems; // it is somewhat inefficient to do a (shallow) clone() every time - list = (ArrayList<BT>) allItems.clone(); + filteredItems = (ListSet<BT>) allItems.clone(); for (Filter f : filters) { filter(f); } // check if exactly the same items are there after filtering to avoid // unnecessary notifications // this may be slow in some cases as it uses BT.equals() - if (!originalItems.equals(list)) { + if (!originalItems.equals(filteredItems)) { fireItemSetChange(); } } protected void filter(Filter f) { - Iterator<BT> iterator = list.iterator(); + Iterator<BT> iterator = filteredItems.iterator(); while (iterator.hasNext()) { BT bean = iterator.next(); if (!f.passesFilter(getItem(bean))) { diff --git a/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java b/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java index 80065f9254..8b6fedb8e4 100644 --- a/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/vaadin/data/util/ContainerHierarchicalWrapper.java @@ -220,7 +220,12 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, return ((Container.Hierarchical) container) .areChildrenAllowed(itemId); } - return !noChildrenAllowed.contains(itemId); + + if (noChildrenAllowed.contains(itemId)) { + return false; + } + + return containsId(itemId); } /* @@ -284,7 +289,11 @@ public class ContainerHierarchicalWrapper implements Container.Hierarchical, return ((Container.Hierarchical) container).isRoot(itemId); } - return parent.get(itemId) == null; + if (parent.containsKey(itemId)) { + return false; + } + + return containsId(itemId); } /* diff --git a/src/com/vaadin/data/util/HierarchicalContainer.java b/src/com/vaadin/data/util/HierarchicalContainer.java index 2b5519e651..a404d83eb1 100644 --- a/src/com/vaadin/data/util/HierarchicalContainer.java +++ b/src/com/vaadin/data/util/HierarchicalContainer.java @@ -42,16 +42,29 @@ public class HierarchicalContainer extends IndexedContainer implements private final HashMap<Object, LinkedList<Object>> children = new HashMap<Object, LinkedList<Object>>(); /** + * Mapping from Item ID to a list of child IDs when filtered + */ + private HashMap<Object, LinkedList<Object>> filteredChildren = null; + + /** * List that contains all root elements of the container. */ private final LinkedList<Object> roots = new LinkedList<Object>(); + /** + * List that contains all filtered root elements of the container. + */ + private LinkedList<Object> filteredRoots = null; + /* * Can the specified Item have any children? Don't add a JavaDoc comment * here, we use the default documentation from implemented interface. */ public boolean areChildrenAllowed(Object itemId) { - return !noChildrenAllowed.contains(itemId); + if (noChildrenAllowed.contains(itemId)) { + return false; + } + return containsId(itemId); } /* @@ -60,7 +73,14 @@ public class HierarchicalContainer extends IndexedContainer implements * interface. */ public Collection getChildren(Object itemId) { - final Collection c = children.get(itemId); + LinkedList<Object> c; + + if (filteredChildren != null) { + c = filteredChildren.get(itemId); + } else { + c = children.get(itemId); + } + if (c == null) { return null; } @@ -82,7 +102,11 @@ public class HierarchicalContainer extends IndexedContainer implements * interface. */ public boolean hasChildren(Object itemId) { - return children.get(itemId) != null; + if (filteredChildren != null) { + return filteredChildren.containsKey(itemId); + } else { + return children.containsKey(itemId); + } } /* @@ -91,7 +115,15 @@ public class HierarchicalContainer extends IndexedContainer implements * interface. */ public boolean isRoot(Object itemId) { - return parent.get(itemId) == null; + if (filteredRoots != null && !filteredRoots.contains(itemId)) { + return false; + } + + if (parent.containsKey(itemId)) { + return false; + } + + return containsId(itemId); } /* @@ -100,7 +132,11 @@ public class HierarchicalContainer extends IndexedContainer implements * interface. */ public Collection rootItemIds() { - return Collections.unmodifiableCollection(roots); + if (filteredRoots != null) { + return Collections.unmodifiableCollection(filteredRoots); + } else { + return Collections.unmodifiableCollection(roots); + } } /** @@ -139,25 +175,6 @@ public class HierarchicalContainer extends IndexedContainer implements return true; } - @Override - public Item addItemAt(int index, Object newItemId) { - Item retval = super.addItemAt(index, newItemId); - if (getParent(newItemId) == null) { - int refIndex = roots.size() - 1; - int indexOfId = indexOfId(roots.get(refIndex)); - while (indexOfId > index) { - refIndex--; - if (refIndex < 0) { - // inserts as first - break; - } - indexOfId = indexOfId(roots.get(refIndex)); - } - roots.add(refIndex + 1, newItemId); - } - return retval; - } - /** * <p> * Sets the parent of an Item. The new parent item must exist and be able to @@ -191,27 +208,58 @@ public class HierarchicalContainer extends IndexedContainer implements return true; } - // Making root + // Making root? if (newParentId == null) { + // The itemId should become a root so we need to + // - Remove it from the old parent's children list (also filtered + // list) + // - Add it as a root + // - Remove it from the item -> parent list (parent is null for + // roots) // Removes from old parents children list - final LinkedList l = children.get(itemId); + final LinkedList<Object> l = children.get(itemId); if (l != null) { l.remove(itemId); if (l.isEmpty()) { children.remove(itemId); } + + if (filteredChildren != null) { + LinkedList<Object> f = filteredChildren.get(itemId); + if (f != null) { + f.remove(itemId); + if (f.isEmpty()) { + filteredChildren.remove(f); + } + } + } } // Add to be a root roots.add(itemId); + if (filteredRoots != null) { + if (passesFilters(itemId)) { + filteredRoots.add(itemId); + } + } // Updates parent parent.remove(itemId); + fireContentsChange(-1); + return true; } + // We get here when the item should not become a root and we need to + // - Verify the new parent exists and can have children + // - Check that the new parent is not a child of the selected itemId + // - Updated the item -> parent mapping to point to the new parent + // - Remove the item from the roots list if it was a root + // - Remove the item from the old parent's children list if it was not a + // root + // Checks that the new parent exists in container and can have // children if (!containsId(newParentId) || noChildrenAllowed.contains(newParentId)) { @@ -229,29 +277,92 @@ public class HierarchicalContainer extends IndexedContainer implements // Updates parent parent.put(itemId, newParentId); - LinkedList pcl = children.get(newParentId); + LinkedList<Object> pcl = children.get(newParentId); if (pcl == null) { - pcl = new LinkedList(); + // Create an empty list for holding children if one were not + // previously created + pcl = new LinkedList<Object>(); children.put(newParentId, pcl); } pcl.add(itemId); + // Add children list for filtered case also + if (filteredChildren != null) { + LinkedList<Object> f = filteredChildren.get(newParentId); + if (f == null) { + // Create an empty list for holding children if one were not + // previously created + f = new LinkedList<Object>(); + filteredChildren.put(newParentId, f); + } + } + // Removes from old parent or root if (oldParentId == null) { roots.remove(itemId); } else { - final LinkedList l = children.get(oldParentId); + final LinkedList<Object> l = children.get(oldParentId); if (l != null) { l.remove(itemId); if (l.isEmpty()) { children.remove(oldParentId); } } + if (filteredChildren != null) { + LinkedList<Object> f = filteredChildren.get(oldParentId); + if (f != null) { + f.remove(itemId); + if (f.isEmpty()) { + filteredChildren.remove(oldParentId); + } + } + } } + fireContentsChange(-1); + return true; } + /** + * TODO javadoc + * + * @param itemId + * @param siblingId + */ + public void moveAfterSibling(Object itemId, Object siblingId) { + Object parent2 = getParent(itemId); + LinkedList<Object> childrenList; + if (parent2 == null) { + childrenList = roots; + } else { + childrenList = children.get(parent2); + } + if (siblingId == null) { + childrenList.remove(itemId); + childrenList.addFirst(itemId); + + } else { + int oldIndex = childrenList.indexOf(itemId); + int indexOfSibling = childrenList.indexOf(siblingId); + if (indexOfSibling != -1 && oldIndex != -1) { + int newIndex; + if (oldIndex > indexOfSibling) { + newIndex = indexOfSibling + 1; + } else { + newIndex = indexOfSibling; + } + childrenList.remove(oldIndex); + childrenList.add(newIndex, itemId); + } else { + throw new IllegalArgumentException( + "Given identifiers no not have the same parent."); + } + } + fireContentsChange(-1); + + } + /* * (non-Javadoc) * @@ -259,12 +370,21 @@ public class HierarchicalContainer extends IndexedContainer implements */ @Override public Object addItem() { - final Object id = super.addItem(); - if (id != null && !roots.contains(id)) { - roots.add(id); + final Object itemId = super.addItem(); + if (itemId == null) { + return null; } - return id; + if (!roots.contains(itemId)) { + roots.add(itemId); + if (filteredRoots != null) { + if (passesFilters(itemId)) { + filteredRoots.add(itemId); + } + } + } + + return itemId; } /* @@ -275,9 +395,18 @@ public class HierarchicalContainer extends IndexedContainer implements @Override public Item addItem(Object itemId) { final Item item = super.addItem(itemId); - if (item != null) { - roots.add(itemId); + if (item == null) { + return null; + } + + roots.add(itemId); + + if (filteredRoots != null) { + if (passesFilters(itemId)) { + filteredRoots.add(itemId); + } } + return item; } @@ -295,6 +424,12 @@ public class HierarchicalContainer extends IndexedContainer implements parent.clear(); children.clear(); noChildrenAllowed.clear(); + if (filteredRoots != null) { + filteredRoots = null; + } + if (filteredChildren != null) { + filteredChildren = null; + } } return success; } @@ -309,20 +444,44 @@ public class HierarchicalContainer extends IndexedContainer implements final boolean success = super.removeItem(itemId); if (success) { - if (isRoot(itemId)) { - roots.remove(itemId); + // Remove from roots if this was a root + if (roots.remove(itemId)) { + + // If filtering is enabled we might need to remove it from the + // filtered list also + if (filteredRoots != null) { + filteredRoots.remove(itemId); + } } - LinkedList<Object> remove = children.remove(itemId); - if (remove != null) { - for (Object object : remove) { - removeItem(object); + + // Clear the children list. Old children will now become root nodes + LinkedList<Object> childNodeIds = children.remove(itemId); + if (childNodeIds != null) { + if (filteredChildren != null) { + filteredChildren.remove(itemId); + } + for (Object childId : childNodeIds) { + setParent(childId, null); } } - final Object p = parent.get(itemId); - if (p != null) { - final LinkedList c = children.get(p); + + // Parent of the item that we are removing will contain the item id + // in its children list + final Object parentItemId = parent.get(itemId); + if (parentItemId != null) { + final LinkedList<Object> c = children.get(parentItemId); if (c != null) { c.remove(itemId); + + // Found in the children list so might also be in the + // filteredChildren list + if (filteredChildren != null) { + LinkedList<Object> f = filteredChildren + .get(parentItemId); + if (f != null) { + f.remove(parentItemId); + } + } } } parent.remove(itemId); @@ -332,6 +491,35 @@ public class HierarchicalContainer extends IndexedContainer implements return success; } + /** + * Removes the Item identified by ItemId from the Container and all its + * children. + * + * @see #removeItem(Object) + * @param itemId + * the identifier of the Item to remove + * @return true if the operation succeeded + */ + public boolean removeItemRecursively(Object itemId) { + boolean success = true; + Collection<Object> children2 = getChildren(itemId); + if (children2 != null) { + Object[] array = children2.toArray(); + for (int i = 0; i < array.length; i++) { + boolean removeItemRecursively = removeItemRecursively(array[i]); + if (!removeItemRecursively) { + success = false; + } + } + } + boolean removeItem = removeItem(itemId); + if (!removeItem) { + success = false; + } + return success; + + } + /* * (non-Javadoc) * @@ -347,4 +535,40 @@ public class HierarchicalContainer extends IndexedContainer implements } } + /* + * Overridden to provide filtering for root & children items. + * + * (non-Javadoc) + * + * @see com.vaadin.data.util.IndexedContainer#updateContainerFiltering() + */ + @Override + protected void updateContainerFiltering() { + super.updateContainerFiltering(); + + filteredRoots = new LinkedList<Object>(); + filteredChildren = new HashMap<Object, LinkedList<Object>>(); + + // Filter root item ids + for (Object rootId : roots) { + if (passesFilters(rootId)) { + filteredRoots.add(rootId); + } + } + + // Filter children + for (Object parent : children.keySet()) { + if (passesFilters(parent)) { + LinkedList<Object> filtered = new LinkedList<Object>(); + filteredChildren.put(parent, filtered); + for (Object child : children.get(parent)) { + if (passesFilters(child)) { + filtered.add(child); + } + } + } + } + + } + } diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java index d6d6d9e77c..3bac19cd7a 100644 --- a/src/com/vaadin/data/util/IndexedContainer.java +++ b/src/com/vaadin/data/util/IndexedContainer.java @@ -469,7 +469,13 @@ public class IndexedContainer implements Container.Indexed, return null; } try { - return itemIds.get(itemIds.indexOf(itemId) + 1); + int idx = itemIds.indexOf(itemId); + if (idx == -1) { + // If the given Item is not found in the Container, + // null is returned. + return null; + } + return itemIds.get(idx + 1); } catch (final IndexOutOfBoundsException e) { return null; } @@ -548,6 +554,11 @@ public class IndexedContainer implements Container.Indexed, * java.lang.Object) */ public Item addItemAfter(Object previousItemId, Object newItemId) { + // Adding an item after null item adds the item as first item of the + // ordered container. + if (previousItemId == null) { + return addItemAt(0, newItemId); + } // Get the index of the addition int index = -1; @@ -574,7 +585,11 @@ public class IndexedContainer implements Container.Indexed, // Creates a new id final Object id = generateId(); - return addItemAfter(previousItemId, id); + if (addItemAfter(previousItemId, id) != null) { + return id; + } else { + return null; + } } /* @@ -953,7 +968,7 @@ public class IndexedContainer implements Container.Indexed, * @param addedItemIndex * index of new item if change event was an item addition */ - private void fireContentsChange(int addedItemIndex) { + protected void fireContentsChange(int addedItemIndex) { if (itemSetChangeListeners != null) { final Object[] l = itemSetChangeListeners.toArray(); final Container.ItemSetChangeEvent event = new IndexedContainer.ItemSetChangeEvent( @@ -1549,7 +1564,7 @@ public class IndexedContainer implements Container.Indexed, } } - private void updateContainerFiltering() { + protected void updateContainerFiltering() { // Clearing filters? if (filters == null || filters.isEmpty()) { @@ -1571,7 +1586,7 @@ public class IndexedContainer implements Container.Indexed, // Filter for (final Iterator i = itemIds.iterator(); i.hasNext();) { final Object id = i.next(); - if (passesFilters(new IndexedContainerItem(id))) { + if (passesFilters(id)) { filteredItemIds.add(id); } } @@ -1579,6 +1594,10 @@ public class IndexedContainer implements Container.Indexed, fireContentsChange(-1); } + protected final boolean passesFilters(Object itemId) { + return passesFilters(new IndexedContainerItem(itemId)); + } + private boolean passesFilters(Item item) { if (filters == null) { return true; diff --git a/src/com/vaadin/data/util/ListSet.java b/src/com/vaadin/data/util/ListSet.java new file mode 100644 index 0000000000..8dc8c6bbfd --- /dev/null +++ b/src/com/vaadin/data/util/ListSet.java @@ -0,0 +1,198 @@ +package com.vaadin.data.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * ListSet is an internal Vaadin class which implements a combination of a List
+ * and a Set. The main purpose of this class is to provide a fast
+ * {@link #contains(Object)} method. Each inserted object must by unique (as
+ * specified by {@link #equals(Object)}).
+ *
+ * This class is subject to change and should not be used outside Vaadin core.
+ */
+public class ListSet<E> extends ArrayList<E> {
+ private HashSet<E> itemSet = null;
+
+ public ListSet() {
+ super();
+ itemSet = new HashSet<E>();
+ }
+
+ public ListSet(Collection<? extends E> c) {
+ super(c);
+ itemSet = new HashSet<E>(c.size());
+ itemSet.addAll(c);
+ }
+
+ public ListSet(int initialCapacity) {
+ super(initialCapacity);
+ itemSet = new HashSet<E>(initialCapacity);
+ }
+
+ // Delegate contains operations to the set
+ @Override
+ public boolean contains(Object o) {
+ return itemSet.contains(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ return itemSet.containsAll(c);
+ }
+
+ // Methods for updating the set when the list is updated.
+ @Override
+ public boolean add(E e) {
+ if (contains(e)) {
+ // Duplicates are not allowed
+ return false;
+ }
+
+ if (super.add(e)) {
+ itemSet.add(e);
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Works as java.util.ArrayList#add(int, java.lang.Object) but returns
+ * immediately if the element is already in the ListSet.
+ */
+ @Override
+ public void add(int index, E element) {
+ if (contains(element)) {
+ // Duplicates are not allowed
+ return;
+ }
+
+ super.add(index, element);
+ itemSet.add(element);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> c) {
+ boolean modified = false;
+ Iterator<? extends E> i = c.iterator();
+ while (i.hasNext()) {
+ E e = i.next();
+ if (contains(e)) {
+ continue;
+ }
+
+ if (add(e)) {
+ itemSet.add(e);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends E> c) {
+ ensureCapacity(size() + c.size());
+
+ boolean modified = false;
+ Iterator<? extends E> i = c.iterator();
+ while (i.hasNext()) {
+ E e = i.next();
+ if (contains(e)) {
+ continue;
+ }
+
+ add(index++, e);
+ itemSet.add(e);
+ modified = true;
+ }
+
+ return modified;
+ }
+
+ @Override
+ public void clear() {
+ super.clear();
+ itemSet.clear();
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ if (!contains(o)) {
+ return -1;
+ }
+
+ return super.indexOf(o);
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ if (!contains(o)) {
+ return -1;
+ }
+
+ return super.lastIndexOf(o);
+ }
+
+ @Override
+ public E remove(int index) {
+ E e = super.remove(index);
+
+ if (e != null) {
+ itemSet.remove(e);
+ }
+
+ return e;
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ if (super.remove(o)) {
+ itemSet.remove(o);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ protected void removeRange(int fromIndex, int toIndex) {
+ HashSet<E> toRemove = new HashSet<E>();
+ for (int idx = fromIndex; idx < toIndex; idx++) {
+ toRemove.add(get(idx));
+ }
+ super.removeRange(fromIndex, toIndex);
+ itemSet.removeAll(toRemove);
+ }
+
+ @Override
+ public E set(int index, E element) {
+ if (contains(element)) {
+ // Element already exist in the list
+ if (get(index) == element) {
+ // At the same position, nothing to be done
+ return element;
+ } else {
+ // At another position, cannot set
+ return null;
+ }
+ }
+
+ E old = super.set(index, element);
+ itemSet.remove(old);
+ itemSet.add(element);
+
+ return old;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object clone() {
+ ListSet<E> v = (ListSet<E>) super.clone();
+ v.itemSet = new HashSet<E>(itemSet);
+ return v;
+ }
+
+}
diff --git a/src/com/vaadin/terminal/FileResource.java b/src/com/vaadin/terminal/FileResource.java index 46f1a6c028..571622b0e4 100644 --- a/src/com/vaadin/terminal/FileResource.java +++ b/src/com/vaadin/terminal/FileResource.java @@ -10,6 +10,7 @@ import java.io.FileNotFoundException; import com.vaadin.Application; import com.vaadin.service.FileTypeResolver; +import com.vaadin.terminal.Terminal.ErrorEvent; /** * <code>FileResources</code> are files or directories on local filesystem. The @@ -67,7 +68,15 @@ public class FileResource implements ApplicationResource { ds.setCacheTime(cacheTime); return ds; } catch (final FileNotFoundException e) { - // No logging for non-existing files at this level. + // Log the exception using the application error handler + getApplication().getErrorHandler().terminalError(new ErrorEvent() { + + public Throwable getThrowable() { + return e; + } + + }); + return null; } } diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 39f4e845f7..5bcf613f6d 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -148,20 +148,15 @@ public class ApplicationConfiguration { int lastdot = module.lastIndexOf("."); String base = module.substring(0, lastdot); String simpleName = module.substring(lastdot + 1); - // if (!wsname.startsWith(base) || !wsname.endsWith(simpleName)) { - // // WidgetSet module name does not match implementation name; - // // probably inherited WidgetSet with entry-point. Skip. - // GWT.log("Ignored init for " + wsname + " when starting " + module, - // null); - // return; - // } if (initedWidgetSet != null) { - // Something went wrong: multiple widgetsets inited - String msg = "Tried to init " + widgetset.getClass().getName() - + ", but " + initedWidgetSet.getClass().getName() - + " was already inited."; - ApplicationConnection.getConsole().log(msg); + // Multiple widgetsets inited; can happen with custom WS + entry + // point + String msg = "Ignoring " + widgetset.getClass().getName() + + ", because " + initedWidgetSet.getClass().getName() + + " was already inited (if this is wrong, your entry point" + + " is probably not first your .gwt.xml)."; + throw new IllegalStateException(msg); } initedWidgetSet = widgetset; ArrayList<String> appIds = new ArrayList<String>(); diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 34e3580608..8574bc0476 100755 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -1116,7 +1116,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, Paintable newValue, boolean immediate) { @@ -1139,7 +1139,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, @@ -1162,7 +1162,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, @@ -1186,7 +1186,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, @@ -1210,7 +1210,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, @@ -1234,7 +1234,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, @@ -1258,7 +1258,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, @@ -1282,7 +1282,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, Map<String, Object> map, boolean immediate) { @@ -1347,7 +1347,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, String[] values, boolean immediate) { @@ -1382,7 +1382,7 @@ public class ApplicationConnection { * @param newValue * the new value to be sent * @param immediate - * true if the update is to be sent as suun as possible + * true if the update is to be sent as soon as possible */ public void updateVariable(String paintableId, String variableName, Object[] values, boolean immediate) { diff --git a/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java b/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java index 724bd24a69..f1b01509d4 100644 --- a/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java +++ b/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java @@ -3,7 +3,7 @@ package com.vaadin.terminal.gwt.client; public class ClientExceptionHandler {
public static void displayError(Throwable e) {
- displayError(e.getMessage());
+ displayError(e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
diff --git a/src/com/vaadin/terminal/gwt/client/DefaultWidgetSet.java b/src/com/vaadin/terminal/gwt/client/DefaultWidgetSet.java index 8ee6b0bb14..c34e5d8bb3 100644 --- a/src/com/vaadin/terminal/gwt/client/DefaultWidgetSet.java +++ b/src/com/vaadin/terminal/gwt/client/DefaultWidgetSet.java @@ -38,7 +38,14 @@ public class DefaultWidgetSet implements WidgetSet { * This is the entry point method. It will start the first */ public void onModuleLoad() { - ApplicationConfiguration.initConfigurations(this); + try { + ApplicationConfiguration.initConfigurations(this); + } catch (Exception e) { + // Log & don't continue; + // custom WidgetSets w/ entry points will cause this + ApplicationConnection.getConsole().log(e.getMessage()); + return; + } ApplicationConfiguration.startNextApplication(); // start first app map = GWT.create(WidgetMap.class); } diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java index 45b8c9353b..172e4df627 100755 --- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java +++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Set; import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; @@ -304,6 +305,10 @@ public final class VDebugConsole extends VOverlay implements Console { * @see com.vaadin.terminal.gwt.client.Console#log(java.lang.String) */ public void log(String msg) { + if (msg == null) { + msg = "null"; + } + panel.add(new HTML(msg)); System.out.println(msg); consoleLog(msg); @@ -315,7 +320,14 @@ public final class VDebugConsole extends VOverlay implements Console { * @see com.vaadin.terminal.gwt.client.Console#error(java.lang.String) */ public void error(String msg) { - panel.add((new HTML(msg))); + if (msg == null) { + msg = "null"; + } + + HTML html = new HTML(msg); + html.getElement().getStyle().setColor("#f00"); + html.getElement().getStyle().setFontWeight(FontWeight.BOLD); + panel.add(html); System.err.println(msg); consoleErr(msg); } @@ -327,7 +339,13 @@ public final class VDebugConsole extends VOverlay implements Console { * Object) */ public void printObject(Object msg) { - panel.add((new Label(msg.toString()))); + String str; + if (msg == null) { + str = "null"; + } else { + str = msg.toString(); + } + panel.add((new Label(str))); consoleLog(msg.toString()); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java index bf13530d7f..90cf102cb9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java @@ -184,10 +184,11 @@ public class VCssLayout extends SimplePanel implements Paintable, Container { // loop oldWidgetWrappers that where not re-attached and unregister // them - for (final Iterator<Widget> it = oldWidgets.iterator(); it - .hasNext();) { - final Paintable w = (Paintable) it.next(); - client.unregisterPaintable(w); + for (Widget w : oldWidgets) { + if (w instanceof Paintable) { + final Paintable p = (Paintable) w; + client.unregisterPaintable(p); + } widgetToCaption.remove(w); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java index 7d69e5682a..ffd09dab2c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java @@ -140,6 +140,7 @@ public class VEmbedded extends HTML implements Paintable { parameters.put("movie", getSrc(uidl, client)); } + // Add the parameters to the Object for (String name : parameters.keySet()) { html += "<param name=\"" + escapeAttribute(name) + "\" value=\"" @@ -147,9 +148,15 @@ public class VEmbedded extends HTML implements Paintable { } html += "<embed src=\"" + getSrc(uidl, client) + "\" width=\"" - + width + "\" height=\"" + height + "\"></embed>"; + + width + "\" height=\"" + height + "\" "; - html += "</object>"; + // Add the parameters to the Embed + for (String name : parameters.keySet()) { + html += escapeAttribute(name) + "=\"" + + escapeAttribute(parameters.get(name)) + "\" "; + } + + html += "></embed></object>"; setHTML(html); } else if (mime.equals("image/svg+xml")) { String data; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 2dcf7562ae..669b5b90ea 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -631,6 +631,23 @@ public class VFilterSelect extends Composite implements Paintable, Field, public void onLoad(LoadEvent event) { updateRootWidth(); updateSelectedIconPosition(); + + /* + * We need to re-calculate the widths in IE at load time to + * ensure that the text is not placed behind the icon. #3991 + */ + if (BrowserInfo.get().isIE()) { + int tbWidth = Util.getRequiredWidth(tb); + int openerWidth = Util.getRequiredWidth(popupOpener); + int iconWidth = selectedItemIcon.isAttached() ? Util + .measureMarginLeft(tb.getElement()) + - Util.measureMarginLeft(selectedItemIcon + .getElement()) : 0; + + int w = tbWidth + openerWidth + iconWidth; + tb.setWidth((tbWidth - getTextboxPadding()) + "px"); + setTextboxWidth(w); + } } }); @@ -883,8 +900,8 @@ public class VFilterSelect extends Composite implements Paintable, Field, panel.remove(selectedItemIcon); updateRootWidth(); } else { - selectedItemIcon.setUrl(iconUri); panel.insert(selectedItemIcon, 0); + selectedItemIcon.setUrl(iconUri); updateRootWidth(); updateSelectedIconPosition(); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index 0a28fd6b41..75ecbd3249 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -8,11 +8,14 @@ import java.util.Stack; import com.google.gwt.dom.client.NodeList; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; 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.ui.HasHTML; import com.google.gwt.user.client.ui.PopupPanel; @@ -27,7 +30,8 @@ import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; public class VMenuBar extends Widget implements Paintable, - CloseHandler<PopupPanel>, ContainerResizedListener { +CloseHandler<PopupPanel>, ContainerResizedListener, +ValueChangeHandler<String> { /** Set the CSS class name to allow styling. */ public static final String CLASSNAME = "v-menubar"; @@ -76,6 +80,8 @@ public class VMenuBar extends Widget implements Paintable, if (!subMenu) { setStylePrimaryName(CLASSNAME); + // Monitor back&forward buttons + History.addValueChangeHandler(this); } else { setStylePrimaryName(CLASSNAME + "-submenu"); } @@ -866,4 +872,12 @@ public class VMenuBar extends Widget implements Paintable, return w; } + public void onValueChange(ValueChangeEvent<String> arg0) { + // Close menu if user uses back & forward buttons #4109 + if (!subMenu) { + setSelected(null); + hideChildren(); + menuVisible = false; + } + } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java index e544e1f9ce..ef7e183698 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java @@ -19,7 +19,7 @@ import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VTooltip; -public class VNativeButton extends Button implements Paintable { +public class VNativeButton extends Button implements Paintable, ClickHandler { public static final String CLASSNAME = "v-nativebutton"; @@ -48,18 +48,8 @@ public class VNativeButton extends Button implements Paintable { getElement().appendChild(captionElement); captionElement.setClassName(getStyleName() + "-caption"); - addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - if (id == null || client == null) { - return; - } - if (BrowserInfo.get().isSafari()) { - VNativeButton.this.setFocus(true); - } - client.updateVariable(id, "state", true, true); - clickPending = false; - } - }); + addClickHandler(this); + sinkEvents(VTooltip.TOOLTIP_EVENTS); sinkEvents(Event.ONMOUSEDOWN); sinkEvents(Event.ONMOUSEUP); @@ -179,4 +169,24 @@ public class VNativeButton extends Button implements Paintable { } } + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event + * .dom.client.ClickEvent) + */ + public void onClick(ClickEvent event) { + if (id == null || client == null) { + return; + } + + if (BrowserInfo.get().isSafari()) { + VNativeButton.this.setFocus(true); + } + + client.updateVariable(id, "state", true, true); + clickPending = false; + } + } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java index f9da8f67d9..d41a739655 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java @@ -189,7 +189,6 @@ public class VPanel extends SimplePanel implements Container { } layout.updateFromUIDL(layoutUidl, client); - runHacks(false); // We may have actions attached to this panel if (uidl.getChildCount() > 1) { final int cnt = uidl.getChildCount(); @@ -224,6 +223,10 @@ public class VPanel extends SimplePanel implements Container { scrollLeft = contentNode.getScrollLeft(); } + // Must be run after scrollTop is set as Webkit overflow fix re-sets the + // scrollTop + runHacks(false); + rendering = false; } @@ -393,7 +396,8 @@ public class VPanel extends SimplePanel implements Container { super.setHeight(height); if (height != null && height != "") { final int targetHeight = getOffsetHeight(); - int containerHeight = targetHeight - captionNode.getOffsetHeight() + int containerHeight = targetHeight + - captionNode.getParentElement().getOffsetHeight() - bottomDecoration.getOffsetHeight() - getContainerBorderHeight(); if (containerHeight < 0) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java index 8d83e8b2b5..9b504bc5f3 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java @@ -52,7 +52,6 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
boolean lastReadOnlyState = readonly;
super.updateFromUIDL(uidl, client);
- addStyleName(CLASSNAME + "-popupcalendar");
popup.setStyleName(VDateField.CLASSNAME + "-popup "
+ VDateField.CLASSNAME + "-"
+ resolutionToString(currentResolution));
@@ -67,6 +66,12 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, }
+ @Override
+ public void setStyleName(String style) {
+ // make sure the style is there before size calculation
+ super.setStyleName(style + " " + CLASSNAME + "-popupcalendar");
+ }
+
public void onClick(ClickEvent event) {
if (event.getSource() == calendarToggle && !open && !readonly) {
open = true;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 59c5d252fe..53f0033bcd 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -19,11 +19,14 @@ import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; 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.FlowPanel; @@ -72,7 +75,7 @@ import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; * TODO implement unregistering for child components in Cells */ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, - VHasDropHandler { + VHasDropHandler, ValueChangeHandler<String> { public static final String CLASSNAME = "v-table"; public static final String ITEM_CLICK_EVENT_ID = "itemClick"; @@ -168,6 +171,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, rowRequestHandler = new RowRequestHandler(); + // Handle back & forward browser buttons + History.addValueChangeHandler(this); } @SuppressWarnings("unchecked") @@ -3264,4 +3269,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } + public void onValueChange(ValueChangeEvent<String> arg0) { + client.getContextMenu().hide(); + } + } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java index d7a11427fb..101c1e9848 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java @@ -122,6 +122,9 @@ public class VSplitPanel extends ComplexPanel implements Container, private boolean rendering = false; + /* The current position of the split handle in either percentages or pixels */ + private String position; + public VSplitPanel() { this(ORIENTATION_HORIZONTAL); } @@ -208,7 +211,8 @@ public class VSplitPanel extends ComplexPanel implements Container, setStylenames(); - setSplitPosition(uidl.getStringAttribute("position")); + position = uidl.getStringAttribute("position"); + setSplitPosition(position); final Paintable newFirstChild = client.getPaintable(uidl .getChildUIDL(0)); @@ -257,14 +261,26 @@ public class VSplitPanel extends ComplexPanel implements Container, } private void setSplitPosition(String pos) { + if (pos == null) { + return; + } + + // Convert percentage values to pixels + if (pos.indexOf("%") > 0) { + pos = Float.parseFloat(pos.substring(0, pos.length() - 1)) + / 100 + * (orientation == ORIENTATION_HORIZONTAL ? getOffsetWidth() + : getOffsetHeight()) + "px"; + } + if (orientation == ORIENTATION_HORIZONTAL) { DOM.setStyleAttribute(splitter, "left", pos); } else { DOM.setStyleAttribute(splitter, "top", pos); } + iLayout(); client.runDescendentsLayout(this); - } /* @@ -441,9 +457,6 @@ public class VSplitPanel extends ComplexPanel implements Container, onVerticalMouseMove(y); break; } - iLayout(); - // TODO Check if this is needed - client.runDescendentsLayout(this); } @@ -455,7 +468,18 @@ public class VSplitPanel extends ComplexPanel implements Container, if (newX + getSplitterSize() > getOffsetWidth()) { newX = getOffsetWidth() - getSplitterSize(); } - DOM.setStyleAttribute(splitter, "left", newX + "px"); + + if (position.indexOf("%") > 0) { + float pos = newX; + // 100% needs special handling + if (newX + getSplitterSize() >= getOffsetWidth()) { + pos = getOffsetWidth(); + } + position = pos / getOffsetWidth() * 100 + "%"; + } + + setSplitPosition(newX + "px"); + if (origX != newX) { resized = true; } @@ -470,7 +494,18 @@ public class VSplitPanel extends ComplexPanel implements Container, if (newY + getSplitterSize() > getOffsetHeight()) { newY = getOffsetHeight() - getSplitterSize(); } - DOM.setStyleAttribute(splitter, "top", newY + "px"); + + if (position.indexOf("%") > 0) { + float pos = newY; + // 100% needs special handling + if (newY + getSplitterSize() >= getOffsetHeight()) { + pos = getOffsetHeight(); + } + position = pos / getOffsetHeight() * 100 + "%"; + } + + setSplitPosition(newY + "px"); + if (origY != newY) { resized = true; } @@ -554,9 +589,9 @@ public class VSplitPanel extends ComplexPanel implements Container, this.height = height; super.setHeight(height); + if (!rendering && client != null) { - iLayout(); - client.runDescendentsLayout(this); + setSplitPosition(position); } } @@ -568,9 +603,9 @@ public class VSplitPanel extends ComplexPanel implements Container, this.width = width; super.setWidth(width); + if (!rendering && client != null) { - iLayout(); - client.runDescendentsLayout(this); + setSplitPosition(position); } } @@ -627,12 +662,14 @@ public class VSplitPanel extends ComplexPanel implements Container, * Updates the new split position back to server. */ private void updateSplitPositionToServer() { - // We always send pixel values to server - final String position = orientation == ORIENTATION_HORIZONTAL ? splitter - .getStyle().getProperty("left") - : splitter.getStyle().getProperty("top"); - final int pos = Integer.parseInt(position.substring(0, position - .length() - 2)); + int pos = 0; + if (position.indexOf("%") > 0) { + pos = Float.valueOf(position.substring(0, position.length() - 1)) + .intValue(); + } else { + pos = Integer + .parseInt(position.substring(0, position.length() - 2)); + } client.updateVariable(id, "position", pos, immediate); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java index fe2c03496c..f4bc96f66a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java @@ -218,6 +218,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field, if (prompting) { setText(""); removeStyleDependentName(CLASSNAME_PROMPT); + setPrompting(false); if (BrowserInfo.get().isIE6()) { // IE6 does not show the cursor when tabbing into the field setCursorPos(0); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 838b60a6d8..033d35dab1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -372,10 +372,6 @@ public class VView extends SimplePanel implements Container, ResizeHandler, onResize(Window.getClientWidth(), Window.getClientHeight()); - if (BrowserInfo.get().isSafari()) { - Util.runWebkitOverflowAutoFix(getElement()); - } - // finally set scroll position from UIDL if (uidl.hasVariable("scrollTop")) { scrollable = true; @@ -387,6 +383,12 @@ public class VView extends SimplePanel implements Container, ResizeHandler, scrollable = false; } + // Safari workaround must be run after scrollTop is updated as it sets + // scrollTop using a deferred command. + if (BrowserInfo.get().isSafari()) { + Util.runWebkitOverflowAutoFix(getElement()); + } + rendering = false; } diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 428a9b38b9..148474bccc 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -14,6 +14,7 @@ import java.security.GeneralSecurityException; import java.util.Date; import java.util.Enumeration; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import java.util.Properties; @@ -28,12 +29,10 @@ import javax.portlet.PortalContext; import javax.portlet.PortletConfig; import javax.portlet.PortletContext; import javax.portlet.PortletException; -import javax.portlet.PortletMode; import javax.portlet.PortletRequest; import javax.portlet.PortletResponse; import javax.portlet.PortletSession; import javax.portlet.PortletURL; -import javax.portlet.RenderMode; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.ResourceRequest; @@ -47,9 +46,14 @@ 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; +import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.ui.Window; /** + * Portlet 2.0 base class. This replaces the servlet in servlet/portlet 1.0 + * deployments and handles various portlet requests from the browser. + * * TODO Document me! * * @author peholmst @@ -193,7 +197,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet * the Default to be used. * @return String value or default if not found */ - private String getApplicationOrSystemProperty(String parameterName, + protected String getApplicationOrSystemProperty(String parameterName, String defaultValue) { String val = null; @@ -240,7 +244,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } - enum RequestType { + protected enum RequestType { FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APPLICATION_RESOURCE, DUMMY, EVENT, ACTION, UNKNOWN; } @@ -304,7 +308,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet RequestType requestType = getRequestType(request); if (requestType == RequestType.UNKNOWN) { - System.err.println("Unknown request type"); + handleUnknownRequest(request, response); } else if (requestType == RequestType.DUMMY) { /* * This dummy page is used by action responses to redirect to, in @@ -317,8 +321,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet final PrintWriter outWriter = new PrintWriter(new BufferedWriter( new OutputStreamWriter(out, "UTF-8"))); outWriter.print("<html><body>dummy page</body></html>"); - outWriter.flush(); - out.close(); + outWriter.close(); } else if (requestType == RequestType.STATIC_FILE) { serveStaticResources((ResourceRequest) request, (ResourceResponse) response); @@ -386,20 +389,43 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet /* Notify listeners */ + // Finds the window within the application + Window window = null; + synchronized (application) { + if (application.isRunning()) { + switch (requestType) { + case FILE_UPLOAD: + // no window + break; + case APPLICATION_RESOURCE: + // use main window - should not need any window + window = application.getMainWindow(); + break; + default: + window = applicationManager.getApplicationWindow( + request, this, application, null); + } + // if window not found, not a problem - use null + } + } + // TODO Should this happen before or after the transaction // starts? if (request instanceof RenderRequest) { applicationContext.firePortletRenderRequest(application, - (RenderRequest) request, (RenderResponse) response); + window, (RenderRequest) request, + (RenderResponse) response); } else if (request instanceof ActionRequest) { applicationContext.firePortletActionRequest(application, - (ActionRequest) request, (ActionResponse) response); + window, (ActionRequest) request, + (ActionResponse) response); } else if (request instanceof EventRequest) { applicationContext.firePortletEventRequest(application, - (EventRequest) request, (EventResponse) response); + window, (EventRequest) request, + (EventResponse) response); } else if (request instanceof ResourceRequest) { applicationContext.firePortletResourceRequest(application, - (ResourceRequest) request, + window, (ResourceRequest) request, (ResourceResponse) response); } @@ -412,7 +438,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet // Handles AJAX UIDL requests applicationManager.handleUidlRequest( (ResourceRequest) request, - (ResourceResponse) response, this); + (ResourceResponse) response, this, window); return; } else { /* @@ -423,45 +449,9 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet return; } - /* - * Always use the main window when running inside a portlet. - */ - Window window = getPortletWindow(request, application); - if (window == null) { - throw new PortletException(ERROR_NO_WINDOW_FOUND); - } - - /* - * Sets terminal type for the window, if not already set - */ - if (window.getTerminal() == null) { - window.setTerminal(applicationContext.getBrowser()); - } - - /* - * Handle parameters - */ - final Map<String, String[]> parameters = request - .getParameterMap(); - if (window != null && parameters != null) { - window.handleParameters(parameters); - } - - if (requestType == RequestType.APPLICATION_RESOURCE) { - handleURI(applicationManager, window, - (ResourceRequest) request, - (ResourceResponse) response); - } else if (requestType == RequestType.RENDER) { - writeAjaxPage((RenderRequest) request, - (RenderResponse) response, window, application); - } else if (requestType == RequestType.EVENT) { - // nothing to do, listeners do all the work - } else if (requestType == RequestType.ACTION) { - // nothing to do, listeners do all the work - } else { - throw new IllegalStateException( - "handleRequest() without anything to do - should never happen!"); - } + handleOtherRequest(request, response, requestType, + application, window, applicationContext, + applicationManager); } } catch (final SessionExpiredException e) { // TODO Figure out a better way to deal with @@ -494,26 +484,67 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } + private void handleUnknownRequest(PortletRequest request, + PortletResponse response) { + System.err.println("Unknown request type"); + } + /** - * Returns a window for a portlet mode. To define custom content for a - * portlet mode, add (in the application) a window whose name matches the - * portlet mode name. By default, the main window is returned. + * Handle a portlet request that is not for static files, UIDL or upload. + * Also render requests are handled here. * - * Alternatively, a PortletListener can change the main window content. + * This method is called after starting the application and calling portlet + * and transaction listeners. * * @param request + * @param response + * @param requestType * @param application - * @return Window to show in the portlet for the given portlet mode + * @param applicationContext + * @param applicationManager + * @throws PortletException + * @throws IOException + * @throws MalformedURLException */ - protected Window getPortletWindow(PortletRequest request, - Application application) { - PortletMode mode = request.getPortletMode(); - Window window = application.getWindow(mode.toString()); - if (window != null) { - return window; + private void handleOtherRequest(PortletRequest request, + PortletResponse response, RequestType requestType, + Application application, Window window, + PortletApplicationContext2 applicationContext, + PortletCommunicationManager applicationManager) + throws PortletException, IOException, MalformedURLException { + if (window == null) { + throw new PortletException(ERROR_NO_WINDOW_FOUND); + } + + /* + * Sets terminal type for the window, if not already set + */ + if (window.getTerminal() == null) { + window.setTerminal(applicationContext.getBrowser()); + } + + /* + * Handle parameters + */ + final Map<String, String[]> parameters = request.getParameterMap(); + if (window != null && parameters != null) { + window.handleParameters(parameters); + } + + if (requestType == RequestType.APPLICATION_RESOURCE) { + handleURI(applicationManager, window, (ResourceRequest) request, + (ResourceResponse) response); + } else if (requestType == RequestType.RENDER) { + writeAjaxPage((RenderRequest) request, (RenderResponse) response, + window, application); + } else if (requestType == RequestType.EVENT) { + // nothing to do, listeners do all the work + } else if (requestType == RequestType.ACTION) { + // nothing to do, listeners do all the work + } else { + throw new IllegalStateException( + "handleRequest() without anything to do - should never happen!"); } - // no specific window found - return application.getMainWindow(); } private void updateBrowserProperties(WebBrowser browser, @@ -648,53 +679,26 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet handleRequest(request, response); } - /** - * Handles a request for the "view" (default) portlet mode. In Vaadin, the - * basic portlet modes ("view", "edit" and "help") are handled identically, - * and their behavior can be changed by registering windows in the - * application with window names identical to the portlet mode names. - * Alternatively, a PortletListener can change the application main window - * contents. - * - * To implement custom portlet modes, subclass the portlet class and - * implement a method annotated with {@link RenderMode} for the custom mode, - * calling {@link #handleRequest(PortletRequest, PortletResponse)} directly - * from it. - * - * Note that the portlet class in the portlet configuration needs to be - * changed when overriding methods of this class. - * - * @param request - * @param response - * @throws PortletException - * @throws IOException - */ @Override - protected void doView(RenderRequest request, RenderResponse response) + protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException { - handleRequest(request, response); - } + try { + // try to let super handle - it'll call methods annotated for + // handling, the default doXYZ(), or throw if a handler for the mode + // is not found + super.doDispatch(request, response); - /** - * Handle a request for the "edit" portlet mode. - * - * @see #doView(RenderRequest, RenderResponse) - */ - @Override - protected void doEdit(RenderRequest request, RenderResponse response) - throws PortletException, IOException { - handleRequest(request, response); - } + } catch (PortletException e) { + if (e.getCause() == null) { + // No cause interpreted as 'unknown mode' - pass that trough + // so that the application can handle + handleRequest(request, response); - /** - * Handle a request for the "help" portlet mode. - * - * @see #doView(RenderRequest, RenderResponse) - */ - @Override - protected void doHelp(RenderRequest request, RenderResponse response) - throws PortletException, IOException { - handleRequest(request, response); + } else { + // Something else failed, pass on + throw e; + } + } } @Override @@ -833,17 +837,63 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet return null; } + /** + * Returns the URL from which the widgetset is served on the portal. + * + * @param widgetset + * @param request + * @return + */ protected String getWidgetsetURL(String widgetset, PortletRequest request) { return getStaticFilesLocation(request) + "/" + WIDGETSET_DIRECTORY_PATH + widgetset + "/" + widgetset + ".nocache.js?" + new Date().getTime(); } + /** + * Returns the theme URI for the named theme on the portal. + * + * Note that this is not the only location referring to the theme URI - also + * e.g. PortletCommunicationManager uses its own way to access the portlet + * 2.0 theme resources. + * + * @param themeName + * @param request + * @return + */ protected String getThemeURI(String themeName, PortletRequest request) { return getStaticFilesLocation(request) + "/" + THEME_DIRECTORY_PATH + themeName; } + /** + * Writes the html host page (aka kickstart page) that starts the actual + * Vaadin application. + * + * If one needs to override parts of the portlet HTML contents creation, it + * is suggested that one overrides one of several submethods including: + * <ul> + * <li> + * {@link #writeAjaxPageHtmlMainDiv(RenderRequest, RenderResponse, BufferedWriter, String)} + * <li> + * {@link #getVaadinConfigurationMap(RenderRequest, RenderResponse, Application, String)} + * <li> + * {@link #writeAjaxPageHtmlVaadinScripts(RenderRequest, RenderResponse, BufferedWriter, Application, String)} + * </ul> + * + * @param request + * the portlet request. + * @param response + * the portlet response to write to. + * @param window + * @param application + * @throws IOException + * if the writing failed due to input/output error. + * @throws MalformedURLException + * if the application is denied access the persistent data store + * represented by the given URL. + * @throws PortletException + */ protected void writeAjaxPage(RenderRequest request, RenderResponse response, Window window, Application application) throws IOException, MalformedURLException, PortletException { @@ -852,27 +902,62 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet final BufferedWriter page = new BufferedWriter(new OutputStreamWriter( response.getPortletOutputStream(), "UTF-8")); - // TODO check - String requestWidgetset = getApplicationOrSystemProperty( - PARAMETER_WIDGETSET, null); - String sharedWidgetset = getPortalProperty( - PORTAL_PARAMETER_VAADIN_WIDGETSET, request.getPortalContext()); - - String widgetset; - if (requestWidgetset != null) { - widgetset = requestWidgetset; - } else if (sharedWidgetset != null) { - widgetset = sharedWidgetset; - } else { - widgetset = DEFAULT_WIDGETSET; - } - // TODO Currently, we can only load widgetsets and themes from the // portal String themeName = getThemeForWindow(request, window); - String widgetsetURL = getWidgetsetURL(widgetset, request); + writeAjaxPageHtmlVaadinScripts(request, response, page, application, + themeName); + + /*- Add classnames; + * .v-app + * .v-app-loading + * .v-app-<simpleName for app class> + * .v-theme-<themeName, remove non-alphanum> + */ + String appClass = "v-app-"; + try { + appClass += getApplicationClass().getSimpleName(); + } catch (ClassNotFoundException e) { + appClass += "unknown"; + e.printStackTrace(); + } + String themeClass = "v-theme-" + + themeName.replaceAll("[^a-zA-Z0-9]", ""); + + String classNames = "v-app v-app-loading " + themeClass + " " + + appClass; + + String style = getApplicationProperty(PORTLET_PARAMETER_STYLE); + String divStyle = ""; + if (style != null) { + divStyle = "style=\"" + style + "\""; + } + + writeAjaxPageHtmlMainDiv(request, response, page, + request.getWindowID(), classNames, divStyle); + + page.close(); + } + + /** + * This method writes the scripts to load the widgetset and the themes as + * well as define Vaadin configuration parameters on the HTML fragment that + * starts the actual Vaadin application. + * + * @param request + * @param response + * @param writer + * @param application + * @param themeName + * @throws IOException + * @throws PortletException + */ + protected void writeAjaxPageHtmlVaadinScripts(RenderRequest request, + RenderResponse response, final BufferedWriter writer, + Application application, String themeName) throws IOException, + PortletException { String themeURI = getThemeURI(themeName, request); // fixed base theme to use - all portal pages with Vaadin @@ -880,52 +965,113 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet String portalTheme = getPortalProperty(PORTAL_PARAMETER_VAADIN_THEME, request.getPortalContext()); - // Get system messages - Application.SystemMessages systemMessages = null; - try { - systemMessages = getSystemMessages(); - } catch (SystemMessageException e) { - // failing to get the system messages is always a problem - throw new PortletException("Failed to obtain system messages!", e); - } - - page.write("<script type=\"text/javascript\">\n"); - page.write("if(!vaadin || !vaadin.vaadinConfigurations) {\n " + writer.write("<script type=\"text/javascript\">\n"); + writer.write("if(!vaadin || !vaadin.vaadinConfigurations) {\n " + "if(!vaadin) { var vaadin = {}} \n" + "vaadin.vaadinConfigurations = {};\n" + "if (!vaadin.themesLoaded) { vaadin.themesLoaded = {}; }\n"); if (!isProductionMode()) { - page.write("vaadin.debug = true;\n"); + writer.write("vaadin.debug = true;\n"); } - page + + writeAjaxPageScriptWidgetset(request, response, writer); + + Map<String, String> config = getVaadinConfigurationMap(request, + response, application, themeURI); + writeAjaxPageScriptConfigurations(request, response, writer, config); + + writer.write("</script>\n"); + + writeAjaxPageHtmlTheme(request, writer, themeName, themeURI, + portalTheme); + + // TODO Warn if widgetset has not been loaded after 15 seconds + } + + /** + * Writes the script to load the widgetset on the HTML fragment created by + * the portlet. + * + * @param request + * @param response + * @param writer + * @throws IOException + */ + protected void writeAjaxPageScriptWidgetset(RenderRequest request, + RenderResponse response, final BufferedWriter writer) + throws IOException { + String requestWidgetset = getApplicationOrSystemProperty( + PARAMETER_WIDGETSET, null); + String sharedWidgetset = getPortalProperty( + PORTAL_PARAMETER_VAADIN_WIDGETSET, request.getPortalContext()); + + String widgetset; + if (requestWidgetset != null) { + widgetset = requestWidgetset; + } else if (sharedWidgetset != null) { + widgetset = sharedWidgetset; + } else { + widgetset = DEFAULT_WIDGETSET; + } + String widgetsetURL = getWidgetsetURL(widgetset, request); + writer .write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" " + "style=\"width:0;height:0;border:0;overflow:" + "hidden\" src=\"javascript:false\"></iframe>');\n"); - page.write("document.write(\"<script language='javascript' src='" + writer.write("document.write(\"<script language='javascript' src='" + widgetsetURL + "'><\\/script>\");\n}\n"); + } - page.write("vaadin.vaadinConfigurations[\"" + request.getWindowID() - + "\"] = {"); + /** + * Returns the configuration parameters to pass to the client. + * + * To add configuration parameters for the client, override, call the super + * method and then modify the map. Overriding this method may also require + * client side changes in {@link ApplicationConnection} and + * {@link ApplicationConfiguration}. + * + * Note that this method must escape and quote the values when appropriate. + * + * The map returned is typically a {@link LinkedHashMap} to preserve + * insertion order, but it is not guaranteed to be one. + * + * @param request + * @param response + * @param application + * @param themeURI + * @return modifiable Map from parameter name to its full value + * @throws PortletException + */ + protected Map<String, String> getVaadinConfigurationMap( + RenderRequest request, RenderResponse response, + Application application, String themeURI) throws PortletException { + Map<String, String> config = new LinkedHashMap<String, String>(); /* * We need this in order to get uploads to work. */ PortletURL appUri = response.createActionURL(); - - page.write("appUri: '" + appUri.toString() + "', "); - page.write("usePortletURLs: true, "); - + config.put("appUri", "'" + appUri.toString() + "'"); + config.put("usePortletURLs", "true"); ResourceURL uidlUrlBase = response.createResourceURL(); uidlUrlBase.setResourceID("UIDL"); + config.put("portletUidlURLBase", "'" + uidlUrlBase.toString() + "'"); + config.put("pathInfo", "''"); + config.put("themeUri", "'" + themeURI + "'"); + + String versionInfo = "{vaadinVersion:\"" + + AbstractApplicationServlet.VERSION + + "\",applicationVersion:\"" + application.getVersion() + "\"}"; + config.put("versionInfo", versionInfo); - page.write("portletUidlURLBase: '" + uidlUrlBase.toString() + "', "); - page.write("pathInfo: '', "); - page.write("themeUri: '" + themeURI + "', "); - page.write("versionInfo : {vaadinVersion:\""); - page.write(AbstractApplicationServlet.VERSION); - page.write("\",applicationVersion:\""); - page.write(application.getVersion()); - page.write("\"},"); + // Get system messages + Application.SystemMessages systemMessages = null; + try { + systemMessages = getSystemMessages(); + } catch (SystemMessageException e) { + // failing to get the system messages is always a problem + throw new PortletException("Failed to obtain system messages!", e); + } if (systemMessages != null) { // Write the CommunicationError -message to client String caption = systemMessages.getCommunicationErrorCaption(); @@ -941,73 +1087,117 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet url = "\"" + url + "\""; } - page.write("\"comErrMsg\": {" + "\"caption\":" + caption + "," + config.put("\"comErrMsg\"", "{" + "\"caption\":" + caption + "," + "\"message\" : " + message + "," + "\"url\" : " + url + "}"); } - page.write("};\n</script>\n"); - page.write("<script type=\"text/javascript\">\n"); + return config; + } + + /** + * Constructs the Vaadin configuration section for + * {@link ApplicationConnection} and {@link ApplicationConfiguration}. + * + * Typically this method should not be overridden. Instead, modify + * {@link #getVaadinConfigurationMap(RenderRequest, RenderResponse, Application, String)} + * . + * + * @param request + * @param response + * @param writer + * @param config + * @throws IOException + * @throws PortletException + */ + protected void writeAjaxPageScriptConfigurations(RenderRequest request, + RenderResponse response, final BufferedWriter writer, + Map<String, String> config) throws IOException, PortletException { + + writer.write("vaadin.vaadinConfigurations[\"" + request.getWindowID() + + "\"] = {"); + + Iterator<String> keyIt = config.keySet().iterator(); + while (keyIt.hasNext()) { + String key = keyIt.next(); + writer.write(key + ": " + config.get(key)); + if (keyIt.hasNext()) { + writer.write(", "); + } + } + + writer.write("};\n"); + } + + /** + * Writes the Vaadin theme loading section of the portlet HTML. Loads both + * the portal theme and the portlet theme in this order, skipping loading of + * themes that are already loaded (matched by name). + * + * @param request + * @param writer + * @param themeName + * @param themeURI + * @param portalTheme + * @throws IOException + */ + protected void writeAjaxPageHtmlTheme(RenderRequest request, + final BufferedWriter writer, String themeName, String themeURI, + String portalTheme) throws IOException { + writer.write("<script type=\"text/javascript\">\n"); if (portalTheme == null) { portalTheme = DEFAULT_THEME_NAME; } - page.write("if(!vaadin.themesLoaded['" + portalTheme + "']) {\n"); - page.write("var defaultStylesheet = document.createElement('link');\n"); - page.write("defaultStylesheet.setAttribute('rel', 'stylesheet');\n"); - page.write("defaultStylesheet.setAttribute('type', 'text/css');\n"); - page.write("defaultStylesheet.setAttribute('href', '" + writer.write("if(!vaadin.themesLoaded['" + portalTheme + "']) {\n"); + writer + .write("var defaultStylesheet = document.createElement('link');\n"); + writer.write("defaultStylesheet.setAttribute('rel', 'stylesheet');\n"); + writer.write("defaultStylesheet.setAttribute('type', 'text/css');\n"); + writer.write("defaultStylesheet.setAttribute('href', '" + getThemeURI(portalTheme, request) + "/styles.css');\n"); - page + writer .write("document.getElementsByTagName('head')[0].appendChild(defaultStylesheet);\n"); - page.write("vaadin.themesLoaded['" + portalTheme + "'] = true;\n}\n"); + writer.write("vaadin.themesLoaded['" + portalTheme + "'] = true;\n}\n"); if (!portalTheme.equals(themeName)) { - page.write("if(!vaadin.themesLoaded['" + themeName + "']) {\n"); - page.write("var stylesheet = document.createElement('link');\n"); - page.write("stylesheet.setAttribute('rel', 'stylesheet');\n"); - page.write("stylesheet.setAttribute('type', 'text/css');\n"); - page.write("stylesheet.setAttribute('href', '" + themeURI + writer.write("if(!vaadin.themesLoaded['" + themeName + "']) {\n"); + writer.write("var stylesheet = document.createElement('link');\n"); + writer.write("stylesheet.setAttribute('rel', 'stylesheet');\n"); + writer.write("stylesheet.setAttribute('type', 'text/css');\n"); + writer.write("stylesheet.setAttribute('href', '" + themeURI + "/styles.css');\n"); - page + writer .write("document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"); - page.write("vaadin.themesLoaded['" + themeName + "'] = true;\n}\n"); - } - - page.write("</script>\n"); - - // TODO Warn if widgetset has not been loaded after 15 seconds - - /*- Add classnames; - * .v-app - * .v-app-loading - * .v-app-<simpleName for app class> - * .v-theme-<themeName, remove non-alphanum> - */ - - String appClass = "v-app-"; - try { - appClass += getApplicationClass().getSimpleName(); - } catch (ClassNotFoundException e) { - appClass += "unknown"; - e.printStackTrace(); + writer.write("vaadin.themesLoaded['" + themeName + + "'] = true;\n}\n"); } - String themeClass = "v-theme-" - + themeName.replaceAll("[^a-zA-Z0-9]", ""); - String classNames = "v-app v-app-loading " + themeClass + " " - + appClass; + writer.write("</script>\n"); + } - String style = getApplicationProperty(PORTLET_PARAMETER_STYLE); - String divStyle = ""; - if (style != null) { - divStyle = "style=\"" + style + "\""; - } - page.write("<div id=\"" + request.getWindowID() + "\" class=\"" + /** + * Method to write the div element into which that actual Vaadin application + * is rendered. + * <p> + * Override this method if you want to add some custom html around around + * the div element into which the actual Vaadin application will be + * rendered. + * + * @param request + * @param response + * @param writer + * @param id + * @param classNames + * @param divStyle + * @throws IOException + */ + protected void writeAjaxPageHtmlMainDiv(RenderRequest request, + RenderResponse response, final BufferedWriter writer, String id, + String classNames, String divStyle) throws IOException { + writer.write("<div id=\"" + id + "\" class=\"" + classNames + "\" " + divStyle + "></div>\n"); - - page.close(); } /** @@ -1017,7 +1207,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet * @param window * @return */ - private String getThemeForWindow(PortletRequest request, Window window) { + protected String getThemeForWindow(PortletRequest request, Window window) { // Finds theme name String themeName; @@ -1189,12 +1379,21 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet + "\"appError\": {" + "\"caption\":" + caption + "," + "\"message\" : " + message + "," + "\"url\" : " + url + "}}, \"resources\": {}, \"locales\":[]}]"); - outWriter.flush(); outWriter.close(); - out.flush(); } - private static String getPortalProperty(String name, PortalContext context) { + /** + * Returns a portal configuration property. + * + * Liferay is handled separately as + * {@link PortalContext#getProperty(String)} does not return portal + * properties from e.g. portal-ext.properties . + * + * @param name + * @param context + * @return + */ + protected static String getPortalProperty(String name, PortalContext context) { boolean isLifeRay = context.getPortalInfo().toLowerCase().contains( "liferay"); diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 7a3978f323..8c901ba7e7 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -362,6 +362,9 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements HttpServletResponse response) throws ServletException, IOException { RequestType requestType = getRequestType(request); + if (!ensureCookiesEnabled(requestType, request, response)) { + return; + } if (requestType == RequestType.STATIC_FILE) { serveStaticResources(request, response); @@ -435,7 +438,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements return; } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests - applicationManager.handleUidlRequest(request, response, this); + Window window = applicationManager.getApplicationWindow( + request, this, application, null); + applicationManager.handleUidlRequest(request, response, this, + window); return; } @@ -502,6 +508,39 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } } + /** + * Check that cookie support is enabled in the browser. Only checks UIDL + * requests. + * + * @param requestType + * Type of the request as returned by + * {@link #getRequestType(HttpServletRequest)} + * @param request + * The request from the browser + * @param response + * The response to which an error can be written + * @return false if cookies are disabled, true otherwise + * @throws IOException + */ + private boolean ensureCookiesEnabled(RequestType requestType, + HttpServletRequest request, HttpServletResponse response) + throws IOException { + if (requestType == RequestType.UIDL && !isRepaintAll(request)) { + // In all other but the first UIDL request a cookie should be + // returned by the browser. + // This can be removed if cookieless mode (#3228) is supported + if (request.getRequestedSessionId() == null) { + // User has cookies disabled + criticalNotification(request, response, getSystemMessages() + .getCookiesDisabledCaption(), getSystemMessages() + .getCookiesDisabledMessage(), null, getSystemMessages() + .getCookiesDisabledURL()); + return false; + } + } + return true; + } + private void updateBrowserProperties(WebBrowser browser, HttpServletRequest request) { browser.updateBrowserProperties(request.getLocale(), request @@ -535,38 +574,40 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } /** - * Send notification to client's application. Used to notify client of - * critical errors and session expiration due to long inactivity. Server has - * no knowledge of what application client refers to. + * Send a notification to client's application. Used to notify client of + * critical errors, session expiration and more. Server has no knowledge of + * what application client refers to. * * @param request * the HTTP request instance. * @param response * the HTTP response to write to. * @param caption - * for the notification + * the notification caption * @param message - * for the notification + * to notification body * @param details - * a detail message to show in addition to the passed message. - * Currently shown directly but could be hidden behind a details - * drop down. + * a detail message to show in addition to the message. Currently + * shown directly below the message but could be hidden behind a + * details drop down in the future. Mainly used to give + * additional information not necessarily useful to the end user. * @param url - * url to load after message, null for current page + * url to load when the message is dismissed. Null will reload + * the current page. * @throws IOException * if the writing failed due to input/output error. */ - void criticalNotification(HttpServletRequest request, + protected final void criticalNotification(HttpServletRequest request, HttpServletResponse response, String caption, String message, String details, String url) throws IOException { - // clients JS app is still running, but server application either - // no longer exists or it might fail to perform reasonably. - // send a notification to client's application and link how - // to "restart" application. + if (!isUIDLRequest(request)) { + throw new RuntimeException( + "criticalNotification can only be used in UIDL requests"); + } if (caption != null) { - caption = "\"" + caption + "\""; + caption = "\"" + JsonPaintTarget.escapeJSON(caption) + "\""; } if (details != null) { if (message == null) { @@ -575,11 +616,12 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements message += "<br/><br/>" + details; } } + if (message != null) { - message = "\"" + message + "\""; + message = "\"" + JsonPaintTarget.escapeJSON(message) + "\""; } if (url != null) { - url = "\"" + url + "\""; + url = "\"" + JsonPaintTarget.escapeJSON(url) + "\""; } // Set the response type @@ -1489,7 +1531,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements * is rendered. * <p> * Override this method if you want to add some custom html around around - * the div element into which the actual vaadin application will be + * the div element into which the actual Vaadin application will be * rendered. * * @param page @@ -1507,8 +1549,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } /** - * - * * Method to write the script part of the page which loads needed vaadin + * Method to write the script part of the page which loads needed Vaadin * scripts and themes. * <p> * Override this method if you want to add some custom html around scripts. diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 67b806f0f0..481e42c0e9 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -498,11 +498,14 @@ public abstract class AbstractCommunicationManager implements * @param request * @param response * @param callback + * @param window + * target window for the UIDL request, can be null if target not + * found * @throws IOException * @throws InvalidUIDLSecurityKeyException */ protected void doHandleUidlRequest(Request request, Response response, - Callback callback) throws IOException, + Callback callback, Window window) throws IOException, InvalidUIDLSecurityKeyException { // repaint requested or session has timed out and new one is created @@ -528,10 +531,7 @@ public abstract class AbstractCommunicationManager implements synchronized (application) { // Finds the window within the application - Window window = null; if (application.isRunning()) { - window = doGetApplicationWindow(request, callback, application, - null); // Returns if no window found if (window == null) { // This should not happen, no windows exists but @@ -588,8 +588,7 @@ public abstract class AbstractCommunicationManager implements } } - // out.flush(); - this line will cause errors when deployed on GateIn. - out.close(); + outWriter.close(); } /** @@ -947,7 +946,6 @@ public abstract class AbstractCommunicationManager implements outWriter.print("}]"); } - outWriter.flush(); outWriter.close(); } @@ -1871,7 +1869,7 @@ public abstract class AbstractCommunicationManager implements } return stream; } else { - // Resolve the prefix end inded + // Resolve the prefix end index final int index = uri.indexOf('/'); if (index > 0) { String prefix = uri.substring(0, index); diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index 8799e37899..4e6bfbd158 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -238,16 +238,22 @@ public class CommunicationManager extends AbstractCommunicationManager { * * @param request * @param response + * @param applicationServlet + * @param window + * target window of the UIDL request, can be null if window not + * found * @throws IOException * @throws ServletException */ public void handleUidlRequest(HttpServletRequest request, HttpServletResponse response, - AbstractApplicationServlet applicationServlet) throws IOException, - ServletException, InvalidUIDLSecurityKeyException { + AbstractApplicationServlet applicationServlet, Window window) + throws IOException, ServletException, + InvalidUIDLSecurityKeyException { doHandleUidlRequest(new HttpServletRequestWrapper(request), new HttpServletResponseWrapper(response), - new AbstractApplicationServletWrapper(applicationServlet)); + new AbstractApplicationServletWrapper(applicationServlet), + window); } /** diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index ab1b1da81f..a6f8d7f204 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -139,18 +139,18 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { } } - public void firePortletRenderRequest(Application app, + public void firePortletRenderRequest(Application app, Window window, RenderRequest request, RenderResponse response) { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { l.handleRenderRequest(request, new RestrictedRenderResponse( - response)); + response), window); } } } - public void firePortletActionRequest(Application app, + public void firePortletActionRequest(Application app, Window window, ActionRequest request, ActionResponse response) { String key = request.getParameter(ActionRequest.ACTION_NAME); if (eventActionDestinationMap.containsKey(key)) { @@ -172,28 +172,28 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleActionRequest(request, response); + l.handleActionRequest(request, response, window); } } } } - public void firePortletEventRequest(Application app, EventRequest request, - EventResponse response) { + public void firePortletEventRequest(Application app, Window window, + EventRequest request, EventResponse response) { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleEventRequest(request, response); + l.handleEventRequest(request, response, window); } } } - public void firePortletResourceRequest(Application app, + public void firePortletResourceRequest(Application app, Window window, ResourceRequest request, ResourceResponse response) { Set<PortletListener> listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleResourceRequest(request, response); + l.handleResourceRequest(request, response, window); } } } @@ -201,16 +201,16 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { public interface PortletListener extends Serializable { public void handleRenderRequest(RenderRequest request, - RenderResponse response); + RenderResponse response, Window window); public void handleActionRequest(ActionRequest request, - ActionResponse response); + ActionResponse response, Window window); public void handleEventRequest(EventRequest request, - EventResponse response); + EventResponse response, Window window); public void handleResourceRequest(ResourceRequest request, - ResourceResponse response); + ResourceResponse response, Window window); } /** diff --git a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index 3a5cd90f7c..7fe324b1db 100644 --- a/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -3,6 +3,7 @@ package com.vaadin.terminal.gwt.server; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.Method; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; @@ -13,6 +14,8 @@ import javax.portlet.PortletResponse; import javax.portlet.PortletSession; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequestWrapper; import com.vaadin.Application; import com.vaadin.external.org.apache.commons.fileupload.FileItemIterator; @@ -54,7 +57,20 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } public String getParameter(String name) { - return request.getParameter(name); + String value = request.getParameter(name); + if (value == null) { + // for GateIn portlet container simple-portal + try { + Method getRealReq = request.getClass().getMethod( + "getRealRequest"); + HttpServletRequestWrapper origRequest = (HttpServletRequestWrapper) getRealReq + .invoke(request); + value = origRequest.getParameter(name); + } catch (Exception e) { + // do nothing - not on GateIn simple-portal + } + } + return value; } public String getRequestID() { @@ -165,19 +181,6 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { + themeName + "/" + resource); } - /** - * Find the application window to use based on the portlet mode. For - * internal use only, not in the {@link Callback} interface. - * - * @param request - * @param application - * @return - */ - public Window getPortletWindow(PortletRequest request, - Application application) { - return portlet.getPortletWindow(request, application); - } - } public PortletCommunicationManager(Application application) { @@ -222,11 +225,12 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { public void handleUidlRequest(ResourceRequest request, ResourceResponse response, - AbstractApplicationPortlet applicationPortlet) + AbstractApplicationPortlet applicationPortlet, Window window) throws InvalidUIDLSecurityKeyException, IOException { doHandleUidlRequest(new PortletRequestWrapper(request), new PortletResponseWrapper(response), - new AbstractApplicationPortletWrapper(applicationPortlet)); + new AbstractApplicationPortletWrapper(applicationPortlet), + window); } DownloadStream handleURI(Window window, ResourceRequest request, @@ -237,18 +241,29 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { new AbstractApplicationPortletWrapper(applicationPortlet)); } - @Override - protected Window doGetApplicationWindow(Request request, Callback callback, + /** + * Gets the existing application or creates a new one. Get a window within + * an application based on the requested URI. + * + * @param request + * the portlet Request. + * @param applicationPortlet + * @param application + * the Application to query for window. + * @param assumedWindow + * if the window has been already resolved once, this parameter + * must contain the window. + * @return Window matching the given URI or null if not found. + * @throws ServletException + * if an exception has occurred that interferes with the + * servlet's normal operation. + */ + Window getApplicationWindow(PortletRequest request, + AbstractApplicationPortlet applicationPortlet, Application application, Window assumedWindow) { - // find window based on portlet mode - if (assumedWindow == null - && callback instanceof AbstractApplicationPortletWrapper - && request.getWrappedRequest() instanceof PortletRequest) { - assumedWindow = ((AbstractApplicationPortletWrapper) callback) - .getPortletWindow((PortletRequest) request - .getWrappedRequest(), application); - } - return super.doGetApplicationWindow(request, callback, application, - assumedWindow); + return doGetApplicationWindow(new PortletRequestWrapper(request), + new AbstractApplicationPortletWrapper(applicationPortlet), + application, assumedWindow); } + } diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java index b3c670ba81..ca20b8b895 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java @@ -19,7 +19,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -175,7 +174,9 @@ public class ClassPathExplorer { for (int i = 0; i < widgetsetNames.length; i++) { String widgetsetname = widgetsetNames[i].trim() .intern(); - widgetsets.put(widgetsetname, location); + if (!widgetsetname.equals("")) { + widgetsets.put(widgetsetname, location); + } } } } @@ -439,8 +440,15 @@ public class ClassPathExplorer { * @return URL */ public static URL getDefaultSourceDirectory() { - logger.fine("classpathLocations keys: " - + new TreeSet<URL>(classpathLocations.keySet())); + if (logger.isLoggable(Level.FINE)) { + logger.fine("classpathLocations keys:"); + ArrayList<URL> locations = new ArrayList<URL>(classpathLocations + .keySet()); + for (URL location : locations) { + logger.fine(location.toString()); + } + } + Iterator<String> it = rawClasspathEntries.iterator(); while (it.hasNext()) { String entry = it.next(); diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 3ed50b2d42..65a34a18bb 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -13,6 +13,7 @@ import com.vaadin.data.Property; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.gwt.client.ui.VButton; +import com.vaadin.ui.themes.BaseTheme; /** * A generic button component. @@ -239,7 +240,12 @@ public class Button extends AbstractField { private static final Method BUTTON_CLICK_METHOD; - /* Button style with no decorations. Looks like a link, acts like a button */ + /** + * Button style with no decorations. Looks like a link, acts like a button + * + * @deprecated use {@link BaseTheme#BUTTON_LINK} instead. + */ + @Deprecated public static final String STYLE_LINK = "link"; static { diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java index c6c9a5a738..678c323dc3 100644 --- a/src/com/vaadin/ui/Form.java +++ b/src/com/vaadin/ui/Form.java @@ -479,54 +479,99 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, return false; } + // Register and attach the created field addField(id, field); return true; } /** - * Adds the field to form. + * Registers the field with the form and adds the field to the form layout. * * <p> * The property id must not be already used in the form. * </p> * * <p> - * This field is added to the form layout in the default position (the - * position used by {@link Layout#addComponent(Component)} method. In the - * special case that the underlying layout is a custom layout, string - * representation of the property id is used instead of the default - * location. + * This field is added to the layout using the + * {@link #attachField(Object, Field)} method. * </p> * * @param propertyId * the Property id the the field. * @param field - * the New field added to the form. + * the field which should be added to the form. */ public void addField(Object propertyId, Field field) { + registerField(propertyId, field); + attachField(propertyId, field); + requestRepaint(); + } - if (propertyId != null && field != null) { - fields.put(propertyId, field); - field.addListener(fieldValueChangeListener); - if (!propertyIds.contains(propertyId)) { - // adding a field directly - propertyIds.addLast(propertyId); - } - field.setReadThrough(readThrough); - field.setWriteThrough(writeThrough); - if (isImmediate() && field instanceof AbstractComponent) { - ((AbstractComponent) field).setImmediate(true); - } - if (layout instanceof CustomLayout) { - ((CustomLayout) layout).addComponent(field, propertyId - .toString()); - } else { - layout.addComponent(field); - } + /** + * Register the field with the form. All registered fields are validated + * when the form is validated and also committed when the form is committed. + * + * <p> + * The property id must not be already used in the form. + * </p> + * + * + * @param propertyId + * the Property id of the field. + * @param field + * the Field that should be registered + */ + private void registerField(Object propertyId, Field field) { + if (propertyId == null || field == null) { + return; + } - requestRepaint(); + fields.put(propertyId, field); + field.addListener(fieldValueChangeListener); + if (!propertyIds.contains(propertyId)) { + // adding a field directly + propertyIds.addLast(propertyId); } + + // Update the read and write through status and immediate to match the + // form. + // Should this also include invalidCommitted (#3993)? + field.setReadThrough(readThrough); + field.setWriteThrough(writeThrough); + if (isImmediate() && field instanceof AbstractComponent) { + ((AbstractComponent) field).setImmediate(true); + } + } + + /** + * Adds the field to the form layout. + * <p> + * The field is added to the form layout in the default position (the + * position used by {@link Layout#addComponent(Component)}. If the + * underlying layout is a {@link CustomLayout} the field is added to the + * CustomLayout location given by the string representation of the property + * id using {@link CustomLayout#addComponent(Component, String)}. + * </p> + * + * <p> + * Override this method to control how the fields are added to the layout. + * </p> + * + * @param propertyId + * @param field + */ + protected void attachField(Object propertyId, Field field) { + if (propertyId == null || field == null) { + return; + } + + if (layout instanceof CustomLayout) { + ((CustomLayout) layout).addComponent(field, propertyId.toString()); + } else { + layout.addComponent(field); + } + } /** diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java index df08c4e62b..f4ce352687 100644 --- a/src/com/vaadin/ui/Panel.java +++ b/src/com/vaadin/ui/Panel.java @@ -19,6 +19,8 @@ import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Scrollable; import com.vaadin.terminal.gwt.client.MouseEventDetails; import com.vaadin.terminal.gwt.client.ui.VPanel; +import com.vaadin.ui.themes.Reindeer; +import com.vaadin.ui.themes.Runo; /** * Panel - a simple single component container. @@ -36,6 +38,16 @@ public class Panel extends AbstractComponentContainer implements Scrollable, private static final String CLICK_EVENT = VPanel.CLICK_EVENT_IDENTIFIER; + /** + * Removes extra decorations from the Panel. + * + * @deprecated this style is no longer part of the core framework and this + * component, even though most built-in themes implement this + * style. Use the constant specified in the theme class file + * that you're using, if it provides one, e.g. + * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT} . + */ + @Deprecated public static final String STYLE_LIGHT = "light"; /** diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java index 5e67b93369..1a149d7394 100644 --- a/src/com/vaadin/ui/SplitPanel.java +++ b/src/com/vaadin/ui/SplitPanel.java @@ -281,10 +281,11 @@ public class SplitPanel extends AbstractLayout { * Moves the position of the splitter. * * @param pos - * the new size of the first region in percentage + * the new size of the first region in the unit that was last + * used (default is percentage) */ public void setSplitPosition(int pos) { - setSplitPosition(pos, UNITS_PERCENTAGE, true); + setSplitPosition(pos, posUnit, true); } /** @@ -303,7 +304,7 @@ public class SplitPanel extends AbstractLayout { * Moves the position of the splitter. * * @param pos - * the new size of the first region in percentage + * the new size of the first region * @param unit * the unit (from {@link Sizeable}) in which the size is given. * @param repaintNotNeeded @@ -312,6 +313,10 @@ public class SplitPanel extends AbstractLayout { * knows the position. */ private void setSplitPosition(int pos, int unit, boolean repaintNeeded) { + if (unit != UNITS_PERCENTAGE && unit != UNITS_PIXELS) { + throw new IllegalArgumentException( + "Only percentage and pixel units are allowed"); + } this.pos = pos; posUnit = unit; if (repaintNeeded) { @@ -353,8 +358,7 @@ public class SplitPanel extends AbstractLayout { if (variables.containsKey("position") && !isLocked()) { Integer newPos = (Integer) variables.get("position"); - // Client always sends pixel values. Repaint is not needed. - setSplitPosition(newPos, UNITS_PIXELS, false); + setSplitPosition(newPos, posUnit, false); } if (variables.containsKey(SPLITTER_CLICK_EVENT)) { diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 9246067541..753a52a3de 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -40,14 +40,20 @@ import com.vaadin.terminal.gwt.client.ui.VScrollTable; /** * <p> - * <code>TableComponent</code> is used for representing data or components in - * pageable and selectable table. + * <code>Table</code> is used for representing data or components in a pageable + * and selectable table. * </p> * * <p> - * Note! Since version 5, components in Table will not have their caption nor - * icon rendered. In order to workaround this limitation, wrap your component in - * a Layout. + * Scalability of the Table is largely dictated by the container. A table does + * not have a limit for the number of items and is just as fast with hundreds of + * thousands of items as with just a few. The current GWT implementation with + * scrolling however limits the number of rows to around 500000, depending on + * the browser and the pixel height of rows. + * </p> + * + * <p> + * Components in a Table will not have their caption nor icon rendered. * </p> * * @author IT Mill Ltd. @@ -518,6 +524,8 @@ public class Table extends AbstractSelect implements Action.Container, } // Assures the visual refresh + // FIXME: Is this really needed? Header captions should not affect + // content so requestRepaint() should be sufficient. resetPageBuffer(); refreshRenderedCells(); } @@ -987,6 +995,8 @@ public class Table extends AbstractSelect implements Action.Container, columnHeaders.put(propertyId, header); // Assures the visual refresh + // FIXME: Is this really needed? Header captions should not affect + // content so requestRepaint() should be sufficient. refreshRenderedCells(); } diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index 665e98cfee..d28d02216c 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -45,6 +45,7 @@ import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers; import com.vaadin.terminal.gwt.client.ui.dd.VOverTreeNode; import com.vaadin.terminal.gwt.client.ui.dd.VTargetNodeIsChildOf; import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; +import com.vaadin.tools.ReflectTools; /** * Tree component. A Tree can be used to select an item (or multiple items) from @@ -60,29 +61,12 @@ import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation; public class Tree extends AbstractSelect implements Container.Hierarchical, Action.Container, ItemClickSource, DragSource, DropTarget { - private static final Method EXPAND_METHOD; - - private static final Method COLLAPSE_METHOD; - - static { - try { - EXPAND_METHOD = ExpandListener.class.getDeclaredMethod( - "nodeExpand", new Class[] { ExpandEvent.class }); - COLLAPSE_METHOD = CollapseListener.class.getDeclaredMethod( - "nodeCollapse", new Class[] { CollapseEvent.class }); - } catch (final java.lang.NoSuchMethodException e) { - // This should never happen - throw new java.lang.RuntimeException( - "Internal error finding methods in Tree"); - } - } - /* Private members */ /** * Set of expanded nodes. */ - private final HashSet expanded = new HashSet(); + private final HashSet<Object> expanded = new HashSet<Object>(); /** * List of action handlers. @@ -775,6 +759,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public interface ExpandListener extends Serializable { + public static final Method EXPAND_METHOD = ReflectTools.findMethod( + ExpandListener.class, "nodeExpand", ExpandEvent.class); + /** * A node has been expanded. * @@ -791,7 +778,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * the Listener to be added. */ public void addListener(ExpandListener listener) { - addListener(ExpandEvent.class, listener, EXPAND_METHOD); + addListener(ExpandEvent.class, listener, ExpandListener.EXPAND_METHOD); } /** @@ -801,7 +788,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * the Listener to be removed. */ public void removeListener(ExpandListener listener) { - removeListener(ExpandEvent.class, listener, EXPAND_METHOD); + removeListener(ExpandEvent.class, listener, + ExpandListener.EXPAND_METHOD); } /** @@ -860,6 +848,9 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public interface CollapseListener extends Serializable { + public static final Method COLLAPSE_METHOD = ReflectTools.findMethod( + CollapseListener.class, "nodeCollapse", CollapseEvent.class); + /** * A node has been collapsed. * @@ -876,7 +867,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * the Listener to be added. */ public void addListener(CollapseListener listener) { - addListener(CollapseEvent.class, listener, COLLAPSE_METHOD); + addListener(CollapseEvent.class, listener, + CollapseListener.COLLAPSE_METHOD); } /** @@ -886,7 +878,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * the Listener to be removed. */ public void removeListener(CollapseListener listener) { - removeListener(CollapseEvent.class, listener, COLLAPSE_METHOD); + removeListener(CollapseEvent.class, listener, + CollapseListener.COLLAPSE_METHOD); } /** @@ -1155,7 +1148,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, Object itemIdOver = getItemIdOver(); if (areChildrenAllowed(itemIdOver) - && getDropLocation() != VerticalDropLocation.TOP) { + && getDropLocation() == VerticalDropLocation.MIDDLE) { return itemIdOver; } return getParent(itemIdOver); diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 63daabdf90..f4657d81f6 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -1053,28 +1053,63 @@ public class Window extends Panel implements URIHandler, ParameterHandler { } } + /** + * An interface used for listening to Window close events. Add the + * CloseListener to a browser level window or a sub window and + * {@link CloseListener#windowClose(CloseEvent)} will be called whenever the + * user closes the window. + * + * <p> + * Note that removing windows using {@link #removeWindow(Window)} will not + * fire the CloseListener. + * </p> + */ public interface CloseListener extends Serializable { + /** + * Called when the user closes a window. Use + * {@link CloseEvent#getWindow()} to get a reference to the + * {@link Window} that was closed. + * + * @param e + * Event containing + */ public void windowClose(CloseEvent e); } /** - * Adds the listener. + * Adds a CloseListener to the window. + * + * For a sub window the CloseListener is fired when the user closes it + * (clicks on the close button). + * + * For a browser level window the CloseListener is fired when the browser + * level window is closed. Note that closing a browser level window does not + * mean it will be destroyed. + * + * <p> + * Note that removing windows using {@link #removeWindow(Window)} will not + * fire the CloseListener. + * </p> * * @param listener - * the listener to add. + * the CloseListener to add. */ public void addListener(CloseListener listener) { addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); } /** - * Removes the listener. + * Removes the CloseListener from the window. + * + * <p> + * For more information on CloseListeners see {@link CloseListener}. + * </p> * * @param listener - * the listener to remove. + * the CloseListener to remove. */ public void removeListener(CloseListener listener) { - addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); + removeListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD); } protected void fireClose() { diff --git a/src/com/vaadin/ui/themes/BaseTheme.java b/src/com/vaadin/ui/themes/BaseTheme.java new file mode 100644 index 0000000000..48083f5240 --- /dev/null +++ b/src/com/vaadin/ui/themes/BaseTheme.java @@ -0,0 +1,44 @@ +package com.vaadin.ui.themes; + +/** + * <p> + * The Base theme is the foundation for all Vaadin themes. Although it is not + * necessary to use it as the starting point for all other themes, it is heavily + * encouraged, since it abstracts and hides away many necessary style properties + * that the Vaadin terminal expects and needs. + * </p> + * <p> + * When creating your own theme, either extend this class and specify the styles + * implemented in your theme here, or extend some other theme that has a class + * file specified (e.g. Reindeer or Runo). + * </p> + * <p> + * All theme class files should follow the convention of specifying the theme + * name as a string constant <code>THEME_NAME</code>. + * + * @since 6.3.0 + * + */ +public class BaseTheme { + + public static final String THEME_NAME = "Base"; + + /** + * Creates a button that looks like a regular hypertext link but still acts + * like a normal button. + */ + public static final String BUTTON_LINK = "link"; + + /** + * Removes extra decorations from the panel. + * + * @deprecated Base theme does not implement this style, but it is defined + * here since it has been a part of the framework before + * multiple themes were available. Use the constant provided by + * the theme you're using instead, e.g. + * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT}. + */ + @Deprecated + public static final String PANEL_LIGHT = "light"; + +}
\ No newline at end of file diff --git a/src/com/vaadin/ui/themes/Reindeer.java b/src/com/vaadin/ui/themes/Reindeer.java new file mode 100644 index 0000000000..acbf003151 --- /dev/null +++ b/src/com/vaadin/ui/themes/Reindeer.java @@ -0,0 +1,163 @@ +package com.vaadin.ui.themes; + +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.VerticalLayout; + +public class Reindeer extends BaseTheme { + + public static final String THEME_NAME = "Reindeer"; + + /*************************************************************************** + * + * Label styles + * + **************************************************************************/ + + /** + * Large font for main application headings + */ + public static final String LABEL_H1 = "h1"; + + /** + * Large font for different sections in the application + */ + public static final String LABEL_H2 = "h2"; + + /** + * Small and a little lighter font + */ + public static final String LABEL_SMALL = "light"; + + /*************************************************************************** + * + * Button styles + * + **************************************************************************/ + + /** + * Default action style for buttons (the button that gets activated when + * user presses 'enter' in a form). Use sparingly, only one default button + * per screen should be visible. + */ + public static final String BUTTON_DEFAULT = "primary"; + + /** + * Small sized button, use for context specific actions for example + */ + public static final String BUTTON_SMALL = "small"; + + /*************************************************************************** + * + * TextField styles + * + **************************************************************************/ + + /** + * Small sized text field with small font + */ + public static final String TEXTFIELD_SMALL = "small"; + + /*************************************************************************** + * + * Panel styles + * + **************************************************************************/ + + /** + * Removes borders and background color from the panel + */ + public static final String PANEL_LIGHT = "light"; + + /*************************************************************************** + * + * SplitPanel styles + * + **************************************************************************/ + + /** + * Reduces the split handle to a minimal size (1 pixel) + */ + public static final String SPLITPANEL_SMALL = "small"; + + /*************************************************************************** + * + * TabSheet styles + * + **************************************************************************/ + + /** + * Removes borders and background color from the tab sheet, and shows the + * tabs as a small bar. + */ + public static final String TABSHEET_BAR = "bar"; + + /** + * Removes borders and background color from the tab sheet. The tabs are + * presented with minimal lines indicating the selected tab. + */ + public static final String TABSHEET_MINIMAL = "minimal"; + + /*************************************************************************** + * + * Table styles + * + **************************************************************************/ + + /** + * Removes borders from the table + */ + public static final String TABLE_BORDERLESS = "borderless"; + + /** + * Makes the table headers dark and more prominent. + */ + public static final String TABLE_STRONG = "strong"; + + /*************************************************************************** + * + * Layout styles + * + **************************************************************************/ + + /** + * Changes the background of a layout to a shade of blue. Applies to + * {@link VerticalLayout}, {@link HorizontalLayout}, {@link GridLayout}, + * {@link FormLayout} and {@link CssLayout}. + */ + public static final String LAYOUT_BLUE = "blue"; + + /** + * <p> + * Changes the background of a layout to almost black, and at the same time + * transforms contained components to their black style correspondents when + * available. At least texts, buttons, text fields, selects, date fields, + * tables and a few other component styles should change. + * </p> + * <p> + * Applies to {@link VerticalLayout}, {@link HorizontalLayout}, + * {@link GridLayout}, {@link FormLayout} and {@link CssLayout}. + * </p> + * + */ + public static final String LAYOUT_BLACK = "black"; + + /*************************************************************************** + * + * Window styles + * + **************************************************************************/ + + /** + * Makes the whole window white and increases the font size of the title. + */ + public static final String WINDOW_LIGHT = "light"; + + /** + * Makes the whole window black, and changes contained components in the + * same way as {@link #LAYOUT_BLACK} does. + */ + public static final String WINDOW_BLACK = "black"; +} diff --git a/src/com/vaadin/ui/themes/Runo.java b/src/com/vaadin/ui/themes/Runo.java new file mode 100644 index 0000000000..4df6046756 --- /dev/null +++ b/src/com/vaadin/ui/themes/Runo.java @@ -0,0 +1,30 @@ +package com.vaadin.ui.themes; + + +public class Runo extends BaseTheme { + + public static final String THEME_NAME = "Runo"; + + /*************************************************************************** + * + * Button styles + * + **************************************************************************/ + + /** + * Small sized button, use for context specific actions for example + */ + public static final String BUTTON_SMALL = "small"; + + /*************************************************************************** + * + * Panel styles + * + **************************************************************************/ + + /** + * Removes borders and background color from the panel + */ + public static final String PANEL_LIGHT = "light"; + +} diff --git a/tests/scripts/sampler-all-samples.html b/tests/scripts/sampler-all-samples.html index 859bb876ea..917064bbfc 100644 --- a/tests/scripts/sampler-all-samples.html +++ b/tests/scripts/sampler-all-samples.html @@ -1043,6 +1043,16 @@ <td></td> <td></td> </tr> +<tr> +<td>mouseClick</td> +<td>vaadin=sampler::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[7]/VHorizontalLayout[0]/ChildComponentContainer[1]/VNativeButton[0]</td> +<td>1,1</td> +</tr> +<tr> +<td>waitForVaadin</td> +<td></td> +<td></td> +</tr> <!--Start over from the main page--> <tr> <td>mouseClick</td> @@ -1918,6 +1928,27 @@ <td></td> <td></td> </tr> +<!--FormAdvancedLayout--> +<tr> +<td>screenCapture</td> +<td></td> +<td>FormAdvancedLayout</td> +</tr> +<tr> +<td>waitForVaadin</td> +<td></td> +<td></td> +</tr> +<tr> +<td>mouseClick</td> +<td>vaadin=sampler::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[7]/VHorizontalLayout[0]/ChildComponentContainer[1]/VNativeButton[0]</td> +<td>1,1</td> +</tr> +<tr> +<td>waitForVaadin</td> +<td></td> +<td></td> +</tr> <!--LoginForm--> <tr> <td>pause</td> diff --git a/tests/src/com/vaadin/automatedtests/ComponentsInTable.java b/tests/src/com/vaadin/automatedtests/ComponentsInTable.java deleted file mode 100644 index ccbe29d2d5..0000000000 --- a/tests/src/com/vaadin/automatedtests/ComponentsInTable.java +++ /dev/null @@ -1,77 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests;
-
-import java.util.Date;
-import java.util.Random;
-import java.util.Vector;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.OrderedLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Button.ClickEvent;
-
-@SuppressWarnings("serial")
-public class ComponentsInTable extends CustomComponent {
-
- public ComponentsInTable(int cols, int rows) {
- final OrderedLayout main = new OrderedLayout();
- setCompositionRoot(main);
-
- main.addComponent(getTestTable(cols, rows));
- }
-
- public static Table getTestTable(int cols, int rows) {
- Random rnd = new Random(1);
-
- final Table t = new Table();
- t.setColumnCollapsingAllowed(true);
- for (int i = 0; i < cols; i++) {
- t.addContainerProperty(testString[i], String.class, "");
- }
- t.addContainerProperty("button", Button.class, null);
- for (int i = 0; i < rows; i++) {
- final Vector content = new Vector();
- for (int j = 0; j < cols; j++) {
- content.add(rndString(rnd));
- }
- content.add(new Button("b" + i, new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- System.out.println(event.getButton().getCaption()
- + " click: " + (new Date()).toGMTString());
- System.out.println(event.getButton().getApplication());
-
- }
- }));
- t.addItem(content.toArray(), "" + i);
- }
- t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- return t;
- }
-
- static String[] testString = new String[] { "Jacob", "Michael", "Joshua",
- "Matthew", "Ethan", "Andrew", "Daniel", "Anthony", "Christopher",
- "Joseph", "William", "Alexander", "Ryan", "David", "Nicholas",
- "Tyler", "James", "John", "Jonathan", "Nathan", "Samuel",
- "Christian", "Noah", "Dylan", "Benjamin", "Logan", "Brandon",
- "Gabriel", "Zachary", "Jose", "Elijah", "Angel", "Kevin", "Jack",
- "Caleb", "Justin", "Austin", "Evan", "Robert", "Thomas", "Luke",
- "Mason", "Aidan", "Jackson", "Isaiah", "Jordan", "Gavin", "Connor",
- "Aiden", "Isaac", "Jason", "Cameron", "Hunter", "Jayden", "Juan",
- "Charles", "Aaron", "Lucas", "Luis", "Owen", "Landon", "Diego",
- "Brian", "Adam", "Adrian", "Kyle", "Eric", "Ian", "Nathaniel",
- "Carlos", "Alex", "Bryan", "Jesus", "Julian", "Sean", "Carter",
- "Hayden", "Jeremiah", "Cole", "Brayden", "Wyatt", "Chase",
- "Steven", "Timothy", "Dominic", "Sebastian", "Xavier", "Jaden",
- "Jesse", "Devin", "Seth", "Antonio", "Richard", "Miguel", "Colin",
- "Cody", "Alejandro", "Caden", "Blake", "Carson" };
-
- public static String rndString(Random rnd) {
- return testString[(int) (rnd.nextDouble() * testString.length)];
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/SimplestApplication.java b/tests/src/com/vaadin/automatedtests/SimplestApplication.java deleted file mode 100644 index 7de7e0928e..0000000000 --- a/tests/src/com/vaadin/automatedtests/SimplestApplication.java +++ /dev/null @@ -1,19 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests; - -import com.vaadin.ui.Label; -import com.vaadin.ui.Window; - -@SuppressWarnings("serial") -public class SimplestApplication extends com.vaadin.Application { - - @Override - public void init() { - final Window main = new Window("Simplest Application window"); - setMainWindow(main); - main.addComponent(new Label("Simplest Application label")); - } -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/AccordionExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/AccordionExample.java deleted file mode 100644 index 05894392ef..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/AccordionExample.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.vaadin.automatedtests.featurebrowser; - -import com.vaadin.ui.Accordion; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Label; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; - -/** - * Accordion is a derivative of TabSheet, a vertical tabbed layout that places - * the tab contents between the vertical tabs. - */ -@SuppressWarnings("serial") -public class AccordionExample extends CustomComponent { - - public AccordionExample() { - // Create a new accordion - final Accordion accordion = new Accordion(); - setCompositionRoot(accordion); - - // Add a few tabs to the accordion. - for (int i = 0; i < 5; i++) { - // Create a root component for a accordion tab - VerticalLayout layout = new VerticalLayout(); - accordion.addComponent(layout); - - // The accordion tab label is taken from the caption of the root - // component. Notice that layouts can have a caption too. - layout.setCaption("Tab " + (i + 1)); - - // Add some components in each accordion tab - Label label = new Label("These are the contents of Tab " + (i + 1) - + "."); - layout.addComponent(label); - - TextField textfield = new TextField("Some text field"); - layout.addComponent(textfield); - } - } -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/ButtonExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/ButtonExample.java deleted file mode 100644 index aabfe41b20..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/ButtonExample.java +++ /dev/null @@ -1,151 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * Shows a few variations of Buttons and Links.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class ButtonExample extends CustomComponent implements
- Button.ClickListener {
-
- public ButtonExample() {
-
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final HorizontalLayout horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- final Panel basic = new Panel("Basic buttons");
- basic.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(basic);
-
- final Panel bells = new Panel("w/ bells & whistles");
- bells.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(bells);
-
- Button b = new Button("Basic button");
- b.setDebugId("Basic1");
- b.addListener(this);
- basic.addComponent(b);
-
- b = new Button("Button w/ icon + tooltip");
- b.setDebugId("Button2");
- b.addListener(this);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("This button does nothing, fast");
- bells.addComponent(b);
-
- b = new CheckBox("CheckBox - a switch-button");
- b.setDebugId("Button3");
- b.setImmediate(true); // checkboxes are not immediate by default
- b.addListener(this);
- basic.addComponent(b);
-
- b = new CheckBox("CheckBox w/ icon + tooltip");
- b.setDebugId("Button4");
- b.setImmediate(true); // checkboxes are not immediate by default
- b.addListener(this);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("This is a CheckBox");
- bells.addComponent(b);
-
- b = new Button("Link-style button");
- b.setDebugId("Button5");
- b.addListener(this);
- b.setStyleName(Button.STYLE_LINK);
- basic.addComponent(b);
-
- b = new Button("Link button w/ icon + tooltip");
- b.setDebugId("Button6");
- b.addListener(this);
- b.setStyleName(Button.STYLE_LINK);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("Link-style, icon+tootip, no caption");
- bells.addComponent(b);
-
- b = new Button();
- b.setDebugId("Button7");
- b.addListener(this);
- b.setStyleName(Button.STYLE_LINK);
- b.setIcon(new ThemeResource("icons/ok.png"));
- b.setDescription("Link-style, icon+tootip, no caption");
- basic.addComponent(b);
-
- final Panel links = new Panel("Links");
- links.setStyleName(Panel.STYLE_LIGHT);
- main.addComponent(links);
- final Label desc = new Label(
- "The main difference between a Link and"
- + " a link-styled Button is that the Link works client-"
- + " side, whereas the Button works server side.<br/> This means"
- + " that the Button triggers some event on the server,"
- + " while the Link is a normal web-link. <br/><br/>Note that for"
- + " opening new windows, the Link might be a safer "
- + " choice, since popup-blockers might interfer with "
- + " server-initiated window opening.");
- desc.setContentMode(Label.CONTENT_XHTML);
- links.addComponent(desc);
- Link l = new Link("Vaadin home", new ExternalResource(
- "http://www.vaadin.com"));
- l.setDebugId("Link1");
- l.setDescription("Link without target name, opens in this window");
- links.addComponent(l);
-
- l = new Link("Vaadin home (new window)", new ExternalResource(
- "http://www.vaadin.com"));
- l.setDebugId("Link2");
- l.setTargetName("_blank");
- l.setDescription("Link with target name, opens in new window");
- links.addComponent(l);
-
- l = new Link("Vaadin home (new window, less decor)",
- new ExternalResource("http://www.vaadin.com"));
- l.setDebugId("Link3");
- l.setTargetName("_blank");
- l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
- l.setTargetName("_blank");
- l
- .setDescription("Link with target name and BORDER_MINIMAL, opens in new window with less decor");
- links.addComponent(l);
-
- l = new Link("Vaadin home (new 200x200 window, no decor, icon)",
- new ExternalResource("http://www.vaadin.com"), "_blank", 200,
- 200, Link.TARGET_BORDER_NONE);
- l.setDebugId("Link4");
- l.setTargetName("_blank");
- l
- .setDescription("Link with target name and BORDER_NONE, opens in new window with no decor");
- l.setIcon(new ThemeResource("icons/ok.png"));
- links.addComponent(l);
-
- }
-
- public void buttonClick(ClickEvent event) {
- final Button b = event.getButton();
- getWindow().showNotification(
- "Clicked"
- + (b instanceof CheckBox ? ", value: "
- + event.getButton().getValue() : ""));
-
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/ClientCachingExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/ClientCachingExample.java deleted file mode 100644 index 2012329df1..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/ClientCachingExample.java +++ /dev/null @@ -1,73 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * This example is a (simple) demonstration of client-side caching. The content
- * in one tab is intentionally made very slow to produce server-side. When the
- * user changes to this tab for the first time, there will be a 3 second wait
- * before the content shows up, but the second time it shows up immediately
- * since the content has not changed and is cached client-side.
- *
- * @author IT Mill Ltd.
- */
-@SuppressWarnings("serial")
-public class ClientCachingExample extends CustomComponent {
-
- private static final String msg = "This example is a (simple) demonstration of client-side caching."
- + " The content in one tab is intentionally made very slow to"
- + " 'produce' server-side. When you changes to this tab for the"
- + " first time, there will be a 3 second wait before the content"
- + " shows up, but the second time it shows up immediately since the"
- + " content has not changed and is cached client-side.";
-
- public ClientCachingExample() {
-
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- main.addComponent(new Label(msg));
-
- final TabSheet ts = new TabSheet();
- main.addComponent(ts);
-
- Layout layout = new VerticalLayout();
- layout.setMargin(true);
- Label l = new Label("This is a normal label, quick to render.");
- l.setCaption("A normal label");
- layout.addComponent(l);
-
- ts.addTab(layout, "Normal", null);
-
- layout = new VerticalLayout();
- layout.setMargin(true);
- l = new Label("Slow label - until cached client side.") {
-
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
- try {
- Thread.sleep(3000);
- } catch (final Exception e) {
- // IGNORED
- }
- super.paintContent(target);
- }
-
- };
- l.setCaption("A slow label");
- layout.addComponent(l);
- ts.addTab(layout, "Slow", null);
-
- }
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/ComboBoxExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/ComboBoxExample.java deleted file mode 100644 index 753c746fdb..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/ComboBoxExample.java +++ /dev/null @@ -1,74 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.featurebrowser; - -import java.util.Random; - -import com.vaadin.ui.ComboBox; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.AbstractSelect.Filtering; - -/** - * - */ -@SuppressWarnings("serial") -public class ComboBoxExample extends CustomComponent { - - private static final String[] firstnames = new String[] { "John", "Mary", - "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Robert", "Paula", - "Lenny", "Kenny", "Nathan", "Nicole", "Laura", "Jos", "Josie", - "Linus" }; - - private static final String[] lastnames = new String[] { "Torvalds", - "Smith", "Adams", "Black", "Wilson", "Richards", "Thompson", - "McGoff", "Halas", "Jones", "Beck", "Sheridan", "Picard", "Hill", - "Fielding", "Einstein" }; - - public ComboBoxExample() { - final OrderedLayout main = new OrderedLayout(); - main.setMargin(true); - setCompositionRoot(main); - - // starts-with filter - final ComboBox s1 = new ComboBox("Select with starts-with filter"); - s1.setDebugId("ComboBoxStartFilter"); - s1.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); - s1.setColumns(20); - Random r = new Random(5); - for (int i = 0; i < 105; i++) { - s1 - .addItem(firstnames[(int) (r.nextDouble() * (firstnames.length - 1))] - + " " - + lastnames[(int) (r.nextDouble() * (lastnames.length - 1))]); - } - s1.setImmediate(true); - main.addComponent(s1); - - // contains filter - final ComboBox s2 = new ComboBox("Select with contains filter"); - s2.setDebugId("ComboBoxContainsFilter"); - s2.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); - s2.setColumns(20); - for (int i = 0; i < 500; i++) { - s2 - .addItem(firstnames[(int) (r.nextDouble() * (firstnames.length - 1))] - + " " - + lastnames[(int) (r.nextDouble() * (lastnames.length - 1))]); - } - s2.setImmediate(true); - main.addComponent(s2); - - // initially empty - final ComboBox s3 = new ComboBox("Initially empty; enter your own"); - s3.setDebugId("EmptyComboBox"); - s3.setColumns(20); - s3.setImmediate(true); - s3.setNewItemsAllowed(true); - main.addComponent(s3); - - } - -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/EmbeddedBrowserExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/EmbeddedBrowserExample.java deleted file mode 100644 index 2ecf60ecdb..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/EmbeddedBrowserExample.java +++ /dev/null @@ -1,89 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.featurebrowser; - -import java.net.MalformedURLException; -import java.net.URL; - -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.Select; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window.Notification; - -/** - * Demonstrates the use of Embedded and "suggesting" Select by creating a simple - * web-browser. Note: does not check for recursion. - * - * @author IT Mill Ltd. - * @see com.vaadin.ui.Window - */ -@SuppressWarnings("serial") -public class EmbeddedBrowserExample extends VerticalLayout implements - Select.ValueChangeListener { - - // Default URL to open. - private static final String DEFAULT_URL = "http://www.vaadin.com/"; - - // The embedded page - Embedded emb = new Embedded(); - - public EmbeddedBrowserExample() { - this(new String[] { DEFAULT_URL, "http://www.vaadin.com/learn", - "http://www.vaadin.com/api", "http://www.vaadin.com/book" }); - } - - public EmbeddedBrowserExample(String[] urls) { - setSizeFull(); - - // create the address combobox - final Select select = new Select(); - // allow input - select.setNewItemsAllowed(true); - // no empty selection - select.setNullSelectionAllowed(false); - // no 'go' -button clicking necessary - select.setImmediate(true); - // add some pre-configured URLs - for (int i = 0; i < urls.length; i++) { - select.addItem(urls[i]); - } - // add to layout - addComponent(select); - // add listener and select initial URL - select.addListener(this); - select.setValue(urls[0]); - - select.setWidth("100%"); - - // configure the embedded and add to layout - emb.setType(Embedded.TYPE_BROWSER); - emb.setSizeFull(); - addComponent(emb); - // make the embedded as large as possible - setExpandRatio(emb, 1); - - } - - public void valueChange(ValueChangeEvent event) { - final String url = (String) event.getProperty().getValue(); - if (url != null) { - try { - // the selected url has changed, let's go there - @SuppressWarnings("unused") - URL u = new URL(url); - emb.setSource(new ExternalResource(url)); - - } catch (MalformedURLException e) { - getWindow().showNotification("Invalid address", - e.getMessage() + " (example: http://www.vaadin.com)", - Notification.TYPE_WARNING_MESSAGE); - } - - } - - } -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/FeatureBrowser.java b/tests/src/com/vaadin/automatedtests/featurebrowser/FeatureBrowser.java deleted file mode 100644 index b6f2e0e163..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/FeatureBrowser.java +++ /dev/null @@ -1,387 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.featurebrowser; - -import java.util.HashMap; -import java.util.Iterator; - -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.data.util.IndexedContainer; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.ThemeResource; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Component; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Select; -import com.vaadin.ui.SplitPanel; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.Tree; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; - -/** - * - * @author IT Mill Ltd. - * @see com.vaadin.ui.Window - */ -@SuppressWarnings("serial") -public class FeatureBrowser extends com.vaadin.Application implements - Select.ValueChangeListener { - - // Property IDs - - private static final Object PROPERTY_ID_CATEGORY = "Category"; - private static final Object PROPERTY_ID_NAME = "Name"; - private static final Object PROPERTY_ID_DESC = "Description"; - private static final Object PROPERTY_ID_CLASS = "Class"; - private static final Object PROPERTY_ID_VIEWED = "Viewed"; - - // Global components - private Tree tree; - private Table table; - private TabSheet ts; - - // Example "cache" - private final HashMap<Class<?>, Component> exampleInstances = new HashMap<Class<?>, Component>(); - private String section; - - // List of examples - private static final Object[][] demos = new Object[][] { - // Category, Name, Desc, Class, Viewed - // Getting started: Labels - { "Getting started", "Labels", "Some variations of Labels", - LabelExample.class }, - // Getting started: Buttons - { "Getting started", "Buttons and links", - "Various Buttons and Links", ButtonExample.class }, - // Getting started: Fields - { "Getting started", "Basic value input", - "TextFields, DateFields, and such", ValueInputExample.class }, - // - { "Getting started", "RichText", "Rich text editing", - RichTextExample.class }, - // Getting started: Selects - { "Getting started", "Choices, choices", - "Some variations of simple selects", SelectExample.class }, - // Layouts - { "Layouts", "Basic layouts", "Laying out components", - LayoutExample.class }, - // Layouts - { "Layouts", "Accordion", "Play the Accordion!", - AccordionExample.class }, - // Wrangling data: ComboBox - { "Wrangling data", "ComboBox", "ComboBox - the swiss army select", - ComboBoxExample.class }, - // Wrangling data: Table - { - "Wrangling data", - "Table (\"grid\")", - "Table with bells, whistles, editmode and actions (contextmenu)", - TableExample.class }, - // Wrangling data: Form - { "Wrangling data", "Form", "Every application needs forms", - FormExample.class }, - // Wrangling data: Tree - { "Wrangling data", "Tree", "A hierarchy of things", - TreeExample.class }, - // Misc: Notifications - { "Misc", "Notifications", "Notifications can improve usability", - NotificationExample.class }, - // Misc: Caching - { "Misc", "Client caching", "Demonstrating of client-side caching", - ClientCachingExample.class }, - // Misc: Embedded - { "Misc", "Embedding", - "Embedding resources - another site in this case", - EmbeddedBrowserExample.class }, - // Windowing - { "Misc", "Windowing", "About windowing", WindowingExample.class }, - // JavaScript API - { "Misc", "JavaScript API", "JavaScript to Vaadin communication", - JavaScriptAPIExample.class }, - // END - }; - - @Override - public void init() { - - // Need to set a theme for ThemeResources to work - setTheme("example"); - - // Create new window for the application and give the window a visible. - final Window main = new Window("Vaadin 6"); - main.setDebugId("mainWindow"); - // set as main window - setMainWindow(main); - - final SplitPanel split = new SplitPanel( - SplitPanel.ORIENTATION_HORIZONTAL); - split.setSplitPosition(200, SplitPanel.UNITS_PIXELS); - main.setContent(split); - - final HashMap<String, Object> sectionIds = new HashMap<String, Object>(); - final HierarchicalContainer container = createContainer(); - final Object rootId = container.addItem(); - Item item = container.getItem(rootId); - Property p = item.getItemProperty(PROPERTY_ID_NAME); - p.setValue("All examples"); - for (int i = 0; i < demos.length; i++) { - final Object[] demo = demos[i]; - final String section = (String) demo[0]; - Object sectionId; - if (sectionIds.containsKey(section)) { - sectionId = sectionIds.get(section); - } else { - sectionId = container.addItem(); - sectionIds.put(section, sectionId); - container.setParent(sectionId, rootId); - item = container.getItem(sectionId); - p = item.getItemProperty(PROPERTY_ID_NAME); - p.setValue(section); - } - final Object id = container.addItem(); - container.setParent(id, sectionId); - initItem(container.getItem(id), demo); - - } - - tree = new Tree(); - tree.setDebugId("FeatureBrowser: Main Tree"); - tree.setSelectable(true); - tree.setMultiSelect(false); - tree.setNullSelectionAllowed(false); - tree.setContainerDataSource(container); - tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); - tree.setItemCaptionPropertyId(PROPERTY_ID_NAME); - tree.addListener(this); - tree.setImmediate(true); - tree.expandItemsRecursively(rootId); - for (Iterator<?> i = container.getItemIds().iterator(); i.hasNext();) { - Object id = i.next(); - if (container.getChildren(id) == null) { - tree.setChildrenAllowed(id, false); - } - } - - split.addComponent(tree); - - final SplitPanel split2 = new SplitPanel(); - split2.setSplitPosition(200, SplitPanel.UNITS_PIXELS); - split.addComponent(split2); - - table = new Table(); - table.setDebugId("FeatureBrowser: Main Table"); - table.setSizeFull(); - table.setColumnReorderingAllowed(true); - table.setColumnCollapsingAllowed(true); - table.setSelectable(true); - table.setMultiSelect(false); - table.setNullSelectionAllowed(false); - try { - table.setContainerDataSource((IndexedContainer) container.clone()); - } catch (final Exception e) { - e.printStackTrace(System.err); - } - // Hide some columns - table.setVisibleColumns(new Object[] { PROPERTY_ID_CATEGORY, - PROPERTY_ID_NAME, PROPERTY_ID_DESC, PROPERTY_ID_VIEWED }); - table.addListener(this); - table.setImmediate(true); - split2.addComponent(table); - - final VerticalLayout exp = new VerticalLayout(); - exp.setSizeFull(); - exp.setMargin(true); - split2.addComponent(exp); - - final HorizontalLayout wbLayout = new HorizontalLayout(); - Button b = new Button("Open in sub-window", new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - Component component = (Component) ts.getComponentIterator() - .next(); - String caption = ts.getTab(component).getCaption(); - try { - component = component.getClass().newInstance(); - } catch (Exception e) { - // Could not create - return; - } - Window w = new Window(caption); - w.setWidth("640px"); - if (Layout.class.isAssignableFrom(component.getClass())) { - w.setContent((Layout) component); - } else { - // w.getLayout().getSize().setSizeFull(); - w.addComponent(component); - } - getMainWindow().addWindow(w); - } - }); - b.setStyleName(Button.STYLE_LINK); - wbLayout.addComponent(b); - b = new Button("Open in native window", new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - Component component = (Component) ts.getComponentIterator() - .next(); - final String caption = ts.getTab(component).getCaption(); - Window w = getWindow(caption); - if (w == null) { - try { - component = component.getClass().newInstance(); - } catch (final Exception e) { - // Could not create - return; - } - w = new Window(caption); - w.setName(caption); - if (Layout.class.isAssignableFrom(component.getClass())) { - w.setContent((Layout) component); - } else { - // w.getLayout().getSize().setSizeFull(); - w.addComponent(component); - } - addWindow(w); - } - getMainWindow().open(new ExternalResource(w.getURL()), caption); - } - }); - b.setStyleName(Button.STYLE_LINK); - wbLayout.addComponent(b); - - exp.addComponent(wbLayout); - exp.setComponentAlignment(wbLayout, Alignment.TOP_RIGHT); - - ts = new TabSheet(); - ts.setSizeFull(); - ts.addTab(new Label(""), "Choose example", null); - exp.addComponent(ts); - exp.setExpandRatio(ts, 1); - - final Label status = new Label( - "<a href=\"http://www.vaadin.com/learn\">30 Seconds to Vaadin</a>" - + " | <a href=\"http://www.vaadin.com/book\">Book of Vaadin</a>"); - status.setContentMode(Label.CONTENT_XHTML); - exp.addComponent(status); - exp.setComponentAlignment(status, Alignment.MIDDLE_RIGHT); - - // select initial section ("All") - tree.setValue(rootId); - - getMainWindow() - .showNotification( - "Welcome", - "Choose an example to begin.<br/><br/>And remember to experiment!", - Window.Notification.TYPE_TRAY_NOTIFICATION); - } - - private void initItem(Item item, Object[] data) { - int p = 0; - Property prop = item.getItemProperty(PROPERTY_ID_CATEGORY); - prop.setValue(data[p++]); - prop = item.getItemProperty(PROPERTY_ID_NAME); - prop.setValue(data[p++]); - prop = item.getItemProperty(PROPERTY_ID_DESC); - prop.setValue(data[p++]); - prop = item.getItemProperty(PROPERTY_ID_CLASS); - prop.setValue(data[p++]); - } - - private HierarchicalContainer createContainer() { - final HierarchicalContainer c = new HierarchicalContainer(); - c.addContainerProperty(PROPERTY_ID_CATEGORY, String.class, null); - c.addContainerProperty(PROPERTY_ID_NAME, String.class, ""); - c.addContainerProperty(PROPERTY_ID_DESC, String.class, ""); - c.addContainerProperty(PROPERTY_ID_CLASS, Class.class, null); - c.addContainerProperty(PROPERTY_ID_VIEWED, Embedded.class, null); - return c; - } - - public void valueChange(ValueChangeEvent event) { - if (event.getProperty() == tree) { - final Object id = tree.getValue(); - if (id == null) { - return; - } - final Item item = tree.getItem(id); - // - String newSection; - if (tree.isRoot(id)) { - newSection = ""; // show all sections - } else if (tree.hasChildren(id)) { - newSection = (String) item.getItemProperty(PROPERTY_ID_NAME) - .getValue(); - } else { - newSection = (String) item - .getItemProperty(PROPERTY_ID_CATEGORY).getValue(); - } - - table.setValue(null); - final IndexedContainer c = (IndexedContainer) table - .getContainerDataSource(); - - if (newSection != null && !newSection.equals(section)) { - c.removeAllContainerFilters(); - c.addContainerFilter(PROPERTY_ID_CATEGORY, newSection, false, - true); - } - section = newSection; - if (!tree.hasChildren(id)) { - // Example, not section - // update table selection - table.setValue(id); - } - - } else if (event.getProperty() == table) { - if (table.getValue() != null) { - table.removeListener(this); - tree.setValue(table.getValue()); - table.addListener(this); - final Item item = table.getItem(table.getValue()); - final Class<?> c = (Class<?>) item.getItemProperty( - PROPERTY_ID_CLASS).getValue(); - final Component component = getComponent(c); - if (component != null) { - final String caption = (String) item.getItemProperty( - PROPERTY_ID_NAME).getValue(); - ts.removeAllComponents(); - ts.addTab(component, caption, null); - } - // update "viewed" state - final Property p = item.getItemProperty(PROPERTY_ID_VIEWED); - if (p.getValue() == null) { - p.setValue(new Embedded("", new ThemeResource( - "icons/ok.png"))); - } - table.requestRepaint(); - } - } - - } - - private Component getComponent(Class<?> componentClass) { - if (!exampleInstances.containsKey(componentClass)) { - try { - final Component c = (Component) componentClass.newInstance(); - exampleInstances.put(componentClass, c); - } catch (final Exception e) { - return null; - } - } - return exampleInstances.get(componentClass); - } - -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/FormExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/FormExample.java deleted file mode 100644 index 927f2ba978..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/FormExample.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.vaadin.automatedtests.featurebrowser; - -import java.io.Serializable; - -import com.vaadin.data.Item; -import com.vaadin.data.Validator; -import com.vaadin.data.util.BeanItem; -import com.vaadin.ui.BaseFieldFactory; -import com.vaadin.ui.Button; -import com.vaadin.ui.Component; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Field; -import com.vaadin.ui.Form; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Button.ClickEvent; - -/** - * 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 custom field editors using a - * FieldFactory, customizing the form without FieldFactory, buffering - * (commit/discard) and validation. Please note that the example is quite a bit - * more complex than real use, as it tries to demonstrate more features than - * needed in general case. - */ -@SuppressWarnings("serial") -public class FormExample extends CustomComponent { - - static final String cities[] = { "Amsterdam", "Berlin", "Helsinki", - "Hong Kong", "London", "Luxemburg", "New York", "Oslo", "Paris", - "Rome", "Stockholm", "Tokyo", "Turku" }; - - /** Compose the demo. */ - public FormExample() { - - // Example data model - final Address dataModel = new Address(); - Button peekDataModelState = new Button("Show the data model state", - new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - getWindow().showNotification( - dataModel.getAddressAsText()); - } - }); - - // Example form - final AddressForm form = new AddressForm("Contact Information"); - form.setDataSource(dataModel); - form - .setDescription("Please enter valid name and address. Fields marked with * are required. " - + "If you try to commit with invalid values, a form error message is displayed. " - + "(Address is required but failing to give it a value does not display an error.)"); - - // Layout the example - VerticalLayout root = new VerticalLayout(); - root.setMargin(true); - root.setSpacing(true); - root.addComponent(form); - root.addComponent(peekDataModelState); - setCompositionRoot(root); - } - - public static class AddressForm extends Form { - - public AddressForm(String caption) { - - setCaption(caption); - - // Use custom field factory to modify the defaults on how the - // components are created - setFieldFactory(new MyFieldFactory()); - - // Add Commit and Discard controls to the form. - Button commit = new Button("Save", this, "commit"); - Button discard = new Button("Reset", this, "discard"); - HorizontalLayout footer = new HorizontalLayout(); - footer.addComponent(commit); - footer.addComponent(discard); - setFooter(footer); - } - - public void setDataSource(Address dataModel) { - - // Set the form to edit given datamodel by converting pojo used as - // the datamodel to Item - setItemDataSource(new BeanItem(dataModel)); - - // Ensure that the fields are shown in correct order as the - // datamodel does not force any specific order. - setVisibleItemProperties(new String[] { "name", "streetAddress", - "postalCode", "city" }); - - // For examples sake, customize some of the form fields directly - // here. The alternative way is to use custom field factory as shown - // above. - getField("name").setRequired(true); - getField("name").setRequiredError("Name is missing"); - getField("streetAddress").setRequired(true); // No error message - getField("postalCode").setRequired(true); // No error message - replaceWithSelect("city", cities, cities).setNewItemsAllowed(true); - - // Set the form to act immediately on user input. This is - // automatically transports data between the client and the server - // to do server-side validation. - setImmediate(true); - - // Enable buffering so that commit() must be called for the form - // before input is written to the data. (Form input is not written - // immediately through to the underlying object.) - setWriteThrough(false); - } - } - - /** - * This is example on how to customize field creation. Any kind of field - * components could be created on the fly. - */ - static class MyFieldFactory extends BaseFieldFactory implements - Serializable { - - @Override - public Field createField(Item item, Object propertyId, - Component uiContext) { - - Field field = super.createField(item, propertyId, uiContext); - - if ("postalCode".equals(propertyId)) { - ((TextField) field).setColumns(5); - field.addValidator(new PostalCodeValidator()); - } - - return field; - } - - } - - /** - * This is an example of how to create a custom validator for automatic - * input validation. - */ - static class PostalCodeValidator implements 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 five digit number."); - } - } - } - - /** - * Contact information data model created as POJO. Note that in many cases - * it would be a good idea to implement Item -interface for the datamodel to - * make it directly bindable to form (without BeanItem wrapper) - */ - public static class Address implements Serializable { - - String name = ""; - String streetAddress = ""; - String postalCode = ""; - String city; - - public String getAddressAsText() { - return name + "\n" + streetAddress + "\n" + postalCode + " " - + (city == null ? "" : city); - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setStreetAddress(String address) { - streetAddress = address; - } - - public String getStreetAddress() { - return streetAddress; - } - - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; - } - - public String getPostalCode() { - return postalCode; - } - - public void setCity(String city) { - this.city = city; - } - - public String getCity() { - return city; - } - } - -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java deleted file mode 100644 index 0988715286..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java +++ /dev/null @@ -1,561 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.featurebrowser; - -import java.util.Collection; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Vector; - -import com.vaadin.data.Container; -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Container.Indexed; -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.Label; -import com.vaadin.ui.Table; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; - -/** - * This example demonstrates the use of generated columns in a table. Generated - * columns can be used for formatting values or calculating them from other - * columns (or properties of the items). - * - * For the data model, we use POJOs bound to a custom Container with BeanItem - * items. - * - * @author magi - */ -@SuppressWarnings("serial") -public class GeneratedColumnExample extends CustomComponent { - - /** - * The business model: fill-up at a gas station. - */ - public class FillUp { - Date date; - double quantity; - double total; - - public FillUp() { - } - - public FillUp(int day, int month, int year, double quantity, - double total) { - date = new GregorianCalendar(year, month - 1, day).getTime(); - this.quantity = quantity; - this.total = total; - } - - /** Calculates price per unit of quantity (€/l). */ - public double price() { - if (quantity != 0.0) { - return total / quantity; - } else { - return 0.0; - } - } - - /** Calculates average daily consumption between two fill-ups. */ - public double dailyConsumption(FillUp other) { - double difference_ms = date.getTime() - other.date.getTime(); - double days = difference_ms / 1000 / 3600 / 24; - if (days < 0.5) { - days = 1.0; // Avoid division by zero if two fill-ups on the - // same day. - } - return quantity / days; - } - - /** Calculates average daily consumption between two fill-ups. */ - public double dailyCost(FillUp other) { - return price() * dailyConsumption(other); - } - - // Getters and setters - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - public double getQuantity() { - return quantity; - } - - public void setQuantity(double quantity) { - this.quantity = quantity; - } - - public double getTotal() { - return total; - } - - public void setTotal(double total) { - this.total = total; - } - }; - - /** - * This is a custom container that allows adding BeanItems inside it. The - * BeanItem objects must be bound to an 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 MySimpleIndexedContainer implements Container, Indexed { - - Vector<BeanItem> items; - Object itemtemplate; - - public MySimpleIndexedContainer(Object itemtemplate) { - this.itemtemplate = itemtemplate; - items = new Vector<BeanItem>(); // 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.add(item); - } - - public boolean containsId(Object itemId) { - if (itemId instanceof Integer) { - int pos = ((Integer) itemId).intValue(); - if (pos >= 0 && pos < items.size()) { - return items.get(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 < items.size()) { - Item item = items.get(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() { - Item item = new BeanItem(itemtemplate); - - // 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 < items.size()) { - return items.get(pos); - } - } - return null; - } - - public Collection getItemIds() { - Vector ids = new Vector(items.size()); - for (int i = 0; i < items.size(); 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 items.size(); - } - - 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() == (items.size() - 1); - } - - public Object lastItemId() { - return new Integer(items.size() - 1); - } - - public Object nextItemId(Object itemId) { - int pos = indexOfId(itemId); - if (pos >= items.size() - 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); - } - } - - /** Formats the dates in a column containing Date objects. */ - class DateColumnGenerator implements Table.ColumnGenerator { - /** - * Generates the cell containing the Date value. The column is - * irrelevant in this use case. - */ - public Component generateCell(Table source, Object itemId, - Object columnId) { - Property prop = source.getItem(itemId).getItemProperty(columnId); - if (prop.getType().equals(Date.class)) { - Label label = new Label(String.format("%tF", - new Object[] { (Date) prop.getValue() })); - label.addStyleName("column-type-date"); - return label; - } - - return null; - } - } - - /** Formats the value in a column containing Double objects. */ - class ValueColumnGenerator implements Table.ColumnGenerator { - String format; /* Format string for the Double values. */ - - /** Creates double value column formatter with the given format string. */ - public ValueColumnGenerator(String format) { - this.format = format; - } - - /** - * Generates the cell containing the Double value. The column is - * irrelevant in this use case. - */ - public Component generateCell(Table source, Object itemId, - Object columnId) { - Property prop = source.getItem(itemId).getItemProperty(columnId); - if (prop.getType().equals(Double.class)) { - Label label = new Label(String.format(format, - new Object[] { (Double) prop.getValue() })); - - // Set styles for the column: one indicating that it's a value - // and a more - // specific one with the column name in it. This assumes that - // the column - // name is proper for CSS. - label.addStyleName("column-type-value"); - label.addStyleName("column-" + (String) columnId); - return label; - } - return null; - } - } - - /** Table column generator for calculating price column. */ - class PriceColumnGenerator implements Table.ColumnGenerator { - public Component generateCell(Table source, Object itemId, - Object columnId) { - // Retrieve the item. - BeanItem item = (BeanItem) source.getItem(itemId); - - // Retrieves the underlying POJO from the item. - FillUp fillup = (FillUp) item.getBean(); - - // Do the business logic - double price = fillup.price(); - - // Create the generated component for displaying the calcucated - // value. - Label label = new Label(String.format("%1.2f €", - new Object[] { new Double(price) })); - - // We set the style here. You can't use a CellStyleGenerator for - // generated columns. - label.addStyleName("column-price"); - return label; - } - } - - /** Table column generator for calculating consumption column. */ - class ConsumptionColumnGenerator implements Table.ColumnGenerator { - - /** - * Generates a cell containing value calculated from the item. - */ - public Component generateCell(Table source, Object itemId, - Object columnId) { - Indexed indexedSource = (Indexed) source.getContainerDataSource(); - - // Can not calculate consumption for the first item. - if (indexedSource.isFirstId(itemId)) { - Label label = new Label("N/A"); - label.addStyleName("column-consumption"); - return label; - } - - // Index of the previous item. - Object prevItemId = indexedSource.prevItemId(itemId); - - // Retrieve the POJOs. - FillUp fillup = (FillUp) ((BeanItem) indexedSource.getItem(itemId)) - .getBean(); - FillUp prev = (FillUp) ((BeanItem) source.getItem(prevItemId)) - .getBean(); - - // Do the business logic - return generateCell(fillup, prev); - } - - public Component generateCell(FillUp fillup, FillUp prev) { - double consumption = fillup.dailyConsumption(prev); - - // Generate the component for displaying the calculated value. - Label label = new Label(String.format("%3.2f l", - new Object[] { new Double(consumption) })); - - // We set the style here. You can't use a CellStyleGenerator for - // generated columns. - label.addStyleName("column-consumption"); - return label; - } - } - - /** Table column generator for calculating daily cost column. */ - class DailyCostColumnGenerator extends ConsumptionColumnGenerator { - - @Override - public Component generateCell(FillUp fillup, FillUp prev) { - double dailycost = fillup.dailyCost(prev); - - // Generate the component for displaying the calculated value. - Label label = new Label(String.format("%3.2f €", - new Object[] { new Double(dailycost) })); - - // We set the style here. You can't use a CellStyleGenerator for - // generated columns. - label.addStyleName("column-dailycost"); - return label; - } - } - - /** - * Custom field factory that sets the fields as immediate. - */ - public class ImmediateFieldFactory 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; - } - } - - public GeneratedColumnExample() { - final Table table = new Table(); - - // Define table columns. These include also the column for the generated - // column, because we want to set the column label to something - // different than the property ID. - table - .addContainerProperty("date", Date.class, null, "Date", null, - null); - table.addContainerProperty("quantity", Double.class, null, - "Quantity (l)", null, null); - table.addContainerProperty("price", Double.class, null, - "Price (€/l)", null, null); - table.addContainerProperty("total", Double.class, null, "Total (€)", - null, null); - table.addContainerProperty("consumption", Double.class, null, - "Consumption (l/day)", null, null); - table.addContainerProperty("dailycost", Double.class, null, - "Daily Cost (€/day)", null, null); - - // Define the generated columns and their generators. - table.addGeneratedColumn("date", new DateColumnGenerator()); - table - .addGeneratedColumn("quantity", new ValueColumnGenerator( - "%.2f l")); - table.addGeneratedColumn("price", new PriceColumnGenerator()); - table.addGeneratedColumn("total", new ValueColumnGenerator("%.2f €")); - table.addGeneratedColumn("consumption", - new ConsumptionColumnGenerator()); - table.addGeneratedColumn("dailycost", new DailyCostColumnGenerator()); - - // Create a data source and bind it to the table. - MySimpleIndexedContainer data = new MySimpleIndexedContainer( - new FillUp()); - table.setContainerDataSource(data); - - // Generated columns are automatically placed after property columns, so - // we have to set the order of the columns explicitly. - table.setVisibleColumns(new Object[] { "date", "quantity", "price", - "total", "consumption", "dailycost" }); - - // Add some data. - data.addItem(new BeanItem(new FillUp(19, 2, 2005, 44.96, 51.21))); - data.addItem(new BeanItem(new FillUp(30, 3, 2005, 44.91, 53.67))); - data.addItem(new BeanItem(new FillUp(20, 4, 2005, 42.96, 49.06))); - data.addItem(new BeanItem(new FillUp(23, 5, 2005, 47.37, 55.28))); - data.addItem(new BeanItem(new FillUp(6, 6, 2005, 35.34, 41.52))); - data.addItem(new BeanItem(new FillUp(30, 6, 2005, 16.07, 20.00))); - data.addItem(new BeanItem(new FillUp(2, 7, 2005, 36.40, 36.19))); - data.addItem(new BeanItem(new FillUp(6, 7, 2005, 39.17, 50.90))); - data.addItem(new BeanItem(new FillUp(27, 7, 2005, 43.43, 53.03))); - data.addItem(new BeanItem(new FillUp(17, 8, 2005, 20, 29.18))); - data.addItem(new BeanItem(new FillUp(30, 8, 2005, 46.06, 59.09))); - data.addItem(new BeanItem(new FillUp(22, 9, 2005, 46.11, 60.36))); - data.addItem(new BeanItem(new FillUp(14, 10, 2005, 41.51, 50.19))); - data.addItem(new BeanItem(new FillUp(12, 11, 2005, 35.24, 40.00))); - data.addItem(new BeanItem(new FillUp(28, 11, 2005, 45.26, 53.27))); - - // Have a check box that allows the user to make the quantity - // and total columns editable. - final CheckBox editable = new CheckBox( - "Edit the input values - calculated columns are regenerated"); - editable.setImmediate(true); - editable.addListener(new ClickListener() { - public void buttonClick(ClickEvent event) { - table.setEditable(editable.booleanValue()); - - // The columns may not be generated when we want to have them - // editable. - if (editable.booleanValue()) { - table.removeGeneratedColumn("quantity"); - table.removeGeneratedColumn("total"); - } else { - // In non-editable mode we want to show the formatted - // values. - table.addGeneratedColumn("quantity", - new ValueColumnGenerator("%.2f l")); - table.addGeneratedColumn("total", new ValueColumnGenerator( - "%.2f €")); - } - // The visible columns are affected by removal and addition of - // generated columns so we have to redefine them. - table.setVisibleColumns(new Object[] { "date", "quantity", - "price", "total", "consumption", "dailycost" }); - } - }); - - // Use a custom field factory to set the edit fields as immediate. - // This is used when the table is in editable mode. - table.setFieldFactory(new ImmediateFieldFactory()); - - // Setting the table itself as immediate has no relevance in this - // example, - // because it is relevant only if the table is selectable and we want to - // get the selection changes immediately. - table.setImmediate(true); - - table.setHeight("300px"); - - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - layout - .addComponent(new Label( - "Table with column generators that format and calculate cell values.")); - layout.addComponent(table); - layout.addComponent(editable); - layout.addComponent(new Label( - "Columns displayed in blue are calculated from Quantity and Total. " - + "Others are simply formatted.")); - layout.setExpandRatio(table, 1); - layout.setSizeUndefined(); - setCompositionRoot(layout); - // setSizeFull(); - } -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/JavaScriptAPIExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/JavaScriptAPIExample.java deleted file mode 100644 index 21e49ce320..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/JavaScriptAPIExample.java +++ /dev/null @@ -1,97 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import java.util.Date;
-
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * An example using a RichTextArea to edit a Label in XHTML-mode.
- *
- */
-public class JavaScriptAPIExample extends CustomComponent {
-
- public static final String txt = "<p>For advanced client side programmers Vaadin offers a simple method which can be used to force sync client with server. This may be needed for example if another part of a mashup changes things on server.</p> (more examples will be added here as the APIs are made public)<br/><br/><A href=\"javascript:vaadin.forceSync();\">javascript:vaadin.forceSync();</A>";
-
- private final VerticalLayout main;
- private final Label l;
- private final TextField editor = new TextField();
-
- public JavaScriptAPIExample() {
- // main layout
- main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
- editor.setRows(7);
- editor.setColumns(50);
- // Add the label
- l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- main.addComponent(l);
- // Edit button with inline click-listener
- Button b = new Button("Edit", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- // swap Label <-> RichTextArea
- if (main.getComponentIterator().next() == l) {
- editor.setValue(l.getValue());
- main.replaceComponent(l, editor);
- event.getButton().setCaption("Save");
- } else {
- l.setValue(editor.getValue());
- main.replaceComponent(editor, l);
- event.getButton().setCaption("Edit");
- }
- }
- });
- main.addComponent(b);
- main.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
-
- //
- Label l = new Label(
- "This label will update it's server-side value AFTER it's rendered to the client-side. "
- + "The client will be synchronized on reload, when you click a button, "
- + "or when vaadin.forceSync() is called.") {
-
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
-
- super.paintContent(target);
- Delay d = new Delay(this);
- d.start();
- }
-
- };
- main.addComponent(l);
-
- }
-
- private class Delay extends Thread {
- Label label;
-
- public Delay(Label l) {
- label = l;
- }
-
- @Override
- public void run() {
- try {
- Thread.sleep(500);
- label.setValue(new Date().toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- }
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/LabelExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/LabelExample.java deleted file mode 100644 index 37b946824d..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/LabelExample.java +++ /dev/null @@ -1,84 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-
-/**
- * Shows a few variations of Labels, including the effects of XHTML- and
- * pre-formatted mode.
- *
- * @author IT Mill Ltd.
- */
-public class LabelExample extends CustomComponent {
-
- private static final String xhtml = "This text has <b>HTML</b> formatting.<br/>"
- + "A plain <i>Label</i> will show the markup, while a <u>XHTML-mode</u>"
- + " <i>Label</i> will show the formatted text.";
-
- private static final String pre = "This text has linebreaks.\n\n"
- + "They will show up in a preformatted Label,\n"
- + "but not in a \"plain\" Label.\n\n"
- + " This is an indented row. \n Same indentation here.";
-
- public LabelExample() {
- final GridLayout g = new GridLayout(2, 4);
- g.setMargin(true);
- setCompositionRoot(g);
- g.setWidth("100%");
-
- // plain w/o caption
- Panel p = getExpamplePanel("Plain");
- Label l = new Label("A plain label without caption.");
- l.setDebugId("label1");
- p.addComponent(l);
- g.addComponent(p);
- // plain w/ caption
- p = getExpamplePanel("Plain w/ caption + tooltip");
- l = new Label("A plain label with caption.");
- l.setCaption("Label caption");
- l.setDebugId("label2");
- l.setDescription("This is a description (tooltip) for the label.");
- p.addComponent(l);
- g.addComponent(p);
- // plain w/ xhtml
- p = getExpamplePanel("Plain w/ XHTML content");
- l = new Label(xhtml);
- l.setDebugId("label3");
- p.addComponent(l);
- g.addComponent(p);
- // xhtml w/ xhtml
- p = getExpamplePanel("XHTML-mode w/ XHTML content");
- l = new Label(xhtml);
- l.setDebugId("label4");
- l.setContentMode(Label.CONTENT_XHTML);
- p.addComponent(l);
- g.addComponent(p);
- // plain w/ preformatted
- p = getExpamplePanel("Plain w/ preformatted content");
- l = new Label(pre);
- l.setDebugId("label5");
- p.addComponent(l);
- g.addComponent(p);
- // preformatted w/ preformatted
- p = getExpamplePanel("Preformatted-mode w/ preformatted content");
- l = new Label(pre);
- l.setDebugId("label6");
- l.setContentMode(Label.CONTENT_PREFORMATTED);
- p.addComponent(l);
- g.addComponent(p);
-
- }
-
- private Panel getExpamplePanel(String caption) {
- Panel p = new Panel(caption);
- p.setDebugId(p.getCaption());
- p.addStyleName(Panel.STYLE_LIGHT);
- return p;
- }
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/LayoutExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/LayoutExample.java deleted file mode 100644 index d5a0773fe2..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/LayoutExample.java +++ /dev/null @@ -1,93 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * A few examples of layout possibilities.
- *
- * @author IT Mill Ltd.
- */
-public class LayoutExample extends CustomComponent {
-
- public LayoutExample() {
-
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final GridLayout g = new GridLayout(2, 5);
- g.setWidth("100%");
- main.addComponent(g);
-
- // panel
- Panel p = new Panel("This is a normal panel");
- p.setDebugId("NormalPanel");
- Label l = new Label("A normal panel.");
- p.addComponent(l);
- g.addComponent(p);
- // lightpanel
- p = new Panel("This is a light panel");
- p.setDebugId("LightPanel");
- p.setStyleName(Panel.STYLE_LIGHT);
- l = new Label("A light-style panel.");
- p.addComponent(l);
- g.addComponent(p);
-
- TabSheet ts = new TabSheet();
- g.addComponent(ts, 0, 1, 1, 1);
-
- VerticalLayout ol = new VerticalLayout();
- ol.setDebugId("VerticalOrderedLayout");
- ol.setMargin(true);
- ol.addComponent(new Label("Component 1"));
- ol.addComponent(new Label("Component 2"));
- ol.addComponent(new Label("Component 3"));
- ts.addTab(ol, "Vertical OrderedLayout", null);
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.setDebugId("HorizontalOrderedLayout");
- hl.setMargin(true);
- hl.addComponent(new Label("Component 1"));
- hl.addComponent(new Label("Component 2"));
- hl.addComponent(new Label("Component 3"));
- ts.addTab(hl, "Horizontal OrderedLayout", null);
-
- final GridLayout gl = new GridLayout(3, 3);
- gl.setDebugId("GridLayout");
- gl.setMargin(true);
- gl.addComponent(new Label("Component 1.1"));
- gl.addComponent(new Label("Component 1.2"));
- gl.addComponent(new Label("Component 1.3"));
- gl.addComponent(new Label("Component 2.2"), 1, 1);
- gl.addComponent(new Label("Component 3.1"), 0, 2);
- gl.addComponent(new Label("Component 3.3"), 2, 2);
- ts.addTab(gl, "GridLayout", null);
-
- /*- TODO spitpanel removed for now - do we need it here?
- ts = new TabSheet();
- ts.setHeight(150);
- g.addComponent(ts, 0, 2, 1, 2);
-
- SplitPanel sp = new SplitPanel();
- sp.addComponent(new Label("Component 1"));
- sp.addComponent(new Label("Component 2"));
- ts.addTab(sp, "Vertical SplitPanel", null);
-
- sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
- sp.addComponent(new Label("Component 1"));
- sp.addComponent(new Label("Component 2"));
- ts.addTab(sp, "Horizontal SplitPanel", null);
- -*/
-
- }
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/NotificationExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/NotificationExample.java deleted file mode 100644 index f3d46a7d00..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/NotificationExample.java +++ /dev/null @@ -1,95 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.featurebrowser; - -import com.vaadin.data.Item; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; - -/** - * Demonstrates the use of Notifications. - * - * @author IT Mill Ltd. - * @see com.vaadin.ui.Window - */ -public class NotificationExample extends CustomComponent { - - // Dropdown select for notification type, using the native dropdown - NativeSelect type; - // Textfield for the notification caption - TextField caption; - // Textfield for the notification content - TextField message; - - /** - * Default constructor; We're subclassing CustomComponent, so we need to - * choose a root component and set it as composition root. - */ - public NotificationExample() { - // Main layout - final VerticalLayout main = new VerticalLayout(); - main.setSizeUndefined(); - main.setSpacing(true); - main.setMargin(true); // use theme-specific margin - setCompositionRoot(main); - - // Create the 'type' dropdown select. - type = new NativeSelect("Notification type"); - main.addComponent(type); - // no empty selection allowed - type.setNullSelectionAllowed(false); - // we want a different caption than the value - type.addContainerProperty("caption", String.class, null); - type.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); - type.setItemCaptionPropertyId("caption"); - // add some content (items) using the Container API - Item i = type.addItem(new Integer( - Window.Notification.TYPE_HUMANIZED_MESSAGE)); - i.getItemProperty("caption").setValue("Humanized message"); - i = type.addItem(new Integer(Window.Notification.TYPE_WARNING_MESSAGE)); - i.getItemProperty("caption").setValue("Warning message"); - i = type.addItem(new Integer(Window.Notification.TYPE_ERROR_MESSAGE)); - i.getItemProperty("caption").setValue("Error message"); - i = type - .addItem(new Integer(Window.Notification.TYPE_TRAY_NOTIFICATION)); - i.getItemProperty("caption").setValue("Tray notification"); - // set the initially selected item - type.setValue(new Integer(Window.Notification.TYPE_HUMANIZED_MESSAGE)); - - // Notification caption - caption = new TextField("Caption"); - main.addComponent(caption); - caption.setColumns(20); - caption.setValue("Brown Fox!"); - - // Notification message - message = new RichTextArea(); - main.addComponent(message); - message.setCaption("Message"); - message.setValue("A quick one jumped over the lazy dog."); - - // Button to show the notification - final Button b = new Button("Show notification", new ClickListener() { - // this is an inline ClickListener - public void buttonClick(ClickEvent event) { - // show the notification - getWindow().showNotification((String) caption.getValue(), - (String) message.getValue(), - ((Integer) type.getValue()).intValue()); - } - }); - main.addComponent(b); - main.setComponentAlignment(b, Alignment.MIDDLE_RIGHT); - } -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/RichTextExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/RichTextExample.java deleted file mode 100644 index 84c16e3a26..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/RichTextExample.java +++ /dev/null @@ -1,63 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.RichTextArea;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * An example using a RichTextArea to edit a Label in XHTML-mode.
- *
- */
-public class RichTextExample extends CustomComponent {
-
- public static final String txt = "<h1>RichText editor example</h1>"
- + "To edit this text, press the <b>Edit</b> button below."
- + "<br/>"
- + "See the <A href=\"http://www.vaadin.com/book\">Book of Vaadin</a> "
- + "for more information.";
-
- private final VerticalLayout main;
- private final Label l;
- private final RichTextArea editor = new RichTextArea();
- private final Button b;
-
- public RichTextExample() {
- // main layout
- main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- editor.setWidth("100%");
-
- // Add the label
- l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- main.addComponent(l);
- // Edit button with inline click-listener
- b = new Button("Edit", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- // swap Label <-> RichTextArea
- if (main.getComponentIterator().next() == l) {
- editor.setValue(l.getValue());
- main.replaceComponent(l, editor);
- b.setCaption("Save");
- } else {
- l.setValue(editor.getValue());
- main.replaceComponent(editor, l);
- b.setCaption("Edit");
- }
- }
- });
- main.addComponent(b);
- main.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/SelectExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/SelectExample.java deleted file mode 100644 index ab6711efce..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/SelectExample.java +++ /dev/null @@ -1,108 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.ListSelect;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.OptionGroup;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TwinColSelect;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- * Shows some basic fields for value input; TextField, DateField, Slider...
- *
- * @author IT Mill Ltd.
- */
-public class SelectExample extends CustomComponent {
-
- // listener that shows a value change notification
- private final Field.ValueChangeListener listener = new Field.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- getWindow().showNotification("" + event.getProperty().getValue());
- }
- };
-
- public SelectExample() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final HorizontalLayout horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- final Panel single = new Panel("Single selects");
- single.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(single);
- final Panel multi = new Panel("Multi selects");
- multi.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(multi);
-
- // radio button group
- AbstractSelect sel = new OptionGroup("OptionGroup");
- sel.setDebugId("RadioButtons");
- initSelect(sel);
- single.addComponent(sel);
- // checkbox group
- sel = new OptionGroup("OptionGroup");
- sel.setDebugId("OptionGroup");
- sel.setMultiSelect(true); // TODO: throws if set after listener - why?
- initSelect(sel);
- multi.addComponent(sel);
- // single-select list
- sel = new ListSelect("ListSelect");
- sel.setDebugId("SingleListSelect");
- ((ListSelect) sel).setColumns(15);
- initSelect(sel);
- single.addComponent(sel);
- // multi-select list
- sel = new ListSelect("ListSelect");
- sel.setDebugId("MultiListSelect");
- ((ListSelect) sel).setColumns(15);
- sel.setMultiSelect(true);
- initSelect(sel);
- multi.addComponent(sel);
- // native-style dropdows
- sel = new NativeSelect("NativeSelect");
- sel.setDebugId("NativeSelect");
- ((NativeSelect) sel).setColumns(15);
- initSelect(sel);
- single.addComponent(sel);
- // combobox
- sel = new ComboBox("ComboBox");
- sel.setDebugId("ComboBox");
- ((ComboBox) sel).setColumns(15);
- initSelect(sel);
- single.addComponent(sel);
- // "twin column" select
- sel = new TwinColSelect("TwinColSelect");
- sel.setDebugId("TwinColSelect");
- ((TwinColSelect) sel).setColumns(15);
- initSelect(sel);
- multi.addComponent(sel);
- }
-
- /*
- * Initialize select with some values, make immediate and add listener.
- */
- private void initSelect(AbstractSelect sel) {
- for (int i = 1; i <= 5; i++) {
- sel.addItem("Item " + i);
- }
- // select one item
- sel.select("Item 1");
-
- // make immediate, add listener
- sel.setImmediate(true);
- sel.addListener(listener);
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/TableExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/TableExample.java deleted file mode 100644 index b1b4fccf6f..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/TableExample.java +++ /dev/null @@ -1,302 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import java.util.Iterator;
-import java.util.Random;
-import java.util.Set;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.event.Action;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Button.ClickEvent;
-
-/**
- * Table example.
- *
- * @author IT Mill Ltd.
- */
-public class TableExample extends CustomComponent implements Action.Handler,
- Button.ClickListener {
-
- // Actions
- private static final Action ACTION_SAVE = new Action("Save");
- private static final Action ACTION_DELETE = new Action("Delete");
- private static final Action ACTION_HIRE = new Action("Hire");
- // Action sets
- private static final Action[] ACTIONS_NOHIRE = new Action[] { ACTION_SAVE,
- ACTION_DELETE };
- private static final Action[] ACTIONS_HIRE = new Action[] { ACTION_HIRE,
- ACTION_SAVE, ACTION_DELETE };
- // Properties
- private static final Object PROPERTY_SPECIES = "Species";
- private static final Object PROPERTY_TYPE = "Type";
- private static final Object PROPERTY_KIND = "Kind";
- private static final Object PROPERTY_HIRED = "Hired";
-
- // "global" components
- Table source;
- Table saved;
- Button saveSelected;
- Button hireSelected;
- Button deleteSelected;
- Button deselect;
-
- public TableExample() {
- VerticalLayout margin = new VerticalLayout();
- margin.setMargin(true);
-
- TabSheet root = new TabSheet();
- setCompositionRoot(margin);
- margin.addComponent(root);
-
- // main layout
- final VerticalLayout main = new VerticalLayout();
- root.addComponent(main);
- main.setCaption("Basic Table");
- main.setMargin(true);
-
- // "source" table with bells & whistlesenabled
- source = new Table("All creatures");
- source.setPageLength(7);
- source.setWidth("550px");
- source.setColumnCollapsingAllowed(true);
- source.setColumnReorderingAllowed(true);
- source.setSelectable(true);
- source.setMultiSelect(true);
- source.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- fillTable(source);
- source.addActionHandler(this);
- main.addComponent(source);
- source.setDebugId("AllCreatures");
-
- // x-selected button row
- final HorizontalLayout horiz = new HorizontalLayout();
-
- horiz.setMargin(false, false, true, false);
- main.addComponent(horiz);
- saveSelected = new Button("Save selected");
- saveSelected.setStyleName(Button.STYLE_LINK);
- saveSelected.addListener(this);
- horiz.addComponent(saveSelected);
- hireSelected = new Button("Hire selected");
- hireSelected.setStyleName(Button.STYLE_LINK);
- hireSelected.addListener(this);
- horiz.addComponent(hireSelected);
- deleteSelected = new Button("Delete selected");
- deleteSelected.setStyleName(Button.STYLE_LINK);
- deleteSelected.addListener(this);
- horiz.addComponent(deleteSelected);
- deselect = new Button("Deselect all");
- deselect.setStyleName(Button.STYLE_LINK);
- deselect.addListener(this);
- horiz.addComponent(deselect);
- final CheckBox editmode = new CheckBox("Editmode ");
- editmode.setDebugId("editMode");
- editmode.addListener(new CheckBox.ClickListener() {
- public void buttonClick(ClickEvent event) {
- source.setEditable(((Boolean) event.getButton().getValue())
- .booleanValue());
- }
- });
- editmode.setImmediate(true);
- horiz.addComponent(editmode);
-
- // "saved" table, minimalistic
- saved = new Table("Saved creatures");
- saved.setPageLength(5);
- saved.setWidth("550px");
- saved.setSelectable(false);
- saved.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
- saved.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- initProperties(saved);
- saved.addActionHandler(this);
- main.addComponent(saved);
- saved.setDebugId("SavedCreatures");
-
- final CheckBox b = new CheckBox("Modify saved creatures");
- b.setDebugId("modifySavedCreatures");
- b.addListener(new CheckBox.ClickListener() {
- public void buttonClick(ClickEvent event) {
- saved.setEditable(((Boolean) event.getButton().getValue())
- .booleanValue());
- }
- });
- b.setImmediate(true);
- main.addComponent(b);
-
- GeneratedColumnExample gencols = new GeneratedColumnExample();
- gencols.setCaption("Generated Columns");
- root.addComponent(gencols);
- }
-
- // set up the properties (columns)
- private void initProperties(Table table) {
- table.addContainerProperty(PROPERTY_SPECIES, String.class, "");
- table.addContainerProperty(PROPERTY_TYPE, String.class, "");
- table.addContainerProperty(PROPERTY_KIND, String.class, "");
- table
- .addContainerProperty(PROPERTY_HIRED, Boolean.class,
- Boolean.FALSE);
- }
-
- // fill the table with some random data
- private void fillTable(Table table) {
- initProperties(table);
-
- final String[] sp = new String[] { "Fox", "Dog", "Cat", "Moose",
- "Penguin", "Cow" };
- final String[] ty = new String[] { "Quick", "Lazy", "Sleepy",
- "Fidgety", "Crazy", "Kewl" };
- final String[] ki = new String[] { "Jumping", "Walking", "Sleeping",
- "Skipping", "Dancing" };
-
- Random r = new Random(5);
-
- for (int i = 0; i < 100; i++) {
- final String s = sp[(int) (r.nextDouble() * sp.length)];
- final String t = ty[(int) (r.nextDouble() * ty.length)];
- final String k = ki[(int) (r.nextDouble() * ki.length)];
- table.addItem(new Object[] { s, t, k, Boolean.FALSE }, new Integer(
- i));
- }
-
- }
-
- // Called for each item (row), returns valid actions for that item
- public Action[] getActions(Object target, Object sender) {
- if (sender == source) {
- final Item item = source.getItem(target);
- // save, delete, and hire if not already hired
- if (item != null
- && item.getItemProperty(PROPERTY_HIRED).getValue() == Boolean.FALSE) {
- return ACTIONS_HIRE;
- } else {
- return ACTIONS_NOHIRE;
- }
- } else {
- // "saved" table only has one action
- return new Action[] { ACTION_DELETE };
- }
- }
-
- // called when an action is invoked on an item (row)
- public void handleAction(Action action, Object sender, Object target) {
- if (sender == source) {
- Item item = source.getItem(target);
- if (action == ACTION_HIRE) {
- // set HIRED property to true
- item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
- if (saved.containsId(target)) {
- item = saved.getItem(target);
- item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
- }
- getWindow().showNotification("Hired", "" + item);
-
- } else if (action == ACTION_SAVE) {
- if (saved.containsId(target)) {
- // let's not save twice
- getWindow().showNotification("Already saved", "" + item);
- return;
- }
- // "manual" copy of the item properties we want
- final Item added = saved.addItem(target);
- Property p = added.getItemProperty(PROPERTY_SPECIES);
- p.setValue(item.getItemProperty(PROPERTY_SPECIES).getValue());
- p = added.getItemProperty(PROPERTY_TYPE);
- p.setValue(item.getItemProperty(PROPERTY_TYPE).getValue());
- p = added.getItemProperty(PROPERTY_KIND);
- p.setValue(item.getItemProperty(PROPERTY_KIND).getValue());
- p = added.getItemProperty(PROPERTY_HIRED);
- p.setValue(item.getItemProperty(PROPERTY_HIRED).getValue());
- getWindow().showNotification("Saved", "" + item);
- } else {
- // ACTION_DELETE
- getWindow().showNotification("Deleted ", "" + item);
- source.removeItem(target);
- }
-
- } else {
- // sender==saved
- if (action == ACTION_DELETE) {
- final Item item = saved.getItem(target);
- getWindow().showNotification("Deleted", "" + item);
- saved.removeItem(target);
- }
- }
- }
-
- public void buttonClick(ClickEvent event) {
- final Button b = event.getButton();
- if (b == deselect) {
- source.setValue(null);
- } else if (b == saveSelected) {
- // loop each selected and copy to "saved" table
- final Set selected = (Set) source.getValue();
- int s = 0;
- for (final Iterator it = selected.iterator(); it.hasNext();) {
- final Object id = it.next();
- if (!saved.containsId(id)) {
- final Item item = source.getItem(id);
- final Item added = saved.addItem(id);
- // "manual" copy of the properties we want
- Property p = added.getItemProperty(PROPERTY_SPECIES);
- p.setValue(item.getItemProperty(PROPERTY_SPECIES)
- .getValue());
- p = added.getItemProperty(PROPERTY_TYPE);
- p.setValue(item.getItemProperty(PROPERTY_TYPE).getValue());
- p = added.getItemProperty(PROPERTY_KIND);
- p.setValue(item.getItemProperty(PROPERTY_KIND).getValue());
- p = added.getItemProperty(PROPERTY_HIRED);
- p.setValue(item.getItemProperty(PROPERTY_HIRED).getValue());
- s++;
- }
- }
- getWindow().showNotification("Saved " + s);
-
- } else if (b == hireSelected) {
- // loop each selected and set property HIRED to true
- int s = 0;
- final Set selected = (Set) source.getValue();
- for (final Iterator it = selected.iterator(); it.hasNext();) {
- final Object id = it.next();
- Item item = source.getItem(id);
- final Property p = item.getItemProperty(PROPERTY_HIRED);
- if (p.getValue() == Boolean.FALSE) {
- p.setValue(Boolean.TRUE);
- s++;
- }
- if (saved.containsId(id)) {
- // also update "saved" table
- item = saved.getItem(id);
- item.getItemProperty(PROPERTY_HIRED).setValue(Boolean.TRUE);
- }
- }
- getWindow().showNotification("Hired " + s);
-
- } else {
- // loop trough selected and delete
- int s = 0;
- final Set selected = (Set) source.getValue();
- for (final Iterator it = selected.iterator(); it.hasNext();) {
- final Object id = it.next();
- if (source.containsId(id)) {
- s++;
- source.removeItem(id);
- }
- }
- getWindow().showNotification("Deleted " + s);
- }
-
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/TreeExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/TreeExample.java deleted file mode 100644 index cf5a6a7f33..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/TreeExample.java +++ /dev/null @@ -1,164 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.featurebrowser; - -import com.vaadin.data.Item; -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.event.Action; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Tree; - -/** - * Demonstrates basic Tree -functionality. Actions are used for add/remove item - * functionality, and a ValueChangeListener reacts to both the Tree and the - * TextField. - */ -public class TreeExample extends CustomComponent implements Action.Handler, - Tree.ValueChangeListener { - - private static final Action ADD = new Action("Add item"); - private static final Action DELETE = new Action("Delete item"); - private static final Action[] actions = new Action[] { ADD, DELETE }; - - // Id for the caption property - private static final Object CAPTION_PROPERTY = "caption"; - - private static final String desc = "Try both right- and left-click!"; - - Tree tree; - TextField editor; - - public TreeExample() { - final HorizontalLayout main = new HorizontalLayout(); - main.setWidth("100%"); - main.setDebugId("mainLayout"); - main.setMargin(true); - setCompositionRoot(main); - - // Panel w/ Tree - Panel p = new Panel("Select item"); - p.setStyleName(Panel.STYLE_LIGHT); - p.setWidth("250px"); - // Description - p.addComponent(new Label(desc)); - // Tree with a few items - tree = new Tree(); - tree.setDebugId("tree"); - tree.setImmediate(true); - // we'll use a property for caption instead of the item id ("value"), - // so that multiple items can have the same caption - tree.addContainerProperty(CAPTION_PROPERTY, String.class, ""); - tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); - tree.setItemCaptionPropertyId(CAPTION_PROPERTY); - for (int i = 1; i <= 3; i++) { - final Object id = addCaptionedItem("Section " + i, null); - tree.expandItem(id); - addCaptionedItem("Team A", id); - addCaptionedItem("Team B", id); - } - // listen for selections - tree.addListener(this); - // "context menu" - tree.addActionHandler(this); - p.addComponent(tree); - main.addComponent(p); - - // Panel w/ TextField ("editor") - p = new Panel("Edit item caption"); - p.setStyleName(Panel.STYLE_LIGHT); - editor = new TextField(); - // make immediate, instead of adding an "apply" button - editor.setImmediate(true); - editor.setEnabled(false); - editor.setColumns(15); - p.addComponent(editor); - main.addComponent(p); - main.setExpandRatio(p, 1); - } - - public Action[] getActions(Object target, Object sender) { - // We can provide different actions for each target (item), but we'll - // use the same actions all the time. - return actions; - } - - public void handleAction(Action action, Object sender, Object target) { - if (action == DELETE) { - tree.removeItem(target); - } else { - // Add - final Object id = addCaptionedItem("New Item", target); - tree.expandItem(target); - tree.setValue(id); - editor.focus(); - } - } - - public void valueChange(ValueChangeEvent event) { - final Object id = tree.getValue(); // selected item id - if (event.getProperty() == tree) { - // a Tree item was (un) selected - if (id == null) { - // no selecteion, disable TextField - editor.removeListener(this); - editor.setValue(""); - editor.setEnabled(false); - } else { - // item selected - // first remove previous listener - editor.removeListener(this); - // enable TextField and update value - editor.setEnabled(true); - final Item item = tree.getItem(id); - editor.setValue(item.getItemProperty(CAPTION_PROPERTY) - .getValue()); - // listen for TextField changes - editor.addListener(this); - editor.focus(); - } - } else { - // TextField - if (id != null) { - final Item item = tree.getItem(id); - final Property p = item.getItemProperty(CAPTION_PROPERTY); - p.setValue(editor.getValue()); - tree.requestRepaint(); - } - - } - } - - /** - * Helper to add an item with specified caption and (optional) parent. - * - * @param caption - * The item caption - * @param parent - * The (optional) parent item id - * @return the created item's id - */ - private Object addCaptionedItem(String caption, Object parent) { - // add item, let tree decide id - final Object id = tree.addItem(); - // get the created item - final Item item = tree.getItem(id); - // set our "caption" property - final Property p = item.getItemProperty(CAPTION_PROPERTY); - p.setValue(caption); - if (parent != null) { - tree.setChildrenAllowed(parent, true); - tree.setParent(id, parent); - tree.setChildrenAllowed(id, false); - } - return id; - } - -} diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/ValueInputExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/ValueInputExample.java deleted file mode 100644 index 14415d3794..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/ValueInputExample.java +++ /dev/null @@ -1,163 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import java.util.Date;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.InlineDateField;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Slider;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window.Notification;
-
-/**
- * Shows some basic fields for value input; TextField, DateField, Slider...
- *
- * @author IT Mill Ltd.
- */
-public class ValueInputExample extends CustomComponent {
-
- @SuppressWarnings("deprecation")
- public ValueInputExample() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- // listener that shows a value change notification
- final Field.ValueChangeListener listener = new Field.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- getWindow().showNotification("Received",
- "<pre>" + event.getProperty().getValue() + "</pre>",
- Notification.TYPE_WARNING_MESSAGE);
- }
- };
-
- // TextField
- HorizontalLayout horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- Panel left = new Panel("TextField");
- left.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(left);
- Panel right = new Panel("multiline");
- right.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(right);
- // basic TextField
- TextField tf = new TextField("Basic");
- tf.setDebugId("BasicTextField");
- tf.setColumns(15);
- tf.setImmediate(true);
- tf.addListener(listener);
- left.addComponent(tf);
- // multiline TextField a.k.a TextArea
- tf = new TextField("Area");
- tf.setDebugId("AreaTextField");
- tf.setColumns(15);
- tf.setRows(5);
- tf.setImmediate(true);
- tf.addListener(listener);
- right.addComponent(tf);
-
- // DateFields
- Date d = new Date(98, 1, 22, 13, 14, 15);
- horiz = new HorizontalLayout();
- horiz.setWidth("100%");
- main.addComponent(horiz);
- left = new Panel("DateField");
- left.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(left);
- right = new Panel("inline");
- right.setStyleName(Panel.STYLE_LIGHT);
- horiz.addComponent(right);
- // default
- DateField df = new DateField("Day resolution");
- df.setDebugId("DayResolutionDateField");
- df.setValue(d);
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_DAY);
- left.addComponent(df);
- // minute
- df = new DateField("Minute resolution");
- df.setValue(d);
- df.setDebugId("MinuteResolutionDateField");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_MIN);
- left.addComponent(df);
- // year
- df = new DateField("Year resolution");
- df.setValue(d);
- df.setDebugId("YearResolutionDateField");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_YEAR);
- left.addComponent(df);
- // msec
- df = new DateField("Millisecond resolution");
- df.setValue(d);
- df.setDebugId("MillisecondResolutionDateField");
- df.addListener(listener);
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_MSEC);
- left.addComponent(df);
- // Inline
- df = new InlineDateField();
- df.setValue(d);
- df.setDebugId("InlineDateField");
- df.addListener(listener);
- df.setImmediate(true);
- right.addComponent(df);
-
- // Slider
- left = new Panel("Slider");
- left.setStyleName(Panel.STYLE_LIGHT);
- main.addComponent(left);
- // int slider
- Slider slider = new Slider(0, 100);
- slider.setDebugId("Slider1");
- slider.setWidth("300px");
- slider.setImmediate(true);
- slider.addListener(new Slider.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- // update caption when value changes
- final Slider s = (Slider) event.getProperty();
- s.setCaption("Value: " + s.getValue());
- }
- });
- try {
- slider.setValue(20);
- } catch (final Exception e) {
- e.printStackTrace(System.err);
- }
- left.addComponent(slider);
- // double slider
- slider = new Slider(0.0, 1.0, 1);
- slider.setOrientation(Slider.ORIENTATION_VERTICAL);
- slider.setDebugId("Slider2");
- slider.setImmediate(true);
- slider.addListener(new Slider.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- // update caption when value changes
- final Slider s = (Slider) event.getProperty();
- s.setCaption("Value: " + s.getValue());
- }
- });
- try {
- slider.setValue(0.5);
- } catch (final Exception e) {
- e.printStackTrace(System.err);
- }
- left.addComponent(slider);
-
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/WindowingExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/WindowingExample.java deleted file mode 100644 index 488d33702f..0000000000 --- a/tests/src/com/vaadin/automatedtests/featurebrowser/WindowingExample.java +++ /dev/null @@ -1,112 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.automatedtests.featurebrowser;
-
-import java.net.URL;
-
-import com.vaadin.terminal.ExternalResource;
-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.Button.ClickEvent;
-
-/**
- * @author marc
- *
- */
-public class WindowingExample extends CustomComponent {
-
- public static final String txt = "<p>There are two main types of windows: application-level windows, and "
- + "\"sub windows\".</p><p>A sub window is rendered as a \"inline\" popup window"
- + " within the (native) browser window to which it was added. You can create"
- + " a sub window by creating a new Window and adding it to a application-level window, for instance"
- + " your main window. </p><p> In contrast, you create a application-level window by"
- + " creating a new Window and adding it to the Application. Application-level"
- + " windows are not shown by default - you need to open a browser window for"
- + " the url representing the window. You can think of the application-level"
- + " windows as separate views into your application - and a way to create a"
- + " \"native\" browser window.</p><p>Depending on your needs, it's also"
- + " possible to create a new window instance (with it's own internal state)"
- + " for each new (native) browser window, or you can share the same instance"
- + " (and state) between several browser windows (the latter is most useful"
- + " for read-only views).</p>";
-
- private URL windowUrl = null;
-
- public WindowingExample() {
- final VerticalLayout main = new VerticalLayout();
- main.setMargin(true);
- setCompositionRoot(main);
-
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- main.addComponent(l);
-
- Button b = new Button("Create a new subwindow",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("Subwindow");
- w.setWidth("50%");
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- w.addComponent(l);
- getApplication().getMainWindow().addWindow(w);
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
- b = new Button("Create a new modal window", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("Modal window");
- w.setWidth("50%");
- w.setModal(true);
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- w.addComponent(l);
- getApplication().getMainWindow().addWindow(w);
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
- b = new Button("Open a application-level window, with shared state",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (windowUrl == null) {
- final Window w = new Window("Subwindow");
- final Label l = new Label(txt);
- l.setContentMode(Label.CONTENT_XHTML);
- w.addComponent(l);
- getApplication().addWindow(w);
- windowUrl = w.getURL();
- }
- getApplication().getMainWindow().open(
- new ExternalResource(windowUrl), "_new");
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
- b = new Button(
- "Create a new application-level window, with it's own state",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window w = new Window("Subwindow");
- getApplication().addWindow(w);
- final Label l = new Label(
- "Each opened window has its own"
- + " name, and is accessed trough its own uri.");
- l.setCaption("Window " + w.getName());
- w.addComponent(l);
- getApplication().getMainWindow().open(
- new ExternalResource(w.getURL()), "_new");
- }
- });
- b.setStyleName(Button.STYLE_LINK);
- main.addComponent(b);
-
- }
-
-}
diff --git a/tests/src/com/vaadin/automatedtests/robustness/Robustness.java b/tests/src/com/vaadin/automatedtests/robustness/Robustness.java deleted file mode 100644 index 1e8a3766f2..0000000000 --- a/tests/src/com/vaadin/automatedtests/robustness/Robustness.java +++ /dev/null @@ -1,91 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.robustness; - -import com.vaadin.automatedtests.util.Log; -import com.vaadin.automatedtests.util.RandomComponents; -import com.vaadin.ui.Button; -import com.vaadin.ui.ComponentContainer; -import com.vaadin.ui.Label; -import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; - -public abstract class Robustness extends com.vaadin.Application implements - Button.ClickListener { - - static int totalCount = 0; - - int count = 0; - - final Window main = new Window("Robustness tests by featurebrowser"); - - Button close = new Button("Close application"); - - Button remove = new Button("Remove all components"); - - Button create = new Button("Create"); - - Label label = new Label(); - - ComponentContainer stressLayout; - - RandomComponents randomComponents = new RandomComponents(); - - @Override - public void init() { - createNewView(); - } - - public void createNewView() { - setMainWindow(main); - main.setDebugId("MainWindow"); - main.removeAllComponents(); - - main.addComponent(label); - main.addComponent(close); - main.addComponent(remove); - main.addComponent(create); - close.addListener(this); - remove.addListener(this); - create.addListener(this); - - remove.setDescription("After this garbage collector should" - + " be able to collect every component" - + " inside stressLayout."); - - close.setDebugId("close"); - remove.setDebugId("remove"); - create.setDebugId("create"); - - } - - public void buttonClick(ClickEvent event) { - if (event.getButton() == create) { - create(); - } else if (event.getButton() == remove) { - main.removeAllComponents(); - close.removeListener(this); - remove.removeListener(this); - create.removeListener(this); - close = null; - remove = null; - create = null; - label = null; - stressLayout = null; - System.out.println("main.getLayout()=" + main.getLayout()); - System.out.println(Log.getMemoryStatistics()); - } else if (event.getButton() == close) { - System.out.println("Before close, memory statistics:"); - System.out.println(Log.getMemoryStatistics()); - close(); - // Still valueUnbound (session expiration) needs to occur for GC to - // do its work - System.out.println("After close, memory statistics:"); - System.out.println(Log.getMemoryStatistics()); - } - } - - public abstract void create(); -} diff --git a/tests/src/com/vaadin/automatedtests/util/DebugId.java b/tests/src/com/vaadin/automatedtests/util/DebugId.java deleted file mode 100644 index 8f2390933b..0000000000 --- a/tests/src/com/vaadin/automatedtests/util/DebugId.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.util; - -import java.io.Serializable; -import java.util.HashMap; - -import com.vaadin.ui.Component; - -public class DebugId implements Serializable { - - private static HashMap debugIds = new HashMap(); - - /** - * Generate static debug id based on package and component type. If - * duplicate package, component type then number of instances count is - * appended to debugId. - * - * @param c - */ - public static void set(Component c, String description) { - String debugId = ""; - - // add package name - StackTraceElement[] st = new Throwable().fillInStackTrace() - .getStackTrace(); - try { - debugId += st[3].getClassName(); - } catch (Exception e) { - e.printStackTrace(); - } - - // add component type - debugId += c.getClass(); - - // add given description - debugId += description; - - if (debugIds.containsKey(debugId)) { - int count = ((Integer) debugIds.get(debugId)).intValue(); - count++; - debugIds.put(debugId, new Integer(count)); - debugId = debugId + "-" + count; - } - - c.setDebugId(debugId); - } -} diff --git a/tests/src/com/vaadin/automatedtests/util/Log.java b/tests/src/com/vaadin/automatedtests/util/Log.java deleted file mode 100644 index f9948af60e..0000000000 --- a/tests/src/com/vaadin/automatedtests/util/Log.java +++ /dev/null @@ -1,136 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.util; - -import java.io.Serializable; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; - -/** - * - * Execution output and error messages should be handled through this class. It - * is likely that we need these messages back to TT Server at some point just to - * figure out what went wrong. - * - */ -public class Log implements Serializable { - - // 3 (errors only) - // 2 (+ warnings) - // 1 (+logs) - // 0 (all, print messages also to System.out) - public static final int debug = 0; - - // Should class.method() and it's call times be told on debug? - public static final boolean showClassInformation = true; - - public static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - public static int DEBUG = 0; - - public static int LOG = 1; - - public static int WARN = 2; - - public static int ERROR = 3; - - private static Log log; - - public static HashMap classMethodCallCounter = new HashMap(); - - static { - log = new Log(); - } - - public static void reset() { - classMethodCallCounter = new HashMap(); - } - - public static String getNow() { - return df.format(new Date()); - } - - private Log() { - } - - public static String getSource() { - StackTraceElement[] st = new Throwable().fillInStackTrace() - .getStackTrace(); - try { - String key = ""; - String methodName = st[3].getMethodName(); - int line = st[3].getLineNumber(); - - String clazz = st[3].getClassName() + ".java"; - key = "(" + clazz + ":" + line + ")" + " " + methodName; - Integer value = (Integer) classMethodCallCounter.get(key); - if (value == null) { - value = new Integer(1); - } else { - value = new Integer(value.intValue() + 1); - } - classMethodCallCounter.put(key, value); - return value.intValue() + ": " + key; - } catch (Exception e) { - return "unknown class.method"; - } - - } - - public static String getClassMethodCounters() { - String result = ""; - for (final Iterator it = classMethodCallCounter.keySet().iterator(); it - .hasNext();) { - String key = (String) it.next(); - result += classMethodCallCounter.get(key) + ": " + key + "\n"; - } - return result; - } - - public void add(int type, String message) { - String source = getSource(); - if (type >= debug) { - if (showClassInformation) { - System.out.println(source + ": " + message); - } else { - System.out.println(message); - } - } - } - - public static void debug(String message) { - log.add(DEBUG, message); - } - - public static void log(String message) { - log.add(LOG, message); - } - - public static void warn(String message) { - log.add(WARN, message); - } - - public static void error(String message) { - log.add(ERROR, message); - } - - /** - * Simple way to check for memory consumption without profiler. - */ - public static String getMemoryStatistics() { - // You should call gc before printing statistics (if you are not using a - // profiler) - System.gc(); - long inUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime() - .freeMemory()); - return "Memory:\n" + inUse + " (Used)\n" - + Runtime.getRuntime().totalMemory() + " (Total)\n" - + Runtime.getRuntime().freeMemory() + " (Free)\n"; - - } -} diff --git a/tests/src/com/vaadin/automatedtests/util/MultiListener.java b/tests/src/com/vaadin/automatedtests/util/MultiListener.java deleted file mode 100644 index 5f7df2ab99..0000000000 --- a/tests/src/com/vaadin/automatedtests/util/MultiListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.util; - -import com.vaadin.data.Container.ItemSetChangeEvent; -import com.vaadin.data.Container.ItemSetChangeListener; -import com.vaadin.data.Container.PropertySetChangeEvent; -import com.vaadin.data.Container.PropertySetChangeListener; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; - -public class MultiListener implements Button.ClickListener, - PropertySetChangeListener, ItemSetChangeListener, ValueChangeListener { - - public void buttonClick(ClickEvent event) { - Log.debug("ClickEvent from " + event.getButton().getCaption()); - } - - public void containerPropertySetChange(PropertySetChangeEvent event) { - Log.debug("containerPropertySetChange from " + event.getContainer()); - } - - public void containerItemSetChange(ItemSetChangeEvent event) { - Log.debug("containerItemSetChange from " + event.getContainer()); - } - - public void valueChange(ValueChangeEvent event) { - Log.debug("valueChange from " + event.getProperty()); - } - -} diff --git a/tests/src/com/vaadin/automatedtests/util/RandomComponents.java b/tests/src/com/vaadin/automatedtests/util/RandomComponents.java deleted file mode 100644 index 46446d8f3b..0000000000 --- a/tests/src/com/vaadin/automatedtests/util/RandomComponents.java +++ /dev/null @@ -1,281 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.util; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.Random; - -import com.vaadin.automatedtests.ComponentsInTable; -import com.vaadin.data.Container.ItemSetChangeListener; -import com.vaadin.data.Container.PropertySetChangeListener; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.demo.featurebrowser.ButtonExample; -import com.vaadin.demo.featurebrowser.ClientCachingExample; -import com.vaadin.demo.featurebrowser.ComboBoxExample; -import com.vaadin.demo.featurebrowser.EmbeddedBrowserExample; -import com.vaadin.demo.featurebrowser.LabelExample; -import com.vaadin.demo.featurebrowser.LayoutExample; -import com.vaadin.demo.featurebrowser.NotificationExample; -import com.vaadin.demo.featurebrowser.RichTextExample; -import com.vaadin.demo.featurebrowser.SelectExample; -import com.vaadin.demo.featurebrowser.TableExample; -import com.vaadin.demo.featurebrowser.TreeExample; -import com.vaadin.demo.featurebrowser.ValueInputExample; -import com.vaadin.demo.featurebrowser.WindowingExample; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.ThemeResource; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.Button; -import com.vaadin.ui.ComponentContainer; -import com.vaadin.ui.DateField; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.GridLayout; -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; - -public class RandomComponents implements Serializable { - - private Random rand = null; - - private static Date date = new Date(2002, 2, 3, 4, 5, 6); - - public RandomComponents() { - // Always use the same seed, used to ensure deterministic behaviour - rand = new Random(1); - } - - /** - * Get random component container - * - * @param caption - * @return - */ - public ComponentContainer getRandomComponentContainer(String caption) { - ComponentContainer result = null; - final int randint = rand.nextInt(5); - switch (randint) { - - case 0: - result = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); - ((OrderedLayout) result).setCaption("OrderedLayout_horizontal_" - + caption); - break; - case 1: - result = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - ((OrderedLayout) result).setCaption("OrderedLayout_vertical_" - + caption); - break; - case 2: - GridLayout gl; - if (rand.nextInt(1) > 0) { - gl = new GridLayout(); - } else { - gl = new GridLayout(rand.nextInt(3) + 1, rand.nextInt(3) + 1); - } - gl.setCaption("GridLayout_" + caption); - gl.setDescription(gl.getCaption()); - for (int x = 0; x < gl.getColumns(); x++) { - for (int y = 0; y < gl.getRows(); y++) { - // gl.addComponent(getExamplePicture("x=" + x + ", y=" + y), - // x, y); - gl.addComponent(new Label("x=" + x + ", y=" + y)); - } - } - result = gl; - break; - case 3: - result = new Panel(); - ((Panel) result).setCaption("Panel_" + caption); - break; - case 4: - final TabSheet ts = new TabSheet(); - ts.setCaption("TabSheet_" + caption); - // randomly select one of the tabs - final int selectedTab = rand.nextInt(3); - final ArrayList tabs = new ArrayList(); - 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); - } - ts.setSelectedTab((ComponentContainer) tabs.get(selectedTab)); - result = ts; - break; - } - - return result; - } - - public AbstractComponent getRandomComponent(int caption) { - AbstractComponent result = null; - int randint = rand.nextInt(23); - MultiListener l = new MultiListener(); - switch (randint) { - case 0: - // Label - result = new Label(); - result.setCaption("Label component " + caption); - result.setDebugId(result.getCaption()); - break; - case 1: - // Button - result = new Button(); - result.setCaption("Button component " + caption); - result.setDebugId(result.getCaption()); - // some listeners - ((Button) result).addListener((Button.ClickListener) l); - break; - case 2: - // TextField - result = new TextField(); - result.setCaption("TextField component " + caption); - result.setDebugId(result.getCaption()); - break; - case 3: - // Select - result = new Select("Select component " + caption); - result.setCaption("Select component " + caption); - result.setDebugId(result.getCaption()); - result.setImmediate(true); - ((Select) result).setNewItemsAllowed(true); - // items - ((Select) result).addItem("first"); - ((Select) result).addItem("first"); - ((Select) result).addItem("first"); - ((Select) result).addItem("second"); - ((Select) result).addItem("third"); - ((Select) result).addItem("fourth"); - // some listeners - ((Select) result).addListener((ValueChangeListener) l); - ((Select) result).addListener((PropertySetChangeListener) l); - ((Select) result).addListener((ItemSetChangeListener) l); - break; - case 4: - // Link - result = new Link("", new ExternalResource("http://www.vaadin.com")); - result.setCaption("Link component " + caption); - break; - case 5: - // Link - result = new Panel(); - result.setCaption("Panel component " + caption); - ((Panel) result) - .addComponent(new Label( - "Panel is a container for other components, by default it draws a frame around it's " - + "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); - break; - case 6: - // Datefield - result = new DateField(); - ((DateField) result).setStyleName("calendar"); - ((DateField) result).setValue(date); - result.setCaption("Calendar component " + caption); - result.setDebugId(result.getCaption()); - break; - case 7: - // Datefield - result = new DateField(); - ((DateField) result).setValue(date); - result.setCaption("Calendar component " + caption); - result.setDebugId(result.getCaption()); - break; - case 8: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ButtonExample()); - break; - case 9: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ClientCachingExample()); - break; - case 10: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ComboBoxExample()); - break; - case 11: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new EmbeddedBrowserExample()); - break; - case 12: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new EmbeddedBrowserExample()); - break; - case 13: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new LabelExample()); - break; - case 14: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new LayoutExample()); - break; - case 15: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new NotificationExample()); - break; - case 16: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new RichTextExample()); - break; - case 17: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new SelectExample()); - break; - case 18: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new ValueInputExample()); - break; - case 19: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new WindowingExample()); - break; - case 20: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new TreeExample()); - break; - case 21: - result = new OrderedLayout(); - ((OrderedLayout) result).addComponent(new TableExample()); - break; - case 22: - result = new OrderedLayout(); - ((OrderedLayout) result) - .addComponent(new ComponentsInTable(4, 1000)); - break; - } - - return result; - } - - /** - * Add demo components to given container - * - * @param container - */ - public void fillLayout(ComponentContainer container, int numberOfComponents) { - for (int i = 0; i < numberOfComponents; i++) { - container.addComponent(getRandomComponent(i)); - } - } - - public AbstractComponent getExamplePicture(String caption) { - final ThemeResource res = new ThemeResource("test.png"); - final Embedded em = new Embedded("Embedded " + caption, res); - return em; - } - -} diff --git a/tests/src/com/vaadin/automatedtests/util/StatusServlet.java b/tests/src/com/vaadin/automatedtests/util/StatusServlet.java deleted file mode 100644 index c0b3c7c118..0000000000 --- a/tests/src/com/vaadin/automatedtests/util/StatusServlet.java +++ /dev/null @@ -1,89 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.util; - -import java.io.IOException; -import java.io.Writer; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@SuppressWarnings("serial") -public class StatusServlet extends HttpServlet { - - public static DateFormat dfHuman = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss"); - - /** - * Version number of this release. For example "5.0.0". - */ - public static final String VERSION; - - /** - * Major version number. For example 5 in 5.1.0. - */ - public static final int VERSION_MAJOR; - - /** - * Minor version number. For example 1 in 5.1.0. - */ - public static final int VERSION_MINOR; - - /** - * Builds number. For example 0-custom_tag in 5.0.0-custom_tag. - */ - public static final String VERSION_BUILD; - - /* Initialize version numbers from string replaced by build-script. */ - static { - if ("@VERSION@".equals("@" + "VERSION" + "@")) { - VERSION = "5.9.9-INTERNAL-NONVERSIONED-DEBUG-BUILD"; - } else { - VERSION = "@VERSION@"; - } - final String[] digits = VERSION.split("\\."); - VERSION_MAJOR = Integer.parseInt(digits[0]); - VERSION_MINOR = Integer.parseInt(digits[1]); - VERSION_BUILD = digits[2]; - } - - @Override - public void init(javax.servlet.ServletConfig servletConfig) - throws javax.servlet.ServletException { - super.init(servletConfig); - } - - @Override - protected void service(HttpServletRequest request, - HttpServletResponse response) throws ServletException, IOException { - Writer w = response.getWriter(); - - // not cacheable - response.setHeader("Cache-Control", "no-cache"); - response.setHeader("Pragma", "no-cache"); - response.setDateHeader("Expires", 0); - response.setContentType("text/html"); - - String p = ""; - p += "<p>StatusServlet " + dfHuman.format(new Date()) + "</p>"; - for (int i = 0; i < 30; i++) { - System.gc(); - } - long inUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime() - .freeMemory()); - p += "<p>Memory:<br />\n<memused>" + inUse - + "</memused> (Used)<br />\n" + "<memtotal>" - + Runtime.getRuntime().totalMemory() - + "<memtotal> (Total)<br />\n" + "<memfree>" - + Runtime.getRuntime().freeMemory() + "<memfree> (Free)</p>\n"; - - w.write("<html>\n" + p + "</html>\n"); - } -} diff --git a/tests/src/com/vaadin/tests/ScrollbarStressTest.java b/tests/src/com/vaadin/tests/ScrollbarStressTest.java index b6cef8353a..23a34302f8 100644 --- a/tests/src/com/vaadin/tests/ScrollbarStressTest.java +++ b/tests/src/com/vaadin/tests/ScrollbarStressTest.java @@ -4,14 +4,14 @@ import com.vaadin.Application; import com.vaadin.ui.Accordion; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.ui.ExpandLayout; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.OptionGroup; -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.Window; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -93,8 +93,7 @@ public class ScrollbarStressTest extends Application { } }); - OrderedLayout ol = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout ol = new HorizontalLayout(); ol.addComponent(context); ol.addComponent(testComponent); ol.addComponent(width); @@ -104,17 +103,17 @@ public class ScrollbarStressTest extends Application { ol.setMargin(true); Window controller = new Window("Controller"); - controller.setLayout(ol); + controller.setContent(ol); main.addWindow(controller); } protected void drawInExpandLayout() { main.removeAllComponents(); - main.getLayout().setSizeFull(); + main.getContent().setSizeFull(); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); - ExpandLayout el = new ExpandLayout(); + VerticalLayout el = new VerticalLayout(); el.removeAllComponents(); @@ -125,18 +124,18 @@ public class ScrollbarStressTest extends Application { el.addComponent(ol); - main.getLayout().addComponent(el); + main.getContent().addComponent(el); main.removeWindow(subwindow); } protected void drawInTabSheet(boolean verticalAkaAccordion) { main.removeAllComponents(); - main.getLayout().setSizeFull(); + main.getContent().setSizeFull(); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); ol.setCaption("Tab 1"); - OrderedLayout ol2 = new OrderedLayout(); + VerticalLayout ol2 = new VerticalLayout(); ol2.setCaption("Tab 2"); TabSheet ts = (verticalAkaAccordion ? accordion : tabsheet); @@ -162,10 +161,10 @@ public class ScrollbarStressTest extends Application { private void drawInSplitPanel() { main.removeAllComponents(); - main.getLayout().setSizeFull(); + main.getContent().setSizeFull(); - OrderedLayout ol = new OrderedLayout(); - OrderedLayout ol2 = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); + VerticalLayout ol2 = new VerticalLayout(); splitPanel.setFirstComponent(ol); splitPanel.setSecondComponent(ol2); @@ -185,11 +184,11 @@ public class ScrollbarStressTest extends Application { private void drawInPanel() { main.removeAllComponents(); - main.getLayout().setSizeFull(); + main.getContent().setSizeFull(); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); panel.setSizeFull(); - panel.setLayout(ol); + panel.setContent(ol); ol.setWidth((String) width.getValue()); ol.setHeight((String) height.getValue()); @@ -201,20 +200,20 @@ public class ScrollbarStressTest extends Application { private void drawInSubwindow() { main.removeAllComponents(); - main.getLayout().setSizeFull(); - OrderedLayout ol = new OrderedLayout(); + main.getContent().setSizeFull(); + VerticalLayout ol = new VerticalLayout(); ol.setWidth((String) width.getValue()); ol.setHeight((String) height.getValue()); ol.addComponent(getTestComponent()); - subwindow.setLayout(ol); + subwindow.setContent(ol); main.addWindow(subwindow); } private void drawInMainWindow() { main.removeAllComponents(); - OrderedLayout ol = new OrderedLayout(); - main.setLayout(ol); + VerticalLayout ol = new VerticalLayout(); + main.setContent(ol); ol.setWidth((String) width.getValue()); ol.setHeight((String) height.getValue()); diff --git a/tests/src/com/vaadin/tests/TestBench.java b/tests/src/com/vaadin/tests/TestBench.java index c3d7155b50..be3471c02d 100644 --- a/tests/src/com/vaadin/tests/TestBench.java +++ b/tests/src/com/vaadin/tests/TestBench.java @@ -18,7 +18,6 @@ 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.ExpandLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; @@ -201,13 +200,13 @@ public class TestBench extends com.vaadin.Application implements bodyLayout.addStyleName("light"); bodyLayout.setSizeFull(); - bodyLayout.setLayout(new ExpandLayout()); + bodyLayout.setContent(new VerticalLayout()); mainLayout.addComponent(bodyLayout); mainLayout.setSplitPosition(30); - mainWindow.setLayout(mainLayout); + mainWindow.setContent(mainLayout); setMainWindow(mainWindow); } diff --git a/tests/src/com/vaadin/tests/TestCaptionWrapper.java b/tests/src/com/vaadin/tests/TestCaptionWrapper.java index c15270458e..82ae63f26e 100644 --- a/tests/src/com/vaadin/tests/TestCaptionWrapper.java +++ b/tests/src/com/vaadin/tests/TestCaptionWrapper.java @@ -14,14 +14,12 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.DateField; import com.vaadin.ui.Embedded; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.ProgressIndicator; import com.vaadin.ui.RichTextArea; @@ -33,12 +31,13 @@ import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; import com.vaadin.ui.TwinColSelect; import com.vaadin.ui.Upload; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Component.Listener; public class TestCaptionWrapper extends CustomComponent implements Listener { - OrderedLayout main = new OrderedLayout(); + VerticalLayout main = new VerticalLayout(); final String eventListenerString = "Component.Listener feedback: "; Label eventListenerFeedback = new Label(eventListenerString @@ -72,13 +71,13 @@ public class TestCaptionWrapper extends CustomComponent implements Listener { final Panel panel = new Panel("Panel"); test(panel); - populateLayout(panel.getLayout()); + populateLayout((Layout) panel.getContent()); final TabSheet tabsheet = new TabSheet(); test(tabsheet); - final OrderedLayout tab1 = new OrderedLayout(); + final VerticalLayout tab1 = new VerticalLayout(); tab1.addComponent(new Label("try tab2")); - final OrderedLayout tab2 = new OrderedLayout(); + final VerticalLayout tab2 = new VerticalLayout(); test(tab2); populateLayout(tab2); tabsheet.addTab(tab1, "TabSheet tab1", new ClassResource("m.gif", @@ -86,7 +85,7 @@ public class TestCaptionWrapper extends CustomComponent implements Listener { tabsheet.addTab(tab2, "TabSheet tab2", new ClassResource("m.gif", getApplication())); - final ExpandLayout expandLayout = new ExpandLayout(); + final VerticalLayout expandLayout = new VerticalLayout(); test(expandLayout); populateLayout(expandLayout); @@ -96,7 +95,7 @@ public class TestCaptionWrapper extends CustomComponent implements Listener { final Window window = new Window("TEST: Window"); test(window); - populateLayout(window.getLayout()); + populateLayout((Layout) window.getContent()); } diff --git a/tests/src/com/vaadin/tests/TestComponentsAndLayouts.java b/tests/src/com/vaadin/tests/TestComponentsAndLayouts.java index 5187f8f8e6..ba9fbe86d0 100644 --- a/tests/src/com/vaadin/tests/TestComponentsAndLayouts.java +++ b/tests/src/com/vaadin/tests/TestComponentsAndLayouts.java @@ -26,7 +26,6 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.DateField; import com.vaadin.ui.Embedded; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; @@ -45,6 +44,7 @@ import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; import com.vaadin.ui.TwinColSelect; import com.vaadin.ui.Upload; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Component.Event; import com.vaadin.ui.Component.Listener; @@ -197,20 +197,6 @@ public class TestComponentsAndLayouts extends Application implements Listener, // ////////////////////////////////////////////////////////////////////// // //// if (false) { - target - .addComponent(new Label( - "<hr /><h1>Components inside ExpandLayout (height 250px)</h3>", - Label.CONTENT_XHTML)); - final ExpandLayout el = new ExpandLayout(); - el.setHeight(250, Component.UNITS_PIXELS); - el.expand(new Label("This label will expand on expand layout")); - populateLayout(el); - target.addComponent(el); - } - - // ////////////////////////////////////////////////////////////////////// - // //// - if (false) { target.addComponent(new Label( "<hr /><h1>Components inside Panel</h3>", Label.CONTENT_XHTML)); @@ -224,36 +210,15 @@ public class TestComponentsAndLayouts extends Application implements Listener, if (false) { target .addComponent(new Label( - "<hr /><h1>Components inside vertical SplitPanel (splitpanel is under 250height ExpandLayout)</h3>", - Label.CONTENT_XHTML)); - final ExpandLayout sp1l = new ExpandLayout(); - sp1l.setHeight(250, ExpandLayout.UNITS_PIXELS); - final SplitPanel sp1 = new SplitPanel( - SplitPanel.ORIENTATION_VERTICAL); - sp1l.addComponent(sp1); - final OrderedLayout sp1first = new OrderedLayout(); - final OrderedLayout sp1second = new OrderedLayout(); - sp1.setFirstComponent(sp1first); - populateLayout(sp1first); - populateLayout(sp1second); - sp1.setSecondComponent(sp1second); - target.addComponent(sp1l); - } - - // ////////////////////////////////////////////////////////////////////// - // //// - if (false) { - target - .addComponent(new Label( "<hr /><h1>Components inside horizontal SplitPanel (splitpanel is under 250px height ExpandLayout)</h3>", Label.CONTENT_XHTML)); - final ExpandLayout sp2l = new ExpandLayout(); + final VerticalLayout sp2l = new VerticalLayout(); sp2l.setHeight(250, SplitPanel.UNITS_PIXELS); final SplitPanel sp2 = new SplitPanel( SplitPanel.ORIENTATION_HORIZONTAL); sp2l.addComponent(sp2); - final OrderedLayout sp2first = new OrderedLayout(); - final OrderedLayout sp2second = new OrderedLayout(); + final VerticalLayout sp2first = new VerticalLayout(); + final VerticalLayout sp2second = new VerticalLayout(); sp2.setFirstComponent(sp2first); populateLayout(sp2first); populateLayout(sp2second); @@ -278,8 +243,8 @@ public class TestComponentsAndLayouts extends Application implements Listener, final Embedded emb = new Embedded("Embedded " + count++, flashResource); emb.setType(Embedded.TYPE_OBJECT); emb.setMimeType("application/x-shockwave-flash"); - emb.setWidth(250); - emb.setHeight(100); + emb.setWidth("250px"); + emb.setHeight("100px"); test(layout, emb); final Panel panel = new Panel("Panel " + count++); @@ -333,9 +298,9 @@ public class TestComponentsAndLayouts extends Application implements Listener, test(layout, table); final TabSheet tabsheet = new TabSheet(); - final OrderedLayout tab1 = new OrderedLayout(); + final VerticalLayout tab1 = new VerticalLayout(); tab1.addComponent(new Label("tab1 " + count++)); - final OrderedLayout tab2 = new OrderedLayout(); + final VerticalLayout tab2 = new VerticalLayout(); tab2.addComponent(new Label("tab2 " + count++)); tabsheet.addTab(tab1, "Default (not configured) TabSheet tab1", new ClassResource("m.gif", this)); @@ -344,9 +309,9 @@ public class TestComponentsAndLayouts extends Application implements Listener, test(layout, tabsheet); final Accordion accordion = new Accordion(); - final OrderedLayout acc1 = new OrderedLayout(); + final VerticalLayout acc1 = new VerticalLayout(); acc1.addComponent(new Label("acc1 " + count++)); - final OrderedLayout acc2 = new OrderedLayout(); + final VerticalLayout acc2 = new VerticalLayout(); acc2.addComponent(new Label("acc2 " + count++)); accordion.addTab(acc1, "Default (not configured) Accordion acc1", new ClassResource("m.gif", this)); diff --git a/tests/src/com/vaadin/tests/TestForExpandLayout.java b/tests/src/com/vaadin/tests/TestForExpandLayout.java deleted file mode 100644 index e58ec24161..0000000000 --- a/tests/src/com/vaadin/tests/TestForExpandLayout.java +++ /dev/null @@ -1,55 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.ExpandLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.OrderedLayout;
-import com.vaadin.ui.Panel;
-
-/**
- *
- * @author IT Mill Ltd.
- */
-public class TestForExpandLayout extends CustomComponent {
-
- ExpandLayout main = new ExpandLayout();
-
- DateField df;
-
- public TestForExpandLayout() {
- setCompositionRoot(main);
- createNewView();
- }
-
- public void createNewView() {
- main.removeAllComponents();
- for (int i = 0; i < 6; i++) {
- final ExpandLayout el = new ExpandLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
- for (int j = 0; j < i + 3; j++) {
- final Label l = new Label("label" + i + ":" + j);
- el.addComponent(l);
- }
- if (i > 0) {
- // el.setMargin(true);
- el.setSizeUndefined();
- el.setWidth("100%");
- if (i % 2 == 0) {
- el.setHeight("8em");
- Panel p = new Panel("tp");
- p.addComponent(new Label("panelc"));
- p.setHeight("100%");
- p.setWidth("100px");
- el.addComponent(p);
- }
- }
- main.addComponent(el);
- }
-
- }
-}
diff --git a/tests/src/com/vaadin/tests/TestForExpandLayout2.java b/tests/src/com/vaadin/tests/TestForExpandLayout2.java deleted file mode 100644 index 5c6ff7955b..0000000000 --- a/tests/src/com/vaadin/tests/TestForExpandLayout2.java +++ /dev/null @@ -1,64 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.ExpandLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-
-/**
- *
- * @author IT Mill Ltd.
- */
-public class TestForExpandLayout2 extends CustomComponent {
-
- ExpandLayout main;
-
- public TestForExpandLayout2() {
- createNewView();
- setCompositionRoot(main);
- }
-
- public void createNewView() {
- main = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
-
- Panel left = new Panel("Left column");
- left.setHeight(100, Panel.UNITS_PERCENTAGE);
- left.setWidth(150);
- main.addComponent(left);
-
- ExpandLayout center = new ExpandLayout();
- center.addComponent(new Label("header"));
- Panel mainContent = new Panel();
- center.addComponent(mainContent);
- center.expand(mainContent);
- mainContent.setSizeFull();
-
- ExpandLayout buttons = new ExpandLayout(
- ExpandLayout.ORIENTATION_HORIZONTAL);
- buttons.setHeight(30, ExpandLayout.UNITS_PIXELS);
- Button b1 = new Button("Save");
- Button b2 = new Button("Cancel");
- Button b3 = new Button("Logout");
- buttons.addComponent(b1);
- buttons.setComponentAlignment(b1, ExpandLayout.ALIGNMENT_RIGHT,
- ExpandLayout.ALIGNMENT_TOP);
- buttons.addComponent(b2);
- buttons.addComponent(b3);
- center.addComponent(buttons);
-
- main.addComponent(center);
- main.expand(center);
-
- Panel right = new Panel("Right column");
- right.setHeight(100, Panel.UNITS_PERCENTAGE);
- right.setWidth(200);
-
- main.addComponent(right);
-
- }
-}
diff --git a/tests/src/com/vaadin/tests/TestForExpandLayout3.java b/tests/src/com/vaadin/tests/TestForExpandLayout3.java deleted file mode 100644 index ae4adfcfaa..0000000000 --- a/tests/src/com/vaadin/tests/TestForExpandLayout3.java +++ /dev/null @@ -1,79 +0,0 @@ -/*
-@ITMillApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.ExpandLayout;
-
-/**
- *
- * @author IT Mill Ltd.
- */
-public class TestForExpandLayout3 extends CustomComponent {
-
- ExpandLayout main = new ExpandLayout();
-
- DateField df;
-
- public TestForExpandLayout3() {
- setCompositionRoot(main);
- createNewView();
- }
-
- public void createNewView() {
- main.removeAllComponents();
-
- ExpandLayout el;
- Button b;
- Button b2;
-
- el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
-
- b = new Button("SDFS");
- b2 = new Button("DSFSDFDFSSDF");
-
- el.addComponent(b);
- el.addComponent(b2);
-
- el.expand(b);
- el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_RIGHT,
- ExpandLayout.ALIGNMENT_VERTICAL_CENTER);
- main.addComponent(el);
-
- el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
-
- b = new Button("SDFS");
- b2 = new Button("DSFSDFDFSSDF");
-
- el.addComponent(b);
- el.addComponent(b2);
-
- el.expand(b);
- el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_HORIZONTAL_CENTER,
- ExpandLayout.ALIGNMENT_VERTICAL_CENTER);
- el.setHeight(60, ExpandLayout.UNITS_PIXELS);
- el.setMargin(true);
- main.addComponent(el);
-
- el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
-
- b = new Button("SDFS");
- b2 = new Button("DSFSDFDFSSDF");
-
- el.addComponent(b);
- el.addComponent(b2);
-
- el.expand(b);
- el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_RIGHT,
- ExpandLayout.ALIGNMENT_BOTTOM);
- el.setHeight(100, ExpandLayout.UNITS_PIXELS);
- el.setSpacing(true);
-
- main.addComponent(el);
-
- }
-}
diff --git a/tests/src/com/vaadin/tests/TestSizeableIncomponents.java b/tests/src/com/vaadin/tests/TestSizeableIncomponents.java index 7c9788e640..7deb4479fa 100644 --- a/tests/src/com/vaadin/tests/TestSizeableIncomponents.java +++ b/tests/src/com/vaadin/tests/TestSizeableIncomponents.java @@ -21,11 +21,11 @@ import com.vaadin.ui.ComboBox; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Embedded; -import com.vaadin.ui.ExpandLayout; +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; import com.vaadin.ui.Button.ClickEvent; @@ -46,8 +46,8 @@ public class TestSizeableIncomponents extends Application { setMainWindow(w); w.setTheme("demo"); - final ExpandLayout main = new ExpandLayout(); - w.setLayout(main); + final VerticalLayout main = new VerticalLayout(); + w.setContent(main); select = new ComboBox(); select.setImmediate(true); @@ -85,8 +85,7 @@ public class TestSizeableIncomponents extends Application { } }); - OrderedLayout controllers = new OrderedLayout( - OrderedLayout.ORIENTATION_HORIZONTAL); + HorizontalLayout controllers = new HorizontalLayout(); controllers.addComponent(prev); controllers.addComponent(select); controllers.addComponent(next); @@ -116,10 +115,10 @@ public class TestSizeableIncomponents extends Application { testPanel = new Panel(); testPanel.setSizeFull(); - testPanel.setLayout(new ExpandLayout()); + testPanel.setContent(new VerticalLayout()); testPanel.setStyleName("testable"); main.addComponent(testPanel); - main.expand(testPanel); + main.setExpandRatio(testPanel, 1); } @@ -147,8 +146,8 @@ public class TestSizeableIncomponents extends Application { t.addConfiguration(new Configuration("100px*100px") { @Override void configure(Component c) { - c.setWidth(60); - c.setHeight(60); + c.setWidth("60px"); + c.setHeight("60px"); } }); t = new Testable(c); @@ -177,7 +176,7 @@ public class TestSizeableIncomponents extends Application { Panel p = new Panel( "Wrapper panel (400px*400px)"); - p.setLayout(new ExpandLayout()); + p.setContent(new VerticalLayout()); p.setWidth("400px"); p.setHeight("400px"); p.addComponent(c); diff --git a/tests/src/com/vaadin/tests/TreeFilesystemContainer.java b/tests/src/com/vaadin/tests/TreeFilesystemContainer.java index 52154fbe22..690555b3ad 100644 --- a/tests/src/com/vaadin/tests/TreeFilesystemContainer.java +++ b/tests/src/com/vaadin/tests/TreeFilesystemContainer.java @@ -9,11 +9,11 @@ import java.io.File; import com.vaadin.data.util.FilesystemContainer; import com.vaadin.data.util.FilesystemContainer.FileItem; import com.vaadin.demo.util.SampleDirectory; -import com.vaadin.ui.ExpandLayout; import com.vaadin.ui.Field; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.Tree; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Component.Event; import com.vaadin.ui.Component.Listener; @@ -45,17 +45,16 @@ public class TreeFilesystemContainer extends com.vaadin.Application implements public void init() { final Window w = new Window("Tree FilesystemContainer demo"); setMainWindow(w); - final ExpandLayout main = new ExpandLayout(); - w.setLayout(main); + final VerticalLayout main = new VerticalLayout(); + w.setContent(main); main.setMargin(true); main.setSpacing(true); - propertyPanel.setHeight(120); + propertyPanel.setHeight("120px"); main.addComponent(propertyPanel); - explorerPanel.setHeight(100); - explorerPanel.setHeightUnits(Panel.UNITS_PERCENTAGE); + explorerPanel.setHeight("100%"); main.addComponent(explorerPanel); - main.expand(explorerPanel); + main.setExpandRatio(explorerPanel, 1); // Explorer panel contains tree explorerPanel.addComponent(filesystem); diff --git a/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html new file mode 100644 index 0000000000..8df7ea00ae --- /dev/null +++ b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html @@ -0,0 +1,251 @@ +<?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.combobox.Comboboxes</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[1]</td> + <td>14,14</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>empty-open</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[1]</td> + <td>14,11</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VFilterSelect[0]/domChild[1]</td> + <td>10,9</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>undefined-wide-open</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VFilterSelect[0]/domChild[1]</td> + <td>12,19</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>undefined-wide-select-wide-popup</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[3]/span</td> + <td>163,4</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[3]/span</td> + <td>163,4</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>undefined-wide-select-wide-popup-page-3</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VFilterSelect[0]/domChild[1]</td> + <td>5,11</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VFilterSelect[0]/domChild[1]</td> + <td>9,9</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VFilterSelect[0]/domChild[1]</td> + <td>13,10</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VFilterSelect[0]/domChild[1]</td> + <td>11,12</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>fixed-select-wide-popup</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[3]/span</td> + <td>184,2</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[3]/span</td> + <td>184,2</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>fixed-select-wide-popup-page-3</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VFilterSelect[0]/domChild[1]</td> + <td>11,12</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>23,5</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>readonly</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>35,3</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>readonly-error</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>26,10</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>error</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>67,8</td> +</tr> +<tr> + <td>waitForVaadin</td> + <td></td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java new file mode 100644 index 0000000000..fe18875a47 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java @@ -0,0 +1,153 @@ +package com.vaadin.tests.components.combobox; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.Select; +import com.vaadin.ui.Button.ClickEvent; + +public class Comboboxes extends ComponentTestCase { + + private static final Object CAPTION = "caption"; + Select label[] = new Select[20]; + + @Override + protected void setup() { + super.setup(); + + Select s; + + s = createSelect(null); + s.setWidth(null); + addTestComponent(s); + + s = createSelect("Undefined wide, empty select"); + s.setWidth(null); + addTestComponent(s); + + s = createSelect("Undefined wide select with 5 items"); + s.setWidth(null); + addItem(s, "The first item"); + addItem(s, "The second item"); + addItem(s, "The third item"); + addItem(s, "The fourth item"); + addItem(s, "The fifth item"); + addTestComponent(s); + + s = createSelect("Undefined wide select with 50 items"); + s.setWidth(null); + populate(s, 50); + addTestComponent(s); + + s = createSelect(null); + s.setWidth("100px"); + addTestComponent(s); + + s = createSelect("100px wide, empty select"); + s.setWidth("100px"); + addTestComponent(s); + + s = createSelect("150px wide select with 5 items"); + s.setWidth("150px"); + addItem(s, "The first item"); + addItem(s, "The second item"); + addItem(s, "The third item"); + addItem(s, "The fourth item"); + addItem(s, "The fifth item"); + addTestComponent(s); + + s = createSelect("200px wide select with 50 items"); + s.setWidth("200px"); + populate(s, 50); + addTestComponent(s); + + } + + private void populate(Select s, int nr) { + String text = " an item "; + + String caption = ""; + for (int i = 0; i < nr; i++) { + if (i % 2 == 0) { + caption += text; + } else { + caption += i; + } + + addItem(s, caption); + } + + } + + private void addItem(Select s, String string) { + Object id = s.addItem(); + s.getItem(id).getItemProperty(CAPTION).setValue(string); + + } + + private Select createSelect(String caption) { + Select s = new Select(); + + s.addContainerProperty(CAPTION, String.class, ""); + s.setItemCaptionPropertyId(CAPTION); + s.setCaption(caption); + + return s; + } + + @Override + protected String getDescription() { + return "A generic test for Labels in different configurations"; + } + + @Override + protected List<Component> createActions() { + ArrayList<Component> actions = new ArrayList<Component>(); + + CheckBox errorIndicators = new CheckBox("Error indicators", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setErrorIndicators(enabled); + + } + }); + + CheckBox enabled = new CheckBox("Enabled", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setEnabled(enabled); + } + }); + + CheckBox readonly = new CheckBox("Readonly", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + boolean enabled = (Boolean) b.getValue(); + setReadOnly(enabled); + } + }); + + errorIndicators.setValue(new Boolean(false)); + readonly.setValue(new Boolean(false)); + enabled.setValue(new Boolean(true)); + + errorIndicators.setImmediate(true); + readonly.setImmediate(true); + enabled.setImmediate(true); + + actions.add(errorIndicators); + actions.add(readonly); + actions.add(enabled); + + return actions; + } + +} diff --git a/tests/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java b/tests/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java new file mode 100644 index 0000000000..026465a624 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java @@ -0,0 +1,52 @@ +package com.vaadin.tests.components.progressindicator;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.ProgressIndicator;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class ProgressIndicatorInvisible extends TestBase {
+
+ @Override
+ protected void setup() {
+ final VerticalLayout lo = new VerticalLayout();
+
+ addComponent(lo);
+
+ final ProgressIndicator pi = new ProgressIndicator();
+ pi.setPollingInterval(400);
+ lo.addComponent(pi);
+
+ final Button b = new Button("Hide container of progress indicator");
+ addComponent(b);
+
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ // If we skip hiding the layout, hiding the ProgressIndicator
+ // will stop the polling
+ lo.setVisible(!lo.isVisible());
+ // Not even this works
+ pi.setVisible(!lo.isVisible());
+ if (!lo.isVisible()) {
+ b.setCaption("Still polling");
+ } else {
+ b.setCaption("Hide container of progress indicator");
+ }
+
+ }
+
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Progress indicator does not stop polling when its parent layout is made invisible";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4014;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/select/SelectIconPlacement.java b/tests/src/com/vaadin/tests/components/select/SelectIconPlacement.java new file mode 100644 index 0000000000..2fcf730669 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/select/SelectIconPlacement.java @@ -0,0 +1,33 @@ +package com.vaadin.tests.components.select; + +import com.vaadin.terminal.ThemeResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Select; + +public class SelectIconPlacement extends TestBase { + private static final long serialVersionUID = 1L; + + private Select mySelect; + + @Override + protected void setup() { + mySelect = new Select("Foo"); + String bar = "FooBarBaz"; + mySelect.addItem(bar); + mySelect.setItemIcon(bar, new ThemeResource("common/icons/error.png")); + mySelect.select(bar); + addComponent(mySelect); + } + + @Override + protected String getDescription() { + return "A select with item icons pushes the caption of that item to the right to make room for the icon. It works fine in all browsers except IE8.<br/>"+ + "Upon component render the icon and caption is on top of each others, and it corrects itself when you open the dropdown. "; + } + + @Override + protected Integer getTicketNumber() { + return 3991; + } + +} diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java new file mode 100644 index 0000000000..3d389184b5 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class TabSheetMinimal extends TestBase {
+
+ int index = 1;
+ TabSheet ts = new TabSheet();
+
+ @Override
+ protected void setup() {
+ ts.setStyleName("minimal");
+ Button b = new Button("Add a tab", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ ts.addTab(new Label("" + index), "Tab " + index, null);
+ index++;
+
+ }
+ });
+ addComponent(ts);
+ addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Adding tabs to a 'minimal' style TabSheet work properly even if the TabSheet is initially empty";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4227;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/tree/TreeFiltering.html b/tests/src/com/vaadin/tests/components/tree/TreeFiltering.html new file mode 100644 index 0000000000..d65cd4d104 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tree/TreeFiltering.html @@ -0,0 +1,112 @@ +<?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">TreeFiltering</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.tree.TreeFiltering?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>unfiltered</td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTreeFiltering::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>all-removed</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTreeFiltering::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>unfiltered</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTreeFiltering::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>filter-0</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTreeFiltering::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>filter-0-and-num</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTreeFiltering::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForVaadin</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>unfiltered</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/tree/TreeFiltering.java b/tests/src/com/vaadin/tests/components/tree/TreeFiltering.java new file mode 100644 index 0000000000..495e6cfb96 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/tree/TreeFiltering.java @@ -0,0 +1,84 @@ +package com.vaadin.tests.components.tree;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class TreeFiltering extends TestBase {
+
+ @Override
+ public void setup() {
+
+ final Tree ccTree = new Tree();
+ addComponent(ccTree);
+ final HierarchicalContainer cont = new HierarchicalContainer();
+ cont.addContainerProperty("caption", String.class, "");
+
+ Item item;
+ for (int i = 0; i < 5; i++) {
+ item = cont.addItem(i);
+ item.getItemProperty("caption").setValue("Number " + i);
+ cont.setParent(i, i - 1);
+ }
+
+ for (int i = 0; i < 5; i++) {
+ Object id = cont.addItem();
+ item = cont.getItem(id);
+ item.getItemProperty("caption").setValue("0-" + i);
+ cont.setParent(id, 0);
+ }
+
+ ccTree.setContainerDataSource(cont);
+ ccTree.setItemCaptionPropertyId("caption");
+
+ for (final Object o : ccTree.getItemIds()) {
+ ccTree.expandItem(o);
+ }
+
+ final Button b = new Button("Add filter 'foo'", new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.addContainerFilter("caption", "foo", true, false);
+
+ }
+ });
+ addComponent(b);
+ final Button b2 = new Button("Add filter 'Num'", new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.addContainerFilter("caption", "Num", true, false);
+
+ }
+ });
+
+ addComponent(b2);
+ final Button num = new Button("Add filter '0'", new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.addContainerFilter("caption", "0", true, false);
+
+ }
+ });
+
+ addComponent(num);
+ final Button r = new Button("Remove filter", new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.removeAllContainerFilters();
+
+ }
+ });
+ addComponent(r);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Filtering in a tree should work as expected. Roots and their children which match the filter should be shown. Other nodes should be hidden";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4192;
+ }
+
+}
\ No newline at end of file diff --git a/tests/src/com/vaadin/tests/components/window/WindowScrollingUp.java b/tests/src/com/vaadin/tests/components/window/WindowScrollingUp.java new file mode 100644 index 0000000000..a97341d8b9 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/WindowScrollingUp.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class WindowScrollingUp extends AbstractTestCase {
+
+ @Override
+ protected String getDescription() {
+ return "Scroll down, click 'up' and the view should scroll to the top";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4206;
+ }
+
+ @Override
+ public void init() {
+ Table table = new Table();
+ table.setPageLength(50);
+
+ final Button up = new Button("up");
+ up.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ up.getWindow().setScrollTop(0);
+ }
+ });
+
+ setMainWindow(new Window(""));
+ getMainWindow().addComponent(table);
+ getMainWindow().addComponent(up);
+
+ }
+}
diff --git a/tests/src/com/vaadin/tests/dd/DDTest1.java b/tests/src/com/vaadin/tests/dd/DDTest1.java index e51f9fa1bc..55ef48e5e6 100644 --- a/tests/src/com/vaadin/tests/dd/DDTest1.java +++ b/tests/src/com/vaadin/tests/dd/DDTest1.java @@ -206,36 +206,34 @@ public class DDTest1 extends TestBase { VerticalDropLocation dropLocation = details .getDropLocation(); + Object itemIdAfter = itemIdOver; if (dropLocation == VerticalDropLocation.MIDDLE) { t.setParent(itemId, itemIdOver); return; } else if (VerticalDropLocation.TOP == dropLocation) { // if on top of the caption area, add before - itemIdOver = idx.prevItemId(itemIdOver); - } - - if (itemId.equals(itemIdOver)) { - // the location is same - return; - } - - HierarchicalContainer subtree = getSubTree(idx, itemId); - boolean removed = idx.removeItem(itemId); - - if (removed) { - - if (dropLocation == null) { - System.err - .println("No detail of drop place available"); + Collection children; + if (itemIdInto != null) { + // seek the previous from child list + children = idx.getChildren(itemIdInto); + } else { + children = idx.rootItemIds(); } + Object ref = null; + for (Object object : children) { + if (object.equals(itemIdOver)) { + itemIdAfter = ref; + break; + } + ref = object; + } + } + idx.setParent(itemId, itemIdInto); - Item addItemAfter = idx - .addItemAfter(itemIdOver, itemId); - populateSubTree(idx, subtree, itemId); - // ensure the same parent as with related item - Object parent = idx.getParent(itemIdOver); - idx.setParent(itemId, parent); + if (dropLocation == null) { + System.err.println("No detail of drop place available"); } + idx.moveAfterSibling(itemId, itemIdAfter); } return; diff --git a/tests/src/com/vaadin/tests/resources/NonExistingFileResource.java b/tests/src/com/vaadin/tests/resources/NonExistingFileResource.java new file mode 100644 index 0000000000..81db64dea0 --- /dev/null +++ b/tests/src/com/vaadin/tests/resources/NonExistingFileResource.java @@ -0,0 +1,47 @@ +package com.vaadin.tests.resources;
+import java.io.File;
+
+import com.vaadin.terminal.FileResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class NonExistingFileResource extends TestBase {
+
+ @Override
+ protected void setup() {
+ Button existing = createButton("WEB-INF/web.xml");
+ Button nonExisting = createButton("WEB-INF/web2.xml");
+ addComponent(existing);
+ addComponent(nonExisting);
+
+ }
+
+ private Button createButton(final String filename) {
+ Button b = new Button("Download " + filename);
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ FileResource res = new FileResource(new File(getContext()
+ .getBaseDirectory()
+ + "/" + filename), NonExistingFileResource.this);
+ getMainWindow().open(res);
+
+ }
+ });
+ return b;
+ }
+
+ @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/robustness/Robustness.java b/tests/src/com/vaadin/tests/robustness/Robustness.java index a12489a2cc..06d2ab0949 100644 --- a/tests/src/com/vaadin/tests/robustness/Robustness.java +++ b/tests/src/com/vaadin/tests/robustness/Robustness.java @@ -1,6 +1,5 @@ package com.vaadin.tests.robustness; -import com.vaadin.automatedtests.util.Log; import com.vaadin.tests.util.RandomComponents; import com.vaadin.ui.Button; import com.vaadin.ui.ComponentContainer; @@ -70,17 +69,29 @@ public abstract class Robustness extends com.vaadin.Application implements label = null; stressLayout = null; System.out.println("main.getLayout()=" + main.getLayout()); - System.out.println(Log.getMemoryStatistics()); + System.out.println(getMemoryStatistics()); } else if (event.getButton() == close) { System.out.println("Before close, memory statistics:"); - System.out.println(Log.getMemoryStatistics()); + System.out.println(getMemoryStatistics()); close(); // Still valueUnbound (session expiration) needs to occur for GC to // do its work System.out.println("After close, memory statistics:"); - System.out.println(Log.getMemoryStatistics()); + System.out.println(getMemoryStatistics()); } } + public static String getMemoryStatistics() { + // You should call gc before printing statistics (if you are not using a + // profiler) + System.gc(); + long inUse = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime() + .freeMemory()); + return "Memory:\n" + inUse + " (Used)\n" + + Runtime.getRuntime().totalMemory() + " (Total)\n" + + Runtime.getRuntime().freeMemory() + " (Free)\n"; + + } + public abstract void create(); } diff --git a/tests/src/com/vaadin/automatedtests/robustness/RobustnessComplex.java b/tests/src/com/vaadin/tests/robustness/RobustnessComplex.java index 9e72af8b86..342270cd58 100644 --- a/tests/src/com/vaadin/automatedtests/robustness/RobustnessComplex.java +++ b/tests/src/com/vaadin/tests/robustness/RobustnessComplex.java @@ -1,45 +1,44 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.automatedtests.robustness; - -import com.vaadin.automatedtests.util.Log; -import com.vaadin.ui.Button; -import com.vaadin.ui.Label; - -public class RobustnessComplex extends Robustness implements - Button.ClickListener { - - /** - * Create complex layouts with components and listeners. - */ - @Override - public void create() { - count++; - - // remove old stressLayout, all dependant components should be now - // allowed for garbage collection. - if (stressLayout != null) { - main.removeComponent(stressLayout); - } - - // create new stress layout - stressLayout = randomComponents - .getRandomComponentContainer("Component container " + count); - - Label label = new Label("Label " + Log.getMemoryStatistics(), - Label.CONTENT_PREFORMATTED); - stressLayout.addComponent(label); - - // fill with random components - randomComponents.fillLayout(stressLayout, 50); - - // add new component container to main layout - main.addComponent(stressLayout); - - // if ((count % 100) == 0) { - System.out.println("Created " + count + " times."); - // } - } -} +/*
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.robustness;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+
+public class RobustnessComplex extends Robustness implements
+ Button.ClickListener {
+
+ /**
+ * Create complex layouts with components and listeners.
+ */
+ @Override
+ public void create() {
+ count++;
+
+ // remove old stressLayout, all dependant components should be now
+ // allowed for garbage collection.
+ if (stressLayout != null) {
+ main.removeComponent(stressLayout);
+ }
+
+ // create new stress layout
+ stressLayout = randomComponents
+ .getRandomComponentContainer("Component container " + count);
+
+ Label label = new Label("Label " + getMemoryStatistics(),
+ Label.CONTENT_PREFORMATTED);
+ stressLayout.addComponent(label);
+
+ // fill with random components
+ randomComponents.fillLayout(stressLayout, 50);
+
+ // add new component container to main layout
+ main.addComponent(stressLayout);
+
+ // if ((count % 100) == 0) {
+ System.out.println("Created " + count + " times.");
+ // }
+ }
+}
diff --git a/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java b/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java index 63324ad9bc..e99fe4b5e7 100644 --- a/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java +++ b/tests/src/com/vaadin/tests/robustness/RobustnessSimple.java @@ -1,6 +1,5 @@ package com.vaadin.tests.robustness; -import com.vaadin.automatedtests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.OrderedLayout; @@ -23,7 +22,7 @@ public class RobustnessSimple extends Robustness implements // CASE single orderedlayout with a label containing 1Mb of data // fill with random components - Label label = new Label("Label " + Log.getMemoryStatistics(), + Label label = new Label("Label " + getMemoryStatistics(), Label.CONTENT_PREFORMATTED); byte[] data = new byte[1024 * 1024]; label.setData(data); diff --git a/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java b/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java new file mode 100644 index 0000000000..e95e78ddea --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/tree/TestListeners.java @@ -0,0 +1,135 @@ +package com.vaadin.tests.server.component.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.CollapseListener;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.Tree.ExpandListener;
+
+public class TestListeners extends TestCase implements ExpandListener,
+ CollapseListener {
+ private int expandCalled;
+ private int collapseCalled;
+ private Object lastExpanded;
+ private Object lastCollapsed;
+
+ @Override
+ protected void setUp() {
+ expandCalled = 0;
+ }
+
+ public void testExpandListener() {
+ Tree tree = createTree(10, 20, false);
+ tree.addListener((ExpandListener) this);
+ List<String> rootIds = new ArrayList<String>(tree.rootItemIds());
+
+ assertEquals(10, rootIds.size());
+ assertEquals(10 + 10 * 20 + 10, tree.size());
+
+ // Expanding should send one expand event for the root item id
+ tree.expandItem(rootIds.get(0));
+ assertEquals(1, expandCalled);
+ assertEquals(rootIds.get(0), lastExpanded);
+
+ // Expand should send one event for each expanded item id.
+ // In this case root + child 4
+ expandCalled = 0;
+ tree.expandItemsRecursively(rootIds.get(1));
+ assertEquals(2, expandCalled);
+ List<Object> c = new ArrayList<Object>(tree.getChildren(rootIds.get(1)));
+
+ assertEquals(c.get(4), lastExpanded);
+
+ // Expanding an already expanded item should send no expand event
+ expandCalled = 0;
+ tree.expandItem(rootIds.get(0));
+ assertEquals(0, expandCalled);
+ }
+
+ /**
+ * Creates a tree with "rootItems" roots, each with "children" children,
+ * each with 1 child.
+ *
+ * @param rootItems
+ * @param children
+ * @param expand
+ * @return
+ */
+ private Tree createTree(int rootItems, int children, boolean expand) {
+ Tree tree = new Tree();
+ for (int i = 0; i < rootItems; i++) {
+ String rootId = "root " + i;
+ tree.addItem(rootId);
+ if (expand) {
+ tree.expandItemsRecursively(rootId);
+ } else {
+ tree.collapseItemsRecursively(rootId);
+
+ }
+ for (int j = 0; j < children; j++) {
+ String childId = "child " + i + "/" + j;
+ tree.addItem(childId);
+ tree.setParent(childId, rootId);
+ tree.setChildrenAllowed(childId, false);
+ if (j == 4) {
+ tree.setChildrenAllowed(childId, true);
+ Object grandChildId = tree.addItem();
+ tree.setParent(grandChildId, childId);
+ tree.setChildrenAllowed(grandChildId, false);
+ if (expand) {
+ tree.expandItemsRecursively(childId);
+ } else {
+ tree.collapseItemsRecursively(childId);
+ }
+ }
+ }
+ }
+
+ return tree;
+ }
+
+ public void testCollapseListener() {
+ Tree tree = createTree(7, 15, true);
+ tree.addListener((CollapseListener) this);
+
+ List<String> rootIds = new ArrayList<String>(tree.rootItemIds());
+
+ assertEquals(7, rootIds.size());
+ assertEquals(7 + 7 * 15 + 7, tree.size());
+
+ // Expanding should send one expand event for the root item id
+ tree.collapseItem(rootIds.get(0));
+ assertEquals(1, collapseCalled);
+ assertEquals(rootIds.get(0), lastCollapsed);
+
+ // Collapse sends one event for each collapsed node.
+ // In this case root + child 4
+ collapseCalled = 0;
+ tree.collapseItemsRecursively(rootIds.get(1));
+ assertEquals(2, collapseCalled);
+ List<Object> c = new ArrayList<Object>(tree.getChildren(rootIds.get(1)));
+ assertEquals(c.get(4), lastCollapsed);
+
+ // Collapsing an already expanded item should send no expand event
+ collapseCalled = 0;
+ tree.collapseItem(rootIds.get(0));
+ assertEquals(0, collapseCalled);
+ }
+
+ public void nodeExpand(ExpandEvent event) {
+ lastExpanded = event.getItemId();
+ expandCalled++;
+
+ }
+
+ public void nodeCollapse(CollapseEvent event) {
+ lastCollapsed = event.getItemId();
+ collapseCalled++;
+
+ }
+}
diff --git a/tests/src/com/vaadin/tests/server/components/TestWindow.java b/tests/src/com/vaadin/tests/server/components/TestWindow.java new file mode 100644 index 0000000000..05604aba61 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/components/TestWindow.java @@ -0,0 +1,90 @@ +package com.vaadin.tests.server.components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+import com.vaadin.ui.Window.ResizeEvent;
+import com.vaadin.ui.Window.ResizeListener;
+
+public class TestWindow extends TestCase {
+
+ private Window window;
+
+ @Override
+ protected void setUp() throws Exception {
+ window = new Window();
+ }
+
+ public void testCloseListener() {
+ CloseListener cl = EasyMock.createMock(Window.CloseListener.class);
+
+ // Expectations
+ cl.windowClose(EasyMock.isA(CloseEvent.class));
+
+ // Start actual test
+ EasyMock.replay(cl);
+
+ // Add listener and send a close event -> should end up in listener once
+ window.addListener(cl);
+ sendClose(window);
+
+ // Ensure listener was called once
+ EasyMock.verify(cl);
+
+ // Remove the listener and send close event -> should not end up in
+ // listener
+ window.removeListener(cl);
+ sendClose(window);
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(cl);
+
+ }
+
+ public void testResizeListener() {
+ ResizeListener rl = EasyMock.createMock(Window.ResizeListener.class);
+
+ // Expectations
+ rl.windowResized(EasyMock.isA(ResizeEvent.class));
+
+ // Start actual test
+ EasyMock.replay(rl);
+
+ // Add listener and send a resize event -> should end up in listener
+ // once
+ window.addListener(rl);
+ sendResize(window);
+
+ // Ensure listener was called once
+ EasyMock.verify(rl);
+
+ // Remove the listener and send close event -> should not end up in
+ // listener
+ window.removeListener(rl);
+ sendResize(window);
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(rl);
+
+ }
+
+ private void sendResize(Window window2) {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("height", 1234);
+ window.changeVariables(window, variables);
+
+ }
+
+ private static void sendClose(Window window) {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("close", true);
+ window.changeVariables(window, variables);
+ }
+}
diff --git a/tests/src/com/vaadin/tests/server/container/AbstractContainerTest.java b/tests/src/com/vaadin/tests/server/container/AbstractContainerTest.java new file mode 100644 index 0000000000..e20f54dc39 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/AbstractContainerTest.java @@ -0,0 +1,509 @@ +package com.vaadin.tests.server.container;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Container.Filterable;
+import com.vaadin.data.Container.Sortable;
+
+public abstract class AbstractContainerTest extends TestCase {
+
+ protected void validateContainer(Container container,
+ Object expectedFirstItemId, Object expectedLastItemId,
+ Object itemIdInSet, Object itemIdNotInSet, int expectedSize) {
+ Container.Indexed indexed = null;
+ if (container instanceof Container.Indexed) {
+ indexed = (Container.Indexed) container;
+ }
+
+ List<Object> itemIdList = new ArrayList<Object>(container.getItemIds());
+
+ // size()
+ assertEquals(expectedSize, container.size());
+ assertEquals(expectedSize, itemIdList.size());
+
+ // first item, last item
+ Object first = itemIdList.get(0);
+ Object last = itemIdList.get(itemIdList.size() - 1);
+
+ assertEquals(expectedFirstItemId, first);
+ assertEquals(expectedLastItemId, last);
+
+ // containsId
+ assertFalse(container.containsId(itemIdNotInSet));
+ assertTrue(container.containsId(itemIdInSet));
+
+ // getItem
+ assertNull(container.getItem(itemIdNotInSet));
+ assertNotNull(container.getItem(itemIdInSet));
+
+ // getContainerProperty
+ for (Object propId : container.getContainerPropertyIds()) {
+ assertNull(container.getContainerProperty(itemIdNotInSet, propId));
+ assertNotNull(container.getContainerProperty(itemIdInSet, propId));
+ }
+
+ if (indexed != null) {
+ // firstItemId
+ assertEquals(first, indexed.firstItemId());
+
+ // lastItemId
+ assertEquals(last, indexed.lastItemId());
+
+ // nextItemId
+ assertEquals(itemIdList.get(1), indexed.nextItemId(first));
+
+ // prevItemId
+ assertEquals(itemIdList.get(itemIdList.size() - 2), indexed
+ .prevItemId(last));
+
+ // isFirstId
+ assertTrue(indexed.isFirstId(first));
+ assertFalse(indexed.isFirstId(last));
+
+ // isLastId
+ assertTrue(indexed.isLastId(last));
+ assertFalse(indexed.isLastId(first));
+
+ // indexOfId
+ assertEquals(0, indexed.indexOfId(first));
+ assertEquals(expectedSize - 1, indexed.indexOfId(last));
+
+ // getIdByIndex
+ assertEquals(indexed.getIdByIndex(0), first);
+ assertEquals(indexed.getIdByIndex(expectedSize - 1), last);
+
+ }
+
+ }
+
+ protected static final Object FULLY_QUALIFIED_NAME = "PROP1";
+ protected static final Object SIMPLE_NAME = "simplename";
+ protected static final Object REVERSE_FULLY_QUALIFIED_NAME = "PROP2";
+ protected static final Object ID_NUMBER = "PROP3";
+
+ protected void testBasicContainerOperations(Container container) {
+ initializeContainer(container);
+
+ // Basic container
+ validateContainer(container, sampleData[0],
+ sampleData[sampleData.length - 1], sampleData[10], "abc",
+ sampleData.length);
+ }
+
+ protected void testContainerOrdered(Container.Ordered container) {
+ Object id = container.addItem();
+ assertNotNull(id);
+ Item item = container.getItem(id);
+ assertNotNull(item);
+
+ assertEquals(id, container.firstItemId());
+ assertEquals(id, container.lastItemId());
+
+ // isFirstId
+ assertTrue(container.isFirstId(id));
+ assertTrue(container.isFirstId(container.firstItemId()));
+ // isLastId
+ assertTrue(container.isLastId(id));
+ assertTrue(container.isLastId(container.lastItemId()));
+
+ // Add a new item before the first
+ // addItemAfter
+ Object newFirstId = container.addItemAfter(null);
+ assertNotNull(newFirstId);
+ assertNotNull(container.getItem(newFirstId));
+
+ // isFirstId
+ assertTrue(container.isFirstId(newFirstId));
+ assertTrue(container.isFirstId(container.firstItemId()));
+ // isLastId
+ assertTrue(container.isLastId(id));
+ assertTrue(container.isLastId(container.lastItemId()));
+
+ // nextItemId
+ assertEquals(id, container.nextItemId(newFirstId));
+ assertNull(container.nextItemId(id));
+ assertNull(container.nextItemId("not-in-container"));
+
+ // prevItemId
+ assertEquals(newFirstId, container.prevItemId(id));
+ assertNull(container.prevItemId(newFirstId));
+ assertNull(container.prevItemId("not-in-container"));
+
+ // addItemAfter(Object)
+ Object newSecondItemId = container.addItemAfter(newFirstId);
+ // order is now: newFirstId, newSecondItemId, id
+ assertNotNull(newSecondItemId);
+ assertNotNull(container.getItem(newSecondItemId));
+ assertEquals(id, container.nextItemId(newSecondItemId));
+ assertEquals(newFirstId, container.prevItemId(newSecondItemId));
+
+ // addItemAfter(Object,Object)
+ String fourthId = "id of the fourth item";
+ Item fourth = container.addItemAfter(newFirstId, fourthId);
+ // order is now: newFirstId, fourthId, newSecondItemId, id
+ assertNotNull(fourth);
+ assertEquals(fourth, container.getItem(fourthId));
+ assertEquals(newSecondItemId, container.nextItemId(fourthId));
+ assertEquals(newFirstId, container.prevItemId(fourthId));
+
+ // addItemAfter(Object,Object)
+ Object fifthId = new Object();
+ Item fifth = container.addItemAfter(null, fifthId);
+ // order is now: fifthId, newFirstId, fourthId, newSecondItemId, id
+ assertNotNull(fifth);
+ assertEquals(fifth, container.getItem(fifthId));
+ assertEquals(newFirstId, container.nextItemId(fifthId));
+ assertNull(container.prevItemId(fifthId));
+
+ }
+
+ protected void testContainerFiltering(Container.Filterable container) {
+ initializeContainer(container);
+
+ // Filter by "contains ab"
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
+
+ validateContainer(container, "com.vaadin.data.BufferedValidatable",
+ "com.vaadin.ui.TabSheet",
+ "com.vaadin.terminal.gwt.client.Focusable",
+ "com.vaadin.data.Buffered", 20);
+
+ // Filter by "contains da" (reversed as ad here)
+ container.removeAllContainerFilters();
+ container.addContainerFilter(REVERSE_FULLY_QUALIFIED_NAME, "ad", false,
+ false);
+
+ validateContainer(container, "com.vaadin.data.Buffered",
+ "com.vaadin.terminal.gwt.server.ComponentSizeValidator",
+ "com.vaadin.data.util.IndexedContainer",
+ "com.vaadin.terminal.gwt.client.ui.VUriFragmentUtility", 37);
+ }
+
+ protected void testContainerSortingAndFiltering(Container.Sortable sortable) {
+ Filterable filterable = (Filterable) sortable;
+
+ initializeContainer(sortable);
+
+ // Filter by "contains ab"
+ filterable.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
+
+ // Must be able to sort based on PROP1 for this test
+ assertTrue(sortable.getSortableContainerPropertyIds().contains(
+ FULLY_QUALIFIED_NAME));
+
+ sortable.sort(new Object[] { FULLY_QUALIFIED_NAME },
+ new boolean[] { true });
+
+ validateContainer(sortable, "com.vaadin.data.BufferedValidatable",
+ "com.vaadin.ui.TableFieldFactory",
+ "com.vaadin.ui.TableFieldFactory",
+ "com.vaadin.data.util.BeanItem", 20);
+ }
+
+ protected void testContainerSorting(Container.Filterable container) {
+ Container.Sortable sortable = (Sortable) container;
+
+ initializeContainer(container);
+
+ // Must be able to sort based on PROP1 for this test
+ assertTrue(sortable.getSortableContainerPropertyIds().contains(
+ FULLY_QUALIFIED_NAME));
+ assertTrue(sortable.getSortableContainerPropertyIds().contains(
+ REVERSE_FULLY_QUALIFIED_NAME));
+
+ sortable.sort(new Object[] { FULLY_QUALIFIED_NAME },
+ new boolean[] { true });
+
+ validateContainer(container, "com.vaadin.Application",
+ "com.vaadin.util.SerializerHelper",
+ "com.vaadin.terminal.ApplicationResource", "blah",
+ sampleData.length);
+
+ sortable.sort(new Object[] { REVERSE_FULLY_QUALIFIED_NAME },
+ new boolean[] { true });
+
+ validateContainer(container,
+ "com.vaadin.terminal.gwt.server.ApplicationPortlet2",
+ "com.vaadin.data.util.ObjectProperty",
+ "com.vaadin.ui.BaseFieldFactory", "blah", sampleData.length);
+
+ }
+
+ protected void initializeContainer(Container container) {
+ container.removeAllItems();
+ Object[] propertyIds = container.getContainerPropertyIds().toArray();
+ for (Object propertyId : propertyIds) {
+ container.removeContainerProperty(propertyId);
+ }
+
+ container.addContainerProperty(FULLY_QUALIFIED_NAME, String.class, "");
+ container.addContainerProperty(SIMPLE_NAME, String.class, "");
+ container.addContainerProperty(REVERSE_FULLY_QUALIFIED_NAME,
+ String.class, null);
+ container.addContainerProperty(ID_NUMBER, Integer.class, null);
+
+ for (int i = 0; i < sampleData.length; i++) {
+ String id = sampleData[i];
+ Item item = container.addItem(id);
+
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(sampleData[i]);
+ item.getItemProperty(SIMPLE_NAME).setValue(
+ getSimpleName(sampleData[i]));
+ item.getItemProperty(REVERSE_FULLY_QUALIFIED_NAME).setValue(
+ reverse(sampleData[i]));
+ item.getItemProperty(ID_NUMBER).setValue(i);
+ }
+ }
+
+ protected String getSimpleName(String name) {
+ if (name.contains(".")) {
+ return name.substring(name.lastIndexOf('.') + 1);
+ } else {
+ return name;
+ }
+ }
+
+ protected static String reverse(String string) {
+ return new StringBuilder(string).reverse().toString();
+ }
+
+ protected final String[] sampleData = {
+ "com.vaadin.annotations.AutoGenerated", "com.vaadin.Application",
+ "com.vaadin.data.Buffered", "com.vaadin.data.BufferedValidatable",
+ "com.vaadin.data.Container", "com.vaadin.data.Item",
+ "com.vaadin.data.Property", "com.vaadin.data.util.BeanItem",
+ "com.vaadin.data.util.BeanItemContainer",
+ "com.vaadin.data.util.ContainerHierarchicalWrapper",
+ "com.vaadin.data.util.ContainerOrderedWrapper",
+ "com.vaadin.data.util.DefaultItemSorter",
+ "com.vaadin.data.util.FilesystemContainer",
+ "com.vaadin.data.util.Filter",
+ "com.vaadin.data.util.HierarchicalContainer",
+ "com.vaadin.data.util.IndexedContainer",
+ "com.vaadin.data.util.ItemSorter",
+ "com.vaadin.data.util.MethodProperty",
+ "com.vaadin.data.util.ObjectProperty",
+ "com.vaadin.data.util.PropertyFormatter",
+ "com.vaadin.data.util.PropertysetItem",
+ "com.vaadin.data.util.QueryContainer",
+ "com.vaadin.data.util.TextFileProperty",
+ "com.vaadin.data.Validatable",
+ "com.vaadin.data.validator.AbstractStringValidator",
+ "com.vaadin.data.validator.AbstractValidator",
+ "com.vaadin.data.validator.CompositeValidator",
+ "com.vaadin.data.validator.DoubleValidator",
+ "com.vaadin.data.validator.EmailValidator",
+ "com.vaadin.data.validator.IntegerValidator",
+ "com.vaadin.data.validator.NullValidator",
+ "com.vaadin.data.validator.RegexpValidator",
+ "com.vaadin.data.validator.StringLengthValidator",
+ "com.vaadin.data.Validator", "com.vaadin.event.Action",
+ "com.vaadin.event.ComponentEventListener",
+ "com.vaadin.event.EventRouter", "com.vaadin.event.FieldEvents",
+ "com.vaadin.event.ItemClickEvent", "com.vaadin.event.LayoutEvents",
+ "com.vaadin.event.ListenerMethod",
+ "com.vaadin.event.MethodEventSource",
+ "com.vaadin.event.MouseEvents", "com.vaadin.event.ShortcutAction",
+ "com.vaadin.launcher.DemoLauncher",
+ "com.vaadin.launcher.DevelopmentServerLauncher",
+ "com.vaadin.launcher.util.BrowserLauncher",
+ "com.vaadin.service.ApplicationContext",
+ "com.vaadin.service.FileTypeResolver",
+ "com.vaadin.terminal.ApplicationResource",
+ "com.vaadin.terminal.ClassResource",
+ "com.vaadin.terminal.CompositeErrorMessage",
+ "com.vaadin.terminal.DownloadStream",
+ "com.vaadin.terminal.ErrorMessage",
+ "com.vaadin.terminal.ExternalResource",
+ "com.vaadin.terminal.FileResource",
+ "com.vaadin.terminal.gwt.client.ApplicationConfiguration",
+ "com.vaadin.terminal.gwt.client.ApplicationConnection",
+ "com.vaadin.terminal.gwt.client.BrowserInfo",
+ "com.vaadin.terminal.gwt.client.ClientExceptionHandler",
+ "com.vaadin.terminal.gwt.client.ComponentDetail",
+ "com.vaadin.terminal.gwt.client.ComponentDetailMap",
+ "com.vaadin.terminal.gwt.client.ComponentLocator",
+ "com.vaadin.terminal.gwt.client.Console",
+ "com.vaadin.terminal.gwt.client.Container",
+ "com.vaadin.terminal.gwt.client.ContainerResizedListener",
+ "com.vaadin.terminal.gwt.client.CSSRule",
+ "com.vaadin.terminal.gwt.client.DateTimeService",
+ "com.vaadin.terminal.gwt.client.DefaultWidgetSet",
+ "com.vaadin.terminal.gwt.client.Focusable",
+ "com.vaadin.terminal.gwt.client.HistoryImplIEVaadin",
+ "com.vaadin.terminal.gwt.client.LocaleNotLoadedException",
+ "com.vaadin.terminal.gwt.client.LocaleService",
+ "com.vaadin.terminal.gwt.client.MouseEventDetails",
+ "com.vaadin.terminal.gwt.client.NullConsole",
+ "com.vaadin.terminal.gwt.client.Paintable",
+ "com.vaadin.terminal.gwt.client.RenderInformation",
+ "com.vaadin.terminal.gwt.client.RenderSpace",
+ "com.vaadin.terminal.gwt.client.StyleConstants",
+ "com.vaadin.terminal.gwt.client.TooltipInfo",
+ "com.vaadin.terminal.gwt.client.ui.Action",
+ "com.vaadin.terminal.gwt.client.ui.ActionOwner",
+ "com.vaadin.terminal.gwt.client.ui.AlignmentInfo",
+ "com.vaadin.terminal.gwt.client.ui.CalendarEntry",
+ "com.vaadin.terminal.gwt.client.ui.ClickEventHandler",
+ "com.vaadin.terminal.gwt.client.ui.Field",
+ "com.vaadin.terminal.gwt.client.ui.Icon",
+ "com.vaadin.terminal.gwt.client.ui.layout.CellBasedLayout",
+ "com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer",
+ "com.vaadin.terminal.gwt.client.ui.layout.Margins",
+ "com.vaadin.terminal.gwt.client.ui.LayoutClickEventHandler",
+ "com.vaadin.terminal.gwt.client.ui.MenuBar",
+ "com.vaadin.terminal.gwt.client.ui.MenuItem",
+ "com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea",
+ "com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextToolbar",
+ "com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler",
+ "com.vaadin.terminal.gwt.client.ui.SubPartAware",
+ "com.vaadin.terminal.gwt.client.ui.Table",
+ "com.vaadin.terminal.gwt.client.ui.TreeAction",
+ "com.vaadin.terminal.gwt.client.ui.TreeImages",
+ "com.vaadin.terminal.gwt.client.ui.VAbsoluteLayout",
+ "com.vaadin.terminal.gwt.client.ui.VAccordion",
+ "com.vaadin.terminal.gwt.client.ui.VButton",
+ "com.vaadin.terminal.gwt.client.ui.VCalendarPanel",
+ "com.vaadin.terminal.gwt.client.ui.VCheckBox",
+ "com.vaadin.terminal.gwt.client.ui.VContextMenu",
+ "com.vaadin.terminal.gwt.client.ui.VCssLayout",
+ "com.vaadin.terminal.gwt.client.ui.VCustomComponent",
+ "com.vaadin.terminal.gwt.client.ui.VCustomLayout",
+ "com.vaadin.terminal.gwt.client.ui.VDateField",
+ "com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar",
+ "com.vaadin.terminal.gwt.client.ui.VEmbedded",
+ "com.vaadin.terminal.gwt.client.ui.VFilterSelect",
+ "com.vaadin.terminal.gwt.client.ui.VForm",
+ "com.vaadin.terminal.gwt.client.ui.VFormLayout",
+ "com.vaadin.terminal.gwt.client.ui.VGridLayout",
+ "com.vaadin.terminal.gwt.client.ui.VHorizontalLayout",
+ "com.vaadin.terminal.gwt.client.ui.VLabel",
+ "com.vaadin.terminal.gwt.client.ui.VLink",
+ "com.vaadin.terminal.gwt.client.ui.VListSelect",
+ "com.vaadin.terminal.gwt.client.ui.VMarginInfo",
+ "com.vaadin.terminal.gwt.client.ui.VMenuBar",
+ "com.vaadin.terminal.gwt.client.ui.VNativeButton",
+ "com.vaadin.terminal.gwt.client.ui.VNativeSelect",
+ "com.vaadin.terminal.gwt.client.ui.VNotification",
+ "com.vaadin.terminal.gwt.client.ui.VOptionGroup",
+ "com.vaadin.terminal.gwt.client.ui.VOptionGroupBase",
+ "com.vaadin.terminal.gwt.client.ui.VOrderedLayout",
+ "com.vaadin.terminal.gwt.client.ui.VOverlay",
+ "com.vaadin.terminal.gwt.client.ui.VPanel",
+ "com.vaadin.terminal.gwt.client.ui.VPasswordField",
+ "com.vaadin.terminal.gwt.client.ui.VPopupCalendar",
+ "com.vaadin.terminal.gwt.client.ui.VPopupView",
+ "com.vaadin.terminal.gwt.client.ui.VProgressIndicator",
+ "com.vaadin.terminal.gwt.client.ui.VScrollTable",
+ "com.vaadin.terminal.gwt.client.ui.VSlider",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanel",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical",
+ "com.vaadin.terminal.gwt.client.ui.VTablePaging",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheet",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheetBase",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheetPanel",
+ "com.vaadin.terminal.gwt.client.ui.VTextArea",
+ "com.vaadin.terminal.gwt.client.ui.VTextField",
+ "com.vaadin.terminal.gwt.client.ui.VTextualDate",
+ "com.vaadin.terminal.gwt.client.ui.VTime",
+ "com.vaadin.terminal.gwt.client.ui.VTree",
+ "com.vaadin.terminal.gwt.client.ui.VTwinColSelect",
+ "com.vaadin.terminal.gwt.client.ui.VUnknownComponent",
+ "com.vaadin.terminal.gwt.client.ui.VUpload",
+ "com.vaadin.terminal.gwt.client.ui.VUriFragmentUtility",
+ "com.vaadin.terminal.gwt.client.ui.VVerticalLayout",
+ "com.vaadin.terminal.gwt.client.ui.VView",
+ "com.vaadin.terminal.gwt.client.ui.VWindow",
+ "com.vaadin.terminal.gwt.client.UIDL",
+ "com.vaadin.terminal.gwt.client.Util",
+ "com.vaadin.terminal.gwt.client.ValueMap",
+ "com.vaadin.terminal.gwt.client.VCaption",
+ "com.vaadin.terminal.gwt.client.VCaptionWrapper",
+ "com.vaadin.terminal.gwt.client.VDebugConsole",
+ "com.vaadin.terminal.gwt.client.VErrorMessage",
+ "com.vaadin.terminal.gwt.client.VTooltip",
+ "com.vaadin.terminal.gwt.client.VUIDLBrowser",
+ "com.vaadin.terminal.gwt.client.WidgetMap",
+ "com.vaadin.terminal.gwt.client.WidgetSet",
+ "com.vaadin.terminal.gwt.server.AbstractApplicationPortlet",
+ "com.vaadin.terminal.gwt.server.AbstractApplicationServlet",
+ "com.vaadin.terminal.gwt.server.AbstractCommunicationManager",
+ "com.vaadin.terminal.gwt.server.AbstractWebApplicationContext",
+ "com.vaadin.terminal.gwt.server.ApplicationPortlet",
+ "com.vaadin.terminal.gwt.server.ApplicationPortlet2",
+ "com.vaadin.terminal.gwt.server.ApplicationRunnerServlet",
+ "com.vaadin.terminal.gwt.server.ApplicationServlet",
+ "com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent",
+ "com.vaadin.terminal.gwt.server.CommunicationManager",
+ "com.vaadin.terminal.gwt.server.ComponentSizeValidator",
+ "com.vaadin.terminal.gwt.server.Constants",
+ "com.vaadin.terminal.gwt.server.GAEApplicationServlet",
+ "com.vaadin.terminal.gwt.server.HttpServletRequestListener",
+ "com.vaadin.terminal.gwt.server.HttpUploadStream",
+ "com.vaadin.terminal.gwt.server.JsonPaintTarget",
+ "com.vaadin.terminal.gwt.server.PortletApplicationContext",
+ "com.vaadin.terminal.gwt.server.PortletApplicationContext2",
+ "com.vaadin.terminal.gwt.server.PortletCommunicationManager",
+ "com.vaadin.terminal.gwt.server.PortletRequestListener",
+ "com.vaadin.terminal.gwt.server.RestrictedRenderResponse",
+ "com.vaadin.terminal.gwt.server.SessionExpiredException",
+ "com.vaadin.terminal.gwt.server.SystemMessageException",
+ "com.vaadin.terminal.gwt.server.WebApplicationContext",
+ "com.vaadin.terminal.gwt.server.WebBrowser",
+ "com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer",
+ "com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator",
+ "com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder",
+ "com.vaadin.terminal.KeyMapper", "com.vaadin.terminal.Paintable",
+ "com.vaadin.terminal.PaintException",
+ "com.vaadin.terminal.PaintTarget",
+ "com.vaadin.terminal.ParameterHandler",
+ "com.vaadin.terminal.Resource", "com.vaadin.terminal.Scrollable",
+ "com.vaadin.terminal.Sizeable",
+ "com.vaadin.terminal.StreamResource",
+ "com.vaadin.terminal.SystemError", "com.vaadin.terminal.Terminal",
+ "com.vaadin.terminal.ThemeResource",
+ "com.vaadin.terminal.UploadStream",
+ "com.vaadin.terminal.URIHandler", "com.vaadin.terminal.UserError",
+ "com.vaadin.terminal.VariableOwner",
+ "com.vaadin.tools.ReflectTools",
+ "com.vaadin.tools.WidgetsetCompiler",
+ "com.vaadin.ui.AbsoluteLayout", "com.vaadin.ui.AbstractComponent",
+ "com.vaadin.ui.AbstractComponentContainer",
+ "com.vaadin.ui.AbstractField", "com.vaadin.ui.AbstractLayout",
+ "com.vaadin.ui.AbstractOrderedLayout",
+ "com.vaadin.ui.AbstractSelect", "com.vaadin.ui.Accordion",
+ "com.vaadin.ui.Alignment", "com.vaadin.ui.AlignmentUtils",
+ "com.vaadin.ui.BaseFieldFactory", "com.vaadin.ui.Button",
+ "com.vaadin.ui.CheckBox", "com.vaadin.ui.ClientWidget",
+ "com.vaadin.ui.ComboBox", "com.vaadin.ui.Component",
+ "com.vaadin.ui.ComponentContainer", "com.vaadin.ui.CssLayout",
+ "com.vaadin.ui.CustomComponent", "com.vaadin.ui.CustomLayout",
+ "com.vaadin.ui.DateField", "com.vaadin.ui.DefaultFieldFactory",
+ "com.vaadin.ui.Embedded", "com.vaadin.ui.ExpandLayout",
+ "com.vaadin.ui.Field", "com.vaadin.ui.FieldFactory",
+ "com.vaadin.ui.Form", "com.vaadin.ui.FormFieldFactory",
+ "com.vaadin.ui.FormLayout", "com.vaadin.ui.GridLayout",
+ "com.vaadin.ui.HorizontalLayout", "com.vaadin.ui.InlineDateField",
+ "com.vaadin.ui.Label", "com.vaadin.ui.Layout",
+ "com.vaadin.ui.Link", "com.vaadin.ui.ListSelect",
+ "com.vaadin.ui.LoginForm", "com.vaadin.ui.MenuBar",
+ "com.vaadin.ui.NativeButton", "com.vaadin.ui.NativeSelect",
+ "com.vaadin.ui.OptionGroup", "com.vaadin.ui.OrderedLayout",
+ "com.vaadin.ui.Panel", "com.vaadin.ui.PopupDateField",
+ "com.vaadin.ui.PopupView", "com.vaadin.ui.ProgressIndicator",
+ "com.vaadin.ui.RichTextArea", "com.vaadin.ui.Select",
+ "com.vaadin.ui.Slider", "com.vaadin.ui.SplitPanel",
+ "com.vaadin.ui.Table", "com.vaadin.ui.TableFieldFactory",
+ "com.vaadin.ui.TabSheet", "com.vaadin.ui.TextField",
+ "com.vaadin.ui.Tree", "com.vaadin.ui.TwinColSelect",
+ "com.vaadin.ui.Upload", "com.vaadin.ui.UriFragmentUtility",
+ "com.vaadin.ui.VerticalLayout", "com.vaadin.ui.Window",
+ "com.vaadin.util.SerializerHelper" };
+
+}
diff --git a/tests/src/com/vaadin/tests/server/container/AbstractHierarchicalContainerTest.java b/tests/src/com/vaadin/tests/server/container/AbstractHierarchicalContainerTest.java new file mode 100644 index 0000000000..7aeef3e1b1 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/AbstractHierarchicalContainerTest.java @@ -0,0 +1,300 @@ +package com.vaadin.tests.server.container;
+
+import java.util.Collection;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Container.Hierarchical;
+import com.vaadin.data.Container.Sortable;
+
+public class AbstractHierarchicalContainerTest extends AbstractContainerTest {
+
+ /**
+ * @param container
+ * The container to validate
+ * @param expectedFirstItemId
+ * Expected first item id
+ * @param expectedLastItemId
+ * Expected last item id
+ * @param itemIdInSet
+ * An item id that is in the container
+ * @param itemIdNotInSet
+ * An item id that is not in the container
+ * @param expectedSize
+ * Expected number of items in the container. Not related to
+ * hierarchy.
+ * @param expectedTraversalSize
+ * Expected number of items found when traversing from the roots
+ * down to all available nodes.
+ * @param expectedRootSize
+ * Expected number of root items
+ */
+ private void validateHierarchicalContainer(Hierarchical container,
+ Object expectedFirstItemId, Object expectedLastItemId,
+ Object itemIdInSet, Object itemIdNotInSet,
+ boolean rootsHaveChildren, int expectedSize,
+ int expectedTraversalSize, int expectedRootSize) {
+
+ validateContainer(container, expectedFirstItemId, expectedLastItemId,
+ itemIdInSet, itemIdNotInSet, expectedSize);
+
+ // rootItemIds
+ Collection<?> rootIds = container.rootItemIds();
+ assertEquals(expectedRootSize, rootIds.size());
+
+ for (Object rootId : rootIds) {
+ // All roots must be in container
+ assertTrue(container.containsId(rootId));
+
+ // All roots must have no parent
+ assertNull(container.getParent(rootId));
+
+ // all roots must be roots
+ assertTrue(container.isRoot(rootId));
+
+ // all roots have children allowed in this case
+ assertTrue(container.areChildrenAllowed(rootId));
+
+ // all roots have children in this case
+ if (rootsHaveChildren) {
+ Collection<?> children = container.getChildren(rootId);
+ assertNotNull(rootId + " should have children", children);
+ assertTrue(rootId + " should have children",
+ (children.size() > 0));
+
+ // getParent
+ for (Object childId : children) {
+ assertEquals(container.getParent(childId), rootId);
+ }
+ } else {
+
+ }
+ }
+
+ // isRoot should return false for unknown items
+ assertFalse(container.isRoot(itemIdNotInSet));
+
+ // hasChildren should return false for unknown items
+ assertFalse(container.hasChildren(itemIdNotInSet));
+
+ // areChildrenAllowed should return false for unknown items
+ assertFalse(container.areChildrenAllowed(itemIdNotInSet));
+
+ // removeItem of unknown items should return false
+ assertFalse(container.removeItem(itemIdNotInSet));
+
+ assertEquals(expectedTraversalSize, countNodes(container));
+
+ validateHierarchy(container);
+ }
+
+ private int countNodes(Hierarchical container) {
+ int totalNodes = 0;
+ for (Object rootId : container.rootItemIds()) {
+ totalNodes += countNodes(container, rootId);
+ }
+
+ return totalNodes;
+ }
+
+ private int countNodes(Hierarchical container, Object itemId) {
+ int nodes = 1; // This
+ Collection<?> children = container.getChildren(itemId);
+ if (children != null) {
+ for (Object id : children) {
+ nodes += countNodes(container, id);
+ }
+ }
+
+ return nodes;
+ }
+
+ private void validateHierarchy(Hierarchical container) {
+ for (Object rootId : container.rootItemIds()) {
+ validateHierarchy(container, rootId, null);
+ }
+ }
+
+ private void validateHierarchy(Hierarchical container, Object itemId,
+ Object parentId) {
+ Collection<?> children = container.getChildren(itemId);
+
+ // getParent
+ assertEquals(container.getParent(itemId), parentId);
+
+ if (!container.areChildrenAllowed(itemId)) {
+ // If no children is allowed the item should have no children
+ assertFalse(container.hasChildren(itemId));
+ assertTrue(children == null || children.size() == 0);
+
+ return;
+ }
+ if (children != null) {
+ for (Object id : children) {
+ validateHierarchy(container, id, itemId);
+ }
+ }
+ }
+
+ protected void testHierarchicalContainer(Container.Hierarchical container) {
+ initializeContainer(container);
+
+ int packages = 21;
+ int expectedSize = sampleData.length + packages;
+ validateHierarchicalContainer(container, "com",
+ "com.vaadin.util.SerializerHelper",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ expectedSize, expectedSize, 1);
+
+ }
+
+ protected void testHierarchicalSorting(Container.Hierarchical container) {
+ Container.Sortable sortable = (Sortable) container;
+
+ initializeContainer(container);
+
+ // Must be able to sort based on PROP1 and PROP2 for this test
+ assertTrue(sortable.getSortableContainerPropertyIds().contains(
+ FULLY_QUALIFIED_NAME));
+ assertTrue(sortable.getSortableContainerPropertyIds().contains(
+ REVERSE_FULLY_QUALIFIED_NAME));
+
+ sortable.sort(new Object[] { FULLY_QUALIFIED_NAME },
+ new boolean[] { true });
+
+ int packages = 21;
+ int expectedSize = sampleData.length + packages;
+ validateHierarchicalContainer(container, "com",
+ "com.vaadin.util.SerializerHelper",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ expectedSize, expectedSize, 1);
+
+ sortable.sort(new Object[] { REVERSE_FULLY_QUALIFIED_NAME },
+ new boolean[] { true });
+
+ validateHierarchicalContainer(container,
+ "com.vaadin.terminal.gwt.server.ApplicationPortlet2",
+ "com.vaadin.data.util.ObjectProperty",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ expectedSize, expectedSize, 1);
+
+ }
+
+ protected void testHierarchicalFiltering(Container.Hierarchical container) {
+ Container.Filterable filterable = (Container.Filterable) container;
+
+ initializeContainer(container);
+
+ // Filter by "contains ab"
+ filterable.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
+
+ // 20 items should remain in the container but the root should be
+ // filtered
+ int expectedSize = 20;
+ int expectedTraversalSize = 0;
+ int expectedRoots = 0;
+
+ validateHierarchicalContainer(container,
+ "com.vaadin.data.BufferedValidatable",
+ "com.vaadin.ui.TabSheet",
+ "com.vaadin.terminal.gwt.client.Focusable", "blah", true,
+ expectedSize, expectedTraversalSize, expectedRoots);
+
+ // filter out every second item except hierarchy items
+ filterable.removeAllContainerFilters();
+ filterable.addContainerFilter(ID_NUMBER, "1", false, false);
+
+ int packages = 21;
+ int other = sampleData.length / 2;
+
+ expectedSize = packages + other;
+ expectedRoots = 1;
+ expectedTraversalSize = expectedSize;
+
+ validateHierarchicalContainer(container, "com", "com.vaadin.util",
+ "com.vaadin.data.util.IndexedContainer", "blah", true,
+ expectedSize, expectedTraversalSize, expectedRoots);
+
+ // Additionally remove all without 'm' in the simple name. Hierarchy is
+ // now one root only.
+ filterable.addContainerFilter(SIMPLE_NAME, "m", false, false);
+
+ expectedSize = 27;
+ expectedRoots = 1;
+ expectedTraversalSize = 1;
+
+ validateHierarchicalContainer(container, "com",
+ "com.vaadin.ui.UriFragmentUtility",
+ "com.vaadin.terminal.gwt.client.ui.TreeImages", "blah", false,
+ expectedSize, expectedTraversalSize, expectedRoots);
+
+ }
+
+ protected void initializeContainer(Container.Hierarchical container) {
+ container.removeAllItems();
+ Object[] propertyIds = container.getContainerPropertyIds().toArray();
+ for (Object propertyId : propertyIds) {
+ container.removeContainerProperty(propertyId);
+ }
+
+ container.addContainerProperty(FULLY_QUALIFIED_NAME, String.class, "");
+ container.addContainerProperty(SIMPLE_NAME, String.class, "");
+ container.addContainerProperty(REVERSE_FULLY_QUALIFIED_NAME,
+ String.class, null);
+ container.addContainerProperty(ID_NUMBER, Integer.class, null);
+
+ for (int i = 0; i < sampleData.length; i++) {
+ String id = sampleData[i];
+
+ // Add path as parent
+ String paths[] = id.split("\\.");
+ String path = paths[0];
+ // Adds "com" and other items multiple times so should return null
+ // for all but the first time
+ if (container.addItem(path) != null) {
+ assertTrue(container.setChildrenAllowed(path, false));
+ Item item = container.getItem(path);
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(path);
+ item.getItemProperty(SIMPLE_NAME).setValue(getSimpleName(path));
+ item.getItemProperty(REVERSE_FULLY_QUALIFIED_NAME).setValue(
+ reverse(path));
+ item.getItemProperty(ID_NUMBER).setValue(1);
+ }
+ for (int j = 1; j < paths.length; j++) {
+ String parent = path;
+ path = path + "." + paths[j];
+
+ // Adds "com" and other items multiple times so should return
+ // null for all but the first time
+ if (container.addItem(path) != null) {
+ assertTrue(container.setChildrenAllowed(path, false));
+
+ Item item = container.getItem(path);
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(path);
+ item.getItemProperty(SIMPLE_NAME).setValue(
+ getSimpleName(path));
+ item.getItemProperty(REVERSE_FULLY_QUALIFIED_NAME)
+ .setValue(reverse(path));
+ item.getItemProperty(ID_NUMBER).setValue(1);
+
+ }
+ assertTrue(container.setChildrenAllowed(parent, true));
+ assertTrue(
+ "Failed to set " + parent + " as parent for " + path,
+ container.setParent(path, parent));
+ }
+
+ Item item = container.getItem(id);
+ assertNotNull(item);
+ String parent = id.substring(0, id.lastIndexOf('.'));
+ assertTrue(container.setParent(id, parent));
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(sampleData[i]);
+ item.getItemProperty(SIMPLE_NAME).setValue(
+ getSimpleName(sampleData[i]));
+ item.getItemProperty(REVERSE_FULLY_QUALIFIED_NAME).setValue(
+ reverse(sampleData[i]));
+ item.getItemProperty(ID_NUMBER).setValue(i % 2);
+ }
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/server/container/TestContainerHierarchicalWrapper.java b/tests/src/com/vaadin/tests/server/container/TestContainerHierarchicalWrapper.java new file mode 100644 index 0000000000..0ac5e76c64 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/TestContainerHierarchicalWrapper.java @@ -0,0 +1,19 @@ +package com.vaadin.tests.server.container;
+
+import com.vaadin.data.util.ContainerHierarchicalWrapper;
+import com.vaadin.data.util.IndexedContainer;
+
+public class TestContainerHierarchicalWrapper extends
+ AbstractHierarchicalContainerTest {
+
+ public void testBasicOperations() {
+ testBasicContainerOperations(new ContainerHierarchicalWrapper(
+ new IndexedContainer()));
+ }
+
+ public void testHierarchicalContainer() {
+ testHierarchicalContainer(new ContainerHierarchicalWrapper(
+ new IndexedContainer()));
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java b/tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java new file mode 100644 index 0000000000..0f60e133c1 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/TestHierarchicalContainer.java @@ -0,0 +1,40 @@ +package com.vaadin.tests.server.container;
+
+import com.vaadin.data.util.HierarchicalContainer;
+
+public class TestHierarchicalContainer extends
+ AbstractHierarchicalContainerTest {
+
+ public void testBasicOperations() {
+ testBasicContainerOperations(new HierarchicalContainer());
+ }
+
+ public void testFiltering() {
+ testContainerFiltering(new HierarchicalContainer());
+ }
+
+ public void testHierarchicalFiltering() {
+ testHierarchicalFiltering(new HierarchicalContainer());
+ }
+
+ public void testSorting() {
+ testContainerSorting(new HierarchicalContainer());
+ }
+
+ public void testOrdered() {
+ testContainerOrdered(new HierarchicalContainer());
+ }
+
+ public void testHierarchicalSorting() {
+ testHierarchicalSorting(new HierarchicalContainer());
+ }
+
+ public void testSortingAndFiltering() {
+ testContainerSortingAndFiltering(new HierarchicalContainer());
+ }
+
+ // public void testHierarchicalSortingAndFiltering() {
+ // testHierarchicalSortingAndFiltering(new HierarchicalContainer());
+ // }
+
+}
diff --git a/tests/src/com/vaadin/tests/server/container/TestIndexedContainer.java b/tests/src/com/vaadin/tests/server/container/TestIndexedContainer.java new file mode 100644 index 0000000000..13e8e17c48 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/container/TestIndexedContainer.java @@ -0,0 +1,27 @@ +package com.vaadin.tests.server.container;
+
+import com.vaadin.data.util.IndexedContainer;
+
+public class TestIndexedContainer extends AbstractContainerTest {
+
+ public void testBasicOperations() {
+ testBasicContainerOperations(new IndexedContainer());
+ }
+
+ public void testFiltering() {
+ testContainerFiltering(new IndexedContainer());
+ }
+
+ public void testSorting() {
+ testContainerSorting(new IndexedContainer());
+ }
+
+ public void testSortingAndFiltering() {
+ testContainerSortingAndFiltering(new IndexedContainer());
+ }
+
+ public void testContainerOrdered() {
+ testContainerOrdered(new IndexedContainer());
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1902.java b/tests/src/com/vaadin/tests/tickets/Ticket1902.java deleted file mode 100644 index 716b6b94f0..0000000000 --- a/tests/src/com/vaadin/tests/tickets/Ticket1902.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.vaadin.tests.tickets; - -import com.vaadin.Application; -import com.vaadin.ui.Button; -import com.vaadin.ui.OrderedLayout; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; - -public class Ticket1902 extends Application { - - @Override - public void init() { - - // Main layout and main window - final OrderedLayout mainLayout = new OrderedLayout(); - setMainWindow(new Window("Testcase for #1902", mainLayout)); - setTheme("tests-tickets"); - mainLayout.setMargin(false); - mainLayout.setSpacing(true); - mainLayout.addComponent(new Button("mainLayout.setSizeFull()", - new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - mainLayout.setSizeFull(); - getMainWindow().showNotification( - "Set the main layout size full"); - } - })); - mainLayout.addComponent(new Button("mainLayout.setWidth(\"100%\")", - new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - mainLayout.setWidth("100%"); - getMainWindow().showNotification( - "Set the main layout width 100%"); - } - })); - - // 100% wide component - TextField b2 = new TextField("100% wide field"); - mainLayout.addComponent(b2); - b2.setWidth("100%"); - - // 400px wide colored layout - OrderedLayout lo = new OrderedLayout(); - lo.setStyleName("red-background"); - mainLayout.addComponent(lo); - lo.setWidth(400); - - Button b = new Button("100% wide button"); - lo.addComponent(b); - b.setWidth("100%"); - - TextField tf = new TextField("100% wide textfield"); - lo.addComponent(tf); - tf.setWidth("100%"); - - // 400x100 colored layout - OrderedLayout lo2 = new OrderedLayout(); - lo2.setStyleName("red-background"); - mainLayout.addComponent(lo2); - lo2.setWidth("50%"); - lo2.setHeight(200); - - Button b3 = new Button("100% wide button"); - lo2.addComponent(b3); - b3.setWidth("100%"); - - TextField tf2 = new TextField("100% wide textfield"); - lo2.addComponent(tf2); - tf2.setWidth("100%"); - // tf2 = new TextField("50% wide, 100% height textfield"); // does not - // work with caption (10.7.2008 mac hosted mode) due layouts are broken - // in trunk - tf2 = new TextField(); - tf2.setRows(2); // trigger textArea impl. - tf2.setHeight("100%"); - tf2.setWidth("50%"); - lo2.addComponent(tf2); - } -}
\ No newline at end of file diff --git a/tests/src/com/vaadin/tests/tickets/Ticket1934.java b/tests/src/com/vaadin/tests/tickets/Ticket1934.java deleted file mode 100644 index b80dfc07e0..0000000000 --- a/tests/src/com/vaadin/tests/tickets/Ticket1934.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.vaadin.tests.tickets; - -import com.vaadin.Application; -import com.vaadin.ui.Button; -import com.vaadin.ui.ExpandLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Window; - -public class Ticket1934 extends Application { - - @Override - public void init() { - Window w = new Window( - "#1934 : Horizontal ExpandLayout completely broken"); - setMainWindow(w); - w.addComponent(new Label( - "Horizontal 500x200 ExpandLayout with two components:")); - - ExpandLayout testedLayout = new ExpandLayout( - ExpandLayout.ORIENTATION_HORIZONTAL); - testedLayout.setWidth("500px"); - testedLayout.setHeight("200px"); - - Button b1 = new Button("b1"); - testedLayout.addComponent(b1); - testedLayout.expand(b1); - testedLayout.addComponent(new Button("b2")); - - w.addComponent(testedLayout); - } - -} diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2032.java b/tests/src/com/vaadin/tests/tickets/Ticket2032.java deleted file mode 100644 index f51984f336..0000000000 --- a/tests/src/com/vaadin/tests/tickets/Ticket2032.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.ExpandLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2032 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setLayout(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- ExpandLayout el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
- Panel p = new Panel(el);
- p.setWidth(600);
- p.setHeight(500);
- p.getLayout().setSizeFull();
-
- TextField tf = new TextField("Field caption");
- tf.setValue("Expanded");
- el.addComponent(tf);
- el.expand(tf);
- tf.setSizeFull();
-
- tf = new TextField("Vertical bottom");
- // tf.setComponentError(new UserError("Error"));
- tf.setValue("Vertical bottom");
- el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- ExpandLayout.ALIGNMENT_BOTTOM);
- el.addComponent(tf);
-
- tf = new TextField("Vertical top");
- tf.setComponentError(new UserError("Error"));
- el.addComponent(tf);
- tf.setValue("Vertical top");
- el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- ExpandLayout.ALIGNMENT_TOP);
- tf = new TextField("Vertical center");
- el.addComponent(tf);
- tf.setValue("Vertical center");
- // tf.setComponentError(new UserError("Error"));
- el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- ExpandLayout.ALIGNMENT_VERTICAL_CENTER);
-
- layout.addComponent(p);
- }
-}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2033.java b/tests/src/com/vaadin/tests/tickets/Ticket2033.java deleted file mode 100644 index 744195619e..0000000000 --- a/tests/src/com/vaadin/tests/tickets/Ticket2033.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.ExpandLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.OrderedLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2033 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(2, 2);
- w.setLayout(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- layout.addComponent(createExpandLayoutPanel());
- layout.addComponent(createOrderedLayoutPanel());
- layout.addComponent(createGridLayoutPanel());
- }
-
- private Panel createExpandLayoutPanel() {
- ExpandLayout el = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);
- Panel p = new Panel("ExpandLayout", el);
- p.setWidth(600);
- p.setHeight(500);
- p.getLayout().setSizeFull();
-
- TextField tf = new TextField("TextField 1");
- tf.setValue("Expanded");
- el.addComponent(tf);
- el.expand(tf);
- tf.setSizeFull();
-
- tf = new TextField("TextField 2 has a longer caption");
- // tf.setComponentError(new UserError("Error"));
- tf.setWidth(100);
- tf.setValue("Vertical bottom");
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_BOTTOM);
- el.addComponent(tf);
-
- tf = new TextField(
- "TextField 3 has a very, very long caption for some weird reason.");
- tf.setWidth(100);
- tf.setComponentError(new UserError("Error"));
- el.addComponent(tf);
- tf.setValue("Vertical top");
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_TOP);
- tf = new TextField("TextField 4");
- el.addComponent(tf);
- tf.setValue("Vertical center");
- // tf.setComponentError(new UserError("Error"));
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_VERTICAL_CENTER);
-
- return p;
- }
-
- private Panel createOrderedLayoutPanel() {
- OrderedLayout ol = new OrderedLayout(
- ExpandLayout.ORIENTATION_HORIZONTAL);
- Panel p = new Panel("OrderedLayout", ol);
- p.setWidth(600);
- p.setHeight(500);
- p.getLayout().setSizeFull();
-
- TextField tf = new TextField("TextField 1");
- tf.setValue("Expanded");
- ol.addComponent(tf);
- // ol.expand(tf);
- tf.setSizeFull();
-
- tf = new TextField("TextField 2 has a longer caption");
- // tf.setComponentError(new UserError("Error"));
- tf.setWidth(100);
- tf.setValue("Vertical bottom");
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_BOTTOM);
- ol.addComponent(tf);
-
- tf = new TextField(
- "TextField 3 has a very, very long caption for some weird reason.");
- tf.setWidth(100);
- tf.setComponentError(new UserError("Error"));
- ol.addComponent(tf);
- tf.setValue("Vertical top");
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_TOP);
- tf = new TextField("TextField 4");
- ol.addComponent(tf);
- tf.setValue("Vertical center");
- // tf.setComponentError(new UserError("Error"));
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_VERTICAL_CENTER);
-
- return p;
- }
-
- private Panel createGridLayoutPanel() {
- GridLayout gl = new GridLayout(4, 1);
- Panel p = new Panel("GridLayout", gl);
- p.setWidth(600);
- p.setHeight(500);
- p.getLayout().setSizeFull();
-
- TextField tf = new TextField("TextField 1");
- tf.setValue("Expanded");
- gl.addComponent(tf);
- // ol.expand(tf);
- tf.setSizeFull();
-
- tf = new TextField("TextField 2 has a longer caption");
- // tf.setComponentError(new UserError("Error"));
- tf.setWidth(100);
- tf.setValue("Vertical bottom");
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_BOTTOM);
- gl.addComponent(tf);
-
- tf = new TextField(
- "TextField 3 has a very, very long caption for some weird reason.");
- tf.setWidth(100);
- tf.setComponentError(new UserError("Error"));
- gl.addComponent(tf);
- tf.setValue("Vertical top");
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_TOP);
- tf = new TextField("TextField 4");
- gl.addComponent(tf);
- tf.setValue("Vertical center");
- // tf.setComponentError(new UserError("Error"));
- // el.setComponentAlignment(tf, ExpandLayout.ALIGNMENT_LEFT,
- // ExpandLayout.ALIGNMENT_VERTICAL_CENTER);
-
- return p;
- }
-}
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket2061c.java b/tests/src/com/vaadin/tests/tickets/Ticket2061c.java index 77381dcbfd..9f4b754325 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket2061c.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket2061c.java @@ -8,12 +8,11 @@ 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.Label; -import com.vaadin.ui.OrderedLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; @@ -28,14 +27,14 @@ public class Ticket2061c extends Application implements public void init() { mainWindow = new Window("Vaadin"); mainWindow.setSizeFull(); - mainWindow.getLayout().setSizeFull(); + mainWindow.getContent().setSizeFull(); setMainWindow(mainWindow); - OrderedLayout ol = new OrderedLayout(); + VerticalLayout ol = new VerticalLayout(); ol.setWidth("200px"); ol.setHeight("200px"); - OrderedLayout ol2 = new OrderedLayout(); + VerticalLayout ol2 = new VerticalLayout(); ol2.setSizeFull(); p = new Panel("This is a panel"); @@ -63,7 +62,7 @@ public class Ticket2061c 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/util/RandomComponents.java b/tests/src/com/vaadin/tests/util/RandomComponents.java index fdfb878e04..bb64450ac7 100644 --- a/tests/src/com/vaadin/tests/util/RandomComponents.java +++ b/tests/src/com/vaadin/tests/util/RandomComponents.java @@ -3,9 +3,11 @@ package com.vaadin.tests.util; import java.util.ArrayList; import java.util.Random; -import com.vaadin.automatedtests.util.MultiListener; +import com.vaadin.data.Container.ItemSetChangeEvent; import com.vaadin.data.Container.ItemSetChangeListener; +import com.vaadin.data.Container.PropertySetChangeEvent; import com.vaadin.data.Container.PropertySetChangeListener; +import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.demo.featurebrowser.ButtonExample; import com.vaadin.demo.featurebrowser.ClientCachingExample; @@ -37,6 +39,7 @@ import com.vaadin.ui.Panel; import com.vaadin.ui.Select; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TextField; +import com.vaadin.ui.Button.ClickEvent; public class RandomComponents { @@ -271,4 +274,29 @@ public class RandomComponents { return em; } + public class MultiListener implements Button.ClickListener, + PropertySetChangeListener, ItemSetChangeListener, + ValueChangeListener { + + public void buttonClick(ClickEvent event) { + System.out.println("ClickEvent from " + + event.getButton().getCaption()); + } + + public void containerPropertySetChange(PropertySetChangeEvent event) { + System.out.println("containerPropertySetChange from " + + event.getContainer()); + } + + public void containerItemSetChange(ItemSetChangeEvent event) { + System.out.println("containerItemSetChange from " + + event.getContainer()); + } + + public void valueChange(ValueChangeEvent event) { + System.out.println("valueChange from " + event.getProperty()); + } + + } + } diff --git a/tests/test.xml b/tests/test.xml index f5da738f84..74ed1cb314 100644 --- a/tests/test.xml +++ b/tests/test.xml @@ -5,7 +5,7 @@ <!-- Configuration --> <!-- ================================================================== --> <!-- Browsers to use for testing --> - <property name="browsers" value="winxp-ie6,winxp-ie7,winxp-ie8,winxp-firefox35,winxp-safari4,winxp-googlechrome3,winxp-opera10" /> + <property name="browsers" value="winxp-ie6,winxp-ie7,winxp-ie8,winxp-firefox35,winxp-safari4,winxp-googlechrome4,winxp-opera10" /> <!-- Screen shot base directory --> <fail unless="com.vaadin.testbench.screenshot.directory" message="The 'com.vaadin.testbench.screenshot.directory' property must be defined." /> |