summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2012-01-27 14:08:53 +0000
committerArtur Signell <artur.signell@itmill.com>2012-01-27 14:08:53 +0000
commitc2722bfeb2552158c9717110b35518a07e13ab85 (patch)
treeb32ead2ac3b8ab68027e12e9bf97394cbad906f1 /tests
parentb1ae3cd70e2ca4656bb28f77ca79fe0efd29dd67 (diff)
downloadvaadin-framework-c2722bfeb2552158c9717110b35518a07e13ab85.tar.gz
vaadin-framework-c2722bfeb2552158c9717110b35518a07e13ab85.zip
#8311 Converted CRLF to LF in all source files
svn changeset:22797/svn branch:6.7
Diffstat (limited to 'tests')
-rw-r--r--tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java154
-rw-r--r--tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java738
-rw-r--r--tests/server-side/com/vaadin/data/util/AbstractContainerTest.java1340
-rw-r--r--tests/server-side/com/vaadin/data/util/AbstractHierarchicalContainerTest.java512
-rw-r--r--tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java198
-rw-r--r--tests/server-side/com/vaadin/data/util/TestContainerHierarchicalWrapper.java90
-rw-r--r--tests/server-side/com/vaadin/data/util/TestContainerSorting.java476
-rw-r--r--tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java538
-rw-r--r--tests/server-side/com/vaadin/data/util/TestIndexedContainer.java542
-rw-r--r--tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java3038
-rw-r--r--tests/server-side/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java482
-rw-r--r--tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java1324
-rw-r--r--tests/server-side/com/vaadin/tests/server/IndexedContainerListeners.java40
-rw-r--r--tests/server-side/com/vaadin/tests/server/PropertysetItemListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java30
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestAbstractContainerListeners.java42
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestAbstractPropertyListeners.java48
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java524
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestKeyMapper.java204
-rw-r--r--tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java370
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java410
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java42
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java40
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java230
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java40
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java54
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/button/ButtonListeners.java54
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java218
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java24
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/datefield/DateFieldListeners.java40
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/datefield/WeekNumberCalculation.java222
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/label/LabelListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/loginform/LoginFormListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/menubar/MenuBarIds.java194
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java40
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java98
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/panel/PanelListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/popupview/PopupViewListeners.java28
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/select/SelectListeners.java38
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/table/TableListeners.java78
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java248
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/tree/TestListeners.java270
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/tree/TreeListeners.java52
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/upload/UploadListeners.java82
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java26
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java166
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java358
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/window/WindowListeners.java68
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java338
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java60
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java360
-rw-r--r--tests/server-side/com/vaadin/tests/server/components/TestWindow.java180
-rw-r--r--tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java34
-rw-r--r--tests/testbench/com/vaadin/launcher/DevelopmentServerLauncher.java436
-rw-r--r--tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java254
-rw-r--r--tests/testbench/com/vaadin/tests/Components.java536
-rw-r--r--tests/testbench/com/vaadin/tests/StressComponentsInTable.java150
-rw-r--r--tests/testbench/com/vaadin/tests/TableChangingDatasource.java106
-rw-r--r--tests/testbench/com/vaadin/tests/TableSelectTest.java246
-rw-r--r--tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java256
-rw-r--r--tests/testbench/com/vaadin/tests/TestContainerChanges.java424
-rw-r--r--tests/testbench/com/vaadin/tests/TestDateField.java148
-rw-r--r--tests/testbench/com/vaadin/tests/TestForBasicApplicationLayout.java202
-rw-r--r--tests/testbench/com/vaadin/tests/application/ApplicationCloseTest.java140
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserTest.java196
-rw-r--r--tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java136
-rw-r--r--tests/testbench/com/vaadin/tests/applicationservlet/NoMainWindow.java44
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractComponentContainerTest.java712
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractComponentTest.java1342
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java200
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractOrderedLayoutTest.java170
-rw-r--r--tests/testbench/com/vaadin/tests/components/AbstractTestCase.java48
-rw-r--r--tests/testbench/com/vaadin/tests/components/HierarchicalContainerSorting.java216
-rw-r--r--tests/testbench/com/vaadin/tests/components/LongTooltip.java98
-rw-r--r--tests/testbench/com/vaadin/tests/components/TestBase.java106
-rw-r--r--tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java116
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java154
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java120
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java468
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java482
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java128
-rw-r--r--tests/testbench/com/vaadin/tests/components/accordion/RemoveTabs.java254
-rw-r--r--tests/testbench/com/vaadin/tests/components/button/ButtonErrorMessage.java62
-rw-r--r--tests/testbench/com/vaadin/tests/components/button/ButtonUndefinedWidth.java80
-rw-r--r--tests/testbench/com/vaadin/tests/components/button/Buttons2.java148
-rw-r--r--tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java104
-rw-r--r--tests/testbench/com/vaadin/tests/components/button/TooltipForDisabledButton.java96
-rw-r--r--tests/testbench/com/vaadin/tests/components/caption/EmptyCaptions.java112
-rw-r--r--tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes.java152
-rw-r--r--tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes2.java112
-rw-r--r--tests/testbench/com/vaadin/tests/components/checkbox/CheckboxCaptionWrapping.java78
-rw-r--r--tests/testbench/com/vaadin/tests/components/checkbox/CheckboxIcon.java58
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java204
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java98
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.java108
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java152
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxTextFieldEventOrder.java76
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java72
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxValueInput.java126
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboxBoxErrorMessage.java52
-rw-r--r--tests/testbench/com/vaadin/tests/components/customcomponent/ClipContent.java112
-rw-r--r--tests/testbench/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java88
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/CustomDateFormats.java412
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java288
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldLocale.java94
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java124
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldReadOnly.java106
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldTest.java274
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java202
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java66
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldTest.java24
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java212
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java66
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldTest.java76
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/PopupDateFields.java210
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java114
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java88
-rw-r--r--tests/testbench/com/vaadin/tests/components/embedded/EmbeddedFlash.java68
-rw-r--r--tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java64
-rw-r--r--tests/testbench/com/vaadin/tests/components/embedded/EmbeddedTooltip.java54
-rw-r--r--tests/testbench/com/vaadin/tests/components/form/FormFieldCaptions.java172
-rw-r--r--tests/testbench/com/vaadin/tests/components/form/FormRenderingFlicker.java130
-rw-r--r--tests/testbench/com/vaadin/tests/components/form/FormWithEnterShortCut.java94
-rw-r--r--tests/testbench/com/vaadin/tests/components/form/FormWithPropertyFormatterConnected.java180
-rw-r--r--tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutReplaceComponent.java112
-rw-r--r--tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java88
-rw-r--r--tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java116
-rw-r--r--tests/testbench/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/label/LabelTest.java200
-rw-r--r--tests/testbench/com/vaadin/tests/components/label/LabelTooltip.java106
-rw-r--r--tests/testbench/com/vaadin/tests/components/label/LabelWrapping.java92
-rw-r--r--tests/testbench/com/vaadin/tests/components/link/LinkIcon.java60
-rw-r--r--tests/testbench/com/vaadin/tests/components/link/LinkTargetSize.java60
-rw-r--r--tests/testbench/com/vaadin/tests/components/listselect/ListSelects.java88
-rw-r--r--tests/testbench/com/vaadin/tests/components/menubar/HiddenAndDisabledMenus.java68
-rw-r--r--tests/testbench/com/vaadin/tests/components/menubar/MenuBarNavigation.java124
-rw-r--r--tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/menubar/MenuBarTest.java676
-rw-r--r--tests/testbench/com/vaadin/tests/components/menubar/Menubars.java176
-rw-r--r--tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonTest.java24
-rw-r--r--tests/testbench/com/vaadin/tests/components/nativeselect/NativeSelects.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/notification/Notifications.java116
-rw-r--r--tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java152
-rw-r--r--tests/testbench/com/vaadin/tests/components/optiongroup/OptionGroups.java134
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/HorizontalLayoutTest.java26
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java80
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutTest.java28
-rw-r--r--tests/testbench/com/vaadin/tests/components/passwordfield/PasswordFieldTest.java40
-rw-r--r--tests/testbench/com/vaadin/tests/components/popupview/PopupViewLabelResized.java74
-rw-r--r--tests/testbench/com/vaadin/tests/components/popupview/PopupViewNullValues.java206
-rw-r--r--tests/testbench/com/vaadin/tests/components/popupview/PopupViewWithRTE.java100
-rw-r--r--tests/testbench/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java104
-rw-r--r--tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaTest.java108
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/AbstractSelectTestCase.java480
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/MultiSelect.java64
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/NullSelectionItemId.java154
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java326
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/SelectTest.java26
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/TwinColSelectTest.java130
-rw-r--r--tests/testbench/com/vaadin/tests/components/select/TwinColSelects.java96
-rw-r--r--tests/testbench/com/vaadin/tests/components/slider/SliderTest.java148
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java254
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/HorizontalSplitPanels.java26
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java136
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java86
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanels.java74
-rw-r--r--tests/testbench/com/vaadin/tests/components/splitpanel/VerticalSplitPanels.java26
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ClippedComponentsInTable.java80
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java182
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ColumnExpandWithFixedColumns.java90
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/EditableModeChange.java196
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/EditableTableFocus.java68
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/FixedHeightTable.java76
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ModifyContainerProperty.java120
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/NotselectablePaintSelections.java110
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/RowAdditionTest.java118
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java130
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java298
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java170
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java120
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableLastRowMissing.java70
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java102
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TablePageLengthCalculation.java98
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java86
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableScrollOnFocus.java96
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableScrollsOnSelection.java72
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableSelectPagingOff.java138
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableSingleSelect.java108
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableSorting.java132
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java336
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableWithManyColumns.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/Tables.java1676
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java120
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java258
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/RemoveTabs.java290
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java128
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java124
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java104
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetIcons.java108
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java78
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabStyleNames.java100
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabTheming.java52
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTest.java404
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java118
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java148
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java80
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java84
-rw-r--r--tests/testbench/com/vaadin/tests/components/textarea/TextAreaTest.java86
-rw-r--r--tests/testbench/com/vaadin/tests/components/textarea/Wordwrap.java118
-rw-r--r--tests/testbench/com/vaadin/tests/components/textfield/IE6Cursor.java56
-rw-r--r--tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java68
-rw-r--r--tests/testbench/com/vaadin/tests/components/textfield/TextFieldTest.java118
-rw-r--r--tests/testbench/com/vaadin/tests/components/tree/TreeContainerChange.java202
-rw-r--r--tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java250
-rw-r--r--tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java108
-rw-r--r--tests/testbench/com/vaadin/tests/components/tree/Trees.java782
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java178
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java248
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java474
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/TreeTableTest.java600
-rw-r--r--tests/testbench/com/vaadin/tests/components/twincolselect/TwinColSelects.java128
-rw-r--r--tests/testbench/com/vaadin/tests/components/upload/ForceSubmit.java170
-rw-r--r--tests/testbench/com/vaadin/tests/components/upload/TestFileUpload.java116
-rw-r--r--tests/testbench/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java106
-rw-r--r--tests/testbench/com/vaadin/tests/components/upload/TestUpload.java118
-rw-r--r--tests/testbench/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java204
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java258
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/CloseSubWindow.java258
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/ExtraLargeSubWindow.java64
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java106
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/FullSizedWindow.java62
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/ModalWindowNativeSelect.java62
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/SubwindowInvalidLayout.java70
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java274
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java78
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java232
-rw-r--r--tests/testbench/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java344
-rw-r--r--tests/testbench/com/vaadin/tests/containers/IndexedContainerFilteringTest.java278
-rw-r--r--tests/testbench/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java280
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/CaptionsInLayouts.java554
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponent.java84
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java82
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/DeepComponentTrees.java228
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/GridLayoutMoveComponent.java132
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/GridLayoutNPE.java144
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/GridLayoutWidthChange.java128
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/HiddenHorizontalLayout.java112
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/OrderedLayoutBasics.java2402
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java628
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/TestLayoutPerformance.java266
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java84
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java154
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java76
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java116
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java60
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java1186
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java1118
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java1178
-rw-r--r--tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java96
-rw-r--r--tests/testbench/com/vaadin/tests/resources/ResourceDownload.java178
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket124.java180
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1245.java184
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1365.java88
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1506_Panel.java96
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer.java252
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java234
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1572.java236
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1581.java142
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1589.java186
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1663.java44
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1673.java56
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1710.java822
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1767.java60
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1772.java74
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1775.java96
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1804.java300
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1805.java114
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1806.java88
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1811.java156
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1819.java128
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java176
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1868.java38
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1869.java110
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1878.java768
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1919.java104
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1923.java158
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1924ThemeChanging.java100
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1925.java30
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1966.java222
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java336
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java126
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1969.java208
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1972.java60
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1973.java100
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1975.java124
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1986.java158
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1991.java54
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket1995.java134
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2002.java102
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2009.java250
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2011.java52
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2014.java126
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2021.java282
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2022.java64
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2024.java70
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2026.java70
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2029.java278
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2037.java94
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2040.java172
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2042.java76
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2043.java56
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2048.java206
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2051.java88
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2060.java100
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2062.java80
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2083.java56
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2095.java58
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2098.java74
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2099.java154
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2101.java42
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2126.java122
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2208.java136
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2209.java84
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java98
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java110
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2215.java58
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2232.java148
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2287.java62
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2292.java174
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2297.java80
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2303.java86
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2407.java42
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2411.java58
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket2998.java664
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket3146.java192
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket5053.java70
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket5157.java104
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket5952.java60
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket6002.java176
-rw-r--r--tests/testbench/com/vaadin/tests/tickets/Ticket677.java420
-rw-r--r--tests/testbench/com/vaadin/tests/util/Log.java124
-rw-r--r--tests/testbench/com/vaadin/tests/util/PortableRandom.java102
-rw-r--r--tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java292
-rw-r--r--tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java188
353 files changed, 34482 insertions, 34482 deletions
diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java b/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java
index fe3b724aaf..3535d50529 100644
--- a/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java
+++ b/tests/client-side/com/vaadin/terminal/gwt/client/ApplicationConnectionTestURLGeneration.java
@@ -1,77 +1,77 @@
-package com.vaadin.terminal.gwt.client;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-
-public class ApplicationConnectionTestURLGeneration {
-
- private static final String[] URIS = new String[] {
- "http://demo.vaadin.com/", //
- "https://demo.vaadin.com/",
- "http://demo.vaadin.com/foo",
- "http://demo.vaadin.com/foo?f",
- "http://demo.vaadin.com/foo?f=1",
- "http://demo.vaadin.com:1234/foo?a",
- "http://demo.vaadin.com:1234/foo#frag?fakeparam",
- // Jetspeed
- "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__",
- // Liferay generated url
- "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1",
-
- };
- private static final String[] URIS_WITH_ABCD_PARAM = new String[] {
- "http://demo.vaadin.com/?a=b&c=d",
- "https://demo.vaadin.com/?a=b&c=d",
- "http://demo.vaadin.com/foo?a=b&c=d",
- "http://demo.vaadin.com/foo?f&a=b&c=d",
- "http://demo.vaadin.com/foo?f=1&a=b&c=d",
- "http://demo.vaadin.com:1234/foo?a&a=b&c=d",
- "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam",
- "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d",
- "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d",
-
- };
-
- private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = new String[] {
- "http://demo.vaadin.com/?a=b&c=d#fragment",
- "https://demo.vaadin.com/?a=b&c=d#fragment",
- "http://demo.vaadin.com/foo?a=b&c=d#fragment",
- "http://demo.vaadin.com/foo?f&a=b&c=d#fragment",
- "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment",
- "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment",
- "",
- "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment",
- "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d#fragment",
-
- };
-
- @Test
- public void testParameterAdding() {
- for (int i = 0; i < URIS.length; i++) {
- // Adding nothing
- assertEquals(URIS[i],
- ApplicationConnection.addGetParameters(URIS[i], ""));
-
- // Adding a=b&c=d
- assertEquals(URIS_WITH_ABCD_PARAM[i],
- ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d"));
-
- // Fragments
- if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) {
- assertEquals(
- URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i],
- ApplicationConnection.addGetParameters(URIS[i]
- + "#fragment", "a=b&c=d"));
-
- // Empty fragment
- assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace(
- "#fragment", "#"),
- ApplicationConnection.addGetParameters(URIS[i] + "#",
- "a=b&c=d"));
- }
- }
- }
-}
+package com.vaadin.terminal.gwt.client;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+
+public class ApplicationConnectionTestURLGeneration {
+
+ private static final String[] URIS = new String[] {
+ "http://demo.vaadin.com/", //
+ "https://demo.vaadin.com/",
+ "http://demo.vaadin.com/foo",
+ "http://demo.vaadin.com/foo?f",
+ "http://demo.vaadin.com/foo?f=1",
+ "http://demo.vaadin.com:1234/foo?a",
+ "http://demo.vaadin.com:1234/foo#frag?fakeparam",
+ // Jetspeed
+ "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__",
+ // Liferay generated url
+ "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1",
+
+ };
+ private static final String[] URIS_WITH_ABCD_PARAM = new String[] {
+ "http://demo.vaadin.com/?a=b&c=d",
+ "https://demo.vaadin.com/?a=b&c=d",
+ "http://demo.vaadin.com/foo?a=b&c=d",
+ "http://demo.vaadin.com/foo?f&a=b&c=d",
+ "http://demo.vaadin.com/foo?f=1&a=b&c=d",
+ "http://demo.vaadin.com:1234/foo?a&a=b&c=d",
+ "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam",
+ "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d",
+ "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d",
+
+ };
+
+ private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = new String[] {
+ "http://demo.vaadin.com/?a=b&c=d#fragment",
+ "https://demo.vaadin.com/?a=b&c=d#fragment",
+ "http://demo.vaadin.com/foo?a=b&c=d#fragment",
+ "http://demo.vaadin.com/foo?f&a=b&c=d#fragment",
+ "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment",
+ "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment",
+ "",
+ "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment",
+ "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d#fragment",
+
+ };
+
+ @Test
+ public void testParameterAdding() {
+ for (int i = 0; i < URIS.length; i++) {
+ // Adding nothing
+ assertEquals(URIS[i],
+ ApplicationConnection.addGetParameters(URIS[i], ""));
+
+ // Adding a=b&c=d
+ assertEquals(URIS_WITH_ABCD_PARAM[i],
+ ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d"));
+
+ // Fragments
+ if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) {
+ assertEquals(
+ URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i],
+ ApplicationConnection.addGetParameters(URIS[i]
+ + "#fragment", "a=b&c=d"));
+
+ // Empty fragment
+ assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace(
+ "#fragment", "#"),
+ ApplicationConnection.addGetParameters(URIS[i] + "#",
+ "a=b&c=d"));
+ }
+ }
+ }
+}
diff --git a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java
index 183a4d0fe3..f661b6cf15 100644
--- a/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java
+++ b/tests/client-side/com/vaadin/terminal/gwt/client/TestVBrowserDetailsUserAgentParser.java
@@ -1,369 +1,369 @@
-package com.vaadin.terminal.gwt.client;
-
-import junit.framework.TestCase;
-
-import com.vaadin.terminal.gwt.client.VBrowserDetails;
-
-public class TestVBrowserDetailsUserAgentParser extends TestCase {
-
- private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6";
- private static final String FIREFOX30_LINUX = "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12";
- private static final String FIREFOX35_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729) FirePHP/0.4";
- private static final String FIREFOX36_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)";
- private static final String FIREFOX36B_MAC = "UAString mozilla/5.0 (macintosh; u; intel mac os x 10.6; en-us; rv:1.9.2) gecko/20100115 firefox/3.6";
- private static final String FIREFOX_30B5_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5";
- private static final String FIREFOX_40B7_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7";
- private static final String FIREFOX_40B11_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b11) Gecko/20100101 Firefox/4.0b11";
- private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)";
-
- private static final String IE6_WINDOWS = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
- private static final String IE7_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
-
- private static final String IE8_WINDOWS = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
- private static final String IE8_IN_IE7_MODE_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
-
- private static final String IE9_BETA_IN_IE7_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
- private static final String IE9_BETA_IN_IE8_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
- private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
-
- // "Version/" was added in 10.00
- private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1";
- private static final String OPERA1010_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.10";
- private static final String OPERA1050_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.22 Version/10.50";
-
- private static final String CHROME3_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.198 Safari/532.0";
- private static final String CHROME4_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5";
-
- private static final String SAFARI3_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29";
- private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7";
-
- public void testSafari3() {
- VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS);
- assertWebKit(bd);
- assertSafari(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 2);
- assertEngineVersion(bd, 525.0f);
- assertWindows(bd);
- }
-
- public void testSafari4() {
- VBrowserDetails bd = new VBrowserDetails(SAFARI4_MAC);
- assertWebKit(bd);
- assertSafari(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 531f);
- assertMacOSX(bd);
- }
-
- public void testChrome3() {
- VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC);
- assertWebKit(bd);
- assertChrome(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 532.0f);
- assertMacOSX(bd);
- }
-
- public void testChrome4() {
- VBrowserDetails bd = new VBrowserDetails(CHROME4_WINDOWS);
- assertWebKit(bd);
- assertChrome(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 532f);
- assertWindows(bd);
- }
-
- public void testFirefox3() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX30_WINDOWS);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 1.9f);
- assertWindows(bd);
-
- bd = new VBrowserDetails(FIREFOX30_LINUX);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 1.9f);
- assertLinux(bd);
- }
-
- public void testFirefox35() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX35_WINDOWS);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 5);
- assertEngineVersion(bd, 1.9f);
- assertWindows(bd);
- }
-
- public void testFirefox36() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX36_WINDOWS);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 6);
- assertEngineVersion(bd, 1.9f);
- assertWindows(bd);
- }
-
- public void testFirefox30b5() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX_30B5_MAC);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 1.9f);
- assertMacOSX(bd);
- }
-
- public void testFirefox40b11() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B11_WIN);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 2.0f);
- assertWindows(bd);
- }
-
- public void testFirefox40b7() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B7_WIN);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 4);
- assertBrowserMinorVersion(bd, 0);
- assertEngineVersion(bd, 2.0f);
- assertWindows(bd);
- }
-
- public void testKonquerorLinux() {
- // Just ensure detection does not crash
- VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX);
- assertLinux(bd);
- }
-
- public void testFirefox36b() {
- VBrowserDetails bd = new VBrowserDetails(FIREFOX36B_MAC);
- assertGecko(bd);
- assertFirefox(bd);
- assertBrowserMajorVersion(bd, 3);
- assertBrowserMinorVersion(bd, 6);
- assertEngineVersion(bd, 1.9f);
- assertMacOSX(bd);
- }
-
- public void testOpera964() {
- VBrowserDetails bd = new VBrowserDetails(OPERA964_WINDOWS);
- assertPresto(bd);
- assertOpera(bd);
- assertBrowserMajorVersion(bd, 9);
- assertBrowserMinorVersion(bd, 64);
- assertWindows(bd);
- }
-
- public void testOpera1010() {
- VBrowserDetails bd = new VBrowserDetails(OPERA1010_WINDOWS);
- assertPresto(bd);
- assertOpera(bd);
- assertBrowserMajorVersion(bd, 10);
- assertBrowserMinorVersion(bd, 10);
- assertWindows(bd);
- }
-
- public void testOpera1050() {
- VBrowserDetails bd = new VBrowserDetails(OPERA1050_WINDOWS);
- assertPresto(bd);
- assertOpera(bd);
- assertBrowserMajorVersion(bd, 10);
- assertBrowserMinorVersion(bd, 50);
- assertWindows(bd);
- }
-
- public void testIE6() {
- VBrowserDetails bd = new VBrowserDetails(IE6_WINDOWS);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 6);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE7() {
- VBrowserDetails bd = new VBrowserDetails(IE7_WINDOWS);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 7);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE8() {
- VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 8);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE8CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS);
- bd.setIEMode(7);
-
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 7);
- assertBrowserMinorVersion(bd, 0);
-
- assertWindows(bd);
- }
-
- public void testIE9() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7);
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 9);
- assertBrowserMinorVersion(bd, 0);
- assertWindows(bd);
- }
-
- public void testIE9InIE7CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE7_MODE_WINDOWS_7);
- // bd.setIE8InCompatibilityMode();
-
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 7);
- assertBrowserMinorVersion(bd, 0);
-
- assertWindows(bd);
- }
-
- public void testIE9InIE8CompatibilityMode() {
- VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE8_MODE_WINDOWS_7);
- // bd.setIE8InCompatibilityMode();
-
- // assertTrident(bd);
- assertIE(bd);
- assertBrowserMajorVersion(bd, 8);
- assertBrowserMinorVersion(bd, 0);
-
- assertWindows(bd);
- }
-
- /*
- * Helper methods below
- */
-
- private void assertEngineVersion(VBrowserDetails browserDetails,
- float version) {
- assertEquals(version, browserDetails.getBrowserEngineVersion());
-
- }
-
- private void assertBrowserMajorVersion(VBrowserDetails browserDetails,
- int version) {
- assertEquals(version, browserDetails.getBrowserMajorVersion());
-
- }
-
- private void assertBrowserMinorVersion(VBrowserDetails browserDetails,
- int version) {
- assertEquals(version, browserDetails.getBrowserMinorVersion());
-
- }
-
- private void assertGecko(VBrowserDetails browserDetails) {
- // Engine
- assertTrue(browserDetails.isGecko());
- assertFalse(browserDetails.isWebKit());
- assertFalse(browserDetails.isPresto());
- }
-
- private void assertPresto(VBrowserDetails browserDetails) {
- // Engine
- assertFalse(browserDetails.isGecko());
- assertFalse(browserDetails.isWebKit());
- assertTrue(browserDetails.isPresto());
- }
-
- private void assertWebKit(VBrowserDetails browserDetails) {
- // Engine
- assertFalse(browserDetails.isGecko());
- assertTrue(browserDetails.isWebKit());
- assertFalse(browserDetails.isPresto());
- }
-
- private void assertFirefox(VBrowserDetails browserDetails) {
- // Browser
- assertTrue(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertChrome(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertTrue(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertIE(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertTrue(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertOpera(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertTrue(browserDetails.isOpera());
- assertFalse(browserDetails.isSafari());
- }
-
- private void assertSafari(VBrowserDetails browserDetails) {
- // Browser
- assertFalse(browserDetails.isFirefox());
- assertFalse(browserDetails.isChrome());
- assertFalse(browserDetails.isIE());
- assertFalse(browserDetails.isOpera());
- assertTrue(browserDetails.isSafari());
- }
-
- private void assertMacOSX(VBrowserDetails browserDetails) {
- assertFalse(browserDetails.isLinux());
- assertFalse(browserDetails.isWindows());
- assertTrue(browserDetails.isMacOSX());
- }
-
- private void assertWindows(VBrowserDetails browserDetails) {
- assertFalse(browserDetails.isLinux());
- assertTrue(browserDetails.isWindows());
- assertFalse(browserDetails.isMacOSX());
- }
-
- private void assertLinux(VBrowserDetails browserDetails) {
- assertTrue(browserDetails.isLinux());
- assertFalse(browserDetails.isWindows());
- assertFalse(browserDetails.isMacOSX());
- }
-
-}
+package com.vaadin.terminal.gwt.client;
+
+import junit.framework.TestCase;
+
+import com.vaadin.terminal.gwt.client.VBrowserDetails;
+
+public class TestVBrowserDetailsUserAgentParser extends TestCase {
+
+ private static final String FIREFOX30_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6";
+ private static final String FIREFOX30_LINUX = "Mozilla/5.0 (X11; U; Linux x86_64; es-ES; rv:1.9.0.12) Gecko/2009070811 Ubuntu/9.04 (jaunty) Firefox/3.0.12";
+ private static final String FIREFOX35_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729) FirePHP/0.4";
+ private static final String FIREFOX36_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)";
+ private static final String FIREFOX36B_MAC = "UAString mozilla/5.0 (macintosh; u; intel mac os x 10.6; en-us; rv:1.9.2) gecko/20100115 firefox/3.6";
+ private static final String FIREFOX_30B5_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5";
+ private static final String FIREFOX_40B7_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7";
+ private static final String FIREFOX_40B11_WIN = "Mozilla/5.0 (Windows NT 5.1; rv:2.0b11) Gecko/20100101 Firefox/4.0b11";
+ private static final String KONQUEROR_LINUX = "Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Exabot-Thumbnails)";
+
+ private static final String IE6_WINDOWS = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
+ private static final String IE7_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
+
+ private static final String IE8_WINDOWS = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
+ private static final String IE8_IN_IE7_MODE_WINDOWS = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)";
+
+ private static final String IE9_BETA_IN_IE7_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
+ private static final String IE9_BETA_IN_IE8_MODE_WINDOWS_7 = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)";
+ private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
+
+ // "Version/" was added in 10.00
+ private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1";
+ private static final String OPERA1010_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.10";
+ private static final String OPERA1050_WINDOWS = "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.22 Version/10.50";
+
+ private static final String CHROME3_MAC = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.198 Safari/532.0";
+ private static final String CHROME4_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.89 Safari/532.5";
+
+ private static final String SAFARI3_WINDOWS = "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29";
+ private static final String SAFARI4_MAC = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7";
+
+ public void testSafari3() {
+ VBrowserDetails bd = new VBrowserDetails(SAFARI3_WINDOWS);
+ assertWebKit(bd);
+ assertSafari(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 2);
+ assertEngineVersion(bd, 525.0f);
+ assertWindows(bd);
+ }
+
+ public void testSafari4() {
+ VBrowserDetails bd = new VBrowserDetails(SAFARI4_MAC);
+ assertWebKit(bd);
+ assertSafari(bd);
+ assertBrowserMajorVersion(bd, 4);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 531f);
+ assertMacOSX(bd);
+ }
+
+ public void testChrome3() {
+ VBrowserDetails bd = new VBrowserDetails(CHROME3_MAC);
+ assertWebKit(bd);
+ assertChrome(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 532.0f);
+ assertMacOSX(bd);
+ }
+
+ public void testChrome4() {
+ VBrowserDetails bd = new VBrowserDetails(CHROME4_WINDOWS);
+ assertWebKit(bd);
+ assertChrome(bd);
+ assertBrowserMajorVersion(bd, 4);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 532f);
+ assertWindows(bd);
+ }
+
+ public void testFirefox3() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX30_WINDOWS);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 1.9f);
+ assertWindows(bd);
+
+ bd = new VBrowserDetails(FIREFOX30_LINUX);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 1.9f);
+ assertLinux(bd);
+ }
+
+ public void testFirefox35() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX35_WINDOWS);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 5);
+ assertEngineVersion(bd, 1.9f);
+ assertWindows(bd);
+ }
+
+ public void testFirefox36() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX36_WINDOWS);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 6);
+ assertEngineVersion(bd, 1.9f);
+ assertWindows(bd);
+ }
+
+ public void testFirefox30b5() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX_30B5_MAC);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 1.9f);
+ assertMacOSX(bd);
+ }
+
+ public void testFirefox40b11() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B11_WIN);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 4);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 2.0f);
+ assertWindows(bd);
+ }
+
+ public void testFirefox40b7() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX_40B7_WIN);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 4);
+ assertBrowserMinorVersion(bd, 0);
+ assertEngineVersion(bd, 2.0f);
+ assertWindows(bd);
+ }
+
+ public void testKonquerorLinux() {
+ // Just ensure detection does not crash
+ VBrowserDetails bd = new VBrowserDetails(KONQUEROR_LINUX);
+ assertLinux(bd);
+ }
+
+ public void testFirefox36b() {
+ VBrowserDetails bd = new VBrowserDetails(FIREFOX36B_MAC);
+ assertGecko(bd);
+ assertFirefox(bd);
+ assertBrowserMajorVersion(bd, 3);
+ assertBrowserMinorVersion(bd, 6);
+ assertEngineVersion(bd, 1.9f);
+ assertMacOSX(bd);
+ }
+
+ public void testOpera964() {
+ VBrowserDetails bd = new VBrowserDetails(OPERA964_WINDOWS);
+ assertPresto(bd);
+ assertOpera(bd);
+ assertBrowserMajorVersion(bd, 9);
+ assertBrowserMinorVersion(bd, 64);
+ assertWindows(bd);
+ }
+
+ public void testOpera1010() {
+ VBrowserDetails bd = new VBrowserDetails(OPERA1010_WINDOWS);
+ assertPresto(bd);
+ assertOpera(bd);
+ assertBrowserMajorVersion(bd, 10);
+ assertBrowserMinorVersion(bd, 10);
+ assertWindows(bd);
+ }
+
+ public void testOpera1050() {
+ VBrowserDetails bd = new VBrowserDetails(OPERA1050_WINDOWS);
+ assertPresto(bd);
+ assertOpera(bd);
+ assertBrowserMajorVersion(bd, 10);
+ assertBrowserMinorVersion(bd, 50);
+ assertWindows(bd);
+ }
+
+ public void testIE6() {
+ VBrowserDetails bd = new VBrowserDetails(IE6_WINDOWS);
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 6);
+ assertBrowserMinorVersion(bd, 0);
+ assertWindows(bd);
+ }
+
+ public void testIE7() {
+ VBrowserDetails bd = new VBrowserDetails(IE7_WINDOWS);
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 7);
+ assertBrowserMinorVersion(bd, 0);
+ assertWindows(bd);
+ }
+
+ public void testIE8() {
+ VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS);
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 8);
+ assertBrowserMinorVersion(bd, 0);
+ assertWindows(bd);
+ }
+
+ public void testIE8CompatibilityMode() {
+ VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS);
+ bd.setIEMode(7);
+
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 7);
+ assertBrowserMinorVersion(bd, 0);
+
+ assertWindows(bd);
+ }
+
+ public void testIE9() {
+ VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7);
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 9);
+ assertBrowserMinorVersion(bd, 0);
+ assertWindows(bd);
+ }
+
+ public void testIE9InIE7CompatibilityMode() {
+ VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE7_MODE_WINDOWS_7);
+ // bd.setIE8InCompatibilityMode();
+
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 7);
+ assertBrowserMinorVersion(bd, 0);
+
+ assertWindows(bd);
+ }
+
+ public void testIE9InIE8CompatibilityMode() {
+ VBrowserDetails bd = new VBrowserDetails(IE9_BETA_IN_IE8_MODE_WINDOWS_7);
+ // bd.setIE8InCompatibilityMode();
+
+ // assertTrident(bd);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 8);
+ assertBrowserMinorVersion(bd, 0);
+
+ assertWindows(bd);
+ }
+
+ /*
+ * Helper methods below
+ */
+
+ private void assertEngineVersion(VBrowserDetails browserDetails,
+ float version) {
+ assertEquals(version, browserDetails.getBrowserEngineVersion());
+
+ }
+
+ private void assertBrowserMajorVersion(VBrowserDetails browserDetails,
+ int version) {
+ assertEquals(version, browserDetails.getBrowserMajorVersion());
+
+ }
+
+ private void assertBrowserMinorVersion(VBrowserDetails browserDetails,
+ int version) {
+ assertEquals(version, browserDetails.getBrowserMinorVersion());
+
+ }
+
+ private void assertGecko(VBrowserDetails browserDetails) {
+ // Engine
+ assertTrue(browserDetails.isGecko());
+ assertFalse(browserDetails.isWebKit());
+ assertFalse(browserDetails.isPresto());
+ }
+
+ private void assertPresto(VBrowserDetails browserDetails) {
+ // Engine
+ assertFalse(browserDetails.isGecko());
+ assertFalse(browserDetails.isWebKit());
+ assertTrue(browserDetails.isPresto());
+ }
+
+ private void assertWebKit(VBrowserDetails browserDetails) {
+ // Engine
+ assertFalse(browserDetails.isGecko());
+ assertTrue(browserDetails.isWebKit());
+ assertFalse(browserDetails.isPresto());
+ }
+
+ private void assertFirefox(VBrowserDetails browserDetails) {
+ // Browser
+ assertTrue(browserDetails.isFirefox());
+ assertFalse(browserDetails.isChrome());
+ assertFalse(browserDetails.isIE());
+ assertFalse(browserDetails.isOpera());
+ assertFalse(browserDetails.isSafari());
+ }
+
+ private void assertChrome(VBrowserDetails browserDetails) {
+ // Browser
+ assertFalse(browserDetails.isFirefox());
+ assertTrue(browserDetails.isChrome());
+ assertFalse(browserDetails.isIE());
+ assertFalse(browserDetails.isOpera());
+ assertFalse(browserDetails.isSafari());
+ }
+
+ private void assertIE(VBrowserDetails browserDetails) {
+ // Browser
+ assertFalse(browserDetails.isFirefox());
+ assertFalse(browserDetails.isChrome());
+ assertTrue(browserDetails.isIE());
+ assertFalse(browserDetails.isOpera());
+ assertFalse(browserDetails.isSafari());
+ }
+
+ private void assertOpera(VBrowserDetails browserDetails) {
+ // Browser
+ assertFalse(browserDetails.isFirefox());
+ assertFalse(browserDetails.isChrome());
+ assertFalse(browserDetails.isIE());
+ assertTrue(browserDetails.isOpera());
+ assertFalse(browserDetails.isSafari());
+ }
+
+ private void assertSafari(VBrowserDetails browserDetails) {
+ // Browser
+ assertFalse(browserDetails.isFirefox());
+ assertFalse(browserDetails.isChrome());
+ assertFalse(browserDetails.isIE());
+ assertFalse(browserDetails.isOpera());
+ assertTrue(browserDetails.isSafari());
+ }
+
+ private void assertMacOSX(VBrowserDetails browserDetails) {
+ assertFalse(browserDetails.isLinux());
+ assertFalse(browserDetails.isWindows());
+ assertTrue(browserDetails.isMacOSX());
+ }
+
+ private void assertWindows(VBrowserDetails browserDetails) {
+ assertFalse(browserDetails.isLinux());
+ assertTrue(browserDetails.isWindows());
+ assertFalse(browserDetails.isMacOSX());
+ }
+
+ private void assertLinux(VBrowserDetails browserDetails) {
+ assertTrue(browserDetails.isLinux());
+ assertFalse(browserDetails.isWindows());
+ assertFalse(browserDetails.isMacOSX());
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java b/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java
index 8f6fb0ab8a..6cbe675fa1 100644
--- a/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java
+++ b/tests/server-side/com/vaadin/data/util/AbstractContainerTest.java
@@ -1,670 +1,670 @@
-package com.vaadin.data.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Filterable;
-import com.vaadin.data.Container.ItemSetChangeEvent;
-import com.vaadin.data.Container.ItemSetChangeListener;
-import com.vaadin.data.Container.Sortable;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.filter.SimpleStringFilter;
-
-public abstract class AbstractContainerTest extends TestCase {
-
- /**
- * Helper class for testing e.g. listeners expecting events to be fired.
- */
- protected abstract static class AbstractEventCounter {
- private int eventCount = 0;
- private int lastAssertedEventCount = 0;
-
- /**
- * Increment the event count. To be called by subclasses e.g. from a
- * listener method.
- */
- protected void increment() {
- ++eventCount;
- }
-
- /**
- * Check that no one event has occurred since the previous assert call.
- */
- public void assertNone() {
- Assert.assertEquals(lastAssertedEventCount, eventCount);
- }
-
- /**
- * Check that exactly one event has occurred since the previous assert
- * call.
- */
- public void assertOnce() {
- Assert.assertEquals(++lastAssertedEventCount, eventCount);
- }
-
- /**
- * Reset the counter and the expected count.
- */
- public void reset() {
- eventCount = 0;
- lastAssertedEventCount = 0;
- }
- }
-
- /**
- * Test class for counting item set change events and verifying they have
- * been received.
- */
- protected static class ItemSetChangeCounter extends AbstractEventCounter
- implements ItemSetChangeListener {
-
- public void containerItemSetChange(ItemSetChangeEvent event) {
- increment();
- }
-
- }
-
- // #6043: for items that have been filtered out, Container interface does
- // not specify what to return from getItem() and getContainerProperty(), so
- // need checkGetItemNull parameter for the test to be usable for most
- // current containers
- protected void validateContainer(Container container,
- Object expectedFirstItemId, Object expectedLastItemId,
- Object itemIdInSet, Object itemIdNotInSet,
- boolean checkGetItemNull, 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
- if (checkGetItemNull) {
- assertNull(container.getItem(itemIdNotInSet));
- }
- assertNotNull(container.getItem(itemIdInSet));
-
- // getContainerProperty
- for (Object propId : container.getContainerPropertyIds()) {
- if (checkGetItemNull) {
- 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 = "fullyQualifiedName";
- protected static final Object SIMPLE_NAME = "simpleName";
- protected static final Object REVERSE_FULLY_QUALIFIED_NAME = "reverseFullyQualifiedName";
- protected static final Object ID_NUMBER = "idNumber";
-
- protected void testBasicContainerOperations(Container container) {
- initializeContainer(container);
-
- // Basic container
- validateContainer(container, sampleData[0],
- sampleData[sampleData.length - 1], sampleData[10], "abc", true,
- 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 testContainerIndexed(Container.Indexed container,
- Object itemId, int itemPosition, boolean testAddEmptyItemAt,
- Object newItemId, boolean testAddItemAtWithId) {
- initializeContainer(container);
-
- // indexOfId
- Assert.assertEquals(itemPosition, container.indexOfId(itemId));
-
- // getIdByIndex
- Assert.assertEquals(itemId, container.getIdByIndex(itemPosition));
-
- // addItemAt
- if (testAddEmptyItemAt) {
- Object addedId = container.addItemAt(itemPosition);
- Assert.assertEquals(itemPosition, container.indexOfId(addedId));
- Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId));
- Assert.assertEquals(addedId, container.getIdByIndex(itemPosition));
- Assert.assertEquals(itemId,
- container.getIdByIndex(itemPosition + 1));
-
- Object newFirstId = container.addItemAt(0);
- Assert.assertEquals(0, container.indexOfId(newFirstId));
- Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId));
- Assert.assertEquals(newFirstId, container.firstItemId());
- Assert.assertEquals(newFirstId, container.getIdByIndex(0));
- Assert.assertEquals(itemId,
- container.getIdByIndex(itemPosition + 2));
-
- Object newLastId = container.addItemAt(container.size());
- Assert.assertEquals(container.size() - 1,
- container.indexOfId(newLastId));
- Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId));
- Assert.assertEquals(newLastId, container.lastItemId());
- Assert.assertEquals(newLastId,
- container.getIdByIndex(container.size() - 1));
- Assert.assertEquals(itemId,
- container.getIdByIndex(itemPosition + 2));
-
- Assert.assertTrue(container.removeItem(addedId));
- Assert.assertTrue(container.removeItem(newFirstId));
- Assert.assertTrue(container.removeItem(newLastId));
-
- Assert.assertFalse(
- "Removing non-existing item should indicate failure",
- container.removeItem(addedId));
- }
-
- // addItemAt
- if (testAddItemAtWithId) {
- container.addItemAt(itemPosition, newItemId);
- Assert.assertEquals(itemPosition, container.indexOfId(newItemId));
- Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId));
- Assert.assertEquals(newItemId, container.getIdByIndex(itemPosition));
- Assert.assertEquals(itemId,
- container.getIdByIndex(itemPosition + 1));
- Assert.assertTrue(container.removeItem(newItemId));
- Assert.assertFalse(container.containsId(newItemId));
-
- container.addItemAt(0, newItemId);
- Assert.assertEquals(0, container.indexOfId(newItemId));
- Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId));
- Assert.assertEquals(newItemId, container.firstItemId());
- Assert.assertEquals(newItemId, container.getIdByIndex(0));
- Assert.assertEquals(itemId,
- container.getIdByIndex(itemPosition + 1));
- Assert.assertTrue(container.removeItem(newItemId));
- Assert.assertFalse(container.containsId(newItemId));
-
- container.addItemAt(container.size(), newItemId);
- Assert.assertEquals(container.size() - 1,
- container.indexOfId(newItemId));
- Assert.assertEquals(itemPosition, container.indexOfId(itemId));
- Assert.assertEquals(newItemId, container.lastItemId());
- Assert.assertEquals(newItemId,
- container.getIdByIndex(container.size() - 1));
- Assert.assertEquals(itemId, container.getIdByIndex(itemPosition));
- Assert.assertTrue(container.removeItem(newItemId));
- Assert.assertFalse(container.containsId(newItemId));
- }
- }
-
- protected void testContainerFiltering(Container.Filterable container) {
- initializeContainer(container);
-
- // Filter by "contains ab"
- container.addContainerFilter(new SimpleStringFilter(
- 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", isFilteredOutItemNull(), 20);
-
- // Filter by "contains da" (reversed as ad here)
- container.removeAllContainerFilters();
- container.addContainerFilter(new SimpleStringFilter(
- 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",
- isFilteredOutItemNull(), 37);
- }
-
- /**
- * Override in subclasses to return false if the container getItem() method
- * returns a non-null value for an item that has been filtered out.
- *
- * @return
- */
- protected boolean isFilteredOutItemNull() {
- return true;
- }
-
- protected void testContainerSortingAndFiltering(Container.Sortable sortable) {
- Filterable filterable = (Filterable) sortable;
-
- initializeContainer(sortable);
-
- // Filter by "contains ab"
- filterable.addContainerFilter(new SimpleStringFilter(
- 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", isFilteredOutItemNull(), 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",
- "org.vaadin.test.LastClass",
- "com.vaadin.terminal.ApplicationResource", "blah", true,
- 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", true,
- sampleData.length);
-
- }
-
- protected void initializeContainer(Container container) {
- Assert.assertTrue(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 static 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", "org.vaadin.test.LastClass" };
-
-}
+package com.vaadin.data.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Filterable;
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+import com.vaadin.data.Container.Sortable;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.filter.SimpleStringFilter;
+
+public abstract class AbstractContainerTest extends TestCase {
+
+ /**
+ * Helper class for testing e.g. listeners expecting events to be fired.
+ */
+ protected abstract static class AbstractEventCounter {
+ private int eventCount = 0;
+ private int lastAssertedEventCount = 0;
+
+ /**
+ * Increment the event count. To be called by subclasses e.g. from a
+ * listener method.
+ */
+ protected void increment() {
+ ++eventCount;
+ }
+
+ /**
+ * Check that no one event has occurred since the previous assert call.
+ */
+ public void assertNone() {
+ Assert.assertEquals(lastAssertedEventCount, eventCount);
+ }
+
+ /**
+ * Check that exactly one event has occurred since the previous assert
+ * call.
+ */
+ public void assertOnce() {
+ Assert.assertEquals(++lastAssertedEventCount, eventCount);
+ }
+
+ /**
+ * Reset the counter and the expected count.
+ */
+ public void reset() {
+ eventCount = 0;
+ lastAssertedEventCount = 0;
+ }
+ }
+
+ /**
+ * Test class for counting item set change events and verifying they have
+ * been received.
+ */
+ protected static class ItemSetChangeCounter extends AbstractEventCounter
+ implements ItemSetChangeListener {
+
+ public void containerItemSetChange(ItemSetChangeEvent event) {
+ increment();
+ }
+
+ }
+
+ // #6043: for items that have been filtered out, Container interface does
+ // not specify what to return from getItem() and getContainerProperty(), so
+ // need checkGetItemNull parameter for the test to be usable for most
+ // current containers
+ protected void validateContainer(Container container,
+ Object expectedFirstItemId, Object expectedLastItemId,
+ Object itemIdInSet, Object itemIdNotInSet,
+ boolean checkGetItemNull, 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
+ if (checkGetItemNull) {
+ assertNull(container.getItem(itemIdNotInSet));
+ }
+ assertNotNull(container.getItem(itemIdInSet));
+
+ // getContainerProperty
+ for (Object propId : container.getContainerPropertyIds()) {
+ if (checkGetItemNull) {
+ 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 = "fullyQualifiedName";
+ protected static final Object SIMPLE_NAME = "simpleName";
+ protected static final Object REVERSE_FULLY_QUALIFIED_NAME = "reverseFullyQualifiedName";
+ protected static final Object ID_NUMBER = "idNumber";
+
+ protected void testBasicContainerOperations(Container container) {
+ initializeContainer(container);
+
+ // Basic container
+ validateContainer(container, sampleData[0],
+ sampleData[sampleData.length - 1], sampleData[10], "abc", true,
+ 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 testContainerIndexed(Container.Indexed container,
+ Object itemId, int itemPosition, boolean testAddEmptyItemAt,
+ Object newItemId, boolean testAddItemAtWithId) {
+ initializeContainer(container);
+
+ // indexOfId
+ Assert.assertEquals(itemPosition, container.indexOfId(itemId));
+
+ // getIdByIndex
+ Assert.assertEquals(itemId, container.getIdByIndex(itemPosition));
+
+ // addItemAt
+ if (testAddEmptyItemAt) {
+ Object addedId = container.addItemAt(itemPosition);
+ Assert.assertEquals(itemPosition, container.indexOfId(addedId));
+ Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId));
+ Assert.assertEquals(addedId, container.getIdByIndex(itemPosition));
+ Assert.assertEquals(itemId,
+ container.getIdByIndex(itemPosition + 1));
+
+ Object newFirstId = container.addItemAt(0);
+ Assert.assertEquals(0, container.indexOfId(newFirstId));
+ Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId));
+ Assert.assertEquals(newFirstId, container.firstItemId());
+ Assert.assertEquals(newFirstId, container.getIdByIndex(0));
+ Assert.assertEquals(itemId,
+ container.getIdByIndex(itemPosition + 2));
+
+ Object newLastId = container.addItemAt(container.size());
+ Assert.assertEquals(container.size() - 1,
+ container.indexOfId(newLastId));
+ Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId));
+ Assert.assertEquals(newLastId, container.lastItemId());
+ Assert.assertEquals(newLastId,
+ container.getIdByIndex(container.size() - 1));
+ Assert.assertEquals(itemId,
+ container.getIdByIndex(itemPosition + 2));
+
+ Assert.assertTrue(container.removeItem(addedId));
+ Assert.assertTrue(container.removeItem(newFirstId));
+ Assert.assertTrue(container.removeItem(newLastId));
+
+ Assert.assertFalse(
+ "Removing non-existing item should indicate failure",
+ container.removeItem(addedId));
+ }
+
+ // addItemAt
+ if (testAddItemAtWithId) {
+ container.addItemAt(itemPosition, newItemId);
+ Assert.assertEquals(itemPosition, container.indexOfId(newItemId));
+ Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId));
+ Assert.assertEquals(newItemId, container.getIdByIndex(itemPosition));
+ Assert.assertEquals(itemId,
+ container.getIdByIndex(itemPosition + 1));
+ Assert.assertTrue(container.removeItem(newItemId));
+ Assert.assertFalse(container.containsId(newItemId));
+
+ container.addItemAt(0, newItemId);
+ Assert.assertEquals(0, container.indexOfId(newItemId));
+ Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId));
+ Assert.assertEquals(newItemId, container.firstItemId());
+ Assert.assertEquals(newItemId, container.getIdByIndex(0));
+ Assert.assertEquals(itemId,
+ container.getIdByIndex(itemPosition + 1));
+ Assert.assertTrue(container.removeItem(newItemId));
+ Assert.assertFalse(container.containsId(newItemId));
+
+ container.addItemAt(container.size(), newItemId);
+ Assert.assertEquals(container.size() - 1,
+ container.indexOfId(newItemId));
+ Assert.assertEquals(itemPosition, container.indexOfId(itemId));
+ Assert.assertEquals(newItemId, container.lastItemId());
+ Assert.assertEquals(newItemId,
+ container.getIdByIndex(container.size() - 1));
+ Assert.assertEquals(itemId, container.getIdByIndex(itemPosition));
+ Assert.assertTrue(container.removeItem(newItemId));
+ Assert.assertFalse(container.containsId(newItemId));
+ }
+ }
+
+ protected void testContainerFiltering(Container.Filterable container) {
+ initializeContainer(container);
+
+ // Filter by "contains ab"
+ container.addContainerFilter(new SimpleStringFilter(
+ 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", isFilteredOutItemNull(), 20);
+
+ // Filter by "contains da" (reversed as ad here)
+ container.removeAllContainerFilters();
+ container.addContainerFilter(new SimpleStringFilter(
+ 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",
+ isFilteredOutItemNull(), 37);
+ }
+
+ /**
+ * Override in subclasses to return false if the container getItem() method
+ * returns a non-null value for an item that has been filtered out.
+ *
+ * @return
+ */
+ protected boolean isFilteredOutItemNull() {
+ return true;
+ }
+
+ protected void testContainerSortingAndFiltering(Container.Sortable sortable) {
+ Filterable filterable = (Filterable) sortable;
+
+ initializeContainer(sortable);
+
+ // Filter by "contains ab"
+ filterable.addContainerFilter(new SimpleStringFilter(
+ 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", isFilteredOutItemNull(), 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",
+ "org.vaadin.test.LastClass",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ 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", true,
+ sampleData.length);
+
+ }
+
+ protected void initializeContainer(Container container) {
+ Assert.assertTrue(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 static 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", "org.vaadin.test.LastClass" };
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/AbstractHierarchicalContainerTest.java b/tests/server-side/com/vaadin/data/util/AbstractHierarchicalContainerTest.java
index 6ab624b8ff..6bfff90c7b 100644
--- a/tests/server-side/com/vaadin/data/util/AbstractHierarchicalContainerTest.java
+++ b/tests/server-side/com/vaadin/data/util/AbstractHierarchicalContainerTest.java
@@ -1,256 +1,256 @@
-package com.vaadin.data.util;
-
-import java.util.Collection;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Hierarchical;
-import com.vaadin.data.Container.Sortable;
-import com.vaadin.data.Item;
-
-public abstract 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 checkGetItemNull
- * true if getItem() should return null for itemIdNotInSet, false
- * to skip the check (container.containsId() is checked in any
- * case)
- * @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
- * @param rootsHaveChildren
- * true if all roots have children, false otherwise (skips some
- * asserts)
- */
- protected void validateHierarchicalContainer(Hierarchical container,
- Object expectedFirstItemId, Object expectedLastItemId,
- Object itemIdInSet, Object itemIdNotInSet,
- boolean checkGetItemNull, int expectedSize, int expectedRootSize,
- boolean rootsHaveChildren) {
-
- validateContainer(container, expectedFirstItemId, expectedLastItemId,
- itemIdInSet, itemIdNotInSet, checkGetItemNull, 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));
-
- if (rootsHaveChildren) {
- // all roots have children allowed in this case
- assertTrue(container.areChildrenAllowed(rootId));
-
- // all roots have children in this case
- 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);
- }
-
- }
- }
-
- // 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(expectedSize, 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 + 3;
- int expectedSize = sampleData.length + packages;
- validateHierarchicalContainer(container, "com",
- "org.vaadin.test.LastClass",
- "com.vaadin.terminal.ApplicationResource", "blah", true,
- expectedSize, 2, true);
-
- }
-
- 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 + 3;
- int expectedSize = sampleData.length + packages;
- validateHierarchicalContainer(container, "com",
- "org.vaadin.test.LastClass",
- "com.vaadin.terminal.ApplicationResource", "blah", true,
- expectedSize, 2, true);
-
- 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, 2, true);
-
- }
-
- 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);
- }
- }
-
-}
+package com.vaadin.data.util;
+
+import java.util.Collection;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Hierarchical;
+import com.vaadin.data.Container.Sortable;
+import com.vaadin.data.Item;
+
+public abstract 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 checkGetItemNull
+ * true if getItem() should return null for itemIdNotInSet, false
+ * to skip the check (container.containsId() is checked in any
+ * case)
+ * @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
+ * @param rootsHaveChildren
+ * true if all roots have children, false otherwise (skips some
+ * asserts)
+ */
+ protected void validateHierarchicalContainer(Hierarchical container,
+ Object expectedFirstItemId, Object expectedLastItemId,
+ Object itemIdInSet, Object itemIdNotInSet,
+ boolean checkGetItemNull, int expectedSize, int expectedRootSize,
+ boolean rootsHaveChildren) {
+
+ validateContainer(container, expectedFirstItemId, expectedLastItemId,
+ itemIdInSet, itemIdNotInSet, checkGetItemNull, 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));
+
+ if (rootsHaveChildren) {
+ // all roots have children allowed in this case
+ assertTrue(container.areChildrenAllowed(rootId));
+
+ // all roots have children in this case
+ 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);
+ }
+
+ }
+ }
+
+ // 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(expectedSize, 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 + 3;
+ int expectedSize = sampleData.length + packages;
+ validateHierarchicalContainer(container, "com",
+ "org.vaadin.test.LastClass",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ expectedSize, 2, true);
+
+ }
+
+ 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 + 3;
+ int expectedSize = sampleData.length + packages;
+ validateHierarchicalContainer(container, "com",
+ "org.vaadin.test.LastClass",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ expectedSize, 2, true);
+
+ 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, 2, true);
+
+ }
+
+ 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/server-side/com/vaadin/data/util/ObjectPropertyTest.java b/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java
index a934b40dce..11676099e6 100644
--- a/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java
+++ b/tests/server-side/com/vaadin/data/util/ObjectPropertyTest.java
@@ -1,99 +1,99 @@
-package com.vaadin.data.util;
-
-import junit.framework.TestCase;
-
-import org.junit.Assert;
-
-import com.vaadin.data.util.ObjectProperty;
-
-public class ObjectPropertyTest extends TestCase {
-
- public static class TestSuperClass {
- private String name;
-
- public TestSuperClass(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return getName();
- }
- }
-
- public static class TestSubClass extends TestSuperClass {
- public TestSubClass(String name) {
- super("Subclass: " + name);
- }
- }
-
- private TestSuperClass super1 = new TestSuperClass("super1");
- private TestSubClass sub1 = new TestSubClass("sub1");
-
- public void testSimple() {
- ObjectProperty<TestSuperClass> prop1 = new ObjectProperty<TestSuperClass>(
- super1, TestSuperClass.class);
- Assert.assertEquals("super1", prop1.getValue().getName());
- prop1 = new ObjectProperty<TestSuperClass>(super1);
- Assert.assertEquals("super1", prop1.getValue().getName());
-
- ObjectProperty<TestSubClass> prop2 = new ObjectProperty<TestSubClass>(
- sub1, TestSubClass.class);
- Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
- prop2 = new ObjectProperty<TestSubClass>(sub1);
- Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
- }
-
- public void testSetValueObjectSuper() {
- ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
- super1, TestSuperClass.class);
- Assert.assertEquals("super1", prop.getValue().getName());
- prop.setValue(new TestSuperClass("super2"));
- Assert.assertEquals("super1", super1.getName());
- Assert.assertEquals("super2", prop.getValue().getName());
- }
-
- public void testSetValueObjectSub() {
- ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
- sub1, TestSubClass.class);
- Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
- prop.setValue(new TestSubClass("sub2"));
- Assert.assertEquals("Subclass: sub1", sub1.getName());
- Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
- }
-
- public void testSetValueStringSuper() {
- ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
- super1, TestSuperClass.class);
- Assert.assertEquals("super1", prop.getValue().getName());
- prop.setValue("super2");
- Assert.assertEquals("super1", super1.getName());
- Assert.assertEquals("super2", prop.getValue().getName());
- }
-
- public void testSetValueStringSub() {
- ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
- sub1, TestSubClass.class);
- Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
- prop.setValue("sub2");
- Assert.assertEquals("Subclass: sub1", sub1.getName());
- Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
- }
-
- public void testMixedGenerics() {
- ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
- sub1);
- Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
- Assert.assertEquals(prop.getType(), TestSubClass.class);
- // create correct subclass based on the runtime type of the instance
- // given to ObjectProperty constructor, which is a subclass of the type
- // parameter
- prop.setValue("sub2");
- Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
- }
-
-}
+package com.vaadin.data.util;
+
+import junit.framework.TestCase;
+
+import org.junit.Assert;
+
+import com.vaadin.data.util.ObjectProperty;
+
+public class ObjectPropertyTest extends TestCase {
+
+ public static class TestSuperClass {
+ private String name;
+
+ public TestSuperClass(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+ }
+
+ public static class TestSubClass extends TestSuperClass {
+ public TestSubClass(String name) {
+ super("Subclass: " + name);
+ }
+ }
+
+ private TestSuperClass super1 = new TestSuperClass("super1");
+ private TestSubClass sub1 = new TestSubClass("sub1");
+
+ public void testSimple() {
+ ObjectProperty<TestSuperClass> prop1 = new ObjectProperty<TestSuperClass>(
+ super1, TestSuperClass.class);
+ Assert.assertEquals("super1", prop1.getValue().getName());
+ prop1 = new ObjectProperty<TestSuperClass>(super1);
+ Assert.assertEquals("super1", prop1.getValue().getName());
+
+ ObjectProperty<TestSubClass> prop2 = new ObjectProperty<TestSubClass>(
+ sub1, TestSubClass.class);
+ Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
+ prop2 = new ObjectProperty<TestSubClass>(sub1);
+ Assert.assertEquals("Subclass: sub1", prop2.getValue().getName());
+ }
+
+ public void testSetValueObjectSuper() {
+ ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
+ super1, TestSuperClass.class);
+ Assert.assertEquals("super1", prop.getValue().getName());
+ prop.setValue(new TestSuperClass("super2"));
+ Assert.assertEquals("super1", super1.getName());
+ Assert.assertEquals("super2", prop.getValue().getName());
+ }
+
+ public void testSetValueObjectSub() {
+ ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
+ sub1, TestSubClass.class);
+ Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
+ prop.setValue(new TestSubClass("sub2"));
+ Assert.assertEquals("Subclass: sub1", sub1.getName());
+ Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
+ }
+
+ public void testSetValueStringSuper() {
+ ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
+ super1, TestSuperClass.class);
+ Assert.assertEquals("super1", prop.getValue().getName());
+ prop.setValue("super2");
+ Assert.assertEquals("super1", super1.getName());
+ Assert.assertEquals("super2", prop.getValue().getName());
+ }
+
+ public void testSetValueStringSub() {
+ ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>(
+ sub1, TestSubClass.class);
+ Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
+ prop.setValue("sub2");
+ Assert.assertEquals("Subclass: sub1", sub1.getName());
+ Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
+ }
+
+ public void testMixedGenerics() {
+ ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>(
+ sub1);
+ Assert.assertEquals("Subclass: sub1", prop.getValue().getName());
+ Assert.assertEquals(prop.getType(), TestSubClass.class);
+ // create correct subclass based on the runtime type of the instance
+ // given to ObjectProperty constructor, which is a subclass of the type
+ // parameter
+ prop.setValue("sub2");
+ Assert.assertEquals("Subclass: sub2", prop.getValue().getName());
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/TestContainerHierarchicalWrapper.java b/tests/server-side/com/vaadin/data/util/TestContainerHierarchicalWrapper.java
index ec0fe1de37..ebe604ff3a 100644
--- a/tests/server-side/com/vaadin/data/util/TestContainerHierarchicalWrapper.java
+++ b/tests/server-side/com/vaadin/data/util/TestContainerHierarchicalWrapper.java
@@ -1,45 +1,45 @@
-package com.vaadin.data.util;
-
-import java.util.Collection;
-
-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()));
- }
-
- public void testRemoveSubtree() {
- testRemoveHierarchicalWrapperSubtree(new ContainerHierarchicalWrapper(
- new IndexedContainer()));
- }
-
- protected void testRemoveHierarchicalWrapperSubtree(
- ContainerHierarchicalWrapper container) {
- initializeContainer(container);
-
- // remove root item
- container.removeItemRecursively("org");
-
- int packages = 21 + 3 - 3;
- int expectedSize = sampleData.length + packages - 1;
-
- validateContainer(container, "com", "com.vaadin.util.SerializerHelper",
- "com.vaadin.terminal.ApplicationResource", "blah", true,
- expectedSize);
-
- // rootItemIds
- Collection<?> rootIds = container.rootItemIds();
- assertEquals(1, rootIds.size());
- }
-
-}
+package com.vaadin.data.util;
+
+import java.util.Collection;
+
+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()));
+ }
+
+ public void testRemoveSubtree() {
+ testRemoveHierarchicalWrapperSubtree(new ContainerHierarchicalWrapper(
+ new IndexedContainer()));
+ }
+
+ protected void testRemoveHierarchicalWrapperSubtree(
+ ContainerHierarchicalWrapper container) {
+ initializeContainer(container);
+
+ // remove root item
+ container.removeItemRecursively("org");
+
+ int packages = 21 + 3 - 3;
+ int expectedSize = sampleData.length + packages - 1;
+
+ validateContainer(container, "com", "com.vaadin.util.SerializerHelper",
+ "com.vaadin.terminal.ApplicationResource", "blah", true,
+ expectedSize);
+
+ // rootItemIds
+ Collection<?> rootIds = container.rootItemIds();
+ assertEquals(1, rootIds.size());
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/TestContainerSorting.java b/tests/server-side/com/vaadin/data/util/TestContainerSorting.java
index dbfea7d75d..d9a8e6e51c 100644
--- a/tests/server-side/com/vaadin/data/util/TestContainerSorting.java
+++ b/tests/server-side/com/vaadin/data/util/TestContainerSorting.java
@@ -1,238 +1,238 @@
-package com.vaadin.data.util;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.data.util.IndexedContainer;
-
-public class TestContainerSorting extends TestCase {
-
- private static final String ITEM_DATA_MINUS2_NULL = "Data -2 null";
- private static final String ITEM_DATA_MINUS2 = "Data -2";
- private static final String ITEM_DATA_MINUS1 = "Data -1";
- private static final String ITEM_DATA_MINUS1_NULL = "Data -1 null";
- private static final String ITEM_ANOTHER_NULL = "Another null";
- private static final String ITEM_STRING_2 = "String 2";
- private static final String ITEM_STRING_NULL2 = "String null";
- private static final String ITEM_STRING_1 = "String 1";
-
- private static final String PROPERTY_INTEGER_NULL2 = "integer-null";
- private static final String PROPERTY_INTEGER_NOT_NULL = "integer-not-null";
- private static final String PROPERTY_STRING_NULL = "string-null";
- private static final String PROPERTY_STRING_ID = "string-not-null";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- public void testEmptyFilteredIndexedContainer() {
- IndexedContainer ic = new IndexedContainer();
-
- addProperties(ic);
- populate(ic);
-
- ic.addContainerFilter(PROPERTY_STRING_ID, "aasdfasdfasdf", true, false);
- ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
-
- }
-
- public void testFilteredIndexedContainer() {
- IndexedContainer ic = new IndexedContainer();
-
- addProperties(ic);
- populate(ic);
-
- ic.addContainerFilter(PROPERTY_STRING_ID, "a", true, false);
- ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
- verifyOrder(ic,
- new String[] { ITEM_ANOTHER_NULL, ITEM_DATA_MINUS1,
- ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS2,
- ITEM_DATA_MINUS2_NULL, });
- }
-
- public void testIndexedContainer() {
- IndexedContainer ic = new IndexedContainer();
-
- addProperties(ic);
- populate(ic);
-
- ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
- verifyOrder(ic, new String[] { ITEM_ANOTHER_NULL, ITEM_DATA_MINUS1,
- ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS2, ITEM_DATA_MINUS2_NULL,
- ITEM_STRING_1, ITEM_STRING_2, ITEM_STRING_NULL2 });
-
- ic.sort(new Object[] { PROPERTY_INTEGER_NOT_NULL,
- PROPERTY_INTEGER_NULL2, PROPERTY_STRING_ID }, new boolean[] {
- true, false, true });
- verifyOrder(ic, new String[] { ITEM_DATA_MINUS2, ITEM_DATA_MINUS2_NULL,
- ITEM_DATA_MINUS1, ITEM_DATA_MINUS1_NULL, ITEM_ANOTHER_NULL,
- ITEM_STRING_NULL2, ITEM_STRING_1, ITEM_STRING_2 });
-
- ic.sort(new Object[] { PROPERTY_INTEGER_NOT_NULL,
- PROPERTY_INTEGER_NULL2, PROPERTY_STRING_ID }, new boolean[] {
- true, true, true });
- verifyOrder(ic, new String[] { ITEM_DATA_MINUS2_NULL, ITEM_DATA_MINUS2,
- ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS1, ITEM_ANOTHER_NULL,
- ITEM_STRING_NULL2, ITEM_STRING_1, ITEM_STRING_2 });
-
- }
-
- public void testHierarchicalContainer() {
- HierarchicalContainer hc = new HierarchicalContainer();
- populateContainer(hc);
- hc.sort(new Object[] { "name" }, new boolean[] { true });
- verifyOrder(hc, new String[] { "Audi", "C++", "Call of Duty", "Cars",
- "English", "Fallout", "Finnish", "Ford", "Games", "Java",
- "Might and Magic", "Natural languages", "PHP",
- "Programming languages", "Python", "Red Alert", "Swedish",
- "Toyota", "Volvo" });
- assertArrays(
- hc.rootItemIds().toArray(),
- new Integer[] { nameToId.get("Cars"), nameToId.get("Games"),
- nameToId.get("Natural languages"),
- nameToId.get("Programming languages") });
- assertArrays(
- hc.getChildren(nameToId.get("Games")).toArray(),
- new Integer[] { nameToId.get("Call of Duty"),
- nameToId.get("Fallout"),
- nameToId.get("Might and Magic"),
- nameToId.get("Red Alert") });
- }
-
- private static void populateContainer(HierarchicalContainer container) {
- container.addContainerProperty("name", String.class, null);
-
- addItem(container, "Games", null);
- addItem(container, "Call of Duty", "Games");
- addItem(container, "Might and Magic", "Games");
- addItem(container, "Fallout", "Games");
- addItem(container, "Red Alert", "Games");
-
- addItem(container, "Cars", null);
- addItem(container, "Toyota", "Cars");
- addItem(container, "Volvo", "Cars");
- addItem(container, "Audi", "Cars");
- addItem(container, "Ford", "Cars");
-
- addItem(container, "Natural languages", null);
- addItem(container, "Swedish", "Natural languages");
- addItem(container, "English", "Natural languages");
- addItem(container, "Finnish", "Natural languages");
-
- addItem(container, "Programming languages", null);
- addItem(container, "C++", "Programming languages");
- addItem(container, "PHP", "Programming languages");
- addItem(container, "Java", "Programming languages");
- addItem(container, "Python", "Programming languages");
-
- }
-
- private static int index = 0;
- private static Map<String, Integer> nameToId = new HashMap<String, Integer>();
- private static Map<Integer, String> idToName = new HashMap<Integer, String>();
-
- public static void addItem(IndexedContainer container, String string,
- String parent) {
- nameToId.put(string, index);
- idToName.put(index, string);
-
- Item item = container.addItem(index);
- item.getItemProperty("name").setValue(string);
-
- if (parent != null && container instanceof HierarchicalContainer) {
- ((HierarchicalContainer) container).setParent(index,
- nameToId.get(parent));
- }
-
- index++;
- }
-
- private void verifyOrder(Container.Sortable ic, Object[] idOrder) {
- int size = ic.size();
- Object[] actual = new Object[size];
- Iterator<?> i = ic.getItemIds().iterator();
- int index = 0;
- while (i.hasNext()) {
- Object o = i.next();
- if (o.getClass() == Integer.class
- && idOrder[index].getClass() == String.class) {
- o = idToName.get(o);
- }
- actual[index++] = o;
- }
-
- assertArrays(actual, idOrder);
-
- }
-
- private void assertArrays(Object[] actualObjects, Object[] expectedObjects) {
- assertEquals(
- "Actual contains a different number of values than was expected",
- expectedObjects.length, actualObjects.length);
-
- for (int i = 0; i < actualObjects.length; i++) {
- Object actual = actualObjects[i];
- Object expected = expectedObjects[i];
-
- assertEquals("Item[" + i + "] does not match", expected, actual);
- }
-
- }
-
- private void populate(IndexedContainer ic) {
- addItem(ic, ITEM_STRING_1, ITEM_STRING_1, 1, 1);
- addItem(ic, ITEM_STRING_NULL2, null, 0, null);
- addItem(ic, ITEM_STRING_2, ITEM_STRING_2, 2, 2);
- addItem(ic, ITEM_ANOTHER_NULL, null, 0, null);
- addItem(ic, ITEM_DATA_MINUS1, ITEM_DATA_MINUS1, -1, -1);
- addItem(ic, ITEM_DATA_MINUS1_NULL, null, -1, null);
- addItem(ic, ITEM_DATA_MINUS2, ITEM_DATA_MINUS2, -2, -2);
- addItem(ic, ITEM_DATA_MINUS2_NULL, null, -2, null);
- }
-
- private Item addItem(Container ic, String id, String string_null,
- int integer, Integer integer_null) {
- Item i = ic.addItem(id);
- i.getItemProperty(PROPERTY_STRING_ID).setValue(id);
- i.getItemProperty(PROPERTY_STRING_NULL).setValue(string_null);
- i.getItemProperty(PROPERTY_INTEGER_NOT_NULL).setValue(integer);
- i.getItemProperty(PROPERTY_INTEGER_NULL2).setValue(integer_null);
-
- return i;
- }
-
- private void addProperties(IndexedContainer ic) {
- ic.addContainerProperty("id", String.class, null);
- ic.addContainerProperty(PROPERTY_STRING_ID, String.class, "");
- ic.addContainerProperty(PROPERTY_STRING_NULL, String.class, null);
- ic.addContainerProperty(PROPERTY_INTEGER_NULL2, Integer.class, null);
- ic.addContainerProperty(PROPERTY_INTEGER_NOT_NULL, Integer.class, 0);
- ic.addContainerProperty("comparable-null", Integer.class, 0);
- }
-
- public class MyObject implements Comparable<MyObject> {
- private String data;
-
- public int compareTo(MyObject o) {
- if (o == null) {
- return 1;
- }
-
- if (o.data == null) {
- return data == null ? 0 : 1;
- } else if (data == null) {
- return -1;
- } else {
- return data.compareTo(o.data);
- }
- }
- }
-
-}
+package com.vaadin.data.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.data.util.IndexedContainer;
+
+public class TestContainerSorting extends TestCase {
+
+ private static final String ITEM_DATA_MINUS2_NULL = "Data -2 null";
+ private static final String ITEM_DATA_MINUS2 = "Data -2";
+ private static final String ITEM_DATA_MINUS1 = "Data -1";
+ private static final String ITEM_DATA_MINUS1_NULL = "Data -1 null";
+ private static final String ITEM_ANOTHER_NULL = "Another null";
+ private static final String ITEM_STRING_2 = "String 2";
+ private static final String ITEM_STRING_NULL2 = "String null";
+ private static final String ITEM_STRING_1 = "String 1";
+
+ private static final String PROPERTY_INTEGER_NULL2 = "integer-null";
+ private static final String PROPERTY_INTEGER_NOT_NULL = "integer-not-null";
+ private static final String PROPERTY_STRING_NULL = "string-null";
+ private static final String PROPERTY_STRING_ID = "string-not-null";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testEmptyFilteredIndexedContainer() {
+ IndexedContainer ic = new IndexedContainer();
+
+ addProperties(ic);
+ populate(ic);
+
+ ic.addContainerFilter(PROPERTY_STRING_ID, "aasdfasdfasdf", true, false);
+ ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
+
+ }
+
+ public void testFilteredIndexedContainer() {
+ IndexedContainer ic = new IndexedContainer();
+
+ addProperties(ic);
+ populate(ic);
+
+ ic.addContainerFilter(PROPERTY_STRING_ID, "a", true, false);
+ ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
+ verifyOrder(ic,
+ new String[] { ITEM_ANOTHER_NULL, ITEM_DATA_MINUS1,
+ ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS2,
+ ITEM_DATA_MINUS2_NULL, });
+ }
+
+ public void testIndexedContainer() {
+ IndexedContainer ic = new IndexedContainer();
+
+ addProperties(ic);
+ populate(ic);
+
+ ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
+ verifyOrder(ic, new String[] { ITEM_ANOTHER_NULL, ITEM_DATA_MINUS1,
+ ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS2, ITEM_DATA_MINUS2_NULL,
+ ITEM_STRING_1, ITEM_STRING_2, ITEM_STRING_NULL2 });
+
+ ic.sort(new Object[] { PROPERTY_INTEGER_NOT_NULL,
+ PROPERTY_INTEGER_NULL2, PROPERTY_STRING_ID }, new boolean[] {
+ true, false, true });
+ verifyOrder(ic, new String[] { ITEM_DATA_MINUS2, ITEM_DATA_MINUS2_NULL,
+ ITEM_DATA_MINUS1, ITEM_DATA_MINUS1_NULL, ITEM_ANOTHER_NULL,
+ ITEM_STRING_NULL2, ITEM_STRING_1, ITEM_STRING_2 });
+
+ ic.sort(new Object[] { PROPERTY_INTEGER_NOT_NULL,
+ PROPERTY_INTEGER_NULL2, PROPERTY_STRING_ID }, new boolean[] {
+ true, true, true });
+ verifyOrder(ic, new String[] { ITEM_DATA_MINUS2_NULL, ITEM_DATA_MINUS2,
+ ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS1, ITEM_ANOTHER_NULL,
+ ITEM_STRING_NULL2, ITEM_STRING_1, ITEM_STRING_2 });
+
+ }
+
+ public void testHierarchicalContainer() {
+ HierarchicalContainer hc = new HierarchicalContainer();
+ populateContainer(hc);
+ hc.sort(new Object[] { "name" }, new boolean[] { true });
+ verifyOrder(hc, new String[] { "Audi", "C++", "Call of Duty", "Cars",
+ "English", "Fallout", "Finnish", "Ford", "Games", "Java",
+ "Might and Magic", "Natural languages", "PHP",
+ "Programming languages", "Python", "Red Alert", "Swedish",
+ "Toyota", "Volvo" });
+ assertArrays(
+ hc.rootItemIds().toArray(),
+ new Integer[] { nameToId.get("Cars"), nameToId.get("Games"),
+ nameToId.get("Natural languages"),
+ nameToId.get("Programming languages") });
+ assertArrays(
+ hc.getChildren(nameToId.get("Games")).toArray(),
+ new Integer[] { nameToId.get("Call of Duty"),
+ nameToId.get("Fallout"),
+ nameToId.get("Might and Magic"),
+ nameToId.get("Red Alert") });
+ }
+
+ private static void populateContainer(HierarchicalContainer container) {
+ container.addContainerProperty("name", String.class, null);
+
+ addItem(container, "Games", null);
+ addItem(container, "Call of Duty", "Games");
+ addItem(container, "Might and Magic", "Games");
+ addItem(container, "Fallout", "Games");
+ addItem(container, "Red Alert", "Games");
+
+ addItem(container, "Cars", null);
+ addItem(container, "Toyota", "Cars");
+ addItem(container, "Volvo", "Cars");
+ addItem(container, "Audi", "Cars");
+ addItem(container, "Ford", "Cars");
+
+ addItem(container, "Natural languages", null);
+ addItem(container, "Swedish", "Natural languages");
+ addItem(container, "English", "Natural languages");
+ addItem(container, "Finnish", "Natural languages");
+
+ addItem(container, "Programming languages", null);
+ addItem(container, "C++", "Programming languages");
+ addItem(container, "PHP", "Programming languages");
+ addItem(container, "Java", "Programming languages");
+ addItem(container, "Python", "Programming languages");
+
+ }
+
+ private static int index = 0;
+ private static Map<String, Integer> nameToId = new HashMap<String, Integer>();
+ private static Map<Integer, String> idToName = new HashMap<Integer, String>();
+
+ public static void addItem(IndexedContainer container, String string,
+ String parent) {
+ nameToId.put(string, index);
+ idToName.put(index, string);
+
+ Item item = container.addItem(index);
+ item.getItemProperty("name").setValue(string);
+
+ if (parent != null && container instanceof HierarchicalContainer) {
+ ((HierarchicalContainer) container).setParent(index,
+ nameToId.get(parent));
+ }
+
+ index++;
+ }
+
+ private void verifyOrder(Container.Sortable ic, Object[] idOrder) {
+ int size = ic.size();
+ Object[] actual = new Object[size];
+ Iterator<?> i = ic.getItemIds().iterator();
+ int index = 0;
+ while (i.hasNext()) {
+ Object o = i.next();
+ if (o.getClass() == Integer.class
+ && idOrder[index].getClass() == String.class) {
+ o = idToName.get(o);
+ }
+ actual[index++] = o;
+ }
+
+ assertArrays(actual, idOrder);
+
+ }
+
+ private void assertArrays(Object[] actualObjects, Object[] expectedObjects) {
+ assertEquals(
+ "Actual contains a different number of values than was expected",
+ expectedObjects.length, actualObjects.length);
+
+ for (int i = 0; i < actualObjects.length; i++) {
+ Object actual = actualObjects[i];
+ Object expected = expectedObjects[i];
+
+ assertEquals("Item[" + i + "] does not match", expected, actual);
+ }
+
+ }
+
+ private void populate(IndexedContainer ic) {
+ addItem(ic, ITEM_STRING_1, ITEM_STRING_1, 1, 1);
+ addItem(ic, ITEM_STRING_NULL2, null, 0, null);
+ addItem(ic, ITEM_STRING_2, ITEM_STRING_2, 2, 2);
+ addItem(ic, ITEM_ANOTHER_NULL, null, 0, null);
+ addItem(ic, ITEM_DATA_MINUS1, ITEM_DATA_MINUS1, -1, -1);
+ addItem(ic, ITEM_DATA_MINUS1_NULL, null, -1, null);
+ addItem(ic, ITEM_DATA_MINUS2, ITEM_DATA_MINUS2, -2, -2);
+ addItem(ic, ITEM_DATA_MINUS2_NULL, null, -2, null);
+ }
+
+ private Item addItem(Container ic, String id, String string_null,
+ int integer, Integer integer_null) {
+ Item i = ic.addItem(id);
+ i.getItemProperty(PROPERTY_STRING_ID).setValue(id);
+ i.getItemProperty(PROPERTY_STRING_NULL).setValue(string_null);
+ i.getItemProperty(PROPERTY_INTEGER_NOT_NULL).setValue(integer);
+ i.getItemProperty(PROPERTY_INTEGER_NULL2).setValue(integer_null);
+
+ return i;
+ }
+
+ private void addProperties(IndexedContainer ic) {
+ ic.addContainerProperty("id", String.class, null);
+ ic.addContainerProperty(PROPERTY_STRING_ID, String.class, "");
+ ic.addContainerProperty(PROPERTY_STRING_NULL, String.class, null);
+ ic.addContainerProperty(PROPERTY_INTEGER_NULL2, Integer.class, null);
+ ic.addContainerProperty(PROPERTY_INTEGER_NOT_NULL, Integer.class, 0);
+ ic.addContainerProperty("comparable-null", Integer.class, 0);
+ }
+
+ public class MyObject implements Comparable<MyObject> {
+ private String data;
+
+ public int compareTo(MyObject o) {
+ if (o == null) {
+ return 1;
+ }
+
+ if (o.data == null) {
+ return data == null ? 0 : 1;
+ } else if (data == null) {
+ return -1;
+ } else {
+ return data.compareTo(o.data);
+ }
+ }
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java b/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java
index 5bbb72fe36..60894dbe6f 100644
--- a/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java
+++ b/tests/server-side/com/vaadin/data/util/TestHierarchicalContainer.java
@@ -1,269 +1,269 @@
-package com.vaadin.data.util;
-
-import com.vaadin.data.Container.Filter;
-import com.vaadin.data.Item;
-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 testSorting() {
- testContainerSorting(new HierarchicalContainer());
- }
-
- public void testOrdered() {
- testContainerOrdered(new HierarchicalContainer());
- }
-
- public void testHierarchicalSorting() {
- testHierarchicalSorting(new HierarchicalContainer());
- }
-
- public void testSortingAndFiltering() {
- testContainerSortingAndFiltering(new HierarchicalContainer());
- }
-
- public void testRemovingItemsFromFilteredContainer() {
- HierarchicalContainer container = new HierarchicalContainer();
- initializeContainer(container);
- container.setIncludeParentsWhenFiltering(true);
- container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
- Object p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertEquals("com.vaadin.ui", p1);
-
- container.removeItem("com.vaadin.ui.TabSheet");
- // Parent for the removed item must be null because the item is no
- // longer in the container
- p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertNull("Parent should be null, is " + p1, p1);
-
- container.removeAllItems();
- p1 = container.getParent("com.vaadin.terminal.gwt.client.Focusable");
- assertNull("Parent should be null, is " + p1, p1);
-
- }
-
- public void testParentWhenRemovingFilterFromContainer() {
- HierarchicalContainer container = new HierarchicalContainer();
- initializeContainer(container);
- container.setIncludeParentsWhenFiltering(true);
- container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
- Object p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertEquals("com.vaadin.ui", p1);
- p1 = container
- .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar");
- assertNull(p1);
- container.removeAllContainerFilters();
- p1 = container
- .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar");
- assertEquals("com.vaadin.terminal.gwt.client.ui", p1);
-
- }
-
- public void testChangeParentInFilteredContainer() {
- HierarchicalContainer container = new HierarchicalContainer();
- initializeContainer(container);
- container.setIncludeParentsWhenFiltering(true);
- container.addContainerFilter(FULLY_QUALIFIED_NAME, "Tab", false, false);
-
- // Change parent of filtered item
- Object p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertEquals("com.vaadin.ui", p1);
- container.setParent("com.vaadin.ui.TabSheet", "com.vaadin");
- p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertEquals("com.vaadin", p1);
- container.setParent("com.vaadin.ui.TabSheet", "com");
- p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertEquals("com", p1);
- container.setParent("com.vaadin.ui.TabSheet", null);
- p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertNull(p1);
-
- // root -> non-root
- container.setParent("com.vaadin.ui.TabSheet", "com");
- p1 = container.getParent("com.vaadin.ui.TabSheet");
- assertEquals("com", p1);
-
- }
-
- public void testHierarchicalFilteringWithParents() {
- HierarchicalContainer container = new HierarchicalContainer();
- initializeContainer(container);
- container.setIncludeParentsWhenFiltering(true);
-
- // Filter by "contains ab"
- container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
-
- // 20 items match the filters and the have 8 parents that should also be
- // included
- // only one root "com" should exist
- // filtered
- int expectedSize = 29;
- int expectedRoots = 1;
-
- validateHierarchicalContainer(container, "com",
- "com.vaadin.ui.TabSheet",
- "com.vaadin.terminal.gwt.client.Focusable", "blah", true,
- expectedSize, expectedRoots, true);
-
- // only include .gwt.client classes
- container.removeAllContainerFilters();
- container.addContainerFilter(FULLY_QUALIFIED_NAME, ".gwt.client.",
- false, false);
-
- int packages = 6;
- int classes = 112;
-
- expectedSize = packages + classes;
- expectedRoots = 1;
-
- validateHierarchicalContainer(container, "com",
- "com.vaadin.terminal.gwt.client.WidgetSet",
- "com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical",
- "blah", true, expectedSize, expectedRoots, true);
-
- // Additionally remove all without 'm' in the simple name.
- container.addContainerFilter(SIMPLE_NAME, "m", false, false);
-
- expectedSize = 7 + 18;
- expectedRoots = 1;
-
- validateHierarchicalContainer(
- container,
- "com",
- "com.vaadin.terminal.gwt.client.ui.VUriFragmentUtility",
- "com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer",
- "blah", true, expectedSize, expectedRoots, true);
-
- }
-
- public void testRemoveLastChild() {
- HierarchicalContainer c = new HierarchicalContainer();
-
- c.addItem("root");
- assertEquals(false, c.hasChildren("root"));
-
- c.addItem("child");
- c.setParent("child", "root");
- assertEquals(true, c.hasChildren("root"));
-
- c.removeItem("child");
- assertFalse(c.containsId("child"));
- assertNull(c.getChildren("root"));
- assertNull(c.getChildren("child"));
- assertFalse(c.hasChildren("child"));
- assertFalse(c.hasChildren("root"));
- }
-
- public void testRemoveLastChildFromFiltered() {
- HierarchicalContainer c = new HierarchicalContainer();
-
- c.addItem("root");
- assertEquals(false, c.hasChildren("root"));
-
- c.addItem("child");
- c.setParent("child", "root");
- assertEquals(true, c.hasChildren("root"));
-
- // Dummy filter that does not remove any items
- c.addContainerFilter(new Filter() {
-
- public boolean passesFilter(Object itemId, Item item)
- throws UnsupportedOperationException {
- return true;
- }
-
- public boolean appliesToProperty(Object propertyId) {
- return true;
- }
- });
- c.removeItem("child");
-
- assertFalse(c.containsId("child"));
- assertNull(c.getChildren("root"));
- assertNull(c.getChildren("child"));
- assertFalse(c.hasChildren("child"));
- assertFalse(c.hasChildren("root"));
- }
-
- public void testHierarchicalFilteringWithoutParents() {
- HierarchicalContainer container = new HierarchicalContainer();
-
- initializeContainer(container);
- container.setIncludeParentsWhenFiltering(false);
-
- // Filter by "contains ab"
- container.addContainerFilter(SIMPLE_NAME, "ab", false, false);
-
- // 20 items match the filter.
- // com.vaadin.data.BufferedValidatable
- // com.vaadin.data.Validatable
- // com.vaadin.terminal.gwt.client.Focusable
- // com.vaadin.terminal.gwt.client.Paintable
- // com.vaadin.terminal.gwt.client.ui.Table
- // com.vaadin.terminal.gwt.client.ui.VLabel
- // com.vaadin.terminal.gwt.client.ui.VScrollTable
- // 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.server.ChangeVariablesErrorEvent
- // com.vaadin.terminal.Paintable
- // com.vaadin.terminal.Scrollable
- // com.vaadin.terminal.Sizeable
- // com.vaadin.terminal.VariableOwner
- // com.vaadin.ui.Label
- // com.vaadin.ui.Table
- // com.vaadin.ui.TableFieldFactory
- // com.vaadin.ui.TabSheet
- // all become roots.
- int expectedSize = 20;
- int expectedRoots = 20;
-
- validateHierarchicalContainer(container,
- "com.vaadin.data.BufferedValidatable",
- "com.vaadin.ui.TabSheet",
- "com.vaadin.terminal.gwt.client.ui.VTabsheetBase", "blah",
- true, expectedSize, expectedRoots, false);
-
- // only include .gwt.client classes
- container.removeAllContainerFilters();
- container.addContainerFilter(FULLY_QUALIFIED_NAME, ".gwt.client.",
- false, false);
-
- int packages = 3;
- int classes = 110;
-
- expectedSize = packages + classes;
- expectedRoots = 35 + 1; // com.vaadin.terminal.gwt.client.ui +
- // com.vaadin.terminal.gwt.client.*
-
- // Sorting is case insensitive
- validateHierarchicalContainer(container,
- "com.vaadin.terminal.gwt.client.ApplicationConfiguration",
- "com.vaadin.terminal.gwt.client.WidgetSet",
- "com.vaadin.terminal.gwt.client.ui.VOptionGroup", "blah", true,
- expectedSize, expectedRoots, false);
-
- // Additionally remove all without 'P' in the simple name.
- container.addContainerFilter(SIMPLE_NAME, "P", false, false);
-
- expectedSize = 13;
- expectedRoots = expectedSize;
-
- validateHierarchicalContainer(container,
- "com.vaadin.terminal.gwt.client.Paintable",
- "com.vaadin.terminal.gwt.client.ui.VTabsheetPanel",
- "com.vaadin.terminal.gwt.client.ui.VPopupCalendar", "blah",
- true, expectedSize, expectedRoots, false);
-
- }
-}
+package com.vaadin.data.util;
+
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.Item;
+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 testSorting() {
+ testContainerSorting(new HierarchicalContainer());
+ }
+
+ public void testOrdered() {
+ testContainerOrdered(new HierarchicalContainer());
+ }
+
+ public void testHierarchicalSorting() {
+ testHierarchicalSorting(new HierarchicalContainer());
+ }
+
+ public void testSortingAndFiltering() {
+ testContainerSortingAndFiltering(new HierarchicalContainer());
+ }
+
+ public void testRemovingItemsFromFilteredContainer() {
+ HierarchicalContainer container = new HierarchicalContainer();
+ initializeContainer(container);
+ container.setIncludeParentsWhenFiltering(true);
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
+ Object p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertEquals("com.vaadin.ui", p1);
+
+ container.removeItem("com.vaadin.ui.TabSheet");
+ // Parent for the removed item must be null because the item is no
+ // longer in the container
+ p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertNull("Parent should be null, is " + p1, p1);
+
+ container.removeAllItems();
+ p1 = container.getParent("com.vaadin.terminal.gwt.client.Focusable");
+ assertNull("Parent should be null, is " + p1, p1);
+
+ }
+
+ public void testParentWhenRemovingFilterFromContainer() {
+ HierarchicalContainer container = new HierarchicalContainer();
+ initializeContainer(container);
+ container.setIncludeParentsWhenFiltering(true);
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
+ Object p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertEquals("com.vaadin.ui", p1);
+ p1 = container
+ .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar");
+ assertNull(p1);
+ container.removeAllContainerFilters();
+ p1 = container
+ .getParent("com.vaadin.terminal.gwt.client.ui.VPopupCalendar");
+ assertEquals("com.vaadin.terminal.gwt.client.ui", p1);
+
+ }
+
+ public void testChangeParentInFilteredContainer() {
+ HierarchicalContainer container = new HierarchicalContainer();
+ initializeContainer(container);
+ container.setIncludeParentsWhenFiltering(true);
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, "Tab", false, false);
+
+ // Change parent of filtered item
+ Object p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertEquals("com.vaadin.ui", p1);
+ container.setParent("com.vaadin.ui.TabSheet", "com.vaadin");
+ p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertEquals("com.vaadin", p1);
+ container.setParent("com.vaadin.ui.TabSheet", "com");
+ p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertEquals("com", p1);
+ container.setParent("com.vaadin.ui.TabSheet", null);
+ p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertNull(p1);
+
+ // root -> non-root
+ container.setParent("com.vaadin.ui.TabSheet", "com");
+ p1 = container.getParent("com.vaadin.ui.TabSheet");
+ assertEquals("com", p1);
+
+ }
+
+ public void testHierarchicalFilteringWithParents() {
+ HierarchicalContainer container = new HierarchicalContainer();
+ initializeContainer(container);
+ container.setIncludeParentsWhenFiltering(true);
+
+ // Filter by "contains ab"
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, "ab", false, false);
+
+ // 20 items match the filters and the have 8 parents that should also be
+ // included
+ // only one root "com" should exist
+ // filtered
+ int expectedSize = 29;
+ int expectedRoots = 1;
+
+ validateHierarchicalContainer(container, "com",
+ "com.vaadin.ui.TabSheet",
+ "com.vaadin.terminal.gwt.client.Focusable", "blah", true,
+ expectedSize, expectedRoots, true);
+
+ // only include .gwt.client classes
+ container.removeAllContainerFilters();
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, ".gwt.client.",
+ false, false);
+
+ int packages = 6;
+ int classes = 112;
+
+ expectedSize = packages + classes;
+ expectedRoots = 1;
+
+ validateHierarchicalContainer(container, "com",
+ "com.vaadin.terminal.gwt.client.WidgetSet",
+ "com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical",
+ "blah", true, expectedSize, expectedRoots, true);
+
+ // Additionally remove all without 'm' in the simple name.
+ container.addContainerFilter(SIMPLE_NAME, "m", false, false);
+
+ expectedSize = 7 + 18;
+ expectedRoots = 1;
+
+ validateHierarchicalContainer(
+ container,
+ "com",
+ "com.vaadin.terminal.gwt.client.ui.VUriFragmentUtility",
+ "com.vaadin.terminal.gwt.client.ui.layout.ChildComponentContainer",
+ "blah", true, expectedSize, expectedRoots, true);
+
+ }
+
+ public void testRemoveLastChild() {
+ HierarchicalContainer c = new HierarchicalContainer();
+
+ c.addItem("root");
+ assertEquals(false, c.hasChildren("root"));
+
+ c.addItem("child");
+ c.setParent("child", "root");
+ assertEquals(true, c.hasChildren("root"));
+
+ c.removeItem("child");
+ assertFalse(c.containsId("child"));
+ assertNull(c.getChildren("root"));
+ assertNull(c.getChildren("child"));
+ assertFalse(c.hasChildren("child"));
+ assertFalse(c.hasChildren("root"));
+ }
+
+ public void testRemoveLastChildFromFiltered() {
+ HierarchicalContainer c = new HierarchicalContainer();
+
+ c.addItem("root");
+ assertEquals(false, c.hasChildren("root"));
+
+ c.addItem("child");
+ c.setParent("child", "root");
+ assertEquals(true, c.hasChildren("root"));
+
+ // Dummy filter that does not remove any items
+ c.addContainerFilter(new Filter() {
+
+ public boolean passesFilter(Object itemId, Item item)
+ throws UnsupportedOperationException {
+ return true;
+ }
+
+ public boolean appliesToProperty(Object propertyId) {
+ return true;
+ }
+ });
+ c.removeItem("child");
+
+ assertFalse(c.containsId("child"));
+ assertNull(c.getChildren("root"));
+ assertNull(c.getChildren("child"));
+ assertFalse(c.hasChildren("child"));
+ assertFalse(c.hasChildren("root"));
+ }
+
+ public void testHierarchicalFilteringWithoutParents() {
+ HierarchicalContainer container = new HierarchicalContainer();
+
+ initializeContainer(container);
+ container.setIncludeParentsWhenFiltering(false);
+
+ // Filter by "contains ab"
+ container.addContainerFilter(SIMPLE_NAME, "ab", false, false);
+
+ // 20 items match the filter.
+ // com.vaadin.data.BufferedValidatable
+ // com.vaadin.data.Validatable
+ // com.vaadin.terminal.gwt.client.Focusable
+ // com.vaadin.terminal.gwt.client.Paintable
+ // com.vaadin.terminal.gwt.client.ui.Table
+ // com.vaadin.terminal.gwt.client.ui.VLabel
+ // com.vaadin.terminal.gwt.client.ui.VScrollTable
+ // 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.server.ChangeVariablesErrorEvent
+ // com.vaadin.terminal.Paintable
+ // com.vaadin.terminal.Scrollable
+ // com.vaadin.terminal.Sizeable
+ // com.vaadin.terminal.VariableOwner
+ // com.vaadin.ui.Label
+ // com.vaadin.ui.Table
+ // com.vaadin.ui.TableFieldFactory
+ // com.vaadin.ui.TabSheet
+ // all become roots.
+ int expectedSize = 20;
+ int expectedRoots = 20;
+
+ validateHierarchicalContainer(container,
+ "com.vaadin.data.BufferedValidatable",
+ "com.vaadin.ui.TabSheet",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheetBase", "blah",
+ true, expectedSize, expectedRoots, false);
+
+ // only include .gwt.client classes
+ container.removeAllContainerFilters();
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, ".gwt.client.",
+ false, false);
+
+ int packages = 3;
+ int classes = 110;
+
+ expectedSize = packages + classes;
+ expectedRoots = 35 + 1; // com.vaadin.terminal.gwt.client.ui +
+ // com.vaadin.terminal.gwt.client.*
+
+ // Sorting is case insensitive
+ validateHierarchicalContainer(container,
+ "com.vaadin.terminal.gwt.client.ApplicationConfiguration",
+ "com.vaadin.terminal.gwt.client.WidgetSet",
+ "com.vaadin.terminal.gwt.client.ui.VOptionGroup", "blah", true,
+ expectedSize, expectedRoots, false);
+
+ // Additionally remove all without 'P' in the simple name.
+ container.addContainerFilter(SIMPLE_NAME, "P", false, false);
+
+ expectedSize = 13;
+ expectedRoots = expectedSize;
+
+ validateHierarchicalContainer(container,
+ "com.vaadin.terminal.gwt.client.Paintable",
+ "com.vaadin.terminal.gwt.client.ui.VTabsheetPanel",
+ "com.vaadin.terminal.gwt.client.ui.VPopupCalendar", "blah",
+ true, expectedSize, expectedRoots, false);
+
+ }
+}
diff --git a/tests/server-side/com/vaadin/data/util/TestIndexedContainer.java b/tests/server-side/com/vaadin/data/util/TestIndexedContainer.java
index 99bd4838cf..156ff83883 100644
--- a/tests/server-side/com/vaadin/data/util/TestIndexedContainer.java
+++ b/tests/server-side/com/vaadin/data/util/TestIndexedContainer.java
@@ -1,271 +1,271 @@
-package com.vaadin.data.util;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-
-public class TestIndexedContainer extends AbstractInMemoryContainerTest {
-
- 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());
- }
-
- public void testContainerIndexed() {
- testContainerIndexed(new IndexedContainer(), sampleData[2], 2, true,
- "newItemId", true);
- }
-
- public void testItemSetChangeListeners() {
- IndexedContainer container = new IndexedContainer();
- ItemSetChangeCounter counter = new ItemSetChangeCounter();
- container.addListener(counter);
-
- String id1 = "id1";
- String id2 = "id2";
- String id3 = "id3";
-
- initializeContainer(container);
- counter.reset();
- container.addItem();
- counter.assertOnce();
- container.addItem(id1);
- counter.assertOnce();
-
- initializeContainer(container);
- counter.reset();
- container.addItemAt(0);
- counter.assertOnce();
- container.addItemAt(0, id1);
- counter.assertOnce();
- container.addItemAt(0, id2);
- counter.assertOnce();
- container.addItemAt(container.size(), id3);
- counter.assertOnce();
- // no notification if already in container
- container.addItemAt(0, id1);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- container.addItemAfter(null);
- counter.assertOnce();
- container.addItemAfter(null, id1);
- counter.assertOnce();
- container.addItemAfter(id1);
- counter.assertOnce();
- container.addItemAfter(id1, id2);
- counter.assertOnce();
- container.addItemAfter(container.firstItemId());
- counter.assertOnce();
- container.addItemAfter(container.lastItemId());
- counter.assertOnce();
- container.addItemAfter(container.lastItemId(), id3);
- counter.assertOnce();
- // no notification if already in container
- container.addItemAfter(0, id1);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- container.removeItem(sampleData[0]);
- counter.assertOnce();
-
- initializeContainer(container);
- counter.reset();
- // no notification for removing a non-existing item
- container.removeItem(id1);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- container.removeAllItems();
- counter.assertOnce();
- // already empty
- container.removeAllItems();
- counter.assertNone();
-
- }
-
- public void testAddRemoveContainerFilter() {
- IndexedContainer container = new IndexedContainer();
- ItemSetChangeCounter counter = new ItemSetChangeCounter();
- container.addListener(counter);
-
- // simply adding or removing container filters should cause events
- // (content changes)
-
- initializeContainer(container);
- counter.reset();
- container.addContainerFilter(SIMPLE_NAME, "a", true, false);
- counter.assertOnce();
- container.removeContainerFilters(SIMPLE_NAME);
- counter.assertOnce();
- container.addContainerFilter(SIMPLE_NAME, "a", true, false);
- counter.assertOnce();
- container.removeAllContainerFilters();
- counter.assertOnce();
- }
-
- // TODO other tests should check positions after removing filter etc,
- // here concentrating on listeners
- public void testItemSetChangeListenersFiltering() {
- IndexedContainer container = new IndexedContainer();
- ItemSetChangeCounter counter = new ItemSetChangeCounter();
- container.addListener(counter);
-
- counter.reset();
- container.addContainerFilter(FULLY_QUALIFIED_NAME, "Test", true, false);
- // no real change, so no notification required
- counter.assertNone();
-
- String id1 = "com.example.Test1";
- String id2 = "com.example.Test2";
- String id3 = "com.example.Other";
-
- // perform operations while filtering container
-
- Item item;
-
- initializeContainer(container);
- counter.reset();
- // passes filter
- item = container.addItem(id1);
- // no event if filtered out
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
- counter.assertOnce();
- // passes filter but already in the container
- item = container.addItem(id1);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- // passes filter after change
- item = container.addItemAt(0, id1);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
- counter.assertOnce();
- item = container.addItemAt(container.size(), id2);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id2);
- counter.assertOnce();
- // passes filter but already in the container
- item = container.addItemAt(0, id1);
- counter.assertNone();
- item = container.addItemAt(container.size(), id2);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- // passes filter
- item = container.addItemAfter(null, id1);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
- counter.assertOnce();
- item = container.addItemAfter(container.lastItemId(), id2);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id2);
- counter.assertOnce();
- // passes filter but already in the container
- item = container.addItemAfter(null, id1);
- counter.assertNone();
- item = container.addItemAfter(container.lastItemId(), id2);
- counter.assertNone();
-
- // does not pass filter
-
- // TODO implement rest
-
- initializeContainer(container);
- counter.reset();
- item = container.addItemAfter(null, id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- item = container.addItemAfter(container.firstItemId(), id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- item = container.addItemAfter(container.lastItemId(), id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- item = container.addItemAt(0, id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- item = container.addItemAt(1, id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
-
- initializeContainer(container);
- counter.reset();
- item = container.addItemAt(container.size(), id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
-
- // passes filter
-
- initializeContainer(container);
- counter.reset();
- item = container.addItem(id1);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
- counter.assertOnce();
- container.removeItem(id1);
- counter.assertOnce();
- // already removed
- container.removeItem(id1);
- counter.assertNone();
-
- item = container.addItem(id3);
- counter.assertNone();
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
- counter.assertNone();
- // not visible
- container.removeItem(id3);
- counter.assertNone();
-
- // remove all
-
- initializeContainer(container);
- item = container.addItem(id1);
- item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
- counter.reset();
- container.removeAllItems();
- counter.assertOnce();
- // no visible items
- container.removeAllItems();
- counter.assertNone();
- }
-
-}
+package com.vaadin.data.util;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+
+public class TestIndexedContainer extends AbstractInMemoryContainerTest {
+
+ 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());
+ }
+
+ public void testContainerIndexed() {
+ testContainerIndexed(new IndexedContainer(), sampleData[2], 2, true,
+ "newItemId", true);
+ }
+
+ public void testItemSetChangeListeners() {
+ IndexedContainer container = new IndexedContainer();
+ ItemSetChangeCounter counter = new ItemSetChangeCounter();
+ container.addListener(counter);
+
+ String id1 = "id1";
+ String id2 = "id2";
+ String id3 = "id3";
+
+ initializeContainer(container);
+ counter.reset();
+ container.addItem();
+ counter.assertOnce();
+ container.addItem(id1);
+ counter.assertOnce();
+
+ initializeContainer(container);
+ counter.reset();
+ container.addItemAt(0);
+ counter.assertOnce();
+ container.addItemAt(0, id1);
+ counter.assertOnce();
+ container.addItemAt(0, id2);
+ counter.assertOnce();
+ container.addItemAt(container.size(), id3);
+ counter.assertOnce();
+ // no notification if already in container
+ container.addItemAt(0, id1);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ container.addItemAfter(null);
+ counter.assertOnce();
+ container.addItemAfter(null, id1);
+ counter.assertOnce();
+ container.addItemAfter(id1);
+ counter.assertOnce();
+ container.addItemAfter(id1, id2);
+ counter.assertOnce();
+ container.addItemAfter(container.firstItemId());
+ counter.assertOnce();
+ container.addItemAfter(container.lastItemId());
+ counter.assertOnce();
+ container.addItemAfter(container.lastItemId(), id3);
+ counter.assertOnce();
+ // no notification if already in container
+ container.addItemAfter(0, id1);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ container.removeItem(sampleData[0]);
+ counter.assertOnce();
+
+ initializeContainer(container);
+ counter.reset();
+ // no notification for removing a non-existing item
+ container.removeItem(id1);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ container.removeAllItems();
+ counter.assertOnce();
+ // already empty
+ container.removeAllItems();
+ counter.assertNone();
+
+ }
+
+ public void testAddRemoveContainerFilter() {
+ IndexedContainer container = new IndexedContainer();
+ ItemSetChangeCounter counter = new ItemSetChangeCounter();
+ container.addListener(counter);
+
+ // simply adding or removing container filters should cause events
+ // (content changes)
+
+ initializeContainer(container);
+ counter.reset();
+ container.addContainerFilter(SIMPLE_NAME, "a", true, false);
+ counter.assertOnce();
+ container.removeContainerFilters(SIMPLE_NAME);
+ counter.assertOnce();
+ container.addContainerFilter(SIMPLE_NAME, "a", true, false);
+ counter.assertOnce();
+ container.removeAllContainerFilters();
+ counter.assertOnce();
+ }
+
+ // TODO other tests should check positions after removing filter etc,
+ // here concentrating on listeners
+ public void testItemSetChangeListenersFiltering() {
+ IndexedContainer container = new IndexedContainer();
+ ItemSetChangeCounter counter = new ItemSetChangeCounter();
+ container.addListener(counter);
+
+ counter.reset();
+ container.addContainerFilter(FULLY_QUALIFIED_NAME, "Test", true, false);
+ // no real change, so no notification required
+ counter.assertNone();
+
+ String id1 = "com.example.Test1";
+ String id2 = "com.example.Test2";
+ String id3 = "com.example.Other";
+
+ // perform operations while filtering container
+
+ Item item;
+
+ initializeContainer(container);
+ counter.reset();
+ // passes filter
+ item = container.addItem(id1);
+ // no event if filtered out
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
+ counter.assertOnce();
+ // passes filter but already in the container
+ item = container.addItem(id1);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ // passes filter after change
+ item = container.addItemAt(0, id1);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
+ counter.assertOnce();
+ item = container.addItemAt(container.size(), id2);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id2);
+ counter.assertOnce();
+ // passes filter but already in the container
+ item = container.addItemAt(0, id1);
+ counter.assertNone();
+ item = container.addItemAt(container.size(), id2);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ // passes filter
+ item = container.addItemAfter(null, id1);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
+ counter.assertOnce();
+ item = container.addItemAfter(container.lastItemId(), id2);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id2);
+ counter.assertOnce();
+ // passes filter but already in the container
+ item = container.addItemAfter(null, id1);
+ counter.assertNone();
+ item = container.addItemAfter(container.lastItemId(), id2);
+ counter.assertNone();
+
+ // does not pass filter
+
+ // TODO implement rest
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItemAfter(null, id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItemAfter(container.firstItemId(), id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItemAfter(container.lastItemId(), id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItemAt(0, id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItemAt(1, id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItemAt(container.size(), id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+
+ // passes filter
+
+ initializeContainer(container);
+ counter.reset();
+ item = container.addItem(id1);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
+ counter.assertOnce();
+ container.removeItem(id1);
+ counter.assertOnce();
+ // already removed
+ container.removeItem(id1);
+ counter.assertNone();
+
+ item = container.addItem(id3);
+ counter.assertNone();
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id3);
+ counter.assertNone();
+ // not visible
+ container.removeItem(id3);
+ counter.assertNone();
+
+ // remove all
+
+ initializeContainer(container);
+ item = container.addItem(id1);
+ item.getItemProperty(FULLY_QUALIFIED_NAME).setValue(id1);
+ counter.reset();
+ container.removeAllItems();
+ counter.assertOnce();
+ // no visible items
+ container.removeAllItems();
+ counter.assertNone();
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
index 58ac123c14..438c40823d 100644
--- a/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
+++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/SQLContainerTableQueryTest.java
@@ -1,1519 +1,1519 @@
-package com.vaadin.data.util.sqlcontainer;
-
-import java.math.BigDecimal;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.Container.ItemSetChangeEvent;
-import com.vaadin.data.Container.ItemSetChangeListener;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.filter.Like;
-import com.vaadin.data.util.sqlcontainer.AllTests.DB;
-import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.query.OrderBy;
-import com.vaadin.data.util.sqlcontainer.query.TableQuery;
-
-public class SQLContainerTableQueryTest {
-
- private static final int offset = AllTests.offset;
- private static final String createGarbage = AllTests.createGarbage;
- private JDBCConnectionPool connectionPool;
-
- @Before
- public void setUp() throws SQLException {
-
- try {
- connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
- AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2);
- } catch (SQLException e) {
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
-
- DataGenerator.addPeopleToDatabase(connectionPool);
- }
-
- @After
- public void tearDown() {
- if (connectionPool != null) {
- connectionPool.destroy();
- }
- }
-
- @Test
- public void constructor_withTableQuery_shouldSucceed() throws SQLException {
- new SQLContainer(new TableQuery("people", connectionPool,
- AllTests.sqlGen));
- }
-
- @Test
- public void containsId_withTableQueryAndExistingId_returnsTrue()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertTrue(container.containsId(new RowId(
- new Object[] { 1 + offset })));
- }
-
- @Test
- public void containsId_withTableQueryAndNonexistingId_returnsFalse()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertFalse(container.containsId(new RowId(
- new Object[] { 1337 + offset })));
- }
-
- @Test
- public void getContainerProperty_tableExistingItemIdAndPropertyId_returnsProperty()
- throws SQLException {
- TableQuery t = new TableQuery("people", connectionPool, AllTests.sqlGen);
- SQLContainer container = new SQLContainer(t);
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- "Ville",
- container
- .getContainerProperty(
- new RowId(new Object[] { new BigDecimal(
- 0 + offset) }), "NAME").getValue());
- } else {
- Assert.assertEquals(
- "Ville",
- container.getContainerProperty(
- new RowId(new Object[] { 0 + offset }), "NAME")
- .getValue());
- }
- }
-
- @Test
- public void getContainerProperty_tableExistingItemIdAndNonexistingPropertyId_returnsNull()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertNull(container.getContainerProperty(new RowId(
- new Object[] { 1 + offset }), "asdf"));
- }
-
- @Test
- public void getContainerProperty_tableNonexistingItemId_returnsNull()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertNull(container.getContainerProperty(new RowId(
- new Object[] { 1337 + offset }), "NAME"));
- }
-
- @Test
- public void getContainerPropertyIds_table_returnsIDAndNAME()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Collection<?> propertyIds = container.getContainerPropertyIds();
- Assert.assertEquals(3, propertyIds.size());
- Assert.assertArrayEquals(new String[] { "ID", "NAME", "AGE" },
- propertyIds.toArray());
- }
-
- @Test
- public void getItem_tableExistingItemId_returnsItem() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Item item;
- if (AllTests.db == DB.ORACLE) {
- item = container.getItem(new RowId(new Object[] { new BigDecimal(
- 0 + offset) }));
- } else {
- item = container.getItem(new RowId(new Object[] { 0 + offset }));
- }
- Assert.assertNotNull(item);
- Assert.assertEquals("Ville", item.getItemProperty("NAME").getValue());
- }
-
- @Test
- public void getItem_commitedModifiedAndRefreshed() throws SQLException {
- String OLD_VALUE = "SomeValue"; //$NON-NLS-1$
- String NEW_VALUE = "OtherValue"; //$NON-NLS-1$
-
- SQLContainer container = new SQLContainer(new TableQuery("people", //$NON-NLS-1$
- connectionPool, AllTests.sqlGen));
- Object itemID = container.addItem();
- Item item = container.getItem(itemID);
- item.getItemProperty("NAME").setValue(OLD_VALUE); //$NON-NLS-1$
- container.commit();
-
- itemID = container.getIdByIndex(container.size() - 1);
- item = container.getItem(itemID);
- Assert.assertEquals(OLD_VALUE, item.getItemProperty("NAME") //$NON-NLS-1$
- .getValue());
- item.getItemProperty("NAME").setValue(NEW_VALUE); //$NON-NLS-1$
-
- // refresh the container which free's the caches
- // and the modified cache keeps untouched which is a really powerful
- // feature
- container.refresh();
-
- // access the item again will use the item from the modified cache.
- item = container.getItem(itemID);
- Assert.assertEquals(NEW_VALUE, item.getItemProperty("NAME") //$NON-NLS-1$
- .getValue());
- }
-
- @Test
- public void getItem_table5000RowsWithParameter1337_returnsItemWithId1337()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
-
- Item item;
- if (AllTests.db == DB.ORACLE) {
- item = container.getItem(new RowId(new Object[] { new BigDecimal(
- 1337 + offset) }));
- Assert.assertNotNull(item);
- Assert.assertEquals(new BigDecimal(1337 + offset), item
- .getItemProperty("ID").getValue());
- } else {
- item = container.getItem(new RowId(new Object[] { 1337 + offset }));
- Assert.assertNotNull(item);
- Assert.assertEquals(1337 + offset, item.getItemProperty("ID")
- .getValue());
- }
- Assert.assertEquals("Person 1337", item.getItemProperty("NAME")
- .getValue());
- }
-
- @Test
- public void getItemIds_table_returnsItemIdsWithKeys0through3()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Collection<?> itemIds = container.getItemIds();
- Assert.assertEquals(4, itemIds.size());
- RowId zero = new RowId(new Object[] { 0 + offset });
- RowId one = new RowId(new Object[] { 1 + offset });
- RowId two = new RowId(new Object[] { 2 + offset });
- RowId three = new RowId(new Object[] { 3 + offset });
- if (AllTests.db == DB.ORACLE) {
- String[] correct = new String[] { "1", "2", "3", "4" };
- List<String> oracle = new ArrayList<String>();
- for (Object o : itemIds) {
- oracle.add(o.toString());
- }
- Assert.assertArrayEquals(correct, oracle.toArray());
- } else {
- Assert.assertArrayEquals(new Object[] { zero, one, two, three },
- itemIds.toArray());
- }
- }
-
- @Test
- public void getType_tableNAMEPropertyId_returnsString() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertEquals(String.class, container.getType("NAME"));
- }
-
- @Test
- public void getType_tableIDPropertyId_returnsInteger() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(BigDecimal.class, container.getType("ID"));
- } else {
- Assert.assertEquals(Integer.class, container.getType("ID"));
- }
- }
-
- @Test
- public void getType_tableNonexistingPropertyId_returnsNull()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertNull(container.getType("asdf"));
- }
-
- @Test
- public void size_table_returnsFour() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertEquals(4, container.size());
- }
-
- @Test
- public void size_tableOneAddedItem_returnsFive() throws SQLException {
- Connection conn = connectionPool.reserveConnection();
- Statement statement = conn.createStatement();
- if (AllTests.db == DB.MSSQL) {
- statement.executeUpdate("insert into people values('Bengt', 30)");
- } else {
- statement
- .executeUpdate("insert into people values(default, 'Bengt', 30)");
- }
- statement.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
-
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertEquals(5, container.size());
- }
-
- @Test
- public void indexOfId_tableWithParameterThree_returnsThree()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(3, container.indexOfId(new RowId(
- new Object[] { new BigDecimal(3 + offset) })));
- } else {
- Assert.assertEquals(3,
- container.indexOfId(new RowId(new Object[] { 3 + offset })));
- }
- }
-
- @Test
- public void indexOfId_table5000RowsWithParameter1337_returns1337()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- TableQuery q = new TableQuery("people", connectionPool, AllTests.sqlGen);
- SQLContainer container = new SQLContainer(q);
- if (AllTests.db == DB.ORACLE) {
- container.getItem(new RowId(new Object[] { new BigDecimal(
- 1337 + offset) }));
- Assert.assertEquals(1337, container.indexOfId(new RowId(
- new Object[] { new BigDecimal(1337 + offset) })));
- } else {
- container.getItem(new RowId(new Object[] { 1337 + offset }));
- Assert.assertEquals(1337, container.indexOfId(new RowId(
- new Object[] { 1337 + offset })));
- }
- }
-
- @Test
- public void getIdByIndex_table5000rowsIndex1337_returnsRowId1337()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object itemId = container.getIdByIndex(1337);
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1337 + offset }).toString(),
- itemId.toString());
- } else {
- Assert.assertEquals(new RowId(new Object[] { 1337 + offset }),
- itemId);
- }
- }
-
- @Test
- public void getIdByIndex_tableWithPaging5000rowsIndex1337_returnsRowId1337()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- Object itemId = container.getIdByIndex(1337);
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1337 + offset }).toString(),
- itemId.toString());
- } else {
- Assert.assertEquals(new RowId(new Object[] { 1337 + offset }),
- itemId);
- }
- }
-
- @Test
- public void nextItemId_tableCurrentItem1337_returnsItem1338()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object itemId = container.getIdByIndex(1337);
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1338 + offset }).toString(),
- container.nextItemId(itemId).toString());
- } else {
- Assert.assertEquals(new RowId(new Object[] { 1338 + offset }),
- container.nextItemId(itemId));
- }
- }
-
- @Test
- public void prevItemId_tableCurrentItem1337_returns1336()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object itemId = container.getIdByIndex(1337);
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 1336 + offset }).toString(),
- container.prevItemId(itemId).toString());
- } else {
- Assert.assertEquals(new RowId(new Object[] { 1336 + offset }),
- container.prevItemId(itemId));
- }
- }
-
- @Test
- public void firstItemId_table_returnsItemId0() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 0 + offset }).toString(),
- container.firstItemId().toString());
- } else {
- Assert.assertEquals(new RowId(new Object[] { 0 + offset }),
- container.firstItemId());
- }
- }
-
- @Test
- public void lastItemId_table5000Rows_returnsItemId4999()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
-
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertEquals(
- new RowId(new Object[] { 4999 + offset }).toString(),
- container.lastItemId().toString());
- } else {
- Assert.assertEquals(new RowId(new Object[] { 4999 + offset }),
- container.lastItemId());
- }
- }
-
- @Test
- public void isFirstId_tableActualFirstId_returnsTrue() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertTrue(container.isFirstId(new RowId(
- new Object[] { new BigDecimal(0 + offset) })));
- } else {
- Assert.assertTrue(container.isFirstId(new RowId(
- new Object[] { 0 + offset })));
- }
- }
-
- @Test
- public void isFirstId_tableSecondId_returnsFalse() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertFalse(container.isFirstId(new RowId(
- new Object[] { new BigDecimal(1 + offset) })));
- } else {
- Assert.assertFalse(container.isFirstId(new RowId(
- new Object[] { 1 + offset })));
- }
- }
-
- @Test
- public void isLastId_tableSecondId_returnsFalse() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertFalse(container.isLastId(new RowId(
- new Object[] { new BigDecimal(1 + offset) })));
- } else {
- Assert.assertFalse(container.isLastId(new RowId(
- new Object[] { 1 + offset })));
- }
- }
-
- @Test
- public void isLastId_tableLastId_returnsTrue() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertTrue(container.isLastId(new RowId(
- new Object[] { new BigDecimal(3 + offset) })));
- } else {
- Assert.assertTrue(container.isLastId(new RowId(
- new Object[] { 3 + offset })));
- }
- }
-
- @Test
- public void isLastId_table5000RowsLastId_returnsTrue() throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- if (AllTests.db == DB.ORACLE) {
- Assert.assertTrue(container.isLastId(new RowId(
- new Object[] { new BigDecimal(4999 + offset) })));
- } else {
- Assert.assertTrue(container.isLastId(new RowId(
- new Object[] { 4999 + offset })));
- }
- }
-
- @Test
- public void allIdsFound_table5000RowsLastId_shouldSucceed()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- for (int i = 0; i < 5000; i++) {
- Assert.assertTrue(container.containsId(container.getIdByIndex(i)));
- }
- }
-
- @Test
- public void allIdsFound_table5000RowsLastId_autoCommit_shouldSucceed()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.setAutoCommit(true);
- for (int i = 0; i < 5000; i++) {
- Assert.assertTrue(container.containsId(container.getIdByIndex(i)));
- }
- }
-
- @Test
- public void refresh_table_sizeShouldUpdate() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertEquals(4, container.size());
- DataGenerator.addFiveThousandPeople(connectionPool);
- container.refresh();
- Assert.assertEquals(5000, container.size());
- }
-
- @Test
- public void refresh_tableWithoutCallingRefresh_sizeShouldNotUpdate()
- throws SQLException {
- // Yeah, this is a weird one. We're testing that the size doesn't update
- // after adding lots of items unless we call refresh inbetween. This to
- // make sure that the refresh method actually refreshes stuff and isn't
- // a NOP.
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertEquals(4, container.size());
- DataGenerator.addFiveThousandPeople(connectionPool);
- Assert.assertEquals(4, container.size());
- }
-
- @Test
- public void setAutoCommit_table_shouldSucceed() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.setAutoCommit(true);
- Assert.assertTrue(container.isAutoCommit());
- container.setAutoCommit(false);
- Assert.assertFalse(container.isAutoCommit());
- }
-
- @Test
- public void getPageLength_table_returnsDefault100() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertEquals(100, container.getPageLength());
- }
-
- @Test
- public void setPageLength_table_shouldSucceed() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.setPageLength(20);
- Assert.assertEquals(20, container.getPageLength());
- container.setPageLength(200);
- Assert.assertEquals(200, container.getPageLength());
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void addContainerProperty_normal_isUnsupported() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addContainerProperty("asdf", String.class, "");
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void removeContainerProperty_normal_isUnsupported()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.removeContainerProperty("asdf");
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void addItemObject_normal_isUnsupported() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItem("asdf");
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void addItemAfterObjectObject_normal_isUnsupported()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItemAfter("asdf", "foo");
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void addItemAtIntObject_normal_isUnsupported() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItemAt(2, "asdf");
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void addItemAtInt_normal_isUnsupported() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItemAt(2);
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void addItemAfterObject_normal_isUnsupported() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItemAfter("asdf");
- }
-
- @Test
- public void addItem_tableAddOneNewItem_returnsItemId() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object itemId = container.addItem();
- Assert.assertNotNull(itemId);
- }
-
- @Test
- public void addItem_tableAddOneNewItem_autoCommit_returnsFinalItemId()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- container.setAutoCommit(true);
- Object itemId = container.addItem();
- Assert.assertNotNull(itemId);
- Assert.assertTrue(itemId instanceof RowId);
- Assert.assertFalse(itemId instanceof TemporaryRowId);
- }
-
- @Test
- public void addItem_tableAddOneNewItem_autoCommit_sizeIsIncreased()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- container.setAutoCommit(true);
- int originalSize = container.size();
- container.addItem();
- Assert.assertEquals(originalSize + 1, container.size());
- }
-
- @Test
- public void addItem_tableAddOneNewItem_shouldChangeSize()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- int size = container.size();
- container.addItem();
- Assert.assertEquals(size + 1, container.size());
- }
-
- @Test
- public void addItem_tableAddTwoNewItems_shouldChangeSize()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- int size = container.size();
- Object id1 = container.addItem();
- Object id2 = container.addItem();
- Assert.assertEquals(size + 2, container.size());
- Assert.assertNotSame(id1, id2);
- Assert.assertFalse(id1.equals(id2));
- }
-
- @Test
- public void nextItemId_tableNewlyAddedItem_returnsNewlyAdded()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object lastId = container.lastItemId();
- Object id = container.addItem();
- Assert.assertEquals(id, container.nextItemId(lastId));
- }
-
- @Test
- public void lastItemId_tableNewlyAddedItem_returnsNewlyAdded()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object lastId = container.lastItemId();
- Object id = container.addItem();
- Assert.assertEquals(id, container.lastItemId());
- Assert.assertNotSame(lastId, container.lastItemId());
- }
-
- @Test
- public void indexOfId_tableNewlyAddedItem_returnsFour() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertEquals(4, container.indexOfId(id));
- }
-
- @Test
- public void getItem_tableNewlyAddedItem_returnsNewlyAdded()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertNotNull(container.getItem(id));
- }
-
- @Test
- public void getItemIds_tableNewlyAddedItem_containsNewlyAdded()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertTrue(container.getItemIds().contains(id));
- }
-
- @Test
- public void getContainerProperty_tableNewlyAddedItem_returnsPropertyOfNewlyAddedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Item item = container.getItem(id);
- item.getItemProperty("NAME").setValue("asdf");
- Assert.assertEquals("asdf", container.getContainerProperty(id, "NAME")
- .getValue());
- }
-
- @Test
- public void containsId_tableNewlyAddedItem_returnsTrue()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertTrue(container.containsId(id));
- }
-
- @Test
- public void prevItemId_tableTwoNewlyAddedItems_returnsFirstAddedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id1 = container.addItem();
- Object id2 = container.addItem();
- Assert.assertEquals(id1, container.prevItemId(id2));
- }
-
- @Test
- public void firstItemId_tableEmptyResultSet_returnsFirstAddedItem()
- throws SQLException {
- DataGenerator.createGarbage(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("garbage",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertSame(id, container.firstItemId());
- }
-
- @Test
- public void isFirstId_tableEmptyResultSet_returnsFirstAddedItem()
- throws SQLException {
- DataGenerator.createGarbage(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("garbage",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertTrue(container.isFirstId(id));
- }
-
- @Test
- public void isLastId_tableOneItemAdded_returnsTrueForAddedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertTrue(container.isLastId(id));
- }
-
- @Test
- public void isLastId_tableTwoItemsAdded_returnsTrueForLastAddedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItem();
- Object id2 = container.addItem();
- Assert.assertTrue(container.isLastId(id2));
- }
-
- @Test
- public void getIdByIndex_tableOneItemAddedLastIndexInContainer_returnsAddedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertEquals(id, container.getIdByIndex(container.size() - 1));
- }
-
- @Test
- public void removeItem_tableNoAddedItems_removesItemFromContainer()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- int size = container.size();
- Object id = container.firstItemId();
- Assert.assertTrue(container.removeItem(id));
- Assert.assertNotSame(id, container.firstItemId());
- Assert.assertEquals(size - 1, container.size());
- }
-
- @Test
- public void containsId_tableRemovedItem_returnsFalse() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.firstItemId();
- Assert.assertTrue(container.removeItem(id));
- Assert.assertFalse(container.containsId(id));
- }
-
- @Test
- public void removeItem_tableOneAddedItem_removesTheAddedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- int size = container.size();
- Assert.assertTrue(container.removeItem(id));
- Assert.assertFalse(container.containsId(id));
- Assert.assertEquals(size - 1, container.size());
- }
-
- @Test
- public void getItem_tableItemRemoved_returnsNull() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.firstItemId();
- Assert.assertTrue(container.removeItem(id));
- Assert.assertNull(container.getItem(id));
- }
-
- @Test
- public void getItem_tableAddedItemRemoved_returnsNull() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertNotNull(container.getItem(id));
- Assert.assertTrue(container.removeItem(id));
- Assert.assertNull(container.getItem(id));
- }
-
- @Test
- public void getItemIds_tableItemRemoved_shouldNotContainRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.firstItemId();
- Assert.assertTrue(container.getItemIds().contains(id));
- Assert.assertTrue(container.removeItem(id));
- Assert.assertFalse(container.getItemIds().contains(id));
- }
-
- @Test
- public void getItemIds_tableAddedItemRemoved_shouldNotContainRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertTrue(container.getItemIds().contains(id));
- Assert.assertTrue(container.removeItem(id));
- Assert.assertFalse(container.getItemIds().contains(id));
- }
-
- @Test
- public void containsId_tableItemRemoved_returnsFalse() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.firstItemId();
- Assert.assertTrue(container.containsId(id));
- Assert.assertTrue(container.removeItem(id));
- Assert.assertFalse(container.containsId(id));
- }
-
- @Test
- public void containsId_tableAddedItemRemoved_returnsFalse()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- Object id = container.addItem();
- Assert.assertTrue(container.containsId(id));
- Assert.assertTrue(container.removeItem(id));
- Assert.assertFalse(container.containsId(id));
- }
-
- @Test
- public void nextItemId_tableItemRemoved_skipsRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object first = container.getIdByIndex(0);
- Object second = container.getIdByIndex(1);
- Object third = container.getIdByIndex(2);
- Assert.assertTrue(container.removeItem(second));
- Assert.assertEquals(third, container.nextItemId(first));
- }
-
- @Test
- public void nextItemId_tableAddedItemRemoved_skipsRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object first = container.lastItemId();
- Object second = container.addItem();
- Object third = container.addItem();
- Assert.assertTrue(container.removeItem(second));
- Assert.assertEquals(third, container.nextItemId(first));
- }
-
- @Test
- public void prevItemId_tableItemRemoved_skipsRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object first = container.getIdByIndex(0);
- Object second = container.getIdByIndex(1);
- Object third = container.getIdByIndex(2);
- Assert.assertTrue(container.removeItem(second));
- Assert.assertEquals(first, container.prevItemId(third));
- }
-
- @Test
- public void prevItemId_tableAddedItemRemoved_skipsRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object first = container.lastItemId();
- Object second = container.addItem();
- Object third = container.addItem();
- Assert.assertTrue(container.removeItem(second));
- Assert.assertEquals(first, container.prevItemId(third));
- }
-
- @Test
- public void firstItemId_tableFirstItemRemoved_resultChanges()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object first = container.firstItemId();
- Assert.assertTrue(container.removeItem(first));
- Assert.assertNotSame(first, container.firstItemId());
- }
-
- @Test
- public void firstItemId_tableNewlyAddedFirstItemRemoved_resultChanges()
- throws SQLException {
- DataGenerator.createGarbage(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("garbage",
- connectionPool, AllTests.sqlGen));
- Object first = container.addItem();
- Object second = container.addItem();
- Assert.assertSame(first, container.firstItemId());
- Assert.assertTrue(container.removeItem(first));
- Assert.assertSame(second, container.firstItemId());
- }
-
- @Test
- public void lastItemId_tableLastItemRemoved_resultChanges()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object last = container.lastItemId();
- Assert.assertTrue(container.removeItem(last));
- Assert.assertNotSame(last, container.lastItemId());
- }
-
- @Test
- public void lastItemId_tableAddedLastItemRemoved_resultChanges()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object last = container.addItem();
- Assert.assertSame(last, container.lastItemId());
- Assert.assertTrue(container.removeItem(last));
- Assert.assertNotSame(last, container.lastItemId());
- }
-
- @Test
- public void isFirstId_tableFirstItemRemoved_returnsFalse()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object first = container.firstItemId();
- Assert.assertTrue(container.removeItem(first));
- Assert.assertFalse(container.isFirstId(first));
- }
-
- @Test
- public void isFirstId_tableAddedFirstItemRemoved_returnsFalse()
- throws SQLException {
- DataGenerator.createGarbage(connectionPool);
- SQLContainer container = new SQLContainer(new TableQuery("garbage",
- connectionPool, AllTests.sqlGen));
- Object first = container.addItem();
- container.addItem();
- Assert.assertSame(first, container.firstItemId());
- Assert.assertTrue(container.removeItem(first));
- Assert.assertFalse(container.isFirstId(first));
- }
-
- @Test
- public void isLastId_tableLastItemRemoved_returnsFalse()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object last = container.lastItemId();
- Assert.assertTrue(container.removeItem(last));
- Assert.assertFalse(container.isLastId(last));
- }
-
- @Test
- public void isLastId_tableAddedLastItemRemoved_returnsFalse()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object last = container.addItem();
- Assert.assertSame(last, container.lastItemId());
- Assert.assertTrue(container.removeItem(last));
- Assert.assertFalse(container.isLastId(last));
- }
-
- @Test
- public void indexOfId_tableItemRemoved_returnsNegOne() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.getIdByIndex(2);
- Assert.assertTrue(container.removeItem(id));
- Assert.assertEquals(-1, container.indexOfId(id));
- }
-
- @Test
- public void indexOfId_tableAddedItemRemoved_returnsNegOne()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- Assert.assertTrue(container.indexOfId(id) != -1);
- Assert.assertTrue(container.removeItem(id));
- Assert.assertEquals(-1, container.indexOfId(id));
- }
-
- @Test
- public void getIdByIndex_tableItemRemoved_resultChanges()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.getIdByIndex(2);
- Assert.assertTrue(container.removeItem(id));
- Assert.assertNotSame(id, container.getIdByIndex(2));
- }
-
- @Test
- public void getIdByIndex_tableAddedItemRemoved_resultChanges()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object id = container.addItem();
- container.addItem();
- int index = container.indexOfId(id);
- Assert.assertTrue(container.removeItem(id));
- Assert.assertNotSame(id, container.getIdByIndex(index));
- }
-
- @Test
- public void removeAllItems_table_shouldSucceed() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertTrue(container.removeAllItems());
- Assert.assertEquals(0, container.size());
- }
-
- @Test
- public void removeAllItems_tableAddedItems_shouldSucceed()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addItem();
- container.addItem();
- Assert.assertTrue(container.removeAllItems());
- Assert.assertEquals(0, container.size());
- }
-
- @Test
- public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- Object id = container.addItem();
- container.getContainerProperty(id, "NAME").setValue("New Name");
- Assert.assertTrue(id instanceof TemporaryRowId);
- Assert.assertSame(id, container.lastItemId());
- container.commit();
- Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
- Assert.assertEquals("New Name",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void commit_tableTwoAddedItems_shouldBeWrittenToDB()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- Object id = container.addItem();
- Object id2 = container.addItem();
- container.getContainerProperty(id, "NAME").setValue("Herbert");
- container.getContainerProperty(id2, "NAME").setValue("Larry");
- Assert.assertTrue(id2 instanceof TemporaryRowId);
- Assert.assertSame(id2, container.lastItemId());
- container.commit();
- Object nextToLast = container.getIdByIndex(container.size() - 2);
- Assert.assertFalse(nextToLast instanceof TemporaryRowId);
- Assert.assertEquals("Herbert",
- container.getContainerProperty(nextToLast, "NAME").getValue());
- Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
- Assert.assertEquals("Larry",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void commit_tableRemovedItem_shouldBeRemovedFromDB()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- Object last = container.lastItemId();
- container.removeItem(last);
- container.commit();
- Assert.assertFalse(last.equals(container.lastItemId()));
- }
-
- @Test
- public void commit_tableLastItemUpdated_shouldUpdateRowInDB()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- Object last = container.lastItemId();
- container.getContainerProperty(last, "NAME").setValue("Donald");
- container.commit();
- Assert.assertEquals("Donald",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void rollback_tableItemAdded_discardsAddedItem() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- int size = container.size();
- Object id = container.addItem();
- container.getContainerProperty(id, "NAME").setValue("foo");
- Assert.assertEquals(size + 1, container.size());
- container.rollback();
- Assert.assertEquals(size, container.size());
- Assert.assertFalse("foo".equals(container.getContainerProperty(
- container.lastItemId(), "NAME").getValue()));
- }
-
- @Test
- public void rollback_tableItemRemoved_restoresRemovedItem()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- int size = container.size();
- Object last = container.lastItemId();
- container.removeItem(last);
- Assert.assertEquals(size - 1, container.size());
- container.rollback();
- Assert.assertEquals(size, container.size());
- Assert.assertEquals(last, container.lastItemId());
- }
-
- @Test
- public void rollback_tableItemChanged_discardsChanges() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Object last = container.lastItemId();
- container.getContainerProperty(last, "NAME").setValue("foo");
- container.rollback();
- Assert.assertFalse("foo".equals(container.getContainerProperty(
- container.lastItemId(), "NAME").getValue()));
- }
-
- @Test
- public void itemChangeNotification_table_isModifiedReturnsTrue()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertFalse(container.isModified());
- RowItem last = (RowItem) container.getItem(container.lastItemId());
- container.itemChangeNotification(last);
- Assert.assertTrue(container.isModified());
- }
-
- @Test
- public void itemSetChangeListeners_table_shouldFire() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- ItemSetChangeListener listener = EasyMock
- .createMock(ItemSetChangeListener.class);
- listener.containerItemSetChange(EasyMock.isA(ItemSetChangeEvent.class));
- EasyMock.replay(listener);
-
- container.addListener(listener);
- container.addItem();
-
- EasyMock.verify(listener);
- }
-
- @Test
- public void itemSetChangeListeners_tableItemRemoved_shouldFire()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- ItemSetChangeListener listener = EasyMock
- .createMock(ItemSetChangeListener.class);
- listener.containerItemSetChange(EasyMock.isA(ItemSetChangeEvent.class));
- EasyMock.expectLastCall().anyTimes();
- EasyMock.replay(listener);
-
- container.addListener(listener);
- container.removeItem(container.lastItemId());
-
- EasyMock.verify(listener);
- }
-
- @Test
- public void removeListener_table_shouldNotFire() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- ItemSetChangeListener listener = EasyMock
- .createMock(ItemSetChangeListener.class);
- EasyMock.replay(listener);
-
- container.addListener(listener);
- container.removeListener(listener);
- container.addItem();
-
- EasyMock.verify(listener);
- }
-
- @Test
- public void isModified_tableRemovedItem_returnsTrue() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertFalse(container.isModified());
- container.removeItem(container.lastItemId());
- Assert.assertTrue(container.isModified());
- }
-
- @Test
- public void isModified_tableAddedItem_returnsTrue() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertFalse(container.isModified());
- container.addItem();
- Assert.assertTrue(container.isModified());
- }
-
- @Test
- public void isModified_tableChangedItem_returnsTrue() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Assert.assertFalse(container.isModified());
- container.getContainerProperty(container.lastItemId(), "NAME")
- .setValue("foo");
- Assert.assertTrue(container.isModified());
- }
-
- @Test
- public void getSortableContainerPropertyIds_table_returnsAllPropertyIds()
- throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- Collection<?> sortableIds = container.getSortableContainerPropertyIds();
- Assert.assertTrue(sortableIds.contains("ID"));
- Assert.assertTrue(sortableIds.contains("NAME"));
- Assert.assertTrue(sortableIds.contains("AGE"));
- Assert.assertEquals(3, sortableIds.size());
- if (AllTests.db == DB.MSSQL || AllTests.db == DB.ORACLE) {
- Assert.assertFalse(sortableIds.contains("rownum"));
- }
- }
-
- @Test
- public void addOrderBy_table_shouldReorderResults() throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.firstItemId(), "NAME")
- .getValue());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- container.addOrderBy(new OrderBy("NAME", true));
- // Börje, Kalle, Pelle, Ville
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.firstItemId(), "NAME")
- .getValue());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void addOrderBy_tableIllegalColumn_shouldFail() throws SQLException {
- SQLContainer container = new SQLContainer(new TableQuery("people",
- connectionPool, AllTests.sqlGen));
- container.addOrderBy(new OrderBy("asdf", true));
- }
-
- @Test
- public void sort_table_sortsByName() throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.firstItemId(), "NAME")
- .getValue());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- container.sort(new Object[] { "NAME" }, new boolean[] { true });
-
- // Börje, Kalle, Pelle, Ville
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.firstItemId(), "NAME")
- .getValue());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void addFilter_table_filtersResults() throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- container.addContainerFilter(new Like("NAME", "%lle"));
- // Ville, Kalle, Pelle
- Assert.assertEquals(3, container.size());
- Assert.assertEquals("Pelle",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void addContainerFilter_filtersResults() throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
-
- container.addContainerFilter("NAME", "Vi", false, false);
-
- // Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void addContainerFilter_ignoreCase_filtersResults()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
-
- container.addContainerFilter("NAME", "vi", true, false);
-
- // Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void removeAllContainerFilters_table_noFiltering()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
-
- container.addContainerFilter("NAME", "Vi", false, false);
-
- // Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- container.removeAllContainerFilters();
-
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void removeContainerFilters_table_noFiltering() throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
-
- container.addContainerFilter("NAME", "Vi", false, false);
-
- // Ville
- Assert.assertEquals(1, container.size());
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- container.removeContainerFilters("NAME");
-
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
- @Test
- public void addFilter_tableBufferedItems_alsoFiltersBufferedItems()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals(4, container.size());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- Object id1 = container.addItem();
- container.getContainerProperty(id1, "NAME").setValue("Palle");
- Object id2 = container.addItem();
- container.getContainerProperty(id2, "NAME").setValue("Bengt");
-
- container.addContainerFilter(new Like("NAME", "%lle"));
-
- // Ville, Kalle, Pelle, Palle
- Assert.assertEquals(4, container.size());
- Assert.assertEquals(
- "Ville",
- container.getContainerProperty(container.getIdByIndex(0),
- "NAME").getValue());
- Assert.assertEquals(
- "Kalle",
- container.getContainerProperty(container.getIdByIndex(1),
- "NAME").getValue());
- Assert.assertEquals(
- "Pelle",
- container.getContainerProperty(container.getIdByIndex(2),
- "NAME").getValue());
- Assert.assertEquals(
- "Palle",
- container.getContainerProperty(container.getIdByIndex(3),
- "NAME").getValue());
-
- Assert.assertNull(container.getIdByIndex(4));
- Assert.assertNull(container.nextItemId(container.getIdByIndex(3)));
-
- Assert.assertFalse(container.containsId(id2));
- Assert.assertFalse(container.getItemIds().contains(id2));
-
- Assert.assertNull(container.getItem(id2));
- Assert.assertEquals(-1, container.indexOfId(id2));
-
- Assert.assertNotSame(id2, container.lastItemId());
- Assert.assertSame(id1, container.lastItemId());
- }
-
- @Test
- public void sort_tableBufferedItems_sortsBufferedItemsLastInOrderAdded()
- throws SQLException {
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
- // Ville, Kalle, Pelle, Börje
- Assert.assertEquals("Ville",
- container.getContainerProperty(container.firstItemId(), "NAME")
- .getValue());
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
-
- Object id1 = container.addItem();
- container.getContainerProperty(id1, "NAME").setValue("Wilbert");
- Object id2 = container.addItem();
- container.getContainerProperty(id2, "NAME").setValue("Albert");
-
- container.sort(new Object[] { "NAME" }, new boolean[] { true });
-
- // Börje, Kalle, Pelle, Ville, Wilbert, Albert
- Assert.assertEquals("Börje",
- container.getContainerProperty(container.firstItemId(), "NAME")
- .getValue());
- Assert.assertEquals(
- "Wilbert",
- container.getContainerProperty(
- container.getIdByIndex(container.size() - 2), "NAME")
- .getValue());
- Assert.assertEquals("Albert",
- container.getContainerProperty(container.lastItemId(), "NAME")
- .getValue());
- }
-
-}
+package com.vaadin.data.util.sqlcontainer;
+
+import java.math.BigDecimal;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.filter.Like;
+import com.vaadin.data.util.sqlcontainer.AllTests.DB;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.OrderBy;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+
+public class SQLContainerTableQueryTest {
+
+ private static final int offset = AllTests.offset;
+ private static final String createGarbage = AllTests.createGarbage;
+ private JDBCConnectionPool connectionPool;
+
+ @Before
+ public void setUp() throws SQLException {
+
+ try {
+ connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
+ AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+
+ DataGenerator.addPeopleToDatabase(connectionPool);
+ }
+
+ @After
+ public void tearDown() {
+ if (connectionPool != null) {
+ connectionPool.destroy();
+ }
+ }
+
+ @Test
+ public void constructor_withTableQuery_shouldSucceed() throws SQLException {
+ new SQLContainer(new TableQuery("people", connectionPool,
+ AllTests.sqlGen));
+ }
+
+ @Test
+ public void containsId_withTableQueryAndExistingId_returnsTrue()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertTrue(container.containsId(new RowId(
+ new Object[] { 1 + offset })));
+ }
+
+ @Test
+ public void containsId_withTableQueryAndNonexistingId_returnsFalse()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertFalse(container.containsId(new RowId(
+ new Object[] { 1337 + offset })));
+ }
+
+ @Test
+ public void getContainerProperty_tableExistingItemIdAndPropertyId_returnsProperty()
+ throws SQLException {
+ TableQuery t = new TableQuery("people", connectionPool, AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(t);
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ "Ville",
+ container
+ .getContainerProperty(
+ new RowId(new Object[] { new BigDecimal(
+ 0 + offset) }), "NAME").getValue());
+ } else {
+ Assert.assertEquals(
+ "Ville",
+ container.getContainerProperty(
+ new RowId(new Object[] { 0 + offset }), "NAME")
+ .getValue());
+ }
+ }
+
+ @Test
+ public void getContainerProperty_tableExistingItemIdAndNonexistingPropertyId_returnsNull()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertNull(container.getContainerProperty(new RowId(
+ new Object[] { 1 + offset }), "asdf"));
+ }
+
+ @Test
+ public void getContainerProperty_tableNonexistingItemId_returnsNull()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertNull(container.getContainerProperty(new RowId(
+ new Object[] { 1337 + offset }), "NAME"));
+ }
+
+ @Test
+ public void getContainerPropertyIds_table_returnsIDAndNAME()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Collection<?> propertyIds = container.getContainerPropertyIds();
+ Assert.assertEquals(3, propertyIds.size());
+ Assert.assertArrayEquals(new String[] { "ID", "NAME", "AGE" },
+ propertyIds.toArray());
+ }
+
+ @Test
+ public void getItem_tableExistingItemId_returnsItem() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Item item;
+ if (AllTests.db == DB.ORACLE) {
+ item = container.getItem(new RowId(new Object[] { new BigDecimal(
+ 0 + offset) }));
+ } else {
+ item = container.getItem(new RowId(new Object[] { 0 + offset }));
+ }
+ Assert.assertNotNull(item);
+ Assert.assertEquals("Ville", item.getItemProperty("NAME").getValue());
+ }
+
+ @Test
+ public void getItem_commitedModifiedAndRefreshed() throws SQLException {
+ String OLD_VALUE = "SomeValue"; //$NON-NLS-1$
+ String NEW_VALUE = "OtherValue"; //$NON-NLS-1$
+
+ SQLContainer container = new SQLContainer(new TableQuery("people", //$NON-NLS-1$
+ connectionPool, AllTests.sqlGen));
+ Object itemID = container.addItem();
+ Item item = container.getItem(itemID);
+ item.getItemProperty("NAME").setValue(OLD_VALUE); //$NON-NLS-1$
+ container.commit();
+
+ itemID = container.getIdByIndex(container.size() - 1);
+ item = container.getItem(itemID);
+ Assert.assertEquals(OLD_VALUE, item.getItemProperty("NAME") //$NON-NLS-1$
+ .getValue());
+ item.getItemProperty("NAME").setValue(NEW_VALUE); //$NON-NLS-1$
+
+ // refresh the container which free's the caches
+ // and the modified cache keeps untouched which is a really powerful
+ // feature
+ container.refresh();
+
+ // access the item again will use the item from the modified cache.
+ item = container.getItem(itemID);
+ Assert.assertEquals(NEW_VALUE, item.getItemProperty("NAME") //$NON-NLS-1$
+ .getValue());
+ }
+
+ @Test
+ public void getItem_table5000RowsWithParameter1337_returnsItemWithId1337()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+
+ Item item;
+ if (AllTests.db == DB.ORACLE) {
+ item = container.getItem(new RowId(new Object[] { new BigDecimal(
+ 1337 + offset) }));
+ Assert.assertNotNull(item);
+ Assert.assertEquals(new BigDecimal(1337 + offset), item
+ .getItemProperty("ID").getValue());
+ } else {
+ item = container.getItem(new RowId(new Object[] { 1337 + offset }));
+ Assert.assertNotNull(item);
+ Assert.assertEquals(1337 + offset, item.getItemProperty("ID")
+ .getValue());
+ }
+ Assert.assertEquals("Person 1337", item.getItemProperty("NAME")
+ .getValue());
+ }
+
+ @Test
+ public void getItemIds_table_returnsItemIdsWithKeys0through3()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Collection<?> itemIds = container.getItemIds();
+ Assert.assertEquals(4, itemIds.size());
+ RowId zero = new RowId(new Object[] { 0 + offset });
+ RowId one = new RowId(new Object[] { 1 + offset });
+ RowId two = new RowId(new Object[] { 2 + offset });
+ RowId three = new RowId(new Object[] { 3 + offset });
+ if (AllTests.db == DB.ORACLE) {
+ String[] correct = new String[] { "1", "2", "3", "4" };
+ List<String> oracle = new ArrayList<String>();
+ for (Object o : itemIds) {
+ oracle.add(o.toString());
+ }
+ Assert.assertArrayEquals(correct, oracle.toArray());
+ } else {
+ Assert.assertArrayEquals(new Object[] { zero, one, two, three },
+ itemIds.toArray());
+ }
+ }
+
+ @Test
+ public void getType_tableNAMEPropertyId_returnsString() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertEquals(String.class, container.getType("NAME"));
+ }
+
+ @Test
+ public void getType_tableIDPropertyId_returnsInteger() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(BigDecimal.class, container.getType("ID"));
+ } else {
+ Assert.assertEquals(Integer.class, container.getType("ID"));
+ }
+ }
+
+ @Test
+ public void getType_tableNonexistingPropertyId_returnsNull()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertNull(container.getType("asdf"));
+ }
+
+ @Test
+ public void size_table_returnsFour() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertEquals(4, container.size());
+ }
+
+ @Test
+ public void size_tableOneAddedItem_returnsFive() throws SQLException {
+ Connection conn = connectionPool.reserveConnection();
+ Statement statement = conn.createStatement();
+ if (AllTests.db == DB.MSSQL) {
+ statement.executeUpdate("insert into people values('Bengt', 30)");
+ } else {
+ statement
+ .executeUpdate("insert into people values(default, 'Bengt', 30)");
+ }
+ statement.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertEquals(5, container.size());
+ }
+
+ @Test
+ public void indexOfId_tableWithParameterThree_returnsThree()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(3, container.indexOfId(new RowId(
+ new Object[] { new BigDecimal(3 + offset) })));
+ } else {
+ Assert.assertEquals(3,
+ container.indexOfId(new RowId(new Object[] { 3 + offset })));
+ }
+ }
+
+ @Test
+ public void indexOfId_table5000RowsWithParameter1337_returns1337()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ TableQuery q = new TableQuery("people", connectionPool, AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(q);
+ if (AllTests.db == DB.ORACLE) {
+ container.getItem(new RowId(new Object[] { new BigDecimal(
+ 1337 + offset) }));
+ Assert.assertEquals(1337, container.indexOfId(new RowId(
+ new Object[] { new BigDecimal(1337 + offset) })));
+ } else {
+ container.getItem(new RowId(new Object[] { 1337 + offset }));
+ Assert.assertEquals(1337, container.indexOfId(new RowId(
+ new Object[] { 1337 + offset })));
+ }
+ }
+
+ @Test
+ public void getIdByIndex_table5000rowsIndex1337_returnsRowId1337()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object itemId = container.getIdByIndex(1337);
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ new RowId(new Object[] { 1337 + offset }).toString(),
+ itemId.toString());
+ } else {
+ Assert.assertEquals(new RowId(new Object[] { 1337 + offset }),
+ itemId);
+ }
+ }
+
+ @Test
+ public void getIdByIndex_tableWithPaging5000rowsIndex1337_returnsRowId1337()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ Object itemId = container.getIdByIndex(1337);
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ new RowId(new Object[] { 1337 + offset }).toString(),
+ itemId.toString());
+ } else {
+ Assert.assertEquals(new RowId(new Object[] { 1337 + offset }),
+ itemId);
+ }
+ }
+
+ @Test
+ public void nextItemId_tableCurrentItem1337_returnsItem1338()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object itemId = container.getIdByIndex(1337);
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ new RowId(new Object[] { 1338 + offset }).toString(),
+ container.nextItemId(itemId).toString());
+ } else {
+ Assert.assertEquals(new RowId(new Object[] { 1338 + offset }),
+ container.nextItemId(itemId));
+ }
+ }
+
+ @Test
+ public void prevItemId_tableCurrentItem1337_returns1336()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object itemId = container.getIdByIndex(1337);
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ new RowId(new Object[] { 1336 + offset }).toString(),
+ container.prevItemId(itemId).toString());
+ } else {
+ Assert.assertEquals(new RowId(new Object[] { 1336 + offset }),
+ container.prevItemId(itemId));
+ }
+ }
+
+ @Test
+ public void firstItemId_table_returnsItemId0() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ new RowId(new Object[] { 0 + offset }).toString(),
+ container.firstItemId().toString());
+ } else {
+ Assert.assertEquals(new RowId(new Object[] { 0 + offset }),
+ container.firstItemId());
+ }
+ }
+
+ @Test
+ public void lastItemId_table5000Rows_returnsItemId4999()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertEquals(
+ new RowId(new Object[] { 4999 + offset }).toString(),
+ container.lastItemId().toString());
+ } else {
+ Assert.assertEquals(new RowId(new Object[] { 4999 + offset }),
+ container.lastItemId());
+ }
+ }
+
+ @Test
+ public void isFirstId_tableActualFirstId_returnsTrue() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertTrue(container.isFirstId(new RowId(
+ new Object[] { new BigDecimal(0 + offset) })));
+ } else {
+ Assert.assertTrue(container.isFirstId(new RowId(
+ new Object[] { 0 + offset })));
+ }
+ }
+
+ @Test
+ public void isFirstId_tableSecondId_returnsFalse() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertFalse(container.isFirstId(new RowId(
+ new Object[] { new BigDecimal(1 + offset) })));
+ } else {
+ Assert.assertFalse(container.isFirstId(new RowId(
+ new Object[] { 1 + offset })));
+ }
+ }
+
+ @Test
+ public void isLastId_tableSecondId_returnsFalse() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertFalse(container.isLastId(new RowId(
+ new Object[] { new BigDecimal(1 + offset) })));
+ } else {
+ Assert.assertFalse(container.isLastId(new RowId(
+ new Object[] { 1 + offset })));
+ }
+ }
+
+ @Test
+ public void isLastId_tableLastId_returnsTrue() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertTrue(container.isLastId(new RowId(
+ new Object[] { new BigDecimal(3 + offset) })));
+ } else {
+ Assert.assertTrue(container.isLastId(new RowId(
+ new Object[] { 3 + offset })));
+ }
+ }
+
+ @Test
+ public void isLastId_table5000RowsLastId_returnsTrue() throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ if (AllTests.db == DB.ORACLE) {
+ Assert.assertTrue(container.isLastId(new RowId(
+ new Object[] { new BigDecimal(4999 + offset) })));
+ } else {
+ Assert.assertTrue(container.isLastId(new RowId(
+ new Object[] { 4999 + offset })));
+ }
+ }
+
+ @Test
+ public void allIdsFound_table5000RowsLastId_shouldSucceed()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ for (int i = 0; i < 5000; i++) {
+ Assert.assertTrue(container.containsId(container.getIdByIndex(i)));
+ }
+ }
+
+ @Test
+ public void allIdsFound_table5000RowsLastId_autoCommit_shouldSucceed()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.setAutoCommit(true);
+ for (int i = 0; i < 5000; i++) {
+ Assert.assertTrue(container.containsId(container.getIdByIndex(i)));
+ }
+ }
+
+ @Test
+ public void refresh_table_sizeShouldUpdate() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertEquals(4, container.size());
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ container.refresh();
+ Assert.assertEquals(5000, container.size());
+ }
+
+ @Test
+ public void refresh_tableWithoutCallingRefresh_sizeShouldNotUpdate()
+ throws SQLException {
+ // Yeah, this is a weird one. We're testing that the size doesn't update
+ // after adding lots of items unless we call refresh inbetween. This to
+ // make sure that the refresh method actually refreshes stuff and isn't
+ // a NOP.
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertEquals(4, container.size());
+ DataGenerator.addFiveThousandPeople(connectionPool);
+ Assert.assertEquals(4, container.size());
+ }
+
+ @Test
+ public void setAutoCommit_table_shouldSucceed() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.setAutoCommit(true);
+ Assert.assertTrue(container.isAutoCommit());
+ container.setAutoCommit(false);
+ Assert.assertFalse(container.isAutoCommit());
+ }
+
+ @Test
+ public void getPageLength_table_returnsDefault100() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertEquals(100, container.getPageLength());
+ }
+
+ @Test
+ public void setPageLength_table_shouldSucceed() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.setPageLength(20);
+ Assert.assertEquals(20, container.getPageLength());
+ container.setPageLength(200);
+ Assert.assertEquals(200, container.getPageLength());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addContainerProperty_normal_isUnsupported() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addContainerProperty("asdf", String.class, "");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeContainerProperty_normal_isUnsupported()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.removeContainerProperty("asdf");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addItemObject_normal_isUnsupported() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItem("asdf");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addItemAfterObjectObject_normal_isUnsupported()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItemAfter("asdf", "foo");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addItemAtIntObject_normal_isUnsupported() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItemAt(2, "asdf");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addItemAtInt_normal_isUnsupported() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItemAt(2);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addItemAfterObject_normal_isUnsupported() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItemAfter("asdf");
+ }
+
+ @Test
+ public void addItem_tableAddOneNewItem_returnsItemId() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object itemId = container.addItem();
+ Assert.assertNotNull(itemId);
+ }
+
+ @Test
+ public void addItem_tableAddOneNewItem_autoCommit_returnsFinalItemId()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ container.setAutoCommit(true);
+ Object itemId = container.addItem();
+ Assert.assertNotNull(itemId);
+ Assert.assertTrue(itemId instanceof RowId);
+ Assert.assertFalse(itemId instanceof TemporaryRowId);
+ }
+
+ @Test
+ public void addItem_tableAddOneNewItem_autoCommit_sizeIsIncreased()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ container.setAutoCommit(true);
+ int originalSize = container.size();
+ container.addItem();
+ Assert.assertEquals(originalSize + 1, container.size());
+ }
+
+ @Test
+ public void addItem_tableAddOneNewItem_shouldChangeSize()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ int size = container.size();
+ container.addItem();
+ Assert.assertEquals(size + 1, container.size());
+ }
+
+ @Test
+ public void addItem_tableAddTwoNewItems_shouldChangeSize()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ int size = container.size();
+ Object id1 = container.addItem();
+ Object id2 = container.addItem();
+ Assert.assertEquals(size + 2, container.size());
+ Assert.assertNotSame(id1, id2);
+ Assert.assertFalse(id1.equals(id2));
+ }
+
+ @Test
+ public void nextItemId_tableNewlyAddedItem_returnsNewlyAdded()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object lastId = container.lastItemId();
+ Object id = container.addItem();
+ Assert.assertEquals(id, container.nextItemId(lastId));
+ }
+
+ @Test
+ public void lastItemId_tableNewlyAddedItem_returnsNewlyAdded()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object lastId = container.lastItemId();
+ Object id = container.addItem();
+ Assert.assertEquals(id, container.lastItemId());
+ Assert.assertNotSame(lastId, container.lastItemId());
+ }
+
+ @Test
+ public void indexOfId_tableNewlyAddedItem_returnsFour() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertEquals(4, container.indexOfId(id));
+ }
+
+ @Test
+ public void getItem_tableNewlyAddedItem_returnsNewlyAdded()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertNotNull(container.getItem(id));
+ }
+
+ @Test
+ public void getItemIds_tableNewlyAddedItem_containsNewlyAdded()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertTrue(container.getItemIds().contains(id));
+ }
+
+ @Test
+ public void getContainerProperty_tableNewlyAddedItem_returnsPropertyOfNewlyAddedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Item item = container.getItem(id);
+ item.getItemProperty("NAME").setValue("asdf");
+ Assert.assertEquals("asdf", container.getContainerProperty(id, "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void containsId_tableNewlyAddedItem_returnsTrue()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertTrue(container.containsId(id));
+ }
+
+ @Test
+ public void prevItemId_tableTwoNewlyAddedItems_returnsFirstAddedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id1 = container.addItem();
+ Object id2 = container.addItem();
+ Assert.assertEquals(id1, container.prevItemId(id2));
+ }
+
+ @Test
+ public void firstItemId_tableEmptyResultSet_returnsFirstAddedItem()
+ throws SQLException {
+ DataGenerator.createGarbage(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("garbage",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertSame(id, container.firstItemId());
+ }
+
+ @Test
+ public void isFirstId_tableEmptyResultSet_returnsFirstAddedItem()
+ throws SQLException {
+ DataGenerator.createGarbage(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("garbage",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertTrue(container.isFirstId(id));
+ }
+
+ @Test
+ public void isLastId_tableOneItemAdded_returnsTrueForAddedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertTrue(container.isLastId(id));
+ }
+
+ @Test
+ public void isLastId_tableTwoItemsAdded_returnsTrueForLastAddedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItem();
+ Object id2 = container.addItem();
+ Assert.assertTrue(container.isLastId(id2));
+ }
+
+ @Test
+ public void getIdByIndex_tableOneItemAddedLastIndexInContainer_returnsAddedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertEquals(id, container.getIdByIndex(container.size() - 1));
+ }
+
+ @Test
+ public void removeItem_tableNoAddedItems_removesItemFromContainer()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ int size = container.size();
+ Object id = container.firstItemId();
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertNotSame(id, container.firstItemId());
+ Assert.assertEquals(size - 1, container.size());
+ }
+
+ @Test
+ public void containsId_tableRemovedItem_returnsFalse() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.firstItemId();
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertFalse(container.containsId(id));
+ }
+
+ @Test
+ public void removeItem_tableOneAddedItem_removesTheAddedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ int size = container.size();
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertFalse(container.containsId(id));
+ Assert.assertEquals(size - 1, container.size());
+ }
+
+ @Test
+ public void getItem_tableItemRemoved_returnsNull() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.firstItemId();
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertNull(container.getItem(id));
+ }
+
+ @Test
+ public void getItem_tableAddedItemRemoved_returnsNull() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertNotNull(container.getItem(id));
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertNull(container.getItem(id));
+ }
+
+ @Test
+ public void getItemIds_tableItemRemoved_shouldNotContainRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.firstItemId();
+ Assert.assertTrue(container.getItemIds().contains(id));
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertFalse(container.getItemIds().contains(id));
+ }
+
+ @Test
+ public void getItemIds_tableAddedItemRemoved_shouldNotContainRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertTrue(container.getItemIds().contains(id));
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertFalse(container.getItemIds().contains(id));
+ }
+
+ @Test
+ public void containsId_tableItemRemoved_returnsFalse() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.firstItemId();
+ Assert.assertTrue(container.containsId(id));
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertFalse(container.containsId(id));
+ }
+
+ @Test
+ public void containsId_tableAddedItemRemoved_returnsFalse()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ Object id = container.addItem();
+ Assert.assertTrue(container.containsId(id));
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertFalse(container.containsId(id));
+ }
+
+ @Test
+ public void nextItemId_tableItemRemoved_skipsRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.getIdByIndex(0);
+ Object second = container.getIdByIndex(1);
+ Object third = container.getIdByIndex(2);
+ Assert.assertTrue(container.removeItem(second));
+ Assert.assertEquals(third, container.nextItemId(first));
+ }
+
+ @Test
+ public void nextItemId_tableAddedItemRemoved_skipsRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.lastItemId();
+ Object second = container.addItem();
+ Object third = container.addItem();
+ Assert.assertTrue(container.removeItem(second));
+ Assert.assertEquals(third, container.nextItemId(first));
+ }
+
+ @Test
+ public void prevItemId_tableItemRemoved_skipsRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.getIdByIndex(0);
+ Object second = container.getIdByIndex(1);
+ Object third = container.getIdByIndex(2);
+ Assert.assertTrue(container.removeItem(second));
+ Assert.assertEquals(first, container.prevItemId(third));
+ }
+
+ @Test
+ public void prevItemId_tableAddedItemRemoved_skipsRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.lastItemId();
+ Object second = container.addItem();
+ Object third = container.addItem();
+ Assert.assertTrue(container.removeItem(second));
+ Assert.assertEquals(first, container.prevItemId(third));
+ }
+
+ @Test
+ public void firstItemId_tableFirstItemRemoved_resultChanges()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.firstItemId();
+ Assert.assertTrue(container.removeItem(first));
+ Assert.assertNotSame(first, container.firstItemId());
+ }
+
+ @Test
+ public void firstItemId_tableNewlyAddedFirstItemRemoved_resultChanges()
+ throws SQLException {
+ DataGenerator.createGarbage(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("garbage",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.addItem();
+ Object second = container.addItem();
+ Assert.assertSame(first, container.firstItemId());
+ Assert.assertTrue(container.removeItem(first));
+ Assert.assertSame(second, container.firstItemId());
+ }
+
+ @Test
+ public void lastItemId_tableLastItemRemoved_resultChanges()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object last = container.lastItemId();
+ Assert.assertTrue(container.removeItem(last));
+ Assert.assertNotSame(last, container.lastItemId());
+ }
+
+ @Test
+ public void lastItemId_tableAddedLastItemRemoved_resultChanges()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object last = container.addItem();
+ Assert.assertSame(last, container.lastItemId());
+ Assert.assertTrue(container.removeItem(last));
+ Assert.assertNotSame(last, container.lastItemId());
+ }
+
+ @Test
+ public void isFirstId_tableFirstItemRemoved_returnsFalse()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.firstItemId();
+ Assert.assertTrue(container.removeItem(first));
+ Assert.assertFalse(container.isFirstId(first));
+ }
+
+ @Test
+ public void isFirstId_tableAddedFirstItemRemoved_returnsFalse()
+ throws SQLException {
+ DataGenerator.createGarbage(connectionPool);
+ SQLContainer container = new SQLContainer(new TableQuery("garbage",
+ connectionPool, AllTests.sqlGen));
+ Object first = container.addItem();
+ container.addItem();
+ Assert.assertSame(first, container.firstItemId());
+ Assert.assertTrue(container.removeItem(first));
+ Assert.assertFalse(container.isFirstId(first));
+ }
+
+ @Test
+ public void isLastId_tableLastItemRemoved_returnsFalse()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object last = container.lastItemId();
+ Assert.assertTrue(container.removeItem(last));
+ Assert.assertFalse(container.isLastId(last));
+ }
+
+ @Test
+ public void isLastId_tableAddedLastItemRemoved_returnsFalse()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object last = container.addItem();
+ Assert.assertSame(last, container.lastItemId());
+ Assert.assertTrue(container.removeItem(last));
+ Assert.assertFalse(container.isLastId(last));
+ }
+
+ @Test
+ public void indexOfId_tableItemRemoved_returnsNegOne() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.getIdByIndex(2);
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertEquals(-1, container.indexOfId(id));
+ }
+
+ @Test
+ public void indexOfId_tableAddedItemRemoved_returnsNegOne()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ Assert.assertTrue(container.indexOfId(id) != -1);
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertEquals(-1, container.indexOfId(id));
+ }
+
+ @Test
+ public void getIdByIndex_tableItemRemoved_resultChanges()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.getIdByIndex(2);
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertNotSame(id, container.getIdByIndex(2));
+ }
+
+ @Test
+ public void getIdByIndex_tableAddedItemRemoved_resultChanges()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object id = container.addItem();
+ container.addItem();
+ int index = container.indexOfId(id);
+ Assert.assertTrue(container.removeItem(id));
+ Assert.assertNotSame(id, container.getIdByIndex(index));
+ }
+
+ @Test
+ public void removeAllItems_table_shouldSucceed() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertTrue(container.removeAllItems());
+ Assert.assertEquals(0, container.size());
+ }
+
+ @Test
+ public void removeAllItems_tableAddedItems_shouldSucceed()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addItem();
+ container.addItem();
+ Assert.assertTrue(container.removeAllItems());
+ Assert.assertEquals(0, container.size());
+ }
+
+ @Test
+ public void commit_tableAddedItem_shouldBeWrittenToDB() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ Object id = container.addItem();
+ container.getContainerProperty(id, "NAME").setValue("New Name");
+ Assert.assertTrue(id instanceof TemporaryRowId);
+ Assert.assertSame(id, container.lastItemId());
+ container.commit();
+ Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
+ Assert.assertEquals("New Name",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void commit_tableTwoAddedItems_shouldBeWrittenToDB()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ Object id = container.addItem();
+ Object id2 = container.addItem();
+ container.getContainerProperty(id, "NAME").setValue("Herbert");
+ container.getContainerProperty(id2, "NAME").setValue("Larry");
+ Assert.assertTrue(id2 instanceof TemporaryRowId);
+ Assert.assertSame(id2, container.lastItemId());
+ container.commit();
+ Object nextToLast = container.getIdByIndex(container.size() - 2);
+ Assert.assertFalse(nextToLast instanceof TemporaryRowId);
+ Assert.assertEquals("Herbert",
+ container.getContainerProperty(nextToLast, "NAME").getValue());
+ Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId);
+ Assert.assertEquals("Larry",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void commit_tableRemovedItem_shouldBeRemovedFromDB()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ Object last = container.lastItemId();
+ container.removeItem(last);
+ container.commit();
+ Assert.assertFalse(last.equals(container.lastItemId()));
+ }
+
+ @Test
+ public void commit_tableLastItemUpdated_shouldUpdateRowInDB()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ Object last = container.lastItemId();
+ container.getContainerProperty(last, "NAME").setValue("Donald");
+ container.commit();
+ Assert.assertEquals("Donald",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void rollback_tableItemAdded_discardsAddedItem() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ int size = container.size();
+ Object id = container.addItem();
+ container.getContainerProperty(id, "NAME").setValue("foo");
+ Assert.assertEquals(size + 1, container.size());
+ container.rollback();
+ Assert.assertEquals(size, container.size());
+ Assert.assertFalse("foo".equals(container.getContainerProperty(
+ container.lastItemId(), "NAME").getValue()));
+ }
+
+ @Test
+ public void rollback_tableItemRemoved_restoresRemovedItem()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ int size = container.size();
+ Object last = container.lastItemId();
+ container.removeItem(last);
+ Assert.assertEquals(size - 1, container.size());
+ container.rollback();
+ Assert.assertEquals(size, container.size());
+ Assert.assertEquals(last, container.lastItemId());
+ }
+
+ @Test
+ public void rollback_tableItemChanged_discardsChanges() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Object last = container.lastItemId();
+ container.getContainerProperty(last, "NAME").setValue("foo");
+ container.rollback();
+ Assert.assertFalse("foo".equals(container.getContainerProperty(
+ container.lastItemId(), "NAME").getValue()));
+ }
+
+ @Test
+ public void itemChangeNotification_table_isModifiedReturnsTrue()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertFalse(container.isModified());
+ RowItem last = (RowItem) container.getItem(container.lastItemId());
+ container.itemChangeNotification(last);
+ Assert.assertTrue(container.isModified());
+ }
+
+ @Test
+ public void itemSetChangeListeners_table_shouldFire() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ ItemSetChangeListener listener = EasyMock
+ .createMock(ItemSetChangeListener.class);
+ listener.containerItemSetChange(EasyMock.isA(ItemSetChangeEvent.class));
+ EasyMock.replay(listener);
+
+ container.addListener(listener);
+ container.addItem();
+
+ EasyMock.verify(listener);
+ }
+
+ @Test
+ public void itemSetChangeListeners_tableItemRemoved_shouldFire()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ ItemSetChangeListener listener = EasyMock
+ .createMock(ItemSetChangeListener.class);
+ listener.containerItemSetChange(EasyMock.isA(ItemSetChangeEvent.class));
+ EasyMock.expectLastCall().anyTimes();
+ EasyMock.replay(listener);
+
+ container.addListener(listener);
+ container.removeItem(container.lastItemId());
+
+ EasyMock.verify(listener);
+ }
+
+ @Test
+ public void removeListener_table_shouldNotFire() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ ItemSetChangeListener listener = EasyMock
+ .createMock(ItemSetChangeListener.class);
+ EasyMock.replay(listener);
+
+ container.addListener(listener);
+ container.removeListener(listener);
+ container.addItem();
+
+ EasyMock.verify(listener);
+ }
+
+ @Test
+ public void isModified_tableRemovedItem_returnsTrue() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertFalse(container.isModified());
+ container.removeItem(container.lastItemId());
+ Assert.assertTrue(container.isModified());
+ }
+
+ @Test
+ public void isModified_tableAddedItem_returnsTrue() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertFalse(container.isModified());
+ container.addItem();
+ Assert.assertTrue(container.isModified());
+ }
+
+ @Test
+ public void isModified_tableChangedItem_returnsTrue() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Assert.assertFalse(container.isModified());
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .setValue("foo");
+ Assert.assertTrue(container.isModified());
+ }
+
+ @Test
+ public void getSortableContainerPropertyIds_table_returnsAllPropertyIds()
+ throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ Collection<?> sortableIds = container.getSortableContainerPropertyIds();
+ Assert.assertTrue(sortableIds.contains("ID"));
+ Assert.assertTrue(sortableIds.contains("NAME"));
+ Assert.assertTrue(sortableIds.contains("AGE"));
+ Assert.assertEquals(3, sortableIds.size());
+ if (AllTests.db == DB.MSSQL || AllTests.db == DB.ORACLE) {
+ Assert.assertFalse(sortableIds.contains("rownum"));
+ }
+ }
+
+ @Test
+ public void addOrderBy_table_shouldReorderResults() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.firstItemId(), "NAME")
+ .getValue());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ container.addOrderBy(new OrderBy("NAME", true));
+ // Börje, Kalle, Pelle, Ville
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.firstItemId(), "NAME")
+ .getValue());
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void addOrderBy_tableIllegalColumn_shouldFail() throws SQLException {
+ SQLContainer container = new SQLContainer(new TableQuery("people",
+ connectionPool, AllTests.sqlGen));
+ container.addOrderBy(new OrderBy("asdf", true));
+ }
+
+ @Test
+ public void sort_table_sortsByName() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.firstItemId(), "NAME")
+ .getValue());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ container.sort(new Object[] { "NAME" }, new boolean[] { true });
+
+ // Börje, Kalle, Pelle, Ville
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.firstItemId(), "NAME")
+ .getValue());
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void addFilter_table_filtersResults() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals(4, container.size());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ container.addContainerFilter(new Like("NAME", "%lle"));
+ // Ville, Kalle, Pelle
+ Assert.assertEquals(3, container.size());
+ Assert.assertEquals("Pelle",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void addContainerFilter_filtersResults() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals(4, container.size());
+
+ container.addContainerFilter("NAME", "Vi", false, false);
+
+ // Ville
+ Assert.assertEquals(1, container.size());
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void addContainerFilter_ignoreCase_filtersResults()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals(4, container.size());
+
+ container.addContainerFilter("NAME", "vi", true, false);
+
+ // Ville
+ Assert.assertEquals(1, container.size());
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void removeAllContainerFilters_table_noFiltering()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals(4, container.size());
+
+ container.addContainerFilter("NAME", "Vi", false, false);
+
+ // Ville
+ Assert.assertEquals(1, container.size());
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ container.removeAllContainerFilters();
+
+ Assert.assertEquals(4, container.size());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void removeContainerFilters_table_noFiltering() throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals(4, container.size());
+
+ container.addContainerFilter("NAME", "Vi", false, false);
+
+ // Ville
+ Assert.assertEquals(1, container.size());
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ container.removeContainerFilters("NAME");
+
+ Assert.assertEquals(4, container.size());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+ @Test
+ public void addFilter_tableBufferedItems_alsoFiltersBufferedItems()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals(4, container.size());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ Object id1 = container.addItem();
+ container.getContainerProperty(id1, "NAME").setValue("Palle");
+ Object id2 = container.addItem();
+ container.getContainerProperty(id2, "NAME").setValue("Bengt");
+
+ container.addContainerFilter(new Like("NAME", "%lle"));
+
+ // Ville, Kalle, Pelle, Palle
+ Assert.assertEquals(4, container.size());
+ Assert.assertEquals(
+ "Ville",
+ container.getContainerProperty(container.getIdByIndex(0),
+ "NAME").getValue());
+ Assert.assertEquals(
+ "Kalle",
+ container.getContainerProperty(container.getIdByIndex(1),
+ "NAME").getValue());
+ Assert.assertEquals(
+ "Pelle",
+ container.getContainerProperty(container.getIdByIndex(2),
+ "NAME").getValue());
+ Assert.assertEquals(
+ "Palle",
+ container.getContainerProperty(container.getIdByIndex(3),
+ "NAME").getValue());
+
+ Assert.assertNull(container.getIdByIndex(4));
+ Assert.assertNull(container.nextItemId(container.getIdByIndex(3)));
+
+ Assert.assertFalse(container.containsId(id2));
+ Assert.assertFalse(container.getItemIds().contains(id2));
+
+ Assert.assertNull(container.getItem(id2));
+ Assert.assertEquals(-1, container.indexOfId(id2));
+
+ Assert.assertNotSame(id2, container.lastItemId());
+ Assert.assertSame(id1, container.lastItemId());
+ }
+
+ @Test
+ public void sort_tableBufferedItems_sortsBufferedItemsLastInOrderAdded()
+ throws SQLException {
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+ // Ville, Kalle, Pelle, Börje
+ Assert.assertEquals("Ville",
+ container.getContainerProperty(container.firstItemId(), "NAME")
+ .getValue());
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+
+ Object id1 = container.addItem();
+ container.getContainerProperty(id1, "NAME").setValue("Wilbert");
+ Object id2 = container.addItem();
+ container.getContainerProperty(id2, "NAME").setValue("Albert");
+
+ container.sort(new Object[] { "NAME" }, new boolean[] { true });
+
+ // Börje, Kalle, Pelle, Ville, Wilbert, Albert
+ Assert.assertEquals("Börje",
+ container.getContainerProperty(container.firstItemId(), "NAME")
+ .getValue());
+ Assert.assertEquals(
+ "Wilbert",
+ container.getContainerProperty(
+ container.getIdByIndex(container.size() - 2), "NAME")
+ .getValue());
+ Assert.assertEquals("Albert",
+ container.getContainerProperty(container.lastItemId(), "NAME")
+ .getValue());
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java
index 58dcdb3227..e62a06e6e1 100644
--- a/tests/server-side/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java
+++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/generator/SQLGeneratorsTest.java
@@ -1,241 +1,241 @@
-package com.vaadin.data.util.sqlcontainer.generator;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.Container.Filter;
-import com.vaadin.data.util.filter.Like;
-import com.vaadin.data.util.filter.Or;
-import com.vaadin.data.util.sqlcontainer.AllTests;
-import com.vaadin.data.util.sqlcontainer.DataGenerator;
-import com.vaadin.data.util.sqlcontainer.RowItem;
-import com.vaadin.data.util.sqlcontainer.SQLContainer;
-import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.query.OrderBy;
-import com.vaadin.data.util.sqlcontainer.query.TableQuery;
-import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
-import com.vaadin.data.util.sqlcontainer.query.generator.MSSQLGenerator;
-import com.vaadin.data.util.sqlcontainer.query.generator.OracleGenerator;
-import com.vaadin.data.util.sqlcontainer.query.generator.SQLGenerator;
-import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
-
-public class SQLGeneratorsTest {
- private JDBCConnectionPool connectionPool;
-
- @Before
- public void setUp() throws SQLException {
-
- try {
- connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
- AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2);
- } catch (SQLException e) {
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
-
- DataGenerator.addPeopleToDatabase(connectionPool);
- }
-
- @After
- public void tearDown() {
- if (connectionPool != null) {
- connectionPool.destroy();
- }
- }
-
- @Test
- public void generateSelectQuery_basicQuery_shouldSucceed() {
- SQLGenerator sg = new DefaultSQLGenerator();
- StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 0, 0,
- null);
- Assert.assertEquals(sh.getQueryString(), "SELECT * FROM TABLE");
- }
-
- @Test
- public void generateSelectQuery_pagingAndColumnsSet_shouldSucceed() {
- SQLGenerator sg = new DefaultSQLGenerator();
- StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 4, 8,
- "COL1, COL2, COL3");
- Assert.assertEquals(sh.getQueryString(),
- "SELECT COL1, COL2, COL3 FROM TABLE LIMIT 8 OFFSET 4");
- }
-
- /**
- * Note: Only tests one kind of filter and ordering.
- */
- @Test
- public void generateSelectQuery_filtersAndOrderingSet_shouldSucceed() {
- SQLGenerator sg = new DefaultSQLGenerator();
- List<com.vaadin.data.Container.Filter> f = new ArrayList<Filter>();
- f.add(new Like("name", "%lle"));
- List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
- StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null);
- Assert.assertEquals(sh.getQueryString(),
- "SELECT * FROM TABLE WHERE \"name\" LIKE ? ORDER BY \"name\" ASC");
- }
-
- @Test
- public void generateSelectQuery_filtersAndOrderingSet_exclusiveFilteringMode_shouldSucceed() {
- SQLGenerator sg = new DefaultSQLGenerator();
- List<Filter> f = new ArrayList<Filter>();
- f.add(new Or(new Like("name", "%lle"), new Like("name", "vi%")));
- List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
- StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null);
- // TODO
- Assert.assertEquals(sh.getQueryString(),
- "SELECT * FROM TABLE WHERE (\"name\" LIKE ? "
- + "OR \"name\" LIKE ?) ORDER BY \"name\" ASC");
- }
-
- @Test
- public void generateDeleteQuery_basicQuery_shouldSucceed()
- throws SQLException {
- /*
- * No need to run this for Oracle/MSSQL generators since the
- * DefaultSQLGenerator method would be called anyway.
- */
- if (AllTests.sqlGen instanceof MSSQLGenerator
- || AllTests.sqlGen instanceof OracleGenerator) {
- return;
- }
- SQLGenerator sg = AllTests.sqlGen;
- TableQuery query = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(query);
-
- StatementHelper sh = sg.generateDeleteQuery(
- "people",
- query.getPrimaryKeyColumns(),
- null,
- (RowItem) container.getItem(container.getItemIds().iterator()
- .next()));
- Assert.assertEquals("DELETE FROM people WHERE \"ID\" = ?",
- sh.getQueryString());
- }
-
- @Test
- public void generateUpdateQuery_basicQuery_shouldSucceed()
- throws SQLException {
- /*
- * No need to run this for Oracle/MSSQL generators since the
- * DefaultSQLGenerator method would be called anyway.
- */
- if (AllTests.sqlGen instanceof MSSQLGenerator
- || AllTests.sqlGen instanceof OracleGenerator) {
- return;
- }
- SQLGenerator sg = new DefaultSQLGenerator();
- TableQuery query = new TableQuery("people", connectionPool);
- SQLContainer container = new SQLContainer(query);
-
- RowItem ri = (RowItem) container.getItem(container.getItemIds()
- .iterator().next());
- ri.getItemProperty("NAME").setValue("Viljami");
-
- StatementHelper sh = sg.generateUpdateQuery("people", ri);
- Assert.assertTrue("UPDATE people SET \"NAME\" = ?, \"AGE\" = ? WHERE \"ID\" = ?"
- .equals(sh.getQueryString())
- || "UPDATE people SET \"AGE\" = ?, \"NAME\" = ? WHERE \"ID\" = ?"
- .equals(sh.getQueryString()));
- }
-
- @Test
- public void generateInsertQuery_basicQuery_shouldSucceed()
- throws SQLException {
- /*
- * No need to run this for Oracle/MSSQL generators since the
- * DefaultSQLGenerator method would be called anyway.
- */
- if (AllTests.sqlGen instanceof MSSQLGenerator
- || AllTests.sqlGen instanceof OracleGenerator) {
- return;
- }
- SQLGenerator sg = new DefaultSQLGenerator();
- TableQuery query = new TableQuery("people", connectionPool);
- SQLContainer container = new SQLContainer(query);
-
- RowItem ri = (RowItem) container.getItem(container.addItem());
- ri.getItemProperty("NAME").setValue("Viljami");
-
- StatementHelper sh = sg.generateInsertQuery("people", ri);
-
- Assert.assertTrue("INSERT INTO people (\"NAME\", \"AGE\") VALUES (?, ?)"
- .equals(sh.getQueryString())
- || "INSERT INTO people (\"AGE\", \"NAME\") VALUES (?, ?)"
- .equals(sh.getQueryString()));
- }
-
- @Test
- public void generateComplexSelectQuery_forOracle_shouldSucceed()
- throws SQLException {
- SQLGenerator sg = new OracleGenerator();
- List<Filter> f = new ArrayList<Filter>();
- f.add(new Like("name", "%lle"));
- List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
- StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
- "NAME, ID");
- Assert.assertEquals(
- "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM"
- + " (SELECT NAME, ID FROM TABLE WHERE \"name\" LIKE ?"
- + " ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12",
- sh.getQueryString());
- }
-
- @Test
- public void generateComplexSelectQuery_forMSSQL_shouldSucceed()
- throws SQLException {
- SQLGenerator sg = new MSSQLGenerator();
- List<Filter> f = new ArrayList<Filter>();
- f.add(new Like("name", "%lle"));
- List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
- StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
- "NAME, ID");
- Assert.assertEquals(sh.getQueryString(),
- "SELECT * FROM (SELECT row_number() OVER "
- + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID "
- + "FROM TABLE WHERE \"name\" LIKE ?) "
- + "AS a WHERE a.rownum BETWEEN 5 AND 12");
- }
-
- @Test
- public void generateComplexSelectQuery_forOracle_exclusiveFilteringMode_shouldSucceed()
- throws SQLException {
- SQLGenerator sg = new OracleGenerator();
- List<Filter> f = new ArrayList<Filter>();
- f.add(new Or(new Like("name", "%lle"), new Like("name", "vi%")));
- List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
- StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
- "NAME, ID");
- Assert.assertEquals(
- sh.getQueryString(),
- "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM"
- + " (SELECT NAME, ID FROM TABLE WHERE (\"name\" LIKE ?"
- + " OR \"name\" LIKE ?) "
- + "ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12");
- }
-
- @Test
- public void generateComplexSelectQuery_forMSSQL_exclusiveFilteringMode_shouldSucceed()
- throws SQLException {
- SQLGenerator sg = new MSSQLGenerator();
- List<Filter> f = new ArrayList<Filter>();
- f.add(new Or(new Like("name", "%lle"), new Like("name", "vi%")));
- List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
- StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
- "NAME, ID");
- Assert.assertEquals(sh.getQueryString(),
- "SELECT * FROM (SELECT row_number() OVER "
- + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID "
- + "FROM TABLE WHERE (\"name\" LIKE ? "
- + "OR \"name\" LIKE ?)) "
- + "AS a WHERE a.rownum BETWEEN 5 AND 12");
- }
-}
+package com.vaadin.data.util.sqlcontainer.generator;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.util.filter.Like;
+import com.vaadin.data.util.filter.Or;
+import com.vaadin.data.util.sqlcontainer.AllTests;
+import com.vaadin.data.util.sqlcontainer.DataGenerator;
+import com.vaadin.data.util.sqlcontainer.RowItem;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.OrderBy;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
+import com.vaadin.data.util.sqlcontainer.query.generator.MSSQLGenerator;
+import com.vaadin.data.util.sqlcontainer.query.generator.OracleGenerator;
+import com.vaadin.data.util.sqlcontainer.query.generator.SQLGenerator;
+import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
+
+public class SQLGeneratorsTest {
+ private JDBCConnectionPool connectionPool;
+
+ @Before
+ public void setUp() throws SQLException {
+
+ try {
+ connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
+ AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+
+ DataGenerator.addPeopleToDatabase(connectionPool);
+ }
+
+ @After
+ public void tearDown() {
+ if (connectionPool != null) {
+ connectionPool.destroy();
+ }
+ }
+
+ @Test
+ public void generateSelectQuery_basicQuery_shouldSucceed() {
+ SQLGenerator sg = new DefaultSQLGenerator();
+ StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 0, 0,
+ null);
+ Assert.assertEquals(sh.getQueryString(), "SELECT * FROM TABLE");
+ }
+
+ @Test
+ public void generateSelectQuery_pagingAndColumnsSet_shouldSucceed() {
+ SQLGenerator sg = new DefaultSQLGenerator();
+ StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 4, 8,
+ "COL1, COL2, COL3");
+ Assert.assertEquals(sh.getQueryString(),
+ "SELECT COL1, COL2, COL3 FROM TABLE LIMIT 8 OFFSET 4");
+ }
+
+ /**
+ * Note: Only tests one kind of filter and ordering.
+ */
+ @Test
+ public void generateSelectQuery_filtersAndOrderingSet_shouldSucceed() {
+ SQLGenerator sg = new DefaultSQLGenerator();
+ List<com.vaadin.data.Container.Filter> f = new ArrayList<Filter>();
+ f.add(new Like("name", "%lle"));
+ List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
+ StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null);
+ Assert.assertEquals(sh.getQueryString(),
+ "SELECT * FROM TABLE WHERE \"name\" LIKE ? ORDER BY \"name\" ASC");
+ }
+
+ @Test
+ public void generateSelectQuery_filtersAndOrderingSet_exclusiveFilteringMode_shouldSucceed() {
+ SQLGenerator sg = new DefaultSQLGenerator();
+ List<Filter> f = new ArrayList<Filter>();
+ f.add(new Or(new Like("name", "%lle"), new Like("name", "vi%")));
+ List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
+ StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null);
+ // TODO
+ Assert.assertEquals(sh.getQueryString(),
+ "SELECT * FROM TABLE WHERE (\"name\" LIKE ? "
+ + "OR \"name\" LIKE ?) ORDER BY \"name\" ASC");
+ }
+
+ @Test
+ public void generateDeleteQuery_basicQuery_shouldSucceed()
+ throws SQLException {
+ /*
+ * No need to run this for Oracle/MSSQL generators since the
+ * DefaultSQLGenerator method would be called anyway.
+ */
+ if (AllTests.sqlGen instanceof MSSQLGenerator
+ || AllTests.sqlGen instanceof OracleGenerator) {
+ return;
+ }
+ SQLGenerator sg = AllTests.sqlGen;
+ TableQuery query = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(query);
+
+ StatementHelper sh = sg.generateDeleteQuery(
+ "people",
+ query.getPrimaryKeyColumns(),
+ null,
+ (RowItem) container.getItem(container.getItemIds().iterator()
+ .next()));
+ Assert.assertEquals("DELETE FROM people WHERE \"ID\" = ?",
+ sh.getQueryString());
+ }
+
+ @Test
+ public void generateUpdateQuery_basicQuery_shouldSucceed()
+ throws SQLException {
+ /*
+ * No need to run this for Oracle/MSSQL generators since the
+ * DefaultSQLGenerator method would be called anyway.
+ */
+ if (AllTests.sqlGen instanceof MSSQLGenerator
+ || AllTests.sqlGen instanceof OracleGenerator) {
+ return;
+ }
+ SQLGenerator sg = new DefaultSQLGenerator();
+ TableQuery query = new TableQuery("people", connectionPool);
+ SQLContainer container = new SQLContainer(query);
+
+ RowItem ri = (RowItem) container.getItem(container.getItemIds()
+ .iterator().next());
+ ri.getItemProperty("NAME").setValue("Viljami");
+
+ StatementHelper sh = sg.generateUpdateQuery("people", ri);
+ Assert.assertTrue("UPDATE people SET \"NAME\" = ?, \"AGE\" = ? WHERE \"ID\" = ?"
+ .equals(sh.getQueryString())
+ || "UPDATE people SET \"AGE\" = ?, \"NAME\" = ? WHERE \"ID\" = ?"
+ .equals(sh.getQueryString()));
+ }
+
+ @Test
+ public void generateInsertQuery_basicQuery_shouldSucceed()
+ throws SQLException {
+ /*
+ * No need to run this for Oracle/MSSQL generators since the
+ * DefaultSQLGenerator method would be called anyway.
+ */
+ if (AllTests.sqlGen instanceof MSSQLGenerator
+ || AllTests.sqlGen instanceof OracleGenerator) {
+ return;
+ }
+ SQLGenerator sg = new DefaultSQLGenerator();
+ TableQuery query = new TableQuery("people", connectionPool);
+ SQLContainer container = new SQLContainer(query);
+
+ RowItem ri = (RowItem) container.getItem(container.addItem());
+ ri.getItemProperty("NAME").setValue("Viljami");
+
+ StatementHelper sh = sg.generateInsertQuery("people", ri);
+
+ Assert.assertTrue("INSERT INTO people (\"NAME\", \"AGE\") VALUES (?, ?)"
+ .equals(sh.getQueryString())
+ || "INSERT INTO people (\"AGE\", \"NAME\") VALUES (?, ?)"
+ .equals(sh.getQueryString()));
+ }
+
+ @Test
+ public void generateComplexSelectQuery_forOracle_shouldSucceed()
+ throws SQLException {
+ SQLGenerator sg = new OracleGenerator();
+ List<Filter> f = new ArrayList<Filter>();
+ f.add(new Like("name", "%lle"));
+ List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
+ StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
+ "NAME, ID");
+ Assert.assertEquals(
+ "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM"
+ + " (SELECT NAME, ID FROM TABLE WHERE \"name\" LIKE ?"
+ + " ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12",
+ sh.getQueryString());
+ }
+
+ @Test
+ public void generateComplexSelectQuery_forMSSQL_shouldSucceed()
+ throws SQLException {
+ SQLGenerator sg = new MSSQLGenerator();
+ List<Filter> f = new ArrayList<Filter>();
+ f.add(new Like("name", "%lle"));
+ List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
+ StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
+ "NAME, ID");
+ Assert.assertEquals(sh.getQueryString(),
+ "SELECT * FROM (SELECT row_number() OVER "
+ + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID "
+ + "FROM TABLE WHERE \"name\" LIKE ?) "
+ + "AS a WHERE a.rownum BETWEEN 5 AND 12");
+ }
+
+ @Test
+ public void generateComplexSelectQuery_forOracle_exclusiveFilteringMode_shouldSucceed()
+ throws SQLException {
+ SQLGenerator sg = new OracleGenerator();
+ List<Filter> f = new ArrayList<Filter>();
+ f.add(new Or(new Like("name", "%lle"), new Like("name", "vi%")));
+ List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
+ StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
+ "NAME, ID");
+ Assert.assertEquals(
+ sh.getQueryString(),
+ "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM"
+ + " (SELECT NAME, ID FROM TABLE WHERE (\"name\" LIKE ?"
+ + " OR \"name\" LIKE ?) "
+ + "ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12");
+ }
+
+ @Test
+ public void generateComplexSelectQuery_forMSSQL_exclusiveFilteringMode_shouldSucceed()
+ throws SQLException {
+ SQLGenerator sg = new MSSQLGenerator();
+ List<Filter> f = new ArrayList<Filter>();
+ f.add(new Or(new Like("name", "%lle"), new Like("name", "vi%")));
+ List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
+ StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8,
+ "NAME, ID");
+ Assert.assertEquals(sh.getQueryString(),
+ "SELECT * FROM (SELECT row_number() OVER "
+ + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID "
+ + "FROM TABLE WHERE (\"name\" LIKE ? "
+ + "OR \"name\" LIKE ?)) "
+ + "AS a WHERE a.rownum BETWEEN 5 AND 12");
+ }
+}
diff --git a/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java b/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java
index 52f7e273c6..657f06ae5e 100644
--- a/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java
+++ b/tests/server-side/com/vaadin/data/util/sqlcontainer/query/TableQueryTest.java
@@ -1,663 +1,663 @@
-package com.vaadin.data.util.sqlcontainer.query;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.vaadin.data.Container.Filter;
-import com.vaadin.data.util.filter.Compare.Equal;
-import com.vaadin.data.util.filter.Like;
-import com.vaadin.data.util.sqlcontainer.AllTests;
-import com.vaadin.data.util.sqlcontainer.DataGenerator;
-import com.vaadin.data.util.sqlcontainer.OptimisticLockException;
-import com.vaadin.data.util.sqlcontainer.RowItem;
-import com.vaadin.data.util.sqlcontainer.SQLContainer;
-import com.vaadin.data.util.sqlcontainer.AllTests.DB;
-import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.query.OrderBy;
-import com.vaadin.data.util.sqlcontainer.query.TableQuery;
-import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
-
-public class TableQueryTest {
- private static final int offset = AllTests.offset;
- private JDBCConnectionPool connectionPool;
-
- @Before
- public void setUp() throws SQLException {
-
- try {
- connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
- AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2);
- } catch (SQLException e) {
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
-
- DataGenerator.addPeopleToDatabase(connectionPool);
- }
-
- @After
- public void tearDown() {
- if (connectionPool != null) {
- connectionPool.destroy();
- }
- }
-
- /**********************************************************************
- * TableQuery construction tests
- **********************************************************************/
- @Test
- public void construction_legalParameters_shouldSucceed() {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- new DefaultSQLGenerator());
- Assert.assertArrayEquals(new Object[] { "ID" }, tQuery
- .getPrimaryKeyColumns().toArray());
- boolean correctTableName = "people".equalsIgnoreCase(tQuery
- .getTableName());
- Assert.assertTrue(correctTableName);
- }
-
- @Test
- public void construction_legalParameters_defaultGenerator_shouldSucceed() {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- Assert.assertArrayEquals(new Object[] { "ID" }, tQuery
- .getPrimaryKeyColumns().toArray());
- boolean correctTableName = "people".equalsIgnoreCase(tQuery
- .getTableName());
- Assert.assertTrue(correctTableName);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void construction_nonExistingTableName_shouldFail() {
- new TableQuery("skgwaguhsd", connectionPool, new DefaultSQLGenerator());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void construction_emptyTableName_shouldFail() {
- new TableQuery("", connectionPool, new DefaultSQLGenerator());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void construction_nullSqlGenerator_shouldFail() {
- new TableQuery("people", connectionPool, null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void construction_nullConnectionPool_shouldFail() {
- new TableQuery("people", null, new DefaultSQLGenerator());
- }
-
- /**********************************************************************
- * TableQuery row count tests
- **********************************************************************/
- @Test
- public void getCount_simpleQuery_returnsFour() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- Assert.assertEquals(4, tQuery.getCount());
- }
-
- @Test
- public void getCount_simpleQueryTwoMorePeopleAdded_returnsSix()
- throws SQLException {
- // Add some people
- Connection conn = connectionPool.reserveConnection();
- Statement statement = conn.createStatement();
- if (AllTests.db == DB.MSSQL) {
- statement.executeUpdate("insert into people values('Bengt', 30)");
- statement.executeUpdate("insert into people values('Ingvar', 50)");
- } else {
- statement
- .executeUpdate("insert into people values(default, 'Bengt', 30)");
- statement
- .executeUpdate("insert into people values(default, 'Ingvar', 50)");
- }
- statement.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
-
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- Assert.assertEquals(6, tQuery.getCount());
- }
-
- @Test
- public void getCount_normalState_releasesConnection() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.getCount();
- tQuery.getCount();
- Assert.assertNotNull(connectionPool.reserveConnection());
- }
-
- /**********************************************************************
- * TableQuery get results tests
- **********************************************************************/
- @Test
- public void getResults_simpleQuery_returnsFourRecords() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.beginTransaction();
- ResultSet rs = tQuery.getResults(0, 0);
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(0 + offset, rs.getInt(1));
- Assert.assertEquals("Ville", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(1 + offset, rs.getInt(1));
- Assert.assertEquals("Kalle", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(2 + offset, rs.getInt(1));
- Assert.assertEquals("Pelle", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(3 + offset, rs.getInt(1));
- Assert.assertEquals("Börje", rs.getString(2));
-
- Assert.assertFalse(rs.next());
- tQuery.commit();
- }
-
- @Test
- public void getResults_noDelegate5000Rows_returns5000rows()
- throws SQLException {
- DataGenerator.addFiveThousandPeople(connectionPool);
-
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- tQuery.beginTransaction();
- ResultSet rs = tQuery.getResults(0, 0);
- for (int i = 0; i < 5000; i++) {
- Assert.assertTrue(rs.next());
- }
- Assert.assertFalse(rs.next());
- tQuery.commit();
- }
-
- /**********************************************************************
- * TableQuery transaction management tests
- **********************************************************************/
- @Test
- public void beginTransaction_readOnly_shouldSucceed() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.beginTransaction();
- }
-
- @Test(expected = IllegalStateException.class)
- public void beginTransaction_transactionAlreadyActive_shouldFail()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- tQuery.beginTransaction();
- tQuery.beginTransaction();
- }
-
- @Test
- public void commit_readOnly_shouldSucceed() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.beginTransaction();
- tQuery.commit();
- }
-
- @Test
- public void rollback_readOnly_shouldSucceed() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.beginTransaction();
- tQuery.rollback();
- }
-
- @Test(expected = SQLException.class)
- public void commit_noActiveTransaction_shouldFail() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.commit();
- }
-
- @Test(expected = SQLException.class)
- public void rollback_noActiveTransaction_shouldFail() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.rollback();
- }
-
- /**********************************************************************
- * TableQuery row query with given keys tests
- **********************************************************************/
- @Test
- public void containsRowWithKeys_existingKeys_returnsTrue()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- Assert.assertTrue(tQuery.containsRowWithKey(1));
- }
-
- @Test
- public void containsRowWithKeys_nonexistingKeys_returnsTrue()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- Assert.assertFalse(tQuery.containsRowWithKey(1337));
- }
-
- @Test
- public void containsRowWithKeys_invalidKeys_shouldFail()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- boolean b = true;
- try {
- b = tQuery.containsRowWithKey("foo");
- } catch (SQLException se) {
- return;
- }
- Assert.assertFalse(b);
- }
-
- @Test
- public void containsRowWithKeys_nullKeys_shouldFailAndReleaseConnections()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- try {
- tQuery.containsRowWithKey(new Object[] { null });
- } catch (SQLException e) {
- // We should now be able to reserve two connections
- connectionPool.reserveConnection();
- connectionPool.reserveConnection();
- }
- }
-
- /**********************************************************************
- * TableQuery filtering and ordering tests
- **********************************************************************/
- @Test
- public void setFilters_shouldReturnCorrectCount() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- List<Filter> filters = new ArrayList<Filter>();
- filters.add(new Like("NAME", "%lle"));
- tQuery.setFilters(filters);
- Assert.assertEquals(3, tQuery.getCount());
- }
-
- @Test
- public void setOrderByNameAscending_shouldReturnCorrectOrder()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- List<OrderBy> orderBys = Arrays.asList(new OrderBy("NAME", true));
- tQuery.setOrderBy(orderBys);
-
- tQuery.beginTransaction();
- ResultSet rs;
- rs = tQuery.getResults(0, 0);
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(3 + offset, rs.getInt(1));
- Assert.assertEquals("Börje", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(1 + offset, rs.getInt(1));
- Assert.assertEquals("Kalle", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(2 + offset, rs.getInt(1));
- Assert.assertEquals("Pelle", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(0 + offset, rs.getInt(1));
- Assert.assertEquals("Ville", rs.getString(2));
-
- Assert.assertFalse(rs.next());
- tQuery.commit();
- }
-
- @Test
- public void setOrderByNameDescending_shouldReturnCorrectOrder()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- List<OrderBy> orderBys = Arrays.asList(new OrderBy("NAME", false));
- tQuery.setOrderBy(orderBys);
-
- tQuery.beginTransaction();
- ResultSet rs;
- rs = tQuery.getResults(0, 0);
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(0 + offset, rs.getInt(1));
- Assert.assertEquals("Ville", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(2 + offset, rs.getInt(1));
- Assert.assertEquals("Pelle", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(1 + offset, rs.getInt(1));
- Assert.assertEquals("Kalle", rs.getString(2));
-
- Assert.assertTrue(rs.next());
- Assert.assertEquals(3 + offset, rs.getInt(1));
- Assert.assertEquals("Börje", rs.getString(2));
-
- Assert.assertFalse(rs.next());
- tQuery.commit();
- }
-
- @Test
- public void setFilters_nullParameter_shouldSucceed() {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.setFilters(null);
- }
-
- @Test
- public void setOrderBy_nullParameter_shouldSucceed() {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.setOrderBy(null);
- }
-
- /**********************************************************************
- * TableQuery row removal tests
- **********************************************************************/
- @Test
- public void removeRowThroughContainer_legalRowItem_shouldSucceed()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(tQuery);
- container.setAutoCommit(false);
- Assert.assertTrue(container.removeItem(container.getItemIds()
- .iterator().next()));
-
- Assert.assertEquals(4, tQuery.getCount());
- Assert.assertEquals(3, container.size());
- container.commit();
-
- Assert.assertEquals(3, tQuery.getCount());
- Assert.assertEquals(3, container.size());
- }
-
- @Test
- public void removeRowThroughContainer_nonexistingRowId_shouldFail()
- throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- SQLContainer container = new SQLContainer(tQuery);
- container.setAutoCommit(true);
- Assert.assertFalse(container.removeItem("foo"));
- }
-
- /**********************************************************************
- * TableQuery row adding / modification tests
- **********************************************************************/
- @Test
- public void insertRowThroughContainer_shouldSucceed() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- tQuery.setVersionColumn("ID");
-
- SQLContainer container = new SQLContainer(tQuery);
- container.setAutoCommit(false);
-
- Object item = container.addItem();
- Assert.assertNotNull(item);
-
- Assert.assertEquals(4, tQuery.getCount());
- Assert.assertEquals(5, container.size());
- container.commit();
-
- Assert.assertEquals(5, tQuery.getCount());
- Assert.assertEquals(5, container.size());
- }
-
- @Test
- public void modifyRowThroughContainer_shouldSucceed() throws SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
-
- // In this test the primary key is used as a version column
- tQuery.setVersionColumn("ID");
- SQLContainer container = new SQLContainer(tQuery);
- container.setAutoCommit(false);
-
- /* Check that the container size is correct and there is no 'Viljami' */
- Assert.assertEquals(4, container.size());
- List<Filter> filters = new ArrayList<Filter>();
- filters.add(new Equal("NAME", "Viljami"));
- tQuery.setFilters(filters);
- Assert.assertEquals(0, tQuery.getCount());
- tQuery.setFilters(null);
-
- /* Fetch first item, modify and commit */
- Object item = container.getItem(container.getItemIds().iterator()
- .next());
- Assert.assertNotNull(item);
-
- RowItem ri = (RowItem) item;
- Assert.assertNotNull(ri.getItemProperty("NAME"));
- ri.getItemProperty("NAME").setValue("Viljami");
-
- container.commit();
-
- // Check that the size is still correct and only 1 'Viljami' is found
- Assert.assertEquals(4, tQuery.getCount());
- Assert.assertEquals(4, container.size());
- tQuery.setFilters(filters);
- Assert.assertEquals(1, tQuery.getCount());
- }
-
- @Test
- public void storeRow_noVersionColumn_shouldSucceed()
- throws UnsupportedOperationException, SQLException {
- TableQuery tQuery = new TableQuery("people", connectionPool,
- AllTests.sqlGen);
- SQLContainer container = new SQLContainer(tQuery);
- Object id = container.addItem();
- RowItem row = (RowItem) container.getItem(id);
- row.getItemProperty("NAME").setValue("R2D2");
- row.getItemProperty("AGE").setValue(123);
- tQuery.beginTransaction();
- tQuery.storeRow(row);
- tQuery.commit();
-
- Connection conn = connectionPool.reserveConnection();
- PreparedStatement stmt = conn
- .prepareStatement("SELECT * FROM PEOPLE WHERE \"NAME\" = ?");
- stmt.setString(1, "R2D2");
- ResultSet rs = stmt.executeQuery();
- Assert.assertTrue(rs.next());
- rs.close();
- stmt.close();
- connectionPool.releaseConnection(conn);
- }
-
- @Test
- public void storeRow_versionSetAndEqualToDBValue_shouldSucceed()
- throws SQLException {
- DataGenerator.addVersionedData(connectionPool);
-
- TableQuery tQuery = new TableQuery("versioned", connectionPool,
- AllTests.sqlGen);
- tQuery.setVersionColumn("VERSION");
- SQLContainer container = new SQLContainer(tQuery);
- RowItem row = (RowItem) container.getItem(container.firstItemId());
- Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
-
- row.getItemProperty("TEXT").setValue("asdf");
- container.commit();
-
- Connection conn = connectionPool.reserveConnection();
- PreparedStatement stmt = conn
- .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?");
- stmt.setString(1, "asdf");
- ResultSet rs = stmt.executeQuery();
- Assert.assertTrue(rs.next());
- rs.close();
- stmt.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
- }
-
- @Test(expected = OptimisticLockException.class)
- public void storeRow_versionSetAndLessThanDBValue_shouldThrowException()
- throws SQLException {
- if (AllTests.db == DB.HSQLDB) {
- throw new OptimisticLockException(
- "HSQLDB doesn't support row versioning for optimistic locking - don't run this test.",
- null);
- }
- DataGenerator.addVersionedData(connectionPool);
-
- TableQuery tQuery = new TableQuery("versioned", connectionPool,
- AllTests.sqlGen);
- tQuery.setVersionColumn("VERSION");
- SQLContainer container = new SQLContainer(tQuery);
- RowItem row = (RowItem) container.getItem(container.firstItemId());
- Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
-
- row.getItemProperty("TEXT").setValue("asdf");
-
- // Update the version using another connection.
- Connection conn = connectionPool.reserveConnection();
- PreparedStatement stmt = conn
- .prepareStatement("UPDATE VERSIONED SET \"TEXT\" = ? WHERE \"ID\" = ?");
- stmt.setString(1, "foo");
- stmt.setObject(2, row.getItemProperty("ID").getValue());
- stmt.executeUpdate();
- stmt.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
-
- container.commit();
- }
-
- @Test
- public void removeRow_versionSetAndEqualToDBValue_shouldSucceed()
- throws SQLException {
- DataGenerator.addVersionedData(connectionPool);
-
- TableQuery tQuery = new TableQuery("versioned", connectionPool,
- AllTests.sqlGen);
- tQuery.setVersionColumn("VERSION");
- SQLContainer container = new SQLContainer(tQuery);
- RowItem row = (RowItem) container.getItem(container.firstItemId());
- Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
-
- container.removeItem(container.firstItemId());
- container.commit();
-
- Connection conn = connectionPool.reserveConnection();
- PreparedStatement stmt = conn
- .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?");
- stmt.setString(1, "Junk");
- ResultSet rs = stmt.executeQuery();
- Assert.assertFalse(rs.next());
- rs.close();
- stmt.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
- }
-
- @Test(expected = OptimisticLockException.class)
- public void removeRow_versionSetAndLessThanDBValue_shouldThrowException()
- throws SQLException {
- if (AllTests.db == AllTests.DB.HSQLDB) {
- // HSQLDB doesn't support versioning, so this is to make the test
- // green.
- throw new OptimisticLockException(null);
- }
- DataGenerator.addVersionedData(connectionPool);
-
- TableQuery tQuery = new TableQuery("versioned", connectionPool,
- AllTests.sqlGen);
- tQuery.setVersionColumn("VERSION");
- SQLContainer container = new SQLContainer(tQuery);
- RowItem row = (RowItem) container.getItem(container.firstItemId());
- Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
-
- // Update the version using another connection.
- Connection conn = connectionPool.reserveConnection();
- PreparedStatement stmt = conn
- .prepareStatement("UPDATE VERSIONED SET \"TEXT\" = ? WHERE \"ID\" = ?");
- stmt.setString(1, "asdf");
- stmt.setObject(2, row.getItemProperty("ID").getValue());
- stmt.executeUpdate();
- stmt.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
-
- container.removeItem(container.firstItemId());
- container.commit();
- }
-
- @Test
- public void removeRow_throwsOptimisticLockException_shouldStillWork()
- throws SQLException {
- if (AllTests.db == AllTests.DB.HSQLDB) {
- // HSQLDB doesn't support versioning, so this is to make the test
- // green.
- return;
- }
- DataGenerator.addVersionedData(connectionPool);
-
- TableQuery tQuery = new TableQuery("versioned", connectionPool,
- AllTests.sqlGen);
- tQuery.setVersionColumn("VERSION");
- SQLContainer container = new SQLContainer(tQuery);
- RowItem row = (RowItem) container.getItem(container.firstItemId());
- Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
-
- // Update the version using another connection.
- Connection conn = connectionPool.reserveConnection();
- PreparedStatement stmt = conn
- .prepareStatement("UPDATE VERSIONED SET \"TEXT\" = ? WHERE \"ID\" = ?");
- stmt.setString(1, "asdf");
- stmt.setObject(2, row.getItemProperty("ID").getValue());
- stmt.executeUpdate();
- stmt.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
-
- Object itemToRemove = container.firstItemId();
- try {
- container.removeItem(itemToRemove);
- container.commit();
- } catch (OptimisticLockException e) {
- // This is expected, refresh and try again.
- container.rollback();
- container.removeItem(itemToRemove);
- container.commit();
- }
- Object id = container.addItem();
- RowItem item = (RowItem) container.getItem(id);
- item.getItemProperty("TEXT").setValue("foo");
- container.commit();
- }
-
+package com.vaadin.data.util.sqlcontainer.query;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.util.filter.Compare.Equal;
+import com.vaadin.data.util.filter.Like;
+import com.vaadin.data.util.sqlcontainer.AllTests;
+import com.vaadin.data.util.sqlcontainer.DataGenerator;
+import com.vaadin.data.util.sqlcontainer.OptimisticLockException;
+import com.vaadin.data.util.sqlcontainer.RowItem;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.data.util.sqlcontainer.AllTests.DB;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.OrderBy;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
+
+public class TableQueryTest {
+ private static final int offset = AllTests.offset;
+ private JDBCConnectionPool connectionPool;
+
+ @Before
+ public void setUp() throws SQLException {
+
+ try {
+ connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
+ AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 2);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+
+ DataGenerator.addPeopleToDatabase(connectionPool);
+ }
+
+ @After
+ public void tearDown() {
+ if (connectionPool != null) {
+ connectionPool.destroy();
+ }
+ }
+
+ /**********************************************************************
+ * TableQuery construction tests
+ **********************************************************************/
+ @Test
+ public void construction_legalParameters_shouldSucceed() {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ new DefaultSQLGenerator());
+ Assert.assertArrayEquals(new Object[] { "ID" }, tQuery
+ .getPrimaryKeyColumns().toArray());
+ boolean correctTableName = "people".equalsIgnoreCase(tQuery
+ .getTableName());
+ Assert.assertTrue(correctTableName);
+ }
+
+ @Test
+ public void construction_legalParameters_defaultGenerator_shouldSucceed() {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ Assert.assertArrayEquals(new Object[] { "ID" }, tQuery
+ .getPrimaryKeyColumns().toArray());
+ boolean correctTableName = "people".equalsIgnoreCase(tQuery
+ .getTableName());
+ Assert.assertTrue(correctTableName);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void construction_nonExistingTableName_shouldFail() {
+ new TableQuery("skgwaguhsd", connectionPool, new DefaultSQLGenerator());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void construction_emptyTableName_shouldFail() {
+ new TableQuery("", connectionPool, new DefaultSQLGenerator());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void construction_nullSqlGenerator_shouldFail() {
+ new TableQuery("people", connectionPool, null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void construction_nullConnectionPool_shouldFail() {
+ new TableQuery("people", null, new DefaultSQLGenerator());
+ }
+
+ /**********************************************************************
+ * TableQuery row count tests
+ **********************************************************************/
+ @Test
+ public void getCount_simpleQuery_returnsFour() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ Assert.assertEquals(4, tQuery.getCount());
+ }
+
+ @Test
+ public void getCount_simpleQueryTwoMorePeopleAdded_returnsSix()
+ throws SQLException {
+ // Add some people
+ Connection conn = connectionPool.reserveConnection();
+ Statement statement = conn.createStatement();
+ if (AllTests.db == DB.MSSQL) {
+ statement.executeUpdate("insert into people values('Bengt', 30)");
+ statement.executeUpdate("insert into people values('Ingvar', 50)");
+ } else {
+ statement
+ .executeUpdate("insert into people values(default, 'Bengt', 30)");
+ statement
+ .executeUpdate("insert into people values(default, 'Ingvar', 50)");
+ }
+ statement.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ Assert.assertEquals(6, tQuery.getCount());
+ }
+
+ @Test
+ public void getCount_normalState_releasesConnection() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.getCount();
+ tQuery.getCount();
+ Assert.assertNotNull(connectionPool.reserveConnection());
+ }
+
+ /**********************************************************************
+ * TableQuery get results tests
+ **********************************************************************/
+ @Test
+ public void getResults_simpleQuery_returnsFourRecords() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.beginTransaction();
+ ResultSet rs = tQuery.getResults(0, 0);
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(0 + offset, rs.getInt(1));
+ Assert.assertEquals("Ville", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(1 + offset, rs.getInt(1));
+ Assert.assertEquals("Kalle", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(2 + offset, rs.getInt(1));
+ Assert.assertEquals("Pelle", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(3 + offset, rs.getInt(1));
+ Assert.assertEquals("Börje", rs.getString(2));
+
+ Assert.assertFalse(rs.next());
+ tQuery.commit();
+ }
+
+ @Test
+ public void getResults_noDelegate5000Rows_returns5000rows()
+ throws SQLException {
+ DataGenerator.addFiveThousandPeople(connectionPool);
+
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ tQuery.beginTransaction();
+ ResultSet rs = tQuery.getResults(0, 0);
+ for (int i = 0; i < 5000; i++) {
+ Assert.assertTrue(rs.next());
+ }
+ Assert.assertFalse(rs.next());
+ tQuery.commit();
+ }
+
+ /**********************************************************************
+ * TableQuery transaction management tests
+ **********************************************************************/
+ @Test
+ public void beginTransaction_readOnly_shouldSucceed() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.beginTransaction();
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void beginTransaction_transactionAlreadyActive_shouldFail()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ tQuery.beginTransaction();
+ tQuery.beginTransaction();
+ }
+
+ @Test
+ public void commit_readOnly_shouldSucceed() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.beginTransaction();
+ tQuery.commit();
+ }
+
+ @Test
+ public void rollback_readOnly_shouldSucceed() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.beginTransaction();
+ tQuery.rollback();
+ }
+
+ @Test(expected = SQLException.class)
+ public void commit_noActiveTransaction_shouldFail() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.commit();
+ }
+
+ @Test(expected = SQLException.class)
+ public void rollback_noActiveTransaction_shouldFail() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.rollback();
+ }
+
+ /**********************************************************************
+ * TableQuery row query with given keys tests
+ **********************************************************************/
+ @Test
+ public void containsRowWithKeys_existingKeys_returnsTrue()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ Assert.assertTrue(tQuery.containsRowWithKey(1));
+ }
+
+ @Test
+ public void containsRowWithKeys_nonexistingKeys_returnsTrue()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ Assert.assertFalse(tQuery.containsRowWithKey(1337));
+ }
+
+ @Test
+ public void containsRowWithKeys_invalidKeys_shouldFail()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ boolean b = true;
+ try {
+ b = tQuery.containsRowWithKey("foo");
+ } catch (SQLException se) {
+ return;
+ }
+ Assert.assertFalse(b);
+ }
+
+ @Test
+ public void containsRowWithKeys_nullKeys_shouldFailAndReleaseConnections()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ try {
+ tQuery.containsRowWithKey(new Object[] { null });
+ } catch (SQLException e) {
+ // We should now be able to reserve two connections
+ connectionPool.reserveConnection();
+ connectionPool.reserveConnection();
+ }
+ }
+
+ /**********************************************************************
+ * TableQuery filtering and ordering tests
+ **********************************************************************/
+ @Test
+ public void setFilters_shouldReturnCorrectCount() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ List<Filter> filters = new ArrayList<Filter>();
+ filters.add(new Like("NAME", "%lle"));
+ tQuery.setFilters(filters);
+ Assert.assertEquals(3, tQuery.getCount());
+ }
+
+ @Test
+ public void setOrderByNameAscending_shouldReturnCorrectOrder()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ List<OrderBy> orderBys = Arrays.asList(new OrderBy("NAME", true));
+ tQuery.setOrderBy(orderBys);
+
+ tQuery.beginTransaction();
+ ResultSet rs;
+ rs = tQuery.getResults(0, 0);
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(3 + offset, rs.getInt(1));
+ Assert.assertEquals("Börje", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(1 + offset, rs.getInt(1));
+ Assert.assertEquals("Kalle", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(2 + offset, rs.getInt(1));
+ Assert.assertEquals("Pelle", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(0 + offset, rs.getInt(1));
+ Assert.assertEquals("Ville", rs.getString(2));
+
+ Assert.assertFalse(rs.next());
+ tQuery.commit();
+ }
+
+ @Test
+ public void setOrderByNameDescending_shouldReturnCorrectOrder()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ List<OrderBy> orderBys = Arrays.asList(new OrderBy("NAME", false));
+ tQuery.setOrderBy(orderBys);
+
+ tQuery.beginTransaction();
+ ResultSet rs;
+ rs = tQuery.getResults(0, 0);
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(0 + offset, rs.getInt(1));
+ Assert.assertEquals("Ville", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(2 + offset, rs.getInt(1));
+ Assert.assertEquals("Pelle", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(1 + offset, rs.getInt(1));
+ Assert.assertEquals("Kalle", rs.getString(2));
+
+ Assert.assertTrue(rs.next());
+ Assert.assertEquals(3 + offset, rs.getInt(1));
+ Assert.assertEquals("Börje", rs.getString(2));
+
+ Assert.assertFalse(rs.next());
+ tQuery.commit();
+ }
+
+ @Test
+ public void setFilters_nullParameter_shouldSucceed() {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setFilters(null);
+ }
+
+ @Test
+ public void setOrderBy_nullParameter_shouldSucceed() {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setOrderBy(null);
+ }
+
+ /**********************************************************************
+ * TableQuery row removal tests
+ **********************************************************************/
+ @Test
+ public void removeRowThroughContainer_legalRowItem_shouldSucceed()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(tQuery);
+ container.setAutoCommit(false);
+ Assert.assertTrue(container.removeItem(container.getItemIds()
+ .iterator().next()));
+
+ Assert.assertEquals(4, tQuery.getCount());
+ Assert.assertEquals(3, container.size());
+ container.commit();
+
+ Assert.assertEquals(3, tQuery.getCount());
+ Assert.assertEquals(3, container.size());
+ }
+
+ @Test
+ public void removeRowThroughContainer_nonexistingRowId_shouldFail()
+ throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ SQLContainer container = new SQLContainer(tQuery);
+ container.setAutoCommit(true);
+ Assert.assertFalse(container.removeItem("foo"));
+ }
+
+ /**********************************************************************
+ * TableQuery row adding / modification tests
+ **********************************************************************/
+ @Test
+ public void insertRowThroughContainer_shouldSucceed() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setVersionColumn("ID");
+
+ SQLContainer container = new SQLContainer(tQuery);
+ container.setAutoCommit(false);
+
+ Object item = container.addItem();
+ Assert.assertNotNull(item);
+
+ Assert.assertEquals(4, tQuery.getCount());
+ Assert.assertEquals(5, container.size());
+ container.commit();
+
+ Assert.assertEquals(5, tQuery.getCount());
+ Assert.assertEquals(5, container.size());
+ }
+
+ @Test
+ public void modifyRowThroughContainer_shouldSucceed() throws SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+
+ // In this test the primary key is used as a version column
+ tQuery.setVersionColumn("ID");
+ SQLContainer container = new SQLContainer(tQuery);
+ container.setAutoCommit(false);
+
+ /* Check that the container size is correct and there is no 'Viljami' */
+ Assert.assertEquals(4, container.size());
+ List<Filter> filters = new ArrayList<Filter>();
+ filters.add(new Equal("NAME", "Viljami"));
+ tQuery.setFilters(filters);
+ Assert.assertEquals(0, tQuery.getCount());
+ tQuery.setFilters(null);
+
+ /* Fetch first item, modify and commit */
+ Object item = container.getItem(container.getItemIds().iterator()
+ .next());
+ Assert.assertNotNull(item);
+
+ RowItem ri = (RowItem) item;
+ Assert.assertNotNull(ri.getItemProperty("NAME"));
+ ri.getItemProperty("NAME").setValue("Viljami");
+
+ container.commit();
+
+ // Check that the size is still correct and only 1 'Viljami' is found
+ Assert.assertEquals(4, tQuery.getCount());
+ Assert.assertEquals(4, container.size());
+ tQuery.setFilters(filters);
+ Assert.assertEquals(1, tQuery.getCount());
+ }
+
+ @Test
+ public void storeRow_noVersionColumn_shouldSucceed()
+ throws UnsupportedOperationException, SQLException {
+ TableQuery tQuery = new TableQuery("people", connectionPool,
+ AllTests.sqlGen);
+ SQLContainer container = new SQLContainer(tQuery);
+ Object id = container.addItem();
+ RowItem row = (RowItem) container.getItem(id);
+ row.getItemProperty("NAME").setValue("R2D2");
+ row.getItemProperty("AGE").setValue(123);
+ tQuery.beginTransaction();
+ tQuery.storeRow(row);
+ tQuery.commit();
+
+ Connection conn = connectionPool.reserveConnection();
+ PreparedStatement stmt = conn
+ .prepareStatement("SELECT * FROM PEOPLE WHERE \"NAME\" = ?");
+ stmt.setString(1, "R2D2");
+ ResultSet rs = stmt.executeQuery();
+ Assert.assertTrue(rs.next());
+ rs.close();
+ stmt.close();
+ connectionPool.releaseConnection(conn);
+ }
+
+ @Test
+ public void storeRow_versionSetAndEqualToDBValue_shouldSucceed()
+ throws SQLException {
+ DataGenerator.addVersionedData(connectionPool);
+
+ TableQuery tQuery = new TableQuery("versioned", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setVersionColumn("VERSION");
+ SQLContainer container = new SQLContainer(tQuery);
+ RowItem row = (RowItem) container.getItem(container.firstItemId());
+ Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
+
+ row.getItemProperty("TEXT").setValue("asdf");
+ container.commit();
+
+ Connection conn = connectionPool.reserveConnection();
+ PreparedStatement stmt = conn
+ .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?");
+ stmt.setString(1, "asdf");
+ ResultSet rs = stmt.executeQuery();
+ Assert.assertTrue(rs.next());
+ rs.close();
+ stmt.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+ }
+
+ @Test(expected = OptimisticLockException.class)
+ public void storeRow_versionSetAndLessThanDBValue_shouldThrowException()
+ throws SQLException {
+ if (AllTests.db == DB.HSQLDB) {
+ throw new OptimisticLockException(
+ "HSQLDB doesn't support row versioning for optimistic locking - don't run this test.",
+ null);
+ }
+ DataGenerator.addVersionedData(connectionPool);
+
+ TableQuery tQuery = new TableQuery("versioned", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setVersionColumn("VERSION");
+ SQLContainer container = new SQLContainer(tQuery);
+ RowItem row = (RowItem) container.getItem(container.firstItemId());
+ Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
+
+ row.getItemProperty("TEXT").setValue("asdf");
+
+ // Update the version using another connection.
+ Connection conn = connectionPool.reserveConnection();
+ PreparedStatement stmt = conn
+ .prepareStatement("UPDATE VERSIONED SET \"TEXT\" = ? WHERE \"ID\" = ?");
+ stmt.setString(1, "foo");
+ stmt.setObject(2, row.getItemProperty("ID").getValue());
+ stmt.executeUpdate();
+ stmt.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+
+ container.commit();
+ }
+
+ @Test
+ public void removeRow_versionSetAndEqualToDBValue_shouldSucceed()
+ throws SQLException {
+ DataGenerator.addVersionedData(connectionPool);
+
+ TableQuery tQuery = new TableQuery("versioned", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setVersionColumn("VERSION");
+ SQLContainer container = new SQLContainer(tQuery);
+ RowItem row = (RowItem) container.getItem(container.firstItemId());
+ Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
+
+ container.removeItem(container.firstItemId());
+ container.commit();
+
+ Connection conn = connectionPool.reserveConnection();
+ PreparedStatement stmt = conn
+ .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?");
+ stmt.setString(1, "Junk");
+ ResultSet rs = stmt.executeQuery();
+ Assert.assertFalse(rs.next());
+ rs.close();
+ stmt.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+ }
+
+ @Test(expected = OptimisticLockException.class)
+ public void removeRow_versionSetAndLessThanDBValue_shouldThrowException()
+ throws SQLException {
+ if (AllTests.db == AllTests.DB.HSQLDB) {
+ // HSQLDB doesn't support versioning, so this is to make the test
+ // green.
+ throw new OptimisticLockException(null);
+ }
+ DataGenerator.addVersionedData(connectionPool);
+
+ TableQuery tQuery = new TableQuery("versioned", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setVersionColumn("VERSION");
+ SQLContainer container = new SQLContainer(tQuery);
+ RowItem row = (RowItem) container.getItem(container.firstItemId());
+ Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
+
+ // Update the version using another connection.
+ Connection conn = connectionPool.reserveConnection();
+ PreparedStatement stmt = conn
+ .prepareStatement("UPDATE VERSIONED SET \"TEXT\" = ? WHERE \"ID\" = ?");
+ stmt.setString(1, "asdf");
+ stmt.setObject(2, row.getItemProperty("ID").getValue());
+ stmt.executeUpdate();
+ stmt.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+
+ container.removeItem(container.firstItemId());
+ container.commit();
+ }
+
+ @Test
+ public void removeRow_throwsOptimisticLockException_shouldStillWork()
+ throws SQLException {
+ if (AllTests.db == AllTests.DB.HSQLDB) {
+ // HSQLDB doesn't support versioning, so this is to make the test
+ // green.
+ return;
+ }
+ DataGenerator.addVersionedData(connectionPool);
+
+ TableQuery tQuery = new TableQuery("versioned", connectionPool,
+ AllTests.sqlGen);
+ tQuery.setVersionColumn("VERSION");
+ SQLContainer container = new SQLContainer(tQuery);
+ RowItem row = (RowItem) container.getItem(container.firstItemId());
+ Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue());
+
+ // Update the version using another connection.
+ Connection conn = connectionPool.reserveConnection();
+ PreparedStatement stmt = conn
+ .prepareStatement("UPDATE VERSIONED SET \"TEXT\" = ? WHERE \"ID\" = ?");
+ stmt.setString(1, "asdf");
+ stmt.setObject(2, row.getItemProperty("ID").getValue());
+ stmt.executeUpdate();
+ stmt.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+
+ Object itemToRemove = container.firstItemId();
+ try {
+ container.removeItem(itemToRemove);
+ container.commit();
+ } catch (OptimisticLockException e) {
+ // This is expected, refresh and try again.
+ container.rollback();
+ container.removeItem(itemToRemove);
+ container.commit();
+ }
+ Object id = container.addItem();
+ RowItem item = (RowItem) container.getItem(id);
+ item.getItemProperty("TEXT").setValue("foo");
+ container.commit();
+ }
+
} \ No newline at end of file
diff --git a/tests/server-side/com/vaadin/tests/server/IndexedContainerListeners.java b/tests/server-side/com/vaadin/tests/server/IndexedContainerListeners.java
index 2dc0caade3..8334c7f183 100644
--- a/tests/server-side/com/vaadin/tests/server/IndexedContainerListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/IndexedContainerListeners.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.server;
-
-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.data.util.IndexedContainer;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-
-public class IndexedContainerListeners extends AbstractListenerMethodsTest {
- public void testValueChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(IndexedContainer.class,
- ValueChangeEvent.class, ValueChangeListener.class);
- }
-
- public void testPropertySetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(IndexedContainer.class,
- PropertySetChangeEvent.class, PropertySetChangeListener.class);
- }
-}
+package com.vaadin.tests.server;
+
+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.data.util.IndexedContainer;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+
+public class IndexedContainerListeners extends AbstractListenerMethodsTest {
+ public void testValueChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(IndexedContainer.class,
+ ValueChangeEvent.class, ValueChangeListener.class);
+ }
+
+ public void testPropertySetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(IndexedContainer.class,
+ PropertySetChangeEvent.class, PropertySetChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/PropertysetItemListeners.java b/tests/server-side/com/vaadin/tests/server/PropertysetItemListeners.java
index 69cbbbfb7c..d493f22779 100644
--- a/tests/server-side/com/vaadin/tests/server/PropertysetItemListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/PropertysetItemListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server;
-
-import com.vaadin.data.Item.PropertySetChangeEvent;
-import com.vaadin.data.Item.PropertySetChangeListener;
-import com.vaadin.data.util.PropertysetItem;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-
-public class PropertysetItemListeners extends AbstractListenerMethodsTest {
- public void testPropertySetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(PropertysetItem.class,
- PropertySetChangeEvent.class, PropertySetChangeListener.class);
- }
-}
+package com.vaadin.tests.server;
+
+import com.vaadin.data.Item.PropertySetChangeEvent;
+import com.vaadin.data.Item.PropertySetChangeListener;
+import com.vaadin.data.util.PropertysetItem;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+
+public class PropertysetItemListeners extends AbstractListenerMethodsTest {
+ public void testPropertySetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(PropertysetItem.class,
+ PropertySetChangeEvent.class, PropertySetChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java b/tests/server-side/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java
index ae70757b3e..d6598a3b62 100644
--- a/tests/server-side/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/TestAbstractBeanContainerListeners.java
@@ -1,15 +1,15 @@
-package com.vaadin.tests.server;
-
-import com.vaadin.data.Container.PropertySetChangeEvent;
-import com.vaadin.data.Container.PropertySetChangeListener;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-
-public class TestAbstractBeanContainerListeners extends AbstractListenerMethodsTest {
- public void testPropertySetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(BeanItemContainer.class,
- PropertySetChangeEvent.class, PropertySetChangeListener.class,
- new BeanItemContainer<PropertySetChangeListener>(
- PropertySetChangeListener.class));
- }
-}
+package com.vaadin.tests.server;
+
+import com.vaadin.data.Container.PropertySetChangeEvent;
+import com.vaadin.data.Container.PropertySetChangeListener;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+
+public class TestAbstractBeanContainerListeners extends AbstractListenerMethodsTest {
+ public void testPropertySetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(BeanItemContainer.class,
+ PropertySetChangeEvent.class, PropertySetChangeListener.class,
+ new BeanItemContainer<PropertySetChangeListener>(
+ PropertySetChangeListener.class));
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestAbstractContainerListeners.java b/tests/server-side/com/vaadin/tests/server/TestAbstractContainerListeners.java
index d10c5d7791..b63e4f809a 100644
--- a/tests/server-side/com/vaadin/tests/server/TestAbstractContainerListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/TestAbstractContainerListeners.java
@@ -1,21 +1,21 @@
-package com.vaadin.tests.server;
-
-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.util.IndexedContainer;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-
-public class TestAbstractContainerListeners extends AbstractListenerMethodsTest {
-
- public void testItemSetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(IndexedContainer.class,
- ItemSetChangeEvent.class, ItemSetChangeListener.class);
- }
-
- public void testPropertySetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(IndexedContainer.class,
- PropertySetChangeEvent.class, PropertySetChangeListener.class);
- }
-}
+package com.vaadin.tests.server;
+
+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.util.IndexedContainer;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+
+public class TestAbstractContainerListeners extends AbstractListenerMethodsTest {
+
+ public void testItemSetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(IndexedContainer.class,
+ ItemSetChangeEvent.class, ItemSetChangeListener.class);
+ }
+
+ public void testPropertySetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(IndexedContainer.class,
+ PropertySetChangeEvent.class, PropertySetChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java b/tests/server-side/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java
index 754f152936..4be4e35554 100644
--- a/tests/server-side/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/TestAbstractInMemoryContainerListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server;
-
-import com.vaadin.data.Container.ItemSetChangeEvent;
-import com.vaadin.data.Container.ItemSetChangeListener;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-
-public class TestAbstractInMemoryContainerListeners extends AbstractListenerMethodsTest {
- public void testItemSetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(IndexedContainer.class,
- ItemSetChangeEvent.class, ItemSetChangeListener.class);
- }
-}
+package com.vaadin.tests.server;
+
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+
+public class TestAbstractInMemoryContainerListeners extends AbstractListenerMethodsTest {
+ public void testItemSetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(IndexedContainer.class,
+ ItemSetChangeEvent.class, ItemSetChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestAbstractPropertyListeners.java b/tests/server-side/com/vaadin/tests/server/TestAbstractPropertyListeners.java
index 58dee08643..a1d01d1930 100644
--- a/tests/server-side/com/vaadin/tests/server/TestAbstractPropertyListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/TestAbstractPropertyListeners.java
@@ -1,24 +1,24 @@
-package com.vaadin.tests.server;
-
-import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
-import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.AbstractProperty;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-
-public class TestAbstractPropertyListeners extends AbstractListenerMethodsTest {
- public void testValueChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(AbstractProperty.class,
- ValueChangeEvent.class, ValueChangeListener.class,
- new ObjectProperty<String>(""));
- }
-
- public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(AbstractProperty.class,
- ReadOnlyStatusChangeEvent.class,
- ReadOnlyStatusChangeListener.class, new ObjectProperty<String>(
- ""));
- }
-}
+package com.vaadin.tests.server;
+
+import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
+import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.AbstractProperty;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+
+public class TestAbstractPropertyListeners extends AbstractListenerMethodsTest {
+ public void testValueChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(AbstractProperty.class,
+ ValueChangeEvent.class, ValueChangeListener.class,
+ new ObjectProperty<String>(""));
+ }
+
+ public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(AbstractProperty.class,
+ ReadOnlyStatusChangeEvent.class,
+ ReadOnlyStatusChangeListener.class, new ObjectProperty<String>(
+ ""));
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java b/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
index 33c1dfaf5f..c047565fcc 100644
--- a/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
+++ b/tests/server-side/com/vaadin/tests/server/TestClassesSerializable.java
@@ -1,262 +1,262 @@
-package com.vaadin.tests.server;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-public class TestClassesSerializable extends TestCase {
-
- /**
- * JARs that will be scanned for classes to test, in addition to classpath
- * directories.
- */
- private static String JAR_PATTERN = ".*vaadin.*\\.jar";
-
- private static String[] BASE_PACKAGES = { "com.vaadin" };
-
- private static String[] EXCLUDED_PATTERNS = {
- "com\\.vaadin\\.demo\\..*", //
- "com\\.vaadin\\.external\\.org\\.apache\\.commons\\.fileupload\\..*", //
- "com\\.vaadin\\.launcher\\..*", //
- "com\\.vaadin\\.terminal\\.gwt\\.client\\..*", //
- "com\\.vaadin\\.terminal\\.gwt\\.widgetsetutils\\..*", //
- "com\\.vaadin\\.tests\\..*", // exclude automated tests
- "com\\.vaadin\\.tools\\..*", //
- "com\\.vaadin\\.ui\\.themes\\..*", //
- // exact class level filtering
- "com\\.vaadin\\.event\\.FieldEvents", //
- "com\\.vaadin\\.event\\.LayoutEvents", //
- "com\\.vaadin\\.event\\.MouseEvents", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.AbstractApplicationPortlet", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.ApplicationPortlet2", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.Constants", //
- "com\\.vaadin\\.util\\.SerializerHelper", // fully static
- // class level filtering, also affecting nested classes and
- // interfaces
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.AbstractCommunicationManager.*", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.ApplicationRunnerServlet.*", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.CommunicationManager.*", //
- "com\\.vaadin\\.terminal\\.gwt\\.server\\.PortletCommunicationManager.*", //
- };
-
- /**
- * Tests that all the relevant classes and interfaces under
- * {@link #BASE_PACKAGES} implement Serializable.
- *
- * @throws Exception
- */
- public void testClassesSerializable() throws Exception {
- List<String> rawClasspathEntries = getRawClasspathEntries();
-
- List<String> classes = new ArrayList<String>();
- for (String location : rawClasspathEntries) {
- classes.addAll(findServerClasses(location));
- }
-
- ArrayList<Class<?>> nonSerializableClasses = new ArrayList<Class<?>>();
- for (String className : classes) {
- Class<?> cls = Class.forName(className);
- // skip annotations and synthetic classes
- if (cls.isAnnotation() || cls.isSynthetic()) {
- continue;
- }
- // Don't add classes that have a @Test annotation on any methods
- boolean testPresent = false;
- for (Method method : cls.getMethods()) {
- if (method.isAnnotationPresent(Test.class)) {
- testPresent = true;
- break;
- }
- }
- if (testPresent) {
- continue;
- }
-
- // report non-serializable classes and interfaces
- if (!Serializable.class.isAssignableFrom(cls)) {
- nonSerializableClasses.add(cls);
- // TODO easier to read when testing
- // System.err.println(cls);
- }
- }
-
- // useful failure message including all non-serializable classes and
- // interfaces
- if (!nonSerializableClasses.isEmpty()) {
- String nonSerializableString = "";
- Iterator<Class<?>> it = nonSerializableClasses.iterator();
- nonSerializableString = it.next().getName();
- while (it.hasNext()) {
- nonSerializableString += ", " + it.next().getName();
- }
- fail("Serializable not implemented by the following classes and interfaces: "
- + nonSerializableString);
- }
- }
-
- /**
- * Lists all class path entries by splitting the class path string.
- *
- * Adapted from ClassPathExplorer.getRawClasspathEntries(), but without
- * filtering.
- *
- * @return List of class path segment strings
- */
- //
- private final static List<String> getRawClasspathEntries() {
- // try to keep the order of the classpath
- List<String> locations = new ArrayList<String>();
-
- String pathSep = System.getProperty("path.separator");
- String classpath = System.getProperty("java.class.path");
-
- if (classpath.startsWith("\"")) {
- classpath = classpath.substring(1);
- }
- if (classpath.endsWith("\"")) {
- classpath = classpath.substring(0, classpath.length() - 1);
- }
-
- String[] split = classpath.split(pathSep);
- for (int i = 0; i < split.length; i++) {
- String classpathEntry = split[i];
- locations.add(classpathEntry);
- }
-
- return locations;
- }
-
- /**
- * Finds the server side classes/interfaces under a class path entry -
- * either a directory or a JAR that matches {@link #JAR_PATTERN}.
- *
- * Only classes under {@link #BASE_PACKAGES} are considered, and those
- * matching {@link #EXCLUDED_PATTERNS} are filtered out.
- *
- * @param classpathEntry
- * @return
- * @throws IOException
- */
- private List<String> findServerClasses(String classpathEntry)
- throws IOException {
- Collection<String> classes = new ArrayList<String>();
-
- File file = new File(classpathEntry);
- if (file.isDirectory()) {
- classes = findClassesInDirectory(null, file);
- } else if (file.getName().matches(JAR_PATTERN)) {
- classes = findClassesInJar(file);
- } else {
- System.out.println("Ignoring " + classpathEntry);
- return Collections.emptyList();
- }
-
- List<String> filteredClasses = new ArrayList<String>();
- for (String className : classes) {
- boolean ok = false;
- for (String basePackage : BASE_PACKAGES) {
- if (className.startsWith(basePackage + ".")) {
- ok = true;
- break;
- }
- }
- for (String excludedPrefix : EXCLUDED_PATTERNS) {
- if (className.matches(excludedPrefix)) {
- ok = false;
- break;
- }
- }
-
- // Don't add test classes
- if (className.contains("Test")) {
- ok = false;
- }
-
- if (ok) {
- filteredClasses.add(className);
- }
- }
-
- return filteredClasses;
- }
-
- /**
- * Lists class names (based on .class files) in a JAR file.
- *
- * @param file
- * a valid JAR file
- * @return collection of fully qualified class names in the JAR
- * @throws IOException
- */
- private Collection<String> findClassesInJar(File file) throws IOException {
- Collection<String> classes = new ArrayList<String>();
-
- JarFile jar = new JarFile(file);
- Enumeration<JarEntry> e = jar.entries();
- while (e.hasMoreElements()) {
- JarEntry entry = e.nextElement();
- if (entry.getName().endsWith(".class")) {
- String nameWithoutExtension = entry.getName().replaceAll(
- "\\.class", "");
- String className = nameWithoutExtension.replace('/', '.');
- classes.add(className);
- }
- }
- return classes;
- }
-
- /**
- * Lists class names (based on .class files) in a directory (a package path
- * root).
- *
- * @param parentPackage
- * parent package name or null at root of hierarchy, used by
- * recursion
- * @param parent
- * File representing the directory to scan
- * @return collection of fully qualified class names in the directory
- */
- private final static Collection<String> findClassesInDirectory(
- String parentPackage, File parent) {
- if (parent.isHidden()
- || parent.getPath().contains(File.separator + ".")) {
- return Collections.emptyList();
- }
-
- if (parentPackage == null) {
- parentPackage = "";
- } else {
- parentPackage += ".";
- }
-
- Collection<String> classNames = new ArrayList<String>();
-
- // add all directories recursively
- File[] files = parent.listFiles();
- for (File child : files) {
- if (child.isDirectory()) {
- classNames.addAll(findClassesInDirectory(
- parentPackage + child.getName(), child));
- } else if (child.getName().endsWith(".class")) {
- classNames.add(parentPackage.replace(File.separatorChar, '.')
- + child.getName().replaceAll("\\.class", ""));
- }
- }
-
- return classNames;
- }
-
-}
+package com.vaadin.tests.server;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+public class TestClassesSerializable extends TestCase {
+
+ /**
+ * JARs that will be scanned for classes to test, in addition to classpath
+ * directories.
+ */
+ private static String JAR_PATTERN = ".*vaadin.*\\.jar";
+
+ private static String[] BASE_PACKAGES = { "com.vaadin" };
+
+ private static String[] EXCLUDED_PATTERNS = {
+ "com\\.vaadin\\.demo\\..*", //
+ "com\\.vaadin\\.external\\.org\\.apache\\.commons\\.fileupload\\..*", //
+ "com\\.vaadin\\.launcher\\..*", //
+ "com\\.vaadin\\.terminal\\.gwt\\.client\\..*", //
+ "com\\.vaadin\\.terminal\\.gwt\\.widgetsetutils\\..*", //
+ "com\\.vaadin\\.tests\\..*", // exclude automated tests
+ "com\\.vaadin\\.tools\\..*", //
+ "com\\.vaadin\\.ui\\.themes\\..*", //
+ // exact class level filtering
+ "com\\.vaadin\\.event\\.FieldEvents", //
+ "com\\.vaadin\\.event\\.LayoutEvents", //
+ "com\\.vaadin\\.event\\.MouseEvents", //
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.AbstractApplicationPortlet", //
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.ApplicationPortlet2", //
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.Constants", //
+ "com\\.vaadin\\.util\\.SerializerHelper", // fully static
+ // class level filtering, also affecting nested classes and
+ // interfaces
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.AbstractCommunicationManager.*", //
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.ApplicationRunnerServlet.*", //
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.CommunicationManager.*", //
+ "com\\.vaadin\\.terminal\\.gwt\\.server\\.PortletCommunicationManager.*", //
+ };
+
+ /**
+ * Tests that all the relevant classes and interfaces under
+ * {@link #BASE_PACKAGES} implement Serializable.
+ *
+ * @throws Exception
+ */
+ public void testClassesSerializable() throws Exception {
+ List<String> rawClasspathEntries = getRawClasspathEntries();
+
+ List<String> classes = new ArrayList<String>();
+ for (String location : rawClasspathEntries) {
+ classes.addAll(findServerClasses(location));
+ }
+
+ ArrayList<Class<?>> nonSerializableClasses = new ArrayList<Class<?>>();
+ for (String className : classes) {
+ Class<?> cls = Class.forName(className);
+ // skip annotations and synthetic classes
+ if (cls.isAnnotation() || cls.isSynthetic()) {
+ continue;
+ }
+ // Don't add classes that have a @Test annotation on any methods
+ boolean testPresent = false;
+ for (Method method : cls.getMethods()) {
+ if (method.isAnnotationPresent(Test.class)) {
+ testPresent = true;
+ break;
+ }
+ }
+ if (testPresent) {
+ continue;
+ }
+
+ // report non-serializable classes and interfaces
+ if (!Serializable.class.isAssignableFrom(cls)) {
+ nonSerializableClasses.add(cls);
+ // TODO easier to read when testing
+ // System.err.println(cls);
+ }
+ }
+
+ // useful failure message including all non-serializable classes and
+ // interfaces
+ if (!nonSerializableClasses.isEmpty()) {
+ String nonSerializableString = "";
+ Iterator<Class<?>> it = nonSerializableClasses.iterator();
+ nonSerializableString = it.next().getName();
+ while (it.hasNext()) {
+ nonSerializableString += ", " + it.next().getName();
+ }
+ fail("Serializable not implemented by the following classes and interfaces: "
+ + nonSerializableString);
+ }
+ }
+
+ /**
+ * Lists all class path entries by splitting the class path string.
+ *
+ * Adapted from ClassPathExplorer.getRawClasspathEntries(), but without
+ * filtering.
+ *
+ * @return List of class path segment strings
+ */
+ //
+ private final static List<String> getRawClasspathEntries() {
+ // try to keep the order of the classpath
+ List<String> locations = new ArrayList<String>();
+
+ String pathSep = System.getProperty("path.separator");
+ String classpath = System.getProperty("java.class.path");
+
+ if (classpath.startsWith("\"")) {
+ classpath = classpath.substring(1);
+ }
+ if (classpath.endsWith("\"")) {
+ classpath = classpath.substring(0, classpath.length() - 1);
+ }
+
+ String[] split = classpath.split(pathSep);
+ for (int i = 0; i < split.length; i++) {
+ String classpathEntry = split[i];
+ locations.add(classpathEntry);
+ }
+
+ return locations;
+ }
+
+ /**
+ * Finds the server side classes/interfaces under a class path entry -
+ * either a directory or a JAR that matches {@link #JAR_PATTERN}.
+ *
+ * Only classes under {@link #BASE_PACKAGES} are considered, and those
+ * matching {@link #EXCLUDED_PATTERNS} are filtered out.
+ *
+ * @param classpathEntry
+ * @return
+ * @throws IOException
+ */
+ private List<String> findServerClasses(String classpathEntry)
+ throws IOException {
+ Collection<String> classes = new ArrayList<String>();
+
+ File file = new File(classpathEntry);
+ if (file.isDirectory()) {
+ classes = findClassesInDirectory(null, file);
+ } else if (file.getName().matches(JAR_PATTERN)) {
+ classes = findClassesInJar(file);
+ } else {
+ System.out.println("Ignoring " + classpathEntry);
+ return Collections.emptyList();
+ }
+
+ List<String> filteredClasses = new ArrayList<String>();
+ for (String className : classes) {
+ boolean ok = false;
+ for (String basePackage : BASE_PACKAGES) {
+ if (className.startsWith(basePackage + ".")) {
+ ok = true;
+ break;
+ }
+ }
+ for (String excludedPrefix : EXCLUDED_PATTERNS) {
+ if (className.matches(excludedPrefix)) {
+ ok = false;
+ break;
+ }
+ }
+
+ // Don't add test classes
+ if (className.contains("Test")) {
+ ok = false;
+ }
+
+ if (ok) {
+ filteredClasses.add(className);
+ }
+ }
+
+ return filteredClasses;
+ }
+
+ /**
+ * Lists class names (based on .class files) in a JAR file.
+ *
+ * @param file
+ * a valid JAR file
+ * @return collection of fully qualified class names in the JAR
+ * @throws IOException
+ */
+ private Collection<String> findClassesInJar(File file) throws IOException {
+ Collection<String> classes = new ArrayList<String>();
+
+ JarFile jar = new JarFile(file);
+ Enumeration<JarEntry> e = jar.entries();
+ while (e.hasMoreElements()) {
+ JarEntry entry = e.nextElement();
+ if (entry.getName().endsWith(".class")) {
+ String nameWithoutExtension = entry.getName().replaceAll(
+ "\\.class", "");
+ String className = nameWithoutExtension.replace('/', '.');
+ classes.add(className);
+ }
+ }
+ return classes;
+ }
+
+ /**
+ * Lists class names (based on .class files) in a directory (a package path
+ * root).
+ *
+ * @param parentPackage
+ * parent package name or null at root of hierarchy, used by
+ * recursion
+ * @param parent
+ * File representing the directory to scan
+ * @return collection of fully qualified class names in the directory
+ */
+ private final static Collection<String> findClassesInDirectory(
+ String parentPackage, File parent) {
+ if (parent.isHidden()
+ || parent.getPath().contains(File.separator + ".")) {
+ return Collections.emptyList();
+ }
+
+ if (parentPackage == null) {
+ parentPackage = "";
+ } else {
+ parentPackage += ".";
+ }
+
+ Collection<String> classNames = new ArrayList<String>();
+
+ // add all directories recursively
+ File[] files = parent.listFiles();
+ for (File child : files) {
+ if (child.isDirectory()) {
+ classNames.addAll(findClassesInDirectory(
+ parentPackage + child.getName(), child));
+ } else if (child.getName().endsWith(".class")) {
+ classNames.add(parentPackage.replace(File.separatorChar, '.')
+ + child.getName().replaceAll("\\.class", ""));
+ }
+ }
+
+ return classNames;
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java b/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java
index 02ea45ce7c..ca33cf3314 100644
--- a/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java
+++ b/tests/server-side/com/vaadin/tests/server/TestKeyMapper.java
@@ -1,102 +1,102 @@
-package com.vaadin.tests.server;
-
-import java.lang.reflect.Field;
-import java.util.Hashtable;
-
-import junit.framework.TestCase;
-
-import com.vaadin.terminal.KeyMapper;
-
-public class TestKeyMapper extends TestCase {
-
- public void testAdd() {
- KeyMapper mapper = new KeyMapper();
- Object o1 = new Object();
- Object o2 = new Object();
- Object o3 = new Object();
-
- // Create new ids
- String key1 = mapper.key(o1);
- String key2 = mapper.key(o2);
- String key3 = mapper.key(o3);
-
- assertEquals(mapper.get(key1), o1);
- assertEquals(mapper.get(key2), o2);
- assertEquals(mapper.get(key3), o3);
- assertNotSame(key1, key2);
- assertNotSame(key1, key3);
- assertNotSame(key2, key3);
-
- assertSize(mapper, 3);
-
- // Key should not add if there already is a mapping
- assertEquals(mapper.key(o3), key3);
- assertSize(mapper, 3);
-
- // Remove -> add should return a new key
- mapper.remove(o1);
- String newkey1 = mapper.key(o1);
- assertNotSame(key1, newkey1);
-
- }
-
- public void testRemoveAll() {
- KeyMapper mapper = new KeyMapper();
- Object o1 = new Object();
- Object o2 = new Object();
- Object o3 = new Object();
-
- // Create new ids
- mapper.key(o1);
- mapper.key(o2);
- mapper.key(o3);
-
- assertSize(mapper, 3);
- mapper.removeAll();
- assertSize(mapper, 0);
-
- }
-
- public void testRemove() {
- KeyMapper mapper = new KeyMapper();
- Object o1 = new Object();
- Object o2 = new Object();
- Object o3 = new Object();
-
- // Create new ids
- mapper.key(o1);
- mapper.key(o2);
- mapper.key(o3);
-
- assertSize(mapper, 3);
- mapper.remove(o1);
- assertSize(mapper, 2);
- mapper.key(o1);
- assertSize(mapper, 3);
- mapper.remove(o1);
- assertSize(mapper, 2);
-
- mapper.remove(o2);
- mapper.remove(o3);
- assertSize(mapper, 0);
-
- }
-
- private void assertSize(KeyMapper mapper, int i) {
- try {
- Field f1 = KeyMapper.class.getDeclaredField("objectKeyMap");
- Field f2 = KeyMapper.class.getDeclaredField("keyObjectMap");
- f1.setAccessible(true);
- f2.setAccessible(true);
-
- Hashtable<?, ?> h1 = (Hashtable<?, ?>) f1.get(mapper);
- Hashtable<?, ?> h2 = (Hashtable<?, ?>) f2.get(mapper);
-
- assertEquals(i, h1.size());
- assertEquals(i, h2.size());
- } catch (Throwable t) {
- t.printStackTrace();
- fail();
- }
- }
-}
+package com.vaadin.tests.server;
+
+import java.lang.reflect.Field;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import com.vaadin.terminal.KeyMapper;
+
+public class TestKeyMapper extends TestCase {
+
+ public void testAdd() {
+ KeyMapper mapper = new KeyMapper();
+ Object o1 = new Object();
+ Object o2 = new Object();
+ Object o3 = new Object();
+
+ // Create new ids
+ String key1 = mapper.key(o1);
+ String key2 = mapper.key(o2);
+ String key3 = mapper.key(o3);
+
+ assertEquals(mapper.get(key1), o1);
+ assertEquals(mapper.get(key2), o2);
+ assertEquals(mapper.get(key3), o3);
+ assertNotSame(key1, key2);
+ assertNotSame(key1, key3);
+ assertNotSame(key2, key3);
+
+ assertSize(mapper, 3);
+
+ // Key should not add if there already is a mapping
+ assertEquals(mapper.key(o3), key3);
+ assertSize(mapper, 3);
+
+ // Remove -> add should return a new key
+ mapper.remove(o1);
+ String newkey1 = mapper.key(o1);
+ assertNotSame(key1, newkey1);
+
+ }
+
+ public void testRemoveAll() {
+ KeyMapper mapper = new KeyMapper();
+ Object o1 = new Object();
+ Object o2 = new Object();
+ Object o3 = new Object();
+
+ // Create new ids
+ mapper.key(o1);
+ mapper.key(o2);
+ mapper.key(o3);
+
+ assertSize(mapper, 3);
+ mapper.removeAll();
+ assertSize(mapper, 0);
+
+ }
+
+ public void testRemove() {
+ KeyMapper mapper = new KeyMapper();
+ Object o1 = new Object();
+ Object o2 = new Object();
+ Object o3 = new Object();
+
+ // Create new ids
+ mapper.key(o1);
+ mapper.key(o2);
+ mapper.key(o3);
+
+ assertSize(mapper, 3);
+ mapper.remove(o1);
+ assertSize(mapper, 2);
+ mapper.key(o1);
+ assertSize(mapper, 3);
+ mapper.remove(o1);
+ assertSize(mapper, 2);
+
+ mapper.remove(o2);
+ mapper.remove(o3);
+ assertSize(mapper, 0);
+
+ }
+
+ private void assertSize(KeyMapper mapper, int i) {
+ try {
+ Field f1 = KeyMapper.class.getDeclaredField("objectKeyMap");
+ Field f2 = KeyMapper.class.getDeclaredField("keyObjectMap");
+ f1.setAccessible(true);
+ f2.setAccessible(true);
+
+ Hashtable<?, ?> h1 = (Hashtable<?, ?>) f1.get(mapper);
+ Hashtable<?, ?> h2 = (Hashtable<?, ?>) f2.get(mapper);
+
+ assertEquals(i, h1.size());
+ assertEquals(i, h2.size());
+ } catch (Throwable t) {
+ t.printStackTrace();
+ fail();
+ }
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java b/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java
index 3f16bb262b..224c9f5964 100644
--- a/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java
+++ b/tests/server-side/com/vaadin/tests/server/TransactionListenersConcurrency.java
@@ -1,185 +1,185 @@
-package com.vaadin.tests.server;
-
-import static org.easymock.EasyMock.createMock;
-
-import java.lang.Thread.UncaughtExceptionHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-
-import javax.servlet.http.HttpSession;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import com.vaadin.Application;
-import com.vaadin.service.ApplicationContext.TransactionListener;
-import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext;
-import com.vaadin.terminal.gwt.server.WebApplicationContext;
-
-public class TransactionListenersConcurrency extends TestCase {
-
- /**
- * This test starts N threads concurrently. Each thread creates an
- * application which adds a transaction listener to the context. A
- * transaction is then started for each application. Some semi-random delays
- * are included so that calls to addTransactionListener and
- * WebApplicationContext.startTransaction are mixed.
- *
- */
- public void testTransactionListeners() throws Exception {
- final List<Throwable> exceptions = new ArrayList<Throwable>();
-
- HttpSession session = createSession();
- final WebApplicationContext context = WebApplicationContext
- .getApplicationContext(session);
- List<Thread> threads = new ArrayList<Thread>();
-
- for (int i = 0; i < 5; i++) {
- Thread t = new Thread(new Runnable() {
-
- public void run() {
- Application app = new Application() {
-
- @Override
- public void init() {
- // Sleep 0-1000ms so another transaction has time to
- // start before we add the transaction listener.
- try {
- Thread.sleep((long) (1000 * new Random()
- .nextDouble()));
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- getContext().addTransactionListener(
- new DelayTransactionListener(2000));
- }
-
- };
-
- // Start the application so the transaction listener is
- // called later on.
- try {
-
- app.start(new URL("http://localhost/"),
- new Properties(), context);
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- try {
- // Call the transaction listener using reflection as
- // startTransaction is protected.
-
- Method m = AbstractWebApplicationContext.class
- .getDeclaredMethod("startTransaction",
- Application.class, Object.class);
- m.setAccessible(true);
- m.invoke(context, app, null);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- });
-
- threads.add(t);
- t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
-
- public void uncaughtException(Thread t, Throwable e) {
- e = e.getCause();
- exceptions.add(e);
- }
- });
- }
-
- // Start the threads and wait for all of them to finish
- for (Thread t : threads) {
- t.start();
- }
- int running = threads.size();
-
- while (running > 0) {
- for (Iterator<Thread> i = threads.iterator(); i.hasNext();) {
- Thread t = i.next();
- if (!t.isAlive()) {
- running--;
- i.remove();
- }
- }
- }
-
- for (Throwable t : exceptions) {
- if (t instanceof InvocationTargetException) {
- t = t.getCause();
- }
- t.printStackTrace(System.err);
- fail(t.getClass().getName());
- }
-
- System.out.println("Done, all ok");
-
- }
-
- /**
- * Creates a HttpSession mock
- *
- */
- private static HttpSession createSession() {
- HttpSession session = createMock(HttpSession.class);
- EasyMock.expect(
- session.getAttribute(WebApplicationContext.class.getName()))
- .andReturn(null).anyTimes();
- session.setAttribute(
- EasyMock.eq(WebApplicationContext.class.getName()),
- EasyMock.anyObject());
-
- EasyMock.replay(session);
- return session;
- }
-
- /**
- * A transaction listener that just sleeps for the given amount of time in
- * transactionStart and transactionEnd.
- *
- */
- public static class DelayTransactionListener implements TransactionListener {
-
- private int delay;
-
- public DelayTransactionListener(int delay) {
- this.delay = delay;
- }
-
- public void transactionStart(Application application,
- Object transactionData) {
- try {
- Thread.sleep(delay);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- }
-
- public void transactionEnd(Application application,
- Object transactionData) {
- try {
- Thread.sleep(delay);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- }
- }
-
-}
+package com.vaadin.tests.server;
+
+import static org.easymock.EasyMock.createMock;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Random;
+
+import javax.servlet.http.HttpSession;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.Application;
+import com.vaadin.service.ApplicationContext.TransactionListener;
+import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext;
+import com.vaadin.terminal.gwt.server.WebApplicationContext;
+
+public class TransactionListenersConcurrency extends TestCase {
+
+ /**
+ * This test starts N threads concurrently. Each thread creates an
+ * application which adds a transaction listener to the context. A
+ * transaction is then started for each application. Some semi-random delays
+ * are included so that calls to addTransactionListener and
+ * WebApplicationContext.startTransaction are mixed.
+ *
+ */
+ public void testTransactionListeners() throws Exception {
+ final List<Throwable> exceptions = new ArrayList<Throwable>();
+
+ HttpSession session = createSession();
+ final WebApplicationContext context = WebApplicationContext
+ .getApplicationContext(session);
+ List<Thread> threads = new ArrayList<Thread>();
+
+ for (int i = 0; i < 5; i++) {
+ Thread t = new Thread(new Runnable() {
+
+ public void run() {
+ Application app = new Application() {
+
+ @Override
+ public void init() {
+ // Sleep 0-1000ms so another transaction has time to
+ // start before we add the transaction listener.
+ try {
+ Thread.sleep((long) (1000 * new Random()
+ .nextDouble()));
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ getContext().addTransactionListener(
+ new DelayTransactionListener(2000));
+ }
+
+ };
+
+ // Start the application so the transaction listener is
+ // called later on.
+ try {
+
+ app.start(new URL("http://localhost/"),
+ new Properties(), context);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ // Call the transaction listener using reflection as
+ // startTransaction is protected.
+
+ Method m = AbstractWebApplicationContext.class
+ .getDeclaredMethod("startTransaction",
+ Application.class, Object.class);
+ m.setAccessible(true);
+ m.invoke(context, app, null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ });
+
+ threads.add(t);
+ t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+
+ public void uncaughtException(Thread t, Throwable e) {
+ e = e.getCause();
+ exceptions.add(e);
+ }
+ });
+ }
+
+ // Start the threads and wait for all of them to finish
+ for (Thread t : threads) {
+ t.start();
+ }
+ int running = threads.size();
+
+ while (running > 0) {
+ for (Iterator<Thread> i = threads.iterator(); i.hasNext();) {
+ Thread t = i.next();
+ if (!t.isAlive()) {
+ running--;
+ i.remove();
+ }
+ }
+ }
+
+ for (Throwable t : exceptions) {
+ if (t instanceof InvocationTargetException) {
+ t = t.getCause();
+ }
+ t.printStackTrace(System.err);
+ fail(t.getClass().getName());
+ }
+
+ System.out.println("Done, all ok");
+
+ }
+
+ /**
+ * Creates a HttpSession mock
+ *
+ */
+ private static HttpSession createSession() {
+ HttpSession session = createMock(HttpSession.class);
+ EasyMock.expect(
+ session.getAttribute(WebApplicationContext.class.getName()))
+ .andReturn(null).anyTimes();
+ session.setAttribute(
+ EasyMock.eq(WebApplicationContext.class.getName()),
+ EasyMock.anyObject());
+
+ EasyMock.replay(session);
+ return session;
+ }
+
+ /**
+ * A transaction listener that just sleeps for the given amount of time in
+ * transactionStart and transactionEnd.
+ *
+ */
+ public static class DelayTransactionListener implements TransactionListener {
+
+ private int delay;
+
+ public DelayTransactionListener(int delay) {
+ this.delay = delay;
+ }
+
+ public void transactionStart(Application application,
+ Object transactionData) {
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public void transactionEnd(Application application,
+ Object transactionData) {
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java b/tests/server-side/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java
index a569ea03e9..7d6db42d1a 100644
--- a/tests/server-side/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/absolutelayout/AbsoluteLayoutListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.absolutelayout;
-
-import com.vaadin.event.LayoutEvents.LayoutClickEvent;
-import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.AbsoluteLayout;
-
-public class AbsoluteLayoutListeners extends AbstractListenerMethodsTest {
- public void testLayoutClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(AbsoluteLayout.class, LayoutClickEvent.class,
- LayoutClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.absolutelayout;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.AbsoluteLayout;
+
+public class AbsoluteLayoutListeners extends AbstractListenerMethodsTest {
+ public void testLayoutClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(AbsoluteLayout.class, LayoutClickEvent.class,
+ LayoutClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java b/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java
index 6fc7fbba0d..ee8ef6bfbc 100644
--- a/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java
+++ b/tests/server-side/com/vaadin/tests/server/component/absolutelayout/ComponentPosition.java
@@ -1,205 +1,205 @@
-package com.vaadin.tests.server.component.absolutelayout;
-
-import junit.framework.TestCase;
-
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.ui.AbsoluteLayout;
-import com.vaadin.ui.Button;
-
-public class ComponentPosition extends TestCase {
-
- private static final String CSS = "top:7.0px;right:7.0%;bottom:7.0pc;left:7.0em;z-index:7;";
- private static final String PARTIAL_CSS = "top:7.0px;left:7.0em;";
- private static final Float CSS_VALUE = Float.valueOf(7);
-
- private static final int UNIT_UNSET = Sizeable.UNITS_PIXELS;
-
- /**
- * Add component w/o giving positions, assert that everything is unset
- */
- public void testNoPosition() {
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b);
-
- assertNull(layout.getPosition(b).getTopValue());
- assertNull(layout.getPosition(b).getBottomValue());
- assertNull(layout.getPosition(b).getLeftValue());
- assertNull(layout.getPosition(b).getRightValue());
-
- assertEquals(UNIT_UNSET, layout.getPosition(b).getTopUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getLeftUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
-
- assertEquals(-1, layout.getPosition(b).getZIndex());
-
- assertEquals("", layout.getPosition(b).getCSSString());
-
- }
-
- /**
- * Add component, setting all attributes using CSS, assert getter agree
- */
- public void testFullCss() {
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b, CSS);
-
- assertEquals(CSS_VALUE, layout.getPosition(b).getTopValue());
- assertEquals(CSS_VALUE, layout.getPosition(b).getBottomValue());
- assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
- assertEquals(CSS_VALUE, layout.getPosition(b).getRightValue());
-
- assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
- assertEquals(Sizeable.UNITS_PICAS, layout.getPosition(b)
- .getBottomUnits());
- assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
- assertEquals(Sizeable.UNITS_PERCENTAGE, layout.getPosition(b)
- .getRightUnits());
-
- assertEquals(7, layout.getPosition(b).getZIndex());
-
- assertEquals(CSS, layout.getPosition(b).getCSSString());
-
- }
-
- /**
- * Add component, setting some attributes using CSS, assert getters agree
- */
- public void testPartialCss() {
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b, PARTIAL_CSS);
-
- assertEquals(CSS_VALUE, layout.getPosition(b).getTopValue());
- assertNull(layout.getPosition(b).getBottomValue());
- assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
- assertNull(layout.getPosition(b).getRightValue());
-
- assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
- assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
-
- assertEquals(-1, layout.getPosition(b).getZIndex());
-
- assertEquals(PARTIAL_CSS, layout.getPosition(b).getCSSString());
-
- }
-
- /**
- * Add component setting all attributes using CSS, then reset using partial
- * CSS; assert getters agree and the appropriate attributes are unset.
- */
- public void testPartialCssReset() {
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b, CSS);
-
- layout.getPosition(b).setCSSString(PARTIAL_CSS);
-
- assertEquals(CSS_VALUE, layout.getPosition(b).getTopValue());
- assertNull(layout.getPosition(b).getBottomValue());
- assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
- assertNull(layout.getPosition(b).getRightValue());
-
- assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
- assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
- assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
-
- assertEquals(-1, layout.getPosition(b).getZIndex());
-
- assertEquals(PARTIAL_CSS, layout.getPosition(b).getCSSString());
-
- }
-
- /**
- * Add component, then set all position attributes with individual setters
- * for value and units; assert getters agree.
- */
- public void testSetPosition() {
- final Float SIZE = Float.valueOf(12);
-
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b);
-
- layout.getPosition(b).setTopValue(SIZE);
- layout.getPosition(b).setRightValue(SIZE);
- layout.getPosition(b).setBottomValue(SIZE);
- layout.getPosition(b).setLeftValue(SIZE);
-
- layout.getPosition(b).setTopUnits(Sizeable.UNITS_CM);
- layout.getPosition(b).setRightUnits(Sizeable.UNITS_EX);
- layout.getPosition(b).setBottomUnits(Sizeable.UNITS_INCH);
- layout.getPosition(b).setLeftUnits(Sizeable.UNITS_MM);
-
- assertEquals(SIZE, layout.getPosition(b).getTopValue());
- assertEquals(SIZE, layout.getPosition(b).getRightValue());
- assertEquals(SIZE, layout.getPosition(b).getBottomValue());
- assertEquals(SIZE, layout.getPosition(b).getLeftValue());
-
- assertEquals(Sizeable.UNITS_CM, layout.getPosition(b).getTopUnits());
- assertEquals(Sizeable.UNITS_EX, layout.getPosition(b).getRightUnits());
- assertEquals(Sizeable.UNITS_INCH, layout.getPosition(b)
- .getBottomUnits());
- assertEquals(Sizeable.UNITS_MM, layout.getPosition(b).getLeftUnits());
-
- }
-
- /**
- * Add component, then set all position attributes with combined setters for
- * value and units; assert getters agree.
- */
- public void testSetPosition2() {
- final Float SIZE = Float.valueOf(12);
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b);
-
- layout.getPosition(b).setTop(SIZE, Sizeable.UNITS_CM);
- layout.getPosition(b).setRight(SIZE, Sizeable.UNITS_EX);
- layout.getPosition(b).setBottom(SIZE, Sizeable.UNITS_INCH);
- layout.getPosition(b).setLeft(SIZE, Sizeable.UNITS_MM);
-
- assertEquals(SIZE, layout.getPosition(b).getTopValue());
- assertEquals(SIZE, layout.getPosition(b).getRightValue());
- assertEquals(SIZE, layout.getPosition(b).getBottomValue());
- assertEquals(SIZE, layout.getPosition(b).getLeftValue());
-
- assertEquals(Sizeable.UNITS_CM, layout.getPosition(b).getTopUnits());
- assertEquals(Sizeable.UNITS_EX, layout.getPosition(b).getRightUnits());
- assertEquals(Sizeable.UNITS_INCH, layout.getPosition(b)
- .getBottomUnits());
- assertEquals(Sizeable.UNITS_MM, layout.getPosition(b).getLeftUnits());
-
- }
-
- /**
- * Add component, set all attributes using CSS, unset some using method
- * calls, assert getters agree.
- */
- public void testUnsetPosition() {
- AbsoluteLayout layout = new AbsoluteLayout();
- Button b = new Button();
- layout.addComponent(b, CSS);
-
- layout.getPosition(b).setTopValue(null);
- layout.getPosition(b).setRightValue(null);
- layout.getPosition(b).setBottomValue(null);
- layout.getPosition(b).setLeftValue(null);
-
- layout.getPosition(b).setZIndex(-1);
-
- assertNull(layout.getPosition(b).getTopValue());
- assertNull(layout.getPosition(b).getBottomValue());
- assertNull(layout.getPosition(b).getLeftValue());
- assertNull(layout.getPosition(b).getRightValue());
-
- assertEquals("", layout.getPosition(b).getCSSString());
-
- }
-
-}
+package com.vaadin.tests.server.component.absolutelayout;
+
+import junit.framework.TestCase;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.Button;
+
+public class ComponentPosition extends TestCase {
+
+ private static final String CSS = "top:7.0px;right:7.0%;bottom:7.0pc;left:7.0em;z-index:7;";
+ private static final String PARTIAL_CSS = "top:7.0px;left:7.0em;";
+ private static final Float CSS_VALUE = Float.valueOf(7);
+
+ private static final int UNIT_UNSET = Sizeable.UNITS_PIXELS;
+
+ /**
+ * Add component w/o giving positions, assert that everything is unset
+ */
+ public void testNoPosition() {
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b);
+
+ assertNull(layout.getPosition(b).getTopValue());
+ assertNull(layout.getPosition(b).getBottomValue());
+ assertNull(layout.getPosition(b).getLeftValue());
+ assertNull(layout.getPosition(b).getRightValue());
+
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getTopUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getLeftUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
+
+ assertEquals(-1, layout.getPosition(b).getZIndex());
+
+ assertEquals("", layout.getPosition(b).getCSSString());
+
+ }
+
+ /**
+ * Add component, setting all attributes using CSS, assert getter agree
+ */
+ public void testFullCss() {
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b, CSS);
+
+ assertEquals(CSS_VALUE, layout.getPosition(b).getTopValue());
+ assertEquals(CSS_VALUE, layout.getPosition(b).getBottomValue());
+ assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
+ assertEquals(CSS_VALUE, layout.getPosition(b).getRightValue());
+
+ assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.UNITS_PICAS, layout.getPosition(b)
+ .getBottomUnits());
+ assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
+ assertEquals(Sizeable.UNITS_PERCENTAGE, layout.getPosition(b)
+ .getRightUnits());
+
+ assertEquals(7, layout.getPosition(b).getZIndex());
+
+ assertEquals(CSS, layout.getPosition(b).getCSSString());
+
+ }
+
+ /**
+ * Add component, setting some attributes using CSS, assert getters agree
+ */
+ public void testPartialCss() {
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b, PARTIAL_CSS);
+
+ assertEquals(CSS_VALUE, layout.getPosition(b).getTopValue());
+ assertNull(layout.getPosition(b).getBottomValue());
+ assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
+ assertNull(layout.getPosition(b).getRightValue());
+
+ assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
+ assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
+
+ assertEquals(-1, layout.getPosition(b).getZIndex());
+
+ assertEquals(PARTIAL_CSS, layout.getPosition(b).getCSSString());
+
+ }
+
+ /**
+ * Add component setting all attributes using CSS, then reset using partial
+ * CSS; assert getters agree and the appropriate attributes are unset.
+ */
+ public void testPartialCssReset() {
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b, CSS);
+
+ layout.getPosition(b).setCSSString(PARTIAL_CSS);
+
+ assertEquals(CSS_VALUE, layout.getPosition(b).getTopValue());
+ assertNull(layout.getPosition(b).getBottomValue());
+ assertEquals(CSS_VALUE, layout.getPosition(b).getLeftValue());
+ assertNull(layout.getPosition(b).getRightValue());
+
+ assertEquals(Sizeable.UNITS_PIXELS, layout.getPosition(b).getTopUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getBottomUnits());
+ assertEquals(Sizeable.UNITS_EM, layout.getPosition(b).getLeftUnits());
+ assertEquals(UNIT_UNSET, layout.getPosition(b).getRightUnits());
+
+ assertEquals(-1, layout.getPosition(b).getZIndex());
+
+ assertEquals(PARTIAL_CSS, layout.getPosition(b).getCSSString());
+
+ }
+
+ /**
+ * Add component, then set all position attributes with individual setters
+ * for value and units; assert getters agree.
+ */
+ public void testSetPosition() {
+ final Float SIZE = Float.valueOf(12);
+
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b);
+
+ layout.getPosition(b).setTopValue(SIZE);
+ layout.getPosition(b).setRightValue(SIZE);
+ layout.getPosition(b).setBottomValue(SIZE);
+ layout.getPosition(b).setLeftValue(SIZE);
+
+ layout.getPosition(b).setTopUnits(Sizeable.UNITS_CM);
+ layout.getPosition(b).setRightUnits(Sizeable.UNITS_EX);
+ layout.getPosition(b).setBottomUnits(Sizeable.UNITS_INCH);
+ layout.getPosition(b).setLeftUnits(Sizeable.UNITS_MM);
+
+ assertEquals(SIZE, layout.getPosition(b).getTopValue());
+ assertEquals(SIZE, layout.getPosition(b).getRightValue());
+ assertEquals(SIZE, layout.getPosition(b).getBottomValue());
+ assertEquals(SIZE, layout.getPosition(b).getLeftValue());
+
+ assertEquals(Sizeable.UNITS_CM, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.UNITS_EX, layout.getPosition(b).getRightUnits());
+ assertEquals(Sizeable.UNITS_INCH, layout.getPosition(b)
+ .getBottomUnits());
+ assertEquals(Sizeable.UNITS_MM, layout.getPosition(b).getLeftUnits());
+
+ }
+
+ /**
+ * Add component, then set all position attributes with combined setters for
+ * value and units; assert getters agree.
+ */
+ public void testSetPosition2() {
+ final Float SIZE = Float.valueOf(12);
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b);
+
+ layout.getPosition(b).setTop(SIZE, Sizeable.UNITS_CM);
+ layout.getPosition(b).setRight(SIZE, Sizeable.UNITS_EX);
+ layout.getPosition(b).setBottom(SIZE, Sizeable.UNITS_INCH);
+ layout.getPosition(b).setLeft(SIZE, Sizeable.UNITS_MM);
+
+ assertEquals(SIZE, layout.getPosition(b).getTopValue());
+ assertEquals(SIZE, layout.getPosition(b).getRightValue());
+ assertEquals(SIZE, layout.getPosition(b).getBottomValue());
+ assertEquals(SIZE, layout.getPosition(b).getLeftValue());
+
+ assertEquals(Sizeable.UNITS_CM, layout.getPosition(b).getTopUnits());
+ assertEquals(Sizeable.UNITS_EX, layout.getPosition(b).getRightUnits());
+ assertEquals(Sizeable.UNITS_INCH, layout.getPosition(b)
+ .getBottomUnits());
+ assertEquals(Sizeable.UNITS_MM, layout.getPosition(b).getLeftUnits());
+
+ }
+
+ /**
+ * Add component, set all attributes using CSS, unset some using method
+ * calls, assert getters agree.
+ */
+ public void testUnsetPosition() {
+ AbsoluteLayout layout = new AbsoluteLayout();
+ Button b = new Button();
+ layout.addComponent(b, CSS);
+
+ layout.getPosition(b).setTopValue(null);
+ layout.getPosition(b).setRightValue(null);
+ layout.getPosition(b).setBottomValue(null);
+ layout.getPosition(b).setLeftValue(null);
+
+ layout.getPosition(b).setZIndex(-1);
+
+ assertNull(layout.getPosition(b).getTopValue());
+ assertNull(layout.getPosition(b).getBottomValue());
+ assertNull(layout.getPosition(b).getLeftValue());
+ assertNull(layout.getPosition(b).getRightValue());
+
+ assertEquals("", layout.getPosition(b).getCSSString());
+
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java
index adf9c8d72e..6a8267f296 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractcomponentcontainer/TestAbstractComponentContainerListeners.java
@@ -1,21 +1,21 @@
-package com.vaadin.tests.server.component.abstractcomponentcontainer;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.ComponentContainer.ComponentAttachEvent;
-import com.vaadin.ui.ComponentContainer.ComponentAttachListener;
-import com.vaadin.ui.ComponentContainer.ComponentDetachEvent;
-import com.vaadin.ui.ComponentContainer.ComponentDetachListener;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.VerticalLayout;
-
-public class TestAbstractComponentContainerListeners extends AbstractListenerMethodsTest {
- public void testComponentDetachListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(HorizontalLayout.class,
- ComponentDetachEvent.class, ComponentDetachListener.class);
- }
-
- public void testComponentAttachListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(VerticalLayout.class,
- ComponentAttachEvent.class, ComponentAttachListener.class);
- }
-}
+package com.vaadin.tests.server.component.abstractcomponentcontainer;
+
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.ComponentContainer.ComponentAttachEvent;
+import com.vaadin.ui.ComponentContainer.ComponentAttachListener;
+import com.vaadin.ui.ComponentContainer.ComponentDetachEvent;
+import com.vaadin.ui.ComponentContainer.ComponentDetachListener;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.VerticalLayout;
+
+public class TestAbstractComponentContainerListeners extends AbstractListenerMethodsTest {
+ public void testComponentDetachListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(HorizontalLayout.class,
+ ComponentDetachEvent.class, ComponentDetachListener.class);
+ }
+
+ public void testComponentAttachListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(VerticalLayout.class,
+ ComponentAttachEvent.class, ComponentAttachListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java
index 63536baf68..7ee70bde13 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/TestAbstractFieldListeners.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.server.component.abstractfield;
-
-import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
-import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Button;
-
-public class TestAbstractFieldListeners extends AbstractListenerMethodsTest {
- public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, ReadOnlyStatusChangeEvent.class,
- ReadOnlyStatusChangeListener.class);
- }
-
- public void testValueChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, ValueChangeEvent.class,
- ValueChangeListener.class);
- }
-}
+package com.vaadin.tests.server.component.abstractfield;
+
+import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
+import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Button;
+
+public class TestAbstractFieldListeners extends AbstractListenerMethodsTest {
+ public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Button.class, ReadOnlyStatusChangeEvent.class,
+ ReadOnlyStatusChangeListener.class);
+ }
+
+ public void testValueChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Button.class, ValueChangeEvent.class,
+ ValueChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java
index ba5ea62181..bd67841f33 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java
@@ -1,115 +1,115 @@
-package com.vaadin.tests.server.component.abstractorderedlayout;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.junit.Test;
-
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.VerticalLayout;
-
-public class AddComponentsTest {
-
- Component[] children = new Component[] { new Label("A"), new Label("B"),
- new Label("C"), new Label("D") };
-
- @Test
- public void moveComponentsBetweenLayouts() {
- AbstractOrderedLayout layout1 = new HorizontalLayout();
- AbstractOrderedLayout layout2 = new VerticalLayout();
-
- layout1.addComponent(children[0]);
- layout1.addComponent(children[1]);
-
- layout2.addComponent(children[2]);
- layout2.addComponent(children[3]);
-
- layout2.addComponent(children[1], 1);
- assertOrder(layout1, new int[] { 0 });
- assertOrder(layout2, new int[] { 2, 1, 3 });
-
- layout1.addComponent(children[3], 0);
- assertOrder(layout1, new int[] { 3, 0 });
- assertOrder(layout2, new int[] { 2, 1 });
-
- layout2.addComponent(children[0]);
- assertOrder(layout1, new int[] { 3 });
- assertOrder(layout2, new int[] { 2, 1, 0 });
-
- layout1.addComponentAsFirst(children[1]);
- assertOrder(layout1, new int[] { 1, 3 });
- assertOrder(layout2, new int[] { 2, 0 });
- }
-
- @Test
- public void shuffleChildComponents() {
- shuffleChildComponents(new HorizontalLayout());
- shuffleChildComponents(new VerticalLayout());
- }
-
- private void shuffleChildComponents(AbstractOrderedLayout layout) {
-
- for (int i = 0; i < children.length; ++i) {
- layout.addComponent(children[i], i);
- }
-
- assertOrder(layout, new int[] { 0, 1, 2, 3 });
-
- // Move C from #2 to #1
- // Exhibits defect #7668
- layout.addComponent(children[2], 1);
- assertOrder(layout, new int[] { 0, 2, 1, 3 });
-
- // Move C from #1 to #4 (which becomes #3 when #1 is erased)
- layout.addComponent(children[2], 4);
- assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
- // Keep everything in place
- layout.addComponent(children[1], 1);
- assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
- // Move D from #2 to #0
- layout.addComponent(children[3], 0);
- assertOrder(layout, new int[] { 3, 0, 1, 2 });
-
- // Move A from #1 to end (#4 which becomes #3)
- layout.addComponent(children[0]);
- assertOrder(layout, new int[] { 3, 1, 2, 0 });
-
- // Keep everything in place
- layout.addComponent(children[0]);
- assertOrder(layout, new int[] { 3, 1, 2, 0 });
-
- // Move C from #2 to #0
- layout.addComponentAsFirst(children[2]);
- assertOrder(layout, new int[] { 2, 3, 1, 0 });
-
- // Keep everything in place
- layout.addComponentAsFirst(children[2]);
- assertOrder(layout, new int[] { 2, 3, 1, 0 });
- }
-
- /**
- * Asserts that layout has the components in children in the order specified
- * by indices.
- */
- private void assertOrder(Layout layout, int[] indices) {
- Iterator<?> i = layout.getComponentIterator();
- try {
- for (int index : indices) {
- assertSame(children[index], i.next());
- }
- assertFalse("Too many components in layout", i.hasNext());
- } catch (NoSuchElementException e) {
- fail("Too few components in layout");
- }
- }
-}
+package com.vaadin.tests.server.component.abstractorderedlayout;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.junit.Test;
+
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.VerticalLayout;
+
+public class AddComponentsTest {
+
+ Component[] children = new Component[] { new Label("A"), new Label("B"),
+ new Label("C"), new Label("D") };
+
+ @Test
+ public void moveComponentsBetweenLayouts() {
+ AbstractOrderedLayout layout1 = new HorizontalLayout();
+ AbstractOrderedLayout layout2 = new VerticalLayout();
+
+ layout1.addComponent(children[0]);
+ layout1.addComponent(children[1]);
+
+ layout2.addComponent(children[2]);
+ layout2.addComponent(children[3]);
+
+ layout2.addComponent(children[1], 1);
+ assertOrder(layout1, new int[] { 0 });
+ assertOrder(layout2, new int[] { 2, 1, 3 });
+
+ layout1.addComponent(children[3], 0);
+ assertOrder(layout1, new int[] { 3, 0 });
+ assertOrder(layout2, new int[] { 2, 1 });
+
+ layout2.addComponent(children[0]);
+ assertOrder(layout1, new int[] { 3 });
+ assertOrder(layout2, new int[] { 2, 1, 0 });
+
+ layout1.addComponentAsFirst(children[1]);
+ assertOrder(layout1, new int[] { 1, 3 });
+ assertOrder(layout2, new int[] { 2, 0 });
+ }
+
+ @Test
+ public void shuffleChildComponents() {
+ shuffleChildComponents(new HorizontalLayout());
+ shuffleChildComponents(new VerticalLayout());
+ }
+
+ private void shuffleChildComponents(AbstractOrderedLayout layout) {
+
+ for (int i = 0; i < children.length; ++i) {
+ layout.addComponent(children[i], i);
+ }
+
+ assertOrder(layout, new int[] { 0, 1, 2, 3 });
+
+ // Move C from #2 to #1
+ // Exhibits defect #7668
+ layout.addComponent(children[2], 1);
+ assertOrder(layout, new int[] { 0, 2, 1, 3 });
+
+ // Move C from #1 to #4 (which becomes #3 when #1 is erased)
+ layout.addComponent(children[2], 4);
+ assertOrder(layout, new int[] { 0, 1, 3, 2 });
+
+ // Keep everything in place
+ layout.addComponent(children[1], 1);
+ assertOrder(layout, new int[] { 0, 1, 3, 2 });
+
+ // Move D from #2 to #0
+ layout.addComponent(children[3], 0);
+ assertOrder(layout, new int[] { 3, 0, 1, 2 });
+
+ // Move A from #1 to end (#4 which becomes #3)
+ layout.addComponent(children[0]);
+ assertOrder(layout, new int[] { 3, 1, 2, 0 });
+
+ // Keep everything in place
+ layout.addComponent(children[0]);
+ assertOrder(layout, new int[] { 3, 1, 2, 0 });
+
+ // Move C from #2 to #0
+ layout.addComponentAsFirst(children[2]);
+ assertOrder(layout, new int[] { 2, 3, 1, 0 });
+
+ // Keep everything in place
+ layout.addComponentAsFirst(children[2]);
+ assertOrder(layout, new int[] { 2, 3, 1, 0 });
+ }
+
+ /**
+ * Asserts that layout has the components in children in the order specified
+ * by indices.
+ */
+ private void assertOrder(Layout layout, int[] indices) {
+ Iterator<?> i = layout.getComponentIterator();
+ try {
+ for (int index : indices) {
+ assertSame(children[index], i.next());
+ }
+ assertFalse("Too many components in layout", i.hasNext());
+ } catch (NoSuchElementException e) {
+ fail("Too few components in layout");
+ }
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java
index 05dfc47126..02143a2796 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/TestAbstractOrderedLayoutListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.abstractorderedlayout;
-
-import com.vaadin.event.LayoutEvents.LayoutClickEvent;
-import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.VerticalLayout;
-
-public class TestAbstractOrderedLayoutListeners extends AbstractListenerMethodsTest {
- public void testLayoutClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(VerticalLayout.class, LayoutClickEvent.class,
- LayoutClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.abstractorderedlayout;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.VerticalLayout;
+
+public class TestAbstractOrderedLayoutListeners extends AbstractListenerMethodsTest {
+ public void testLayoutClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(VerticalLayout.class, LayoutClickEvent.class,
+ LayoutClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java
index c1886943fd..75c19b0517 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractselect/TestAbstractSelectListeners.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.server.component.abstractselect;
-
-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.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.ComboBox;
-
-public class TestAbstractSelectListeners extends AbstractListenerMethodsTest {
- public void testItemSetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(ComboBox.class, ItemSetChangeEvent.class,
- ItemSetChangeListener.class);
- }
-
- public void testPropertySetChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(ComboBox.class, PropertySetChangeEvent.class,
- PropertySetChangeListener.class);
- }
-}
+package com.vaadin.tests.server.component.abstractselect;
+
+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.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.ComboBox;
+
+public class TestAbstractSelectListeners extends AbstractListenerMethodsTest {
+ public void testItemSetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(ComboBox.class, ItemSetChangeEvent.class,
+ ItemSetChangeListener.class);
+ }
+
+ public void testPropertySetChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(ComboBox.class, PropertySetChangeEvent.class,
+ PropertySetChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java
index 4f66d1446b..5e9556c182 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstractsplitpanel/TestAbstractSplitPanelListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.abstractsplitpanel;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent;
-import com.vaadin.ui.AbstractSplitPanel.SplitterClickListener;
-import com.vaadin.ui.HorizontalSplitPanel;
-
-public class TestAbstractSplitPanelListeners extends AbstractListenerMethodsTest {
- public void testSplitterClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(HorizontalSplitPanel.class,
- SplitterClickEvent.class, SplitterClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.abstractsplitpanel;
+
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent;
+import com.vaadin.ui.AbstractSplitPanel.SplitterClickListener;
+import com.vaadin.ui.HorizontalSplitPanel;
+
+public class TestAbstractSplitPanelListeners extends AbstractListenerMethodsTest {
+ public void testSplitterClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(HorizontalSplitPanel.class,
+ SplitterClickEvent.class, SplitterClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java b/tests/server-side/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java
index fb8eb65f55..9868d6ebfd 100644
--- a/tests/server-side/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/abstracttextfield/TestAbstractTextFieldListeners.java
@@ -1,27 +1,27 @@
-package com.vaadin.tests.server.component.abstracttextfield;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.event.FieldEvents.TextChangeEvent;
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.TextField;
-
-public class TestAbstractTextFieldListeners extends AbstractListenerMethodsTest {
- public void testTextChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(TextField.class, TextChangeEvent.class,
- TextChangeListener.class);
- }
-
- public void testFocusListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(TextField.class, FocusEvent.class,
- FocusListener.class);
- }
-
- public void testBlurListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(TextField.class, BlurEvent.class,
- BlurListener.class);
- }
-}
+package com.vaadin.tests.server.component.abstracttextfield;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.TextField;
+
+public class TestAbstractTextFieldListeners extends AbstractListenerMethodsTest {
+ public void testTextChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(TextField.class, TextChangeEvent.class,
+ TextChangeListener.class);
+ }
+
+ public void testFocusListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(TextField.class, FocusEvent.class,
+ FocusListener.class);
+ }
+
+ public void testBlurListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(TextField.class, BlurEvent.class,
+ BlurListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/button/ButtonListeners.java b/tests/server-side/com/vaadin/tests/server/component/button/ButtonListeners.java
index 59ddad4efe..dc37312eea 100644
--- a/tests/server-side/com/vaadin/tests/server/component/button/ButtonListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/button/ButtonListeners.java
@@ -1,27 +1,27 @@
-package com.vaadin.tests.server.component.button;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-
-public class ButtonListeners extends AbstractListenerMethodsTest {
- public void testFocusListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, FocusEvent.class,
- FocusListener.class);
- }
-
- public void testBlurListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, BlurEvent.class,
- BlurListener.class);
- }
-
- public void testClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Button.class, ClickEvent.class,
- ClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.button;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class ButtonListeners extends AbstractListenerMethodsTest {
+ public void testFocusListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Button.class, FocusEvent.class,
+ FocusListener.class);
+ }
+
+ public void testBlurListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Button.class, BlurEvent.class,
+ BlurListener.class);
+ }
+
+ public void testClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Button.class, ClickEvent.class,
+ ClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java b/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java
index 29657830e8..d4a0592768 100644
--- a/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java
+++ b/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java
@@ -1,109 +1,109 @@
-package com.vaadin.tests.server.component.csslayout;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-
-public class AddComponentsTest {
-
- private Component[] children = new Component[] { new Label("A"),
- new Label("B"), new Label("C"), new Label("D") };
-
- @Test
- public void moveComponentsBetweenLayouts() {
- CssLayout layout1 = new CssLayout();
- CssLayout layout2 = new CssLayout();
-
- layout1.addComponent(children[0]);
- layout1.addComponent(children[1]);
-
- layout2.addComponent(children[2]);
- layout2.addComponent(children[3]);
-
- layout2.addComponent(children[1], 1);
- assertOrder(layout1, new int[] { 0 });
- assertOrder(layout2, new int[] { 2, 1, 3 });
-
- layout1.addComponent(children[3], 0);
- assertOrder(layout1, new int[] { 3, 0 });
- assertOrder(layout2, new int[] { 2, 1 });
-
- layout2.addComponent(children[0]);
- assertOrder(layout1, new int[] { 3 });
- assertOrder(layout2, new int[] { 2, 1, 0 });
-
- layout1.addComponentAsFirst(children[1]);
- assertOrder(layout1, new int[] { 1, 3 });
- assertOrder(layout2, new int[] { 2, 0 });
- }
-
- @Test
- public void shuffleChildComponents() {
- CssLayout layout = new CssLayout();
-
- for (int i = 0; i < children.length; ++i) {
- layout.addComponent(children[i], i);
- }
-
- assertOrder(layout, new int[] { 0, 1, 2, 3 });
-
- // Move C from #2 to #1
- // Exhibits defect #7668
- layout.addComponent(children[2], 1);
- assertOrder(layout, new int[] { 0, 2, 1, 3 });
-
- // Move C from #1 to #4 (which becomes #3 when #1 is erased)
- layout.addComponent(children[2], 4);
- assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
- // Keep everything in place
- layout.addComponent(children[1], 1);
- assertOrder(layout, new int[] { 0, 1, 3, 2 });
-
- // Move D from #2 to #0
- layout.addComponent(children[3], 0);
- assertOrder(layout, new int[] { 3, 0, 1, 2 });
-
- // Move A from #1 to end (#4 which becomes #3)
- layout.addComponent(children[0]);
- assertOrder(layout, new int[] { 3, 1, 2, 0 });
-
- // Keep everything in place
- layout.addComponent(children[0]);
- assertOrder(layout, new int[] { 3, 1, 2, 0 });
-
- // Move C from #2 to #0
- layout.addComponentAsFirst(children[2]);
- assertOrder(layout, new int[] { 2, 3, 1, 0 });
-
- // Keep everything in place
- layout.addComponentAsFirst(children[2]);
- assertOrder(layout, new int[] { 2, 3, 1, 0 });
- }
-
- /**
- * Asserts that layout has the components in children in the order specified
- * by indices.
- */
- private void assertOrder(Layout layout, int[] indices) {
- Iterator<?> i = layout.getComponentIterator();
- try {
- for (int index : indices) {
- assertSame(children[index], i.next());
- }
- assertFalse("Too many components in layout", i.hasNext());
- } catch (NoSuchElementException e) {
- fail("Too few components in layout");
- }
- }
-}
+package com.vaadin.tests.server.component.csslayout;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+
+public class AddComponentsTest {
+
+ private Component[] children = new Component[] { new Label("A"),
+ new Label("B"), new Label("C"), new Label("D") };
+
+ @Test
+ public void moveComponentsBetweenLayouts() {
+ CssLayout layout1 = new CssLayout();
+ CssLayout layout2 = new CssLayout();
+
+ layout1.addComponent(children[0]);
+ layout1.addComponent(children[1]);
+
+ layout2.addComponent(children[2]);
+ layout2.addComponent(children[3]);
+
+ layout2.addComponent(children[1], 1);
+ assertOrder(layout1, new int[] { 0 });
+ assertOrder(layout2, new int[] { 2, 1, 3 });
+
+ layout1.addComponent(children[3], 0);
+ assertOrder(layout1, new int[] { 3, 0 });
+ assertOrder(layout2, new int[] { 2, 1 });
+
+ layout2.addComponent(children[0]);
+ assertOrder(layout1, new int[] { 3 });
+ assertOrder(layout2, new int[] { 2, 1, 0 });
+
+ layout1.addComponentAsFirst(children[1]);
+ assertOrder(layout1, new int[] { 1, 3 });
+ assertOrder(layout2, new int[] { 2, 0 });
+ }
+
+ @Test
+ public void shuffleChildComponents() {
+ CssLayout layout = new CssLayout();
+
+ for (int i = 0; i < children.length; ++i) {
+ layout.addComponent(children[i], i);
+ }
+
+ assertOrder(layout, new int[] { 0, 1, 2, 3 });
+
+ // Move C from #2 to #1
+ // Exhibits defect #7668
+ layout.addComponent(children[2], 1);
+ assertOrder(layout, new int[] { 0, 2, 1, 3 });
+
+ // Move C from #1 to #4 (which becomes #3 when #1 is erased)
+ layout.addComponent(children[2], 4);
+ assertOrder(layout, new int[] { 0, 1, 3, 2 });
+
+ // Keep everything in place
+ layout.addComponent(children[1], 1);
+ assertOrder(layout, new int[] { 0, 1, 3, 2 });
+
+ // Move D from #2 to #0
+ layout.addComponent(children[3], 0);
+ assertOrder(layout, new int[] { 3, 0, 1, 2 });
+
+ // Move A from #1 to end (#4 which becomes #3)
+ layout.addComponent(children[0]);
+ assertOrder(layout, new int[] { 3, 1, 2, 0 });
+
+ // Keep everything in place
+ layout.addComponent(children[0]);
+ assertOrder(layout, new int[] { 3, 1, 2, 0 });
+
+ // Move C from #2 to #0
+ layout.addComponentAsFirst(children[2]);
+ assertOrder(layout, new int[] { 2, 3, 1, 0 });
+
+ // Keep everything in place
+ layout.addComponentAsFirst(children[2]);
+ assertOrder(layout, new int[] { 2, 3, 1, 0 });
+ }
+
+ /**
+ * Asserts that layout has the components in children in the order specified
+ * by indices.
+ */
+ private void assertOrder(Layout layout, int[] indices) {
+ Iterator<?> i = layout.getComponentIterator();
+ try {
+ for (int index : indices) {
+ assertSame(children[index], i.next());
+ }
+ assertFalse("Too many components in layout", i.hasNext());
+ } catch (NoSuchElementException e) {
+ fail("Too few components in layout");
+ }
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java b/tests/server-side/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java
index e646467cb2..21a48888d6 100644
--- a/tests/server-side/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/csslayout/CssLayoutListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.csslayout;
-
-import com.vaadin.event.LayoutEvents.LayoutClickEvent;
-import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.CssLayout;
-
-public class CssLayoutListeners extends AbstractListenerMethodsTest {
- public void testLayoutClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(CssLayout.class, LayoutClickEvent.class,
- LayoutClickListener.class);
- }
+package com.vaadin.tests.server.component.csslayout;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.CssLayout;
+
+public class CssLayoutListeners extends AbstractListenerMethodsTest {
+ public void testLayoutClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(CssLayout.class, LayoutClickEvent.class,
+ LayoutClickListener.class);
+ }
} \ No newline at end of file
diff --git a/tests/server-side/com/vaadin/tests/server/component/datefield/DateFieldListeners.java b/tests/server-side/com/vaadin/tests/server/component/datefield/DateFieldListeners.java
index 1d7f729868..0f4aee35c7 100644
--- a/tests/server-side/com/vaadin/tests/server/component/datefield/DateFieldListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/datefield/DateFieldListeners.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.server.component.datefield;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.DateField;
-
-public class DateFieldListeners extends AbstractListenerMethodsTest {
- public void testFocusListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(DateField.class, FocusEvent.class,
- FocusListener.class);
- }
-
- public void testBlurListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(DateField.class, BlurEvent.class,
- BlurListener.class);
- }
-}
+package com.vaadin.tests.server.component.datefield;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.DateField;
+
+public class DateFieldListeners extends AbstractListenerMethodsTest {
+ public void testFocusListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(DateField.class, FocusEvent.class,
+ FocusListener.class);
+ }
+
+ public void testBlurListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(DateField.class, BlurEvent.class,
+ BlurListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/datefield/WeekNumberCalculation.java b/tests/server-side/com/vaadin/tests/server/component/datefield/WeekNumberCalculation.java
index 428a8634b3..ae8bc9beae 100644
--- a/tests/server-side/com/vaadin/tests/server/component/datefield/WeekNumberCalculation.java
+++ b/tests/server-side/com/vaadin/tests/server/component/datefield/WeekNumberCalculation.java
@@ -1,111 +1,111 @@
-package com.vaadin.tests.server.component.datefield;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import com.vaadin.terminal.gwt.client.DateTimeService;
-
-public class WeekNumberCalculation extends TestCase {
-
- final long MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
-
- static Map<Date, Integer> isoWeekNumbers = new HashMap<Date, Integer>();
- static {
- isoWeekNumbers.put(getDate(2005, 02, 02), 5);
-
- isoWeekNumbers.put(getDate(2005, 1, 1), 53);
- isoWeekNumbers.put(getDate(2005, 1, 2), 53);
- isoWeekNumbers.put(getDate(2005, 1, 3), 1);
- isoWeekNumbers.put(getDate(2005, 1, 4), 1);
- isoWeekNumbers.put(getDate(2005, 1, 5), 1);
- isoWeekNumbers.put(getDate(2005, 1, 6), 1);
- isoWeekNumbers.put(getDate(2005, 1, 7), 1);
- isoWeekNumbers.put(getDate(2005, 1, 8), 1);
- isoWeekNumbers.put(getDate(2005, 1, 9), 1);
- isoWeekNumbers.put(getDate(2005, 1, 10), 2);
- isoWeekNumbers.put(getDate(2005, 12, 31), 52);
- isoWeekNumbers.put(getDate(2005, 12, 30), 52);
- isoWeekNumbers.put(getDate(2005, 12, 29), 52);
- isoWeekNumbers.put(getDate(2005, 12, 28), 52);
- isoWeekNumbers.put(getDate(2005, 12, 27), 52);
- isoWeekNumbers.put(getDate(2005, 12, 26), 52);
- isoWeekNumbers.put(getDate(2005, 12, 25), 51);
- isoWeekNumbers.put(getDate(2007, 1, 1), 1);
- isoWeekNumbers.put(getDate(2007, 12, 30), 52);
- isoWeekNumbers.put(getDate(2007, 12, 31), 1);
- isoWeekNumbers.put(getDate(2008, 1, 1), 1);
- isoWeekNumbers.put(getDate(2008, 12, 28), 52);
- isoWeekNumbers.put(getDate(2008, 12, 29), 1);
- isoWeekNumbers.put(getDate(2008, 12, 30), 1);
- isoWeekNumbers.put(getDate(2008, 12, 31), 1);
- isoWeekNumbers.put(getDate(2009, 1, 1), 1);
- isoWeekNumbers.put(getDate(2009, 12, 31), 53);
- isoWeekNumbers.put(getDate(2010, 1, 1), 53);
- isoWeekNumbers.put(getDate(2010, 1, 2), 53);
- isoWeekNumbers.put(getDate(2010, 1, 3), 53);
- isoWeekNumbers.put(getDate(2010, 1, 4), 1);
- isoWeekNumbers.put(getDate(2010, 1, 5), 1);
- isoWeekNumbers.put(getDate(2010, 10, 10), 40);
-
- }
-
- /**
- * Test all dates from 1990-1992 + some more and see that {@link Calendar}
- * calculates the ISO week number like we do.
- *
- */
- public void testISOWeekNumbers() {
- Calendar c = Calendar.getInstance();
- c.set(1990, 1, 1);
- long start = c.getTimeInMillis();
-
- for (int i = 0; i < 1000; i++) {
- Date d = new Date(start + i * MILLISECONDS_PER_DAY);
- int expected = getCalendarISOWeekNr(d);
- int calculated = DateTimeService.getISOWeekNumber(d);
- assertEquals(d + " should be week " + expected, expected,
- calculated);
-
- }
- }
-
- /**
- * Verify that special cases are handled correctly by us (and
- * {@link Calendar}).
- *
- */
- public void testSampleISOWeekNumbers() {
- for (Date d : isoWeekNumbers.keySet()) {
- // System.out.println("Sample: " + d);
- int expected = isoWeekNumbers.get(d);
- int calculated = DateTimeService.getISOWeekNumber(d);
- assertEquals(d + " should be week " + expected
- + " (Java Calendar is wrong?)", expected,
- getCalendarISOWeekNr(d));
- assertEquals(d + " should be week " + expected, expected,
- calculated);
-
- }
- }
-
- private int getCalendarISOWeekNr(Date d) {
- Calendar c = Calendar.getInstance();
- c.setFirstDayOfWeek(Calendar.MONDAY);
- c.setMinimalDaysInFirstWeek(4);
- c.setTime(d);
-
- return c.get(Calendar.WEEK_OF_YEAR);
- }
-
- private static Date getDate(int year, int month, int date) {
- Calendar c = Calendar.getInstance();
- c.clear();
- c.set(year, month - 1, date);
- return c.getTime();
- }
-
-}
+package com.vaadin.tests.server.component.datefield;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import com.vaadin.terminal.gwt.client.DateTimeService;
+
+public class WeekNumberCalculation extends TestCase {
+
+ final long MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
+
+ static Map<Date, Integer> isoWeekNumbers = new HashMap<Date, Integer>();
+ static {
+ isoWeekNumbers.put(getDate(2005, 02, 02), 5);
+
+ isoWeekNumbers.put(getDate(2005, 1, 1), 53);
+ isoWeekNumbers.put(getDate(2005, 1, 2), 53);
+ isoWeekNumbers.put(getDate(2005, 1, 3), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 4), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 5), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 6), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 7), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 8), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 9), 1);
+ isoWeekNumbers.put(getDate(2005, 1, 10), 2);
+ isoWeekNumbers.put(getDate(2005, 12, 31), 52);
+ isoWeekNumbers.put(getDate(2005, 12, 30), 52);
+ isoWeekNumbers.put(getDate(2005, 12, 29), 52);
+ isoWeekNumbers.put(getDate(2005, 12, 28), 52);
+ isoWeekNumbers.put(getDate(2005, 12, 27), 52);
+ isoWeekNumbers.put(getDate(2005, 12, 26), 52);
+ isoWeekNumbers.put(getDate(2005, 12, 25), 51);
+ isoWeekNumbers.put(getDate(2007, 1, 1), 1);
+ isoWeekNumbers.put(getDate(2007, 12, 30), 52);
+ isoWeekNumbers.put(getDate(2007, 12, 31), 1);
+ isoWeekNumbers.put(getDate(2008, 1, 1), 1);
+ isoWeekNumbers.put(getDate(2008, 12, 28), 52);
+ isoWeekNumbers.put(getDate(2008, 12, 29), 1);
+ isoWeekNumbers.put(getDate(2008, 12, 30), 1);
+ isoWeekNumbers.put(getDate(2008, 12, 31), 1);
+ isoWeekNumbers.put(getDate(2009, 1, 1), 1);
+ isoWeekNumbers.put(getDate(2009, 12, 31), 53);
+ isoWeekNumbers.put(getDate(2010, 1, 1), 53);
+ isoWeekNumbers.put(getDate(2010, 1, 2), 53);
+ isoWeekNumbers.put(getDate(2010, 1, 3), 53);
+ isoWeekNumbers.put(getDate(2010, 1, 4), 1);
+ isoWeekNumbers.put(getDate(2010, 1, 5), 1);
+ isoWeekNumbers.put(getDate(2010, 10, 10), 40);
+
+ }
+
+ /**
+ * Test all dates from 1990-1992 + some more and see that {@link Calendar}
+ * calculates the ISO week number like we do.
+ *
+ */
+ public void testISOWeekNumbers() {
+ Calendar c = Calendar.getInstance();
+ c.set(1990, 1, 1);
+ long start = c.getTimeInMillis();
+
+ for (int i = 0; i < 1000; i++) {
+ Date d = new Date(start + i * MILLISECONDS_PER_DAY);
+ int expected = getCalendarISOWeekNr(d);
+ int calculated = DateTimeService.getISOWeekNumber(d);
+ assertEquals(d + " should be week " + expected, expected,
+ calculated);
+
+ }
+ }
+
+ /**
+ * Verify that special cases are handled correctly by us (and
+ * {@link Calendar}).
+ *
+ */
+ public void testSampleISOWeekNumbers() {
+ for (Date d : isoWeekNumbers.keySet()) {
+ // System.out.println("Sample: " + d);
+ int expected = isoWeekNumbers.get(d);
+ int calculated = DateTimeService.getISOWeekNumber(d);
+ assertEquals(d + " should be week " + expected
+ + " (Java Calendar is wrong?)", expected,
+ getCalendarISOWeekNr(d));
+ assertEquals(d + " should be week " + expected, expected,
+ calculated);
+
+ }
+ }
+
+ private int getCalendarISOWeekNr(Date d) {
+ Calendar c = Calendar.getInstance();
+ c.setFirstDayOfWeek(Calendar.MONDAY);
+ c.setMinimalDaysInFirstWeek(4);
+ c.setTime(d);
+
+ return c.get(Calendar.WEEK_OF_YEAR);
+ }
+
+ private static Date getDate(int year, int month, int date) {
+ Calendar c = Calendar.getInstance();
+ c.clear();
+ c.set(year, month - 1, date);
+ return c.getTime();
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java b/tests/server-side/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java
index 66a9a2b5d5..7512f0f499 100644
--- a/tests/server-side/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/embedded/EmbeddedListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.embedded;
-
-import com.vaadin.event.MouseEvents.ClickEvent;
-import com.vaadin.event.MouseEvents.ClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Embedded;
-
-public class EmbeddedListeners extends AbstractListenerMethodsTest {
- public void testClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Embedded.class, ClickEvent.class,
- ClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.embedded;
+
+import com.vaadin.event.MouseEvents.ClickEvent;
+import com.vaadin.event.MouseEvents.ClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Embedded;
+
+public class EmbeddedListeners extends AbstractListenerMethodsTest {
+ public void testClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Embedded.class, ClickEvent.class,
+ ClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java b/tests/server-side/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java
index 24db0856da..ce3a9faa65 100644
--- a/tests/server-side/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/gridlayout/GridLayoutListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.gridlayout;
-
-import com.vaadin.event.LayoutEvents.LayoutClickEvent;
-import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.GridLayout;
-
-public class GridLayoutListeners extends AbstractListenerMethodsTest {
- public void testLayoutClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(GridLayout.class, LayoutClickEvent.class,
- LayoutClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.gridlayout;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.GridLayout;
+
+public class GridLayoutListeners extends AbstractListenerMethodsTest {
+ public void testLayoutClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(GridLayout.class, LayoutClickEvent.class,
+ LayoutClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/label/LabelListeners.java b/tests/server-side/com/vaadin/tests/server/component/label/LabelListeners.java
index a25309b32f..3ed79f5010 100644
--- a/tests/server-side/com/vaadin/tests/server/component/label/LabelListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/label/LabelListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.label;
-
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Label.ValueChangeEvent;
-
-public class LabelListeners extends AbstractListenerMethodsTest {
- public void testValueChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Label.class, ValueChangeEvent.class,
- ValueChangeListener.class);
- }
-}
+package com.vaadin.tests.server.component.label;
+
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Label.ValueChangeEvent;
+
+public class LabelListeners extends AbstractListenerMethodsTest {
+ public void testValueChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Label.class, ValueChangeEvent.class,
+ ValueChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/loginform/LoginFormListeners.java b/tests/server-side/com/vaadin/tests/server/component/loginform/LoginFormListeners.java
index a8e7d76710..fd3e02994c 100644
--- a/tests/server-side/com/vaadin/tests/server/component/loginform/LoginFormListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/loginform/LoginFormListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.loginform;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.LoginForm;
-import com.vaadin.ui.LoginForm.LoginEvent;
-import com.vaadin.ui.LoginForm.LoginListener;
-
-public class LoginFormListeners extends AbstractListenerMethodsTest {
- public void testLoginListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(LoginForm.class, LoginEvent.class,
- LoginListener.class);
- }
-}
+package com.vaadin.tests.server.component.loginform;
+
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.LoginForm;
+import com.vaadin.ui.LoginForm.LoginEvent;
+import com.vaadin.ui.LoginForm.LoginListener;
+
+public class LoginFormListeners extends AbstractListenerMethodsTest {
+ public void testLoginListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(LoginForm.class, LoginEvent.class,
+ LoginListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/menubar/MenuBarIds.java b/tests/server-side/com/vaadin/tests/server/component/menubar/MenuBarIds.java
index 9ce55361bd..a0dadf8cc6 100644
--- a/tests/server-side/com/vaadin/tests/server/component/menubar/MenuBarIds.java
+++ b/tests/server-side/com/vaadin/tests/server/component/menubar/MenuBarIds.java
@@ -1,97 +1,97 @@
-package com.vaadin.tests.server.component.menubar;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.Command;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public class MenuBarIds extends TestCase implements Command {
-
- private MenuItem lastSelectedItem;
- private MenuItem menuFile;
- private MenuItem menuEdit;
- private MenuItem menuEditCopy;
- private MenuItem menuEditCut;
- private MenuItem menuEditPaste;
- private MenuItem menuEditFind;
- private MenuItem menuFileOpen;
- private MenuItem menuFileSave;
- private MenuItem menuFileExit;
- private Set<MenuItem> menuItems = new HashSet<MenuItem>();
-
- private MenuBar menuBar;
-
- @Override
- public void setUp() {
- menuBar = new MenuBar();
- menuFile = menuBar.addItem("File", this);
- menuEdit = menuBar.addItem("Edit", this);
- menuEditCopy = menuEdit.addItem("Copy", this);
- menuEditCut = menuEdit.addItem("Cut", this);
- menuEditPaste = menuEdit.addItem("Paste", this);
- menuEdit.addSeparator();
- menuEditFind = menuEdit.addItem("Find...", this);
- menuFileOpen = menuFile.addItem("Open", this);
- menuFileSave = menuFile.addItem("Save", this);
- menuFile.addSeparator();
- menuFileExit = menuFile.addItem("Exit", this);
-
- menuItems.add(menuFile);
- menuItems.add(menuEdit);
- menuItems.add(menuEditCopy);
- menuItems.add(menuEditCut);
- menuItems.add(menuEditPaste);
- menuItems.add(menuEditFind);
- menuItems.add(menuFileOpen);
- menuItems.add(menuFileSave);
- menuItems.add(menuFileExit);
- }
-
- public void testMenubarIdUniqueness() {
- // Ids within a menubar must be unique
- assertUniqueIds(menuBar);
-
- menuBar.removeItem(menuFile);
- MenuItem file2 = menuBar.addItem("File2", this);
- MenuItem file3 = menuBar.addItem("File3", this);
- MenuItem file2sub = file2.addItem("File2 sub menu", this);
- menuItems.add(file2);
- menuItems.add(file2sub);
- menuItems.add(file3);
-
- assertUniqueIds(menuBar);
- }
-
- private static void assertUniqueIds(MenuBar menuBar) {
-
- Set<Object> ids = new HashSet<Object>();
-
- for (MenuItem item : menuBar.getItems()) {
- assertUniqueIds(ids, item);
- }
- }
-
- private static void assertUniqueIds(Set<Object> ids, MenuItem item) {
- int id = item.getId();
- System.out.println("Item " + item.getText() + ", id: " + id);
- assertFalse(ids.contains(id));
- ids.add(id);
- if (item.getChildren() != null) {
- for (MenuItem subItem : item.getChildren()) {
- assertUniqueIds(ids, subItem);
- }
- }
- }
-
- public void menuSelected(MenuItem selectedItem) {
- assertNull("lastSelectedItem was not cleared before selecting an item",
- lastSelectedItem);
-
- lastSelectedItem = selectedItem;
-
- }
-}
+package com.vaadin.tests.server.component.menubar;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.Command;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class MenuBarIds extends TestCase implements Command {
+
+ private MenuItem lastSelectedItem;
+ private MenuItem menuFile;
+ private MenuItem menuEdit;
+ private MenuItem menuEditCopy;
+ private MenuItem menuEditCut;
+ private MenuItem menuEditPaste;
+ private MenuItem menuEditFind;
+ private MenuItem menuFileOpen;
+ private MenuItem menuFileSave;
+ private MenuItem menuFileExit;
+ private Set<MenuItem> menuItems = new HashSet<MenuItem>();
+
+ private MenuBar menuBar;
+
+ @Override
+ public void setUp() {
+ menuBar = new MenuBar();
+ menuFile = menuBar.addItem("File", this);
+ menuEdit = menuBar.addItem("Edit", this);
+ menuEditCopy = menuEdit.addItem("Copy", this);
+ menuEditCut = menuEdit.addItem("Cut", this);
+ menuEditPaste = menuEdit.addItem("Paste", this);
+ menuEdit.addSeparator();
+ menuEditFind = menuEdit.addItem("Find...", this);
+ menuFileOpen = menuFile.addItem("Open", this);
+ menuFileSave = menuFile.addItem("Save", this);
+ menuFile.addSeparator();
+ menuFileExit = menuFile.addItem("Exit", this);
+
+ menuItems.add(menuFile);
+ menuItems.add(menuEdit);
+ menuItems.add(menuEditCopy);
+ menuItems.add(menuEditCut);
+ menuItems.add(menuEditPaste);
+ menuItems.add(menuEditFind);
+ menuItems.add(menuFileOpen);
+ menuItems.add(menuFileSave);
+ menuItems.add(menuFileExit);
+ }
+
+ public void testMenubarIdUniqueness() {
+ // Ids within a menubar must be unique
+ assertUniqueIds(menuBar);
+
+ menuBar.removeItem(menuFile);
+ MenuItem file2 = menuBar.addItem("File2", this);
+ MenuItem file3 = menuBar.addItem("File3", this);
+ MenuItem file2sub = file2.addItem("File2 sub menu", this);
+ menuItems.add(file2);
+ menuItems.add(file2sub);
+ menuItems.add(file3);
+
+ assertUniqueIds(menuBar);
+ }
+
+ private static void assertUniqueIds(MenuBar menuBar) {
+
+ Set<Object> ids = new HashSet<Object>();
+
+ for (MenuItem item : menuBar.getItems()) {
+ assertUniqueIds(ids, item);
+ }
+ }
+
+ private static void assertUniqueIds(Set<Object> ids, MenuItem item) {
+ int id = item.getId();
+ System.out.println("Item " + item.getText() + ", id: " + id);
+ assertFalse(ids.contains(id));
+ ids.add(id);
+ if (item.getChildren() != null) {
+ for (MenuItem subItem : item.getChildren()) {
+ assertUniqueIds(ids, subItem);
+ }
+ }
+ }
+
+ public void menuSelected(MenuItem selectedItem) {
+ assertNull("lastSelectedItem was not cleared before selecting an item",
+ lastSelectedItem);
+
+ lastSelectedItem = selectedItem;
+
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java b/tests/server-side/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java
index a4c2289da4..7eb35c3882 100644
--- a/tests/server-side/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/optiongroup/OptionGroupListeners.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.server.component.optiongroup;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.OptionGroup;
-
-public class OptionGroupListeners extends AbstractListenerMethodsTest {
- public void testFocusListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(OptionGroup.class, FocusEvent.class,
- FocusListener.class);
- }
-
- public void testBlurListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(OptionGroup.class, BlurEvent.class,
- BlurListener.class);
- }
-}
+package com.vaadin.tests.server.component.optiongroup;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.OptionGroup;
+
+public class OptionGroupListeners extends AbstractListenerMethodsTest {
+ public void testFocusListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(OptionGroup.class, FocusEvent.class,
+ FocusListener.class);
+ }
+
+ public void testBlurListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(OptionGroup.class, BlurEvent.class,
+ BlurListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java b/tests/server-side/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java
index e17fb284dc..6a9d55d7e4 100644
--- a/tests/server-side/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java
+++ b/tests/server-side/com/vaadin/tests/server/component/orderedlayout/TestOrderedLayout.java
@@ -1,49 +1,49 @@
-package com.vaadin.tests.server.component.orderedlayout;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-public class TestOrderedLayout extends TestCase {
-
- public void testVLIteration() {
- testIndexing(new VerticalLayout(), 10);
- }
-
- public void testHLIteration() {
- testIndexing(new HorizontalLayout(), 12);
- }
-
- public void testIndexing(AbstractOrderedLayout aol, int nrComponents) {
- Component[] components = generateComponents(nrComponents);
- for (Component c : components) {
- aol.addComponent(c);
- }
- for (int i = 0; i < nrComponents; i++) {
- assert (aol.getComponent(i) == components[i]);
- assert (aol.getComponentIndex(components[i]) == i);
- }
-
- // Iteration should be in indexed order
- int idx = 0;
- for (Iterator<Component> i = aol.getComponentIterator(); i.hasNext();) {
- Component c = i.next();
- assert (aol.getComponentIndex(c) == idx++);
- }
- }
-
- private Component[] generateComponents(int nr) {
- Component[] components = new Component[nr];
- for (int i = 0; i < nr; i++) {
- components[i] = new Label("" + i);
- }
-
- return components;
- }
-}
+package com.vaadin.tests.server.component.orderedlayout;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class TestOrderedLayout extends TestCase {
+
+ public void testVLIteration() {
+ testIndexing(new VerticalLayout(), 10);
+ }
+
+ public void testHLIteration() {
+ testIndexing(new HorizontalLayout(), 12);
+ }
+
+ public void testIndexing(AbstractOrderedLayout aol, int nrComponents) {
+ Component[] components = generateComponents(nrComponents);
+ for (Component c : components) {
+ aol.addComponent(c);
+ }
+ for (int i = 0; i < nrComponents; i++) {
+ assert (aol.getComponent(i) == components[i]);
+ assert (aol.getComponentIndex(components[i]) == i);
+ }
+
+ // Iteration should be in indexed order
+ int idx = 0;
+ for (Iterator<Component> i = aol.getComponentIterator(); i.hasNext();) {
+ Component c = i.next();
+ assert (aol.getComponentIndex(c) == idx++);
+ }
+ }
+
+ private Component[] generateComponents(int nr) {
+ Component[] components = new Component[nr];
+ for (int i = 0; i < nr; i++) {
+ components[i] = new Label("" + i);
+ }
+
+ return components;
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/panel/PanelListeners.java b/tests/server-side/com/vaadin/tests/server/component/panel/PanelListeners.java
index e6094225e2..275e90f5d1 100644
--- a/tests/server-side/com/vaadin/tests/server/component/panel/PanelListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/panel/PanelListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.panel;
-
-import com.vaadin.event.MouseEvents.ClickEvent;
-import com.vaadin.event.MouseEvents.ClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Panel;
-
-public class PanelListeners extends AbstractListenerMethodsTest {
- public void testClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Panel.class, ClickEvent.class,
- ClickListener.class);
- }
-}
+package com.vaadin.tests.server.component.panel;
+
+import com.vaadin.event.MouseEvents.ClickEvent;
+import com.vaadin.event.MouseEvents.ClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Panel;
+
+public class PanelListeners extends AbstractListenerMethodsTest {
+ public void testClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Panel.class, ClickEvent.class,
+ ClickListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/popupview/PopupViewListeners.java b/tests/server-side/com/vaadin/tests/server/component/popupview/PopupViewListeners.java
index 5b5fc2eb31..12a5a0f520 100644
--- a/tests/server-side/com/vaadin/tests/server/component/popupview/PopupViewListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/popupview/PopupViewListeners.java
@@ -1,14 +1,14 @@
-package com.vaadin.tests.server.component.popupview;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.PopupView;
-import com.vaadin.ui.PopupView.PopupVisibilityEvent;
-import com.vaadin.ui.PopupView.PopupVisibilityListener;
-
-public class PopupViewListeners extends AbstractListenerMethodsTest {
- public void testPopupVisibilityListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(PopupView.class, PopupVisibilityEvent.class,
- PopupVisibilityListener.class, new PopupView("", new Label()));
- }
-}
+package com.vaadin.tests.server.component.popupview;
+
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.PopupView.PopupVisibilityEvent;
+import com.vaadin.ui.PopupView.PopupVisibilityListener;
+
+public class PopupViewListeners extends AbstractListenerMethodsTest {
+ public void testPopupVisibilityListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(PopupView.class, PopupVisibilityEvent.class,
+ PopupVisibilityListener.class, new PopupView("", new Label()));
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/select/SelectListeners.java b/tests/server-side/com/vaadin/tests/server/component/select/SelectListeners.java
index 8f90f2021e..c7703303d3 100644
--- a/tests/server-side/com/vaadin/tests/server/component/select/SelectListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/select/SelectListeners.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.server.component.select;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Select;
-
-public class SelectListeners extends AbstractListenerMethodsTest {
- public void testFocusListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Select.class, FocusEvent.class,
- FocusListener.class);
- }
-
- public void testBlurListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Select.class, BlurEvent.class,
- BlurListener.class);
- }
+package com.vaadin.tests.server.component.select;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Select;
+
+public class SelectListeners extends AbstractListenerMethodsTest {
+ public void testFocusListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Select.class, FocusEvent.class,
+ FocusListener.class);
+ }
+
+ public void testBlurListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Select.class, BlurEvent.class,
+ BlurListener.class);
+ }
} \ No newline at end of file
diff --git a/tests/server-side/com/vaadin/tests/server/component/table/TableListeners.java b/tests/server-side/com/vaadin/tests/server/component/table/TableListeners.java
index 75ec839823..6d9c7ed0eb 100644
--- a/tests/server-side/com/vaadin/tests/server/component/table/TableListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/table/TableListeners.java
@@ -1,40 +1,40 @@
-package com.vaadin.tests.server.component.table;
-
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Table.ColumnReorderEvent;
-import com.vaadin.ui.Table.ColumnReorderListener;
-import com.vaadin.ui.Table.ColumnResizeEvent;
-import com.vaadin.ui.Table.ColumnResizeListener;
-import com.vaadin.ui.Table.FooterClickEvent;
-import com.vaadin.ui.Table.FooterClickListener;
-import com.vaadin.ui.Table.HeaderClickEvent;
-import com.vaadin.ui.Table.HeaderClickListener;
-
-public class TableListeners extends AbstractListenerMethodsTest {
- public void testColumnResizeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Table.class, ColumnResizeEvent.class,
- ColumnResizeListener.class);
- }
-
- public void testItemClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Table.class, ItemClickEvent.class, ItemClickListener.class);
- }
-
- public void testFooterClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Table.class, FooterClickEvent.class,
- FooterClickListener.class);
- }
-
- public void testHeaderClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Table.class, HeaderClickEvent.class,
- HeaderClickListener.class);
- }
-
- public void testColumnReorderListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Table.class, ColumnReorderEvent.class,
- ColumnReorderListener.class);
- }
+package com.vaadin.tests.server.component.table;
+
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.ColumnReorderEvent;
+import com.vaadin.ui.Table.ColumnReorderListener;
+import com.vaadin.ui.Table.ColumnResizeEvent;
+import com.vaadin.ui.Table.ColumnResizeListener;
+import com.vaadin.ui.Table.FooterClickEvent;
+import com.vaadin.ui.Table.FooterClickListener;
+import com.vaadin.ui.Table.HeaderClickEvent;
+import com.vaadin.ui.Table.HeaderClickListener;
+
+public class TableListeners extends AbstractListenerMethodsTest {
+ public void testColumnResizeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Table.class, ColumnResizeEvent.class,
+ ColumnResizeListener.class);
+ }
+
+ public void testItemClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Table.class, ItemClickEvent.class, ItemClickListener.class);
+ }
+
+ public void testFooterClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Table.class, FooterClickEvent.class,
+ FooterClickListener.class);
+ }
+
+ public void testHeaderClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Table.class, HeaderClickEvent.class,
+ HeaderClickListener.class);
+ }
+
+ public void testColumnReorderListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Table.class, ColumnReorderEvent.class,
+ ColumnReorderListener.class);
+ }
} \ No newline at end of file
diff --git a/tests/server-side/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java b/tests/server-side/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java
index 30dcbca155..5c01a1c99f 100644
--- a/tests/server-side/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/tabsheet/TabSheetListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.tabsheet;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
-import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
-
-public class TabSheetListeners extends AbstractListenerMethodsTest {
- public void testSelectedTabChangeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(TabSheet.class, SelectedTabChangeEvent.class,
- SelectedTabChangeListener.class);
- }
-}
+package com.vaadin.tests.server.component.tabsheet;
+
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
+import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
+
+public class TabSheetListeners extends AbstractListenerMethodsTest {
+ public void testSelectedTabChangeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(TabSheet.class, SelectedTabChangeEvent.class,
+ SelectedTabChangeListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java b/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java
index 873bb1c030..1832d1bd95 100644
--- a/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java
+++ b/tests/server-side/com/vaadin/tests/server/component/tabsheet/TestTabSheet.java
@@ -1,124 +1,124 @@
-package com.vaadin.tests.server.component.tabsheet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Iterator;
-
-import org.junit.Test;
-
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-
-public class TestTabSheet {
-
- @Test
- public void addExistingComponent() {
- Component c = new Label("abc");
- TabSheet tabSheet = new TabSheet();
- tabSheet.addComponent(c);
- tabSheet.addComponent(c);
-
- Iterator<Component> iter = tabSheet.getComponentIterator();
-
- assertEquals(c, iter.next());
- assertEquals(false, iter.hasNext());
- assertNotNull(tabSheet.getTab(c));
- }
-
- @Test
- public void getComponentFromTab() {
- Component c = new Label("abc");
- TabSheet tabSheet = new TabSheet();
- Tab tab = tabSheet.addTab(c);
- assertEquals(c, tab.getComponent());
- }
-
- @Test
- public void addTabWithComponentOnly() {
- TabSheet tabSheet = new TabSheet();
- Tab tab1 = tabSheet.addTab(new Label("aaa"));
- Tab tab2 = tabSheet.addTab(new Label("bbb"));
- Tab tab3 = tabSheet.addTab(new Label("ccc"));
-
- // Check right order of tabs
- assertEquals(0, tabSheet.getTabPosition(tab1));
- assertEquals(1, tabSheet.getTabPosition(tab2));
- assertEquals(2, tabSheet.getTabPosition(tab3));
-
- // Calling addTab with existing component does not move tab
- tabSheet.addTab(tab1.getComponent());
-
- // Check right order of tabs
- assertEquals(0, tabSheet.getTabPosition(tab1));
- assertEquals(1, tabSheet.getTabPosition(tab2));
- assertEquals(2, tabSheet.getTabPosition(tab3));
- }
-
- @Test
- public void addTabWithComponentAndIndex() {
- TabSheet tabSheet = new TabSheet();
- Tab tab1 = tabSheet.addTab(new Label("aaa"));
- Tab tab2 = tabSheet.addTab(new Label("bbb"));
- Tab tab3 = tabSheet.addTab(new Label("ccc"));
-
- Tab tab4 = tabSheet.addTab(new Label("ddd"), 1);
- Tab tab5 = tabSheet.addTab(new Label("eee"), 3);
-
- assertEquals(0, tabSheet.getTabPosition(tab1));
- assertEquals(1, tabSheet.getTabPosition(tab4));
- assertEquals(2, tabSheet.getTabPosition(tab2));
- assertEquals(3, tabSheet.getTabPosition(tab5));
- assertEquals(4, tabSheet.getTabPosition(tab3));
-
- // Calling addTab with existing component does not move tab
- tabSheet.addTab(tab1.getComponent(), 3);
-
- assertEquals(0, tabSheet.getTabPosition(tab1));
- assertEquals(1, tabSheet.getTabPosition(tab4));
- assertEquals(2, tabSheet.getTabPosition(tab2));
- assertEquals(3, tabSheet.getTabPosition(tab5));
- assertEquals(4, tabSheet.getTabPosition(tab3));
- }
-
- @Test
- public void addTabWithAllParameters() {
- TabSheet tabSheet = new TabSheet();
- Tab tab1 = tabSheet.addTab(new Label("aaa"));
- Tab tab2 = tabSheet.addTab(new Label("bbb"));
- Tab tab3 = tabSheet.addTab(new Label("ccc"));
-
- Tab tab4 = tabSheet.addTab(new Label("ddd"), "ddd", null, 1);
- Tab tab5 = tabSheet.addTab(new Label("eee"), "eee", null, 3);
-
- assertEquals(0, tabSheet.getTabPosition(tab1));
- assertEquals(1, tabSheet.getTabPosition(tab4));
- assertEquals(2, tabSheet.getTabPosition(tab2));
- assertEquals(3, tabSheet.getTabPosition(tab5));
- assertEquals(4, tabSheet.getTabPosition(tab3));
-
- // Calling addTab with existing component does not move tab
- tabSheet.addTab(tab1.getComponent(), "xxx", null, 3);
-
- assertEquals(0, tabSheet.getTabPosition(tab1));
- assertEquals(1, tabSheet.getTabPosition(tab4));
- assertEquals(2, tabSheet.getTabPosition(tab2));
- assertEquals(3, tabSheet.getTabPosition(tab5));
- assertEquals(4, tabSheet.getTabPosition(tab3));
- }
-
- @Test
- public void getTabByPosition() {
- TabSheet tabSheet = new TabSheet();
- Tab tab1 = tabSheet.addTab(new Label("aaa"));
- Tab tab2 = tabSheet.addTab(new Label("bbb"));
- Tab tab3 = tabSheet.addTab(new Label("ccc"));
-
- assertEquals(tab1, tabSheet.getTab(0));
- assertEquals(tab2, tabSheet.getTab(1));
- assertEquals(tab3, tabSheet.getTab(2));
- }
-
-}
+package com.vaadin.tests.server.component.tabsheet;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class TestTabSheet {
+
+ @Test
+ public void addExistingComponent() {
+ Component c = new Label("abc");
+ TabSheet tabSheet = new TabSheet();
+ tabSheet.addComponent(c);
+ tabSheet.addComponent(c);
+
+ Iterator<Component> iter = tabSheet.getComponentIterator();
+
+ assertEquals(c, iter.next());
+ assertEquals(false, iter.hasNext());
+ assertNotNull(tabSheet.getTab(c));
+ }
+
+ @Test
+ public void getComponentFromTab() {
+ Component c = new Label("abc");
+ TabSheet tabSheet = new TabSheet();
+ Tab tab = tabSheet.addTab(c);
+ assertEquals(c, tab.getComponent());
+ }
+
+ @Test
+ public void addTabWithComponentOnly() {
+ TabSheet tabSheet = new TabSheet();
+ Tab tab1 = tabSheet.addTab(new Label("aaa"));
+ Tab tab2 = tabSheet.addTab(new Label("bbb"));
+ Tab tab3 = tabSheet.addTab(new Label("ccc"));
+
+ // Check right order of tabs
+ assertEquals(0, tabSheet.getTabPosition(tab1));
+ assertEquals(1, tabSheet.getTabPosition(tab2));
+ assertEquals(2, tabSheet.getTabPosition(tab3));
+
+ // Calling addTab with existing component does not move tab
+ tabSheet.addTab(tab1.getComponent());
+
+ // Check right order of tabs
+ assertEquals(0, tabSheet.getTabPosition(tab1));
+ assertEquals(1, tabSheet.getTabPosition(tab2));
+ assertEquals(2, tabSheet.getTabPosition(tab3));
+ }
+
+ @Test
+ public void addTabWithComponentAndIndex() {
+ TabSheet tabSheet = new TabSheet();
+ Tab tab1 = tabSheet.addTab(new Label("aaa"));
+ Tab tab2 = tabSheet.addTab(new Label("bbb"));
+ Tab tab3 = tabSheet.addTab(new Label("ccc"));
+
+ Tab tab4 = tabSheet.addTab(new Label("ddd"), 1);
+ Tab tab5 = tabSheet.addTab(new Label("eee"), 3);
+
+ assertEquals(0, tabSheet.getTabPosition(tab1));
+ assertEquals(1, tabSheet.getTabPosition(tab4));
+ assertEquals(2, tabSheet.getTabPosition(tab2));
+ assertEquals(3, tabSheet.getTabPosition(tab5));
+ assertEquals(4, tabSheet.getTabPosition(tab3));
+
+ // Calling addTab with existing component does not move tab
+ tabSheet.addTab(tab1.getComponent(), 3);
+
+ assertEquals(0, tabSheet.getTabPosition(tab1));
+ assertEquals(1, tabSheet.getTabPosition(tab4));
+ assertEquals(2, tabSheet.getTabPosition(tab2));
+ assertEquals(3, tabSheet.getTabPosition(tab5));
+ assertEquals(4, tabSheet.getTabPosition(tab3));
+ }
+
+ @Test
+ public void addTabWithAllParameters() {
+ TabSheet tabSheet = new TabSheet();
+ Tab tab1 = tabSheet.addTab(new Label("aaa"));
+ Tab tab2 = tabSheet.addTab(new Label("bbb"));
+ Tab tab3 = tabSheet.addTab(new Label("ccc"));
+
+ Tab tab4 = tabSheet.addTab(new Label("ddd"), "ddd", null, 1);
+ Tab tab5 = tabSheet.addTab(new Label("eee"), "eee", null, 3);
+
+ assertEquals(0, tabSheet.getTabPosition(tab1));
+ assertEquals(1, tabSheet.getTabPosition(tab4));
+ assertEquals(2, tabSheet.getTabPosition(tab2));
+ assertEquals(3, tabSheet.getTabPosition(tab5));
+ assertEquals(4, tabSheet.getTabPosition(tab3));
+
+ // Calling addTab with existing component does not move tab
+ tabSheet.addTab(tab1.getComponent(), "xxx", null, 3);
+
+ assertEquals(0, tabSheet.getTabPosition(tab1));
+ assertEquals(1, tabSheet.getTabPosition(tab4));
+ assertEquals(2, tabSheet.getTabPosition(tab2));
+ assertEquals(3, tabSheet.getTabPosition(tab5));
+ assertEquals(4, tabSheet.getTabPosition(tab3));
+ }
+
+ @Test
+ public void getTabByPosition() {
+ TabSheet tabSheet = new TabSheet();
+ Tab tab1 = tabSheet.addTab(new Label("aaa"));
+ Tab tab2 = tabSheet.addTab(new Label("bbb"));
+ Tab tab3 = tabSheet.addTab(new Label("ccc"));
+
+ assertEquals(tab1, tabSheet.getTab(0));
+ assertEquals(tab2, tabSheet.getTab(1));
+ assertEquals(tab3, tabSheet.getTab(2));
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/tree/TestListeners.java b/tests/server-side/com/vaadin/tests/server/component/tree/TestListeners.java
index 391ef02e3c..49610ff293 100644
--- a/tests/server-side/com/vaadin/tests/server/component/tree/TestListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/tree/TestListeners.java
@@ -1,135 +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<Object> rootIds = new ArrayList<Object>(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<Object> rootIds = new ArrayList<Object>(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++;
-
- }
-}
+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<Object> rootIds = new ArrayList<Object>(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<Object> rootIds = new ArrayList<Object>(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/server-side/com/vaadin/tests/server/component/tree/TreeListeners.java b/tests/server-side/com/vaadin/tests/server/component/tree/TreeListeners.java
index 8ba2e1de4d..e14ebe739d 100644
--- a/tests/server-side/com/vaadin/tests/server/component/tree/TreeListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/tree/TreeListeners.java
@@ -1,27 +1,27 @@
-package com.vaadin.tests.server.component.tree;
-
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-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 TreeListeners extends AbstractListenerMethodsTest {
- public void testExpandListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Tree.class, ExpandEvent.class,
- ExpandListener.class);
- }
-
- public void testItemClickListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Tree.class, ItemClickEvent.class,
- ItemClickListener.class);
- }
-
- public void testCollapseListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Tree.class, CollapseEvent.class,
- CollapseListener.class);
- }
+package com.vaadin.tests.server.component.tree;
+
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+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 TreeListeners extends AbstractListenerMethodsTest {
+ public void testExpandListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Tree.class, ExpandEvent.class,
+ ExpandListener.class);
+ }
+
+ public void testItemClickListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Tree.class, ItemClickEvent.class,
+ ItemClickListener.class);
+ }
+
+ public void testCollapseListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Tree.class, CollapseEvent.class,
+ CollapseListener.class);
+ }
} \ No newline at end of file
diff --git a/tests/server-side/com/vaadin/tests/server/component/upload/UploadListeners.java b/tests/server-side/com/vaadin/tests/server/component/upload/UploadListeners.java
index ea5fa94326..c9ce0ac0a2 100644
--- a/tests/server-side/com/vaadin/tests/server/component/upload/UploadListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/upload/UploadListeners.java
@@ -1,41 +1,41 @@
-package com.vaadin.tests.server.component.upload;
-
-import com.vaadin.terminal.StreamVariable.StreamingProgressEvent;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Upload.FailedEvent;
-import com.vaadin.ui.Upload.FailedListener;
-import com.vaadin.ui.Upload.FinishedEvent;
-import com.vaadin.ui.Upload.FinishedListener;
-import com.vaadin.ui.Upload.ProgressListener;
-import com.vaadin.ui.Upload.StartedEvent;
-import com.vaadin.ui.Upload.StartedListener;
-import com.vaadin.ui.Upload.SucceededEvent;
-import com.vaadin.ui.Upload.SucceededListener;
-
-public class UploadListeners extends AbstractListenerMethodsTest {
- public void testProgressListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Upload.class, StreamingProgressEvent.class,
- ProgressListener.class);
- }
-
- public void testSucceededListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Upload.class, SucceededEvent.class,
- SucceededListener.class);
- }
-
- public void testStartedListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Upload.class, StartedEvent.class,
- StartedListener.class);
- }
-
- public void testFailedListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Upload.class, FailedEvent.class,
- FailedListener.class);
- }
-
- public void testFinishedListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Upload.class, FinishedEvent.class,
- FinishedListener.class);
- }
-}
+package com.vaadin.tests.server.component.upload;
+
+import com.vaadin.terminal.StreamVariable.StreamingProgressEvent;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.FailedEvent;
+import com.vaadin.ui.Upload.FailedListener;
+import com.vaadin.ui.Upload.FinishedEvent;
+import com.vaadin.ui.Upload.FinishedListener;
+import com.vaadin.ui.Upload.ProgressListener;
+import com.vaadin.ui.Upload.StartedEvent;
+import com.vaadin.ui.Upload.StartedListener;
+import com.vaadin.ui.Upload.SucceededEvent;
+import com.vaadin.ui.Upload.SucceededListener;
+
+public class UploadListeners extends AbstractListenerMethodsTest {
+ public void testProgressListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Upload.class, StreamingProgressEvent.class,
+ ProgressListener.class);
+ }
+
+ public void testSucceededListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Upload.class, SucceededEvent.class,
+ SucceededListener.class);
+ }
+
+ public void testStartedListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Upload.class, StartedEvent.class,
+ StartedListener.class);
+ }
+
+ public void testFailedListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Upload.class, FailedEvent.class,
+ FailedListener.class);
+ }
+
+ public void testFinishedListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Upload.class, FinishedEvent.class,
+ FinishedListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java b/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java
index fe400e55b9..70fb68b9ec 100644
--- a/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/urifragmentutility/UriFragmentUtilityListeners.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.server.component.urifragmentutility;
-
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-import com.vaadin.ui.UriFragmentUtility;
-import com.vaadin.ui.UriFragmentUtility.FragmentChangedEvent;
-import com.vaadin.ui.UriFragmentUtility.FragmentChangedListener;
-
-public class UriFragmentUtilityListeners extends AbstractListenerMethodsTest {
- public void testFragmentChangedListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(UriFragmentUtility.class,
- FragmentChangedEvent.class, FragmentChangedListener.class);
- }
-}
+package com.vaadin.tests.server.component.urifragmentutility;
+
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+import com.vaadin.ui.UriFragmentUtility;
+import com.vaadin.ui.UriFragmentUtility.FragmentChangedEvent;
+import com.vaadin.ui.UriFragmentUtility.FragmentChangedListener;
+
+public class UriFragmentUtilityListeners extends AbstractListenerMethodsTest {
+ public void testFragmentChangedListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(UriFragmentUtility.class,
+ FragmentChangedEvent.class, FragmentChangedListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
index afc050b981..50de91e2af 100644
--- a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
+++ b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java
@@ -1,83 +1,83 @@
-package com.vaadin.tests.server.component.window;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Window;
-
-public class AddRemoveSubWindow {
-
- public class TestApp extends Application {
-
- @Override
- public void init() {
- Window w = new Window("Main window");
- setMainWindow(w);
- }
- }
-
- @Test
- public void addSubWindow() {
- TestApp app = new TestApp();
- app.init();
- Window subWindow = new Window("Sub window");
- Window mainWindow = app.getMainWindow();
-
- mainWindow.addWindow(subWindow);
- // Added to main window so the parent of the sub window should be the
- // main window
- assertEquals(subWindow.getParent(), mainWindow);
-
- try {
- mainWindow.addWindow(subWindow);
- assertTrue("Window.addWindow did not throw the expected exception",
- false);
- } catch (IllegalArgumentException e) {
- // Should throw an exception as it has already been added to the
- // main window
- }
-
- // Try to add the same sub window to another window
- try {
- Window w = new Window();
- w.addWindow(subWindow);
- assertTrue("Window.addWindow did not throw the expected exception",
- false);
- } catch (IllegalArgumentException e) {
- // Should throw an exception as it has already been added to the
- // main window
- }
-
- }
-
- @Test
- public void removeSubWindow() {
- TestApp app = new TestApp();
- app.init();
- Window subWindow = new Window("Sub window");
- Window mainWindow = app.getMainWindow();
- mainWindow.addWindow(subWindow);
-
- // Added to main window so the parent of the sub window should be the
- // main window
- assertEquals(subWindow.getParent(), mainWindow);
-
- // Remove from the wrong window, should result in an exception
- boolean removed = subWindow.removeWindow(subWindow);
- assertFalse("Window was removed even though it should not have been",
- removed);
-
- // Parent should still be set
- assertEquals(subWindow.getParent(), mainWindow);
-
- // Remove from the main window and assert it has been removed
- removed = mainWindow.removeWindow(subWindow);
- assertTrue("Window was not removed correctly", removed);
- assertNull(subWindow.getParent());
- }
-}
+package com.vaadin.tests.server.component.window;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Window;
+
+public class AddRemoveSubWindow {
+
+ public class TestApp extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window("Main window");
+ setMainWindow(w);
+ }
+ }
+
+ @Test
+ public void addSubWindow() {
+ TestApp app = new TestApp();
+ app.init();
+ Window subWindow = new Window("Sub window");
+ Window mainWindow = app.getMainWindow();
+
+ mainWindow.addWindow(subWindow);
+ // Added to main window so the parent of the sub window should be the
+ // main window
+ assertEquals(subWindow.getParent(), mainWindow);
+
+ try {
+ mainWindow.addWindow(subWindow);
+ assertTrue("Window.addWindow did not throw the expected exception",
+ false);
+ } catch (IllegalArgumentException e) {
+ // Should throw an exception as it has already been added to the
+ // main window
+ }
+
+ // Try to add the same sub window to another window
+ try {
+ Window w = new Window();
+ w.addWindow(subWindow);
+ assertTrue("Window.addWindow did not throw the expected exception",
+ false);
+ } catch (IllegalArgumentException e) {
+ // Should throw an exception as it has already been added to the
+ // main window
+ }
+
+ }
+
+ @Test
+ public void removeSubWindow() {
+ TestApp app = new TestApp();
+ app.init();
+ Window subWindow = new Window("Sub window");
+ Window mainWindow = app.getMainWindow();
+ mainWindow.addWindow(subWindow);
+
+ // Added to main window so the parent of the sub window should be the
+ // main window
+ assertEquals(subWindow.getParent(), mainWindow);
+
+ // Remove from the wrong window, should result in an exception
+ boolean removed = subWindow.removeWindow(subWindow);
+ assertFalse("Window was removed even though it should not have been",
+ removed);
+
+ // Parent should still be set
+ assertEquals(subWindow.getParent(), mainWindow);
+
+ // Remove from the main window and assert it has been removed
+ removed = mainWindow.removeWindow(subWindow);
+ assertTrue("Window was not removed correctly", removed);
+ assertNull(subWindow.getParent());
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java
index 8daee1ba65..5fabe40bb7 100644
--- a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java
+++ b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java
@@ -1,179 +1,179 @@
-package com.vaadin.tests.server.component.window;
-
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-import org.junit.Test;
-
-public class AttachDetachWindow {
-
- private Application testApp = new Application() {
- @Override
- public void init() {
- }
- };
-
- private class TestWindow extends Window {
- boolean windowAttachCalled = false;
- boolean contentAttachCalled = false;
- boolean childAttachCalled = false;
- boolean windowDetachCalled = false;
- boolean contentDetachCalled = false;
- boolean childDetachCalled = false;
-
- TestWindow() {
- setContent(new VerticalLayout() {
- @Override
- public void attach() {
- super.attach();
- contentAttachCalled = true;
- }
-
- @Override
- public void detach() {
- super.detach();
- contentDetachCalled = true;
- }
- });
- addComponent(new Label() {
- @Override
- public void attach() {
- super.attach();
- childAttachCalled = true;
- }
-
- @Override
- public void detach() {
- super.detach();
- childDetachCalled = true;
- }
- });
- }
-
- Component getChild() {
- return getComponentIterator().next();
- }
-
- @Override
- public void attach() {
- super.attach();
- windowAttachCalled = true;
- }
-
- @Override
- public void detach() {
- super.detach();
- windowDetachCalled = true;
- }
- }
-
- TestWindow main = new TestWindow();
- TestWindow sub = new TestWindow();
-
- @Test
- public void addSubWindowBeforeAttachingMainWindow() {
- assertUnattached(main);
- assertUnattached(sub);
-
- main.addWindow(sub);
- assertUnattached(main);
- assertUnattached(sub);
-
- // attaching main should recurse to sub
- testApp.setMainWindow(main);
- assertAttached(main);
- assertAttached(sub);
- }
-
- @Test
- public void addSubWindowAfterAttachingMainWindow() {
- assertUnattached(main);
- assertUnattached(sub);
-
- testApp.setMainWindow(main);
- assertAttached(main);
- assertUnattached(sub);
-
- // main is already attached, so attach should be called for sub
- main.addWindow(sub);
- assertAttached(main);
- assertAttached(sub);
- }
-
- @Test
- public void removeSubWindowBeforeDetachingMainWindow() {
- testApp.addWindow(main);
- main.addWindow(sub);
-
- // sub should be detached when removing from attached main
- main.removeWindow(sub);
- assertAttached(main);
- assertDetached(sub);
-
- // main detach should recurse to sub
- testApp.removeWindow(main);
- assertDetached(main);
- assertDetached(sub);
- }
-
- @Test
- public void removeSubWindowAfterDetachingMainWindow() {
- testApp.addWindow(main);
- main.addWindow(sub);
-
- // main detach should recurse to sub
- testApp.removeWindow(main);
- assertDetached(main);
- assertDetached(sub);
-
- main.removeWindow(sub);
- assertDetached(main);
- assertDetached(sub);
- }
-
- /**
- * Asserts that win and its children are attached to testApp and their
- * attach() methods have been called.
- */
- private void assertAttached(TestWindow win) {
- assertTrue("window attach not called", win.windowAttachCalled);
- assertTrue("window content attach not called", win.contentAttachCalled);
- assertTrue("window child attach not called", win.childAttachCalled);
-
- assertSame("window not attached", win.getApplication(), testApp);
- assertSame("window content not attached", win.getContent()
- .getApplication(), testApp);
- assertSame("window children not attached", win.getChild()
- .getApplication(), testApp);
- }
-
- /**
- * Asserts that win and its children are not attached.
- */
- private void assertUnattached(TestWindow win) {
- assertSame("window not detached", win.getApplication(), null);
- assertSame("window content not detached", win.getContent()
- .getApplication(), null);
- assertSame("window children not detached", win.getChild()
- .getApplication(), null);
- }
-
- /**
- * Asserts that win and its children are unattached and their detach()
- * methods have been been called.
- *
- * @param win
- */
- private void assertDetached(TestWindow win) {
- assertUnattached(win);
- assertTrue("window detach not called", win.windowDetachCalled);
- assertTrue("window content detach not called", win.contentDetachCalled);
- assertTrue("window child detach not called", win.childDetachCalled);
- }
-}
+package com.vaadin.tests.server.component.window;
+
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+import org.junit.Test;
+
+public class AttachDetachWindow {
+
+ private Application testApp = new Application() {
+ @Override
+ public void init() {
+ }
+ };
+
+ private class TestWindow extends Window {
+ boolean windowAttachCalled = false;
+ boolean contentAttachCalled = false;
+ boolean childAttachCalled = false;
+ boolean windowDetachCalled = false;
+ boolean contentDetachCalled = false;
+ boolean childDetachCalled = false;
+
+ TestWindow() {
+ setContent(new VerticalLayout() {
+ @Override
+ public void attach() {
+ super.attach();
+ contentAttachCalled = true;
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ contentDetachCalled = true;
+ }
+ });
+ addComponent(new Label() {
+ @Override
+ public void attach() {
+ super.attach();
+ childAttachCalled = true;
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ childDetachCalled = true;
+ }
+ });
+ }
+
+ Component getChild() {
+ return getComponentIterator().next();
+ }
+
+ @Override
+ public void attach() {
+ super.attach();
+ windowAttachCalled = true;
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ windowDetachCalled = true;
+ }
+ }
+
+ TestWindow main = new TestWindow();
+ TestWindow sub = new TestWindow();
+
+ @Test
+ public void addSubWindowBeforeAttachingMainWindow() {
+ assertUnattached(main);
+ assertUnattached(sub);
+
+ main.addWindow(sub);
+ assertUnattached(main);
+ assertUnattached(sub);
+
+ // attaching main should recurse to sub
+ testApp.setMainWindow(main);
+ assertAttached(main);
+ assertAttached(sub);
+ }
+
+ @Test
+ public void addSubWindowAfterAttachingMainWindow() {
+ assertUnattached(main);
+ assertUnattached(sub);
+
+ testApp.setMainWindow(main);
+ assertAttached(main);
+ assertUnattached(sub);
+
+ // main is already attached, so attach should be called for sub
+ main.addWindow(sub);
+ assertAttached(main);
+ assertAttached(sub);
+ }
+
+ @Test
+ public void removeSubWindowBeforeDetachingMainWindow() {
+ testApp.addWindow(main);
+ main.addWindow(sub);
+
+ // sub should be detached when removing from attached main
+ main.removeWindow(sub);
+ assertAttached(main);
+ assertDetached(sub);
+
+ // main detach should recurse to sub
+ testApp.removeWindow(main);
+ assertDetached(main);
+ assertDetached(sub);
+ }
+
+ @Test
+ public void removeSubWindowAfterDetachingMainWindow() {
+ testApp.addWindow(main);
+ main.addWindow(sub);
+
+ // main detach should recurse to sub
+ testApp.removeWindow(main);
+ assertDetached(main);
+ assertDetached(sub);
+
+ main.removeWindow(sub);
+ assertDetached(main);
+ assertDetached(sub);
+ }
+
+ /**
+ * Asserts that win and its children are attached to testApp and their
+ * attach() methods have been called.
+ */
+ private void assertAttached(TestWindow win) {
+ assertTrue("window attach not called", win.windowAttachCalled);
+ assertTrue("window content attach not called", win.contentAttachCalled);
+ assertTrue("window child attach not called", win.childAttachCalled);
+
+ assertSame("window not attached", win.getApplication(), testApp);
+ assertSame("window content not attached", win.getContent()
+ .getApplication(), testApp);
+ assertSame("window children not attached", win.getChild()
+ .getApplication(), testApp);
+ }
+
+ /**
+ * Asserts that win and its children are not attached.
+ */
+ private void assertUnattached(TestWindow win) {
+ assertSame("window not detached", win.getApplication(), null);
+ assertSame("window content not detached", win.getContent()
+ .getApplication(), null);
+ assertSame("window children not detached", win.getChild()
+ .getApplication(), null);
+ }
+
+ /**
+ * Asserts that win and its children are unattached and their detach()
+ * methods have been been called.
+ *
+ * @param win
+ */
+ private void assertDetached(TestWindow win) {
+ assertUnattached(win);
+ assertTrue("window detach not called", win.windowDetachCalled);
+ assertTrue("window content detach not called", win.contentDetachCalled);
+ assertTrue("window child detach not called", win.childDetachCalled);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/window/WindowListeners.java b/tests/server-side/com/vaadin/tests/server/component/window/WindowListeners.java
index b8d9579dae..c33871cbd8 100644
--- a/tests/server-side/com/vaadin/tests/server/component/window/WindowListeners.java
+++ b/tests/server-side/com/vaadin/tests/server/component/window/WindowListeners.java
@@ -1,34 +1,34 @@
-package com.vaadin.tests.server.component.window;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
-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 WindowListeners extends AbstractListenerMethodsTest {
- public void testFocusListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Window.class, FocusEvent.class,
- FocusListener.class);
- }
-
- public void testBlurListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Window.class, BlurEvent.class,
- BlurListener.class);
- }
-
- public void testResizeListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Window.class, ResizeEvent.class,
- ResizeListener.class);
- }
-
- public void testCloseListenerAddGetRemove() throws Exception {
- testListenerAddGetRemove(Window.class, CloseEvent.class,
- CloseListener.class);
- }
-}
+package com.vaadin.tests.server.component.window;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTest;
+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 WindowListeners extends AbstractListenerMethodsTest {
+ public void testFocusListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Window.class, FocusEvent.class,
+ FocusListener.class);
+ }
+
+ public void testBlurListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Window.class, BlurEvent.class,
+ BlurListener.class);
+ }
+
+ public void testResizeListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Window.class, ResizeEvent.class,
+ ResizeListener.class);
+ }
+
+ public void testCloseListenerAddGetRemove() throws Exception {
+ testListenerAddGetRemove(Window.class, CloseEvent.class,
+ CloseListener.class);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
index 3aebd5bf9d..fcea309e84 100644
--- a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java
@@ -1,169 +1,169 @@
-package com.vaadin.tests.server.components;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Property.ValueChangeNotifier;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.ui.AbstractField;
-
-/**
- * Base class for tests for checking that value change listeners for fields are
- * not called exactly once when they should be, and not at other times.
- *
- * Does not check all cases (e.g. properties that do not implement
- * {@link ValueChangeNotifier}).
- *
- * Subclasses should implement {@link #setValue()} and call
- * <code>super.setValue(AbstractField)</code>. Also, subclasses should typically
- * override {@link #setValue(AbstractField)} to set the field value via
- * <code>changeVariables()</code>.
- */
-public abstract class AbstractTestFieldValueChange extends TestCase {
-
- private AbstractField field;
- private ValueChangeListener listener;
-
- protected void setUp(AbstractField field) throws Exception {
- this.field = field;
- listener = EasyMock.createStrictMock(ValueChangeListener.class);
-
- }
-
- protected ValueChangeListener getListener() {
- return listener;
- }
-
- /**
- * Test that listeners are not called when they have been unregistered.
- */
- public void testRemoveListener() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(true);
- getField().setReadThrough(true);
-
- // Expectations and start test
- listener.valueChange(EasyMock.isA(ValueChangeEvent.class));
- EasyMock.replay(listener);
-
- // Add listener and set the value -> should end up in listener once
- getField().addListener(listener);
- setValue(getField());
-
- // Ensure listener was called once
- EasyMock.verify(listener);
-
- // Remove the listener and set the value -> should not end up in
- // listener
- getField().removeListener(listener);
- setValue(getField());
-
- // Ensure listener still has been called only once
- EasyMock.verify(listener);
- }
-
- /**
- * Common unbuffered case: both writeThrough (auto-commit) and readThrough
- * are on. Calling commit() should not cause notifications.
- *
- * Using the readThrough mode allows changes made to the property value to
- * be seen in some cases also when there is no notification of value change
- * from the property.
- *
- * Field value change notifications closely mirror value changes of the data
- * source behind the field.
- */
- public void testWriteThroughReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(true);
- getField().setReadThrough(true);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- /**
- * Fully buffered use where the data source is neither read nor modified
- * during editing, and is updated at commit().
- *
- * Field value change notifications reflect the buffered value in the field,
- * not the original data source value changes.
- */
- public void testNoWriteThroughNoReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(false);
- getField().setReadThrough(false);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- /**
- * Less common partly buffered case: writeThrough (auto-commit) is on and
- * readThrough is off. Calling commit() should not cause notifications.
- *
- * Without readThrough activated, changes to the data source that do not
- * cause notifications are not reflected by the field value.
- *
- * Field value change notifications correspond to changes made to the data
- * source value through the text field or the (notifying) property.
- */
- public void testWriteThroughNoReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(true);
- getField().setReadThrough(false);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- /**
- * Partly buffered use where the data source is read but not nor modified
- * during editing, and is updated at commit().
- *
- * When used like this, a field is updated from the data source if necessary
- * when its value is requested and the property value has changed but the
- * field has not been modified in its buffer.
- *
- * Field value change notifications reflect the buffered value in the field,
- * not the original data source value changes.
- */
- public void testNoWriteThroughReadThrough() {
- getField().setPropertyDataSource(new ObjectProperty<String>(""));
- getField().setWriteThrough(false);
- getField().setReadThrough(true);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- protected void expectValueChangeFromSetValueNotCommit() {
- // Expectations and start test
- listener.valueChange(EasyMock.isA(ValueChangeEvent.class));
- EasyMock.replay(listener);
-
- // Add listener and set the value -> should end up in listener once
- getField().addListener(listener);
- setValue(getField());
-
- // Ensure listener was called once
- EasyMock.verify(listener);
-
- // commit
- getField().commit();
-
- // Ensure listener was not called again
- EasyMock.verify(listener);
- }
-
- protected AbstractField getField() {
- return field;
- }
-
- /**
- * Override in subclasses to set value with changeVariables().
- */
- protected void setValue(AbstractField field) {
- field.setValue("newValue");
- }
-
-}
+package com.vaadin.tests.server.components;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Property.ValueChangeNotifier;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.ui.AbstractField;
+
+/**
+ * Base class for tests for checking that value change listeners for fields are
+ * not called exactly once when they should be, and not at other times.
+ *
+ * Does not check all cases (e.g. properties that do not implement
+ * {@link ValueChangeNotifier}).
+ *
+ * Subclasses should implement {@link #setValue()} and call
+ * <code>super.setValue(AbstractField)</code>. Also, subclasses should typically
+ * override {@link #setValue(AbstractField)} to set the field value via
+ * <code>changeVariables()</code>.
+ */
+public abstract class AbstractTestFieldValueChange extends TestCase {
+
+ private AbstractField field;
+ private ValueChangeListener listener;
+
+ protected void setUp(AbstractField field) throws Exception {
+ this.field = field;
+ listener = EasyMock.createStrictMock(ValueChangeListener.class);
+
+ }
+
+ protected ValueChangeListener getListener() {
+ return listener;
+ }
+
+ /**
+ * Test that listeners are not called when they have been unregistered.
+ */
+ public void testRemoveListener() {
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
+ getField().setWriteThrough(true);
+ getField().setReadThrough(true);
+
+ // Expectations and start test
+ listener.valueChange(EasyMock.isA(ValueChangeEvent.class));
+ EasyMock.replay(listener);
+
+ // Add listener and set the value -> should end up in listener once
+ getField().addListener(listener);
+ setValue(getField());
+
+ // Ensure listener was called once
+ EasyMock.verify(listener);
+
+ // Remove the listener and set the value -> should not end up in
+ // listener
+ getField().removeListener(listener);
+ setValue(getField());
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(listener);
+ }
+
+ /**
+ * Common unbuffered case: both writeThrough (auto-commit) and readThrough
+ * are on. Calling commit() should not cause notifications.
+ *
+ * Using the readThrough mode allows changes made to the property value to
+ * be seen in some cases also when there is no notification of value change
+ * from the property.
+ *
+ * Field value change notifications closely mirror value changes of the data
+ * source behind the field.
+ */
+ public void testWriteThroughReadThrough() {
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
+ getField().setWriteThrough(true);
+ getField().setReadThrough(true);
+
+ expectValueChangeFromSetValueNotCommit();
+ }
+
+ /**
+ * Fully buffered use where the data source is neither read nor modified
+ * during editing, and is updated at commit().
+ *
+ * Field value change notifications reflect the buffered value in the field,
+ * not the original data source value changes.
+ */
+ public void testNoWriteThroughNoReadThrough() {
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
+ getField().setWriteThrough(false);
+ getField().setReadThrough(false);
+
+ expectValueChangeFromSetValueNotCommit();
+ }
+
+ /**
+ * Less common partly buffered case: writeThrough (auto-commit) is on and
+ * readThrough is off. Calling commit() should not cause notifications.
+ *
+ * Without readThrough activated, changes to the data source that do not
+ * cause notifications are not reflected by the field value.
+ *
+ * Field value change notifications correspond to changes made to the data
+ * source value through the text field or the (notifying) property.
+ */
+ public void testWriteThroughNoReadThrough() {
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
+ getField().setWriteThrough(true);
+ getField().setReadThrough(false);
+
+ expectValueChangeFromSetValueNotCommit();
+ }
+
+ /**
+ * Partly buffered use where the data source is read but not nor modified
+ * during editing, and is updated at commit().
+ *
+ * When used like this, a field is updated from the data source if necessary
+ * when its value is requested and the property value has changed but the
+ * field has not been modified in its buffer.
+ *
+ * Field value change notifications reflect the buffered value in the field,
+ * not the original data source value changes.
+ */
+ public void testNoWriteThroughReadThrough() {
+ getField().setPropertyDataSource(new ObjectProperty<String>(""));
+ getField().setWriteThrough(false);
+ getField().setReadThrough(true);
+
+ expectValueChangeFromSetValueNotCommit();
+ }
+
+ protected void expectValueChangeFromSetValueNotCommit() {
+ // Expectations and start test
+ listener.valueChange(EasyMock.isA(ValueChangeEvent.class));
+ EasyMock.replay(listener);
+
+ // Add listener and set the value -> should end up in listener once
+ getField().addListener(listener);
+ setValue(getField());
+
+ // Ensure listener was called once
+ EasyMock.verify(listener);
+
+ // commit
+ getField().commit();
+
+ // Ensure listener was not called again
+ EasyMock.verify(listener);
+ }
+
+ protected AbstractField getField() {
+ return field;
+ }
+
+ /**
+ * Override in subclasses to set value with changeVariables().
+ */
+ protected void setValue(AbstractField field) {
+ field.setValue("newValue");
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java
index cb73199fb8..3fbe1406f2 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestComboBoxValueChange.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.server.components;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.ComboBox;
-
-/**
- * Check that the value change listener for a combo box is triggered exactly
- * once when setting the value, at the correct time.
- *
- * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
- */
-public class TestComboBoxValueChange extends AbstractTestFieldValueChange {
- @Override
- protected void setUp() throws Exception {
- ComboBox combo = new ComboBox();
- combo.addItem("myvalue");
- super.setUp(combo);
- }
-
- @Override
- protected void setValue(AbstractField field) {
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("selected", new String[] { "myvalue" });
- field.changeVariables(field, variables);
- }
-
-}
+package com.vaadin.tests.server.components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.ComboBox;
+
+/**
+ * Check that the value change listener for a combo box is triggered exactly
+ * once when setting the value, at the correct time.
+ *
+ * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
+ */
+public class TestComboBoxValueChange extends AbstractTestFieldValueChange {
+ @Override
+ protected void setUp() throws Exception {
+ ComboBox combo = new ComboBox();
+ combo.addItem("myvalue");
+ super.setUp(combo);
+ }
+
+ @Override
+ protected void setValue(AbstractField field) {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("selected", new String[] { "myvalue" });
+ field.changeVariables(field, variables);
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
index 1144caf805..2c911d5f3f 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java
@@ -1,180 +1,180 @@
-package com.vaadin.tests.server.components;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.Assert;
-
-import org.easymock.EasyMock;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.TextField;
-
-/**
- * Check that the value change listener for a text field is triggered exactly
- * once when setting the value, at the correct time.
- *
- * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
- */
-public class TestTextFieldValueChange extends AbstractTestFieldValueChange {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp(new TextField());
- }
-
- /**
- * Case where the text field only uses its internal buffer, no external
- * property data source.
- */
- public void testNoDataSource() {
- getField().setPropertyDataSource(null);
-
- expectValueChangeFromSetValueNotCommit();
- }
-
- @Override
- protected void setValue(AbstractField field) {
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("text", "newValue");
- field.changeVariables(field, variables);
- }
-
- /**
- * Test that field propagates value change events originating from property,
- * but don't fire value change events twice if value has only changed once.
- *
- *
- * TODO make test field type agnostic (eg. combobox)
- */
- public void testValueChangeEventPropagationWithReadThrough() {
- ObjectProperty<String> property = new ObjectProperty<String>("");
- getField().setPropertyDataSource(property);
-
- // defaults, buffering off
- getField().setWriteThrough(true);
- getField().setReadThrough(true);
-
- // Expectations and start test
- getListener().valueChange(EasyMock.isA(ValueChangeEvent.class));
- EasyMock.replay(getListener());
-
- // Add listener and set the value -> should end up in listener once
- getField().addListener(getListener());
-
- property.setValue("Foo");
-
- // Ensure listener was called once
- EasyMock.verify(getListener());
-
- // get value should not fire value change again
- Object value = getField().getValue();
- Assert.assertEquals("Foo", value);
-
- // Ensure listener still has been called only once
- EasyMock.verify(getListener());
- }
-
- /**
- * If read through is on and value has been modified, but not committed, the
- * value should not propagate similar to
- * {@link #testValueChangeEventPropagationWithReadThrough()}
- *
- * TODO make test field type agnostic (eg. combobox)
- */
- public void testValueChangePropagationWithReadThroughWithModifiedValue() {
- final String initialValue = "initial";
- ObjectProperty<String> property = new ObjectProperty<String>(
- initialValue);
- getField().setPropertyDataSource(property);
-
- // write buffering on, read buffering off
- getField().setWriteThrough(false);
- getField().setReadThrough(true);
-
- // Expect no value changes calls to listener
- EasyMock.replay(getListener());
-
- // first set the value (note, write through false -> not forwarded to
- // property)
- setValue(getField());
-
- Assert.assertTrue(getField().isModified());
-
- // Add listener and set the value -> should end up in listener once
- getField().addListener(getListener());
-
- // modify property value, should not fire value change in field as the
- // field has uncommitted value (aka isModified() == true)
- property.setValue("Foo");
-
- // Ensure listener was called once
- EasyMock.verify(getListener());
-
- // get value should not fire value change again
- Object value = getField().getValue();
- // Ensure listener still has been called only once
- EasyMock.verify(getListener());
-
- // field value should be different from the original value and current
- // proeprty value
- boolean isValueEqualToInitial = value.equals(initialValue);
- Assert.assertFalse(isValueEqualToInitial);
- boolean isValueEqualToPropertyValue = value.equals(property.getValue());
- Assert.assertFalse(isValueEqualToPropertyValue);
-
- // Ensure listener has not been called
- EasyMock.verify(getListener());
-
- }
-
- /**
- * Value change events from property should not propagate if read through is
- * false. Execpt when the property is being set.
- *
- * TODO make test field type agnostic (eg. combobox)
- */
- public void testValueChangePropagationWithReadThroughOff() {
- final String initialValue = "initial";
- ObjectProperty<String> property = new ObjectProperty<String>(
- initialValue);
-
- // set buffering
- getField().setWriteThrough(false);
- getField().setReadThrough(false);
-
- // Value change should only happen once, when setting the property,
- // further changes via property should not cause value change listener
- // in field to be notified
- getListener().valueChange(EasyMock.isA(ValueChangeEvent.class));
- EasyMock.replay(getListener());
-
- getField().addListener(getListener());
- getField().setPropertyDataSource(property);
-
- // Ensure listener was called once
- EasyMock.verify(getListener());
-
- // modify property value, should not fire value change in field as the
- // read buffering is on (read through == false)
- property.setValue("Foo");
-
- // Ensure listener still has been called only once
- EasyMock.verify(getListener());
-
- // get value should not fire value change again
- Object value = getField().getValue();
-
- // field value should be different from the original value and current
- // proeprty value
- boolean isValueEqualToInitial = value.equals(initialValue);
- Assert.assertTrue(isValueEqualToInitial);
-
- // Ensure listener still has been called only once
- EasyMock.verify(getListener());
-
- }
-
-}
+package com.vaadin.tests.server.components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.TextField;
+
+/**
+ * Check that the value change listener for a text field is triggered exactly
+ * once when setting the value, at the correct time.
+ *
+ * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
+ */
+public class TestTextFieldValueChange extends AbstractTestFieldValueChange {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp(new TextField());
+ }
+
+ /**
+ * Case where the text field only uses its internal buffer, no external
+ * property data source.
+ */
+ public void testNoDataSource() {
+ getField().setPropertyDataSource(null);
+
+ expectValueChangeFromSetValueNotCommit();
+ }
+
+ @Override
+ protected void setValue(AbstractField field) {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("text", "newValue");
+ field.changeVariables(field, variables);
+ }
+
+ /**
+ * Test that field propagates value change events originating from property,
+ * but don't fire value change events twice if value has only changed once.
+ *
+ *
+ * TODO make test field type agnostic (eg. combobox)
+ */
+ public void testValueChangeEventPropagationWithReadThrough() {
+ ObjectProperty<String> property = new ObjectProperty<String>("");
+ getField().setPropertyDataSource(property);
+
+ // defaults, buffering off
+ getField().setWriteThrough(true);
+ getField().setReadThrough(true);
+
+ // Expectations and start test
+ getListener().valueChange(EasyMock.isA(ValueChangeEvent.class));
+ EasyMock.replay(getListener());
+
+ // Add listener and set the value -> should end up in listener once
+ getField().addListener(getListener());
+
+ property.setValue("Foo");
+
+ // Ensure listener was called once
+ EasyMock.verify(getListener());
+
+ // get value should not fire value change again
+ Object value = getField().getValue();
+ Assert.assertEquals("Foo", value);
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(getListener());
+ }
+
+ /**
+ * If read through is on and value has been modified, but not committed, the
+ * value should not propagate similar to
+ * {@link #testValueChangeEventPropagationWithReadThrough()}
+ *
+ * TODO make test field type agnostic (eg. combobox)
+ */
+ public void testValueChangePropagationWithReadThroughWithModifiedValue() {
+ final String initialValue = "initial";
+ ObjectProperty<String> property = new ObjectProperty<String>(
+ initialValue);
+ getField().setPropertyDataSource(property);
+
+ // write buffering on, read buffering off
+ getField().setWriteThrough(false);
+ getField().setReadThrough(true);
+
+ // Expect no value changes calls to listener
+ EasyMock.replay(getListener());
+
+ // first set the value (note, write through false -> not forwarded to
+ // property)
+ setValue(getField());
+
+ Assert.assertTrue(getField().isModified());
+
+ // Add listener and set the value -> should end up in listener once
+ getField().addListener(getListener());
+
+ // modify property value, should not fire value change in field as the
+ // field has uncommitted value (aka isModified() == true)
+ property.setValue("Foo");
+
+ // Ensure listener was called once
+ EasyMock.verify(getListener());
+
+ // get value should not fire value change again
+ Object value = getField().getValue();
+ // Ensure listener still has been called only once
+ EasyMock.verify(getListener());
+
+ // field value should be different from the original value and current
+ // proeprty value
+ boolean isValueEqualToInitial = value.equals(initialValue);
+ Assert.assertFalse(isValueEqualToInitial);
+ boolean isValueEqualToPropertyValue = value.equals(property.getValue());
+ Assert.assertFalse(isValueEqualToPropertyValue);
+
+ // Ensure listener has not been called
+ EasyMock.verify(getListener());
+
+ }
+
+ /**
+ * Value change events from property should not propagate if read through is
+ * false. Execpt when the property is being set.
+ *
+ * TODO make test field type agnostic (eg. combobox)
+ */
+ public void testValueChangePropagationWithReadThroughOff() {
+ final String initialValue = "initial";
+ ObjectProperty<String> property = new ObjectProperty<String>(
+ initialValue);
+
+ // set buffering
+ getField().setWriteThrough(false);
+ getField().setReadThrough(false);
+
+ // Value change should only happen once, when setting the property,
+ // further changes via property should not cause value change listener
+ // in field to be notified
+ getListener().valueChange(EasyMock.isA(ValueChangeEvent.class));
+ EasyMock.replay(getListener());
+
+ getField().addListener(getListener());
+ getField().setPropertyDataSource(property);
+
+ // Ensure listener was called once
+ EasyMock.verify(getListener());
+
+ // modify property value, should not fire value change in field as the
+ // read buffering is on (read through == false)
+ property.setValue("Foo");
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(getListener());
+
+ // get value should not fire value change again
+ Object value = getField().getValue();
+
+ // field value should be different from the original value and current
+ // proeprty value
+ boolean isValueEqualToInitial = value.equals(initialValue);
+ Assert.assertTrue(isValueEqualToInitial);
+
+ // Ensure listener still has been called only once
+ EasyMock.verify(getListener());
+
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/components/TestWindow.java b/tests/server-side/com/vaadin/tests/server/components/TestWindow.java
index 05604aba61..89d018c8a5 100644
--- a/tests/server-side/com/vaadin/tests/server/components/TestWindow.java
+++ b/tests/server-side/com/vaadin/tests/server/components/TestWindow.java
@@ -1,90 +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);
- }
-}
+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/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java b/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java
index 6939ce27d2..c4052c2db8 100644
--- a/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java
+++ b/tests/server-side/com/vaadin/tests/server/validation/TestReadOnlyValidation.java
@@ -1,17 +1,17 @@
-package com.vaadin.tests.server.validation;
-
-import org.junit.Test;
-
-import com.vaadin.data.validator.IntegerValidator;
-import com.vaadin.ui.TextField;
-
-public class TestReadOnlyValidation {
-
- @Test
- public void testIntegerValidation() {
- TextField field = new TextField();
- field.addValidator(new IntegerValidator("Enter a Valid Number"));
- field.setValue(Integer.valueOf(10));
- field.validate();
- }
-}
+package com.vaadin.tests.server.validation;
+
+import org.junit.Test;
+
+import com.vaadin.data.validator.IntegerValidator;
+import com.vaadin.ui.TextField;
+
+public class TestReadOnlyValidation {
+
+ @Test
+ public void testIntegerValidation() {
+ TextField field = new TextField();
+ field.addValidator(new IntegerValidator("Enter a Valid Number"));
+ field.setValue(Integer.valueOf(10));
+ field.validate();
+ }
+}
diff --git a/tests/testbench/com/vaadin/launcher/DevelopmentServerLauncher.java b/tests/testbench/com/vaadin/launcher/DevelopmentServerLauncher.java
index 2146d8472b..0fb346736e 100644
--- a/tests/testbench/com/vaadin/launcher/DevelopmentServerLauncher.java
+++ b/tests/testbench/com/vaadin/launcher/DevelopmentServerLauncher.java
@@ -1,218 +1,218 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.launcher;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.webapp.WebAppContext;
-
-import com.vaadin.launcher.util.BrowserLauncher;
-
-/**
- * Class for running Jetty servlet container within Eclipse project.
- *
- */
-public class DevelopmentServerLauncher {
-
- private static final String KEYSTORE = "src/com/vaadin/launcher/keystore";
- private final static int serverPort = 8888;
-
- /**
- * Main function for running Jetty.
- *
- * Command line Arguments are passed through to Jetty, see runServer method
- * for options.
- *
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) {
-
- // Pass-through of arguments for Jetty
- final Map<String, String> serverArgs = parseArguments(args);
-
- if (serverArgs.containsKey("shutdownPort")) {
- int port = Integer.parseInt(serverArgs.get("shutdownPort"));
- try {
- // Try to notify another instance that it's time to close
- Socket socket = new Socket((String) null, port);
- // Wait until the other instance says it has closed
- socket.getInputStream().read();
- // Then tidy up
- socket.close();
- } catch (IOException e) {
- // Ignore if port is not open
- }
- }
-
- // Start Jetty
- System.out.println("Starting Jetty servlet container.");
- String url;
- try {
- url = runServer(serverArgs, "Development Server Mode");
- // Start Browser
- if (!serverArgs.containsKey("nogui") && url != null) {
- System.out.println("Starting Web Browser.");
-
- // Open browser into application URL
- BrowserLauncher.openBrowser(url);
- }
- } catch (Exception e) {
- // NOP exception already on console by jetty
- }
- }
-
- /**
- * Run the server with specified arguments.
- *
- * @param serverArgs
- * @return
- * @throws Exception
- * @throws Exception
- */
- protected static String runServer(Map<String, String> serverArgs,
- String mode) throws Exception {
-
- // Assign default values for some arguments
- assignDefault(serverArgs, "webroot", "WebContent");
- assignDefault(serverArgs, "httpPort", "" + serverPort);
- assignDefault(serverArgs, "context", "");
-
- int port = serverPort;
- try {
- port = Integer.parseInt(serverArgs.get("httpPort"));
- } catch (NumberFormatException e) {
- // keep default value for port
- }
-
- // Add help for System.out
- System.out
- .println("-------------------------------------------------\n"
- + "Starting Vaadin in "
- + mode
- + ".\n"
- + "Running in http://localhost:"
- + serverPort
- + "\n-------------------------------------------------\n");
-
- final Server server = new Server();
-
- final Connector connector = new SelectChannelConnector();
-
- connector.setPort(port);
- if (serverArgs.containsKey("withssl")) {
- final SslSocketConnector sslConnector = new SslSocketConnector();
- sslConnector.setPort(8444);
- sslConnector.setTruststore(KEYSTORE);
- sslConnector.setTrustPassword("password");
- sslConnector.setKeystore(KEYSTORE);
- sslConnector.setKeyPassword("password");
- sslConnector.setPassword("password");
- server.setConnectors(new Connector[] { connector, sslConnector });
- } else {
- server.setConnectors(new Connector[] { connector });
- }
-
- final WebAppContext webappcontext = new WebAppContext();
- String path = DevelopmentServerLauncher.class.getPackage().getName()
- .replace(".", File.separator);
- webappcontext.setDefaultsDescriptor(path + File.separator
- + "jetty-webdefault.xml");
- webappcontext.setContextPath(serverArgs.get("context"));
- webappcontext.setWar(serverArgs.get("webroot"));
- server.setHandler(webappcontext);
-
- try {
- server.start();
-
- if (serverArgs.containsKey("shutdownPort")) {
- int shutdownPort = Integer.parseInt(serverArgs
- .get("shutdownPort"));
- final ServerSocket serverSocket = new ServerSocket(
- shutdownPort, 1, InetAddress.getByName("127.0.0.1"));
- new Thread() {
- @Override
- public void run() {
- try {
- System.out
- .println("Waiting for shutdown signal on port "
- + serverSocket.getLocalPort());
- // Start waiting for a close signal
- Socket accept = serverSocket.accept();
- // First stop listening to the port
- serverSocket.close();
- // Then stop the jetty server
- server.stop();
- // Send a byte to tell the other process that it can
- // start jetty
- OutputStream outputStream = accept
- .getOutputStream();
- outputStream.write(0);
- outputStream.flush();
- // Finally close the socket
- accept.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- };
-
- }.start();
-
- }
- } catch (Exception e) {
- server.stop();
- throw e;
- }
-
- return "http://localhost:" + port + serverArgs.get("context");
- }
-
- /**
- * Assign default value for given key.
- *
- * @param map
- * @param key
- * @param value
- */
- private static void assignDefault(Map<String, String> map, String key,
- String value) {
- if (!map.containsKey(key)) {
- map.put(key, value);
- }
- }
-
- /**
- * Parse all command line arguments into a map.
- *
- * Arguments format "key=value" are put into map.
- *
- * @param args
- * @return map of arguments key value pairs.
- */
- protected static Map<String, String> parseArguments(String[] args) {
- final Map<String, String> map = new HashMap<String, String>();
- for (int i = 0; i < args.length; i++) {
- final int d = args[i].indexOf("=");
- if (d > 0 && d < args[i].length() && args[i].startsWith("--")) {
- final String name = args[i].substring(2, d);
- final String value = args[i].substring(d + 1);
- map.put(name, value);
- }
- }
- return map;
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.launcher;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+import com.vaadin.launcher.util.BrowserLauncher;
+
+/**
+ * Class for running Jetty servlet container within Eclipse project.
+ *
+ */
+public class DevelopmentServerLauncher {
+
+ private static final String KEYSTORE = "src/com/vaadin/launcher/keystore";
+ private final static int serverPort = 8888;
+
+ /**
+ * Main function for running Jetty.
+ *
+ * Command line Arguments are passed through to Jetty, see runServer method
+ * for options.
+ *
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) {
+
+ // Pass-through of arguments for Jetty
+ final Map<String, String> serverArgs = parseArguments(args);
+
+ if (serverArgs.containsKey("shutdownPort")) {
+ int port = Integer.parseInt(serverArgs.get("shutdownPort"));
+ try {
+ // Try to notify another instance that it's time to close
+ Socket socket = new Socket((String) null, port);
+ // Wait until the other instance says it has closed
+ socket.getInputStream().read();
+ // Then tidy up
+ socket.close();
+ } catch (IOException e) {
+ // Ignore if port is not open
+ }
+ }
+
+ // Start Jetty
+ System.out.println("Starting Jetty servlet container.");
+ String url;
+ try {
+ url = runServer(serverArgs, "Development Server Mode");
+ // Start Browser
+ if (!serverArgs.containsKey("nogui") && url != null) {
+ System.out.println("Starting Web Browser.");
+
+ // Open browser into application URL
+ BrowserLauncher.openBrowser(url);
+ }
+ } catch (Exception e) {
+ // NOP exception already on console by jetty
+ }
+ }
+
+ /**
+ * Run the server with specified arguments.
+ *
+ * @param serverArgs
+ * @return
+ * @throws Exception
+ * @throws Exception
+ */
+ protected static String runServer(Map<String, String> serverArgs,
+ String mode) throws Exception {
+
+ // Assign default values for some arguments
+ assignDefault(serverArgs, "webroot", "WebContent");
+ assignDefault(serverArgs, "httpPort", "" + serverPort);
+ assignDefault(serverArgs, "context", "");
+
+ int port = serverPort;
+ try {
+ port = Integer.parseInt(serverArgs.get("httpPort"));
+ } catch (NumberFormatException e) {
+ // keep default value for port
+ }
+
+ // Add help for System.out
+ System.out
+ .println("-------------------------------------------------\n"
+ + "Starting Vaadin in "
+ + mode
+ + ".\n"
+ + "Running in http://localhost:"
+ + serverPort
+ + "\n-------------------------------------------------\n");
+
+ final Server server = new Server();
+
+ final Connector connector = new SelectChannelConnector();
+
+ connector.setPort(port);
+ if (serverArgs.containsKey("withssl")) {
+ final SslSocketConnector sslConnector = new SslSocketConnector();
+ sslConnector.setPort(8444);
+ sslConnector.setTruststore(KEYSTORE);
+ sslConnector.setTrustPassword("password");
+ sslConnector.setKeystore(KEYSTORE);
+ sslConnector.setKeyPassword("password");
+ sslConnector.setPassword("password");
+ server.setConnectors(new Connector[] { connector, sslConnector });
+ } else {
+ server.setConnectors(new Connector[] { connector });
+ }
+
+ final WebAppContext webappcontext = new WebAppContext();
+ String path = DevelopmentServerLauncher.class.getPackage().getName()
+ .replace(".", File.separator);
+ webappcontext.setDefaultsDescriptor(path + File.separator
+ + "jetty-webdefault.xml");
+ webappcontext.setContextPath(serverArgs.get("context"));
+ webappcontext.setWar(serverArgs.get("webroot"));
+ server.setHandler(webappcontext);
+
+ try {
+ server.start();
+
+ if (serverArgs.containsKey("shutdownPort")) {
+ int shutdownPort = Integer.parseInt(serverArgs
+ .get("shutdownPort"));
+ final ServerSocket serverSocket = new ServerSocket(
+ shutdownPort, 1, InetAddress.getByName("127.0.0.1"));
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ System.out
+ .println("Waiting for shutdown signal on port "
+ + serverSocket.getLocalPort());
+ // Start waiting for a close signal
+ Socket accept = serverSocket.accept();
+ // First stop listening to the port
+ serverSocket.close();
+ // Then stop the jetty server
+ server.stop();
+ // Send a byte to tell the other process that it can
+ // start jetty
+ OutputStream outputStream = accept
+ .getOutputStream();
+ outputStream.write(0);
+ outputStream.flush();
+ // Finally close the socket
+ accept.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ };
+
+ }.start();
+
+ }
+ } catch (Exception e) {
+ server.stop();
+ throw e;
+ }
+
+ return "http://localhost:" + port + serverArgs.get("context");
+ }
+
+ /**
+ * Assign default value for given key.
+ *
+ * @param map
+ * @param key
+ * @param value
+ */
+ private static void assignDefault(Map<String, String> map, String key,
+ String value) {
+ if (!map.containsKey(key)) {
+ map.put(key, value);
+ }
+ }
+
+ /**
+ * Parse all command line arguments into a map.
+ *
+ * Arguments format "key=value" are put into map.
+ *
+ * @param args
+ * @return map of arguments key value pairs.
+ */
+ protected static Map<String, String> parseArguments(String[] args) {
+ final Map<String, String> map = new HashMap<String, String>();
+ for (int i = 0; i < args.length; i++) {
+ final int d = args[i].indexOf("=");
+ if (d > 0 && d < args[i].length() && args[i].startsWith("--")) {
+ final String name = args[i].substring(2, d);
+ final String value = args[i].substring(d + 1);
+ map.put(name, value);
+ }
+ }
+ return map;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
index 55692cb251..0ade893238 100644
--- a/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
+++ b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
@@ -1,127 +1,127 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.launcher.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * This class opens default browser for DemoLauncher class. Default browser is
- * detected by the operating system.
- *
- */
-public class BrowserLauncher {
-
- /**
- * Open browser on specified URL.
- *
- * @param url
- */
- public static void openBrowser(String url) {
-
- final Runtime runtime = Runtime.getRuntime();
- boolean started = false;
-
- final String os = System.getProperty("os.name", "windows")
- .toLowerCase();
-
- // Linux
- if (os.indexOf("linux") >= 0) {
- // See if the default browser is Konqueror by resolving the symlink.
- boolean isDefaultKonqueror = false;
- try {
- // Find out the location of the x-www-browser link from path.
- Process process = runtime.exec("which x-www-browser");
- BufferedInputStream ins = new BufferedInputStream(
- process.getInputStream());
- BufferedReader bufreader = new BufferedReader(
- new InputStreamReader(ins));
- String defaultLinkPath = bufreader.readLine();
- ins.close();
-
- // The path is null if the link did not exist.
- if (defaultLinkPath != null) {
- // See if the default browser is Konqueror.
- File file = new File(defaultLinkPath);
- String canonical = file.getCanonicalPath();
- if (canonical.indexOf("konqueror") != -1) {
- isDefaultKonqueror = true;
- }
- }
- } catch (IOException e1) {
- // The symlink was probably not found, so this is ok.
- }
-
- // Try x-www-browser, which is symlink to the default browser,
- // except if we found that it is Konqueror.
- if (!started && !isDefaultKonqueror) {
- try {
- runtime.exec("x-www-browser " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
-
- // Try firefox
- if (!started) {
- try {
- runtime.exec("firefox " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
-
- // Try mozilla
- if (!started) {
- try {
- runtime.exec("mozilla " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
-
- // Try konqueror
- if (!started) {
- try {
- runtime.exec("konqueror " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
- }
-
- // OS X
- if (os.indexOf("mac os x") >= 0) {
-
- // Try open
- if (!started) {
- try {
- runtime.exec("open " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
- }
-
- // Try cmd /start command on windows
- if (os.indexOf("win") >= 0) {
- if (!started) {
- try {
- runtime.exec("cmd /c start " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
- }
-
- if (!started) {
- System.out.println("Failed to open browser. Please go to " + url);
- }
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.launcher.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * This class opens default browser for DemoLauncher class. Default browser is
+ * detected by the operating system.
+ *
+ */
+public class BrowserLauncher {
+
+ /**
+ * Open browser on specified URL.
+ *
+ * @param url
+ */
+ public static void openBrowser(String url) {
+
+ final Runtime runtime = Runtime.getRuntime();
+ boolean started = false;
+
+ final String os = System.getProperty("os.name", "windows")
+ .toLowerCase();
+
+ // Linux
+ if (os.indexOf("linux") >= 0) {
+ // See if the default browser is Konqueror by resolving the symlink.
+ boolean isDefaultKonqueror = false;
+ try {
+ // Find out the location of the x-www-browser link from path.
+ Process process = runtime.exec("which x-www-browser");
+ BufferedInputStream ins = new BufferedInputStream(
+ process.getInputStream());
+ BufferedReader bufreader = new BufferedReader(
+ new InputStreamReader(ins));
+ String defaultLinkPath = bufreader.readLine();
+ ins.close();
+
+ // The path is null if the link did not exist.
+ if (defaultLinkPath != null) {
+ // See if the default browser is Konqueror.
+ File file = new File(defaultLinkPath);
+ String canonical = file.getCanonicalPath();
+ if (canonical.indexOf("konqueror") != -1) {
+ isDefaultKonqueror = true;
+ }
+ }
+ } catch (IOException e1) {
+ // The symlink was probably not found, so this is ok.
+ }
+
+ // Try x-www-browser, which is symlink to the default browser,
+ // except if we found that it is Konqueror.
+ if (!started && !isDefaultKonqueror) {
+ try {
+ runtime.exec("x-www-browser " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try firefox
+ if (!started) {
+ try {
+ runtime.exec("firefox " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try mozilla
+ if (!started) {
+ try {
+ runtime.exec("mozilla " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try konqueror
+ if (!started) {
+ try {
+ runtime.exec("konqueror " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ // OS X
+ if (os.indexOf("mac os x") >= 0) {
+
+ // Try open
+ if (!started) {
+ try {
+ runtime.exec("open " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ // Try cmd /start command on windows
+ if (os.indexOf("win") >= 0) {
+ if (!started) {
+ try {
+ runtime.exec("cmd /c start " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ if (!started) {
+ System.out.println("Failed to open browser. Please go to " + url);
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/Components.java b/tests/testbench/com/vaadin/tests/Components.java
index d7bc18e2f6..3366f6db43 100644
--- a/tests/testbench/com/vaadin/tests/Components.java
+++ b/tests/testbench/com/vaadin/tests/Components.java
@@ -1,268 +1,268 @@
-package com.vaadin.tests;
-
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.vaadin.Application;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.DefaultItemSorter;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.tests.components.AbstractComponentTest;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.Embedded;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.Tree.ItemStyleGenerator;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Components extends Application {
-
- private static final Object CAPTION = "c";
- private Map<Class<? extends AbstractComponentTest>, String> tests = new HashMap<Class<? extends AbstractComponentTest>, String>();
- private Tree naviTree;
- private HorizontalSplitPanel sp;
- private Window mainWindow;
- private final Embedded applicationEmbedder = new Embedded();
- private String baseUrl;
- private List<Class<? extends Component>> componentsWithoutTests = new ArrayList<Class<? extends Component>>();
-
- {
- for (Class<?> c : VaadinClasses.getBasicComponentTests()) {
- String testClass = c.getSimpleName();
- tests.put((Class<? extends AbstractComponentTest>) c, testClass);
- }
-
- List<Class<? extends Component>> componentsWithoutTest = VaadinClasses
- .getComponents();
- Set<String> availableTests = new HashSet<String>();
- for (String testName : tests.values()) {
- availableTests.add(testName);
- }
-
- for (Class<? extends Component> component : componentsWithoutTest) {
- String baseName = component.getSimpleName();
- if (availableTests.contains(baseName + "es")) {
- continue;
- }
- if (availableTests.contains(baseName + "es2")) {
- continue;
- }
- if (availableTests.contains(baseName + "s2")) {
- continue;
- }
- if (availableTests.contains(baseName + "s")) {
- continue;
- }
- if (availableTests.contains(baseName + "Test")) {
- continue;
- }
-
- componentsWithoutTests.add(component);
- }
-
- }
-
- class MissingTest extends AbstractComponentTest<AbstractComponent> {
- @Override
- protected Class<AbstractComponent> getTestClass() {
- return null;
- }
- }
-
- @Override
- public void init() {
- mainWindow = new Window();
- setTheme("tests-components");
- mainWindow.getContent().setSizeFull();
- setMainWindow(mainWindow);
- sp = new HorizontalSplitPanel();
- sp.setSizeFull();
- VerticalLayout naviLayout = new VerticalLayout();
- naviLayout
- .addComponent(new Label(
- "Click to open a test case.<br/>Right click to open test in a new window<br/><br/>",
- Label.CONTENT_XHTML));
- naviLayout.addComponent(createMenu());
- naviLayout.addComponent(createMissingTestsList());
-
- sp.setFirstComponent(naviLayout);
- sp.setSplitPosition(250, Sizeable.UNITS_PIXELS);
- VerticalLayout embeddingLayout = new VerticalLayout();
- embeddingLayout.setSizeFull();
- embeddingLayout
- .addComponent(new Label(
- "<b>Do not use the embedded version for creating automated tests. Open the test in a new window before recording.</b><br/>",
- Label.CONTENT_XHTML));
- applicationEmbedder.setSizeFull();
- embeddingLayout.addComponent(applicationEmbedder);
- embeddingLayout.setExpandRatio(applicationEmbedder, 1);
- sp.setSecondComponent(embeddingLayout);
- mainWindow.addComponent(sp);
-
- applicationEmbedder.setType(Embedded.TYPE_BROWSER);
- baseUrl = getURL().toString().replace(getClass().getName(), "")
- .replaceAll("//$", "/");
- }
-
- private Component createMissingTestsList() {
- String missingTests = "";
- for (Class<? extends Component> component : componentsWithoutTests) {
- String cls = "missing";
- if (component.getAnnotation(Deprecated.class) != null) {
- cls = "missing-deprecated";
- }
- missingTests += "<font class=\"" + cls + "\">"
- + component.getSimpleName() + "</font><br/>";
- }
- return new Label("<b>Components without a test:</B><br/>"
- + missingTests, Label.CONTENT_XHTML);
- }
-
- private Component createMenu() {
- naviTree = new Tree();
- naviTree.setItemStyleGenerator(new ItemStyleGenerator() {
-
- public String getStyle(Object itemId) {
- Class<?> cls = (Class<?>) itemId;
- if (!isAbstract(cls)) {
- return "blue";
- }
- return null;
- }
- });
- HierarchicalContainer hc = new HierarchicalContainer();
- naviTree.setContainerDataSource(hc);
- DefaultItemSorter sorter = new DefaultItemSorter() {
- @SuppressWarnings("rawtypes")
- @Override
- public int compare(Object o1, Object o2) {
- if (o1 instanceof Class && o2 instanceof Class && o1 != null
- && o2 != null) {
- Class<?> c1 = (Class) o1;
- Class<?> c2 = (Class) o2;
- boolean a1 = isAbstract(c1);
- boolean a2 = isAbstract(c2);
-
- if (a1 && !a2) {
- return 1;
- } else if (!a1 && a2) {
- return -1;
- }
-
- }
- return super.compare(o1, o2);
- }
- };
- hc.setItemSorter(sorter);
- naviTree.addContainerProperty(CAPTION, String.class, "");
- naviTree.setItemCaptionPropertyId(CAPTION);
- for (Class<? extends AbstractComponentTest> cls : tests.keySet()) {
- addTreeItem(cls);
- }
- hc.sort(new Object[] { CAPTION }, new boolean[] { true });
- naviTree.setSelectable(false);
- for (Object o : naviTree.rootItemIds()) {
- expandAndSetChildrenAllowed(o);
- }
-
- naviTree.addListener(new ItemClickListener() {
-
- public void itemClick(ItemClickEvent event) {
- Class<?> cls = (Class<?>) event.getItemId();
- if (!isAbstract(cls)) {
- String url = baseUrl + cls.getName()
- + "?restartApplication";
- if (event.getButton() == ItemClickEvent.BUTTON_LEFT) {
- openEmbedded(url);
- naviTree.setValue(event.getItemId());
- } else if (event.getButton() == ItemClickEvent.BUTTON_RIGHT) {
- openInNewTab(url);
- }
- }
- }
-
- });
- return naviTree;
- }
-
- protected void openInNewTab(String url) {
- getMainWindow().open(new ExternalResource(url), "_blank");
- }
-
- protected void openEmbedded(String url) {
- applicationEmbedder.setSource(new ExternalResource(url));
- }
-
- private void expandAndSetChildrenAllowed(Object o) {
- Collection<?> children = naviTree.getChildren(o);
- if (children == null || children.size() == 0) {
- naviTree.setChildrenAllowed(o, false);
- } else {
- naviTree.expandItem(o);
- for (Object c : children) {
- expandAndSetChildrenAllowed(c);
- }
- }
-
- }
-
- protected boolean isAbstract(Class<?> cls) {
- return Modifier.isAbstract(cls.getModifiers());
- }
-
- @SuppressWarnings("unchecked")
- private void addTreeItem(Class<? extends AbstractComponentTest> cls) {
- String name = tests.get(cls);
- if (name == null) {
- name = cls.getSimpleName();
- }
-
- Class<? extends AbstractComponentTest> superClass = (Class<? extends AbstractComponentTest>) cls
- .getSuperclass();
-
- // This cast is needed only to make compilation through Ant work ..
- if (((Class<?>) cls) != AbstractComponentTest.class) {
- addTreeItem(superClass);
- }
- if (naviTree.containsId(cls)) {
- return;
- }
-
- Item i = naviTree.addItem(cls);
- i.getItemProperty(CAPTION).setValue(name);
- naviTree.setParent(cls, superClass);
- }
-
- protected Component createTestComponent(
- Class<? extends AbstractComponentTest> cls) {
- try {
- AbstractComponentTest t = cls.newInstance();
- t.init();
- ComponentContainer c = t.getMainWindow().getContent();
- t.getMainWindow().setContent(null);
- return c;
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
-}
+package com.vaadin.tests;
+
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.vaadin.Application;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.DefaultItemSorter;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.Tree.ItemStyleGenerator;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Components extends Application {
+
+ private static final Object CAPTION = "c";
+ private Map<Class<? extends AbstractComponentTest>, String> tests = new HashMap<Class<? extends AbstractComponentTest>, String>();
+ private Tree naviTree;
+ private HorizontalSplitPanel sp;
+ private Window mainWindow;
+ private final Embedded applicationEmbedder = new Embedded();
+ private String baseUrl;
+ private List<Class<? extends Component>> componentsWithoutTests = new ArrayList<Class<? extends Component>>();
+
+ {
+ for (Class<?> c : VaadinClasses.getBasicComponentTests()) {
+ String testClass = c.getSimpleName();
+ tests.put((Class<? extends AbstractComponentTest>) c, testClass);
+ }
+
+ List<Class<? extends Component>> componentsWithoutTest = VaadinClasses
+ .getComponents();
+ Set<String> availableTests = new HashSet<String>();
+ for (String testName : tests.values()) {
+ availableTests.add(testName);
+ }
+
+ for (Class<? extends Component> component : componentsWithoutTest) {
+ String baseName = component.getSimpleName();
+ if (availableTests.contains(baseName + "es")) {
+ continue;
+ }
+ if (availableTests.contains(baseName + "es2")) {
+ continue;
+ }
+ if (availableTests.contains(baseName + "s2")) {
+ continue;
+ }
+ if (availableTests.contains(baseName + "s")) {
+ continue;
+ }
+ if (availableTests.contains(baseName + "Test")) {
+ continue;
+ }
+
+ componentsWithoutTests.add(component);
+ }
+
+ }
+
+ class MissingTest extends AbstractComponentTest<AbstractComponent> {
+ @Override
+ protected Class<AbstractComponent> getTestClass() {
+ return null;
+ }
+ }
+
+ @Override
+ public void init() {
+ mainWindow = new Window();
+ setTheme("tests-components");
+ mainWindow.getContent().setSizeFull();
+ setMainWindow(mainWindow);
+ sp = new HorizontalSplitPanel();
+ sp.setSizeFull();
+ VerticalLayout naviLayout = new VerticalLayout();
+ naviLayout
+ .addComponent(new Label(
+ "Click to open a test case.<br/>Right click to open test in a new window<br/><br/>",
+ Label.CONTENT_XHTML));
+ naviLayout.addComponent(createMenu());
+ naviLayout.addComponent(createMissingTestsList());
+
+ sp.setFirstComponent(naviLayout);
+ sp.setSplitPosition(250, Sizeable.UNITS_PIXELS);
+ VerticalLayout embeddingLayout = new VerticalLayout();
+ embeddingLayout.setSizeFull();
+ embeddingLayout
+ .addComponent(new Label(
+ "<b>Do not use the embedded version for creating automated tests. Open the test in a new window before recording.</b><br/>",
+ Label.CONTENT_XHTML));
+ applicationEmbedder.setSizeFull();
+ embeddingLayout.addComponent(applicationEmbedder);
+ embeddingLayout.setExpandRatio(applicationEmbedder, 1);
+ sp.setSecondComponent(embeddingLayout);
+ mainWindow.addComponent(sp);
+
+ applicationEmbedder.setType(Embedded.TYPE_BROWSER);
+ baseUrl = getURL().toString().replace(getClass().getName(), "")
+ .replaceAll("//$", "/");
+ }
+
+ private Component createMissingTestsList() {
+ String missingTests = "";
+ for (Class<? extends Component> component : componentsWithoutTests) {
+ String cls = "missing";
+ if (component.getAnnotation(Deprecated.class) != null) {
+ cls = "missing-deprecated";
+ }
+ missingTests += "<font class=\"" + cls + "\">"
+ + component.getSimpleName() + "</font><br/>";
+ }
+ return new Label("<b>Components without a test:</B><br/>"
+ + missingTests, Label.CONTENT_XHTML);
+ }
+
+ private Component createMenu() {
+ naviTree = new Tree();
+ naviTree.setItemStyleGenerator(new ItemStyleGenerator() {
+
+ public String getStyle(Object itemId) {
+ Class<?> cls = (Class<?>) itemId;
+ if (!isAbstract(cls)) {
+ return "blue";
+ }
+ return null;
+ }
+ });
+ HierarchicalContainer hc = new HierarchicalContainer();
+ naviTree.setContainerDataSource(hc);
+ DefaultItemSorter sorter = new DefaultItemSorter() {
+ @SuppressWarnings("rawtypes")
+ @Override
+ public int compare(Object o1, Object o2) {
+ if (o1 instanceof Class && o2 instanceof Class && o1 != null
+ && o2 != null) {
+ Class<?> c1 = (Class) o1;
+ Class<?> c2 = (Class) o2;
+ boolean a1 = isAbstract(c1);
+ boolean a2 = isAbstract(c2);
+
+ if (a1 && !a2) {
+ return 1;
+ } else if (!a1 && a2) {
+ return -1;
+ }
+
+ }
+ return super.compare(o1, o2);
+ }
+ };
+ hc.setItemSorter(sorter);
+ naviTree.addContainerProperty(CAPTION, String.class, "");
+ naviTree.setItemCaptionPropertyId(CAPTION);
+ for (Class<? extends AbstractComponentTest> cls : tests.keySet()) {
+ addTreeItem(cls);
+ }
+ hc.sort(new Object[] { CAPTION }, new boolean[] { true });
+ naviTree.setSelectable(false);
+ for (Object o : naviTree.rootItemIds()) {
+ expandAndSetChildrenAllowed(o);
+ }
+
+ naviTree.addListener(new ItemClickListener() {
+
+ public void itemClick(ItemClickEvent event) {
+ Class<?> cls = (Class<?>) event.getItemId();
+ if (!isAbstract(cls)) {
+ String url = baseUrl + cls.getName()
+ + "?restartApplication";
+ if (event.getButton() == ItemClickEvent.BUTTON_LEFT) {
+ openEmbedded(url);
+ naviTree.setValue(event.getItemId());
+ } else if (event.getButton() == ItemClickEvent.BUTTON_RIGHT) {
+ openInNewTab(url);
+ }
+ }
+ }
+
+ });
+ return naviTree;
+ }
+
+ protected void openInNewTab(String url) {
+ getMainWindow().open(new ExternalResource(url), "_blank");
+ }
+
+ protected void openEmbedded(String url) {
+ applicationEmbedder.setSource(new ExternalResource(url));
+ }
+
+ private void expandAndSetChildrenAllowed(Object o) {
+ Collection<?> children = naviTree.getChildren(o);
+ if (children == null || children.size() == 0) {
+ naviTree.setChildrenAllowed(o, false);
+ } else {
+ naviTree.expandItem(o);
+ for (Object c : children) {
+ expandAndSetChildrenAllowed(c);
+ }
+ }
+
+ }
+
+ protected boolean isAbstract(Class<?> cls) {
+ return Modifier.isAbstract(cls.getModifiers());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void addTreeItem(Class<? extends AbstractComponentTest> cls) {
+ String name = tests.get(cls);
+ if (name == null) {
+ name = cls.getSimpleName();
+ }
+
+ Class<? extends AbstractComponentTest> superClass = (Class<? extends AbstractComponentTest>) cls
+ .getSuperclass();
+
+ // This cast is needed only to make compilation through Ant work ..
+ if (((Class<?>) cls) != AbstractComponentTest.class) {
+ addTreeItem(superClass);
+ }
+ if (naviTree.containsId(cls)) {
+ return;
+ }
+
+ Item i = naviTree.addItem(cls);
+ i.getItemProperty(CAPTION).setValue(name);
+ naviTree.setParent(cls, superClass);
+ }
+
+ protected Component createTestComponent(
+ Class<? extends AbstractComponentTest> cls) {
+ try {
+ AbstractComponentTest t = cls.newInstance();
+ t.init();
+ ComponentContainer c = t.getMainWindow().getContent();
+ t.getMainWindow().setContent(null);
+ return c;
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/StressComponentsInTable.java b/tests/testbench/com/vaadin/tests/StressComponentsInTable.java
index 02662cdcbb..9c2703822e 100644
--- a/tests/testbench/com/vaadin/tests/StressComponentsInTable.java
+++ b/tests/testbench/com/vaadin/tests/StressComponentsInTable.java
@@ -1,75 +1,75 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import java.util.Date;
-import java.util.Vector;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-
-public class StressComponentsInTable extends CustomComponent {
-
- public StressComponentsInTable() {
- final VerticalLayout main = new VerticalLayout();
- setCompositionRoot(main);
-
- main.addComponent(getTestTable(4, 1000));
-
- }
-
- public static Table getTestTable(int cols, int rows) {
- 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<Object> content = new Vector<Object>();
- for (int j = 0; j < cols; j++) {
- content.add(rndString());
- }
- content.add(new Button("b" + i, new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Button b = event.getButton();
- System.out.println(b.getCaption() + " click: "
- + (new Date()).toString());
- System.out.println(b.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() {
- return testString[(int) (Math.random() * testString.length)];
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests;
+
+import java.util.Date;
+import java.util.Vector;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class StressComponentsInTable extends CustomComponent {
+
+ public StressComponentsInTable() {
+ final VerticalLayout main = new VerticalLayout();
+ setCompositionRoot(main);
+
+ main.addComponent(getTestTable(4, 1000));
+
+ }
+
+ public static Table getTestTable(int cols, int rows) {
+ 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<Object> content = new Vector<Object>();
+ for (int j = 0; j < cols; j++) {
+ content.add(rndString());
+ }
+ content.add(new Button("b" + i, new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Button b = event.getButton();
+ System.out.println(b.getCaption() + " click: "
+ + (new Date()).toString());
+ System.out.println(b.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() {
+ return testString[(int) (Math.random() * testString.length)];
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/TableChangingDatasource.java b/tests/testbench/com/vaadin/tests/TableChangingDatasource.java
index 983355a6e6..fa7edc3a45 100644
--- a/tests/testbench/com/vaadin/tests/TableChangingDatasource.java
+++ b/tests/testbench/com/vaadin/tests/TableChangingDatasource.java
@@ -1,53 +1,53 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-
-public class TableChangingDatasource extends CustomComponent implements
- ClickListener {
- Table t;
- Table[] ta = new Table[4];
- private int mode = 0;
-
- public TableChangingDatasource() {
- final VerticalLayout main = new VerticalLayout();
-
- main.addComponent(new Label(
- "Table should look sane after data source changes"));
-
- t = new Table();
-
- t.setWidth("500px");
- t.setHeight("300px");
-
- ta[0] = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(3, 0);
- ta[1] = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(3, 7);
- ta[2] = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(3, 5);
- ta[3] = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(3, 1);
-
- main.addComponent(t);
- main.addComponent(new Button("switch DS", this));
-
- setCompositionRoot(main);
-
- }
-
- public void buttonClick(ClickEvent event) {
- int i = mode % 4;
- t.setContainerDataSource(ta[i].getContainerDataSource());
- mode++;
- }
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class TableChangingDatasource extends CustomComponent implements
+ ClickListener {
+ Table t;
+ Table[] ta = new Table[4];
+ private int mode = 0;
+
+ public TableChangingDatasource() {
+ final VerticalLayout main = new VerticalLayout();
+
+ main.addComponent(new Label(
+ "Table should look sane after data source changes"));
+
+ t = new Table();
+
+ t.setWidth("500px");
+ t.setHeight("300px");
+
+ ta[0] = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(3, 0);
+ ta[1] = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(3, 7);
+ ta[2] = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(3, 5);
+ ta[3] = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(3, 1);
+
+ main.addComponent(t);
+ main.addComponent(new Button("switch DS", this));
+
+ setCompositionRoot(main);
+
+ }
+
+ public void buttonClick(ClickEvent event) {
+ int i = mode % 4;
+ t.setContainerDataSource(ta[i].getContainerDataSource());
+ mode++;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/TableSelectTest.java b/tests/testbench/com/vaadin/tests/TableSelectTest.java
index 6430d7bc1c..62070c4b97 100644
--- a/tests/testbench/com/vaadin/tests/TableSelectTest.java
+++ b/tests/testbench/com/vaadin/tests/TableSelectTest.java
@@ -1,123 +1,123 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-
-public class TableSelectTest extends CustomComponent implements
- Table.ValueChangeListener {
-
- public TableSelectTest() {
- final VerticalLayout main = new VerticalLayout();
- setCompositionRoot(main);
- main.addComponent(new Label("Hello World!"));
-
- Table t;
- t = new Table("single nullsel");
- main.addComponent(t);
- t(t);
- t.setMultiSelect(false);
- t.setNullSelectionAllowed(true);
- t.addListener(this);
-
- t = new Table("single NO-nullsel");
- main.addComponent(t);
- t(t);
- t.setMultiSelect(false);
- t.setNullSelectionAllowed(false);
- t.addListener(this);
-
- t = new Table("multi nullsel");
- main.addComponent(t);
- t(t);
- t.setMultiSelect(true);
- t.setNullSelectionAllowed(true);
- t.addListener(this);
-
- t = new Table("multi NO-nullsel");
- main.addComponent(t);
- t(t);
- t.setMultiSelect(true);
- t.setNullSelectionAllowed(false);
- t.addListener(this);
-
- // --
-
- t = new Table("single nullsel nullselid");
- main.addComponent(t);
- Object id = t(t);
- t.setNullSelectionItemId(id);
- t.setMultiSelect(false);
- t.setNullSelectionAllowed(true);
- t.addListener(this);
-
- t = new Table("single NO-nullsel nullselid");
- main.addComponent(t);
- id = t(t);
- t.setNullSelectionItemId(id);
- t.setMultiSelect(false);
- t.setNullSelectionAllowed(false);
- t.addListener(this);
-
- t = new Table("multi(fails) nullsel nullselid");
- main.addComponent(t);
- id = t(t);
- t.setNullSelectionItemId(id);
- try {
- t.setMultiSelect(true);
- t.setCaption("multi(SHOLD FAIL BUT DID NOT) nullsel nullselid");
- } catch (final Exception e) {
- System.err.println("failed ok");
- }
- t.setNullSelectionAllowed(true);
- t.addListener(this);
-
- t = new Table("multi(fails) NO-nullsel nullselid");
- main.addComponent(t);
- id = t(t);
- t.setNullSelectionItemId(id);
- try {
- t.setMultiSelect(true);
- t.setCaption("multi(SHOLD FAIL BUT DID NOT) NO-nullsel nullselid");
- } catch (final Exception e) {
- System.err.println("failed ok");
- }
- t.setNullSelectionAllowed(false);
- t.addListener(this);
-
- /*
- * And that's it! The framework will display the main window and its
- * contents when the application is accessed with the terminal.
- */
-
- }
-
- private Object t(Table t) {
- t.setImmediate(true);
- t.setSelectable(true);
-
- Object id = null;
- for (int i = 0; i < 5; i++) {
- id = t.addItem();
- }
- t.addContainerProperty("asd", String.class, "the asd thing");
- t.addContainerProperty("foo", String.class, "foo stuff");
- t.addContainerProperty("Alonger column header", String.class, "short");
-
- return id;
- }
-
- public void valueChange(ValueChangeEvent event) {
- final Object val = event.getProperty().getValue();
-
- System.err.println("Value: " + val);
-
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class TableSelectTest extends CustomComponent implements
+ Table.ValueChangeListener {
+
+ public TableSelectTest() {
+ final VerticalLayout main = new VerticalLayout();
+ setCompositionRoot(main);
+ main.addComponent(new Label("Hello World!"));
+
+ Table t;
+ t = new Table("single nullsel");
+ main.addComponent(t);
+ t(t);
+ t.setMultiSelect(false);
+ t.setNullSelectionAllowed(true);
+ t.addListener(this);
+
+ t = new Table("single NO-nullsel");
+ main.addComponent(t);
+ t(t);
+ t.setMultiSelect(false);
+ t.setNullSelectionAllowed(false);
+ t.addListener(this);
+
+ t = new Table("multi nullsel");
+ main.addComponent(t);
+ t(t);
+ t.setMultiSelect(true);
+ t.setNullSelectionAllowed(true);
+ t.addListener(this);
+
+ t = new Table("multi NO-nullsel");
+ main.addComponent(t);
+ t(t);
+ t.setMultiSelect(true);
+ t.setNullSelectionAllowed(false);
+ t.addListener(this);
+
+ // --
+
+ t = new Table("single nullsel nullselid");
+ main.addComponent(t);
+ Object id = t(t);
+ t.setNullSelectionItemId(id);
+ t.setMultiSelect(false);
+ t.setNullSelectionAllowed(true);
+ t.addListener(this);
+
+ t = new Table("single NO-nullsel nullselid");
+ main.addComponent(t);
+ id = t(t);
+ t.setNullSelectionItemId(id);
+ t.setMultiSelect(false);
+ t.setNullSelectionAllowed(false);
+ t.addListener(this);
+
+ t = new Table("multi(fails) nullsel nullselid");
+ main.addComponent(t);
+ id = t(t);
+ t.setNullSelectionItemId(id);
+ try {
+ t.setMultiSelect(true);
+ t.setCaption("multi(SHOLD FAIL BUT DID NOT) nullsel nullselid");
+ } catch (final Exception e) {
+ System.err.println("failed ok");
+ }
+ t.setNullSelectionAllowed(true);
+ t.addListener(this);
+
+ t = new Table("multi(fails) NO-nullsel nullselid");
+ main.addComponent(t);
+ id = t(t);
+ t.setNullSelectionItemId(id);
+ try {
+ t.setMultiSelect(true);
+ t.setCaption("multi(SHOLD FAIL BUT DID NOT) NO-nullsel nullselid");
+ } catch (final Exception e) {
+ System.err.println("failed ok");
+ }
+ t.setNullSelectionAllowed(false);
+ t.addListener(this);
+
+ /*
+ * And that's it! The framework will display the main window and its
+ * contents when the application is accessed with the terminal.
+ */
+
+ }
+
+ private Object t(Table t) {
+ t.setImmediate(true);
+ t.setSelectable(true);
+
+ Object id = null;
+ for (int i = 0; i < 5; i++) {
+ id = t.addItem();
+ }
+ t.addContainerProperty("asd", String.class, "the asd thing");
+ t.addContainerProperty("foo", String.class, "foo stuff");
+ t.addContainerProperty("Alonger column header", String.class, "short");
+
+ return id;
+ }
+
+ public void valueChange(ValueChangeEvent event) {
+ final Object val = event.getProperty().getValue();
+
+ System.err.println("Value: " + val);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java b/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java
index 5203a7055f..62a67cb747 100644
--- a/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java
+++ b/tests/testbench/com/vaadin/tests/TestComponentAddAndRecursion.java
@@ -1,128 +1,128 @@
-/**
- *
- */
-package com.vaadin.tests;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-/**
- * @author marc
- *
- */
-public class TestComponentAddAndRecursion extends CustomComponent {
- Panel p;
- Panel p2;
- Label l;
- Label l2;
- Panel p3;
-
- public TestComponentAddAndRecursion() {
-
- VerticalLayout main = new VerticalLayout();
- setCompositionRoot(main);
-
- l = new Label("A");
- l2 = new Label("B");
- p = new Panel("p");
- p.addComponent(l);
- p.addComponent(l2);
- main.addComponent(p);
- p2 = new Panel("p2");
- p2.addComponent(l);
- main.addComponent(p2);
- p3 = new Panel("p3");
- p2.addComponent(p3);
-
- Button b = new Button("use gridlayout", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- p.setContent(new GridLayout());
- p2.setContent(new GridLayout());
- p3.setContent(new GridLayout());
- }
-
- });
- main.addComponent(b);
- b = new Button("use orderedlayout", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- p.setContent(new VerticalLayout());
- p2.setContent(new VerticalLayout());
- p3.setContent(new VerticalLayout());
- }
-
- });
- main.addComponent(b);
- b = new Button("move B", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- p2.addComponent(l2);
- }
-
- });
- main.addComponent(b);
- b = new Button("move p", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- p3.addComponent(p);
- }
-
- });
- main.addComponent(b);
- b = new Button("add to both", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Label l = new Label("both");
- p.addComponent(l);
- p2.addComponent(l);
- }
-
- });
- main.addComponent(b);
- b = new Button("recurse", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- try {
- p3.addComponent(p2);
- getWindow().showNotification("ERROR",
- "This should have failed",
- Window.Notification.TYPE_ERROR_MESSAGE);
- } catch (Exception e) {
- getWindow().showNotification("OK", "threw, as expected",
- Window.Notification.TYPE_ERROR_MESSAGE);
- }
- }
-
- });
- main.addComponent(b);
- b = new Button("recurse2", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Panel p = new Panel("dynamic");
- p.addComponent(p2);
- try {
- p3.addComponent(p);
- getWindow().showNotification("ERROR",
- "This should have failed",
- Window.Notification.TYPE_ERROR_MESSAGE);
- } catch (Exception e) {
- getWindow().showNotification("OK", "threw, as expected",
- Window.Notification.TYPE_ERROR_MESSAGE);
- }
- }
-
- });
- main.addComponent(b);
- /*
- * And that's it! The framework will display the main window and its
- * contents when the application is accessed with the terminal.
- */
- }
-}
+/**
+ *
+ */
+package com.vaadin.tests;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+/**
+ * @author marc
+ *
+ */
+public class TestComponentAddAndRecursion extends CustomComponent {
+ Panel p;
+ Panel p2;
+ Label l;
+ Label l2;
+ Panel p3;
+
+ public TestComponentAddAndRecursion() {
+
+ VerticalLayout main = new VerticalLayout();
+ setCompositionRoot(main);
+
+ l = new Label("A");
+ l2 = new Label("B");
+ p = new Panel("p");
+ p.addComponent(l);
+ p.addComponent(l2);
+ main.addComponent(p);
+ p2 = new Panel("p2");
+ p2.addComponent(l);
+ main.addComponent(p2);
+ p3 = new Panel("p3");
+ p2.addComponent(p3);
+
+ Button b = new Button("use gridlayout", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ p.setContent(new GridLayout());
+ p2.setContent(new GridLayout());
+ p3.setContent(new GridLayout());
+ }
+
+ });
+ main.addComponent(b);
+ b = new Button("use orderedlayout", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ p.setContent(new VerticalLayout());
+ p2.setContent(new VerticalLayout());
+ p3.setContent(new VerticalLayout());
+ }
+
+ });
+ main.addComponent(b);
+ b = new Button("move B", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ p2.addComponent(l2);
+ }
+
+ });
+ main.addComponent(b);
+ b = new Button("move p", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ p3.addComponent(p);
+ }
+
+ });
+ main.addComponent(b);
+ b = new Button("add to both", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Label l = new Label("both");
+ p.addComponent(l);
+ p2.addComponent(l);
+ }
+
+ });
+ main.addComponent(b);
+ b = new Button("recurse", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ try {
+ p3.addComponent(p2);
+ getWindow().showNotification("ERROR",
+ "This should have failed",
+ Window.Notification.TYPE_ERROR_MESSAGE);
+ } catch (Exception e) {
+ getWindow().showNotification("OK", "threw, as expected",
+ Window.Notification.TYPE_ERROR_MESSAGE);
+ }
+ }
+
+ });
+ main.addComponent(b);
+ b = new Button("recurse2", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Panel p = new Panel("dynamic");
+ p.addComponent(p2);
+ try {
+ p3.addComponent(p);
+ getWindow().showNotification("ERROR",
+ "This should have failed",
+ Window.Notification.TYPE_ERROR_MESSAGE);
+ } catch (Exception e) {
+ getWindow().showNotification("OK", "threw, as expected",
+ Window.Notification.TYPE_ERROR_MESSAGE);
+ }
+ }
+
+ });
+ main.addComponent(b);
+ /*
+ * And that's it! The framework will display the main window and its
+ * contents when the application is accessed with the terminal.
+ */
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/TestContainerChanges.java b/tests/testbench/com/vaadin/tests/TestContainerChanges.java
index c3a1a98665..b7f24abd8b 100644
--- a/tests/testbench/com/vaadin/tests/TestContainerChanges.java
+++ b/tests/testbench/com/vaadin/tests/TestContainerChanges.java
@@ -1,212 +1,212 @@
-/**
- *
- */
-package com.vaadin.tests;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.ContainerHierarchicalWrapper;
-import com.vaadin.data.util.ContainerOrderedWrapper;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.ListSelect;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.themes.Reindeer;
-
-/**
- * @author marc
- *
- */
-public class TestContainerChanges extends CustomComponent {
- Container cont = new IndexedContainer();
- Container hierarchical = new ContainerHierarchicalWrapper(cont);
- Container ordered = new ContainerOrderedWrapper(cont);
-
- int cnt = 0;
- Table tbl;
-
- public TestContainerChanges() {
-
- cont.addContainerProperty("Asd", String.class, "qwe");
- cont.addContainerProperty("Bar", String.class, "foo");
-
- VerticalLayout main = new VerticalLayout();
- setCompositionRoot(main);
-
- main.addComponent(new Label(
- "The same IndexedContainer is wrapped in a ordered/hierarchical wrapper and is set as data source for all components . The buttons only affect the 'original' IndexedContainer."));
-
- HorizontalLayout h = new HorizontalLayout();
-
- main.addComponent(h);
-
- VerticalLayout v = new VerticalLayout();
- h.addComponent(v);
- tbl = new Table();
- tbl.setHeight("200px");
- tbl.setWidth("300px");
- v.addComponent(tbl);
- tbl.setSelectable(true);
- tbl.setMultiSelect(false);
- tbl.setImmediate(true);
- tbl.setEditable(true);
- tbl.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- // Original container
- tbl.setContainerDataSource(hierarchical);
-
- Table tbl2 = new Table();
- tbl2.setHeight("200px");
- tbl2.setWidth("300px");
- v.addComponent(tbl2);
- tbl2.setSelectable(true);
- tbl2.setMultiSelect(false);
- tbl2.setImmediate(true);
- tbl2.addListener(new Table.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- System.err.println("Value now "
- + event.getProperty().getValue());
-
- }
- });
- tbl2.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- // non-ordered container will get wrapped
- tbl2.setContainerDataSource(hierarchical);
-
- VerticalLayout buttons = new VerticalLayout();
- v.addComponent(buttons);
-
- Button b = new Button("table.commit()", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tbl.commit();
- }
-
- });
- buttons.addComponent(b);
-
- b = new Button("indexedcontainer.addItem()",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cont.addItem(new Integer(cnt++));
- }
-
- });
- buttons.addComponent(b);
- b = new Button("indexedcontainer.addItem(null)",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cont.addItem(null);
- }
-
- });
- buttons.addComponent(b);
- b = new Button("indexedcontainer.removeItem(table.lastItemId()",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cont.removeItem(tbl.lastItemId());
- }
-
- });
- buttons.addComponent(b);
-
- b = new Button("indexedcontainer.addContainerProperty()",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cont.addContainerProperty("prop" + cnt, String.class,
- "#" + cnt++);
- }
-
- });
- buttons.addComponent(b);
-
- b = new Button("indexedcontainer.clear()", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cont.removeAllItems();
- }
-
- });
- buttons.addComponent(b);
- b = new Button("table.setContainerDataSource(indexedcontainer)",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tbl.setContainerDataSource(cont);
- }
-
- });
- buttons.addComponent(b);
- b = new Button("table.setContainerDataSource(orderedwrapper)",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tbl.setContainerDataSource(ordered);
- }
-
- });
- buttons.addComponent(b);
- b = new Button("table.setContainerDataSource(hierarchicalwrapper)",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tbl.setContainerDataSource(hierarchical);
- }
-
- });
- buttons.addComponent(b);
-
- Panel p = new Panel("Tree");
- p.setStyleName(Reindeer.PANEL_LIGHT);
- h.addComponent(p);
- Tree tree = new Tree("ITEM_CAPTION_MODE_PROPERTY");
- tree.setContainerDataSource(ordered);
- tree.setItemCaptionPropertyId("Asd");
- tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);
- p.addComponent(tree);
- tree = new Tree("ITEM_CAPTION_MODE_ITEM");
- // nonhierarchical container will get wrapped
- tree.setContainerDataSource(ordered);
- tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_ITEM);
- p.addComponent(tree);
-
- p = new Panel("ComboBox");
- p.setStyleName(Reindeer.PANEL_LIGHT);
- h.addComponent(p);
- ComboBox c = new ComboBox("ITEM_CAPTION_MODE_PROPERTY");
- c.setImmediate(true);
- c.setContainerDataSource(cont);
- c.setItemCaptionPropertyId("Asd");
- c.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
- p.addComponent(c);
- c = new ComboBox("ITEM_CAPTION_MODE_ITEM");
- c.setImmediate(true);
- c.setContainerDataSource(cont);
- c.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
- p.addComponent(c);
-
- p = new Panel("ListBox");
- p.setStyleName(Reindeer.PANEL_LIGHT);
- h.addComponent(p);
- ListSelect l = new ListSelect("ITEM_CAPTION_MODE_PROPERTY");
- l.setContainerDataSource(cont);
- l.setItemCaptionPropertyId("Asd");
- l.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
- p.addComponent(l);
- l = new ListSelect("ITEM_CAPTION_MODE_ITEM");
- l.setContainerDataSource(cont);
- l.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
- p.addComponent(l);
- }
-}
+/**
+ *
+ */
+package com.vaadin.tests;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.ContainerHierarchicalWrapper;
+import com.vaadin.data.util.ContainerOrderedWrapper;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
+
+/**
+ * @author marc
+ *
+ */
+public class TestContainerChanges extends CustomComponent {
+ Container cont = new IndexedContainer();
+ Container hierarchical = new ContainerHierarchicalWrapper(cont);
+ Container ordered = new ContainerOrderedWrapper(cont);
+
+ int cnt = 0;
+ Table tbl;
+
+ public TestContainerChanges() {
+
+ cont.addContainerProperty("Asd", String.class, "qwe");
+ cont.addContainerProperty("Bar", String.class, "foo");
+
+ VerticalLayout main = new VerticalLayout();
+ setCompositionRoot(main);
+
+ main.addComponent(new Label(
+ "The same IndexedContainer is wrapped in a ordered/hierarchical wrapper and is set as data source for all components . The buttons only affect the 'original' IndexedContainer."));
+
+ HorizontalLayout h = new HorizontalLayout();
+
+ main.addComponent(h);
+
+ VerticalLayout v = new VerticalLayout();
+ h.addComponent(v);
+ tbl = new Table();
+ tbl.setHeight("200px");
+ tbl.setWidth("300px");
+ v.addComponent(tbl);
+ tbl.setSelectable(true);
+ tbl.setMultiSelect(false);
+ tbl.setImmediate(true);
+ tbl.setEditable(true);
+ tbl.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ // Original container
+ tbl.setContainerDataSource(hierarchical);
+
+ Table tbl2 = new Table();
+ tbl2.setHeight("200px");
+ tbl2.setWidth("300px");
+ v.addComponent(tbl2);
+ tbl2.setSelectable(true);
+ tbl2.setMultiSelect(false);
+ tbl2.setImmediate(true);
+ tbl2.addListener(new Table.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ System.err.println("Value now "
+ + event.getProperty().getValue());
+
+ }
+ });
+ tbl2.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ // non-ordered container will get wrapped
+ tbl2.setContainerDataSource(hierarchical);
+
+ VerticalLayout buttons = new VerticalLayout();
+ v.addComponent(buttons);
+
+ Button b = new Button("table.commit()", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tbl.commit();
+ }
+
+ });
+ buttons.addComponent(b);
+
+ b = new Button("indexedcontainer.addItem()",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cont.addItem(new Integer(cnt++));
+ }
+
+ });
+ buttons.addComponent(b);
+ b = new Button("indexedcontainer.addItem(null)",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cont.addItem(null);
+ }
+
+ });
+ buttons.addComponent(b);
+ b = new Button("indexedcontainer.removeItem(table.lastItemId()",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cont.removeItem(tbl.lastItemId());
+ }
+
+ });
+ buttons.addComponent(b);
+
+ b = new Button("indexedcontainer.addContainerProperty()",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cont.addContainerProperty("prop" + cnt, String.class,
+ "#" + cnt++);
+ }
+
+ });
+ buttons.addComponent(b);
+
+ b = new Button("indexedcontainer.clear()", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cont.removeAllItems();
+ }
+
+ });
+ buttons.addComponent(b);
+ b = new Button("table.setContainerDataSource(indexedcontainer)",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tbl.setContainerDataSource(cont);
+ }
+
+ });
+ buttons.addComponent(b);
+ b = new Button("table.setContainerDataSource(orderedwrapper)",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tbl.setContainerDataSource(ordered);
+ }
+
+ });
+ buttons.addComponent(b);
+ b = new Button("table.setContainerDataSource(hierarchicalwrapper)",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tbl.setContainerDataSource(hierarchical);
+ }
+
+ });
+ buttons.addComponent(b);
+
+ Panel p = new Panel("Tree");
+ p.setStyleName(Reindeer.PANEL_LIGHT);
+ h.addComponent(p);
+ Tree tree = new Tree("ITEM_CAPTION_MODE_PROPERTY");
+ tree.setContainerDataSource(ordered);
+ tree.setItemCaptionPropertyId("Asd");
+ tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);
+ p.addComponent(tree);
+ tree = new Tree("ITEM_CAPTION_MODE_ITEM");
+ // nonhierarchical container will get wrapped
+ tree.setContainerDataSource(ordered);
+ tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_ITEM);
+ p.addComponent(tree);
+
+ p = new Panel("ComboBox");
+ p.setStyleName(Reindeer.PANEL_LIGHT);
+ h.addComponent(p);
+ ComboBox c = new ComboBox("ITEM_CAPTION_MODE_PROPERTY");
+ c.setImmediate(true);
+ c.setContainerDataSource(cont);
+ c.setItemCaptionPropertyId("Asd");
+ c.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
+ p.addComponent(c);
+ c = new ComboBox("ITEM_CAPTION_MODE_ITEM");
+ c.setImmediate(true);
+ c.setContainerDataSource(cont);
+ c.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
+ p.addComponent(c);
+
+ p = new Panel("ListBox");
+ p.setStyleName(Reindeer.PANEL_LIGHT);
+ h.addComponent(p);
+ ListSelect l = new ListSelect("ITEM_CAPTION_MODE_PROPERTY");
+ l.setContainerDataSource(cont);
+ l.setItemCaptionPropertyId("Asd");
+ l.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY);
+ p.addComponent(l);
+ l = new ListSelect("ITEM_CAPTION_MODE_ITEM");
+ l.setContainerDataSource(cont);
+ l.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
+ p.addComponent(l);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/TestDateField.java b/tests/testbench/com/vaadin/tests/TestDateField.java
index 2cd47ca568..5997ee0199 100644
--- a/tests/testbench/com/vaadin/tests/TestDateField.java
+++ b/tests/testbench/com/vaadin/tests/TestDateField.java
@@ -1,74 +1,74 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import java.util.Locale;
-
-import com.vaadin.terminal.ClassResource;
-import com.vaadin.terminal.ErrorMessage;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-/**
- *
- * @author Vaadin Ltd.
- */
-public class TestDateField extends CustomComponent {
-
- VerticalLayout main = new VerticalLayout();
-
- DateField df;
-
- public TestDateField() {
- setCompositionRoot(main);
- createNewView();
- }
-
- public void createNewView() {
- main.removeAllComponents();
- main.addComponent(new Label("DateField"));
-
- df = new DateField();
- main.addComponent(df);
-
- final ErrorMessage errorMsg = new UserError("User error " + df);
- df.setCaption("DateField caption " + df);
- df.setDescription("DateField description " + df);
- df.setComponentError(errorMsg);
- df.setImmediate(true);
- // FIXME: bug #1138 this makes datefield to render with unknown
- // component (UIDL tree debug)
- df.addStyleName("thisShouldBeHarmless");
-
- // Another test: locale
- final DateField df1 = new DateField("US locale");
- main.addComponent(df1);
- df1.setLocale(new Locale("en", "US"));
-
- final DateField df2 = new DateField("DE locale");
- main.addComponent(df2);
- df2.setLocale(new Locale("de", "DE"));
-
- final DateField df3 = new DateField("RU locale");
- main.addComponent(df3);
- df3.setLocale(new Locale("ru", "RU"));
-
- final DateField df4 = new DateField("FI locale");
- main.addComponent(df4);
- df4.setLocale(new Locale("fi", "FI"));
- }
-
- @Override
- public void attach() {
- final ClassResource res = new ClassResource("m.gif",
- super.getApplication());
- df.setIcon(res);
- super.attach();
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests;
+
+import java.util.Locale;
+
+import com.vaadin.terminal.ClassResource;
+import com.vaadin.terminal.ErrorMessage;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ *
+ * @author Vaadin Ltd.
+ */
+public class TestDateField extends CustomComponent {
+
+ VerticalLayout main = new VerticalLayout();
+
+ DateField df;
+
+ public TestDateField() {
+ setCompositionRoot(main);
+ createNewView();
+ }
+
+ public void createNewView() {
+ main.removeAllComponents();
+ main.addComponent(new Label("DateField"));
+
+ df = new DateField();
+ main.addComponent(df);
+
+ final ErrorMessage errorMsg = new UserError("User error " + df);
+ df.setCaption("DateField caption " + df);
+ df.setDescription("DateField description " + df);
+ df.setComponentError(errorMsg);
+ df.setImmediate(true);
+ // FIXME: bug #1138 this makes datefield to render with unknown
+ // component (UIDL tree debug)
+ df.addStyleName("thisShouldBeHarmless");
+
+ // Another test: locale
+ final DateField df1 = new DateField("US locale");
+ main.addComponent(df1);
+ df1.setLocale(new Locale("en", "US"));
+
+ final DateField df2 = new DateField("DE locale");
+ main.addComponent(df2);
+ df2.setLocale(new Locale("de", "DE"));
+
+ final DateField df3 = new DateField("RU locale");
+ main.addComponent(df3);
+ df3.setLocale(new Locale("ru", "RU"));
+
+ final DateField df4 = new DateField("FI locale");
+ main.addComponent(df4);
+ df4.setLocale(new Locale("fi", "FI"));
+ }
+
+ @Override
+ public void attach() {
+ final ClassResource res = new ClassResource("m.gif",
+ super.getApplication());
+ df.setIcon(res);
+ super.attach();
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/TestForBasicApplicationLayout.java b/tests/testbench/com/vaadin/tests/TestForBasicApplicationLayout.java
index dc6bcd71a3..67370039bb 100644
--- a/tests/testbench/com/vaadin/tests/TestForBasicApplicationLayout.java
+++ b/tests/testbench/com/vaadin/tests/TestForBasicApplicationLayout.java
@@ -1,101 +1,101 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests;
-
-import java.util.Locale;
-
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.themes.Reindeer;
-
-public class TestForBasicApplicationLayout extends CustomComponent {
-
- private final Button click;
- private final Button click2;
- private final TabSheet tab;
-
- public TestForBasicApplicationLayout() {
-
- click = new Button("Set height -1", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tab.setHeight(null);
- }
-
- });
-
- click2 = new Button("Set height 100%", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tab.setHeight(100, TabSheet.UNITS_PERCENTAGE);
- }
-
- });
-
- final HorizontalSplitPanel sp = new HorizontalSplitPanel();
- sp.setSplitPosition(290, Sizeable.UNITS_PIXELS);
-
- final HorizontalSplitPanel sp2 = new HorizontalSplitPanel();
- sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);
-
- final Panel p = new Panel("Accordion Panel");
- p.setSizeFull();
-
- tab = new TabSheet();
- tab.setSizeFull();
-
- final Panel report = new Panel("Monthly Program Runs",
- new VerticalLayout());
- final VerticalLayout controls = new VerticalLayout();
- controls.setMargin(true);
- controls.addComponent(new Label("Report tab"));
- controls.addComponent(click);
- controls.addComponent(click2);
- report.addComponent(controls);
- final DateField cal = new DateField();
- cal.setResolution(DateField.RESOLUTION_DAY);
- cal.setLocale(new Locale("en", "US"));
- report.addComponent(cal);
- ((VerticalLayout) report.getContent()).setExpandRatio(controls, 1);
- report.addStyleName(Reindeer.PANEL_LIGHT);
- report.setHeight(100, Sizeable.UNITS_PERCENTAGE);
-
- sp2.setFirstComponent(report);
-
- final Table table = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(5, 200);
- table.setPageLength(15);
- table.setSelectable(true);
- table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);
- table.setColumnCollapsingAllowed(true);
- table.setColumnReorderingAllowed(true);
- table.setSortDisabled(false);
- table.setSizeFull();
- table.addStyleName("table-inline");
- sp2.setSecondComponent(table);
-
- tab.addTab(new Label("Tab1"), "Summary", null);
- tab.addTab(sp2, "Reports", null);
- tab.addTab(new Label("Tab 3"), "Statistics", null);
- tab.addTab(new Label("Tab 4"), "Error Tracking", null);
- tab.setSelectedTab(sp2);
-
- sp.setFirstComponent(p);
- sp.setSecondComponent(tab);
-
- setCompositionRoot(sp);
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests;
+
+import java.util.Locale;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
+
+public class TestForBasicApplicationLayout extends CustomComponent {
+
+ private final Button click;
+ private final Button click2;
+ private final TabSheet tab;
+
+ public TestForBasicApplicationLayout() {
+
+ click = new Button("Set height -1", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tab.setHeight(null);
+ }
+
+ });
+
+ click2 = new Button("Set height 100%", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tab.setHeight(100, TabSheet.UNITS_PERCENTAGE);
+ }
+
+ });
+
+ final HorizontalSplitPanel sp = new HorizontalSplitPanel();
+ sp.setSplitPosition(290, Sizeable.UNITS_PIXELS);
+
+ final HorizontalSplitPanel sp2 = new HorizontalSplitPanel();
+ sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);
+
+ final Panel p = new Panel("Accordion Panel");
+ p.setSizeFull();
+
+ tab = new TabSheet();
+ tab.setSizeFull();
+
+ final Panel report = new Panel("Monthly Program Runs",
+ new VerticalLayout());
+ final VerticalLayout controls = new VerticalLayout();
+ controls.setMargin(true);
+ controls.addComponent(new Label("Report tab"));
+ controls.addComponent(click);
+ controls.addComponent(click2);
+ report.addComponent(controls);
+ final DateField cal = new DateField();
+ cal.setResolution(DateField.RESOLUTION_DAY);
+ cal.setLocale(new Locale("en", "US"));
+ report.addComponent(cal);
+ ((VerticalLayout) report.getContent()).setExpandRatio(controls, 1);
+ report.addStyleName(Reindeer.PANEL_LIGHT);
+ report.setHeight(100, Sizeable.UNITS_PERCENTAGE);
+
+ sp2.setFirstComponent(report);
+
+ final Table table = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(5, 200);
+ table.setPageLength(15);
+ table.setSelectable(true);
+ table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);
+ table.setColumnCollapsingAllowed(true);
+ table.setColumnReorderingAllowed(true);
+ table.setSortDisabled(false);
+ table.setSizeFull();
+ table.addStyleName("table-inline");
+ sp2.setSecondComponent(table);
+
+ tab.addTab(new Label("Tab1"), "Summary", null);
+ tab.addTab(sp2, "Reports", null);
+ tab.addTab(new Label("Tab 3"), "Statistics", null);
+ tab.addTab(new Label("Tab 4"), "Error Tracking", null);
+ tab.setSelectedTab(sp2);
+
+ sp.setFirstComponent(p);
+ sp.setSecondComponent(tab);
+
+ setCompositionRoot(sp);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/application/ApplicationCloseTest.java b/tests/testbench/com/vaadin/tests/application/ApplicationCloseTest.java
index b10752d26c..3d767eb016 100644
--- a/tests/testbench/com/vaadin/tests/application/ApplicationCloseTest.java
+++ b/tests/testbench/com/vaadin/tests/application/ApplicationCloseTest.java
@@ -1,70 +1,70 @@
-package com.vaadin.tests.application;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.gwt.server.WebApplicationContext;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-
-public class ApplicationCloseTest extends TestBase {
-
- private String memoryConsumer;
-
- @Override
- protected void setup() {
- Label applications = new Label("Applications in session: <br/>",
- Label.CONTENT_XHTML);
- for (Application a : ((WebApplicationContext) getContext())
- .getApplications()) {
- applications.setValue(applications.getValue() + "App: " + a
- + "<br/>");
- }
- applications.setValue(applications.getValue() + "<br/><br/>");
-
- addComponent(applications);
- Label thisApp = new Label("This applications: " + this);
- Button close = new Button("Close this", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- event.getButton().getApplication().close();
- }
- });
-
- StringBuilder sb = new StringBuilder();
-
- // 100 bytes
- String str = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
-
- int MB = 5;
- for (int i = 0; i < MB * 10000; i++) {
- sb.append(str);
- }
-
- memoryConsumer = sb.toString();
- long totalUsage = Runtime.getRuntime().totalMemory();
- String totalUsageString = totalUsage / 1000 / 1000 + "MiB";
- Label memoryUsage = new Label(
- "Using about "
- + memoryConsumer.length()
- / 1000
- / 1000
- + "MiB memory for this application.<br/>Total memory usage reported as "
- + totalUsageString + "<br/>", Label.CONTENT_XHTML);
-
- addComponent(thisApp);
- addComponent(memoryUsage);
- addComponent(close);
- }
-
- @Override
- protected String getDescription() {
- return "Click close to close the application and open a new one";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3732;
- }
-
-}
+package com.vaadin.tests.application;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.gwt.server.WebApplicationContext;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class ApplicationCloseTest extends TestBase {
+
+ private String memoryConsumer;
+
+ @Override
+ protected void setup() {
+ Label applications = new Label("Applications in session: <br/>",
+ Label.CONTENT_XHTML);
+ for (Application a : ((WebApplicationContext) getContext())
+ .getApplications()) {
+ applications.setValue(applications.getValue() + "App: " + a
+ + "<br/>");
+ }
+ applications.setValue(applications.getValue() + "<br/><br/>");
+
+ addComponent(applications);
+ Label thisApp = new Label("This applications: " + this);
+ Button close = new Button("Close this", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ event.getButton().getApplication().close();
+ }
+ });
+
+ StringBuilder sb = new StringBuilder();
+
+ // 100 bytes
+ String str = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
+
+ int MB = 5;
+ for (int i = 0; i < MB * 10000; i++) {
+ sb.append(str);
+ }
+
+ memoryConsumer = sb.toString();
+ long totalUsage = Runtime.getRuntime().totalMemory();
+ String totalUsageString = totalUsage / 1000 / 1000 + "MiB";
+ Label memoryUsage = new Label(
+ "Using about "
+ + memoryConsumer.length()
+ / 1000
+ / 1000
+ + "MiB memory for this application.<br/>Total memory usage reported as "
+ + totalUsageString + "<br/>", Label.CONTENT_XHTML);
+
+ addComponent(thisApp);
+ addComponent(memoryUsage);
+ addComponent(close);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click close to close the application and open a new one";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3732;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
index 31e7534042..4508e4ef90 100644
--- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
@@ -1,98 +1,98 @@
-package com.vaadin.tests.application;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.TimeZone;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-
-public class WebBrowserTest extends TestBase {
-
- @Override
- protected void setup() {
-
- final Label offsetLabel = new Label("n/a");
- offsetLabel.setCaption("Browser offset");
-
- final Label rawOffsetLabel = new Label("n/a");
- rawOffsetLabel.setCaption("Browser raw offset");
-
- final Label dstDiffLabel = new Label("n/a");
- dstDiffLabel.setCaption("Difference between raw offset and DST");
-
- final Label dstInEffectLabel = new Label("n/a");
- dstInEffectLabel.setCaption("Is DST currently active?");
-
- final Label curDateLabel = new Label("n/a");
- curDateLabel.setCaption("Current date in the browser");
-
- final Label diffLabel = new Label("n/a");
- diffLabel.setCaption("Browser to Europe/Helsinki offset difference");
-
- final Label containsLabel = new Label("n/a");
- containsLabel.setCaption("Browser could be in Helsinki");
-
- final Button update = new Button("Get TimeZone from browser",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- TimeZone hkiTZ = TimeZone
- .getTimeZone("Europe/Helsinki");
- int hkiOffset = hkiTZ.getOffset(new Date().getTime());
-
- int browserOffset = getBrowser().getTimezoneOffset();
- int browserRawOffset = getBrowser()
- .getRawTimezoneOffset();
- String[] tzs = TimeZone
- .getAvailableIDs(browserRawOffset);
-
- boolean contains = Arrays.asList(tzs).contains(
- hkiTZ.getID());
-
- offsetLabel.setValue(String.valueOf(browserOffset));
-
- rawOffsetLabel.setValue(String
- .valueOf(browserRawOffset));
-
- diffLabel.setValue(String.valueOf(browserOffset
- - hkiOffset));
-
- containsLabel.setValue(contains ? "Yes" : "No");
-
- dstDiffLabel.setValue(String.valueOf(getBrowser()
- .getDSTSavings()));
-
- dstInEffectLabel
- .setValue(getBrowser().isDSTInEffect() ? "Yes"
- : "No");
-
- curDateLabel.setValue(getBrowser().getCurrentDate()
- .toString());
-
- }
- });
-
- addComponent(update);
- addComponent(offsetLabel);
- addComponent(rawOffsetLabel);
- addComponent(dstDiffLabel);
- addComponent(dstInEffectLabel);
- addComponent(curDateLabel);
- addComponent(diffLabel);
- addComponent(containsLabel);
- }
-
- @Override
- protected String getDescription() {
- return "Verifies that browser TimeZone offset works - should be same as server in our case (NOTE assumes server+browser in same TZ)";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6691;
- }
-
-}
+package com.vaadin.tests.application;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.TimeZone;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class WebBrowserTest extends TestBase {
+
+ @Override
+ protected void setup() {
+
+ final Label offsetLabel = new Label("n/a");
+ offsetLabel.setCaption("Browser offset");
+
+ final Label rawOffsetLabel = new Label("n/a");
+ rawOffsetLabel.setCaption("Browser raw offset");
+
+ final Label dstDiffLabel = new Label("n/a");
+ dstDiffLabel.setCaption("Difference between raw offset and DST");
+
+ final Label dstInEffectLabel = new Label("n/a");
+ dstInEffectLabel.setCaption("Is DST currently active?");
+
+ final Label curDateLabel = new Label("n/a");
+ curDateLabel.setCaption("Current date in the browser");
+
+ final Label diffLabel = new Label("n/a");
+ diffLabel.setCaption("Browser to Europe/Helsinki offset difference");
+
+ final Label containsLabel = new Label("n/a");
+ containsLabel.setCaption("Browser could be in Helsinki");
+
+ final Button update = new Button("Get TimeZone from browser",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ TimeZone hkiTZ = TimeZone
+ .getTimeZone("Europe/Helsinki");
+ int hkiOffset = hkiTZ.getOffset(new Date().getTime());
+
+ int browserOffset = getBrowser().getTimezoneOffset();
+ int browserRawOffset = getBrowser()
+ .getRawTimezoneOffset();
+ String[] tzs = TimeZone
+ .getAvailableIDs(browserRawOffset);
+
+ boolean contains = Arrays.asList(tzs).contains(
+ hkiTZ.getID());
+
+ offsetLabel.setValue(String.valueOf(browserOffset));
+
+ rawOffsetLabel.setValue(String
+ .valueOf(browserRawOffset));
+
+ diffLabel.setValue(String.valueOf(browserOffset
+ - hkiOffset));
+
+ containsLabel.setValue(contains ? "Yes" : "No");
+
+ dstDiffLabel.setValue(String.valueOf(getBrowser()
+ .getDSTSavings()));
+
+ dstInEffectLabel
+ .setValue(getBrowser().isDSTInEffect() ? "Yes"
+ : "No");
+
+ curDateLabel.setValue(getBrowser().getCurrentDate()
+ .toString());
+ }
+ });
+
+ addComponent(update);
+ addComponent(offsetLabel);
+ addComponent(rawOffsetLabel);
+ addComponent(dstDiffLabel);
+ addComponent(dstInEffectLabel);
+ addComponent(curDateLabel);
+ addComponent(diffLabel);
+ addComponent(containsLabel);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Verifies that browser TimeZone offset works - should be same as server in our case (NOTE assumes server+browser in same TZ)";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6691;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java b/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java
index ddbbc49e68..c0141a72d5 100644
--- a/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java
+++ b/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java
@@ -1,69 +1,69 @@
-package com.vaadin.tests.applicationcontext;
-
-import com.vaadin.terminal.gwt.server.WebApplicationContext;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Window;
-
-public class ChangeSessionId extends AbstractTestCase {
-
- private Log log = new Log(5);
- Button loginButton = new Button("Change session");
- boolean requestSessionSwitch = false;
-
- @Override
- public void init() {
- Window mainWindow = new Window("Sestest Application");
- mainWindow.addComponent(log);
- mainWindow.addComponent(loginButton);
- mainWindow.addComponent(new Button("Show session id",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- logSessionId();
- }
- }));
- setMainWindow(mainWindow);
-
- loginButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- WebApplicationContext context = ((WebApplicationContext) getContext());
-
- String oldSessionId = context.getHttpSession().getId();
- context.reinitializeSession();
- String newSessionId = context.getHttpSession().getId();
- if (oldSessionId.equals(newSessionId)) {
- log.log("FAILED! Both old and new session id is "
- + newSessionId);
- } else {
- log.log("Session id changed successfully from "
- + oldSessionId + " to " + newSessionId);
- }
-
- }
- });
- logSessionId();
- }
-
- private void logSessionId() {
- log.log("Session id: " + getSessionId());
- }
-
- protected String getSessionId() {
- return ((WebApplicationContext) getContext()).getHttpSession().getId();
- }
-
- @Override
- protected String getDescription() {
- return "Tests that the session id can be changed to prevent session fixation attacks";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6094;
- }
-
+package com.vaadin.tests.applicationcontext;
+
+import com.vaadin.terminal.gwt.server.WebApplicationContext;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Window;
+
+public class ChangeSessionId extends AbstractTestCase {
+
+ private Log log = new Log(5);
+ Button loginButton = new Button("Change session");
+ boolean requestSessionSwitch = false;
+
+ @Override
+ public void init() {
+ Window mainWindow = new Window("Sestest Application");
+ mainWindow.addComponent(log);
+ mainWindow.addComponent(loginButton);
+ mainWindow.addComponent(new Button("Show session id",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ logSessionId();
+ }
+ }));
+ setMainWindow(mainWindow);
+
+ loginButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ WebApplicationContext context = ((WebApplicationContext) getContext());
+
+ String oldSessionId = context.getHttpSession().getId();
+ context.reinitializeSession();
+ String newSessionId = context.getHttpSession().getId();
+ if (oldSessionId.equals(newSessionId)) {
+ log.log("FAILED! Both old and new session id is "
+ + newSessionId);
+ } else {
+ log.log("Session id changed successfully from "
+ + oldSessionId + " to " + newSessionId);
+ }
+
+ }
+ });
+ logSessionId();
+ }
+
+ private void logSessionId() {
+ log.log("Session id: " + getSessionId());
+ }
+
+ protected String getSessionId() {
+ return ((WebApplicationContext) getContext()).getHttpSession().getId();
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests that the session id can be changed to prevent session fixation attacks";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6094;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/applicationservlet/NoMainWindow.java b/tests/testbench/com/vaadin/tests/applicationservlet/NoMainWindow.java
index 9097274236..fc72b86a34 100644
--- a/tests/testbench/com/vaadin/tests/applicationservlet/NoMainWindow.java
+++ b/tests/testbench/com/vaadin/tests/applicationservlet/NoMainWindow.java
@@ -1,22 +1,22 @@
-package com.vaadin.tests.applicationservlet;
-
-import com.vaadin.tests.components.AbstractTestCase;
-
-public class NoMainWindow extends AbstractTestCase {
-
- @Override
- protected String getDescription() {
- return "This should produce an stack trace with \"No window found. Did you remember to setMainWindow()?\"";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3349;
- }
-
- @Override
- public void init() {
-
- }
-
-}
+package com.vaadin.tests.applicationservlet;
+
+import com.vaadin.tests.components.AbstractTestCase;
+
+public class NoMainWindow extends AbstractTestCase {
+
+ @Override
+ protected String getDescription() {
+ return "This should produce an stack trace with \"No window found. Did you remember to setMainWindow()?\"";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3349;
+ }
+
+ @Override
+ public void init() {
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractComponentContainerTest.java b/tests/testbench/com/vaadin/tests/components/AbstractComponentContainerTest.java
index 0c9c9c4ae2..2a98988487 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractComponentContainerTest.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractComponentContainerTest.java
@@ -1,356 +1,356 @@
-package com.vaadin.tests.components;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-
-import com.vaadin.ui.AbstractComponentContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer.ComponentAttachEvent;
-import com.vaadin.ui.ComponentContainer.ComponentAttachListener;
-import com.vaadin.ui.ComponentContainer.ComponentDetachEvent;
-import com.vaadin.ui.ComponentContainer.ComponentDetachListener;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.InlineDateField;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.PopupDateField;
-import com.vaadin.ui.RichTextArea;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalSplitPanel;
-
-public abstract class AbstractComponentContainerTest<T extends AbstractComponentContainer>
- extends AbstractComponentTest<T> implements ComponentAttachListener,
- ComponentDetachListener {
-
- private String CATEGORY_COMPONENT_CONTAINER_FEATURES = "Component container features";
- private Command<T, ComponentSize> addButtonCommand = new Command<T, ComponentSize>() {
-
- public void execute(T c, ComponentSize size, Object data) {
- Button b = new Button("A button");
- c.addComponent(b);
- size.apply(b);
- }
- };
-
- private Command<T, ComponentSize> addNativeButtonCommand = new Command<T, ComponentSize>() {
-
- public void execute(T c, ComponentSize size, Object data) {
- NativeButton b = new NativeButton("Native button");
- c.addComponent(b);
- size.apply(b);
- }
- };
-
- private Command<T, ComponentSize> addTextAreaCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- TextArea ta = new TextArea();
- c.addComponent(ta);
- size.apply(ta);
- }
- };
-
- private Command<T, ComponentSize> addRichTextAreaCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- RichTextArea ta = new RichTextArea();
- c.addComponent(ta);
- size.apply(ta);
- }
- };
-
- private Command<T, ComponentSize> addTextFieldCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- TextField tf = new TextField();
- c.addComponent(tf);
- size.apply(tf);
- }
- };
-
- private Command<T, ComponentSize> addInlineDateFieldCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- InlineDateField tf = new InlineDateField();
- c.addComponent(tf);
- size.apply(tf);
- }
- };
- private Command<T, ComponentSize> addPopupDateFieldCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- PopupDateField tf = new PopupDateField();
- c.addComponent(tf);
- size.apply(tf);
- }
- };
-
- private Command<T, ComponentSize> addVerticalSplitPanelCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- VerticalSplitPanel vsp = new VerticalSplitPanel();
- c.addComponent(vsp);
- size.apply(vsp);
- }
- };
-
- private Command<T, ComponentSize> addHorizontalSplitPanelCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- HorizontalSplitPanel vsp = new HorizontalSplitPanel();
- c.addComponent(vsp);
- size.apply(vsp);
- }
- };
-
- private Command<T, ComponentSize> addTabSheetCommand = new Command<T, ComponentSize>() {
- public void execute(T c, ComponentSize size, Object data) {
- TabSheet ts = createTabSheet();
- c.addComponent(ts);
- size.apply(ts);
- }
- };
-
- private Command<T, ComponentSize> addTableCommand = new Command<T, ComponentSize>() {
-
- public void execute(T c, ComponentSize size, Object data) {
- Table t = createTable();
- c.addComponent(t);
- size.apply(t);
- }
- };
- private Command<T, Object> removeAllComponentsCommand = new Command<T, Object>() {
- public void execute(T c, Object value, Object data) {
- c.removeAllComponents();
- }
- };
- private Command<T, Integer> removeComponentByIndexCommand = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- Component child = getComponentAtIndex(c, value);
- c.removeComponent(child);
-
- }
- };
- private Command<T, Boolean> componentAttachListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((ComponentAttachListener) AbstractComponentContainerTest.this);
- } else {
- c.removeListener((ComponentAttachListener) AbstractComponentContainerTest.this);
- }
- }
- };
-
- private Command<T, Boolean> componentDetachListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((ComponentDetachListener) AbstractComponentContainerTest.this);
- } else {
- c.removeListener((ComponentDetachListener) AbstractComponentContainerTest.this);
- }
- }
- };
-
- private Command<T, Integer> setComponentHeight = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- Component child = getComponentAtIndex(c, value);
- child.setHeight((String) data);
-
- }
- };
-
- private Command<T, Integer> setComponentWidth = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- Component child = getComponentAtIndex(c, value);
- child.setWidth((String) data);
-
- }
- };
-
- protected static class ComponentSize {
- private String width, height;
-
- public ComponentSize(String width, String height) {
- this.width = width;
- this.height = height;
- }
-
- public void apply(Component target) {
- target.setWidth(width);
- target.setHeight(height);
- }
-
- public String getWidth() {
- return width;
- }
-
- public String getHeight() {
- return height;
- }
-
- @Override
- public String toString() {
- String s = "";
- s += width == null ? "auto" : width;
- s += " x ";
- s += height == null ? "auto" : height;
- return s;
- }
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createAddComponentActions(CATEGORY_COMPONENT_CONTAINER_FEATURES);
- createRemoveComponentActions(CATEGORY_COMPONENT_CONTAINER_FEATURES);
- createChangeComponentSizeActions(CATEGORY_COMPONENT_CONTAINER_FEATURES);
- createComponentAttachListener(CATEGORY_LISTENERS);
- createComponentDetachListener(CATEGORY_LISTENERS);
- }
-
- protected Component getComponentAtIndex(T container, int value) {
- Iterator<Component> iter = container.getComponentIterator();
- for (int i = 0; i < value; i++) {
- iter.next();
- }
-
- return iter.next();
- }
-
- protected Table createTable() {
- Table t = new Table();
- t.addContainerProperty("property 1", String.class, "");
- t.addContainerProperty("property 2", String.class, "");
- t.addContainerProperty("property 3", String.class, "");
- for (int i = 1; i < 10; i++) {
- t.addItem(new Object[] { "row/col " + i + "/1",
- "row/col " + i + "/2", "row/col " + i + "/3" },
- String.valueOf(i));
- }
- return t;
- }
-
- protected TabSheet createTabSheet() {
- TabSheet ts = new TabSheet();
- Table t = createTable();
- t.setSizeFull();
- ts.addTab(t, "Size full Table", ICON_16_USER_PNG_UNCACHEABLE);
- ts.addTab(new Button("A button"), "Button", null);
- return ts;
- }
-
- private void createComponentAttachListener(String category) {
- createBooleanAction("Component attach listener", category, false,
- componentAttachListenerCommand);
-
- }
-
- private void createComponentDetachListener(String category) {
- createBooleanAction("Component detach listener", category, false,
- componentDetachListenerCommand);
-
- }
-
- private void createRemoveComponentActions(String category) {
- String subCategory = "Remove component";
- String byIndexCategory = "By index";
-
- createCategory(subCategory, category);
- createCategory(byIndexCategory, subCategory);
- createClickAction("Remove all components", subCategory,
- removeAllComponentsCommand, null);
- for (int i = 0; i < 20; i++) {
- createClickAction("Remove component " + i, byIndexCategory,
- removeComponentByIndexCommand, Integer.valueOf(i));
- }
-
- }
-
- private void createAddComponentActions(String category) {
- String subCategory = "Add component";
- createCategory(subCategory, category);
-
- LinkedHashMap<String, Command<T, ComponentSize>> addCommands = new LinkedHashMap<String, AbstractComponentTestCase.Command<T, ComponentSize>>();
- addCommands.put("Button", addButtonCommand);
- addCommands.put("NativeButton", addNativeButtonCommand);
- addCommands.put("TextField", addTextFieldCommand);
- addCommands.put("TextArea", addTextAreaCommand);
- addCommands.put("RichTextArea", addRichTextAreaCommand);
- addCommands.put("TabSheet", addTabSheetCommand);
- addCommands.put("Table", addTableCommand);
- addCommands.put("InlineDateField", addInlineDateFieldCommand);
- addCommands.put("PopupDateField", addPopupDateFieldCommand);
- addCommands.put("VerticalSplitPanel", addVerticalSplitPanelCommand);
- addCommands.put("HorizontalSplitPanel", addHorizontalSplitPanelCommand);
- // addCommands.put("AbsoluteLayout", addAbsoluteLayoutCommand);
- // addCommands.put("HorizontalLayout", addHorizontalLayoutCommand);
- // addCommands.put("VerticalLayout", addVerticalLayoutCommand);
-
- ComponentSize[] sizes = new ComponentSize[] {
- new ComponentSize(null, null),
- new ComponentSize("200px", null),
- new ComponentSize("100%", null),
- new ComponentSize(null, "200px"),
- new ComponentSize(null, "100%"),
- new ComponentSize("300px", "300px"),
- new ComponentSize("100%", "100%"),
-
- };
-
- for (String componentCategory : addCommands.keySet()) {
- createCategory(componentCategory, subCategory);
-
- for (ComponentSize size : sizes) {
- createClickAction(size.toString(), componentCategory,
- addCommands.get(componentCategory), size);
- }
- }
-
- }
-
- private void createChangeComponentSizeActions(String category) {
- String widthCategory = "Change component width";
- createCategory(widthCategory, category);
- String heightCategory = "Change component height";
- createCategory(heightCategory, category);
-
- String[] options = new String[] { "100px", "200px", "50%", "100%" };
- for (int i = 0; i < 20; i++) {
- String componentWidthCategory = "Component " + i + " width";
- String componentHeightCategory = "Component " + i + " height";
- createCategory(componentWidthCategory, widthCategory);
- createCategory(componentHeightCategory, heightCategory);
-
- createClickAction("auto", componentHeightCategory,
- setComponentHeight, Integer.valueOf(i), null);
- createClickAction("auto", componentWidthCategory,
- setComponentWidth, Integer.valueOf(i), null);
- for (String option : options) {
- createClickAction(option, componentHeightCategory,
- setComponentHeight, Integer.valueOf(i), option);
- createClickAction(option, componentWidthCategory,
- setComponentWidth, Integer.valueOf(i), option);
- }
-
- }
-
- }
-
- public void componentDetachedFromContainer(ComponentDetachEvent event) {
- log(event.getClass().getSimpleName() + ": "
- + event.getDetachedComponent().getClass().getSimpleName()
- + " detached from "
- + event.getContainer().getClass().getSimpleName());
- }
-
- public void componentAttachedToContainer(ComponentAttachEvent event) {
- log(event.getClass().getSimpleName() + ": "
- + event.getAttachedComponent().getClass().getSimpleName()
- + " attached to "
- + event.getContainer().getClass().getSimpleName());
-
- }
-
-}
+package com.vaadin.tests.components;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+
+import com.vaadin.ui.AbstractComponentContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer.ComponentAttachEvent;
+import com.vaadin.ui.ComponentContainer.ComponentAttachListener;
+import com.vaadin.ui.ComponentContainer.ComponentDetachEvent;
+import com.vaadin.ui.ComponentContainer.ComponentDetachListener;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.InlineDateField;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.PopupDateField;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalSplitPanel;
+
+public abstract class AbstractComponentContainerTest<T extends AbstractComponentContainer>
+ extends AbstractComponentTest<T> implements ComponentAttachListener,
+ ComponentDetachListener {
+
+ private String CATEGORY_COMPONENT_CONTAINER_FEATURES = "Component container features";
+ private Command<T, ComponentSize> addButtonCommand = new Command<T, ComponentSize>() {
+
+ public void execute(T c, ComponentSize size, Object data) {
+ Button b = new Button("A button");
+ c.addComponent(b);
+ size.apply(b);
+ }
+ };
+
+ private Command<T, ComponentSize> addNativeButtonCommand = new Command<T, ComponentSize>() {
+
+ public void execute(T c, ComponentSize size, Object data) {
+ NativeButton b = new NativeButton("Native button");
+ c.addComponent(b);
+ size.apply(b);
+ }
+ };
+
+ private Command<T, ComponentSize> addTextAreaCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ TextArea ta = new TextArea();
+ c.addComponent(ta);
+ size.apply(ta);
+ }
+ };
+
+ private Command<T, ComponentSize> addRichTextAreaCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ RichTextArea ta = new RichTextArea();
+ c.addComponent(ta);
+ size.apply(ta);
+ }
+ };
+
+ private Command<T, ComponentSize> addTextFieldCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ TextField tf = new TextField();
+ c.addComponent(tf);
+ size.apply(tf);
+ }
+ };
+
+ private Command<T, ComponentSize> addInlineDateFieldCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ InlineDateField tf = new InlineDateField();
+ c.addComponent(tf);
+ size.apply(tf);
+ }
+ };
+ private Command<T, ComponentSize> addPopupDateFieldCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ PopupDateField tf = new PopupDateField();
+ c.addComponent(tf);
+ size.apply(tf);
+ }
+ };
+
+ private Command<T, ComponentSize> addVerticalSplitPanelCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ VerticalSplitPanel vsp = new VerticalSplitPanel();
+ c.addComponent(vsp);
+ size.apply(vsp);
+ }
+ };
+
+ private Command<T, ComponentSize> addHorizontalSplitPanelCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ HorizontalSplitPanel vsp = new HorizontalSplitPanel();
+ c.addComponent(vsp);
+ size.apply(vsp);
+ }
+ };
+
+ private Command<T, ComponentSize> addTabSheetCommand = new Command<T, ComponentSize>() {
+ public void execute(T c, ComponentSize size, Object data) {
+ TabSheet ts = createTabSheet();
+ c.addComponent(ts);
+ size.apply(ts);
+ }
+ };
+
+ private Command<T, ComponentSize> addTableCommand = new Command<T, ComponentSize>() {
+
+ public void execute(T c, ComponentSize size, Object data) {
+ Table t = createTable();
+ c.addComponent(t);
+ size.apply(t);
+ }
+ };
+ private Command<T, Object> removeAllComponentsCommand = new Command<T, Object>() {
+ public void execute(T c, Object value, Object data) {
+ c.removeAllComponents();
+ }
+ };
+ private Command<T, Integer> removeComponentByIndexCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ Component child = getComponentAtIndex(c, value);
+ c.removeComponent(child);
+
+ }
+ };
+ private Command<T, Boolean> componentAttachListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ComponentAttachListener) AbstractComponentContainerTest.this);
+ } else {
+ c.removeListener((ComponentAttachListener) AbstractComponentContainerTest.this);
+ }
+ }
+ };
+
+ private Command<T, Boolean> componentDetachListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ComponentDetachListener) AbstractComponentContainerTest.this);
+ } else {
+ c.removeListener((ComponentDetachListener) AbstractComponentContainerTest.this);
+ }
+ }
+ };
+
+ private Command<T, Integer> setComponentHeight = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ Component child = getComponentAtIndex(c, value);
+ child.setHeight((String) data);
+
+ }
+ };
+
+ private Command<T, Integer> setComponentWidth = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ Component child = getComponentAtIndex(c, value);
+ child.setWidth((String) data);
+
+ }
+ };
+
+ protected static class ComponentSize {
+ private String width, height;
+
+ public ComponentSize(String width, String height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ public void apply(Component target) {
+ target.setWidth(width);
+ target.setHeight(height);
+ }
+
+ public String getWidth() {
+ return width;
+ }
+
+ public String getHeight() {
+ return height;
+ }
+
+ @Override
+ public String toString() {
+ String s = "";
+ s += width == null ? "auto" : width;
+ s += " x ";
+ s += height == null ? "auto" : height;
+ return s;
+ }
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createAddComponentActions(CATEGORY_COMPONENT_CONTAINER_FEATURES);
+ createRemoveComponentActions(CATEGORY_COMPONENT_CONTAINER_FEATURES);
+ createChangeComponentSizeActions(CATEGORY_COMPONENT_CONTAINER_FEATURES);
+ createComponentAttachListener(CATEGORY_LISTENERS);
+ createComponentDetachListener(CATEGORY_LISTENERS);
+ }
+
+ protected Component getComponentAtIndex(T container, int value) {
+ Iterator<Component> iter = container.getComponentIterator();
+ for (int i = 0; i < value; i++) {
+ iter.next();
+ }
+
+ return iter.next();
+ }
+
+ protected Table createTable() {
+ Table t = new Table();
+ t.addContainerProperty("property 1", String.class, "");
+ t.addContainerProperty("property 2", String.class, "");
+ t.addContainerProperty("property 3", String.class, "");
+ for (int i = 1; i < 10; i++) {
+ t.addItem(new Object[] { "row/col " + i + "/1",
+ "row/col " + i + "/2", "row/col " + i + "/3" },
+ String.valueOf(i));
+ }
+ return t;
+ }
+
+ protected TabSheet createTabSheet() {
+ TabSheet ts = new TabSheet();
+ Table t = createTable();
+ t.setSizeFull();
+ ts.addTab(t, "Size full Table", ICON_16_USER_PNG_UNCACHEABLE);
+ ts.addTab(new Button("A button"), "Button", null);
+ return ts;
+ }
+
+ private void createComponentAttachListener(String category) {
+ createBooleanAction("Component attach listener", category, false,
+ componentAttachListenerCommand);
+
+ }
+
+ private void createComponentDetachListener(String category) {
+ createBooleanAction("Component detach listener", category, false,
+ componentDetachListenerCommand);
+
+ }
+
+ private void createRemoveComponentActions(String category) {
+ String subCategory = "Remove component";
+ String byIndexCategory = "By index";
+
+ createCategory(subCategory, category);
+ createCategory(byIndexCategory, subCategory);
+ createClickAction("Remove all components", subCategory,
+ removeAllComponentsCommand, null);
+ for (int i = 0; i < 20; i++) {
+ createClickAction("Remove component " + i, byIndexCategory,
+ removeComponentByIndexCommand, Integer.valueOf(i));
+ }
+
+ }
+
+ private void createAddComponentActions(String category) {
+ String subCategory = "Add component";
+ createCategory(subCategory, category);
+
+ LinkedHashMap<String, Command<T, ComponentSize>> addCommands = new LinkedHashMap<String, AbstractComponentTestCase.Command<T, ComponentSize>>();
+ addCommands.put("Button", addButtonCommand);
+ addCommands.put("NativeButton", addNativeButtonCommand);
+ addCommands.put("TextField", addTextFieldCommand);
+ addCommands.put("TextArea", addTextAreaCommand);
+ addCommands.put("RichTextArea", addRichTextAreaCommand);
+ addCommands.put("TabSheet", addTabSheetCommand);
+ addCommands.put("Table", addTableCommand);
+ addCommands.put("InlineDateField", addInlineDateFieldCommand);
+ addCommands.put("PopupDateField", addPopupDateFieldCommand);
+ addCommands.put("VerticalSplitPanel", addVerticalSplitPanelCommand);
+ addCommands.put("HorizontalSplitPanel", addHorizontalSplitPanelCommand);
+ // addCommands.put("AbsoluteLayout", addAbsoluteLayoutCommand);
+ // addCommands.put("HorizontalLayout", addHorizontalLayoutCommand);
+ // addCommands.put("VerticalLayout", addVerticalLayoutCommand);
+
+ ComponentSize[] sizes = new ComponentSize[] {
+ new ComponentSize(null, null),
+ new ComponentSize("200px", null),
+ new ComponentSize("100%", null),
+ new ComponentSize(null, "200px"),
+ new ComponentSize(null, "100%"),
+ new ComponentSize("300px", "300px"),
+ new ComponentSize("100%", "100%"),
+
+ };
+
+ for (String componentCategory : addCommands.keySet()) {
+ createCategory(componentCategory, subCategory);
+
+ for (ComponentSize size : sizes) {
+ createClickAction(size.toString(), componentCategory,
+ addCommands.get(componentCategory), size);
+ }
+ }
+
+ }
+
+ private void createChangeComponentSizeActions(String category) {
+ String widthCategory = "Change component width";
+ createCategory(widthCategory, category);
+ String heightCategory = "Change component height";
+ createCategory(heightCategory, category);
+
+ String[] options = new String[] { "100px", "200px", "50%", "100%" };
+ for (int i = 0; i < 20; i++) {
+ String componentWidthCategory = "Component " + i + " width";
+ String componentHeightCategory = "Component " + i + " height";
+ createCategory(componentWidthCategory, widthCategory);
+ createCategory(componentHeightCategory, heightCategory);
+
+ createClickAction("auto", componentHeightCategory,
+ setComponentHeight, Integer.valueOf(i), null);
+ createClickAction("auto", componentWidthCategory,
+ setComponentWidth, Integer.valueOf(i), null);
+ for (String option : options) {
+ createClickAction(option, componentHeightCategory,
+ setComponentHeight, Integer.valueOf(i), option);
+ createClickAction(option, componentWidthCategory,
+ setComponentWidth, Integer.valueOf(i), option);
+ }
+
+ }
+
+ }
+
+ public void componentDetachedFromContainer(ComponentDetachEvent event) {
+ log(event.getClass().getSimpleName() + ": "
+ + event.getDetachedComponent().getClass().getSimpleName()
+ + " detached from "
+ + event.getContainer().getClass().getSimpleName());
+ }
+
+ public void componentAttachedToContainer(ComponentAttachEvent event) {
+ log(event.getClass().getSimpleName() + ": "
+ + event.getAttachedComponent().getClass().getSimpleName()
+ + " attached to "
+ + event.getContainer().getClass().getSimpleName());
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractComponentTest.java b/tests/testbench/com/vaadin/tests/components/AbstractComponentTest.java
index 8344ed216a..fe61df8913 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractComponentTest.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractComponentTest.java
@@ -1,671 +1,671 @@
-package com.vaadin.tests.components;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.util.Log;
-import com.vaadin.tests.util.LoremIpsum;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public abstract class AbstractComponentTest<T extends AbstractComponent>
- extends AbstractComponentTestCase<T> {
-
- protected static final String TEXT_SHORT = "Short";
- protected static final String TEXT_MEDIUM = "This is a semi-long text that might wrap.";
- protected static final String TEXT_LONG = "This is a long text. "
- + LoremIpsum.get(500);
- protected static final String TEXT_VERY_LONG = "This is a very, very long text. "
- + LoremIpsum.get(5000);
-
- private static final Resource SELECTED_ICON = new ThemeResource(
- "../runo/icons/16/ok.png");
-
- private static final LinkedHashMap<String, String> sizeOptions = new LinkedHashMap<String, String>();
- static {
- sizeOptions.put("auto", null);
- sizeOptions.put("50%", "50%");
- sizeOptions.put("100%", "100%");
- for (int w = 200; w < 1000; w += 100) {
- sizeOptions.put(w + "px", w + "px");
- }
- }
-
- // Menu related
-
- private MenuItem mainMenu;
-
- private MenuBar menu;
-
- private MenuItem settingsMenu;
-
- private T component;
-
- // Used to determine if a menuItem should be selected and the other
- // unselected on click
- private Set<MenuItem> parentOfSelectableMenuItem = new HashSet<MenuItem>();
-
- /**
- * Maps the category name to a menu item
- */
- private Map<String, MenuItem> categoryToMenuItem = new HashMap<String, MenuItem>();
- private Map<MenuItem, String> menuItemToCategory = new HashMap<MenuItem, String>();
-
- // Logging
- private Log log;
-
- protected static final String CATEGORY_STATE = "State";
- protected static final String CATEGORY_SIZE = "Size";
- protected static final String CATEGORY_SELECTION = "Selection";
- protected static final String CATEGORY_LISTENERS = "Listeners";
- protected static final String CATEGORY_FEATURES = "Features";
- protected static final String CATEGORY_ACTIONS = "Actions";
- protected static final String CATEGORY_DECORATIONS = "Decorations";
-
- @Override
- protected final void setup() {
- setTheme("tests-components");
-
- // Create menu here so it appears before the components
- addComponent(createMainMenu());
-
- getLayout().setSizeFull();
- createLog();
- super.setup();
-
- // Create menu actions and trigger default actions
- createActions();
-
- // Clear initialization log messages
- log.clear();
- }
-
- private MenuBar createMainMenu() {
- menu = new MenuBar();
- menu.setDebugId("menu");
- mainMenu = menu.addItem("Component", null);
- settingsMenu = menu.addItem("Settings", null);
- populateSettingsMenu(settingsMenu);
-
- return menu;
- }
-
- /**
- * Override to add items to the "settings" menu.
- *
- * NOTE, Call super class first to preserve current order. If you override
- * this in a class and another class overrides it you might break tests
- * because the wrong items will be selected.
- *
- * @param settingsMenu
- */
- protected void populateSettingsMenu(MenuItem settingsMenu) {
-
- MenuItem showEventLog = settingsMenu.addItem("Show event log",
- new MenuBar.Command() {
-
- public void menuSelected(MenuItem selectedItem) {
- boolean selected = !isSelected(selectedItem);
- setLogVisible(selected);
- setSelected(selectedItem, selected);
- }
-
- });
- setSelected(showEventLog, true);
-
- settingsMenu.addItem("Clear log", new MenuBar.Command() {
-
- public void menuSelected(MenuItem selectedItem) {
- log.clear();
- }
- });
- MenuItem layoutSize = settingsMenu.addItem("Parent layout size", null);
- MenuItem layoutWidth = layoutSize.addItem("Width", null);
- MenuItem layoutHeight = layoutSize.addItem("Height", null);
- for (final String name : sizeOptions.keySet()) {
- layoutWidth.addItem(name, new MenuBar.Command() {
- public void menuSelected(MenuItem selectedItem) {
- getTestComponents().get(0).getParent()
- .setWidth(sizeOptions.get(name));
- log("Parent layout width set to " + name);
- }
- });
- layoutHeight.addItem(name, new MenuBar.Command() {
- public void menuSelected(MenuItem selectedItem) {
- getTestComponents().get(0).getParent()
- .setHeight(sizeOptions.get(name));
- log("Parent layout height set to " + name);
- }
- });
- }
-
- }
-
- protected void setLogVisible(boolean visible) {
- log.setVisible(visible);
- }
-
- private void createLog() {
- log = new Log(5).setNumberLogRows(true);
- getLayout().addComponent(log, 1);
- }
-
- /**
- * By default initializes just one instance of {@link #getTestClass()} using
- * {@link #constructComponent()}.
- */
- @Override
- protected void initializeComponents() {
- component = constructComponent();
- component.setDebugId("testComponent");
- addTestComponent(component);
- }
-
- public T getComponent() {
- return component;
- }
-
- @Override
- protected void addTestComponent(T c) {
- super.addTestComponent(c);
- getLayout().setExpandRatio(c, 1);
-
- };
-
- /**
- * Construct the component that is to be tested. This method uses a no-arg
- * constructor by default. Override to customize.
- *
- * @return Instance of the component that is to be tested.
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- protected T constructComponent() {
- try {
- return getTestClass().newInstance();
- } catch (Exception e) {
- throw new RuntimeException("Failed to instantiate "
- + getTestClass(), e);
- }
- }
-
- /**
- * Create actions for the component. Remember to call super.createActions()
- * when overriding.
- */
- protected void createActions() {
- createBooleanAction("Immediate", CATEGORY_STATE, true, immediateCommand);
- createBooleanAction("Enabled", CATEGORY_STATE, true, enabledCommand);
- createBooleanAction("Readonly", CATEGORY_STATE, false, readonlyCommand);
- createBooleanAction("Visible", CATEGORY_STATE, true, visibleCommand);
- createBooleanAction("Error indicator", CATEGORY_STATE, false,
- errorIndicatorCommand);
- createLocaleSelect(CATEGORY_STATE);
- createErrorMessageSelect(CATEGORY_DECORATIONS);
-
- createDescriptionSelect(CATEGORY_DECORATIONS);
- createCaptionSelect(CATEGORY_DECORATIONS);
- createIconSelect(CATEGORY_DECORATIONS);
-
- createWidthAndHeightActions(CATEGORY_SIZE);
-
- createStyleNameSelect(CATEGORY_DECORATIONS);
-
- }
-
- private void createStyleNameSelect(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put("Light blue background (background-lightblue)",
- "background-lightblue");
- options.put("1px red border (border-red-1px)", "border-red-1px");
- options.put("2px blue border (border-blue-2px)", "border-blue-2px");
- createComponentStyleNames(options);
- createSelectAction("Style name", category, options, "-",
- styleNameCommand);
-
- }
-
- protected void createComponentStyleNames(
- LinkedHashMap<String, String> options) {
-
- }
-
- private void createErrorMessageSelect(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put(TEXT_SHORT, TEXT_SHORT);
- options.put("Medium", TEXT_MEDIUM);
- options.put("Long", TEXT_LONG);
- options.put("Very long", TEXT_VERY_LONG);
- createSelectAction("Error message", category, options, "-",
- errorMessageCommand);
-
- }
-
- private void createDescriptionSelect(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put(TEXT_SHORT, TEXT_SHORT);
- options.put("Medium", TEXT_MEDIUM);
- options.put("Long", TEXT_LONG);
- options.put("Very long", TEXT_VERY_LONG);
- createSelectAction("Description / tooltip", category, options, "-",
- descriptionCommand);
-
- }
-
- private void createCaptionSelect(String category) {
- createSelectAction("Caption", category, createCaptionOptions(),
- "Short", captionCommand);
-
- }
-
- protected LinkedHashMap<String, String> createCaptionOptions() {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put("Short", TEXT_SHORT);
- options.put("Medium", TEXT_MEDIUM);
- options.put("Long", TEXT_LONG);
- options.put("Very long", TEXT_VERY_LONG);
- return options;
- }
-
- private void createWidthAndHeightActions(String category) {
- String widthCategory = "Width";
- String heightCategory = "Height";
-
- createCategory(widthCategory, category);
- createCategory(heightCategory, category);
-
- for (String name : sizeOptions.keySet()) {
- createClickAction(name, widthCategory, widthCommand,
- sizeOptions.get(name));
- createClickAction(name, heightCategory, heightCommand,
- sizeOptions.get(name));
- }
-
- // Default to undefined size
- for (T c : getTestComponents()) {
- c.setWidth(null);
- c.setHeight(null);
- }
- }
-
- private void createIconSelect(String category) {
- LinkedHashMap<String, Resource> options = new LinkedHashMap<String, Resource>();
- options.put("-", null);
- options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
- options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
- options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
-
- createSelectAction("Icon", category, options, "-", iconCommand, null);
- }
-
- private void createLocaleSelect(String category) {
- LinkedHashMap<String, Locale> options = new LinkedHashMap<String, Locale>();
- options.put("-", null);
- options.put("fi_FI", new Locale("fi", "FI"));
- options.put("en_US", Locale.US);
- options.put("zh_CN", Locale.SIMPLIFIED_CHINESE);
- options.put("fr_FR", Locale.FRANCE);
-
- createSelectAction("Locale", category, options, "en_US", localeCommand,
- null);
- }
-
- protected void createBooleanAction(String caption, String category,
- boolean initialState, final Command<T, Boolean> command) {
- createBooleanAction(caption, category, initialState, command, null);
- }
-
- protected <DATATYPE> void createBooleanAction(String caption,
- String category, boolean initialState,
- final Command<T, Boolean> command, Object data) {
- MenuItem categoryItem = getCategoryMenuItem(category);
- MenuItem item = categoryItem.addItem(caption,
- menuBooleanCommand(command, data));
- setSelected(item, initialState);
- doCommand(caption, command, initialState, data);
- }
-
- protected <DATATYPE> void createClickAction(String caption,
- String category, final Command<T, DATATYPE> command, DATATYPE value) {
- createClickAction(caption, category, command, value, null);
- }
-
- protected <DATATYPE> void createClickAction(String caption,
- String category, final Command<T, DATATYPE> command,
- DATATYPE value, Object data) {
- MenuItem categoryItem = getCategoryMenuItem(category);
- categoryItem.addItem(caption, menuClickCommand(command, value, data));
- }
-
- private MenuItem getCategoryMenuItem(String category) {
- if (category == null) {
- return getCategoryMenuItem("Misc");
- }
-
- MenuItem item = categoryToMenuItem.get(category);
- if (item != null) {
- return item;
- }
-
- return createCategory(category, null);
- }
-
- /**
- * Creates category named "category" with id "categoryId" in parent category
- * "parentCategory". Each categoryId must be globally unique.
- *
- * @param category
- * @param categoryId
- * @param parentCategory
- * @return
- */
- protected MenuItem createCategory(String category, String parentCategory) {
- if (hasCategory(category)) {
- return categoryToMenuItem.get(category);
- }
- MenuItem item;
- if (parentCategory == null) {
- item = mainMenu.addItem(category, null);
- } else {
- item = getCategoryMenuItem(parentCategory).addItem(category, null);
- }
- categoryToMenuItem.put(category, item);
- menuItemToCategory.put(item, category);
- return item;
- }
-
- protected boolean hasCategory(String categoryId) {
- return categoryToMenuItem.containsKey(categoryId);
- }
-
- protected void removeCategory(String categoryId) {
- if (!hasCategory(categoryId)) {
- throw new IllegalArgumentException("Category '" + categoryId
- + "' does not exist");
- }
-
- MenuItem item = getCategoryMenuItem(categoryId);
- Object[] children = item.getChildren().toArray();
- for (Object child : children) {
- if (menuItemToCategory.containsKey(child)) {
- removeCategory(menuItemToCategory.get(child));
- }
- }
- // Detach from parent
- item.getParent().removeChild(item);
- // Clean mappings
- categoryToMenuItem.remove(categoryId);
- menuItemToCategory.remove(item);
-
- }
-
- private MenuBar.Command menuBooleanCommand(
- final com.vaadin.tests.components.ComponentTestCase.Command<T, Boolean> booleanCommand,
- final Object data) {
-
- return new MenuBar.Command() {
- public void menuSelected(MenuItem selectedItem) {
- boolean selected = !isSelected(selectedItem);
- doCommand(getText(selectedItem), booleanCommand, selected, data);
- setSelected(selectedItem, selected);
- }
-
- };
- }
-
- private <DATATYPE> MenuBar.Command menuClickCommand(
- final com.vaadin.tests.components.ComponentTestCase.Command<T, DATATYPE> command,
- final DATATYPE value, final Object data) {
-
- return new MenuBar.Command() {
- public void menuSelected(MenuItem selectedItem) {
- doCommand(getText(selectedItem), command, value, data);
- }
-
- };
- }
-
- protected void setSelected(MenuItem item, boolean selected) {
- if (selected) {
- item.setIcon(SELECTED_ICON);
- } else {
- item.setIcon(null);
- }
- }
-
- protected boolean isSelected(MenuItem item) {
- return (item.getIcon() != null);
- }
-
- private <VALUETYPE> MenuBar.Command singleSelectMenuCommand(
- final com.vaadin.tests.components.ComponentTestCase.Command<T, VALUETYPE> cmd,
- final VALUETYPE object, final Object data) {
- return new MenuBar.Command() {
- public void menuSelected(MenuItem selectedItem) {
- doCommand(getText(selectedItem), cmd, object, data);
-
- if (parentOfSelectableMenuItem.contains(selectedItem
- .getParent())) {
- unselectChildren(selectedItem.getParent());
- setSelected(selectedItem, true);
- }
- }
-
- };
-
- }
-
- /**
- * Unselect all child menu items
- *
- * @param parent
- */
- protected void unselectChildren(MenuItem parent) {
- List<MenuItem> children = parent.getChildren();
- if (children == null) {
- return;
- }
-
- for (MenuItem child : children) {
- setSelected(child, false);
- }
- }
-
- protected String getText(MenuItem item) {
- String path = "";
- MenuItem parent = item.getParent();
- while (!isCategory(parent)) {
- path = parent.getText() + "/" + path;
- parent = parent.getParent();
- }
-
- return path + "/" + item.getText();
- }
-
- private boolean isCategory(MenuItem item) {
- return item.getParent() == mainMenu;
- }
-
- protected <TYPE> void createSelectAction(
- String caption,
- String category,
- LinkedHashMap<String, TYPE> options,
- String initialValue,
- com.vaadin.tests.components.ComponentTestCase.Command<T, TYPE> command) {
- createSelectAction(caption, category, options, initialValue, command,
- null);
-
- }
-
- protected <TYPE> void createMultiClickAction(
- String caption,
- String category,
- LinkedHashMap<String, TYPE> options,
- com.vaadin.tests.components.ComponentTestCase.Command<T, TYPE> command,
- Object data) {
-
- MenuItem categoryItem = getCategoryMenuItem(category);
- MenuItem mainItem = categoryItem.addItem(caption, null);
-
- for (String option : options.keySet()) {
- MenuBar.Command cmd = menuClickCommand(command,
- options.get(option), data);
- mainItem.addItem(option, cmd);
- }
- }
-
- protected <TYPE> void createMultiToggleAction(
- String caption,
- String category,
- LinkedHashMap<String, TYPE> options,
- com.vaadin.tests.components.ComponentTestCase.Command<T, Boolean> command,
- boolean defaultValue) {
-
- LinkedHashMap<String, Boolean> defaultValues = new LinkedHashMap<String, Boolean>();
-
- for (String option : options.keySet()) {
- defaultValues.put(option, defaultValue);
- }
-
- createMultiToggleAction(caption, category, options, command,
- defaultValues);
- }
-
- protected <TYPE> void createMultiToggleAction(
- String caption,
- String category,
- LinkedHashMap<String, TYPE> options,
- com.vaadin.tests.components.ComponentTestCase.Command<T, Boolean> command,
- LinkedHashMap<String, Boolean> defaultValues) {
-
- createCategory(caption, category);
-
- for (String option : options.keySet()) {
- createBooleanAction(option, caption, defaultValues.get(option),
- command, options.get(option));
-
- }
- }
-
- protected <TYPE> void createSelectAction(
- String caption,
- String category,
- LinkedHashMap<String, TYPE> options,
- String initialValue,
- com.vaadin.tests.components.ComponentTestCase.Command<T, TYPE> command,
- Object data) {
-
- MenuItem parentItem = getCategoryMenuItem(category);
- MenuItem mainItem = parentItem.addItem(caption, null);
-
- parentOfSelectableMenuItem.add(mainItem);
- for (String option : options.keySet()) {
- MenuBar.Command cmd = singleSelectMenuCommand(command,
- options.get(option), data);
- MenuItem item = mainItem.addItem(option, cmd);
- if (option.equals(initialValue)) {
- cmd.menuSelected(item);
- }
- }
- }
-
- protected LinkedHashMap<String, Integer> createIntegerOptions(int max) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- for (int i = 0; i <= 9 && i <= max; i++) {
- options.put(String.valueOf(i), i);
- }
- for (int i = 10; i <= max; i *= 10) {
- options.put(String.valueOf(i), i);
- if (2 * i <= max) {
- options.put(String.valueOf(2 * i), 2 * i);
- }
- if (5 * i <= max) {
- options.put(String.valueOf(5 * i), 5 * i);
- }
- }
-
- return options;
- }
-
- protected LinkedHashMap<String, Double> createDoubleOptions(double max) {
- LinkedHashMap<String, Double> options = new LinkedHashMap<String, Double>();
- for (double d = 0; d <= max && d < 10; d += 0.5) {
- options.put(String.valueOf(d), d);
- }
- for (double d = 10; d <= max; d *= 10) {
- options.put(String.valueOf(d), d);
- if (2.5 * d <= max) {
- options.put(String.valueOf(2 * d), 2 * d);
- }
- if (5 * d <= max) {
- options.put(String.valueOf(5 * d), 5 * d);
- }
- }
-
- return options;
- }
-
- protected LinkedHashMap<String, Resource> createIconOptions(
- boolean cacheable) {
- LinkedHashMap<String, Resource> options = new LinkedHashMap<String, Resource>();
- options.put("-", null);
- if (cacheable) {
- options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
- options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
- options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
- } else {
- options.put("16x16", ICON_16_USER_PNG_UNCACHEABLE);
- options.put("32x32", ICON_32_ATTENTION_PNG_UNCACHEABLE);
- options.put("64x64", ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE);
-
- }
- return options;
- }
-
- protected void log(String msg) {
- log.log(msg);
- }
-
- protected boolean hasLog() {
- return log != null;
- }
-
- @Override
- protected <VALUET> void doCommand(String commandName,
- AbstractComponentTestCase.Command<T, VALUET> command, VALUET value,
- Object data) {
- if (hasLog()) {
- log("Command: " + commandName + "(" + value + ")");
- }
- super.doCommand(commandName, command, value, data);
- }
-
- @Override
- public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) {
- String logMsg = "Exception occured, "
- + event.getThrowable().getClass().getName();
-
- String exceptionMsg = event.getThrowable().getMessage();
- if (exceptionMsg != null && exceptionMsg.length() > 0) {
- logMsg += exceptionMsg;
- }
- log.log(logMsg);
- final Throwable t = event.getThrowable();
- if (t != null) {
- t.printStackTrace();
- }
-
- }
-}
+package com.vaadin.tests.components;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.util.Log;
+import com.vaadin.tests.util.LoremIpsum;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public abstract class AbstractComponentTest<T extends AbstractComponent>
+ extends AbstractComponentTestCase<T> {
+
+ protected static final String TEXT_SHORT = "Short";
+ protected static final String TEXT_MEDIUM = "This is a semi-long text that might wrap.";
+ protected static final String TEXT_LONG = "This is a long text. "
+ + LoremIpsum.get(500);
+ protected static final String TEXT_VERY_LONG = "This is a very, very long text. "
+ + LoremIpsum.get(5000);
+
+ private static final Resource SELECTED_ICON = new ThemeResource(
+ "../runo/icons/16/ok.png");
+
+ private static final LinkedHashMap<String, String> sizeOptions = new LinkedHashMap<String, String>();
+ static {
+ sizeOptions.put("auto", null);
+ sizeOptions.put("50%", "50%");
+ sizeOptions.put("100%", "100%");
+ for (int w = 200; w < 1000; w += 100) {
+ sizeOptions.put(w + "px", w + "px");
+ }
+ }
+
+ // Menu related
+
+ private MenuItem mainMenu;
+
+ private MenuBar menu;
+
+ private MenuItem settingsMenu;
+
+ private T component;
+
+ // Used to determine if a menuItem should be selected and the other
+ // unselected on click
+ private Set<MenuItem> parentOfSelectableMenuItem = new HashSet<MenuItem>();
+
+ /**
+ * Maps the category name to a menu item
+ */
+ private Map<String, MenuItem> categoryToMenuItem = new HashMap<String, MenuItem>();
+ private Map<MenuItem, String> menuItemToCategory = new HashMap<MenuItem, String>();
+
+ // Logging
+ private Log log;
+
+ protected static final String CATEGORY_STATE = "State";
+ protected static final String CATEGORY_SIZE = "Size";
+ protected static final String CATEGORY_SELECTION = "Selection";
+ protected static final String CATEGORY_LISTENERS = "Listeners";
+ protected static final String CATEGORY_FEATURES = "Features";
+ protected static final String CATEGORY_ACTIONS = "Actions";
+ protected static final String CATEGORY_DECORATIONS = "Decorations";
+
+ @Override
+ protected final void setup() {
+ setTheme("tests-components");
+
+ // Create menu here so it appears before the components
+ addComponent(createMainMenu());
+
+ getLayout().setSizeFull();
+ createLog();
+ super.setup();
+
+ // Create menu actions and trigger default actions
+ createActions();
+
+ // Clear initialization log messages
+ log.clear();
+ }
+
+ private MenuBar createMainMenu() {
+ menu = new MenuBar();
+ menu.setDebugId("menu");
+ mainMenu = menu.addItem("Component", null);
+ settingsMenu = menu.addItem("Settings", null);
+ populateSettingsMenu(settingsMenu);
+
+ return menu;
+ }
+
+ /**
+ * Override to add items to the "settings" menu.
+ *
+ * NOTE, Call super class first to preserve current order. If you override
+ * this in a class and another class overrides it you might break tests
+ * because the wrong items will be selected.
+ *
+ * @param settingsMenu
+ */
+ protected void populateSettingsMenu(MenuItem settingsMenu) {
+
+ MenuItem showEventLog = settingsMenu.addItem("Show event log",
+ new MenuBar.Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ boolean selected = !isSelected(selectedItem);
+ setLogVisible(selected);
+ setSelected(selectedItem, selected);
+ }
+
+ });
+ setSelected(showEventLog, true);
+
+ settingsMenu.addItem("Clear log", new MenuBar.Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ log.clear();
+ }
+ });
+ MenuItem layoutSize = settingsMenu.addItem("Parent layout size", null);
+ MenuItem layoutWidth = layoutSize.addItem("Width", null);
+ MenuItem layoutHeight = layoutSize.addItem("Height", null);
+ for (final String name : sizeOptions.keySet()) {
+ layoutWidth.addItem(name, new MenuBar.Command() {
+ public void menuSelected(MenuItem selectedItem) {
+ getTestComponents().get(0).getParent()
+ .setWidth(sizeOptions.get(name));
+ log("Parent layout width set to " + name);
+ }
+ });
+ layoutHeight.addItem(name, new MenuBar.Command() {
+ public void menuSelected(MenuItem selectedItem) {
+ getTestComponents().get(0).getParent()
+ .setHeight(sizeOptions.get(name));
+ log("Parent layout height set to " + name);
+ }
+ });
+ }
+
+ }
+
+ protected void setLogVisible(boolean visible) {
+ log.setVisible(visible);
+ }
+
+ private void createLog() {
+ log = new Log(5).setNumberLogRows(true);
+ getLayout().addComponent(log, 1);
+ }
+
+ /**
+ * By default initializes just one instance of {@link #getTestClass()} using
+ * {@link #constructComponent()}.
+ */
+ @Override
+ protected void initializeComponents() {
+ component = constructComponent();
+ component.setDebugId("testComponent");
+ addTestComponent(component);
+ }
+
+ public T getComponent() {
+ return component;
+ }
+
+ @Override
+ protected void addTestComponent(T c) {
+ super.addTestComponent(c);
+ getLayout().setExpandRatio(c, 1);
+
+ };
+
+ /**
+ * Construct the component that is to be tested. This method uses a no-arg
+ * constructor by default. Override to customize.
+ *
+ * @return Instance of the component that is to be tested.
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ protected T constructComponent() {
+ try {
+ return getTestClass().newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to instantiate "
+ + getTestClass(), e);
+ }
+ }
+
+ /**
+ * Create actions for the component. Remember to call super.createActions()
+ * when overriding.
+ */
+ protected void createActions() {
+ createBooleanAction("Immediate", CATEGORY_STATE, true, immediateCommand);
+ createBooleanAction("Enabled", CATEGORY_STATE, true, enabledCommand);
+ createBooleanAction("Readonly", CATEGORY_STATE, false, readonlyCommand);
+ createBooleanAction("Visible", CATEGORY_STATE, true, visibleCommand);
+ createBooleanAction("Error indicator", CATEGORY_STATE, false,
+ errorIndicatorCommand);
+ createLocaleSelect(CATEGORY_STATE);
+ createErrorMessageSelect(CATEGORY_DECORATIONS);
+
+ createDescriptionSelect(CATEGORY_DECORATIONS);
+ createCaptionSelect(CATEGORY_DECORATIONS);
+ createIconSelect(CATEGORY_DECORATIONS);
+
+ createWidthAndHeightActions(CATEGORY_SIZE);
+
+ createStyleNameSelect(CATEGORY_DECORATIONS);
+
+ }
+
+ private void createStyleNameSelect(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("Light blue background (background-lightblue)",
+ "background-lightblue");
+ options.put("1px red border (border-red-1px)", "border-red-1px");
+ options.put("2px blue border (border-blue-2px)", "border-blue-2px");
+ createComponentStyleNames(options);
+ createSelectAction("Style name", category, options, "-",
+ styleNameCommand);
+
+ }
+
+ protected void createComponentStyleNames(
+ LinkedHashMap<String, String> options) {
+
+ }
+
+ private void createErrorMessageSelect(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put(TEXT_SHORT, TEXT_SHORT);
+ options.put("Medium", TEXT_MEDIUM);
+ options.put("Long", TEXT_LONG);
+ options.put("Very long", TEXT_VERY_LONG);
+ createSelectAction("Error message", category, options, "-",
+ errorMessageCommand);
+
+ }
+
+ private void createDescriptionSelect(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put(TEXT_SHORT, TEXT_SHORT);
+ options.put("Medium", TEXT_MEDIUM);
+ options.put("Long", TEXT_LONG);
+ options.put("Very long", TEXT_VERY_LONG);
+ createSelectAction("Description / tooltip", category, options, "-",
+ descriptionCommand);
+
+ }
+
+ private void createCaptionSelect(String category) {
+ createSelectAction("Caption", category, createCaptionOptions(),
+ "Short", captionCommand);
+
+ }
+
+ protected LinkedHashMap<String, String> createCaptionOptions() {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("Short", TEXT_SHORT);
+ options.put("Medium", TEXT_MEDIUM);
+ options.put("Long", TEXT_LONG);
+ options.put("Very long", TEXT_VERY_LONG);
+ return options;
+ }
+
+ private void createWidthAndHeightActions(String category) {
+ String widthCategory = "Width";
+ String heightCategory = "Height";
+
+ createCategory(widthCategory, category);
+ createCategory(heightCategory, category);
+
+ for (String name : sizeOptions.keySet()) {
+ createClickAction(name, widthCategory, widthCommand,
+ sizeOptions.get(name));
+ createClickAction(name, heightCategory, heightCommand,
+ sizeOptions.get(name));
+ }
+
+ // Default to undefined size
+ for (T c : getTestComponents()) {
+ c.setWidth(null);
+ c.setHeight(null);
+ }
+ }
+
+ private void createIconSelect(String category) {
+ LinkedHashMap<String, Resource> options = new LinkedHashMap<String, Resource>();
+ options.put("-", null);
+ options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
+ options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
+ options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
+
+ createSelectAction("Icon", category, options, "-", iconCommand, null);
+ }
+
+ private void createLocaleSelect(String category) {
+ LinkedHashMap<String, Locale> options = new LinkedHashMap<String, Locale>();
+ options.put("-", null);
+ options.put("fi_FI", new Locale("fi", "FI"));
+ options.put("en_US", Locale.US);
+ options.put("zh_CN", Locale.SIMPLIFIED_CHINESE);
+ options.put("fr_FR", Locale.FRANCE);
+
+ createSelectAction("Locale", category, options, "en_US", localeCommand,
+ null);
+ }
+
+ protected void createBooleanAction(String caption, String category,
+ boolean initialState, final Command<T, Boolean> command) {
+ createBooleanAction(caption, category, initialState, command, null);
+ }
+
+ protected <DATATYPE> void createBooleanAction(String caption,
+ String category, boolean initialState,
+ final Command<T, Boolean> command, Object data) {
+ MenuItem categoryItem = getCategoryMenuItem(category);
+ MenuItem item = categoryItem.addItem(caption,
+ menuBooleanCommand(command, data));
+ setSelected(item, initialState);
+ doCommand(caption, command, initialState, data);
+ }
+
+ protected <DATATYPE> void createClickAction(String caption,
+ String category, final Command<T, DATATYPE> command, DATATYPE value) {
+ createClickAction(caption, category, command, value, null);
+ }
+
+ protected <DATATYPE> void createClickAction(String caption,
+ String category, final Command<T, DATATYPE> command,
+ DATATYPE value, Object data) {
+ MenuItem categoryItem = getCategoryMenuItem(category);
+ categoryItem.addItem(caption, menuClickCommand(command, value, data));
+ }
+
+ private MenuItem getCategoryMenuItem(String category) {
+ if (category == null) {
+ return getCategoryMenuItem("Misc");
+ }
+
+ MenuItem item = categoryToMenuItem.get(category);
+ if (item != null) {
+ return item;
+ }
+
+ return createCategory(category, null);
+ }
+
+ /**
+ * Creates category named "category" with id "categoryId" in parent category
+ * "parentCategory". Each categoryId must be globally unique.
+ *
+ * @param category
+ * @param categoryId
+ * @param parentCategory
+ * @return
+ */
+ protected MenuItem createCategory(String category, String parentCategory) {
+ if (hasCategory(category)) {
+ return categoryToMenuItem.get(category);
+ }
+ MenuItem item;
+ if (parentCategory == null) {
+ item = mainMenu.addItem(category, null);
+ } else {
+ item = getCategoryMenuItem(parentCategory).addItem(category, null);
+ }
+ categoryToMenuItem.put(category, item);
+ menuItemToCategory.put(item, category);
+ return item;
+ }
+
+ protected boolean hasCategory(String categoryId) {
+ return categoryToMenuItem.containsKey(categoryId);
+ }
+
+ protected void removeCategory(String categoryId) {
+ if (!hasCategory(categoryId)) {
+ throw new IllegalArgumentException("Category '" + categoryId
+ + "' does not exist");
+ }
+
+ MenuItem item = getCategoryMenuItem(categoryId);
+ Object[] children = item.getChildren().toArray();
+ for (Object child : children) {
+ if (menuItemToCategory.containsKey(child)) {
+ removeCategory(menuItemToCategory.get(child));
+ }
+ }
+ // Detach from parent
+ item.getParent().removeChild(item);
+ // Clean mappings
+ categoryToMenuItem.remove(categoryId);
+ menuItemToCategory.remove(item);
+
+ }
+
+ private MenuBar.Command menuBooleanCommand(
+ final com.vaadin.tests.components.ComponentTestCase.Command<T, Boolean> booleanCommand,
+ final Object data) {
+
+ return new MenuBar.Command() {
+ public void menuSelected(MenuItem selectedItem) {
+ boolean selected = !isSelected(selectedItem);
+ doCommand(getText(selectedItem), booleanCommand, selected, data);
+ setSelected(selectedItem, selected);
+ }
+
+ };
+ }
+
+ private <DATATYPE> MenuBar.Command menuClickCommand(
+ final com.vaadin.tests.components.ComponentTestCase.Command<T, DATATYPE> command,
+ final DATATYPE value, final Object data) {
+
+ return new MenuBar.Command() {
+ public void menuSelected(MenuItem selectedItem) {
+ doCommand(getText(selectedItem), command, value, data);
+ }
+
+ };
+ }
+
+ protected void setSelected(MenuItem item, boolean selected) {
+ if (selected) {
+ item.setIcon(SELECTED_ICON);
+ } else {
+ item.setIcon(null);
+ }
+ }
+
+ protected boolean isSelected(MenuItem item) {
+ return (item.getIcon() != null);
+ }
+
+ private <VALUETYPE> MenuBar.Command singleSelectMenuCommand(
+ final com.vaadin.tests.components.ComponentTestCase.Command<T, VALUETYPE> cmd,
+ final VALUETYPE object, final Object data) {
+ return new MenuBar.Command() {
+ public void menuSelected(MenuItem selectedItem) {
+ doCommand(getText(selectedItem), cmd, object, data);
+
+ if (parentOfSelectableMenuItem.contains(selectedItem
+ .getParent())) {
+ unselectChildren(selectedItem.getParent());
+ setSelected(selectedItem, true);
+ }
+ }
+
+ };
+
+ }
+
+ /**
+ * Unselect all child menu items
+ *
+ * @param parent
+ */
+ protected void unselectChildren(MenuItem parent) {
+ List<MenuItem> children = parent.getChildren();
+ if (children == null) {
+ return;
+ }
+
+ for (MenuItem child : children) {
+ setSelected(child, false);
+ }
+ }
+
+ protected String getText(MenuItem item) {
+ String path = "";
+ MenuItem parent = item.getParent();
+ while (!isCategory(parent)) {
+ path = parent.getText() + "/" + path;
+ parent = parent.getParent();
+ }
+
+ return path + "/" + item.getText();
+ }
+
+ private boolean isCategory(MenuItem item) {
+ return item.getParent() == mainMenu;
+ }
+
+ protected <TYPE> void createSelectAction(
+ String caption,
+ String category,
+ LinkedHashMap<String, TYPE> options,
+ String initialValue,
+ com.vaadin.tests.components.ComponentTestCase.Command<T, TYPE> command) {
+ createSelectAction(caption, category, options, initialValue, command,
+ null);
+
+ }
+
+ protected <TYPE> void createMultiClickAction(
+ String caption,
+ String category,
+ LinkedHashMap<String, TYPE> options,
+ com.vaadin.tests.components.ComponentTestCase.Command<T, TYPE> command,
+ Object data) {
+
+ MenuItem categoryItem = getCategoryMenuItem(category);
+ MenuItem mainItem = categoryItem.addItem(caption, null);
+
+ for (String option : options.keySet()) {
+ MenuBar.Command cmd = menuClickCommand(command,
+ options.get(option), data);
+ mainItem.addItem(option, cmd);
+ }
+ }
+
+ protected <TYPE> void createMultiToggleAction(
+ String caption,
+ String category,
+ LinkedHashMap<String, TYPE> options,
+ com.vaadin.tests.components.ComponentTestCase.Command<T, Boolean> command,
+ boolean defaultValue) {
+
+ LinkedHashMap<String, Boolean> defaultValues = new LinkedHashMap<String, Boolean>();
+
+ for (String option : options.keySet()) {
+ defaultValues.put(option, defaultValue);
+ }
+
+ createMultiToggleAction(caption, category, options, command,
+ defaultValues);
+ }
+
+ protected <TYPE> void createMultiToggleAction(
+ String caption,
+ String category,
+ LinkedHashMap<String, TYPE> options,
+ com.vaadin.tests.components.ComponentTestCase.Command<T, Boolean> command,
+ LinkedHashMap<String, Boolean> defaultValues) {
+
+ createCategory(caption, category);
+
+ for (String option : options.keySet()) {
+ createBooleanAction(option, caption, defaultValues.get(option),
+ command, options.get(option));
+
+ }
+ }
+
+ protected <TYPE> void createSelectAction(
+ String caption,
+ String category,
+ LinkedHashMap<String, TYPE> options,
+ String initialValue,
+ com.vaadin.tests.components.ComponentTestCase.Command<T, TYPE> command,
+ Object data) {
+
+ MenuItem parentItem = getCategoryMenuItem(category);
+ MenuItem mainItem = parentItem.addItem(caption, null);
+
+ parentOfSelectableMenuItem.add(mainItem);
+ for (String option : options.keySet()) {
+ MenuBar.Command cmd = singleSelectMenuCommand(command,
+ options.get(option), data);
+ MenuItem item = mainItem.addItem(option, cmd);
+ if (option.equals(initialValue)) {
+ cmd.menuSelected(item);
+ }
+ }
+ }
+
+ protected LinkedHashMap<String, Integer> createIntegerOptions(int max) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ for (int i = 0; i <= 9 && i <= max; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ for (int i = 10; i <= max; i *= 10) {
+ options.put(String.valueOf(i), i);
+ if (2 * i <= max) {
+ options.put(String.valueOf(2 * i), 2 * i);
+ }
+ if (5 * i <= max) {
+ options.put(String.valueOf(5 * i), 5 * i);
+ }
+ }
+
+ return options;
+ }
+
+ protected LinkedHashMap<String, Double> createDoubleOptions(double max) {
+ LinkedHashMap<String, Double> options = new LinkedHashMap<String, Double>();
+ for (double d = 0; d <= max && d < 10; d += 0.5) {
+ options.put(String.valueOf(d), d);
+ }
+ for (double d = 10; d <= max; d *= 10) {
+ options.put(String.valueOf(d), d);
+ if (2.5 * d <= max) {
+ options.put(String.valueOf(2 * d), 2 * d);
+ }
+ if (5 * d <= max) {
+ options.put(String.valueOf(5 * d), 5 * d);
+ }
+ }
+
+ return options;
+ }
+
+ protected LinkedHashMap<String, Resource> createIconOptions(
+ boolean cacheable) {
+ LinkedHashMap<String, Resource> options = new LinkedHashMap<String, Resource>();
+ options.put("-", null);
+ if (cacheable) {
+ options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
+ options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
+ options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
+ } else {
+ options.put("16x16", ICON_16_USER_PNG_UNCACHEABLE);
+ options.put("32x32", ICON_32_ATTENTION_PNG_UNCACHEABLE);
+ options.put("64x64", ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE);
+
+ }
+ return options;
+ }
+
+ protected void log(String msg) {
+ log.log(msg);
+ }
+
+ protected boolean hasLog() {
+ return log != null;
+ }
+
+ @Override
+ protected <VALUET> void doCommand(String commandName,
+ AbstractComponentTestCase.Command<T, VALUET> command, VALUET value,
+ Object data) {
+ if (hasLog()) {
+ log("Command: " + commandName + "(" + value + ")");
+ }
+ super.doCommand(commandName, command, value, data);
+ }
+
+ @Override
+ public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) {
+ String logMsg = "Exception occured, "
+ + event.getThrowable().getClass().getName();
+
+ String exceptionMsg = event.getThrowable().getMessage();
+ if (exceptionMsg != null && exceptionMsg.length() > 0) {
+ logMsg += exceptionMsg;
+ }
+ log.log(logMsg);
+ final Throwable t = event.getThrowable();
+ if (t != null) {
+ t.printStackTrace();
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java b/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java
index f6b979c698..5c25359e28 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractLayoutTest.java
@@ -1,100 +1,100 @@
-package com.vaadin.tests.components;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.ui.AbstractLayout;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.Layout.MarginInfo;
-import com.vaadin.ui.Layout.SpacingHandler;
-
-public abstract class AbstractLayoutTest<T extends AbstractLayout> extends
- AbstractComponentContainerTest<T> {
-
- protected static final String CATEGORY_LAYOUT_FEATURES = "Layout features";
- private Command<T, MarginInfo> marginCommand = new Command<T, MarginInfo>() {
-
- public void execute(T c, MarginInfo value, Object data) {
- c.setMargin(value);
-
- }
- };
-
- protected Command<T, Boolean> spacingCommand = new Command<T, Boolean>() {
- public void execute(T c, Boolean value, Object data) {
- ((SpacingHandler) c).setSpacing(value);
- }
- };
-
- private Command<T, Integer> setComponentAlignment = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object alignment) {
- Component child = getComponentAtIndex(c, value);
- ((AlignmentHandler) c).setComponentAlignment(child,
- (Alignment) alignment);
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
- createMarginsSelect(CATEGORY_LAYOUT_FEATURES);
- if (SpacingHandler.class.isAssignableFrom(getTestClass())) {
- createSpacingSelect(CATEGORY_LAYOUT_FEATURES);
- }
- if (AlignmentHandler.class.isAssignableFrom(getTestClass())) {
- createChangeComponentAlignmentAction(CATEGORY_LAYOUT_FEATURES);
- }
-
- }
-
- private void createMarginsSelect(String category) {
- LinkedHashMap<String, MarginInfo> options = new LinkedHashMap<String, MarginInfo>();
- options.put("off", new MarginInfo(false));
- options.put("all", new MarginInfo(true));
- options.put("left", new MarginInfo(false, false, false, true));
- options.put("right", new MarginInfo(false, true, false, false));
- options.put("top", new MarginInfo(true, false, false, false));
- options.put("bottom", new MarginInfo(false, false, true, false));
- options.put("left-right", new MarginInfo(false, true, false, true));
- options.put("top-bottom", new MarginInfo(true, false, true, false));
-
- createSelectAction("Margins", category, options, "off", marginCommand);
- }
-
- private void createSpacingSelect(String category) {
- createBooleanAction("Spacing", category, false, spacingCommand);
- }
-
- private void createChangeComponentAlignmentAction(String category) {
- String alignmentCategory = "Component alignment";
- createCategory(alignmentCategory, category);
-
- LinkedHashMap<String, Alignment> options = new LinkedHashMap<String, Alignment>();
- options.put("Top left", Alignment.TOP_LEFT);
- options.put("Top center", Alignment.TOP_CENTER);
- options.put("Top right", Alignment.TOP_RIGHT);
-
- options.put("Middle left", Alignment.MIDDLE_LEFT);
- options.put("Middle center", Alignment.MIDDLE_CENTER);
- options.put("Middle right", Alignment.MIDDLE_RIGHT);
-
- options.put("Bottom left", Alignment.BOTTOM_LEFT);
- options.put("Bottom center", Alignment.BOTTOM_CENTER);
- options.put("Bottom right", Alignment.BOTTOM_RIGHT);
-
- for (int i = 0; i < 20; i++) {
- String componentAlignmentCategory = "Component " + i + " alignment";
- createCategory(componentAlignmentCategory, alignmentCategory);
-
- for (String option : options.keySet()) {
- createClickAction(option, componentAlignmentCategory,
- setComponentAlignment, Integer.valueOf(i),
- options.get(option));
- }
-
- }
-
- }
-}
+package com.vaadin.tests.components;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.ui.AbstractLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Layout.AlignmentHandler;
+import com.vaadin.ui.Layout.MarginInfo;
+import com.vaadin.ui.Layout.SpacingHandler;
+
+public abstract class AbstractLayoutTest<T extends AbstractLayout> extends
+ AbstractComponentContainerTest<T> {
+
+ protected static final String CATEGORY_LAYOUT_FEATURES = "Layout features";
+ private Command<T, MarginInfo> marginCommand = new Command<T, MarginInfo>() {
+
+ public void execute(T c, MarginInfo value, Object data) {
+ c.setMargin(value);
+
+ }
+ };
+
+ protected Command<T, Boolean> spacingCommand = new Command<T, Boolean>() {
+ public void execute(T c, Boolean value, Object data) {
+ ((SpacingHandler) c).setSpacing(value);
+ }
+ };
+
+ private Command<T, Integer> setComponentAlignment = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object alignment) {
+ Component child = getComponentAtIndex(c, value);
+ ((AlignmentHandler) c).setComponentAlignment(child,
+ (Alignment) alignment);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createMarginsSelect(CATEGORY_LAYOUT_FEATURES);
+ if (SpacingHandler.class.isAssignableFrom(getTestClass())) {
+ createSpacingSelect(CATEGORY_LAYOUT_FEATURES);
+ }
+ if (AlignmentHandler.class.isAssignableFrom(getTestClass())) {
+ createChangeComponentAlignmentAction(CATEGORY_LAYOUT_FEATURES);
+ }
+
+ }
+
+ private void createMarginsSelect(String category) {
+ LinkedHashMap<String, MarginInfo> options = new LinkedHashMap<String, MarginInfo>();
+ options.put("off", new MarginInfo(false));
+ options.put("all", new MarginInfo(true));
+ options.put("left", new MarginInfo(false, false, false, true));
+ options.put("right", new MarginInfo(false, true, false, false));
+ options.put("top", new MarginInfo(true, false, false, false));
+ options.put("bottom", new MarginInfo(false, false, true, false));
+ options.put("left-right", new MarginInfo(false, true, false, true));
+ options.put("top-bottom", new MarginInfo(true, false, true, false));
+
+ createSelectAction("Margins", category, options, "off", marginCommand);
+ }
+
+ private void createSpacingSelect(String category) {
+ createBooleanAction("Spacing", category, false, spacingCommand);
+ }
+
+ private void createChangeComponentAlignmentAction(String category) {
+ String alignmentCategory = "Component alignment";
+ createCategory(alignmentCategory, category);
+
+ LinkedHashMap<String, Alignment> options = new LinkedHashMap<String, Alignment>();
+ options.put("Top left", Alignment.TOP_LEFT);
+ options.put("Top center", Alignment.TOP_CENTER);
+ options.put("Top right", Alignment.TOP_RIGHT);
+
+ options.put("Middle left", Alignment.MIDDLE_LEFT);
+ options.put("Middle center", Alignment.MIDDLE_CENTER);
+ options.put("Middle right", Alignment.MIDDLE_RIGHT);
+
+ options.put("Bottom left", Alignment.BOTTOM_LEFT);
+ options.put("Bottom center", Alignment.BOTTOM_CENTER);
+ options.put("Bottom right", Alignment.BOTTOM_RIGHT);
+
+ for (int i = 0; i < 20; i++) {
+ String componentAlignmentCategory = "Component " + i + " alignment";
+ createCategory(componentAlignmentCategory, alignmentCategory);
+
+ for (String option : options.keySet()) {
+ createClickAction(option, componentAlignmentCategory,
+ setComponentAlignment, Integer.valueOf(i),
+ options.get(option));
+ }
+
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractOrderedLayoutTest.java b/tests/testbench/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
index d6cbe8590d..fd323d2156 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
@@ -1,85 +1,85 @@
-package com.vaadin.tests.components;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.event.LayoutEvents.LayoutClickEvent;
-import com.vaadin.event.LayoutEvents.LayoutClickListener;
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Component;
-
-public abstract class AbstractOrderedLayoutTest<T extends AbstractOrderedLayout>
- extends AbstractLayoutTest<T> implements LayoutClickListener {
-
- private Command<T, Boolean> layoutClickListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((LayoutClickListener) AbstractOrderedLayoutTest.this);
- } else {
-
- }
-
- }
- };
-
- private Command<T, Integer> setComponentExpandRatio = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object ratio) {
- Component child = getComponentAtIndex(c, value);
- c.setExpandRatio(child, (Float) ratio);
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createLayoutClickListenerAction(CATEGORY_LISTENERS);
- createChangeComponentExpandRatioAction(CATEGORY_LAYOUT_FEATURES);
- // Set a root style so we can see the component. Can be overridden by
- // setting the style name in the UI
- for (T c : getTestComponents()) {
- c.setStyleName("background-lightblue");
- }
- }
-
- private void createLayoutClickListenerAction(String category) {
- createBooleanAction("Layout click listener", category, false,
- layoutClickListenerCommand);
- }
-
- private void createChangeComponentExpandRatioAction(String category) {
- String expandRatioCategory = "Component expand ratio";
- createCategory(expandRatioCategory, category);
-
- LinkedHashMap<String, Float> options = new LinkedHashMap<String, Float>();
- options.put("0", 0f);
- options.put("0.5", 0.5f);
- for (float f = 1; f <= 5; f++) {
- options.put(String.valueOf(f), f);
- }
-
- for (int i = 0; i < 20; i++) {
- String componentExpandRatioCategory = "Component " + i
- + " expand ratio";
- createCategory(componentExpandRatioCategory, expandRatioCategory);
-
- for (String option : options.keySet()) {
- createClickAction(option, componentExpandRatioCategory,
- setComponentExpandRatio, Integer.valueOf(i),
- options.get(option));
- }
-
- }
-
- }
-
- public void layoutClick(LayoutClickEvent event) {
- log(event.getClass().getSimpleName() + ": button="
- + event.getButtonName() + ", childComponent="
- + event.getChildComponent().getClass().getSimpleName()
- + ", relativeX=" + event.getRelativeX() + ", relativeY="
- + event.getRelativeY());
-
- }
-}
+package com.vaadin.tests.components;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Component;
+
+public abstract class AbstractOrderedLayoutTest<T extends AbstractOrderedLayout>
+ extends AbstractLayoutTest<T> implements LayoutClickListener {
+
+ private Command<T, Boolean> layoutClickListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((LayoutClickListener) AbstractOrderedLayoutTest.this);
+ } else {
+
+ }
+
+ }
+ };
+
+ private Command<T, Integer> setComponentExpandRatio = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object ratio) {
+ Component child = getComponentAtIndex(c, value);
+ c.setExpandRatio(child, (Float) ratio);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createLayoutClickListenerAction(CATEGORY_LISTENERS);
+ createChangeComponentExpandRatioAction(CATEGORY_LAYOUT_FEATURES);
+ // Set a root style so we can see the component. Can be overridden by
+ // setting the style name in the UI
+ for (T c : getTestComponents()) {
+ c.setStyleName("background-lightblue");
+ }
+ }
+
+ private void createLayoutClickListenerAction(String category) {
+ createBooleanAction("Layout click listener", category, false,
+ layoutClickListenerCommand);
+ }
+
+ private void createChangeComponentExpandRatioAction(String category) {
+ String expandRatioCategory = "Component expand ratio";
+ createCategory(expandRatioCategory, category);
+
+ LinkedHashMap<String, Float> options = new LinkedHashMap<String, Float>();
+ options.put("0", 0f);
+ options.put("0.5", 0.5f);
+ for (float f = 1; f <= 5; f++) {
+ options.put(String.valueOf(f), f);
+ }
+
+ for (int i = 0; i < 20; i++) {
+ String componentExpandRatioCategory = "Component " + i
+ + " expand ratio";
+ createCategory(componentExpandRatioCategory, expandRatioCategory);
+
+ for (String option : options.keySet()) {
+ createClickAction(option, componentExpandRatioCategory,
+ setComponentExpandRatio, Integer.valueOf(i),
+ options.get(option));
+ }
+
+ }
+
+ }
+
+ public void layoutClick(LayoutClickEvent event) {
+ log(event.getClass().getSimpleName() + ": button="
+ + event.getButtonName() + ", childComponent="
+ + event.getChildComponent().getClass().getSimpleName()
+ + ", relativeX=" + event.getRelativeX() + ", relativeY="
+ + event.getRelativeY());
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/AbstractTestCase.java b/tests/testbench/com/vaadin/tests/components/AbstractTestCase.java
index ded579f58c..e2b3ad0fe1 100644
--- a/tests/testbench/com/vaadin/tests/components/AbstractTestCase.java
+++ b/tests/testbench/com/vaadin/tests/components/AbstractTestCase.java
@@ -1,24 +1,24 @@
-package com.vaadin.tests.components;
-
-import com.vaadin.Application;
-import com.vaadin.service.ApplicationContext;
-import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext;
-import com.vaadin.terminal.gwt.server.WebBrowser;
-
-public abstract class AbstractTestCase extends Application {
-
- protected abstract String getDescription();
-
- protected abstract Integer getTicketNumber();
-
- protected WebBrowser getBrowser() {
- ApplicationContext context = getContext();
- if (context instanceof AbstractWebApplicationContext) {
- WebBrowser webBrowser = ((AbstractWebApplicationContext) context)
- .getBrowser();
- return webBrowser;
- }
-
- return null;
- }
-}
+package com.vaadin.tests.components;
+
+import com.vaadin.Application;
+import com.vaadin.service.ApplicationContext;
+import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext;
+import com.vaadin.terminal.gwt.server.WebBrowser;
+
+public abstract class AbstractTestCase extends Application {
+
+ protected abstract String getDescription();
+
+ protected abstract Integer getTicketNumber();
+
+ protected WebBrowser getBrowser() {
+ ApplicationContext context = getContext();
+ if (context instanceof AbstractWebApplicationContext) {
+ WebBrowser webBrowser = ((AbstractWebApplicationContext) context)
+ .getBrowser();
+ return webBrowser;
+ }
+
+ return null;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/HierarchicalContainerSorting.java b/tests/testbench/com/vaadin/tests/components/HierarchicalContainerSorting.java
index 1f0f1bd923..d0638be54c 100644
--- a/tests/testbench/com/vaadin/tests/components/HierarchicalContainerSorting.java
+++ b/tests/testbench/com/vaadin/tests/components/HierarchicalContainerSorting.java
@@ -1,109 +1,109 @@
-package com.vaadin.tests.components;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Tree;
-
-public class HierarchicalContainerSorting extends TestBase {
- IndexedContainer hierarchicalContainer = new HierarchicalContainer();
-
- IndexedContainer indexedContainer = new IndexedContainer();
-
- @Override
- public void setup() {
-
- populateContainer(indexedContainer);
- populateContainer(hierarchicalContainer);
-
- sort(indexedContainer);
- sort(hierarchicalContainer);
-
- HorizontalLayout hl = new HorizontalLayout();
-
- Tree tree1 = new Tree("Tree with IndexedContainer");
- tree1.setContainerDataSource(indexedContainer);
- tree1.setItemCaptionPropertyId("name");
- hl.addComponent(tree1);
-
- Tree tree2 = new Tree("Tree with HierarchicalContainer");
- tree2.setContainerDataSource(hierarchicalContainer);
- tree2.setItemCaptionPropertyId("name");
- for (Object id : tree2.rootItemIds()) {
- tree2.expandItemsRecursively(id);
- }
- hl.addComponent(tree2);
-
- addComponent(hl);
- }
-
- private static void sort(IndexedContainer container) {
- Object[] properties = new Object[1];
- properties[0] = "name";
-
- boolean[] ascending = new boolean[1];
- ascending[0] = true;
-
- container.sort(properties, ascending);
- }
-
- private static void populateContainer(IndexedContainer container) {
- container.addContainerProperty("name", String.class, null);
-
- addItem(container, "Games", null);
- addItem(container, "Call of Duty", "Games");
- addItem(container, "Might and Magic", "Games");
- addItem(container, "Fallout", "Games");
- addItem(container, "Red Alert", "Games");
-
- addItem(container, "Cars", null);
- addItem(container, "Toyota", "Cars");
- addItem(container, "Volvo", "Cars");
- addItem(container, "Audi", "Cars");
- addItem(container, "Ford", "Cars");
-
- addItem(container, "Natural languages", null);
- addItem(container, "Swedish", "Natural languages");
- addItem(container, "English", "Natural languages");
- addItem(container, "Finnish", "Natural languages");
-
- addItem(container, "Programming languages", null);
- addItem(container, "C++", "Programming languages");
- addItem(container, "PHP", "Programming languages");
- addItem(container, "Java", "Programming languages");
- addItem(container, "Python", "Programming languages");
-
- }
-
- private static int index = 0;
- private static Map<String, Integer> nameToId = new HashMap<String, Integer>();
-
- public static void addItem(IndexedContainer container, String string,
- String parent) {
- nameToId.put(string, index);
- Item item = container.addItem(index);
- item.getItemProperty("name").setValue(string);
-
- if (parent != null && container instanceof HierarchicalContainer) {
- ((HierarchicalContainer) container).setParent(index,
- nameToId.get(parent));
- }
-
- index++;
- }
-
- @Override
- protected String getDescription() {
- return "The two trees contain the same data, one uses IndexedContainer, one uses HierarchicalContainer. Both should be sorted, both the root nodes and the children.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3095;
- }
-
+package com.vaadin.tests.components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Tree;
+
+public class HierarchicalContainerSorting extends TestBase {
+ IndexedContainer hierarchicalContainer = new HierarchicalContainer();
+
+ IndexedContainer indexedContainer = new IndexedContainer();
+
+ @Override
+ public void setup() {
+
+ populateContainer(indexedContainer);
+ populateContainer(hierarchicalContainer);
+
+ sort(indexedContainer);
+ sort(hierarchicalContainer);
+
+ HorizontalLayout hl = new HorizontalLayout();
+
+ Tree tree1 = new Tree("Tree with IndexedContainer");
+ tree1.setContainerDataSource(indexedContainer);
+ tree1.setItemCaptionPropertyId("name");
+ hl.addComponent(tree1);
+
+ Tree tree2 = new Tree("Tree with HierarchicalContainer");
+ tree2.setContainerDataSource(hierarchicalContainer);
+ tree2.setItemCaptionPropertyId("name");
+ for (Object id : tree2.rootItemIds()) {
+ tree2.expandItemsRecursively(id);
+ }
+ hl.addComponent(tree2);
+
+ addComponent(hl);
+ }
+
+ private static void sort(IndexedContainer container) {
+ Object[] properties = new Object[1];
+ properties[0] = "name";
+
+ boolean[] ascending = new boolean[1];
+ ascending[0] = true;
+
+ container.sort(properties, ascending);
+ }
+
+ private static void populateContainer(IndexedContainer container) {
+ container.addContainerProperty("name", String.class, null);
+
+ addItem(container, "Games", null);
+ addItem(container, "Call of Duty", "Games");
+ addItem(container, "Might and Magic", "Games");
+ addItem(container, "Fallout", "Games");
+ addItem(container, "Red Alert", "Games");
+
+ addItem(container, "Cars", null);
+ addItem(container, "Toyota", "Cars");
+ addItem(container, "Volvo", "Cars");
+ addItem(container, "Audi", "Cars");
+ addItem(container, "Ford", "Cars");
+
+ addItem(container, "Natural languages", null);
+ addItem(container, "Swedish", "Natural languages");
+ addItem(container, "English", "Natural languages");
+ addItem(container, "Finnish", "Natural languages");
+
+ addItem(container, "Programming languages", null);
+ addItem(container, "C++", "Programming languages");
+ addItem(container, "PHP", "Programming languages");
+ addItem(container, "Java", "Programming languages");
+ addItem(container, "Python", "Programming languages");
+
+ }
+
+ private static int index = 0;
+ private static Map<String, Integer> nameToId = new HashMap<String, Integer>();
+
+ public static void addItem(IndexedContainer container, String string,
+ String parent) {
+ nameToId.put(string, index);
+ Item item = container.addItem(index);
+ item.getItemProperty("name").setValue(string);
+
+ if (parent != null && container instanceof HierarchicalContainer) {
+ ((HierarchicalContainer) container).setParent(index,
+ nameToId.get(parent));
+ }
+
+ index++;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The two trees contain the same data, one uses IndexedContainer, one uses HierarchicalContainer. Both should be sorted, both the root nodes and the children.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3095;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/LongTooltip.java b/tests/testbench/com/vaadin/tests/components/LongTooltip.java
index 87adaa673b..acb498bcee 100644
--- a/tests/testbench/com/vaadin/tests/components/LongTooltip.java
+++ b/tests/testbench/com/vaadin/tests/components/LongTooltip.java
@@ -1,49 +1,49 @@
-package com.vaadin.tests.components;
-
-import com.vaadin.tests.util.LoremIpsum;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.TextField;
-
-public class LongTooltip extends TestBase {
-
- @Override
- public void setup() {
-
- GridLayout gl = new GridLayout(2, 2);
- gl.setSizeFull();
- TextField f1 = createField();
- TextField f2 = createField();
- TextField f3 = createField();
- TextField f4 = createField();
- gl.addComponent(f1);
- gl.addComponent(f2);
- gl.addComponent(f3);
- gl.addComponent(f4);
-
- gl.setComponentAlignment(f1, Alignment.TOP_LEFT);
- gl.setComponentAlignment(f2, Alignment.TOP_RIGHT);
- gl.setComponentAlignment(f3, Alignment.BOTTOM_LEFT);
- gl.setComponentAlignment(f4, Alignment.BOTTOM_RIGHT);
-
- getLayout().setSizeFull();
- getLayout().addComponent(gl);
-
- }
-
- private TextField createField() {
- final TextField field = new TextField();
- field.setDescription(LoremIpsum.get(1000));
- return field;
- }
-
- @Override
- protected String getDescription() {
- return "For a given cursor position the tooltip should always appear with the same size in the same position. The tooltip should also always be completely on screen and not cause any scrollbars to appear.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7100;
- }
-}
+package com.vaadin.tests.components;
+
+import com.vaadin.tests.util.LoremIpsum;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+
+public class LongTooltip extends TestBase {
+
+ @Override
+ public void setup() {
+
+ GridLayout gl = new GridLayout(2, 2);
+ gl.setSizeFull();
+ TextField f1 = createField();
+ TextField f2 = createField();
+ TextField f3 = createField();
+ TextField f4 = createField();
+ gl.addComponent(f1);
+ gl.addComponent(f2);
+ gl.addComponent(f3);
+ gl.addComponent(f4);
+
+ gl.setComponentAlignment(f1, Alignment.TOP_LEFT);
+ gl.setComponentAlignment(f2, Alignment.TOP_RIGHT);
+ gl.setComponentAlignment(f3, Alignment.BOTTOM_LEFT);
+ gl.setComponentAlignment(f4, Alignment.BOTTOM_RIGHT);
+
+ getLayout().setSizeFull();
+ getLayout().addComponent(gl);
+
+ }
+
+ private TextField createField() {
+ final TextField field = new TextField();
+ field.setDescription(LoremIpsum.get(1000));
+ return field;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "For a given cursor position the tooltip should always appear with the same size in the same position. The tooltip should also always be completely on screen and not cause any scrollbars to appear.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7100;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/TestBase.java b/tests/testbench/com/vaadin/tests/components/TestBase.java
index 2156c512ce..c7380d3d7c 100644
--- a/tests/testbench/com/vaadin/tests/components/TestBase.java
+++ b/tests/testbench/com/vaadin/tests/components/TestBase.java
@@ -1,53 +1,53 @@
-package com.vaadin.tests.components;
-
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public abstract class TestBase extends AbstractTestCase {
-
- @Override
- public final void init() {
- window = new Window(getClass().getName());
- setMainWindow(window);
- window.getContent().setSizeFull();
-
- Label label = new Label(getDescription(), Label.CONTENT_XHTML);
- label.setWidth("100%");
- window.getContent().addComponent(label);
-
- layout = new VerticalLayout();
- window.getContent().addComponent(layout);
- ((VerticalLayout) window.getContent()).setExpandRatio(layout, 1);
-
- setup();
- }
-
- private Window window;
- private VerticalLayout layout;
-
- public TestBase() {
-
- }
-
- protected VerticalLayout getLayout() {
- return layout;
- }
-
- protected abstract void setup();
-
- protected void addComponent(Component c) {
- getLayout().addComponent(c);
- }
-
- protected void removeComponent(Component c) {
- getLayout().removeComponent(c);
- }
-
- protected void replaceComponent(Component oldComponent,
- Component newComponent) {
- getLayout().replaceComponent(oldComponent, newComponent);
- }
-
-}
+package com.vaadin.tests.components;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public abstract class TestBase extends AbstractTestCase {
+
+ @Override
+ public final void init() {
+ window = new Window(getClass().getName());
+ setMainWindow(window);
+ window.getContent().setSizeFull();
+
+ Label label = new Label(getDescription(), Label.CONTENT_XHTML);
+ label.setWidth("100%");
+ window.getContent().addComponent(label);
+
+ layout = new VerticalLayout();
+ window.getContent().addComponent(layout);
+ ((VerticalLayout) window.getContent()).setExpandRatio(layout, 1);
+
+ setup();
+ }
+
+ private Window window;
+ private VerticalLayout layout;
+
+ public TestBase() {
+
+ }
+
+ protected VerticalLayout getLayout() {
+ return layout;
+ }
+
+ protected abstract void setup();
+
+ protected void addComponent(Component c) {
+ getLayout().addComponent(c);
+ }
+
+ protected void removeComponent(Component c) {
+ getLayout().removeComponent(c);
+ }
+
+ protected void replaceComponent(Component oldComponent,
+ Component newComponent) {
+ getLayout().replaceComponent(oldComponent, newComponent);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java b/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java
index 9082842b1c..139ed5bb0b 100644
--- a/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java
@@ -1,58 +1,58 @@
-package com.vaadin.tests.components.absolutelayout;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbsoluteLayout;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.VerticalLayout;
-
-public class MoveComponentsFromAbsoluteLayoutToInnerLayout extends TestBase {
-
- protected Button testButton;
- private AbsoluteLayout al;
- protected ComponentContainer vl;
-
- @Override
- protected void setup() {
- al = new AbsoluteLayout();
- al.setWidth("200px");
- al.setHeight("200px");
-
- testButton = new Button("Click to move to inner layout",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- vl.addComponent(testButton);
- }
- });
-
- al.addComponent(testButton);
-
- vl = new VerticalLayout();
- al.addComponent(vl, "top: 100px");
-
- addComponent(al);
-
- Button b = new Button("Repaint inner layout",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- vl.requestRepaint();
- }
- });
-
- addComponent(b);
- }
-
- @Override
- protected String getDescription() {
- return "Click the first button to move it from an outer layout to an inner. Then click the second button to repaint the inner layout.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6061;
- }
-
-}
+package com.vaadin.tests.components.absolutelayout;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.VerticalLayout;
+
+public class MoveComponentsFromAbsoluteLayoutToInnerLayout extends TestBase {
+
+ protected Button testButton;
+ private AbsoluteLayout al;
+ protected ComponentContainer vl;
+
+ @Override
+ protected void setup() {
+ al = new AbsoluteLayout();
+ al.setWidth("200px");
+ al.setHeight("200px");
+
+ testButton = new Button("Click to move to inner layout",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ vl.addComponent(testButton);
+ }
+ });
+
+ al.addComponent(testButton);
+
+ vl = new VerticalLayout();
+ al.addComponent(vl, "top: 100px");
+
+ addComponent(al);
+
+ Button b = new Button("Repaint inner layout",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ vl.requestRepaint();
+ }
+ });
+
+ addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the first button to move it from an outer layout to an inner. Then click the second button to repaint the inner layout.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6061;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java b/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java
index 5d4f0f2acf..a5498660be 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java
@@ -1,77 +1,77 @@
-package com.vaadin.tests.components.abstractcomponent;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class EnableState extends AbstractTestCase {
- @Override
- public void init() {
- Window mainWindow = new Window("Helloworld Application");
-
- final Panel panel = new Panel("Test");
- final Button button = new Button("ablebutton");
- panel.addComponent(button);
-
- CheckBox enable = new CheckBox("Toggle button enabled", true);
- enable.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- boolean enabled = (Boolean) event.getButton().getValue();
- button.setEnabled(enabled);
- // button.requestRepaint();
- }
- });
- enable.setImmediate(true);
-
- CheckBox caption = new CheckBox("Toggle button caption", true);
- caption.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- button.setCaption(button.getCaption() + "+");
- }
- });
- caption.setImmediate(true);
-
- CheckBox visible = new CheckBox("Toggle panel visibility", true);
- visible.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- boolean visible = (Boolean) event.getButton().getValue();
-
- panel.setVisible(visible);
- }
- });
- visible.setImmediate(true);
-
- CheckBox panelEnable = new CheckBox("Toggle panel enabled", true);
- panelEnable.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- boolean enabled = (Boolean) event.getButton().getValue();
- panel.setEnabled(enabled);
- }
- });
- panelEnable.setImmediate(true);
-
- mainWindow.addComponent(enable);
- mainWindow.addComponent(caption);
- mainWindow.addComponent(visible);
- mainWindow.addComponent(panelEnable);
- mainWindow.addComponent(panel);
-
- setMainWindow(mainWindow);
- }
-
- @Override
- protected String getDescription() {
- return "This tests the enabled/disabled propagation and that enabled/disabled state is updated"
- + " properly even when the parent is invisible. Disabling the Button while the panel is"
- + " invisible should be reflected on the screen when the panel is set visible"
- + " again.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3609;
- }
-}
+package com.vaadin.tests.components.abstractcomponent;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class EnableState extends AbstractTestCase {
+ @Override
+ public void init() {
+ Window mainWindow = new Window("Helloworld Application");
+
+ final Panel panel = new Panel("Test");
+ final Button button = new Button("ablebutton");
+ panel.addComponent(button);
+
+ CheckBox enable = new CheckBox("Toggle button enabled", true);
+ enable.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ boolean enabled = (Boolean) event.getButton().getValue();
+ button.setEnabled(enabled);
+ // button.requestRepaint();
+ }
+ });
+ enable.setImmediate(true);
+
+ CheckBox caption = new CheckBox("Toggle button caption", true);
+ caption.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ button.setCaption(button.getCaption() + "+");
+ }
+ });
+ caption.setImmediate(true);
+
+ CheckBox visible = new CheckBox("Toggle panel visibility", true);
+ visible.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ boolean visible = (Boolean) event.getButton().getValue();
+
+ panel.setVisible(visible);
+ }
+ });
+ visible.setImmediate(true);
+
+ CheckBox panelEnable = new CheckBox("Toggle panel enabled", true);
+ panelEnable.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ boolean enabled = (Boolean) event.getButton().getValue();
+ panel.setEnabled(enabled);
+ }
+ });
+ panelEnable.setImmediate(true);
+
+ mainWindow.addComponent(enable);
+ mainWindow.addComponent(caption);
+ mainWindow.addComponent(visible);
+ mainWindow.addComponent(panelEnable);
+ mainWindow.addComponent(panel);
+
+ setMainWindow(mainWindow);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "This tests the enabled/disabled propagation and that enabled/disabled state is updated"
+ + " properly even when the parent is invisible. Disabling the Button while the panel is"
+ + " invisible should be reflected on the screen when the panel is set visible"
+ + " again.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3609;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java
index 2a2fc0153a..780130847a 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java
@@ -1,60 +1,60 @@
-package com.vaadin.tests.components.abstractfield;
-
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component.Event;
-import com.vaadin.ui.Component.Listener;
-import com.vaadin.ui.TextField;
-
-public class AbstractFieldDataSourceReadOnly extends TestBase {
-
- private static class StateHolder {
- private ObjectProperty<String> textField = new ObjectProperty<String>(
- "");
-
- public ObjectProperty<String> getTextField() {
- return textField;
- }
-
- @SuppressWarnings("unused")
- public void setTextField(ObjectProperty<String> textField) {
- this.textField = textField;
- }
-
- public void buttonClicked() {
- textField.setReadOnly(true);
- }
- }
-
- @Override
- protected void setup() {
- final StateHolder stateHolder = new StateHolder();
-
- // Button
- Button button = new Button("Make data source read-only");
- button.addListener(new Listener() {
- public void componentEvent(Event event) {
- stateHolder.buttonClicked();
- }
- });
-
- // Input field
- TextField input = new TextField("Field");
- input.setPropertyDataSource(stateHolder.getTextField());
-
- addComponent(button);
- addComponent(input);
- }
-
- @Override
- protected String getDescription() {
- return "Read-only status changes in data sources are not rendered immediately";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5013;
- }
-
-}
+package com.vaadin.tests.components.abstractfield;
+
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component.Event;
+import com.vaadin.ui.Component.Listener;
+import com.vaadin.ui.TextField;
+
+public class AbstractFieldDataSourceReadOnly extends TestBase {
+
+ private static class StateHolder {
+ private ObjectProperty<String> textField = new ObjectProperty<String>(
+ "");
+
+ public ObjectProperty<String> getTextField() {
+ return textField;
+ }
+
+ @SuppressWarnings("unused")
+ public void setTextField(ObjectProperty<String> textField) {
+ this.textField = textField;
+ }
+
+ public void buttonClicked() {
+ textField.setReadOnly(true);
+ }
+ }
+
+ @Override
+ protected void setup() {
+ final StateHolder stateHolder = new StateHolder();
+
+ // Button
+ Button button = new Button("Make data source read-only");
+ button.addListener(new Listener() {
+ public void componentEvent(Event event) {
+ stateHolder.buttonClicked();
+ }
+ });
+
+ // Input field
+ TextField input = new TextField("Field");
+ input.setPropertyDataSource(stateHolder.getTextField());
+
+ addComponent(button);
+ addComponent(input);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Read-only status changes in data sources are not rendered immediately";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5013;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java
index 1c8e728908..40cc2948ee 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java
@@ -1,234 +1,234 @@
-package com.vaadin.tests.components.abstractfield;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
-import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.BlurNotifier;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.event.FieldEvents.FocusNotifier;
-import com.vaadin.tests.components.AbstractComponentTest;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public abstract class AbstractFieldTest<T extends AbstractField> extends
- AbstractComponentTest<T> implements ValueChangeListener,
- ReadOnlyStatusChangeListener, FocusListener, BlurListener {
-
- @Override
- protected void createActions() {
- super.createActions();
- createBooleanAction("Required", CATEGORY_STATE, false, requiredCommand);
- createRequiredErrorSelect(CATEGORY_DECORATIONS);
-
- createValueChangeListener(CATEGORY_LISTENERS);
- createReadOnlyStatusChangeListener(CATEGORY_LISTENERS);
-
- // * invalidcommitted
- // * commit()
- // * discard()
- // * writethrough
- // * readthrough
- // * addvalidator
- // * isvalid
- // * invalidallowed
- // * error indicator
- //
- // * tabindex
- // * validation visible
- // * ShortcutListener
-
- }
-
- @Override
- protected void populateSettingsMenu(MenuItem settingsMenu) {
- super.populateSettingsMenu(settingsMenu);
-
- if (AbstractField.class.isAssignableFrom(getTestClass())) {
- MenuItem abstractField = settingsMenu
- .addItem("AbstractField", null);
- abstractField.addItem("Show value", new MenuBar.Command() {
-
- public void menuSelected(MenuItem selectedItem) {
- for (T a : getTestComponents()) {
- log(a.getClass().getSimpleName() + " value: "
- + getValue(a));
- }
- }
- });
- }
- }
-
- private void createRequiredErrorSelect(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put(TEXT_SHORT, TEXT_SHORT);
- options.put("Medium", TEXT_MEDIUM);
- options.put("Long", TEXT_LONG);
- options.put("Very long", TEXT_VERY_LONG);
- createSelectAction("Required error message", category, options, "-",
- requiredErrorMessageCommand);
-
- if (FocusNotifier.class.isAssignableFrom(getTestClass())) {
- createFocusListener(CATEGORY_LISTENERS);
- }
-
- if (BlurNotifier.class.isAssignableFrom(getTestClass())) {
- createBlurListener(CATEGORY_LISTENERS);
- }
-
- }
-
- private void createValueChangeListener(String category) {
-
- createBooleanAction("Value change listener", category, false,
- valueChangeListenerCommand);
- }
-
- private void createReadOnlyStatusChangeListener(String category) {
-
- createBooleanAction("Read only status change listener", category,
- false, readonlyStatusChangeListenerCommand);
- }
-
- private void createFocusListener(String category) {
- createBooleanAction("Focus listener", category, false,
- focusListenerCommand);
-
- }
-
- private void createBlurListener(String category) {
- createBooleanAction("Blur listener", category, false,
- blurListenerCommand);
-
- }
-
- protected Command<T, Boolean> valueChangeListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((ValueChangeListener) AbstractFieldTest.this);
- } else {
- c.removeListener((ValueChangeListener) AbstractFieldTest.this);
- }
- }
- };
- protected Command<T, Boolean> readonlyStatusChangeListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((ReadOnlyStatusChangeListener) AbstractFieldTest.this);
- } else {
- c.removeListener((ReadOnlyStatusChangeListener) AbstractFieldTest.this);
- }
- }
- };
- protected Command<T, Boolean> focusListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- ((FocusNotifier) c).addListener(AbstractFieldTest.this);
- } else {
- ((FocusNotifier) c).removeListener(AbstractFieldTest.this);
- }
- }
- };
- protected Command<T, Boolean> blurListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- ((BlurNotifier) c).addListener(AbstractFieldTest.this);
- } else {
- ((BlurNotifier) c).removeListener(AbstractFieldTest.this);
- }
- }
- };
- protected Command<T, Object> setValueCommand = new Command<T, Object>() {
-
- public void execute(T c, Object value, Object data) {
- c.setValue(value);
- }
- };
-
- public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
- log(event.getClass().getSimpleName() + ", new value: "
- + getValue(event.getProperty()));
- };
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private String getValue(Property property) {
- Object o = property.getValue();
- if (o instanceof Collection) {
- // Sort collections to avoid problems with values printed in
- // different order
- try {
- ArrayList<Comparable> c = new ArrayList<Comparable>(
- (Collection) o);
- Collections.sort(c);
- o = c;
- } catch (Exception e) {
- // continue with unsorted if sorting fails for some reason
- log("Exception while sorting value: " + e.getMessage());
- }
- }
-
- // Distinguish between null and 'null'
- String value = "null";
- if (o != null) {
- if (o instanceof Date) {
- Date d = (Date) o;
- // Dec 31, 2068 23:09:26.531
- String pattern = "MMM d, yyyy HH:mm:ss.SSS";
- SimpleDateFormat format = new SimpleDateFormat(pattern,
- new Locale("en", "US"));
- value = format.format(d);
- } else {
- value = "'" + o.toString() + "'";
- }
- }
-
- return value;
-
- }
-
- public void readOnlyStatusChange(ReadOnlyStatusChangeEvent event) {
- log(event.getClass().getSimpleName());
- }
-
- public void focus(FocusEvent event) {
- log(event.getClass().getSimpleName());
- }
-
- public void blur(BlurEvent event) {
- log(event.getClass().getSimpleName());
- }
-
- protected void createSetTextValueAction(String category) {
- String subCategory = "Set text value";
- createCategory(subCategory, category);
- List<String> values = new ArrayList<String>();
- values.add("Test");
- values.add("A little longer value");
- values.add("A very long value with very much text. All in all it is 74 characters long");
-
- createClickAction("(empty string)", subCategory, setValueCommand, "");
- createClickAction("(null)", subCategory, setValueCommand, null);
- for (String value : values) {
- createClickAction(value, subCategory, setValueCommand, value);
- }
- }
-
-}
+package com.vaadin.tests.components.abstractfield;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
+import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.BlurNotifier;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.event.FieldEvents.FocusNotifier;
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public abstract class AbstractFieldTest<T extends AbstractField> extends
+ AbstractComponentTest<T> implements ValueChangeListener,
+ ReadOnlyStatusChangeListener, FocusListener, BlurListener {
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createBooleanAction("Required", CATEGORY_STATE, false, requiredCommand);
+ createRequiredErrorSelect(CATEGORY_DECORATIONS);
+
+ createValueChangeListener(CATEGORY_LISTENERS);
+ createReadOnlyStatusChangeListener(CATEGORY_LISTENERS);
+
+ // * invalidcommitted
+ // * commit()
+ // * discard()
+ // * writethrough
+ // * readthrough
+ // * addvalidator
+ // * isvalid
+ // * invalidallowed
+ // * error indicator
+ //
+ // * tabindex
+ // * validation visible
+ // * ShortcutListener
+
+ }
+
+ @Override
+ protected void populateSettingsMenu(MenuItem settingsMenu) {
+ super.populateSettingsMenu(settingsMenu);
+
+ if (AbstractField.class.isAssignableFrom(getTestClass())) {
+ MenuItem abstractField = settingsMenu
+ .addItem("AbstractField", null);
+ abstractField.addItem("Show value", new MenuBar.Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ for (T a : getTestComponents()) {
+ log(a.getClass().getSimpleName() + " value: "
+ + getValue(a));
+ }
+ }
+ });
+ }
+ }
+
+ private void createRequiredErrorSelect(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put(TEXT_SHORT, TEXT_SHORT);
+ options.put("Medium", TEXT_MEDIUM);
+ options.put("Long", TEXT_LONG);
+ options.put("Very long", TEXT_VERY_LONG);
+ createSelectAction("Required error message", category, options, "-",
+ requiredErrorMessageCommand);
+
+ if (FocusNotifier.class.isAssignableFrom(getTestClass())) {
+ createFocusListener(CATEGORY_LISTENERS);
+ }
+
+ if (BlurNotifier.class.isAssignableFrom(getTestClass())) {
+ createBlurListener(CATEGORY_LISTENERS);
+ }
+
+ }
+
+ private void createValueChangeListener(String category) {
+
+ createBooleanAction("Value change listener", category, false,
+ valueChangeListenerCommand);
+ }
+
+ private void createReadOnlyStatusChangeListener(String category) {
+
+ createBooleanAction("Read only status change listener", category,
+ false, readonlyStatusChangeListenerCommand);
+ }
+
+ private void createFocusListener(String category) {
+ createBooleanAction("Focus listener", category, false,
+ focusListenerCommand);
+
+ }
+
+ private void createBlurListener(String category) {
+ createBooleanAction("Blur listener", category, false,
+ blurListenerCommand);
+
+ }
+
+ protected Command<T, Boolean> valueChangeListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ValueChangeListener) AbstractFieldTest.this);
+ } else {
+ c.removeListener((ValueChangeListener) AbstractFieldTest.this);
+ }
+ }
+ };
+ protected Command<T, Boolean> readonlyStatusChangeListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ReadOnlyStatusChangeListener) AbstractFieldTest.this);
+ } else {
+ c.removeListener((ReadOnlyStatusChangeListener) AbstractFieldTest.this);
+ }
+ }
+ };
+ protected Command<T, Boolean> focusListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ ((FocusNotifier) c).addListener(AbstractFieldTest.this);
+ } else {
+ ((FocusNotifier) c).removeListener(AbstractFieldTest.this);
+ }
+ }
+ };
+ protected Command<T, Boolean> blurListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ ((BlurNotifier) c).addListener(AbstractFieldTest.this);
+ } else {
+ ((BlurNotifier) c).removeListener(AbstractFieldTest.this);
+ }
+ }
+ };
+ protected Command<T, Object> setValueCommand = new Command<T, Object>() {
+
+ public void execute(T c, Object value, Object data) {
+ c.setValue(value);
+ }
+ };
+
+ public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
+ log(event.getClass().getSimpleName() + ", new value: "
+ + getValue(event.getProperty()));
+ };
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private String getValue(Property property) {
+ Object o = property.getValue();
+ if (o instanceof Collection) {
+ // Sort collections to avoid problems with values printed in
+ // different order
+ try {
+ ArrayList<Comparable> c = new ArrayList<Comparable>(
+ (Collection) o);
+ Collections.sort(c);
+ o = c;
+ } catch (Exception e) {
+ // continue with unsorted if sorting fails for some reason
+ log("Exception while sorting value: " + e.getMessage());
+ }
+ }
+
+ // Distinguish between null and 'null'
+ String value = "null";
+ if (o != null) {
+ if (o instanceof Date) {
+ Date d = (Date) o;
+ // Dec 31, 2068 23:09:26.531
+ String pattern = "MMM d, yyyy HH:mm:ss.SSS";
+ SimpleDateFormat format = new SimpleDateFormat(pattern,
+ new Locale("en", "US"));
+ value = format.format(d);
+ } else {
+ value = "'" + o.toString() + "'";
+ }
+ }
+
+ return value;
+
+ }
+
+ public void readOnlyStatusChange(ReadOnlyStatusChangeEvent event) {
+ log(event.getClass().getSimpleName());
+ }
+
+ public void focus(FocusEvent event) {
+ log(event.getClass().getSimpleName());
+ }
+
+ public void blur(BlurEvent event) {
+ log(event.getClass().getSimpleName());
+ }
+
+ protected void createSetTextValueAction(String category) {
+ String subCategory = "Set text value";
+ createCategory(subCategory, category);
+ List<String> values = new ArrayList<String>();
+ values.add("Test");
+ values.add("A little longer value");
+ values.add("A very long value with very much text. All in all it is 74 characters long");
+
+ createClickAction("(empty string)", subCategory, setValueCommand, "");
+ createClickAction("(null)", subCategory, setValueCommand, null);
+ for (String value : values) {
+ createClickAction(value, subCategory, setValueCommand, value);
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java
index eb9adef8d2..b68134f379 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractTextFieldTest.java
@@ -1,241 +1,241 @@
-package com.vaadin.tests.components.abstractfield;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.vaadin.event.FieldEvents.TextChangeEvent;
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
-
-public abstract class AbstractTextFieldTest<T extends AbstractTextField>
- extends AbstractFieldTest<T> implements TextChangeListener {
-
- private Command<T, Integer> maxlengthCommand = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.setMaxLength(value);
- }
- };
- private Command<T, Boolean> nullSelectionAllowedCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setNullSettingAllowed(value);
-
- }
- };
- private Command<T, String> nullRepresentationCommand = new Command<T, String>() {
-
- public void execute(T c, String value, Object data) {
- c.setNullRepresentation(value);
- }
- };
-
- private Command<T, String> inputPromptCommand = new Command<T, String>() {
- public void execute(T c, String value, Object data) {
- c.setInputPrompt(value);
- }
- };
-
- private Command<T, Boolean> textChangeListenerCommand = new Command<T, Boolean>() {
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((TextChangeListener) AbstractTextFieldTest.this);
- } else {
- c.removeListener((TextChangeListener) AbstractTextFieldTest.this);
- }
- }
- };
-
- private Command<T, Integer> colsCommand = new Command<T, Integer>() {
- public void execute(T c, Integer value, Object data) {
- c.setColumns(value);
- }
- };
-
- private Command<T, TextChangeEventMode> textChangeEventModeCommand = new Command<T, TextChangeEventMode>() {
- public void execute(T c, TextChangeEventMode value, Object data) {
- c.setTextChangeEventMode(value);
- }
- };
-
- private Command<T, Integer> textChangeTimeoutCommand = new Command<T, Integer>() {
- public void execute(T c, Integer value, Object data) {
- c.setTextChangeTimeout(value);
- }
- };
-
- private Command<T, Range> selectionRangeCommand = new Command<T, Range>() {
- public void execute(T c, Range value, Object data) {
- c.setSelectionRange(value.getStart(),
- value.getEnd() - value.getStart());
-
- }
- };
- private Command<T, Object> selectAllCommand = new Command<T, Object>() {
- public void execute(T c, Object value, Object data) {
- c.selectAll();
- }
- };
-
- private Command<T, Integer> setCursorPositionCommand = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.setCursorPosition(value);
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createSetTextValueAction(CATEGORY_ACTIONS);
-
- createNullSettingAllowedAction(CATEGORY_FEATURES);
- createNullRepresentationAction(CATEGORY_FEATURES);
- createMaxLengthAction(CATEGORY_FEATURES);
-
- createInputPromptAction(CATEGORY_FEATURES);
- createColsAction(CATEGORY_STATE);
-
- createTextChangeListener(CATEGORY_LISTENERS);
- createTextChangeEventModeAction(CATEGORY_FEATURES);
- createTextChangeEventTimeoutAction(CATEGORY_FEATURES);
-
- createSetTextValueAction(CATEGORY_ACTIONS);
- createCursorPositionAction(CATEGORY_ACTIONS);
- createSelectionRangeAction(CATEGORY_ACTIONS);
-
- }
-
- private void createNullSettingAllowedAction(String category) {
- createBooleanAction("Null selection allowed", category, true,
- nullSelectionAllowedCommand);
- }
-
- private void createNullRepresentationAction(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put("null", "null");
- options.put("This is empty", "This is empty");
- options.put("- Nothing -", "- Nothing -");
- createSelectAction("Null representation", category, options, "null",
- nullRepresentationCommand);
- }
-
- private void createMaxLengthAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(100);
- options.put("-", -1);
- createSelectAction("Max length", category, options, "-",
- maxlengthCommand);
-
- }
-
- public class Range {
- private int start;
- private int end;
-
- public Range(int start, int end) {
- this.start = start;
- this.end = end;
- }
-
- public int getStart() {
- return start;
- }
-
- public int getEnd() {
- return end;
- }
-
- @Override
- public String toString() {
- return start + "-" + end;
- }
- }
-
- private void createSelectionRangeAction(String category) {
- List<Range> options = new ArrayList<Range>();
- options.add(new Range(0, 10));
- options.add(new Range(0, 1));
- options.add(new Range(0, 2));
- options.add(new Range(1, 2));
- options.add(new Range(2, 5));
- options.add(new Range(5, 10));
-
- createCategory("Select range", category);
-
- createClickAction("All", "Select range", selectAllCommand, null);
- for (Range range : options) {
- createClickAction(range.toString(), "Select range",
- selectionRangeCommand, range);
- }
-
- }
-
- private void createCursorPositionAction(String category) {
- String subCategory = "Set cursor position";
- createCategory(subCategory, category);
- for (int i = 0; i < 20; i++) {
- createClickAction(String.valueOf(i), subCategory,
- setCursorPositionCommand, Integer.valueOf(i));
- }
-
- }
-
- private void createTextChangeEventTimeoutAction(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("0", 0);
- options.put("100ms", 100);
- options.put("500ms", 500);
- options.put("1s", 1000);
- options.put("2s", 2000);
- options.put("5s", 5000);
-
- createSelectAction("TextChange timeout", category, options, "0",
- textChangeTimeoutCommand);
- }
-
- private void createTextChangeEventModeAction(String category) {
- LinkedHashMap<String, TextChangeEventMode> options = new LinkedHashMap<String, AbstractTextField.TextChangeEventMode>();
- for (TextChangeEventMode m : TextChangeEventMode.values()) {
- options.put(m.toString(), m);
- }
-
- createSelectAction("TextChange event mode", category, options,
- TextChangeEventMode.EAGER.toString(),
- textChangeEventModeCommand);
-
- }
-
- private void createTextChangeListener(String category) {
- createBooleanAction("Text change listener", category, false,
- textChangeListenerCommand);
-
- }
-
- private void createColsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Columns", category, options, "0", colsCommand);
- }
-
- private void createInputPromptAction(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put("Enter a value", "Enter a value");
- options.put("- Click here -", "- Click here -");
- createSelectAction("Input prompt", category, options, "-",
- inputPromptCommand);
-
- }
-
- public void textChange(TextChangeEvent event) {
- AbstractTextField tf = (AbstractTextField) event.getComponent();
- log("TextChangeEvent: text='" + event.getText() + "', cursor position="
- + event.getCursorPosition() + " (field cursor pos: "
- + tf.getCursorPosition() + ")");
-
- }
-
-}
+package com.vaadin.tests.components.abstractfield;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+
+public abstract class AbstractTextFieldTest<T extends AbstractTextField>
+ extends AbstractFieldTest<T> implements TextChangeListener {
+
+ private Command<T, Integer> maxlengthCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.setMaxLength(value);
+ }
+ };
+ private Command<T, Boolean> nullSelectionAllowedCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setNullSettingAllowed(value);
+
+ }
+ };
+ private Command<T, String> nullRepresentationCommand = new Command<T, String>() {
+
+ public void execute(T c, String value, Object data) {
+ c.setNullRepresentation(value);
+ }
+ };
+
+ private Command<T, String> inputPromptCommand = new Command<T, String>() {
+ public void execute(T c, String value, Object data) {
+ c.setInputPrompt(value);
+ }
+ };
+
+ private Command<T, Boolean> textChangeListenerCommand = new Command<T, Boolean>() {
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((TextChangeListener) AbstractTextFieldTest.this);
+ } else {
+ c.removeListener((TextChangeListener) AbstractTextFieldTest.this);
+ }
+ }
+ };
+
+ private Command<T, Integer> colsCommand = new Command<T, Integer>() {
+ public void execute(T c, Integer value, Object data) {
+ c.setColumns(value);
+ }
+ };
+
+ private Command<T, TextChangeEventMode> textChangeEventModeCommand = new Command<T, TextChangeEventMode>() {
+ public void execute(T c, TextChangeEventMode value, Object data) {
+ c.setTextChangeEventMode(value);
+ }
+ };
+
+ private Command<T, Integer> textChangeTimeoutCommand = new Command<T, Integer>() {
+ public void execute(T c, Integer value, Object data) {
+ c.setTextChangeTimeout(value);
+ }
+ };
+
+ private Command<T, Range> selectionRangeCommand = new Command<T, Range>() {
+ public void execute(T c, Range value, Object data) {
+ c.setSelectionRange(value.getStart(),
+ value.getEnd() - value.getStart());
+
+ }
+ };
+ private Command<T, Object> selectAllCommand = new Command<T, Object>() {
+ public void execute(T c, Object value, Object data) {
+ c.selectAll();
+ }
+ };
+
+ private Command<T, Integer> setCursorPositionCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.setCursorPosition(value);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createSetTextValueAction(CATEGORY_ACTIONS);
+
+ createNullSettingAllowedAction(CATEGORY_FEATURES);
+ createNullRepresentationAction(CATEGORY_FEATURES);
+ createMaxLengthAction(CATEGORY_FEATURES);
+
+ createInputPromptAction(CATEGORY_FEATURES);
+ createColsAction(CATEGORY_STATE);
+
+ createTextChangeListener(CATEGORY_LISTENERS);
+ createTextChangeEventModeAction(CATEGORY_FEATURES);
+ createTextChangeEventTimeoutAction(CATEGORY_FEATURES);
+
+ createSetTextValueAction(CATEGORY_ACTIONS);
+ createCursorPositionAction(CATEGORY_ACTIONS);
+ createSelectionRangeAction(CATEGORY_ACTIONS);
+
+ }
+
+ private void createNullSettingAllowedAction(String category) {
+ createBooleanAction("Null selection allowed", category, true,
+ nullSelectionAllowedCommand);
+ }
+
+ private void createNullRepresentationAction(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("null", "null");
+ options.put("This is empty", "This is empty");
+ options.put("- Nothing -", "- Nothing -");
+ createSelectAction("Null representation", category, options, "null",
+ nullRepresentationCommand);
+ }
+
+ private void createMaxLengthAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(100);
+ options.put("-", -1);
+ createSelectAction("Max length", category, options, "-",
+ maxlengthCommand);
+
+ }
+
+ public class Range {
+ private int start;
+ private int end;
+
+ public Range(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+
+ @Override
+ public String toString() {
+ return start + "-" + end;
+ }
+ }
+
+ private void createSelectionRangeAction(String category) {
+ List<Range> options = new ArrayList<Range>();
+ options.add(new Range(0, 10));
+ options.add(new Range(0, 1));
+ options.add(new Range(0, 2));
+ options.add(new Range(1, 2));
+ options.add(new Range(2, 5));
+ options.add(new Range(5, 10));
+
+ createCategory("Select range", category);
+
+ createClickAction("All", "Select range", selectAllCommand, null);
+ for (Range range : options) {
+ createClickAction(range.toString(), "Select range",
+ selectionRangeCommand, range);
+ }
+
+ }
+
+ private void createCursorPositionAction(String category) {
+ String subCategory = "Set cursor position";
+ createCategory(subCategory, category);
+ for (int i = 0; i < 20; i++) {
+ createClickAction(String.valueOf(i), subCategory,
+ setCursorPositionCommand, Integer.valueOf(i));
+ }
+
+ }
+
+ private void createTextChangeEventTimeoutAction(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ options.put("100ms", 100);
+ options.put("500ms", 500);
+ options.put("1s", 1000);
+ options.put("2s", 2000);
+ options.put("5s", 5000);
+
+ createSelectAction("TextChange timeout", category, options, "0",
+ textChangeTimeoutCommand);
+ }
+
+ private void createTextChangeEventModeAction(String category) {
+ LinkedHashMap<String, TextChangeEventMode> options = new LinkedHashMap<String, AbstractTextField.TextChangeEventMode>();
+ for (TextChangeEventMode m : TextChangeEventMode.values()) {
+ options.put(m.toString(), m);
+ }
+
+ createSelectAction("TextChange event mode", category, options,
+ TextChangeEventMode.EAGER.toString(),
+ textChangeEventModeCommand);
+
+ }
+
+ private void createTextChangeListener(String category) {
+ createBooleanAction("Text change listener", category, false,
+ textChangeListenerCommand);
+
+ }
+
+ private void createColsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Columns", category, options, "0", colsCommand);
+ }
+
+ private void createInputPromptAction(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("Enter a value", "Enter a value");
+ options.put("- Click here -", "- Click here -");
+ createSelectAction("Input prompt", category, options, "-",
+ inputPromptCommand);
+
+ }
+
+ public void textChange(TextChangeEvent event) {
+ AbstractTextField tf = (AbstractTextField) event.getComponent();
+ log("TextChangeEvent: text='" + event.getText() + "', cursor position="
+ + event.getCursorPosition() + " (field cursor pos: "
+ + tf.getCursorPosition() + ")");
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java b/tests/testbench/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java
index 837256ff65..26720d67f3 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java
@@ -1,64 +1,64 @@
-package com.vaadin.tests.components.abstractfield;
-
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.TextArea;
-
-public class ShortcutAddAndRemove extends TestBase {
-
- private Log log;
- private TextArea textArea;
-
- @Override
- protected void setup() {
- log = new Log(4);
-
- final Button logButton = new Button("Log a row (enter shortcut)");
- logButton.setClickShortcut(KeyCode.ENTER);
- logButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- log.log("Log button was clicked");
- }
- });
-
- final Button removeShortcut = new Button("Remove shortcut");
- removeShortcut.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- logButton.removeClickShortcut();
- logButton.setCaption("Log a row (no shortcut)");
- }
- });
- final Button addShortcut = new Button("Add shortcut");
- addShortcut.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- logButton.setClickShortcut(KeyCode.ENTER);
- logButton.setCaption("Log a row (enter shortcut)");
- }
- });
- addComponent(log);
- addComponent(logButton);
- textArea = new TextArea("Enter key does not break lines ...");
- textArea.setRows(5);
- textArea.setColumns(20);
- addComponent(textArea);
- addComponent(removeShortcut);
- addComponent(addShortcut);
-
- }
-
- @Override
- protected String getDescription() {
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
+package com.vaadin.tests.components.abstractfield;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TextArea;
+
+public class ShortcutAddAndRemove extends TestBase {
+
+ private Log log;
+ private TextArea textArea;
+
+ @Override
+ protected void setup() {
+ log = new Log(4);
+
+ final Button logButton = new Button("Log a row (enter shortcut)");
+ logButton.setClickShortcut(KeyCode.ENTER);
+ logButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("Log button was clicked");
+ }
+ });
+
+ final Button removeShortcut = new Button("Remove shortcut");
+ removeShortcut.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ logButton.removeClickShortcut();
+ logButton.setCaption("Log a row (no shortcut)");
+ }
+ });
+ final Button addShortcut = new Button("Add shortcut");
+ addShortcut.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ logButton.setClickShortcut(KeyCode.ENTER);
+ logButton.setCaption("Log a row (enter shortcut)");
+ }
+ });
+ addComponent(log);
+ addComponent(logButton);
+ textArea = new TextArea("Enter key does not break lines ...");
+ textArea.setRows(5);
+ textArea.setColumns(20);
+ addComponent(textArea);
+ addComponent(removeShortcut);
+ addComponent(addShortcut);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/accordion/RemoveTabs.java b/tests/testbench/com/vaadin/tests/components/accordion/RemoveTabs.java
index bc8bea1c56..a048cf04a8 100644
--- a/tests/testbench/com/vaadin/tests/components/accordion/RemoveTabs.java
+++ b/tests/testbench/com/vaadin/tests/components/accordion/RemoveTabs.java
@@ -1,127 +1,127 @@
-package com.vaadin.tests.components.accordion;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbstractComponentContainer;
-import com.vaadin.ui.Accordion;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-
-public class RemoveTabs extends TestBase {
-
- private Accordion accordion;
-
- protected Component[] tab = new Component[5];
-
- private Button closeCurrent;
- private Button closeFirst;
- private Button closeLast;
- private Button reorderTabs;
-
- @Override
- protected Integer getTicketNumber() {
- return 2425;
- }
-
- @Override
- protected String getDescription() {
- return "Tests the removal of individual tabs from an Accordion. No matter what is done in this test the tab caption \"Tab X\" should always match the content \"Tab X\". Use \"remove first\" and \"remove active\" buttons to remove the first or the active tab. The \"reorder\" button reverses the order by adding and removing all components.";
- }
-
- @Override
- protected void setup() {
- accordion = new Accordion();
- for (int i = 1; i <= tab.length; i++) {
- tab[i - 1] = new Label("This is the contents of tab " + i);
- tab[i - 1].setCaption("Tab " + i);
-
- accordion.addComponent(tab[i - 1]);
- }
-
- getLayout().addComponent(accordion);
-
- closeCurrent = new Button("Close current tab");
- closeCurrent.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeCurrentTab();
-
- }
- });
-
- closeFirst = new Button("close first tab");
- closeFirst.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeFirstTab();
-
- }
- });
-
- closeLast = new Button("close last tab");
- closeLast.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeLastTab();
-
- }
- });
-
- reorderTabs = new Button("reorder");
- reorderTabs.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- reorder();
-
- }
- });
-
- getLayout().addComponent(closeFirst);
- getLayout().addComponent(closeLast);
- getLayout().addComponent(closeCurrent);
- getLayout().addComponent(reorderTabs);
-
- }
-
- private void closeCurrentTab() {
- Component c = accordion.getSelectedTab();
- if (c != null) {
- accordion.removeComponent(c);
- }
- }
-
- private void closeFirstTab() {
- accordion.removeComponent(accordion.getComponentIterator().next());
- }
-
- private void closeLastTab() {
- Iterator<Component> i = accordion.getComponentIterator();
- Component last = null;
- while (i.hasNext()) {
- last = i.next();
-
- }
- accordion.removeComponent(last);
- }
-
- private void reorder() {
- AbstractComponentContainer container = accordion;
-
- if (container != null) {
- List<Component> c = new ArrayList<Component>();
- Iterator<Component> i = container.getComponentIterator();
- while (i.hasNext()) {
- Component comp = i.next();
- c.add(comp);
- }
- container.removeAllComponents();
-
- for (int j = c.size() - 1; j >= 0; j--) {
- container.addComponent(c.get(j));
- }
-
- }
- }
-
-}
+package com.vaadin.tests.components.accordion;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractComponentContainer;
+import com.vaadin.ui.Accordion;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+
+public class RemoveTabs extends TestBase {
+
+ private Accordion accordion;
+
+ protected Component[] tab = new Component[5];
+
+ private Button closeCurrent;
+ private Button closeFirst;
+ private Button closeLast;
+ private Button reorderTabs;
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2425;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests the removal of individual tabs from an Accordion. No matter what is done in this test the tab caption \"Tab X\" should always match the content \"Tab X\". Use \"remove first\" and \"remove active\" buttons to remove the first or the active tab. The \"reorder\" button reverses the order by adding and removing all components.";
+ }
+
+ @Override
+ protected void setup() {
+ accordion = new Accordion();
+ for (int i = 1; i <= tab.length; i++) {
+ tab[i - 1] = new Label("This is the contents of tab " + i);
+ tab[i - 1].setCaption("Tab " + i);
+
+ accordion.addComponent(tab[i - 1]);
+ }
+
+ getLayout().addComponent(accordion);
+
+ closeCurrent = new Button("Close current tab");
+ closeCurrent.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeCurrentTab();
+
+ }
+ });
+
+ closeFirst = new Button("close first tab");
+ closeFirst.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeFirstTab();
+
+ }
+ });
+
+ closeLast = new Button("close last tab");
+ closeLast.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeLastTab();
+
+ }
+ });
+
+ reorderTabs = new Button("reorder");
+ reorderTabs.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ reorder();
+
+ }
+ });
+
+ getLayout().addComponent(closeFirst);
+ getLayout().addComponent(closeLast);
+ getLayout().addComponent(closeCurrent);
+ getLayout().addComponent(reorderTabs);
+
+ }
+
+ private void closeCurrentTab() {
+ Component c = accordion.getSelectedTab();
+ if (c != null) {
+ accordion.removeComponent(c);
+ }
+ }
+
+ private void closeFirstTab() {
+ accordion.removeComponent(accordion.getComponentIterator().next());
+ }
+
+ private void closeLastTab() {
+ Iterator<Component> i = accordion.getComponentIterator();
+ Component last = null;
+ while (i.hasNext()) {
+ last = i.next();
+
+ }
+ accordion.removeComponent(last);
+ }
+
+ private void reorder() {
+ AbstractComponentContainer container = accordion;
+
+ if (container != null) {
+ List<Component> c = new ArrayList<Component>();
+ Iterator<Component> i = container.getComponentIterator();
+ while (i.hasNext()) {
+ Component comp = i.next();
+ c.add(comp);
+ }
+ container.removeAllComponents();
+
+ for (int j = c.size() - 1; j >= 0; j--) {
+ container.addComponent(c.get(j));
+ }
+
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonErrorMessage.java b/tests/testbench/com/vaadin/tests/components/button/ButtonErrorMessage.java
index b543c69c51..aca85d4efe 100644
--- a/tests/testbench/com/vaadin/tests/components/button/ButtonErrorMessage.java
+++ b/tests/testbench/com/vaadin/tests/components/button/ButtonErrorMessage.java
@@ -1,31 +1,31 @@
-package com.vaadin.tests.components.button;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-
-public class ButtonErrorMessage extends TestBase {
-
- @Override
- protected void setup() {
- Button b = new Button("Click for error");
- b.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- throw new NullPointerException();
- }
- });
- addComponent(b);
- }
-
- @Override
- protected String getDescription() {
- return "Click the button for an exception. The exception should not contain any extra ',' characters";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3303;
- }
-
-}
+package com.vaadin.tests.components.button;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class ButtonErrorMessage extends TestBase {
+
+ @Override
+ protected void setup() {
+ Button b = new Button("Click for error");
+ b.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ throw new NullPointerException();
+ }
+ });
+ addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the button for an exception. The exception should not contain any extra ',' characters";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3303;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonUndefinedWidth.java b/tests/testbench/com/vaadin/tests/components/button/ButtonUndefinedWidth.java
index 852e41bd05..89b03df92a 100644
--- a/tests/testbench/com/vaadin/tests/components/button/ButtonUndefinedWidth.java
+++ b/tests/testbench/com/vaadin/tests/components/button/ButtonUndefinedWidth.java
@@ -1,40 +1,40 @@
-package com.vaadin.tests.components.button;
-
-import com.vaadin.data.Item;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.Table;
-
-public class ButtonUndefinedWidth extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Both the button outside the table and inside the table should be only as wide as necessary. There should be empty space in the table to the right of the button.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3257;
- }
-
- @Override
- protected void setup() {
- Button b = new Button("Undefined wide");
- addComponent(b);
- NativeButton b2 = new NativeButton("Undefined wide");
- addComponent(b2);
-
- Table t = new Table();
- t.addContainerProperty("A", Button.class, null);
- t.setWidth("500px");
-
- Item i = t.addItem("1");
- i.getItemProperty("A").setValue(new Button("Undef wide"));
- Item i2 = t.addItem("2");
- i2.getItemProperty("A").setValue(new NativeButton("Undef wide"));
-
- addComponent(t);
- }
-
-}
+package com.vaadin.tests.components.button;
+
+import com.vaadin.data.Item;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.Table;
+
+public class ButtonUndefinedWidth extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Both the button outside the table and inside the table should be only as wide as necessary. There should be empty space in the table to the right of the button.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3257;
+ }
+
+ @Override
+ protected void setup() {
+ Button b = new Button("Undefined wide");
+ addComponent(b);
+ NativeButton b2 = new NativeButton("Undefined wide");
+ addComponent(b2);
+
+ Table t = new Table();
+ t.addContainerProperty("A", Button.class, null);
+ t.setWidth("500px");
+
+ Item i = t.addItem("1");
+ i.getItemProperty("A").setValue(new Button("Undef wide"));
+ Item i2 = t.addItem("2");
+ i2.getItemProperty("A").setValue(new NativeButton("Undef wide"));
+
+ addComponent(t);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/button/Buttons2.java b/tests/testbench/com/vaadin/tests/components/button/Buttons2.java
index c18e736082..b65a9fc0cd 100644
--- a/tests/testbench/com/vaadin/tests/components/button/Buttons2.java
+++ b/tests/testbench/com/vaadin/tests/components/button/Buttons2.java
@@ -1,74 +1,74 @@
-package com.vaadin.tests.components.button;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.themes.Reindeer;
-
-public class Buttons2<T extends Button> extends AbstractFieldTest<T> implements
- ClickListener {
-
- private Command<T, Boolean> switchModeCommand = new Command<T, Boolean>() {
-
- @SuppressWarnings("deprecation")
- public void execute(T c, Boolean value, Object data) {
- c.setSwitchMode(value);
- }
- };
-
- private Command<T, Boolean> disableOnClickCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setDisableOnClick(value);
- }
- };
-
- private Command<T, Boolean> clickListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((Button.ClickListener) Buttons2.this);
- } else {
- c.removeListener((Button.ClickListener) Buttons2.this);
- }
-
- }
- };
-
- @Override
- protected Class<T> getTestClass() {
- return (Class<T>) Button.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createBooleanAction("Switch mode", CATEGORY_FEATURES, false,
- switchModeCommand);
- createBooleanAction("Disable on click", CATEGORY_FEATURES, false,
- disableOnClickCommand);
- addClickListener(CATEGORY_LISTENERS);
- }
-
- @Override
- protected void createComponentStyleNames(
- LinkedHashMap<String, String> options) {
- options.put("Reindeer default", Reindeer.BUTTON_DEFAULT);
- options.put("Reindeer small", Reindeer.BUTTON_SMALL);
- options.put("Reindeer link", Reindeer.BUTTON_LINK);
- }
-
- private void addClickListener(String category) {
- createBooleanAction("Click listener", category, false,
- clickListenerCommand);
-
- }
-
- public void buttonClick(ClickEvent event) {
- log(event.getClass().getSimpleName());
- }
-}
+package com.vaadin.tests.components.button;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.themes.Reindeer;
+
+public class Buttons2<T extends Button> extends AbstractFieldTest<T> implements
+ ClickListener {
+
+ private Command<T, Boolean> switchModeCommand = new Command<T, Boolean>() {
+
+ @SuppressWarnings("deprecation")
+ public void execute(T c, Boolean value, Object data) {
+ c.setSwitchMode(value);
+ }
+ };
+
+ private Command<T, Boolean> disableOnClickCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setDisableOnClick(value);
+ }
+ };
+
+ private Command<T, Boolean> clickListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((Button.ClickListener) Buttons2.this);
+ } else {
+ c.removeListener((Button.ClickListener) Buttons2.this);
+ }
+
+ }
+ };
+
+ @Override
+ protected Class<T> getTestClass() {
+ return (Class<T>) Button.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createBooleanAction("Switch mode", CATEGORY_FEATURES, false,
+ switchModeCommand);
+ createBooleanAction("Disable on click", CATEGORY_FEATURES, false,
+ disableOnClickCommand);
+ addClickListener(CATEGORY_LISTENERS);
+ }
+
+ @Override
+ protected void createComponentStyleNames(
+ LinkedHashMap<String, String> options) {
+ options.put("Reindeer default", Reindeer.BUTTON_DEFAULT);
+ options.put("Reindeer small", Reindeer.BUTTON_SMALL);
+ options.put("Reindeer link", Reindeer.BUTTON_LINK);
+ }
+
+ private void addClickListener(String category) {
+ createBooleanAction("Click listener", category, false,
+ clickListenerCommand);
+
+ }
+
+ public void buttonClick(ClickEvent event) {
+ log(event.getClass().getSimpleName());
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java b/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java
index cca76ce418..46d92c3a03 100644
--- a/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java
@@ -1,52 +1,52 @@
-package com.vaadin.tests.components.button;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.themes.BaseTheme;
-
-public class ButtonsInHorizontalLayout extends AbstractTestCase {
-
- @Override
- public void init() {
- VerticalLayout content = new VerticalLayout();
- content.setMargin(true);
- content.setSpacing(true);
-
- content.addComponent(createButtonLayout(null));
- content.addComponent(createButtonLayout(BaseTheme.BUTTON_LINK));
-
- setMainWindow(new Window("", content));
- }
-
- private HorizontalLayout createButtonLayout(String style) {
- HorizontalLayout layout = new HorizontalLayout();
- layout.setSpacing(true);
- layout.addComponent(createButton(style));
- layout.addComponent(createButton(style));
- layout.addComponent(createButton(style));
- return layout;
- }
-
- private Button createButton(String style) {
- Button button = new Button(
- "Look at me in IE7 or IE8 in compatibility mode");
- if (style != null && style.length() != 0) {
- button.setStyleName(style);
- }
- return button;
- }
-
- @Override
- protected String getDescription() {
- return "Tests for rendering of buttons in a HorizontalLayout";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7978;
- }
-
-}
+package com.vaadin.tests.components.button;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.BaseTheme;
+
+public class ButtonsInHorizontalLayout extends AbstractTestCase {
+
+ @Override
+ public void init() {
+ VerticalLayout content = new VerticalLayout();
+ content.setMargin(true);
+ content.setSpacing(true);
+
+ content.addComponent(createButtonLayout(null));
+ content.addComponent(createButtonLayout(BaseTheme.BUTTON_LINK));
+
+ setMainWindow(new Window("", content));
+ }
+
+ private HorizontalLayout createButtonLayout(String style) {
+ HorizontalLayout layout = new HorizontalLayout();
+ layout.setSpacing(true);
+ layout.addComponent(createButton(style));
+ layout.addComponent(createButton(style));
+ layout.addComponent(createButton(style));
+ return layout;
+ }
+
+ private Button createButton(String style) {
+ Button button = new Button(
+ "Look at me in IE7 or IE8 in compatibility mode");
+ if (style != null && style.length() != 0) {
+ button.setStyleName(style);
+ }
+ return button;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests for rendering of buttons in a HorizontalLayout";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7978;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/button/TooltipForDisabledButton.java b/tests/testbench/com/vaadin/tests/components/button/TooltipForDisabledButton.java
index 3fed5b9c02..4952b4bc50 100644
--- a/tests/testbench/com/vaadin/tests/components/button/TooltipForDisabledButton.java
+++ b/tests/testbench/com/vaadin/tests/components/button/TooltipForDisabledButton.java
@@ -1,48 +1,48 @@
-package com.vaadin.tests.components.button;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-
-public class TooltipForDisabledButton extends TestBase {
-
- @Override
- protected String getDescription() {
- return "A disabled button should show a tooltip when hovering it";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2085;
- }
-
- @Override
- protected void setup() {
- Button buttonEnabled = new Button("This is an enabled button");
- Button buttonDisabled = new Button("This is an disabled button");
- buttonDisabled.setEnabled(false);
-
- buttonEnabled.setDescription("Tooltip for enabled");
- buttonDisabled.setDescription("Tooltip for disabled");
-
- buttonDisabled.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- getMainWindow().showNotification("Clicked Disabled");
- }
-
- });
-
- buttonEnabled.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- getMainWindow().showNotification("Clicked Enabled");
- }
-
- });
-
- addComponent(buttonEnabled);
- addComponent(buttonDisabled);
- }
-
-}
+package com.vaadin.tests.components.button;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class TooltipForDisabledButton extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "A disabled button should show a tooltip when hovering it";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2085;
+ }
+
+ @Override
+ protected void setup() {
+ Button buttonEnabled = new Button("This is an enabled button");
+ Button buttonDisabled = new Button("This is an disabled button");
+ buttonDisabled.setEnabled(false);
+
+ buttonEnabled.setDescription("Tooltip for enabled");
+ buttonDisabled.setDescription("Tooltip for disabled");
+
+ buttonDisabled.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().showNotification("Clicked Disabled");
+ }
+
+ });
+
+ buttonEnabled.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().showNotification("Clicked Enabled");
+ }
+
+ });
+
+ addComponent(buttonEnabled);
+ addComponent(buttonDisabled);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/caption/EmptyCaptions.java b/tests/testbench/com/vaadin/tests/components/caption/EmptyCaptions.java
index 86f0bd6b9d..8e0e8d1071 100644
--- a/tests/testbench/com/vaadin/tests/components/caption/EmptyCaptions.java
+++ b/tests/testbench/com/vaadin/tests/components/caption/EmptyCaptions.java
@@ -1,56 +1,56 @@
-package com.vaadin.tests.components.caption;
-
-import com.vaadin.terminal.UserError;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.TextField;
-
-public class EmptyCaptions extends TestBase {
-
- @Override
- protected void setup() {
- TextField tf;
-
- tf = new TextField(null, "Null caption");
- addComponent(tf);
-
- tf = new TextField("", "Empty caption");
- addComponent(tf);
-
- tf = new TextField(" ", "Space as caption");
- addComponent(tf);
-
- tf = new TextField(null, "Null caption, required");
- tf.setRequired(true);
- addComponent(tf);
- tf = new TextField("", "Empty caption, required");
- tf.setRequired(true);
- addComponent(tf);
- tf = new TextField(" ", "Space as caption, required");
- tf.setRequired(true);
- addComponent(tf);
-
- tf = new TextField(null, "Null caption, error");
- tf.setComponentError(new UserError("error"));
- addComponent(tf);
-
- tf = new TextField("", "Empty caption, error");
- tf.setComponentError(new UserError("error"));
- addComponent(tf);
-
- tf = new TextField(" ", "Space as caption, error");
- tf.setComponentError(new UserError("error"));
- addComponent(tf);
-
- }
-
- @Override
- protected String getDescription() {
- return "Null caption should never use space while a non-null caption always should use space.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3846;
- }
-
-}
+package com.vaadin.tests.components.caption;
+
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.TextField;
+
+public class EmptyCaptions extends TestBase {
+
+ @Override
+ protected void setup() {
+ TextField tf;
+
+ tf = new TextField(null, "Null caption");
+ addComponent(tf);
+
+ tf = new TextField("", "Empty caption");
+ addComponent(tf);
+
+ tf = new TextField(" ", "Space as caption");
+ addComponent(tf);
+
+ tf = new TextField(null, "Null caption, required");
+ tf.setRequired(true);
+ addComponent(tf);
+ tf = new TextField("", "Empty caption, required");
+ tf.setRequired(true);
+ addComponent(tf);
+ tf = new TextField(" ", "Space as caption, required");
+ tf.setRequired(true);
+ addComponent(tf);
+
+ tf = new TextField(null, "Null caption, error");
+ tf.setComponentError(new UserError("error"));
+ addComponent(tf);
+
+ tf = new TextField("", "Empty caption, error");
+ tf.setComponentError(new UserError("error"));
+ addComponent(tf);
+
+ tf = new TextField(" ", "Space as caption, error");
+ tf.setComponentError(new UserError("error"));
+ addComponent(tf);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Null caption should never use space while a non-null caption always should use space.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3846;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes.java b/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes.java
index 0efa8bc818..f4d65b8d53 100644
--- a/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes.java
+++ b/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes.java
@@ -1,76 +1,76 @@
-package com.vaadin.tests.components.checkbox;
-
-import java.util.Date;
-
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.CheckBox;
-
-public class CheckBoxes extends ComponentTestCase<CheckBox> {
-
- private ThemeResource SMALL_ICON = new ThemeResource(
- "../runo/icons/16/ok.png");
- private ThemeResource LARGE_ICON = new ThemeResource(
- "../runo/icons/64/document.png");
- private ThemeResource LARGE_ICON_NOCACHE = new ThemeResource(
- "../runo/icons/64/document.png?" + new Date().getTime());
-
- @Override
- protected Class<CheckBox> getTestClass() {
- return CheckBox.class;
- }
-
- @Override
- protected void initializeComponents() {
-
- setTheme("tests-tickets");
- CheckBox cb;
-
- cb = createCheckBox("CheckBox with normal text");
- addTestComponent(cb);
-
- cb = createCheckBox("CheckBox with large text");
- cb.setStyleName("large");
- addTestComponent(cb);
-
- cb = createCheckBox("CheckBox with normal text and small icon",
- SMALL_ICON);
- addTestComponent(cb);
- cb = createCheckBox("CheckBox with large text and small icon",
- SMALL_ICON);
- cb.setStyleName("large");
- addTestComponent(cb);
-
- cb = createCheckBox("CheckBox with normal text and large icon",
- LARGE_ICON);
- addTestComponent(cb);
- cb = createCheckBox("CheckBox with large text and large icon",
- LARGE_ICON_NOCACHE);
- cb.setStyleName("large");
- addTestComponent(cb);
-
- }
-
- private CheckBox createCheckBox(String caption, Resource icon) {
- CheckBox cb = createCheckBox(caption);
- cb.setIcon(icon);
-
- return cb;
- }
-
- private CheckBox createCheckBox(String caption) {
- return new CheckBox(caption);
- }
-
- @Override
- protected String getDescription() {
- return "A generic test for CheckBoxes in different configurations";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
+package com.vaadin.tests.components.checkbox;
+
+import java.util.Date;
+
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.CheckBox;
+
+public class CheckBoxes extends ComponentTestCase<CheckBox> {
+
+ private ThemeResource SMALL_ICON = new ThemeResource(
+ "../runo/icons/16/ok.png");
+ private ThemeResource LARGE_ICON = new ThemeResource(
+ "../runo/icons/64/document.png");
+ private ThemeResource LARGE_ICON_NOCACHE = new ThemeResource(
+ "../runo/icons/64/document.png?" + new Date().getTime());
+
+ @Override
+ protected Class<CheckBox> getTestClass() {
+ return CheckBox.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+
+ setTheme("tests-tickets");
+ CheckBox cb;
+
+ cb = createCheckBox("CheckBox with normal text");
+ addTestComponent(cb);
+
+ cb = createCheckBox("CheckBox with large text");
+ cb.setStyleName("large");
+ addTestComponent(cb);
+
+ cb = createCheckBox("CheckBox with normal text and small icon",
+ SMALL_ICON);
+ addTestComponent(cb);
+ cb = createCheckBox("CheckBox with large text and small icon",
+ SMALL_ICON);
+ cb.setStyleName("large");
+ addTestComponent(cb);
+
+ cb = createCheckBox("CheckBox with normal text and large icon",
+ LARGE_ICON);
+ addTestComponent(cb);
+ cb = createCheckBox("CheckBox with large text and large icon",
+ LARGE_ICON_NOCACHE);
+ cb.setStyleName("large");
+ addTestComponent(cb);
+
+ }
+
+ private CheckBox createCheckBox(String caption, Resource icon) {
+ CheckBox cb = createCheckBox(caption);
+ cb.setIcon(icon);
+
+ return cb;
+ }
+
+ private CheckBox createCheckBox(String caption) {
+ return new CheckBox(caption);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A generic test for CheckBoxes in different configurations";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes2.java b/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes2.java
index 20f1ece65e..2af1e41867 100644
--- a/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes2.java
+++ b/tests/testbench/com/vaadin/tests/components/checkbox/CheckBoxes2.java
@@ -1,56 +1,56 @@
-package com.vaadin.tests.components.checkbox;
-
-import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-
-public class CheckBoxes2 extends AbstractFieldTest<CheckBox> implements
- ClickListener {
-
- // cannot extend Buttons2 because of Switch mode problems
-
- @Override
- protected Class<CheckBox> getTestClass() {
- return CheckBox.class;
- }
-
- private Command<CheckBox, Boolean> switchModeCommand = new Command<CheckBox, Boolean>() {
-
- @SuppressWarnings("deprecation")
- public void execute(CheckBox c, Boolean value, Object data) {
- c.setSwitchMode(value);
- }
- };
-
- private Command<CheckBox, Boolean> clickListenerCommand = new Command<CheckBox, Boolean>() {
-
- public void execute(CheckBox c, Boolean value, Object data) {
- if (value) {
- c.addListener((ClickListener) CheckBoxes2.this);
- } else {
- c.removeListener((ClickListener) CheckBoxes2.this);
- }
-
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createBooleanAction("Switch mode", CATEGORY_FEATURES, true,
- switchModeCommand);
- addClickListener(CATEGORY_LISTENERS);
- }
-
- private void addClickListener(String category) {
- createBooleanAction("Click listener", category, false,
- clickListenerCommand);
-
- }
-
- public void buttonClick(ClickEvent event) {
- log(event.getClass().getSimpleName());
- }
-}
+package com.vaadin.tests.components.checkbox;
+
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+
+public class CheckBoxes2 extends AbstractFieldTest<CheckBox> implements
+ ClickListener {
+
+ // cannot extend Buttons2 because of Switch mode problems
+
+ @Override
+ protected Class<CheckBox> getTestClass() {
+ return CheckBox.class;
+ }
+
+ private Command<CheckBox, Boolean> switchModeCommand = new Command<CheckBox, Boolean>() {
+
+ @SuppressWarnings("deprecation")
+ public void execute(CheckBox c, Boolean value, Object data) {
+ c.setSwitchMode(value);
+ }
+ };
+
+ private Command<CheckBox, Boolean> clickListenerCommand = new Command<CheckBox, Boolean>() {
+
+ public void execute(CheckBox c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ClickListener) CheckBoxes2.this);
+ } else {
+ c.removeListener((ClickListener) CheckBoxes2.this);
+ }
+
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createBooleanAction("Switch mode", CATEGORY_FEATURES, true,
+ switchModeCommand);
+ addClickListener(CATEGORY_LISTENERS);
+ }
+
+ private void addClickListener(String category) {
+ createBooleanAction("Click listener", category, false,
+ clickListenerCommand);
+
+ }
+
+ public void buttonClick(ClickEvent event) {
+ log(event.getClass().getSimpleName());
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxCaptionWrapping.java b/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxCaptionWrapping.java
index 540af083c4..463d53a4a8 100644
--- a/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxCaptionWrapping.java
+++ b/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxCaptionWrapping.java
@@ -1,39 +1,39 @@
-package com.vaadin.tests.components.checkbox;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-public class CheckboxCaptionWrapping extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The checkbox caption consists of 10 words which should all be shown. There should be no extra white space between the checkbox caption and the label below it.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3263;
- }
-
- @Override
- protected void setup() {
- setTheme("tests-tickets");
- VerticalLayout mainLayout = new VerticalLayout();
- CheckBox cb = new CheckBox(
- "Checkbox with some Incididunt ut labore et dolore magna aliqua.");
- cb.setStyleName("wrap");
- cb.setWidth("100%");
- mainLayout.setStyleName("borders");
- mainLayout.setWidth("300px");
- mainLayout.addComponent(cb);
- mainLayout.addComponent(new Label(
- "Lorem ipsum dolor sit amet, consectetur adipisicing"
- + " elit, sed do eiusmod tempor."));
-
- addComponent(mainLayout);
-
- }
-
-}
+package com.vaadin.tests.components.checkbox;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class CheckboxCaptionWrapping extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The checkbox caption consists of 10 words which should all be shown. There should be no extra white space between the checkbox caption and the label below it.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3263;
+ }
+
+ @Override
+ protected void setup() {
+ setTheme("tests-tickets");
+ VerticalLayout mainLayout = new VerticalLayout();
+ CheckBox cb = new CheckBox(
+ "Checkbox with some Incididunt ut labore et dolore magna aliqua.");
+ cb.setStyleName("wrap");
+ cb.setWidth("100%");
+ mainLayout.setStyleName("borders");
+ mainLayout.setWidth("300px");
+ mainLayout.addComponent(cb);
+ mainLayout.addComponent(new Label(
+ "Lorem ipsum dolor sit amet, consectetur adipisicing"
+ + " elit, sed do eiusmod tempor."));
+
+ addComponent(mainLayout);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxIcon.java b/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxIcon.java
index 1f96a05084..6fa714a6d7 100644
--- a/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxIcon.java
+++ b/tests/testbench/com/vaadin/tests/components/checkbox/CheckboxIcon.java
@@ -1,29 +1,29 @@
-package com.vaadin.tests.components.checkbox;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.CheckBox;
-
-public class CheckboxIcon extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The icon of a Checkbox component should have the same cursor as the text and should be clickable. The tooltip should appear when hovering the checkbox, the icon or the caption.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected void setup() {
- CheckBox checkbox = new CheckBox("A checkbox");
- checkbox.setIcon(new ThemeResource("../runo/icons/32/calendar.png"));
- checkbox.setDescription("Tooltip for checkbox");
-
- addComponent(checkbox);
- }
-
-}
+package com.vaadin.tests.components.checkbox;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+
+public class CheckboxIcon extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The icon of a Checkbox component should have the same cursor as the text and should be clickable. The tooltip should appear when hovering the checkbox, the icon or the caption.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void setup() {
+ CheckBox checkbox = new CheckBox("A checkbox");
+ checkbox.setIcon(new ThemeResource("../runo/icons/32/calendar.png"));
+ checkbox.setDescription("Tooltip for checkbox");
+
+ addComponent(checkbox);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
index adeaede187..9285983b99 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
@@ -1,102 +1,102 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-
-@SuppressWarnings("serial")
-public class ComboBoxDataSourceChange extends TestBase {
-
- private ComboBox cb2;
-
- @Override
- protected void setup() {
- final IndexedContainer ds1 = new IndexedContainer();
- // ds1.addContainerProperty("caption", String.class, "");
- for (int i = 0; i < 32; i++) {
- ds1.addItem("ds1-" + i);
- }
-
- final IndexedContainer ds2 = new IndexedContainer();
- // ds2.addContainerProperty("caption", String.class, "");
- for (int i = 0; i < 32; i++) {
- ds2.addItem("ds2-" + i);
- }
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.setWidth("100%");
-
- cb2 = new ComboBox();
- cb2.setImmediate(true);
- hl.addComponent(cb2);
- HorizontalLayout state = new HorizontalLayout();
- state.setSpacing(true);
- hl.addComponent(state);
-
- final Label currentValue = new Label();
- currentValue.setCaption("Current Value:");
- currentValue.setSizeUndefined();
- final Label currentDS = new Label();
- currentDS.setCaption("Current DS:");
- currentDS.setSizeUndefined();
- state.addComponent(currentValue);
- state.addComponent(currentDS);
-
- Table t = new Table("ds1");
- t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- t.setContainerDataSource(ds1);
- state.addComponent(t);
-
- Button b = new Button("Use ds1");
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cb2.setContainerDataSource(ds1);
- currentDS.setValue("ds1");
- }
- });
- state.addComponent(b);
-
- t = new Table("ds2");
- t.setContainerDataSource(ds2);
- t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- state.addComponent(t);
-
- b = new Button("Use ds2");
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cb2.setContainerDataSource(ds2);
- currentDS.setValue("ds2");
- }
- });
- state.addComponent(b);
-
- addComponent(hl);
-
- cb2.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- currentValue.setValue(event.getProperty().getValue());
- }
- });
- }
-
- @Override
- protected String getDescription() {
- return "A test for combobox and its container changes.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO should be list of integers applies for #5279
- return 4607;
- }
-
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+@SuppressWarnings("serial")
+public class ComboBoxDataSourceChange extends TestBase {
+
+ private ComboBox cb2;
+
+ @Override
+ protected void setup() {
+ final IndexedContainer ds1 = new IndexedContainer();
+ // ds1.addContainerProperty("caption", String.class, "");
+ for (int i = 0; i < 32; i++) {
+ ds1.addItem("ds1-" + i);
+ }
+
+ final IndexedContainer ds2 = new IndexedContainer();
+ // ds2.addContainerProperty("caption", String.class, "");
+ for (int i = 0; i < 32; i++) {
+ ds2.addItem("ds2-" + i);
+ }
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setWidth("100%");
+
+ cb2 = new ComboBox();
+ cb2.setImmediate(true);
+ hl.addComponent(cb2);
+ HorizontalLayout state = new HorizontalLayout();
+ state.setSpacing(true);
+ hl.addComponent(state);
+
+ final Label currentValue = new Label();
+ currentValue.setCaption("Current Value:");
+ currentValue.setSizeUndefined();
+ final Label currentDS = new Label();
+ currentDS.setCaption("Current DS:");
+ currentDS.setSizeUndefined();
+ state.addComponent(currentValue);
+ state.addComponent(currentDS);
+
+ Table t = new Table("ds1");
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ t.setContainerDataSource(ds1);
+ state.addComponent(t);
+
+ Button b = new Button("Use ds1");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cb2.setContainerDataSource(ds1);
+ currentDS.setValue("ds1");
+ }
+ });
+ state.addComponent(b);
+
+ t = new Table("ds2");
+ t.setContainerDataSource(ds2);
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ state.addComponent(t);
+
+ b = new Button("Use ds2");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cb2.setContainerDataSource(ds2);
+ currentDS.setValue("ds2");
+ }
+ });
+ state.addComponent(b);
+
+ addComponent(hl);
+
+ cb2.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentValue.setValue(event.getProperty().getValue());
+ }
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A test for combobox and its container changes.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO should be list of integers applies for #5279
+ return 4607;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java
index 6178d25a2a..d9739602f6 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java
@@ -1,49 +1,49 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.ComboBox;
-
-public class ComboBoxEnablesComboBox extends TestBase {
-
- private ComboBox cb2;
-
- @Override
- protected void setup() {
- ComboBox cb = new ComboBox("Always enabled");
- cb.setImmediate(true);
- populate(cb);
- cb.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- cb2.setEnabled(true);
- }
-
- });
- cb2 = new ComboBox("Initially disabled");
- cb2.setImmediate(true);
- cb2.setEnabled(false);
- populate(cb2);
-
- addComponent(cb);
- addComponent(cb2);
- }
-
- private void populate(ComboBox cb) {
- for (int i = 1; i < 10; i++) {
- cb.addItem("Item " + i);
- }
- }
-
- @Override
- protected String getDescription() {
- return "Selecting an item in the first combobox enables the second.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4632;
- }
-
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxEnablesComboBox extends TestBase {
+
+ private ComboBox cb2;
+
+ @Override
+ protected void setup() {
+ ComboBox cb = new ComboBox("Always enabled");
+ cb.setImmediate(true);
+ populate(cb);
+ cb.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ cb2.setEnabled(true);
+ }
+
+ });
+ cb2 = new ComboBox("Initially disabled");
+ cb2.setImmediate(true);
+ cb2.setEnabled(false);
+ populate(cb2);
+
+ addComponent(cb);
+ addComponent(cb2);
+ }
+
+ private void populate(ComboBox cb) {
+ for (int i = 1; i < 10; i++) {
+ cb.addItem("Item " + i);
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Selecting an item in the first combobox enables the second.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4632;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.java
index dcd4af58ad..fd434a7acd 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.java
@@ -1,54 +1,54 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.ComboBox;
-
-public class ComboBoxIdenticalItems extends TestBase {
-
- private Log log = new Log(5);
-
- @Override
- public void setup() {
- final ComboBox select = new ComboBox("ComboBox");
- select.addContainerProperty("caption", String.class, null);
- Item item = select.addItem("one-1");
- item.getItemProperty("caption").setValue("One");
- item = select.addItem("one-2");
- item.getItemProperty("caption").setValue("One");
- item = select.addItem("two");
- item.getItemProperty("caption").setValue("Two");
- select.setItemCaptionPropertyId("caption");
- select.setNullSelectionAllowed(false);
- select.setImmediate(true);
- select.addListener(new Property.ValueChangeListener() {
- private static final long serialVersionUID = -7932700771673919620L;
-
- public void valueChange(ValueChangeEvent event) {
- log.log("Item " + select.getValue() + " selected");
-
- }
- });
-
- addComponent(log);
- addComponent(select);
- }
-
- @Override
- protected String getDescription() {
- return "Keyboard selecting of a value is broken in combobox if two "
- + "items have the same caption. The first item's id is \"One-1\" "
- + "while the second one is \"One-2\". Selecting with mouse works "
- + "as expected but selecting with keyboard always returns the "
- + "object \"One-1\".";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxIdenticalItems extends TestBase {
+
+ private Log log = new Log(5);
+
+ @Override
+ public void setup() {
+ final ComboBox select = new ComboBox("ComboBox");
+ select.addContainerProperty("caption", String.class, null);
+ Item item = select.addItem("one-1");
+ item.getItemProperty("caption").setValue("One");
+ item = select.addItem("one-2");
+ item.getItemProperty("caption").setValue("One");
+ item = select.addItem("two");
+ item.getItemProperty("caption").setValue("Two");
+ select.setItemCaptionPropertyId("caption");
+ select.setNullSelectionAllowed(false);
+ select.setImmediate(true);
+ select.addListener(new Property.ValueChangeListener() {
+ private static final long serialVersionUID = -7932700771673919620L;
+
+ public void valueChange(ValueChangeEvent event) {
+ log.log("Item " + select.getValue() + " selected");
+
+ }
+ });
+
+ addComponent(log);
+ addComponent(select);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Keyboard selecting of a value is broken in combobox if two "
+ + "items have the same caption. The first item's id is \"One-1\" "
+ + "while the second one is \"One-2\". Selecting with mouse works "
+ + "as expected but selecting with keyboard always returns the "
+ + "object \"One-1\".";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java
index 2fcb44d4f2..e11b10f3e1 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java
@@ -1,76 +1,76 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComboBox;
-
-public class ComboBoxInvalidNullSelection extends TestBase {
-
- private static final Object CAPTION = "C";
- private IndexedContainer ds1;
- private IndexedContainer ds2;
- private ComboBox combo;
- private Log log = new Log(5);
-
- @Override
- protected void setup() {
-
- createDataSources();
-
- Button b = new Button("Swap data source");
- b.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (combo.getContainerDataSource() == ds1) {
- combo.setContainerDataSource(ds2);
- } else {
- combo.setContainerDataSource(ds1);
- }
- combo.setValue("Item 3");
- }
- });
-
- combo = new ComboBox();
- combo.setImmediate(true);
- combo.setContainerDataSource(ds1);
- combo.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- log.log("Value is now: " + combo.getValue());
- }
- });
- addComponent(log);
- addComponent(b);
- addComponent(combo);
- addComponent(new Button("Dummy for TestBench"));
- }
-
- private void createDataSources() {
- ds1 = new IndexedContainer();
- ds1.addContainerProperty(CAPTION, String.class, "");
- ds1.addItem("Item 1");
- ds1.addItem("Item 2");
- ds1.addItem("Item 3");
- ds1.addItem("Item 4");
-
- ds2 = new IndexedContainer();
- ds2.addContainerProperty(CAPTION, String.class, "");
- ds2.addItem("Item 3");
-
- }
-
- @Override
- protected String getDescription() {
- return "Select \"Item 3\" in the ComboBox, change the data source, focus and blur the ComboBox. The value should temporarily change to null when changing data source but not when focusing and blurring the ComboBox";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6170;
- }
-
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxInvalidNullSelection extends TestBase {
+
+ private static final Object CAPTION = "C";
+ private IndexedContainer ds1;
+ private IndexedContainer ds2;
+ private ComboBox combo;
+ private Log log = new Log(5);
+
+ @Override
+ protected void setup() {
+
+ createDataSources();
+
+ Button b = new Button("Swap data source");
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (combo.getContainerDataSource() == ds1) {
+ combo.setContainerDataSource(ds2);
+ } else {
+ combo.setContainerDataSource(ds1);
+ }
+ combo.setValue("Item 3");
+ }
+ });
+
+ combo = new ComboBox();
+ combo.setImmediate(true);
+ combo.setContainerDataSource(ds1);
+ combo.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ log.log("Value is now: " + combo.getValue());
+ }
+ });
+ addComponent(log);
+ addComponent(b);
+ addComponent(combo);
+ addComponent(new Button("Dummy for TestBench"));
+ }
+
+ private void createDataSources() {
+ ds1 = new IndexedContainer();
+ ds1.addContainerProperty(CAPTION, String.class, "");
+ ds1.addItem("Item 1");
+ ds1.addItem("Item 2");
+ ds1.addItem("Item 3");
+ ds1.addItem("Item 4");
+
+ ds2 = new IndexedContainer();
+ ds2.addContainerProperty(CAPTION, String.class, "");
+ ds2.addItem("Item 3");
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Select \"Item 3\" in the ComboBox, change the data source, focus and blur the ComboBox. The value should temporarily change to null when changing data source but not when focusing and blurring the ComboBox";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6170;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxTextFieldEventOrder.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxTextFieldEventOrder.java
index 31979a6a90..d92a1872b8 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxTextFieldEventOrder.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxTextFieldEventOrder.java
@@ -1,38 +1,38 @@
-package com.vaadin.tests.components.combobox;
-import java.util.Arrays;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.TextField;
-
-public class ComboBoxTextFieldEventOrder extends TestBase {
-
- @Override
- protected void setup() {
- TextField textField = new TextField("text field");
- textField.setImmediate(true);
- final Select select = new Select("select", Arrays.asList("1", "2", "3",
- "4"));
- textField.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- select.addItem(Long.valueOf(select.size() + 1).toString()); // or
- // just
- // select.requestRepaint();
- }
- });
- addComponent(textField);
- addComponent(select);
- }
-
- @Override
- protected String getDescription() {
- return "Entering a text in a TextField and then clicking on the button in a ComboBox should cause the TextField value change to be sent first and the ComboBox filtering afterwards. Failure to do so will cause errors if the value change listener modifies the ComboBox";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7481;
- }
-}
+package com.vaadin.tests.components.combobox;
+import java.util.Arrays;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.TextField;
+
+public class ComboBoxTextFieldEventOrder extends TestBase {
+
+ @Override
+ protected void setup() {
+ TextField textField = new TextField("text field");
+ textField.setImmediate(true);
+ final Select select = new Select("select", Arrays.asList("1", "2", "3",
+ "4"));
+ textField.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ select.addItem(Long.valueOf(select.size() + 1).toString()); // or
+ // just
+ // select.requestRepaint();
+ }
+ });
+ addComponent(textField);
+ addComponent(select);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Entering a text in a TextField and then clicking on the button in a ComboBox should cause the TextField value change to be sent first and the ComboBox filtering afterwards. Failure to do so will cause errors if the value change listener modifies the ComboBox";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7481;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java
index fd5f7d47f8..eb28a9ff4e 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java
@@ -1,36 +1,36 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.data.Item;
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.ComboBox;
-
-public class ComboBoxUndefinedWidthAndIcon extends TestBase {
- @Override
- protected void setup() {
- ComboBox cb = new ComboBox();
- cb.addContainerProperty("caption", String.class, null);
- cb.addContainerProperty("icon", Resource.class, null);
- for (int i = 1; i < 200 + 1; i++) {
- Item item = cb.addItem(i);
- item.getItemProperty("caption").setValue("Item " + i);
- item.getItemProperty("icon").setValue(
- new ThemeResource("../runo/icons/16/users.png"));
- }
- cb.setItemIconPropertyId("icon");
- cb.setItemCaptionPropertyId("caption");
-
- addComponent(cb);
- }
-
- @Override
- protected String getDescription() {
- return "The width of the ComboBox should be fixed even though it is set to undefined width. The width should not change when changing pages in the dropdown.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7013;
- }
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Item;
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxUndefinedWidthAndIcon extends TestBase {
+ @Override
+ protected void setup() {
+ ComboBox cb = new ComboBox();
+ cb.addContainerProperty("caption", String.class, null);
+ cb.addContainerProperty("icon", Resource.class, null);
+ for (int i = 1; i < 200 + 1; i++) {
+ Item item = cb.addItem(i);
+ item.getItemProperty("caption").setValue("Item " + i);
+ item.getItemProperty("icon").setValue(
+ new ThemeResource("../runo/icons/16/users.png"));
+ }
+ cb.setItemIconPropertyId("icon");
+ cb.setItemCaptionPropertyId("caption");
+
+ addComponent(cb);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The width of the ComboBox should be fixed even though it is set to undefined width. The width should not change when changing pages in the dropdown.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7013;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxValueInput.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
index 177b3542a4..9e1fab0cda 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
@@ -1,63 +1,63 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.ComboBox;
-
-public class ComboBoxValueInput extends TestBase {
-
- @Override
- protected void setup() {
- (getLayout()).setSpacing(true);
-
- ComboBox cb = getComboBox("A combobox", false);
- addComponent(cb);
-
- cb = getComboBox("A combobox with input prompt", false);
- cb.setInputPrompt("Please select");
- addComponent(cb);
-
- cb = getComboBox("A combobox with null item", true);
- addComponent(cb);
-
- cb = getComboBox("A combobox with null item and input prompt", true);
- cb.setInputPrompt("Please select");
- addComponent(cb);
-
- cb = getComboBox("A disabled combobox", true);
- cb.setEnabled(false);
- addComponent(cb);
-
- cb = getComboBox("A read-only combobox", true);
- cb.setReadOnly(true);
- addComponent(cb);
-
- cb = getComboBox("A combobox with filteringMode off", false);
- cb.setFilteringMode(ComboBox.FILTERINGMODE_OFF);
-
- }
-
- @Override
- protected String getDescription() {
- return "A combobox should always show the selected value when it is not focused. Entering a text when nothing is selected and blurring the combobox should reset the value. The same should happen when a value is selected";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3268;
- }
-
- private ComboBox getComboBox(String caption, boolean addNullItem) {
- ComboBox cb = new ComboBox(caption);
- cb.setImmediate(true);
- if (addNullItem) {
- cb.addItem("Null item");
- cb.setNullSelectionItemId("Null item");
- }
- cb.addItem("Value 1");
- cb.addItem("Value 2");
- cb.addItem("Value 3");
-
- return cb;
- }
-
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxValueInput extends TestBase {
+
+ @Override
+ protected void setup() {
+ (getLayout()).setSpacing(true);
+
+ ComboBox cb = getComboBox("A combobox", false);
+ addComponent(cb);
+
+ cb = getComboBox("A combobox with input prompt", false);
+ cb.setInputPrompt("Please select");
+ addComponent(cb);
+
+ cb = getComboBox("A combobox with null item", true);
+ addComponent(cb);
+
+ cb = getComboBox("A combobox with null item and input prompt", true);
+ cb.setInputPrompt("Please select");
+ addComponent(cb);
+
+ cb = getComboBox("A disabled combobox", true);
+ cb.setEnabled(false);
+ addComponent(cb);
+
+ cb = getComboBox("A read-only combobox", true);
+ cb.setReadOnly(true);
+ addComponent(cb);
+
+ cb = getComboBox("A combobox with filteringMode off", false);
+ cb.setFilteringMode(ComboBox.FILTERINGMODE_OFF);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A combobox should always show the selected value when it is not focused. Entering a text when nothing is selected and blurring the combobox should reset the value. The same should happen when a value is selected";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3268;
+ }
+
+ private ComboBox getComboBox(String caption, boolean addNullItem) {
+ ComboBox cb = new ComboBox(caption);
+ cb.setImmediate(true);
+ if (addNullItem) {
+ cb.addItem("Null item");
+ cb.setNullSelectionItemId("Null item");
+ }
+ cb.addItem("Value 1");
+ cb.addItem("Value 2");
+ cb.addItem("Value 3");
+
+ return cb;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboxBoxErrorMessage.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboxBoxErrorMessage.java
index a6eaf7d3e6..7f0816c842 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboxBoxErrorMessage.java
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboxBoxErrorMessage.java
@@ -1,26 +1,26 @@
-package com.vaadin.tests.components.combobox;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.ComboBox;
-
-public class ComboxBoxErrorMessage extends TestBase {
-
- @Override
- protected void setup() {
- ComboBox cb = new ComboBox("");
- cb.setRequired(true);
- cb.setRequiredError("You must select something");
- addComponent(cb);
- }
-
- @Override
- protected String getDescription() {
- return "The ComboBox should show an \"You must select something\" tooltip when the cursor is hovering it. Both when hovering the textfield and the dropdown button.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3345;
- }
-
-}
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+
+public class ComboxBoxErrorMessage extends TestBase {
+
+ @Override
+ protected void setup() {
+ ComboBox cb = new ComboBox("");
+ cb.setRequired(true);
+ cb.setRequiredError("You must select something");
+ addComponent(cb);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The ComboBox should show an \"You must select something\" tooltip when the cursor is hovering it. Both when hovering the textfield and the dropdown button.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3345;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/customcomponent/ClipContent.java b/tests/testbench/com/vaadin/tests/components/customcomponent/ClipContent.java
index cc7320ad03..8bc464f176 100644
--- a/tests/testbench/com/vaadin/tests/components/customcomponent/ClipContent.java
+++ b/tests/testbench/com/vaadin/tests/components/customcomponent/ClipContent.java
@@ -1,56 +1,56 @@
-package com.vaadin.tests.components.customcomponent;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-
-public class ClipContent extends TestBase {
-
- @Override
- protected void setup() {
-
- Label text = new Label(
- "1_long_line_that_should_be_clipped<br/>2_long_line_that_should_be_clipped<br/>3_long_line_that_should_be_clipped<br/>4_long_line_that_should_be_clipped<br/>",
- Label.CONTENT_XHTML);
-
- final CustomComponent cc = new CustomComponent(text);
- cc.setWidth("20px");
- cc.setHeight("20px");
-
- final TextField w = new TextField("Width");
- w.setValue("20px");
- w.addListener(new TextField.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- cc.setWidth((String) w.getValue());
- }
- });
- addComponent(w);
- final TextField h = new TextField("Height");
- h.setValue("20px");
- h.addListener(new TextField.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- cc.setHeight((String) h.getValue());
- }
- });
- addComponent(h);
- Button b = new Button("apply");
- addComponent(b);
-
- addComponent(cc);
-
- }
-
- @Override
- protected String getDescription() {
- return "The text in CustomComponent should be clipped if it has size defined.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
+package com.vaadin.tests.components.customcomponent;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+
+public class ClipContent extends TestBase {
+
+ @Override
+ protected void setup() {
+
+ Label text = new Label(
+ "1_long_line_that_should_be_clipped<br/>2_long_line_that_should_be_clipped<br/>3_long_line_that_should_be_clipped<br/>4_long_line_that_should_be_clipped<br/>",
+ Label.CONTENT_XHTML);
+
+ final CustomComponent cc = new CustomComponent(text);
+ cc.setWidth("20px");
+ cc.setHeight("20px");
+
+ final TextField w = new TextField("Width");
+ w.setValue("20px");
+ w.addListener(new TextField.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ cc.setWidth((String) w.getValue());
+ }
+ });
+ addComponent(w);
+ final TextField h = new TextField("Height");
+ h.setValue("20px");
+ h.addListener(new TextField.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ cc.setHeight((String) h.getValue());
+ }
+ });
+ addComponent(h);
+ Button b = new Button("apply");
+ addComponent(b);
+
+ addComponent(cc);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The text in CustomComponent should be clipped if it has size defined.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java b/tests/testbench/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
index 575a1651e3..43d4c70eb8 100644
--- a/tests/testbench/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
+++ b/tests/testbench/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
@@ -1,44 +1,44 @@
-package com.vaadin.tests.components.customcomponent;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.NativeButton;
-
-public class CustomComponentSizeUpdate extends TestBase {
-
- @Override
- protected void setup() {
- NativeButton nb = new NativeButton(
- "100%x100% button. Click to reduce CustomComponent size");
- nb.setSizeFull();
-
- final CustomComponent cc = new CustomComponent(nb);
- cc.setWidth("500px");
- cc.setHeight("500px");
-
- nb.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cc.setWidth((cc.getWidth() - 20) + "px");
- cc.setHeight((cc.getHeight() - 20) + "px");
-
- }
- });
-
- addComponent(cc);
-
- }
-
- @Override
- protected String getDescription() {
- return "Click the button to reduce the size of the parent. The button should be resized to fit the parent.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3705;
- }
-
-}
+package com.vaadin.tests.components.customcomponent;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.NativeButton;
+
+public class CustomComponentSizeUpdate extends TestBase {
+
+ @Override
+ protected void setup() {
+ NativeButton nb = new NativeButton(
+ "100%x100% button. Click to reduce CustomComponent size");
+ nb.setSizeFull();
+
+ final CustomComponent cc = new CustomComponent(nb);
+ cc.setWidth("500px");
+ cc.setHeight("500px");
+
+ nb.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cc.setWidth((cc.getWidth() - 20) + "px");
+ cc.setHeight((cc.getHeight() - 20) + "px");
+
+ }
+ });
+
+ addComponent(cc);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the button to reduce the size of the parent. The button should be resized to fit the parent.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3705;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/CustomDateFormats.java b/tests/testbench/com/vaadin/tests/components/datefield/CustomDateFormats.java
index 7f67af1adc..48bf3622d1 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/CustomDateFormats.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/CustomDateFormats.java
@@ -1,207 +1,207 @@
-package com.vaadin.tests.components.datefield;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.NativeSelect;
-
-public class CustomDateFormats extends TestBase {
-
- private static final Object CAPTION = "C";
-
- private Component customFormats = null;
-
- @Override
- protected void setup() {
- final NativeSelect s = new NativeSelect("Locale");
- s.setImmediate(true);
- s.setNullSelectionAllowed(false);
- s.addContainerProperty(CAPTION, String.class, "");
- addLocale(Locale.FRANCE, s);
- addLocale(Locale.CHINESE, s);
- addLocale(Locale.US, s);
- addLocale(Locale.UK, s);
- addLocale(new Locale("fi", "FI"), s);
-
- s.addListener(new Property.ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- setDateFieldLocale((Locale) s.getValue());
- }
- });
- addComponent(s);
- s.setValue(Locale.FRANCE);
- }
-
- private void addLocale(Locale locale, NativeSelect s) {
- Item i = s.addItem(locale);
- i.getItemProperty(CAPTION).setValue(locale.toString());
-
- }
-
- protected void setDateFieldLocale(Locale value) {
- Component n = getCustomFormats(value);
- if (customFormats == null) {
- addComponent(n);
- } else {
- replaceComponent(customFormats, n);
- }
- customFormats = n;
-
- }
-
- private GridLayout getCustomFormats(Locale locale) {
- GridLayout gridLayout = createGridLayout();
- usedDebugIds.clear();
- addDateFields(gridLayout, locale);
-
- return gridLayout;
- }
-
- private GridLayout createGridLayout() {
- GridLayout gridLayout = new GridLayout(4, 4);
- gridLayout.setMargin(true);
- gridLayout.addComponent(new Label("FORMAT"));
- gridLayout.addComponent(new Label("DATEFIELD"));
- gridLayout.addComponent(new Label("SERVER SIDE VALUE"));
- gridLayout.addComponent(new Label("EXPECTED"));
-
- return gridLayout;
- }
-
- private void addDateFields(GridLayout gridLayout, Locale locale) {
- addDateField(gridLayout, "d M yyyy", locale);
- addDateField(gridLayout, "d MM yyyy", locale);
- addDateField(gridLayout, "d MMM yyyy", locale);
- addDateField(gridLayout, "d MMMM yyyy", locale);
-
- addDateField(gridLayout, "dd M yyyy", locale);
- addDateField(gridLayout, "ddd M yyyy", locale);
-
- addDateField(gridLayout, "d M y", locale, "d M yyyy");
- addDateField(gridLayout, "d M yy", locale);
- addDateField(gridLayout, "d M yyy", locale, "d M yyyy");
- addDateField(gridLayout, "d M yyyy", locale);
-
- addDateField(gridLayout, getDatePattern(locale, DateFormat.FULL),
- locale);
- addDateField(gridLayout, getDatePattern(locale, DateFormat.LONG),
- locale);
- addDateField(gridLayout, getDatePattern(locale, DateFormat.MEDIUM),
- locale);
- addDateField(gridLayout, getDatePattern(locale, DateFormat.SHORT),
- locale);
-
- }
-
- private String getDatePattern(Locale locale, int dateStyle) {
- DateFormat dateFormat = DateFormat.getDateInstance(dateStyle, locale);
-
- if (dateFormat instanceof SimpleDateFormat) {
- String pattern = ((SimpleDateFormat) dateFormat).toPattern();
- return pattern;
- }
- return null;
-
- }
-
- public class Data {
-
- private Label label;
- private String pattern;
-
- public Data(Label label, String pattern) {
- this.label = label;
- this.pattern = pattern;
- }
-
- }
-
- private Set<String> usedDebugIds = new HashSet<String>();
-
- private void addDateField(GridLayout gridLayout, String pattern,
- Locale locale, String expectedDateFormat) {
- Calendar cal = Calendar.getInstance();
- cal.set(2010, 1, 1);
-
- Label serversideValueLabel = new Label();
-
- DateField df = new DateField();
- df.setResolution(DateField.RESOLUTION_DAY);
- df.setLocale(locale);
- df.setWidth("300px");
- df.setDateFormat(pattern);
- df.setImmediate(true);
- String debugId = pattern.replace('/', 'X');
- while (usedDebugIds.contains(debugId)) {
- debugId = debugId + "-";
- }
- df.setDebugId(debugId);
- usedDebugIds.add(debugId);
-
- df.setData(new Data(serversideValueLabel, pattern));
- df.setValue(cal.getTime());
- df.addListener(new Property.ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- updateServerSideLabel((DateField) event.getProperty());
- }
- });
-
- Label patternLabel = new Label(pattern);
- patternLabel.setWidth(null);
- SimpleDateFormat expDateFormat = new SimpleDateFormat(
- expectedDateFormat, locale);
-
- Label expectedLabel = new Label(expDateFormat.format(cal.getTime()));
- if (!pattern.equals(expectedDateFormat)) {
- expectedLabel.setValue(expectedLabel.getValue()
- + " (differs from JDK)");
- }
- expectedLabel.setWidth(null);
-
- gridLayout.addComponent(patternLabel);
- gridLayout.addComponent(df);
- gridLayout.addComponent(serversideValueLabel);
- gridLayout.addComponent(expectedLabel);
-
- updateServerSideLabel(df);
- }
-
- private void updateServerSideLabel(DateField df) {
- Data data = (Data) df.getData();
- String pattern = data.pattern;
- Locale locale = df.getLocale();
- SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
-
- String newValue = formatter.format(df.getValue());
- data.label.setValue(newValue);
- }
-
- private void addDateField(GridLayout gridLayout, String pattern,
- Locale locale) {
- addDateField(gridLayout, pattern, locale, pattern);
- }
-
- @Override
- protected String getDescription() {
- return "Test that DateField renders custom date formats the same way as SimpleDateFormat formats them";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5465;
- }
+package com.vaadin.tests.components.datefield;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.NativeSelect;
+
+public class CustomDateFormats extends TestBase {
+
+ private static final Object CAPTION = "C";
+
+ private Component customFormats = null;
+
+ @Override
+ protected void setup() {
+ final NativeSelect s = new NativeSelect("Locale");
+ s.setImmediate(true);
+ s.setNullSelectionAllowed(false);
+ s.addContainerProperty(CAPTION, String.class, "");
+ addLocale(Locale.FRANCE, s);
+ addLocale(Locale.CHINESE, s);
+ addLocale(Locale.US, s);
+ addLocale(Locale.UK, s);
+ addLocale(new Locale("fi", "FI"), s);
+
+ s.addListener(new Property.ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ setDateFieldLocale((Locale) s.getValue());
+ }
+ });
+ addComponent(s);
+ s.setValue(Locale.FRANCE);
+ }
+
+ private void addLocale(Locale locale, NativeSelect s) {
+ Item i = s.addItem(locale);
+ i.getItemProperty(CAPTION).setValue(locale.toString());
+
+ }
+
+ protected void setDateFieldLocale(Locale value) {
+ Component n = getCustomFormats(value);
+ if (customFormats == null) {
+ addComponent(n);
+ } else {
+ replaceComponent(customFormats, n);
+ }
+ customFormats = n;
+
+ }
+
+ private GridLayout getCustomFormats(Locale locale) {
+ GridLayout gridLayout = createGridLayout();
+ usedDebugIds.clear();
+ addDateFields(gridLayout, locale);
+
+ return gridLayout;
+ }
+
+ private GridLayout createGridLayout() {
+ GridLayout gridLayout = new GridLayout(4, 4);
+ gridLayout.setMargin(true);
+ gridLayout.addComponent(new Label("FORMAT"));
+ gridLayout.addComponent(new Label("DATEFIELD"));
+ gridLayout.addComponent(new Label("SERVER SIDE VALUE"));
+ gridLayout.addComponent(new Label("EXPECTED"));
+
+ return gridLayout;
+ }
+
+ private void addDateFields(GridLayout gridLayout, Locale locale) {
+ addDateField(gridLayout, "d M yyyy", locale);
+ addDateField(gridLayout, "d MM yyyy", locale);
+ addDateField(gridLayout, "d MMM yyyy", locale);
+ addDateField(gridLayout, "d MMMM yyyy", locale);
+
+ addDateField(gridLayout, "dd M yyyy", locale);
+ addDateField(gridLayout, "ddd M yyyy", locale);
+
+ addDateField(gridLayout, "d M y", locale, "d M yyyy");
+ addDateField(gridLayout, "d M yy", locale);
+ addDateField(gridLayout, "d M yyy", locale, "d M yyyy");
+ addDateField(gridLayout, "d M yyyy", locale);
+
+ addDateField(gridLayout, getDatePattern(locale, DateFormat.FULL),
+ locale);
+ addDateField(gridLayout, getDatePattern(locale, DateFormat.LONG),
+ locale);
+ addDateField(gridLayout, getDatePattern(locale, DateFormat.MEDIUM),
+ locale);
+ addDateField(gridLayout, getDatePattern(locale, DateFormat.SHORT),
+ locale);
+
+ }
+
+ private String getDatePattern(Locale locale, int dateStyle) {
+ DateFormat dateFormat = DateFormat.getDateInstance(dateStyle, locale);
+
+ if (dateFormat instanceof SimpleDateFormat) {
+ String pattern = ((SimpleDateFormat) dateFormat).toPattern();
+ return pattern;
+ }
+ return null;
+
+ }
+
+ public class Data {
+
+ private Label label;
+ private String pattern;
+
+ public Data(Label label, String pattern) {
+ this.label = label;
+ this.pattern = pattern;
+ }
+
+ }
+
+ private Set<String> usedDebugIds = new HashSet<String>();
+
+ private void addDateField(GridLayout gridLayout, String pattern,
+ Locale locale, String expectedDateFormat) {
+ Calendar cal = Calendar.getInstance();
+ cal.set(2010, 1, 1);
+
+ Label serversideValueLabel = new Label();
+
+ DateField df = new DateField();
+ df.setResolution(DateField.RESOLUTION_DAY);
+ df.setLocale(locale);
+ df.setWidth("300px");
+ df.setDateFormat(pattern);
+ df.setImmediate(true);
+ String debugId = pattern.replace('/', 'X');
+ while (usedDebugIds.contains(debugId)) {
+ debugId = debugId + "-";
+ }
+ df.setDebugId(debugId);
+ usedDebugIds.add(debugId);
+
+ df.setData(new Data(serversideValueLabel, pattern));
+ df.setValue(cal.getTime());
+ df.addListener(new Property.ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ updateServerSideLabel((DateField) event.getProperty());
+ }
+ });
+
+ Label patternLabel = new Label(pattern);
+ patternLabel.setWidth(null);
+ SimpleDateFormat expDateFormat = new SimpleDateFormat(
+ expectedDateFormat, locale);
+
+ Label expectedLabel = new Label(expDateFormat.format(cal.getTime()));
+ if (!pattern.equals(expectedDateFormat)) {
+ expectedLabel.setValue(expectedLabel.getValue()
+ + " (differs from JDK)");
+ }
+ expectedLabel.setWidth(null);
+
+ gridLayout.addComponent(patternLabel);
+ gridLayout.addComponent(df);
+ gridLayout.addComponent(serversideValueLabel);
+ gridLayout.addComponent(expectedLabel);
+
+ updateServerSideLabel(df);
+ }
+
+ private void updateServerSideLabel(DateField df) {
+ Data data = (Data) df.getData();
+ String pattern = data.pattern;
+ Locale locale = df.getLocale();
+ SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
+
+ String newValue = formatter.format(df.getValue());
+ data.label.setValue(newValue);
+ }
+
+ private void addDateField(GridLayout gridLayout, String pattern,
+ Locale locale) {
+ addDateField(gridLayout, pattern, locale, pattern);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test that DateField renders custom date formats the same way as SimpleDateFormat formats them";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5465;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
index 53b1d253ab..440f004531 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
@@ -1,144 +1,144 @@
-package com.vaadin.tests.components.datefield;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.PopupDateField;
-
-@SuppressWarnings("serial")
-public class DateFieldEmptyValid extends TestBase {
-
- private Log log;
-
- private MyDateField df;
-
- private SimpleDateFormat formatter = new SimpleDateFormat(
- "MMMM d, yyyy hh:mm:ss aaa", Locale.US);
-
- public class MyDateField extends PopupDateField {
- @Override
- public boolean isEmpty() {
- return super.isEmpty();
- }
-
- }
-
- @Override
- protected void setup() {
- addComponent(new Label("<br/><br/>", Label.CONTENT_XHTML));
- log = new Log(8);
- addComponent(log);
- df = new MyDateField();
- df.setDebugId("DateField");
- df.setRequired(true);
- df.setLocale(new Locale("fi", "FI"));
- df.setValue(new Date(100000000000L));
- df.setImmediate(true);
- df.setResolution(DateField.RESOLUTION_DAY);
- df.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- log.log("Value changeEvent");
- checkEmpty();
- }
- });
- addComponent(df);
- checkEmpty();
- Button b = new Button("Clear date");
- b.setDebugId("clear");
- b.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- log.log("Clearing date aka setValue(null)");
- df.setValue(null);
- }
- });
- addComponent(b);
-
- b = new Button("Set date to 4.5.1990");
- b.setDebugId("set4.5.1990");
- b.addListener(new ClickListener() {
-
- @SuppressWarnings("deprecation")
- public void buttonClick(ClickEvent event) {
- log.log("Setting new value to datefield (4.5.1990)");
- df.setValue(new Date(1990 - 1900, 5 - 1, 4));
- }
- });
- addComponent(b);
-
- b = new Button("Set date to 5.6.2000 using a property data source");
- b.addListener(new ClickListener() {
-
- @SuppressWarnings("deprecation")
- public void buttonClick(ClickEvent event) {
- log.log("Setting new object property (5.6.2000) to datefield");
- ObjectProperty<Date> dfProp = new ObjectProperty<Date>(
- new Date(2000 - 1900, 6 - 1, 5), Date.class);
- df.setPropertyDataSource(dfProp);
- }
- });
- b.setDebugId("set-by-ds");
- addComponent(b);
-
- b = new Button(
- "Set date to 27.8.2005 by changing a new property data source from null, ds attached before value setting.");
- b.setDebugId("set-via-ds");
- b.addListener(new ClickListener() {
-
- @SuppressWarnings("deprecation")
- public void buttonClick(ClickEvent event) {
- log.log("Setting object property (with value null) to datefield and set value of property to 27.8.2005");
- ObjectProperty<Date> dfProp = new ObjectProperty<Date>(null,
- Date.class);
- df.setPropertyDataSource(dfProp);
- dfProp.setValue(new Date(2005 - 1900, 8 - 1, 27));
- }
- });
- addComponent(b);
-
- b = new Button("Check value");
- b.setDebugId("check-value");
- b.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- log.log("Checking state");
- checkEmpty();
- }
- });
- addComponent(b);
- }
-
- private void checkEmpty() {
- Object value = df.getValue();
- if (value instanceof Date) {
- value = formatter.format(df.getValue());
- }
-
- log.log("DateField value is now " + value);
- // log.log("DateField value is now " + df.getValue());
- log.log("isEmpty: " + df.isEmpty() + ", isValid: " + df.isValid());
- }
-
- @Override
- protected String getDescription() {
- return "Tests the isEmpty() and isValid() functionality of a DateField. The field is required and has no other validators."
- + "IsEmpty() should return true when the field is truly empty i.e. contains no text, no matter how the field has been made empty. If the field contains any text, isEmpty() should return false."
- + "IsValid() should in this case return true if the field is not empty and vice versa.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5277;
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupDateField;
+
+@SuppressWarnings("serial")
+public class DateFieldEmptyValid extends TestBase {
+
+ private Log log;
+
+ private MyDateField df;
+
+ private SimpleDateFormat formatter = new SimpleDateFormat(
+ "MMMM d, yyyy hh:mm:ss aaa", Locale.US);
+
+ public class MyDateField extends PopupDateField {
+ @Override
+ public boolean isEmpty() {
+ return super.isEmpty();
+ }
+
+ }
+
+ @Override
+ protected void setup() {
+ addComponent(new Label("<br/><br/>", Label.CONTENT_XHTML));
+ log = new Log(8);
+ addComponent(log);
+ df = new MyDateField();
+ df.setDebugId("DateField");
+ df.setRequired(true);
+ df.setLocale(new Locale("fi", "FI"));
+ df.setValue(new Date(100000000000L));
+ df.setImmediate(true);
+ df.setResolution(DateField.RESOLUTION_DAY);
+ df.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ log.log("Value changeEvent");
+ checkEmpty();
+ }
+ });
+ addComponent(df);
+ checkEmpty();
+ Button b = new Button("Clear date");
+ b.setDebugId("clear");
+ b.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ log.log("Clearing date aka setValue(null)");
+ df.setValue(null);
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Set date to 4.5.1990");
+ b.setDebugId("set4.5.1990");
+ b.addListener(new ClickListener() {
+
+ @SuppressWarnings("deprecation")
+ public void buttonClick(ClickEvent event) {
+ log.log("Setting new value to datefield (4.5.1990)");
+ df.setValue(new Date(1990 - 1900, 5 - 1, 4));
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Set date to 5.6.2000 using a property data source");
+ b.addListener(new ClickListener() {
+
+ @SuppressWarnings("deprecation")
+ public void buttonClick(ClickEvent event) {
+ log.log("Setting new object property (5.6.2000) to datefield");
+ ObjectProperty<Date> dfProp = new ObjectProperty<Date>(
+ new Date(2000 - 1900, 6 - 1, 5), Date.class);
+ df.setPropertyDataSource(dfProp);
+ }
+ });
+ b.setDebugId("set-by-ds");
+ addComponent(b);
+
+ b = new Button(
+ "Set date to 27.8.2005 by changing a new property data source from null, ds attached before value setting.");
+ b.setDebugId("set-via-ds");
+ b.addListener(new ClickListener() {
+
+ @SuppressWarnings("deprecation")
+ public void buttonClick(ClickEvent event) {
+ log.log("Setting object property (with value null) to datefield and set value of property to 27.8.2005");
+ ObjectProperty<Date> dfProp = new ObjectProperty<Date>(null,
+ Date.class);
+ df.setPropertyDataSource(dfProp);
+ dfProp.setValue(new Date(2005 - 1900, 8 - 1, 27));
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Check value");
+ b.setDebugId("check-value");
+ b.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("Checking state");
+ checkEmpty();
+ }
+ });
+ addComponent(b);
+ }
+
+ private void checkEmpty() {
+ Object value = df.getValue();
+ if (value instanceof Date) {
+ value = formatter.format(df.getValue());
+ }
+
+ log.log("DateField value is now " + value);
+ // log.log("DateField value is now " + df.getValue());
+ log.log("isEmpty: " + df.isEmpty() + ", isValid: " + df.isValid());
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests the isEmpty() and isValid() functionality of a DateField. The field is required and has no other validators."
+ + "IsEmpty() should return true when the field is truly empty i.e. contains no text, no matter how the field has been made empty. If the field contains any text, isEmpty() should return false."
+ + "IsValid() should in this case return true if the field is not empty and vice versa.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5277;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldLocale.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldLocale.java
index fbeeb872d7..dd61ccd60c 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldLocale.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldLocale.java
@@ -1,47 +1,47 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.DateField;
-
-public class DateFieldLocale extends TestBase {
-
- @Override
- public void setup() {
- final DateField dateField = new DateField("DateField");
- dateField.setLocale(new Locale("fi", "FI"));
- dateField.setCaption(dateField.getLocale().toString());
- dateField.setValue(new Date());
- dateField.setResolution(DateField.RESOLUTION_DAY);
-
- addComponent(new Button("Change locale", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- if (dateField.getLocale().getCountry().equalsIgnoreCase("fi")) {
- dateField.setLocale(new Locale("zh", "CN"));
- } else {
- dateField.setLocale(new Locale("fi", "FI"));
- }
- dateField.setCaption(dateField.getLocale().toString());
- }
- }));
-
- addComponent(dateField);
- }
-
- @Override
- protected String getDescription() {
- return "Click change locale to switch between Finnish and Chinese locale for the DateField. The date string should be updated in addition to the caption.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3935;
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+import java.util.Locale;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.DateField;
+
+public class DateFieldLocale extends TestBase {
+
+ @Override
+ public void setup() {
+ final DateField dateField = new DateField("DateField");
+ dateField.setLocale(new Locale("fi", "FI"));
+ dateField.setCaption(dateField.getLocale().toString());
+ dateField.setValue(new Date());
+ dateField.setResolution(DateField.RESOLUTION_DAY);
+
+ addComponent(new Button("Change locale", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ if (dateField.getLocale().getCountry().equalsIgnoreCase("fi")) {
+ dateField.setLocale(new Locale("zh", "CN"));
+ } else {
+ dateField.setLocale(new Locale("fi", "FI"));
+ }
+ dateField.setCaption(dateField.getLocale().toString());
+ }
+ }));
+
+ addComponent(dateField);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click change locale to switch between Finnish and Chinese locale for the DateField. The date string should be updated in addition to the caption.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3935;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java
index cb3fc1f916..122fd4347f 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java
@@ -1,62 +1,62 @@
-package com.vaadin.tests.components.datefield;
-
-import java.sql.Date;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Window;
-
-public class DateFieldPopupOffScreen extends AbstractTestCase {
-
- @Override
- protected String getDescription() {
- return "Test for the popup position from a DateField. The popup should always be on-screen even if the DateField is close the the edge of the browser.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3639;
- }
-
- @Override
- public void init() {
- Window mainWindow = new Window(getClass().getName());
-
- GridLayout mainLayout = new GridLayout(3, 3);
- mainLayout.setSizeFull();
-
- DateField df;
-
- df = createDateField();
- mainLayout.addComponent(df, 2, 0);
- mainLayout.setComponentAlignment(df, Alignment.TOP_RIGHT);
-
- df = createDateField();
- mainLayout.addComponent(df, 2, 1);
- mainLayout.setComponentAlignment(df, Alignment.MIDDLE_RIGHT);
-
- df = createDateField();
- mainLayout.addComponent(df, 2, 2);
- mainLayout.setComponentAlignment(df, Alignment.BOTTOM_RIGHT);
-
- df = createDateField();
- mainLayout.addComponent(df, 0, 2);
- mainLayout.setComponentAlignment(df, Alignment.BOTTOM_LEFT);
-
- df = createDateField();
- mainLayout.addComponent(df, 1, 2);
- mainLayout.setComponentAlignment(df, Alignment.BOTTOM_CENTER);
-
- mainWindow.setContent(mainLayout);
- setMainWindow(mainWindow);
- }
-
- private DateField createDateField() {
- DateField df = new DateField();
- df.setDescription("This is a long, multiline tooltip.<br/>It should always be on screen so it can be read.");
- df.setValue(new Date(1000000L));
- return df;
- }
-}
+package com.vaadin.tests.components.datefield;
+
+import java.sql.Date;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Window;
+
+public class DateFieldPopupOffScreen extends AbstractTestCase {
+
+ @Override
+ protected String getDescription() {
+ return "Test for the popup position from a DateField. The popup should always be on-screen even if the DateField is close the the edge of the browser.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3639;
+ }
+
+ @Override
+ public void init() {
+ Window mainWindow = new Window(getClass().getName());
+
+ GridLayout mainLayout = new GridLayout(3, 3);
+ mainLayout.setSizeFull();
+
+ DateField df;
+
+ df = createDateField();
+ mainLayout.addComponent(df, 2, 0);
+ mainLayout.setComponentAlignment(df, Alignment.TOP_RIGHT);
+
+ df = createDateField();
+ mainLayout.addComponent(df, 2, 1);
+ mainLayout.setComponentAlignment(df, Alignment.MIDDLE_RIGHT);
+
+ df = createDateField();
+ mainLayout.addComponent(df, 2, 2);
+ mainLayout.setComponentAlignment(df, Alignment.BOTTOM_RIGHT);
+
+ df = createDateField();
+ mainLayout.addComponent(df, 0, 2);
+ mainLayout.setComponentAlignment(df, Alignment.BOTTOM_LEFT);
+
+ df = createDateField();
+ mainLayout.addComponent(df, 1, 2);
+ mainLayout.setComponentAlignment(df, Alignment.BOTTOM_CENTER);
+
+ mainWindow.setContent(mainLayout);
+ setMainWindow(mainWindow);
+ }
+
+ private DateField createDateField() {
+ DateField df = new DateField();
+ df.setDescription("This is a long, multiline tooltip.<br/>It should always be on screen so it can be read.");
+ df.setValue(new Date(1000000L));
+ return df;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldReadOnly.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
index 3084eab32b..516d207a38 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
@@ -1,53 +1,53 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.Calendar;
-import java.util.Locale;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.DateField;
-
-public class DateFieldReadOnly extends TestBase {
-
- @Override
- protected String getDescription() {
- return "A read-only DateField should not show the popup button and not be editable.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3163;
- }
-
- @Override
- protected void setup() {
- final DateField timeField = new DateField("A read-only datefield");
- timeField.setResolution(DateField.RESOLUTION_SEC);
- timeField.setDateFormat("HH:mm:ss");
- timeField.setCaption(null);
- timeField.setIcon(null);
- timeField.setWidth("8em");
- timeField.addStyleName("timeField");
-
- // Set date so that testing always has same time
- Calendar c = Calendar.getInstance(Locale.ENGLISH);
- c.set(2009, 05, 12, 0, 0, 0);
-
- timeField.setValue(c.getTime());
- timeField.setReadOnly(true);
-
- addComponent(timeField);
-
- Button b = new Button("Switch read-only");
- b.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- timeField.setReadOnly(!timeField.isReadOnly());
- }
- });
-
- addComponent(b);
- }
-}
+package com.vaadin.tests.components.datefield;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.DateField;
+
+public class DateFieldReadOnly extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "A read-only DateField should not show the popup button and not be editable.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3163;
+ }
+
+ @Override
+ protected void setup() {
+ final DateField timeField = new DateField("A read-only datefield");
+ timeField.setResolution(DateField.RESOLUTION_SEC);
+ timeField.setDateFormat("HH:mm:ss");
+ timeField.setCaption(null);
+ timeField.setIcon(null);
+ timeField.setWidth("8em");
+ timeField.addStyleName("timeField");
+
+ // Set date so that testing always has same time
+ Calendar c = Calendar.getInstance(Locale.ENGLISH);
+ c.set(2009, 05, 12, 0, 0, 0);
+
+ timeField.setValue(c.getTime());
+ timeField.setReadOnly(true);
+
+ addComponent(timeField);
+
+ Button b = new Button("Switch read-only");
+ b.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ timeField.setReadOnly(!timeField.isReadOnly());
+ }
+ });
+
+ addComponent(b);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldTest.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldTest.java
index cf433257bb..7d1bdfc2c8 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldTest.java
@@ -1,137 +1,137 @@
-package com.vaadin.tests.components.datefield;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-
-import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.ui.DateField;
-
-public class DateFieldTest<T extends DateField> extends AbstractFieldTest<T> {
-
- @Override
- protected Class<T> getTestClass() {
- return (Class<T>) DateField.class;
- }
-
- private Command<T, Date> setValue = new Command<T, Date>() {
-
- public void execute(T c, Date value, Object data) {
- c.setValue(value);
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
- createResolutionSelectAction(CATEGORY_FEATURES);
- createBooleanAction("Lenient", CATEGORY_FEATURES, false, lenientCommand);
- createBooleanAction("Show week numbers", CATEGORY_FEATURES, false,
- weekNumberCommand);
- createDateFormatSelectAction(CATEGORY_FEATURES);
- createSetValueAction(CATEGORY_FEATURES);
-
- };
-
- private void createSetValueAction(String category) {
- LinkedHashMap<String, Date> options = new LinkedHashMap<String, Date>();
- options.put("(null)", null);
- options.put("(current time)", new Date());
- Calendar c = Calendar.getInstance(new Locale("fi", "FI"));
- c.clear();
- c.set(2010, 12 - 1, 12, 12, 0, 0);
- c.set(Calendar.MILLISECOND, 0);
- options.put("2010-12-12 12:00:00.000", c.getTime());
- c.clear();
- c.set(2000, 1 - 1, 2, 3, 4, 5);
- c.set(Calendar.MILLISECOND, 6);
- options.put("2000-01-02 03:04:05.006", c.getTime());
- createMultiClickAction("Set value", category, options, setValue, null);
- }
-
- private void createDateFormatSelectAction(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
-
- options.put("-", null);
- options.put("d M yyyy", "d M yyyy");
- options.put("d MM yyyy", "d MM yyyy");
- options.put("d MMM yyyy", "d MMM yyyy");
- options.put("d MMMM yyyy", "d MMMM yyyy");
- options.put("dd M yyyy", "dd M yyyy");
- options.put("ddd M yyyy", "ddd M yyyy");
- options.put("d M y", "d M y");
- options.put("d M yy", "d M yy");
- options.put("d M yyy", "d M yyy");
- options.put("d M yyyy", "d M yyyy");
- options.put("d M 'custom text' yyyy", "d M 'custom text' yyyy");
- options.put("'day:'d', month:'M', year: 'yyyy",
- "'day:'d', month:'M', year: 'yyyy");
- options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.LONG),
- getDatePattern(new Locale("fi", "FI"), DateFormat.LONG));
- options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM),
- getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM));
- options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT),
- getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT));
-
- createSelectAction("Date format", category, options, "-",
- dateFormatCommand);
-
- }
-
- private String getDatePattern(Locale locale, int dateStyle) {
- DateFormat dateFormat = DateFormat.getDateInstance(dateStyle, locale);
-
- if (dateFormat instanceof SimpleDateFormat) {
- String pattern = ((SimpleDateFormat) dateFormat).toPattern();
- return pattern;
- }
- return null;
-
- }
-
- private void createResolutionSelectAction(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Year", DateField.RESOLUTION_YEAR);
- options.put("Month", DateField.RESOLUTION_MONTH);
- options.put("Day", DateField.RESOLUTION_DAY);
- options.put("Hour", DateField.RESOLUTION_HOUR);
- options.put("Min", DateField.RESOLUTION_MIN);
- options.put("Sec", DateField.RESOLUTION_SEC);
- options.put("Msec", DateField.RESOLUTION_MSEC);
-
- createSelectAction("Resolution", category, options, "Year",
- resolutionCommand);
- }
-
- private Command<T, Integer> resolutionCommand = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.setResolution(value);
-
- }
- };
- private Command<T, Boolean> lenientCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setLenient(false);
-
- }
- };
- private Command<T, Boolean> weekNumberCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setShowISOWeekNumbers(value);
-
- }
- };
- private Command<T, String> dateFormatCommand = new Command<T, String>() {
-
- public void execute(T c, String value, Object data) {
- c.setDateFormat(value);
- }
- };
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.ui.DateField;
+
+public class DateFieldTest<T extends DateField> extends AbstractFieldTest<T> {
+
+ @Override
+ protected Class<T> getTestClass() {
+ return (Class<T>) DateField.class;
+ }
+
+ private Command<T, Date> setValue = new Command<T, Date>() {
+
+ public void execute(T c, Date value, Object data) {
+ c.setValue(value);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createResolutionSelectAction(CATEGORY_FEATURES);
+ createBooleanAction("Lenient", CATEGORY_FEATURES, false, lenientCommand);
+ createBooleanAction("Show week numbers", CATEGORY_FEATURES, false,
+ weekNumberCommand);
+ createDateFormatSelectAction(CATEGORY_FEATURES);
+ createSetValueAction(CATEGORY_FEATURES);
+
+ };
+
+ private void createSetValueAction(String category) {
+ LinkedHashMap<String, Date> options = new LinkedHashMap<String, Date>();
+ options.put("(null)", null);
+ options.put("(current time)", new Date());
+ Calendar c = Calendar.getInstance(new Locale("fi", "FI"));
+ c.clear();
+ c.set(2010, 12 - 1, 12, 12, 0, 0);
+ c.set(Calendar.MILLISECOND, 0);
+ options.put("2010-12-12 12:00:00.000", c.getTime());
+ c.clear();
+ c.set(2000, 1 - 1, 2, 3, 4, 5);
+ c.set(Calendar.MILLISECOND, 6);
+ options.put("2000-01-02 03:04:05.006", c.getTime());
+ createMultiClickAction("Set value", category, options, setValue, null);
+ }
+
+ private void createDateFormatSelectAction(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+
+ options.put("-", null);
+ options.put("d M yyyy", "d M yyyy");
+ options.put("d MM yyyy", "d MM yyyy");
+ options.put("d MMM yyyy", "d MMM yyyy");
+ options.put("d MMMM yyyy", "d MMMM yyyy");
+ options.put("dd M yyyy", "dd M yyyy");
+ options.put("ddd M yyyy", "ddd M yyyy");
+ options.put("d M y", "d M y");
+ options.put("d M yy", "d M yy");
+ options.put("d M yyy", "d M yyy");
+ options.put("d M yyyy", "d M yyyy");
+ options.put("d M 'custom text' yyyy", "d M 'custom text' yyyy");
+ options.put("'day:'d', month:'M', year: 'yyyy",
+ "'day:'d', month:'M', year: 'yyyy");
+ options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.LONG),
+ getDatePattern(new Locale("fi", "FI"), DateFormat.LONG));
+ options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM),
+ getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM));
+ options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT),
+ getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT));
+
+ createSelectAction("Date format", category, options, "-",
+ dateFormatCommand);
+
+ }
+
+ private String getDatePattern(Locale locale, int dateStyle) {
+ DateFormat dateFormat = DateFormat.getDateInstance(dateStyle, locale);
+
+ if (dateFormat instanceof SimpleDateFormat) {
+ String pattern = ((SimpleDateFormat) dateFormat).toPattern();
+ return pattern;
+ }
+ return null;
+
+ }
+
+ private void createResolutionSelectAction(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Year", DateField.RESOLUTION_YEAR);
+ options.put("Month", DateField.RESOLUTION_MONTH);
+ options.put("Day", DateField.RESOLUTION_DAY);
+ options.put("Hour", DateField.RESOLUTION_HOUR);
+ options.put("Min", DateField.RESOLUTION_MIN);
+ options.put("Sec", DateField.RESOLUTION_SEC);
+ options.put("Msec", DateField.RESOLUTION_MSEC);
+
+ createSelectAction("Resolution", category, options, "Year",
+ resolutionCommand);
+ }
+
+ private Command<T, Integer> resolutionCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.setResolution(value);
+
+ }
+ };
+ private Command<T, Boolean> lenientCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setLenient(false);
+
+ }
+ };
+ private Command<T, Boolean> weekNumberCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setShowISOWeekNumbers(value);
+
+ }
+ };
+ private Command<T, String> dateFormatCommand = new Command<T, String>() {
+
+ public void execute(T c, String value, Object data) {
+ c.setDateFormat(value);
+ }
+ };
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java
index 32456e34c5..4f83575b39 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java
@@ -1,101 +1,101 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.Date;
-
-import com.vaadin.data.Property;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.DateField;
-
-public class DateFieldUnparsableDate extends TestBase {
-
- public class MyDateField extends DateField {
- Date oldDate = null;
-
- public MyDateField(String caption) {
- super(caption);
- addListener(new Property.ValueChangeListener() {
- public void valueChange(
- com.vaadin.data.Property.ValueChangeEvent event) {
- oldDate = (Date) getValue();
- }
- });
- }
-
- @Override
- protected Date handleUnparsableDateString(String dateString)
- throws ConversionException {
- return oldDate;
- }
- }
-
- public class MyDateField2 extends DateField {
- public MyDateField2(String caption) {
- super(caption);
- }
-
- @Override
- protected Date handleUnparsableDateString(String dateString)
- throws ConversionException {
- return null;
- }
- }
-
- public class MyDateField3 extends DateField {
- public MyDateField3(String caption) {
- super(caption);
- }
-
- @Override
- protected Date handleUnparsableDateString(String dateString)
- throws ConversionException {
- throw new ConversionException("You should not enter invalid dates!");
- }
- }
-
- public class MyDateField4 extends DateField {
- public MyDateField4(String caption) {
- super(caption);
- }
-
- @Override
- protected Date handleUnparsableDateString(String dateString)
- throws ConversionException {
- if (dateString != null && dateString.equals("today")) {
- return new Date();
- }
- throw new ConversionException("You should not enter invalid dates!");
- }
- }
-
- @Override
- protected void setup() {
- MyDateField df = new MyDateField(
- "Returns the old value for invalid dates");
- df.setImmediate(true);
- addComponent(df);
-
- MyDateField2 df2 = new MyDateField2("Returns empty for invalid dates");
- df2.setImmediate(true);
- addComponent(df2);
-
- MyDateField3 df3 = new MyDateField3(
- "Throws an exception for invalid dates");
- df3.setImmediate(true);
- addComponent(df3);
-
- MyDateField4 df4 = new MyDateField4("Can convert 'today'");
- df4.setImmediate(true);
- addComponent(df4);
-
- }
-
- @Override
- protected String getDescription() {
- return "DateFields in various configurations (according to caption). All handle unparsable dates differently";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4236;
- }
-}
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+
+import com.vaadin.data.Property;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.DateField;
+
+public class DateFieldUnparsableDate extends TestBase {
+
+ public class MyDateField extends DateField {
+ Date oldDate = null;
+
+ public MyDateField(String caption) {
+ super(caption);
+ addListener(new Property.ValueChangeListener() {
+ public void valueChange(
+ com.vaadin.data.Property.ValueChangeEvent event) {
+ oldDate = (Date) getValue();
+ }
+ });
+ }
+
+ @Override
+ protected Date handleUnparsableDateString(String dateString)
+ throws ConversionException {
+ return oldDate;
+ }
+ }
+
+ public class MyDateField2 extends DateField {
+ public MyDateField2(String caption) {
+ super(caption);
+ }
+
+ @Override
+ protected Date handleUnparsableDateString(String dateString)
+ throws ConversionException {
+ return null;
+ }
+ }
+
+ public class MyDateField3 extends DateField {
+ public MyDateField3(String caption) {
+ super(caption);
+ }
+
+ @Override
+ protected Date handleUnparsableDateString(String dateString)
+ throws ConversionException {
+ throw new ConversionException("You should not enter invalid dates!");
+ }
+ }
+
+ public class MyDateField4 extends DateField {
+ public MyDateField4(String caption) {
+ super(caption);
+ }
+
+ @Override
+ protected Date handleUnparsableDateString(String dateString)
+ throws ConversionException {
+ if (dateString != null && dateString.equals("today")) {
+ return new Date();
+ }
+ throw new ConversionException("You should not enter invalid dates!");
+ }
+ }
+
+ @Override
+ protected void setup() {
+ MyDateField df = new MyDateField(
+ "Returns the old value for invalid dates");
+ df.setImmediate(true);
+ addComponent(df);
+
+ MyDateField2 df2 = new MyDateField2("Returns empty for invalid dates");
+ df2.setImmediate(true);
+ addComponent(df2);
+
+ MyDateField3 df3 = new MyDateField3(
+ "Throws an exception for invalid dates");
+ df3.setImmediate(true);
+ addComponent(df3);
+
+ MyDateField4 df4 = new MyDateField4("Can convert 'today'");
+ df4.setImmediate(true);
+ addComponent(df4);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "DateFields in various configurations (according to caption). All handle unparsable dates differently";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4236;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java b/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java
index ba4e324dc1..3c42d71af5 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java
@@ -1,33 +1,33 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.Date;
-
-import com.vaadin.terminal.UserError;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.DateField;
-
-public class DatePopupStyleName extends TestBase {
- @Override
- public void setup() {
- setTheme("reindeer-tests");
-
- final DateField df = new DateField();
- df.setValue(new Date(1203910239L));
- df.setWidth("200px");
- df.setRequired(true);
- df.setComponentError(new UserError("abc"));
- df.addStyleName("popup-style");
- addComponent(df);
- }
-
- @Override
- protected String getDescription() {
- return "The DateField is given a style name 'test', but that style isn't applied on the calendar popup element.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 8083;
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.DateField;
+
+public class DatePopupStyleName extends TestBase {
+ @Override
+ public void setup() {
+ setTheme("reindeer-tests");
+
+ final DateField df = new DateField();
+ df.setValue(new Date(1203910239L));
+ df.setWidth("200px");
+ df.setRequired(true);
+ df.setComponentError(new UserError("abc"));
+ df.addStyleName("popup-style");
+ addComponent(df);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The DateField is given a style name 'test', but that style isn't applied on the calendar popup element.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8083;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java b/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
index 33156b9a75..8f201e120d 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.datefield;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.GridLayout;
-
-public class DisabledDateFieldWidth extends TestBase {
- @Override
- public void setup() {
-
- final DateField dateField1 = new DateField("DateField");
- dateField1.setResolution(DateField.RESOLUTION_YEAR);
- dateField1.setEnabled(false);
-
- Button button = new Button("Repaint datefield",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- dateField1.requestRepaint();
- }
- });
-
- GridLayout gl = new GridLayout(3, 1);
- gl.addComponent(dateField1);
- gl.addComponent(button);
-
- addComponent(gl);
- }
-
- @Override
- protected String getDescription() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-}
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.GridLayout;
+
+public class DisabledDateFieldWidth extends TestBase {
+ @Override
+ public void setup() {
+
+ final DateField dateField1 = new DateField("DateField");
+ dateField1.setResolution(DateField.RESOLUTION_YEAR);
+ dateField1.setEnabled(false);
+
+ Button button = new Button("Repaint datefield",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ dateField1.requestRepaint();
+ }
+ });
+
+ GridLayout gl = new GridLayout(3, 1);
+ gl.addComponent(dateField1);
+ gl.addComponent(button);
+
+ addComponent(gl);
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldTest.java b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldTest.java
index c2384584e2..1c8d8cfae6 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFieldTest.java
@@ -1,12 +1,12 @@
-package com.vaadin.tests.components.datefield;
-
-import com.vaadin.ui.InlineDateField;
-
-public class InlineDateFieldTest extends DateFieldTest<InlineDateField> {
-
- @Override
- protected Class<InlineDateField> getTestClass() {
- return InlineDateField.class;
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.ui.InlineDateField;
+
+public class InlineDateFieldTest extends DateFieldTest<InlineDateField> {
+
+ @Override
+ protected Class<InlineDateField> getTestClass() {
+ return InlineDateField.class;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java
index 083e8f0190..56f3641043 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/InlineDateFields.java
@@ -1,106 +1,106 @@
-package com.vaadin.tests.components.datefield;
-
-import java.sql.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.InlineDateField;
-
-@SuppressWarnings("serial")
-public class InlineDateFields extends ComponentTestCase<InlineDateField> {
-
- private static final Locale[] LOCALES = new Locale[] { Locale.US,
- Locale.TAIWAN, new Locale("fi", "FI") };
-
- @Override
- protected Class<InlineDateField> getTestClass() {
- return InlineDateField.class;
- }
-
- @Override
- protected void initializeComponents() {
-
- Locale locale = LOCALES[0];
-
- InlineDateField pd = createInlineDateField("Undefined width", "-1",
- locale);
- pd.setDebugId("Locale-" + locale.toString() + "-undefined-wide");
- addTestComponent(pd);
- pd = createInlineDateField("300px width", "300px", locale);
- pd.setDebugId("Locale-" + locale.toString() + "-300px-wide");
- addTestComponent(pd);
- pd = createInlineDateField("Initially empty", "", locale);
- pd.setValue(null);
- pd.setDebugId("Locale-" + locale.toString() + "-initially-empty");
- addTestComponent(pd);
-
- }
-
- private InlineDateField createInlineDateField(String caption, String width,
- Locale locale) {
- InlineDateField pd = new InlineDateField(caption + "("
- + locale.toString() + ")");
- pd.setWidth(width);
- pd.setValue(new Date(12312312313L));
- pd.setLocale(locale);
- pd.setResolution(DateField.RESOLUTION_YEAR);
-
- return pd;
- }
-
- @Override
- protected String getDescription() {
- return "A generic test for InlineDateFields in different configurations";
- }
-
- @Override
- protected List<Component> createActions() {
- List<Component> actions = super.createActions();
- actions.add(createResolutionSelectAction());
- actions.add(createLocaleSelectAction());
- return actions;
- }
-
- private Component createResolutionSelectAction() {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Year", DateField.RESOLUTION_YEAR);
- options.put("Month", DateField.RESOLUTION_MONTH);
- options.put("Day", DateField.RESOLUTION_DAY);
- options.put("Hour", DateField.RESOLUTION_HOUR);
- options.put("Min", DateField.RESOLUTION_MIN);
- options.put("Sec", DateField.RESOLUTION_SEC);
- options.put("Msec", DateField.RESOLUTION_MSEC);
- return createSelectAction("Resolution", options, "Year",
- new Command<InlineDateField, Integer>() {
-
- public void execute(InlineDateField c, Integer value,
- Object data) {
- c.setResolution(value);
-
- }
- });
- }
-
- private Component createLocaleSelectAction() {
- LinkedHashMap<String, Locale> options = new LinkedHashMap<String, Locale>();
- for (Locale locale : LOCALES) {
- options.put(locale.toString(), locale);
- }
- return createSelectAction("Locale", options, LOCALES[0].toString(),
- new Command<InlineDateField, Locale>() {
-
- public void execute(InlineDateField c, Locale value,
- Object data) {
- c.setCaption(c.getCaption().replaceAll(
- c.getLocale().toString(), value.toString()));
- c.setLocale(value);
-
- }
- });
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.sql.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.InlineDateField;
+
+@SuppressWarnings("serial")
+public class InlineDateFields extends ComponentTestCase<InlineDateField> {
+
+ private static final Locale[] LOCALES = new Locale[] { Locale.US,
+ Locale.TAIWAN, new Locale("fi", "FI") };
+
+ @Override
+ protected Class<InlineDateField> getTestClass() {
+ return InlineDateField.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+
+ Locale locale = LOCALES[0];
+
+ InlineDateField pd = createInlineDateField("Undefined width", "-1",
+ locale);
+ pd.setDebugId("Locale-" + locale.toString() + "-undefined-wide");
+ addTestComponent(pd);
+ pd = createInlineDateField("300px width", "300px", locale);
+ pd.setDebugId("Locale-" + locale.toString() + "-300px-wide");
+ addTestComponent(pd);
+ pd = createInlineDateField("Initially empty", "", locale);
+ pd.setValue(null);
+ pd.setDebugId("Locale-" + locale.toString() + "-initially-empty");
+ addTestComponent(pd);
+
+ }
+
+ private InlineDateField createInlineDateField(String caption, String width,
+ Locale locale) {
+ InlineDateField pd = new InlineDateField(caption + "("
+ + locale.toString() + ")");
+ pd.setWidth(width);
+ pd.setValue(new Date(12312312313L));
+ pd.setLocale(locale);
+ pd.setResolution(DateField.RESOLUTION_YEAR);
+
+ return pd;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A generic test for InlineDateFields in different configurations";
+ }
+
+ @Override
+ protected List<Component> createActions() {
+ List<Component> actions = super.createActions();
+ actions.add(createResolutionSelectAction());
+ actions.add(createLocaleSelectAction());
+ return actions;
+ }
+
+ private Component createResolutionSelectAction() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Year", DateField.RESOLUTION_YEAR);
+ options.put("Month", DateField.RESOLUTION_MONTH);
+ options.put("Day", DateField.RESOLUTION_DAY);
+ options.put("Hour", DateField.RESOLUTION_HOUR);
+ options.put("Min", DateField.RESOLUTION_MIN);
+ options.put("Sec", DateField.RESOLUTION_SEC);
+ options.put("Msec", DateField.RESOLUTION_MSEC);
+ return createSelectAction("Resolution", options, "Year",
+ new Command<InlineDateField, Integer>() {
+
+ public void execute(InlineDateField c, Integer value,
+ Object data) {
+ c.setResolution(value);
+
+ }
+ });
+ }
+
+ private Component createLocaleSelectAction() {
+ LinkedHashMap<String, Locale> options = new LinkedHashMap<String, Locale>();
+ for (Locale locale : LOCALES) {
+ options.put(locale.toString(), locale);
+ }
+ return createSelectAction("Locale", options, LOCALES[0].toString(),
+ new Command<InlineDateField, Locale>() {
+
+ public void execute(InlineDateField c, Locale value,
+ Object data) {
+ c.setCaption(c.getCaption().replaceAll(
+ c.getLocale().toString(), value.toString()));
+ c.setLocale(value);
+
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java b/tests/testbench/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java
index 73ec3b659e..dab47ebdd9 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java
@@ -1,34 +1,34 @@
-package com.vaadin.tests.components.datefield;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.PopupDateField;
-import com.vaadin.ui.Table;
-
-public class NarrowPopupDateFieldInTable extends TestBase {
-
- private final Object DATE = "Date";
-
- @Override
- public void setup() {
- PopupDateField df = new PopupDateField();
- df.setWidth("100%");
-
- Table t = new Table();
- t.setWidth("100px");
- t.addContainerProperty(DATE, Component.class, null);
- t.addItem(new Object[] { df }, "1");
- addComponent(t);
- }
-
- @Override
- protected String getDescription() {
- return "Simple test to ensure a narrow PopupDateField can be used in a Table.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6166;
- }
-
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.PopupDateField;
+import com.vaadin.ui.Table;
+
+public class NarrowPopupDateFieldInTable extends TestBase {
+
+ private final Object DATE = "Date";
+
+ @Override
+ public void setup() {
+ PopupDateField df = new PopupDateField();
+ df.setWidth("100%");
+
+ Table t = new Table();
+ t.setWidth("100px");
+ t.addContainerProperty(DATE, Component.class, null);
+ t.addItem(new Object[] { df }, "1");
+ addComponent(t);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Simple test to ensure a narrow PopupDateField can be used in a Table.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6166;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldTest.java b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldTest.java
index ae238b2a91..3ab1f52891 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldTest.java
@@ -1,38 +1,38 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.ui.PopupDateField;
-
-public class PopupDateFieldTest extends DateFieldTest<PopupDateField> {
-
- @Override
- protected Class<PopupDateField> getTestClass() {
- return PopupDateField.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createInputPromptSelectAction(CATEGORY_FEATURES);
- }
-
- private void createInputPromptSelectAction(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("<none>", null);
- options.put("Please enter date", "Please enter date");
- options.put("åäöÅÄÖ", "åäöÅÄÖ");
-
- createSelectAction("Input prompt", category, options, "<none>",
- new Command<PopupDateField, String>() {
-
- public void execute(PopupDateField c, String value,
- Object data) {
- c.setInputPrompt(value);
-
- }
- });
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.ui.PopupDateField;
+
+public class PopupDateFieldTest extends DateFieldTest<PopupDateField> {
+
+ @Override
+ protected Class<PopupDateField> getTestClass() {
+ return PopupDateField.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createInputPromptSelectAction(CATEGORY_FEATURES);
+ }
+
+ private void createInputPromptSelectAction(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("<none>", null);
+ options.put("Please enter date", "Please enter date");
+ options.put("åäöÅÄÖ", "åäöÅÄÖ");
+
+ createSelectAction("Input prompt", category, options, "<none>",
+ new Command<PopupDateField, String>() {
+
+ public void execute(PopupDateField c, String value,
+ Object data) {
+ c.setInputPrompt(value);
+
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFields.java b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFields.java
index 8b9cb68d7b..7e8b19b2a1 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFields.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFields.java
@@ -1,105 +1,105 @@
-package com.vaadin.tests.components.datefield;
-
-import java.sql.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.PopupDateField;
-
-@SuppressWarnings("serial")
-public class PopupDateFields extends ComponentTestCase<PopupDateField> {
-
- private static final Locale[] LOCALES = new Locale[] { Locale.US,
- Locale.TAIWAN, new Locale("fi", "FI") };
-
- @Override
- protected Class<PopupDateField> getTestClass() {
- return PopupDateField.class;
- }
-
- @Override
- protected void initializeComponents() {
-
- for (Locale locale : LOCALES) {
- PopupDateField pd = createPopupDateField("Undefined width", "-1",
- locale);
- pd.setDebugId("Locale-" + locale.toString() + "-undefined-wide");
- addTestComponent(pd);
- pd = createPopupDateField("500px width", "500px", locale);
- pd.setDebugId("Locale-" + locale.toString() + "-500px-wide");
- addTestComponent(pd);
- pd = createPopupDateField("Initially empty", "", locale);
- pd.setValue(null);
- pd.setDebugId("Locale-" + locale.toString() + "-initially-empty");
- addTestComponent(pd);
- }
-
- }
-
- private PopupDateField createPopupDateField(String caption, String width,
- Locale locale) {
- PopupDateField pd = new PopupDateField(caption + "("
- + locale.toString() + ")");
- pd.setWidth(width);
- pd.setValue(new Date(12312312313L));
- pd.setLocale(locale);
- pd.setResolution(DateField.RESOLUTION_YEAR);
-
- return pd;
- }
-
- @Override
- protected String getDescription() {
- return "A generic test for PopupDateFields in different configurations";
- }
-
- @Override
- protected List<Component> createActions() {
- List<Component> actions = super.createActions();
- actions.add(createResolutionSelectAction());
- actions.add(createInputPromptSelectAction());
- return actions;
- }
-
- private Component createResolutionSelectAction() {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Year", DateField.RESOLUTION_YEAR);
- options.put("Month", DateField.RESOLUTION_MONTH);
- options.put("Day", DateField.RESOLUTION_DAY);
- options.put("Hour", DateField.RESOLUTION_HOUR);
- options.put("Min", DateField.RESOLUTION_MIN);
- options.put("Sec", DateField.RESOLUTION_SEC);
- options.put("Msec", DateField.RESOLUTION_MSEC);
- return createSelectAction("Resolution", options, "Year",
- new Command<PopupDateField, Integer>() {
-
- public void execute(PopupDateField c, Integer value,
- Object data) {
- c.setResolution(value);
-
- }
- });
- }
-
- private Component createInputPromptSelectAction() {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("<none>", null);
- options.put("Please enter date", "Please enter date");
- options.put("åäöÅÄÖ", "åäöÅÄÖ");
-
- return createSelectAction("Input prompt", options, "<none>",
- new Command<PopupDateField, String>() {
-
- public void execute(PopupDateField c, String value,
- Object data) {
- c.setInputPrompt(value);
-
- }
- });
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.sql.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.PopupDateField;
+
+@SuppressWarnings("serial")
+public class PopupDateFields extends ComponentTestCase<PopupDateField> {
+
+ private static final Locale[] LOCALES = new Locale[] { Locale.US,
+ Locale.TAIWAN, new Locale("fi", "FI") };
+
+ @Override
+ protected Class<PopupDateField> getTestClass() {
+ return PopupDateField.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+
+ for (Locale locale : LOCALES) {
+ PopupDateField pd = createPopupDateField("Undefined width", "-1",
+ locale);
+ pd.setDebugId("Locale-" + locale.toString() + "-undefined-wide");
+ addTestComponent(pd);
+ pd = createPopupDateField("500px width", "500px", locale);
+ pd.setDebugId("Locale-" + locale.toString() + "-500px-wide");
+ addTestComponent(pd);
+ pd = createPopupDateField("Initially empty", "", locale);
+ pd.setValue(null);
+ pd.setDebugId("Locale-" + locale.toString() + "-initially-empty");
+ addTestComponent(pd);
+ }
+
+ }
+
+ private PopupDateField createPopupDateField(String caption, String width,
+ Locale locale) {
+ PopupDateField pd = new PopupDateField(caption + "("
+ + locale.toString() + ")");
+ pd.setWidth(width);
+ pd.setValue(new Date(12312312313L));
+ pd.setLocale(locale);
+ pd.setResolution(DateField.RESOLUTION_YEAR);
+
+ return pd;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A generic test for PopupDateFields in different configurations";
+ }
+
+ @Override
+ protected List<Component> createActions() {
+ List<Component> actions = super.createActions();
+ actions.add(createResolutionSelectAction());
+ actions.add(createInputPromptSelectAction());
+ return actions;
+ }
+
+ private Component createResolutionSelectAction() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Year", DateField.RESOLUTION_YEAR);
+ options.put("Month", DateField.RESOLUTION_MONTH);
+ options.put("Day", DateField.RESOLUTION_DAY);
+ options.put("Hour", DateField.RESOLUTION_HOUR);
+ options.put("Min", DateField.RESOLUTION_MIN);
+ options.put("Sec", DateField.RESOLUTION_SEC);
+ options.put("Msec", DateField.RESOLUTION_MSEC);
+ return createSelectAction("Resolution", options, "Year",
+ new Command<PopupDateField, Integer>() {
+
+ public void execute(PopupDateField c, Integer value,
+ Object data) {
+ c.setResolution(value);
+
+ }
+ });
+ }
+
+ private Component createInputPromptSelectAction() {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("<none>", null);
+ options.put("Please enter date", "Please enter date");
+ options.put("åäöÅÄÖ", "åäöÅÄÖ");
+
+ return createSelectAction("Input prompt", options, "<none>",
+ new Command<PopupDateField, String>() {
+
+ public void execute(PopupDateField c, String value,
+ Object data) {
+ c.setInputPrompt(value);
+
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java b/tests/testbench/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java
index fde3d4e56b..6686fa6fe0 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java
@@ -1,57 +1,57 @@
-package com.vaadin.tests.components.datefield;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.PopupDateField;
-
-/**
- * First entering an invalid date, forcing a server roundtrip and then selecting
- * a valid date from the popup in a non-immediate {@link PopupDateField} caused
- * the invalid date string to continue to show.
- */
-public class ShowSelectedDateAfterInvalid extends TestBase {
-
- @Override
- protected void setup() {
- final Label result = new Label();
-
- final Form form = new Form();
-
- PopupDateField datefield = new PopupDateField();
- datefield.setResolution(PopupDateField.RESOLUTION_DAY);
- datefield.setDateFormat("dd/MM/yyyy");
-
- form.addField("datefield", datefield);
-
- Button button = new Button("Validate");
-
- button.addListener(new Button.ClickListener() {
- public void buttonClick(Button.ClickEvent event) {
- form.setValidationVisible(true);
- if (form.isValid()) {
- result.setValue("Valid!");
- } else {
- result.setValue("Invalid");
- }
- }
-
- });
-
- addComponent(form);
- addComponent(button);
- addComponent(result);
- }
-
- @Override
- protected String getDescription() {
- return "DateField doesn't show selected value after invalid and then selecting a value";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5369;
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupDateField;
+
+/**
+ * First entering an invalid date, forcing a server roundtrip and then selecting
+ * a valid date from the popup in a non-immediate {@link PopupDateField} caused
+ * the invalid date string to continue to show.
+ */
+public class ShowSelectedDateAfterInvalid extends TestBase {
+
+ @Override
+ protected void setup() {
+ final Label result = new Label();
+
+ final Form form = new Form();
+
+ PopupDateField datefield = new PopupDateField();
+ datefield.setResolution(PopupDateField.RESOLUTION_DAY);
+ datefield.setDateFormat("dd/MM/yyyy");
+
+ form.addField("datefield", datefield);
+
+ Button button = new Button("Validate");
+
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(Button.ClickEvent event) {
+ form.setValidationVisible(true);
+ if (form.isValid()) {
+ result.setValue("Valid!");
+ } else {
+ result.setValue("Invalid");
+ }
+ }
+
+ });
+
+ addComponent(form);
+ addComponent(button);
+ addComponent(result);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "DateField doesn't show selected value after invalid and then selecting a value";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5369;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java b/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
index f25a9f0350..517bf2ee76 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
+++ b/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
@@ -1,44 +1,44 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.Date;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.DateField;
-
-public class WidthRecalculationOnEnableStateChange extends TestBase {
- @Override
- public void setup() {
- setTheme("reindeer-tests");
-
- final DateField df = new DateField();
- df.setValue(new Date(1203910239L));
- df.setWidth("200px");
- df.addStyleName("enabled-readonly-styled");
- addComponent(df);
- addComponent(new Button("Toggle disabled for date field",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- df.setEnabled(!df.isEnabled());
- }
- }));
- addComponent(new Button("Toggle read only for date field",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- df.setReadOnly(!df.isReadOnly());
- }
- }));
- }
-
- @Override
- protected String getDescription() {
- return "Setting the disabled state doesn't recalculate the input element width. Setting the read-only state instead recalculates the width. In both cases, the popup button is hidden using CSS.<br><br>The DateField is also given a style name 'test', but that style isn't applied on the calendar popup element.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 8085;
- }
-
-}
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.DateField;
+
+public class WidthRecalculationOnEnableStateChange extends TestBase {
+ @Override
+ public void setup() {
+ setTheme("reindeer-tests");
+
+ final DateField df = new DateField();
+ df.setValue(new Date(1203910239L));
+ df.setWidth("200px");
+ df.addStyleName("enabled-readonly-styled");
+ addComponent(df);
+ addComponent(new Button("Toggle disabled for date field",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ df.setEnabled(!df.isEnabled());
+ }
+ }));
+ addComponent(new Button("Toggle read only for date field",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ df.setReadOnly(!df.isReadOnly());
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Setting the disabled state doesn't recalculate the input element width. Setting the read-only state instead recalculates the width. In both cases, the popup button is hidden using CSS.<br><br>The DateField is also given a style name 'test', but that style isn't applied on the calendar popup element.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8085;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedFlash.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedFlash.java
index 87e0714545..fb6b55ded0 100644
--- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedFlash.java
+++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedFlash.java
@@ -1,34 +1,34 @@
-package com.vaadin.tests.components.embedded;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Embedded;
-
-public class EmbeddedFlash extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The embedded flash should have the movie parameter set to \"someRandomValue\" and an allowFullScreen parameter set to \"true\".";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3367;
- }
-
- @Override
- public void setup() {
- Embedded player = new Embedded();
- player.setType(Embedded.TYPE_OBJECT);
- player.setWidth("400px");
- player.setHeight("300px");
- player.setMimeType("application/x-shockwave-flash");
- String url = "http://www.youtube.com/v/qQ9N742QB4g&autoplay=1";
- player.setSource(new ExternalResource(url));
- player.setParameter("movie", "someRandomValue");
- player.setParameter("allowFullScreen", "true");
-
- addComponent(player);
- }
-
-}
+package com.vaadin.tests.components.embedded;
+
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Embedded;
+
+public class EmbeddedFlash extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The embedded flash should have the movie parameter set to \"someRandomValue\" and an allowFullScreen parameter set to \"true\".";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3367;
+ }
+
+ @Override
+ public void setup() {
+ Embedded player = new Embedded();
+ player.setType(Embedded.TYPE_OBJECT);
+ player.setWidth("400px");
+ player.setHeight("300px");
+ player.setMimeType("application/x-shockwave-flash");
+ String url = "http://www.youtube.com/v/qQ9N742QB4g&autoplay=1";
+ player.setSource(new ExternalResource(url));
+ player.setParameter("movie", "someRandomValue");
+ player.setParameter("allowFullScreen", "true");
+
+ addComponent(player);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java
index bea25a2122..0fb8b27b75 100644
--- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java
+++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java
@@ -1,32 +1,32 @@
-package com.vaadin.tests.components.embedded;
-
-import com.vaadin.terminal.ClassResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Embedded;
-import com.vaadin.ui.Window;
-
-public class EmbeddedPdf extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The embedded flash should have the movie parameter set to \"someRandomValue\" and an allowFullScreen parameter set to \"true\".";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3367;
- }
-
- @Override
- public void setup() {
- Embedded player = new Embedded();
- player.setType(Embedded.TYPE_BROWSER);
- player.setWidth("400px");
- player.setHeight("300px");
- player.setSource(new ClassResource(getClass(), "test.pdf", this));
- addComponent(player);
-
- player.getWindow().addWindow(new Window("Testwindow"));
- }
-
-}
+package com.vaadin.tests.components.embedded;
+
+import com.vaadin.terminal.ClassResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.Window;
+
+public class EmbeddedPdf extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The embedded flash should have the movie parameter set to \"someRandomValue\" and an allowFullScreen parameter set to \"true\".";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3367;
+ }
+
+ @Override
+ public void setup() {
+ Embedded player = new Embedded();
+ player.setType(Embedded.TYPE_BROWSER);
+ player.setWidth("400px");
+ player.setHeight("300px");
+ player.setSource(new ClassResource(getClass(), "test.pdf", this));
+ addComponent(player);
+
+ player.getWindow().addWindow(new Window("Testwindow"));
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedTooltip.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedTooltip.java
index 2ac39c05a0..d8be22f507 100644
--- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedTooltip.java
+++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedTooltip.java
@@ -1,27 +1,27 @@
-package com.vaadin.tests.components.embedded;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Embedded;
-
-public class EmbeddedTooltip extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The tooltip for an Embedded image should be visible also when hovering the image";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2853;
- }
-
- @Override
- protected void setup() {
- Embedded e = new Embedded("Embedded caption", new ThemeResource(
- "../runo/icons/64/ok.png"));
- e.setDescription("Embedded tooltip, only shown on caption, not on the image");
- addComponent(e);
-
- }
-}
+package com.vaadin.tests.components.embedded;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Embedded;
+
+public class EmbeddedTooltip extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The tooltip for an Embedded image should be visible also when hovering the image";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2853;
+ }
+
+ @Override
+ protected void setup() {
+ Embedded e = new Embedded("Embedded caption", new ThemeResource(
+ "../runo/icons/64/ok.png"));
+ e.setDescription("Embedded tooltip, only shown on caption, not on the image");
+ addComponent(e);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/form/FormFieldCaptions.java b/tests/testbench/com/vaadin/tests/components/form/FormFieldCaptions.java
index b4dee985f4..25487fba7c 100644
--- a/tests/testbench/com/vaadin/tests/components/form/FormFieldCaptions.java
+++ b/tests/testbench/com/vaadin/tests/components/form/FormFieldCaptions.java
@@ -1,86 +1,86 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-
-public class FormFieldCaptions extends TestBase {
-
- @Override
- protected void setup() {
- // Method 1
- Form form1 = new Form();
- Item item1 = createItem();
- for (Object propertyId : item1.getItemPropertyIds()) {
- form1.addItemProperty(propertyId, item1.getItemProperty(propertyId));
- }
-
- // Method 2
-
- Form form2 = new Form();
- Item item2 = createItem();
- form2.setItemDataSource(item2);
-
- // Layout
- HorizontalLayout hl = new HorizontalLayout();
- hl.addComponent(form1);
- hl.addComponent(form2);
-
- addComponent(hl);
- }
-
- private Item createItem() {
- return new BeanItem<Person>(new Person("John", "Doe", 38));
- }
-
- public class Person {
- private String firstName;
- private String lastName;
-
- public Person(String firstName, String lastName, int age) {
- super();
- this.firstName = firstName;
- this.lastName = lastName;
- this.age = age;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- private int age;
- }
-
- @Override
- protected String getDescription() {
- return "The two forms generated using different methods should have the same captions for all fields";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3554;
- }
-
-}
+package com.vaadin.tests.components.form;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.HorizontalLayout;
+
+public class FormFieldCaptions extends TestBase {
+
+ @Override
+ protected void setup() {
+ // Method 1
+ Form form1 = new Form();
+ Item item1 = createItem();
+ for (Object propertyId : item1.getItemPropertyIds()) {
+ form1.addItemProperty(propertyId, item1.getItemProperty(propertyId));
+ }
+
+ // Method 2
+
+ Form form2 = new Form();
+ Item item2 = createItem();
+ form2.setItemDataSource(item2);
+
+ // Layout
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.addComponent(form1);
+ hl.addComponent(form2);
+
+ addComponent(hl);
+ }
+
+ private Item createItem() {
+ return new BeanItem<Person>(new Person("John", "Doe", 38));
+ }
+
+ public class Person {
+ private String firstName;
+ private String lastName;
+
+ public Person(String firstName, String lastName, int age) {
+ super();
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ private int age;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The two forms generated using different methods should have the same captions for all fields";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3554;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/form/FormRenderingFlicker.java b/tests/testbench/com/vaadin/tests/components/form/FormRenderingFlicker.java
index 5858366a63..ecf3215005 100644
--- a/tests/testbench/com/vaadin/tests/components/form/FormRenderingFlicker.java
+++ b/tests/testbench/com/vaadin/tests/components/form/FormRenderingFlicker.java
@@ -1,65 +1,65 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.Item;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-
-public class FormRenderingFlicker extends TestBase {
-
- private VerticalLayout tableLayout;
- private Table table;
- private Panel tablePanel;
- private Form form;
-
- @Override
- protected String getDescription() {
- return "Clicking on an item in the table will replace the panel (surrounding the table) with a form. This should not cause the table rows to move downwards or cause any other visible flicker";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2816;
- }
-
- @Override
- protected void setup() {
- createTableLayout();
- form = new Form();
-
- tablePanel = new Panel();
- tablePanel.setContent(tableLayout);
-
- addComponent(tablePanel);
- }
-
- private void createTableLayout() {
- tableLayout = new VerticalLayout();
- table = new Table();
- table.addContainerProperty("name", String.class, "");
- table.addContainerProperty("age", String.class, "");
- for (int i = 0; i < 100; i++) {
- table.addItem(new Object[] { "Name " + i, String.valueOf(i) },
- new Object());
- }
- table.setImmediate(true);
- table.addListener(new ItemClickListener() {
-
- public void itemClick(ItemClickEvent event) {
- clicked(event.getItem());
- }
-
- });
-
- tableLayout.addComponent(table);
- }
-
- protected void clicked(Item item) {
- getLayout().replaceComponent(tablePanel, form);
- }
-
-}
+package com.vaadin.tests.components.form;
+
+import com.vaadin.data.Item;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class FormRenderingFlicker extends TestBase {
+
+ private VerticalLayout tableLayout;
+ private Table table;
+ private Panel tablePanel;
+ private Form form;
+
+ @Override
+ protected String getDescription() {
+ return "Clicking on an item in the table will replace the panel (surrounding the table) with a form. This should not cause the table rows to move downwards or cause any other visible flicker";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2816;
+ }
+
+ @Override
+ protected void setup() {
+ createTableLayout();
+ form = new Form();
+
+ tablePanel = new Panel();
+ tablePanel.setContent(tableLayout);
+
+ addComponent(tablePanel);
+ }
+
+ private void createTableLayout() {
+ tableLayout = new VerticalLayout();
+ table = new Table();
+ table.addContainerProperty("name", String.class, "");
+ table.addContainerProperty("age", String.class, "");
+ for (int i = 0; i < 100; i++) {
+ table.addItem(new Object[] { "Name " + i, String.valueOf(i) },
+ new Object());
+ }
+ table.setImmediate(true);
+ table.addListener(new ItemClickListener() {
+
+ public void itemClick(ItemClickEvent event) {
+ clicked(event.getItem());
+ }
+
+ });
+
+ tableLayout.addComponent(table);
+ }
+
+ protected void clicked(Item item) {
+ getLayout().replaceComponent(tablePanel, form);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/form/FormWithEnterShortCut.java b/tests/testbench/com/vaadin/tests/components/form/FormWithEnterShortCut.java
index 624d0746e9..a3baab921f 100644
--- a/tests/testbench/com/vaadin/tests/components/form/FormWithEnterShortCut.java
+++ b/tests/testbench/com/vaadin/tests/components/form/FormWithEnterShortCut.java
@@ -1,47 +1,47 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.TextField;
-
-public class FormWithEnterShortCut extends TestBase {
- private Log log = new Log(2);
-
- @Override
- protected void setup() {
-
- final Form form = new Form();
- final Field tf = new TextField("Search");
- form.addField("searchfield", tf);
-
- Button button = new Button("Go");
- button.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- log.log("search: " + tf.getValue());
- }
- });
- button.setClickShortcut(KeyCode.ENTER);
- button.setStyleName("primary");
-
- form.getFooter().addComponent(button);
-
- addComponent(log);
- addComponent(form);
-
- }
-
- @Override
- protected String getDescription() {
- return "Focusing a button and pressing enter (which is a shortcut for button click) should only produce one click event";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5433;
- }
-}
+package com.vaadin.tests.components.form;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.TextField;
+
+public class FormWithEnterShortCut extends TestBase {
+ private Log log = new Log(2);
+
+ @Override
+ protected void setup() {
+
+ final Form form = new Form();
+ final Field tf = new TextField("Search");
+ form.addField("searchfield", tf);
+
+ Button button = new Button("Go");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("search: " + tf.getValue());
+ }
+ });
+ button.setClickShortcut(KeyCode.ENTER);
+ button.setStyleName("primary");
+
+ form.getFooter().addComponent(button);
+
+ addComponent(log);
+ addComponent(form);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Focusing a button and pressing enter (which is a shortcut for button click) should only produce one click event";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5433;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/form/FormWithPropertyFormatterConnected.java b/tests/testbench/com/vaadin/tests/components/form/FormWithPropertyFormatterConnected.java
index 116dd5bcc7..eba570c490 100644
--- a/tests/testbench/com/vaadin/tests/components/form/FormWithPropertyFormatterConnected.java
+++ b/tests/testbench/com/vaadin/tests/components/form/FormWithPropertyFormatterConnected.java
@@ -1,90 +1,90 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.PropertyFormatter;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.FormFieldFactory;
-
-public class FormWithPropertyFormatterConnected extends TestBase {
- @Override
- protected void setup() {
- Form form2 = new Form();
- form2.setFormFieldFactory(new FormFieldFactory() {
-
- public Field createField(Item item, Object propertyId,
- Component uiContext) {
- AbstractField f = (AbstractField) DefaultFieldFactory.get()
- .createField(item, propertyId, uiContext);
- if (propertyId.equals("age")) {
- f.setPropertyDataSource(new PropertyFormatter() {
-
- @Override
- public Object parse(String formattedValue)
- throws Exception {
- String str = formattedValue
- .replaceAll("[^0-9.]", "");
- if (formattedValue.toLowerCase().contains("months")) {
- return Double.parseDouble(str) / 12;
- }
- return Double.parseDouble(str);
- }
-
- @Override
- public String format(Object value) {
- Double dValue = (Double) value;
- if (dValue < 1) {
- return ((int)(dValue * 12)) + " months";
- }
- return dValue + " years";
- }
- });
- f.setImmediate(true);
- }
- return f;
- }
- });
- form2.setItemDataSource(createItem());
-
- addComponent(form2);
- addComponent(new Button("B"));
- }
-
- private Item createItem() {
- return new BeanItem<Person>(new Person(0.5));
- }
-
- public class Person {
- public Person(double age) {
- super();
- this.age = age;
- }
-
- public double getAge() {
- return age;
- }
-
- public void setAge(double age) {
- this.age = age;
- }
-
- private double age;
- }
-
- @Override
- protected String getDescription() {
- return "It should be possible to inject PropertyFormatter and similar classses to fields in form. The test app hooks formatter that displays age in years or months and also accepts value in both (years by default, months if mentioned in the field)";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
+package com.vaadin.tests.components.form;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.PropertyFormatter;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DefaultFieldFactory;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.FormFieldFactory;
+
+public class FormWithPropertyFormatterConnected extends TestBase {
+ @Override
+ protected void setup() {
+ Form form2 = new Form();
+ form2.setFormFieldFactory(new FormFieldFactory() {
+
+ public Field createField(Item item, Object propertyId,
+ Component uiContext) {
+ AbstractField f = (AbstractField) DefaultFieldFactory.get()
+ .createField(item, propertyId, uiContext);
+ if (propertyId.equals("age")) {
+ f.setPropertyDataSource(new PropertyFormatter() {
+
+ @Override
+ public Object parse(String formattedValue)
+ throws Exception {
+ String str = formattedValue
+ .replaceAll("[^0-9.]", "");
+ if (formattedValue.toLowerCase().contains("months")) {
+ return Double.parseDouble(str) / 12;
+ }
+ return Double.parseDouble(str);
+ }
+
+ @Override
+ public String format(Object value) {
+ Double dValue = (Double) value;
+ if (dValue < 1) {
+ return ((int)(dValue * 12)) + " months";
+ }
+ return dValue + " years";
+ }
+ });
+ f.setImmediate(true);
+ }
+ return f;
+ }
+ });
+ form2.setItemDataSource(createItem());
+
+ addComponent(form2);
+ addComponent(new Button("B"));
+ }
+
+ private Item createItem() {
+ return new BeanItem<Person>(new Person(0.5));
+ }
+
+ public class Person {
+ public Person(double age) {
+ super();
+ this.age = age;
+ }
+
+ public double getAge() {
+ return age;
+ }
+
+ public void setAge(double age) {
+ this.age = age;
+ }
+
+ private double age;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "It should be possible to inject PropertyFormatter and similar classses to fields in form. The test app hooks formatter that displays age in years or months and also accepts value in both (years by default, months if mentioned in the field)";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutReplaceComponent.java b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutReplaceComponent.java
index e42d64201e..9427318a10 100644
--- a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutReplaceComponent.java
+++ b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutReplaceComponent.java
@@ -1,57 +1,57 @@
-package com.vaadin.tests.components.formlayout;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.TextField;
-
-public class FormLayoutReplaceComponent extends TestBase {
-
- @Override
- protected void setup() {
- addComponent(new FL());
-
- }
-
- public class FL extends FormLayout implements ClickListener {
-
- private TextField messages;
- private CheckBox control;
-
- @SuppressWarnings("deprecation")
- public FL() {
- setCaption("Test");
- control = new CheckBox("Messages On/Off");
- control.addListener(this);
- control.setImmediate(true);
- addComponent(control);
-
- // The bug is in replaceComponent, triggered when VTextField is
- // replaced by VTextArea so cannot replace this with TextArea.
- messages = new TextField("Messages");
- messages.setRows(10);
- messages.setColumns(40);
- messages.setVisible(false);
- messages.setEnabled(false);
- addComponent(messages);
- }
-
- public final void buttonClick(Button.ClickEvent e) {
- if (e.getButton() == control) {
- messages.setVisible(control.booleanValue());
- }
- }
- }
-
- @Override
- protected String getDescription() {
- return "Check or uncheck the CheckBox to show/hide the messages field inside the FormLayout.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6308;
- }
-
+package com.vaadin.tests.components.formlayout;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.TextField;
+
+public class FormLayoutReplaceComponent extends TestBase {
+
+ @Override
+ protected void setup() {
+ addComponent(new FL());
+
+ }
+
+ public class FL extends FormLayout implements ClickListener {
+
+ private TextField messages;
+ private CheckBox control;
+
+ @SuppressWarnings("deprecation")
+ public FL() {
+ setCaption("Test");
+ control = new CheckBox("Messages On/Off");
+ control.addListener(this);
+ control.setImmediate(true);
+ addComponent(control);
+
+ // The bug is in replaceComponent, triggered when VTextField is
+ // replaced by VTextArea so cannot replace this with TextArea.
+ messages = new TextField("Messages");
+ messages.setRows(10);
+ messages.setColumns(40);
+ messages.setVisible(false);
+ messages.setEnabled(false);
+ addComponent(messages);
+ }
+
+ public final void buttonClick(Button.ClickEvent e) {
+ if (e.getButton() == control) {
+ messages.setVisible(control.booleanValue());
+ }
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Check or uncheck the CheckBox to show/hide the messages field inside the FormLayout.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6308;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java b/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java
index 157772f8cd..c8eb1483b4 100644
--- a/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java
+++ b/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java
@@ -1,45 +1,45 @@
-package com.vaadin.tests.components.formlayout;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class TableInFormLayoutCausesScrolling extends AbstractTestCase {
-
- @Override
- public void init() {
- // Window Initialization.
- final Window window = new Window("Main Window");
- setMainWindow(window);
-
- // FormLayout creation
- final FormLayout fl = new FormLayout();
- window.setContent(fl);
-
- // Add 20 TextField
- for (int i = 20; i-- > 0;) {
- fl.addComponent(new TextField());
- }
-
- // Add 1 selectable table with some items
- final Table table = new Table();
- table.setSelectable(true);
- table.addContainerProperty("item", String.class, "");
- for (int i = 50; i-- > 0;) {
- table.addItem(new String[] { "item" + i }, i);
- }
- window.addComponent(table);
- }
-
- @Override
- protected String getDescription() {
- return "Clicking in the Table should not cause the page to scroll";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7309;
- }
+package com.vaadin.tests.components.formlayout;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class TableInFormLayoutCausesScrolling extends AbstractTestCase {
+
+ @Override
+ public void init() {
+ // Window Initialization.
+ final Window window = new Window("Main Window");
+ setMainWindow(window);
+
+ // FormLayout creation
+ final FormLayout fl = new FormLayout();
+ window.setContent(fl);
+
+ // Add 20 TextField
+ for (int i = 20; i-- > 0;) {
+ fl.addComponent(new TextField());
+ }
+
+ // Add 1 selectable table with some items
+ final Table table = new Table();
+ table.setSelectable(true);
+ table.addContainerProperty("item", String.class, "");
+ for (int i = 50; i-- > 0;) {
+ table.addItem(new String[] { "item" + i }, i);
+ }
+ window.addComponent(table);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Clicking in the Table should not cause the page to scroll";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7309;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java b/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java
index 08a37dcd9a..da0efe9464 100644
--- a/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java
@@ -1,58 +1,58 @@
-package com.vaadin.tests.components.gridlayout;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.VerticalLayout;
-
-public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase {
-
- protected Button testButton;
- private GridLayout gl;
- protected ComponentContainer vl;
-
- @Override
- protected void setup() {
- gl = new GridLayout();
- gl.setWidth("200px");
- gl.setHeight("200px");
-
- testButton = new Button("Click to move to inner layout",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- vl.addComponent(testButton);
- }
- });
-
- gl.addComponent(testButton);
-
- vl = new VerticalLayout();
- gl.addComponent(vl);
-
- addComponent(gl);
-
- Button b = new Button("Repaint inner layout",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- vl.requestRepaint();
- }
- });
-
- addComponent(b);
- }
-
- @Override
- protected String getDescription() {
- return "Click the first button to move it from an outer layout to an inner. Then click the second button to repaint the inner layout.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6060;
- }
-
-}
+package com.vaadin.tests.components.gridlayout;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.VerticalLayout;
+
+public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase {
+
+ protected Button testButton;
+ private GridLayout gl;
+ protected ComponentContainer vl;
+
+ @Override
+ protected void setup() {
+ gl = new GridLayout();
+ gl.setWidth("200px");
+ gl.setHeight("200px");
+
+ testButton = new Button("Click to move to inner layout",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ vl.addComponent(testButton);
+ }
+ });
+
+ gl.addComponent(testButton);
+
+ vl = new VerticalLayout();
+ gl.addComponent(vl);
+
+ addComponent(gl);
+
+ Button b = new Button("Repaint inner layout",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ vl.requestRepaint();
+ }
+ });
+
+ addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the first button to move it from an outer layout to an inner. Then click the second button to repaint the inner layout.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6060;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java b/tests/testbench/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java
index 1d2fb2a59c..a5bb291b67 100644
--- a/tests/testbench/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java
+++ b/tests/testbench/com/vaadin/tests/components/label/HundredPercentWideLabelResize.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.label;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-
-public class HundredPercentWideLabelResize extends TestBase {
-
- @Override
- protected String getDescription() {
- return "100% wide label re-wrap should cause re-layout; forceLayout fixes this.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2514;
- }
-
- @Override
- protected void setup() {
- getLayout().setWidth("500px");
- Label text = new Label(
- "This is a fairly long text that will wrap if the width of the layout is narrow enough. Directly below the text is a Button - however, when the layout changes size, the Label re-wraps w/o moving the button, causing eiter clipping or a big space.");
- text.setWidth("100%");
- getLayout().addComponent(text);
-
- getLayout().addComponent(
- new Button("toggle width", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (getLayout().getWidth() == 500) {
- getLayout().setWidth("100px");
- } else {
- getLayout().setWidth("500px");
- }
-
- }
-
- }));
- }
-
-}
+package com.vaadin.tests.components.label;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class HundredPercentWideLabelResize extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "100% wide label re-wrap should cause re-layout; forceLayout fixes this.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2514;
+ }
+
+ @Override
+ protected void setup() {
+ getLayout().setWidth("500px");
+ Label text = new Label(
+ "This is a fairly long text that will wrap if the width of the layout is narrow enough. Directly below the text is a Button - however, when the layout changes size, the Label re-wraps w/o moving the button, causing eiter clipping or a big space.");
+ text.setWidth("100%");
+ getLayout().addComponent(text);
+
+ getLayout().addComponent(
+ new Button("toggle width", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (getLayout().getWidth() == 500) {
+ getLayout().setWidth("100px");
+ } else {
+ getLayout().setWidth("500px");
+ }
+
+ }
+
+ }));
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/label/LabelTest.java b/tests/testbench/com/vaadin/tests/components/label/LabelTest.java
index 38ced67f18..5c71046404 100644
--- a/tests/testbench/com/vaadin/tests/components/label/LabelTest.java
+++ b/tests/testbench/com/vaadin/tests/components/label/LabelTest.java
@@ -1,100 +1,100 @@
-package com.vaadin.tests.components.label;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.components.AbstractComponentTest;
-import com.vaadin.ui.Label;
-
-public class LabelTest extends AbstractComponentTest<Label> implements
- ValueChangeListener {
-
- private Command<Label, Object> setValueCommand = new Command<Label, Object>() {
-
- public void execute(Label c, Object value, Object data) {
- c.setValue(value);
- }
- };
-
- private Command<Label, Boolean> valueChangeListenerCommand = new Command<Label, Boolean>() {
- public void execute(Label c, Boolean value, Object data) {
- if (value) {
- c.addListener(LabelTest.this);
- } else {
- c.removeListener(LabelTest.this);
-
- }
- }
- };
-
- private Command<Label, Integer> contentModeCommand = new Command<Label, Integer>() {
- public void execute(Label c, Integer value, Object data) {
- c.setContentMode(value);
- }
- };
-
- @Override
- protected Class<Label> getTestClass() {
- return Label.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createContentModeSelect(CATEGORY_FEATURES);
- createValueSelect(CATEGORY_FEATURES);
- createValueChangeListener(CATEGORY_LISTENERS);
- }
-
- private void createValueSelect(String category) {
- String subCategory = "Set text value";
- createCategory(subCategory, category);
- List<String> values = new ArrayList<String>();
- values.add("Test");
- values.add("A little longer value");
- values.add("A very long value with very much text. All in all it is 74 characters long");
- values.add("<b>Bold</b>");
- values.add("<div style=\"height: 70px; width: 15px; border: 1px dashed red\">With border</div>");
-
- createClickAction("(empty string)", subCategory, setValueCommand, "");
- createClickAction("(null)", subCategory, setValueCommand, null);
- for (String value : values) {
- createClickAction(value, subCategory, setValueCommand, value);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void createContentModeSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Text", Label.CONTENT_TEXT);
- options.put("Preformatted", Label.CONTENT_PREFORMATTED);
- options.put("Raw", Label.CONTENT_RAW);
- options.put("UIDL", Label.CONTENT_UIDL);
- options.put("XHTML", Label.CONTENT_XHTML);
- options.put("XML", Label.CONTENT_XML);
-
- createSelectAction("Content mode", category, options, "Text",
- contentModeCommand);
- }
-
- private void createValueChangeListener(String category) {
- createBooleanAction("Value change listener", category, false,
- valueChangeListenerCommand);
- }
-
- public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
- Object o = event.getProperty().getValue();
-
- // Distinguish between null and 'null'
- String value = "null";
- if (o != null) {
- value = "'" + o.toString() + "'";
- }
-
- log(event.getClass().getSimpleName() + ", new value: " + value);
- };
-
-}
+package com.vaadin.tests.components.label;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.Label;
+
+public class LabelTest extends AbstractComponentTest<Label> implements
+ ValueChangeListener {
+
+ private Command<Label, Object> setValueCommand = new Command<Label, Object>() {
+
+ public void execute(Label c, Object value, Object data) {
+ c.setValue(value);
+ }
+ };
+
+ private Command<Label, Boolean> valueChangeListenerCommand = new Command<Label, Boolean>() {
+ public void execute(Label c, Boolean value, Object data) {
+ if (value) {
+ c.addListener(LabelTest.this);
+ } else {
+ c.removeListener(LabelTest.this);
+
+ }
+ }
+ };
+
+ private Command<Label, Integer> contentModeCommand = new Command<Label, Integer>() {
+ public void execute(Label c, Integer value, Object data) {
+ c.setContentMode(value);
+ }
+ };
+
+ @Override
+ protected Class<Label> getTestClass() {
+ return Label.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createContentModeSelect(CATEGORY_FEATURES);
+ createValueSelect(CATEGORY_FEATURES);
+ createValueChangeListener(CATEGORY_LISTENERS);
+ }
+
+ private void createValueSelect(String category) {
+ String subCategory = "Set text value";
+ createCategory(subCategory, category);
+ List<String> values = new ArrayList<String>();
+ values.add("Test");
+ values.add("A little longer value");
+ values.add("A very long value with very much text. All in all it is 74 characters long");
+ values.add("<b>Bold</b>");
+ values.add("<div style=\"height: 70px; width: 15px; border: 1px dashed red\">With border</div>");
+
+ createClickAction("(empty string)", subCategory, setValueCommand, "");
+ createClickAction("(null)", subCategory, setValueCommand, null);
+ for (String value : values) {
+ createClickAction(value, subCategory, setValueCommand, value);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private void createContentModeSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Text", Label.CONTENT_TEXT);
+ options.put("Preformatted", Label.CONTENT_PREFORMATTED);
+ options.put("Raw", Label.CONTENT_RAW);
+ options.put("UIDL", Label.CONTENT_UIDL);
+ options.put("XHTML", Label.CONTENT_XHTML);
+ options.put("XML", Label.CONTENT_XML);
+
+ createSelectAction("Content mode", category, options, "Text",
+ contentModeCommand);
+ }
+
+ private void createValueChangeListener(String category) {
+ createBooleanAction("Value change listener", category, false,
+ valueChangeListenerCommand);
+ }
+
+ public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
+ Object o = event.getProperty().getValue();
+
+ // Distinguish between null and 'null'
+ String value = "null";
+ if (o != null) {
+ value = "'" + o.toString() + "'";
+ }
+
+ log(event.getClass().getSimpleName() + ", new value: " + value);
+ };
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/label/LabelTooltip.java b/tests/testbench/com/vaadin/tests/components/label/LabelTooltip.java
index aa1b357cad..5ce19bcff8 100644
--- a/tests/testbench/com/vaadin/tests/components/label/LabelTooltip.java
+++ b/tests/testbench/com/vaadin/tests/components/label/LabelTooltip.java
@@ -1,53 +1,53 @@
-package com.vaadin.tests.components.label;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-
-public class LabelTooltip extends TestBase {
-
- @Override
- protected void setup() {
- addComponent(createLayout());
- }
-
- private static Layout createLayout() {
- GridLayout layout = new GridLayout(2, 1);
- layout.setCaption("Tooltips");
- layout.setIcon(new ThemeResource("icons/blue/16/home.png"));
- layout.setMargin(true);
- layout.setSpacing(true);
- layout.setWidth("400px");
- layout.setColumnExpandRatio(0, 1);
-
- layout.addComponent(new Label("Default"));
- Label tooltip = new Label("Hover over me to see the tooltip");
- tooltip.setSizeUndefined();
- tooltip.setDescription("Default tooltip content");
- layout.addComponent(tooltip);
-
- layout.addComponent(new Label("Default /w error"));
- tooltip = new Label("Hover over me to see the tooltip");
- tooltip.setSizeUndefined();
- tooltip.setDescription("Default tooltip content");
- tooltip.setComponentError(new UserError(
- "Error inside tooltip together with the regular tooltip message."));
- layout.addComponent(tooltip);
-
- return layout;
- }
-
- @Override
- protected String getDescription() {
- return "The lower label should have an error indicator. The upper should not.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6911;
- }
-
-}
+package com.vaadin.tests.components.label;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+
+public class LabelTooltip extends TestBase {
+
+ @Override
+ protected void setup() {
+ addComponent(createLayout());
+ }
+
+ private static Layout createLayout() {
+ GridLayout layout = new GridLayout(2, 1);
+ layout.setCaption("Tooltips");
+ layout.setIcon(new ThemeResource("icons/blue/16/home.png"));
+ layout.setMargin(true);
+ layout.setSpacing(true);
+ layout.setWidth("400px");
+ layout.setColumnExpandRatio(0, 1);
+
+ layout.addComponent(new Label("Default"));
+ Label tooltip = new Label("Hover over me to see the tooltip");
+ tooltip.setSizeUndefined();
+ tooltip.setDescription("Default tooltip content");
+ layout.addComponent(tooltip);
+
+ layout.addComponent(new Label("Default /w error"));
+ tooltip = new Label("Hover over me to see the tooltip");
+ tooltip.setSizeUndefined();
+ tooltip.setDescription("Default tooltip content");
+ tooltip.setComponentError(new UserError(
+ "Error inside tooltip together with the regular tooltip message."));
+ layout.addComponent(tooltip);
+
+ return layout;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The lower label should have an error indicator. The upper should not.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6911;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/label/LabelWrapping.java b/tests/testbench/com/vaadin/tests/components/label/LabelWrapping.java
index a06d0b1351..166d0bda77 100644
--- a/tests/testbench/com/vaadin/tests/components/label/LabelWrapping.java
+++ b/tests/testbench/com/vaadin/tests/components/label/LabelWrapping.java
@@ -1,46 +1,46 @@
-package com.vaadin.tests.components.label;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-
-public class LabelWrapping extends TestBase {
-
- @Override
- protected String getDescription() {
- return "A label inside a limited HorizontalLayout should strive to be as wide as possible and only wrap when the size of the layout is reached. The label should look the same if it is rendered initially with the layout or updated later on.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2478;
- }
-
- @Override
- protected void setup() {
- HorizontalLayout hl = new HorizontalLayout();
- hl.setWidth("250px");
-
- final String longString = "this is a somewhat long string.";
- final Label longLabel = new Label(longString);
-
- Button changeLength = new Button("Change length");
- changeLength.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (longLabel.getValue().equals(longString)) {
- longLabel.setValue("");
- } else {
- longLabel.setValue(longString);
- }
- }
- });
-
- hl.addComponent(longLabel);
- hl.addComponent(changeLength);
-
- addComponent(hl);
- }
-
-}
+package com.vaadin.tests.components.label;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+
+public class LabelWrapping extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "A label inside a limited HorizontalLayout should strive to be as wide as possible and only wrap when the size of the layout is reached. The label should look the same if it is rendered initially with the layout or updated later on.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2478;
+ }
+
+ @Override
+ protected void setup() {
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setWidth("250px");
+
+ final String longString = "this is a somewhat long string.";
+ final Label longLabel = new Label(longString);
+
+ Button changeLength = new Button("Change length");
+ changeLength.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (longLabel.getValue().equals(longString)) {
+ longLabel.setValue("");
+ } else {
+ longLabel.setValue(longString);
+ }
+ }
+ });
+
+ hl.addComponent(longLabel);
+ hl.addComponent(changeLength);
+
+ addComponent(hl);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/link/LinkIcon.java b/tests/testbench/com/vaadin/tests/components/link/LinkIcon.java
index 372417a45c..ae8eccb59a 100644
--- a/tests/testbench/com/vaadin/tests/components/link/LinkIcon.java
+++ b/tests/testbench/com/vaadin/tests/components/link/LinkIcon.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.components.link;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Link;
-
-public class LinkIcon extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The icon of a Link component should have the same cursor as the text and should be clickable";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected void setup() {
- Link l = new Link("www.google.com", new ExternalResource(
- "http://www.vaadin.com/"));
- l.setIcon(new ThemeResource("../runo/icons/32/calendar.png"));
-
- addComponent(l);
- }
-
-}
+package com.vaadin.tests.components.link;
+
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Link;
+
+public class LinkIcon extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The icon of a Link component should have the same cursor as the text and should be clickable";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void setup() {
+ Link l = new Link("www.google.com", new ExternalResource(
+ "http://www.vaadin.com/"));
+ l.setIcon(new ThemeResource("../runo/icons/32/calendar.png"));
+
+ addComponent(l);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/link/LinkTargetSize.java b/tests/testbench/com/vaadin/tests/components/link/LinkTargetSize.java
index d5542cab04..0b3643c3ac 100644
--- a/tests/testbench/com/vaadin/tests/components/link/LinkTargetSize.java
+++ b/tests/testbench/com/vaadin/tests/components/link/LinkTargetSize.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.components.link;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Link;
-
-public class LinkTargetSize extends TestBase {
-
- @Override
- protected String getDescription() {
- return "This link should open a small window w/o decorations";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2524;
- }
-
- @Override
- protected void setup() {
- Link l = new Link("Try it!", new ExternalResource(
- "http://www.google.com/m"));
- l.setTargetName("_blank");
- l.setTargetWidth(300);
- l.setTargetHeight(300);
- l.setTargetBorder(Link.TARGET_BORDER_NONE);
- addComponent(l);
- }
-
-}
+package com.vaadin.tests.components.link;
+
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Link;
+
+public class LinkTargetSize extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "This link should open a small window w/o decorations";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2524;
+ }
+
+ @Override
+ protected void setup() {
+ Link l = new Link("Try it!", new ExternalResource(
+ "http://www.google.com/m"));
+ l.setTargetName("_blank");
+ l.setTargetWidth(300);
+ l.setTargetHeight(300);
+ l.setTargetBorder(Link.TARGET_BORDER_NONE);
+ addComponent(l);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/listselect/ListSelects.java b/tests/testbench/com/vaadin/tests/components/listselect/ListSelects.java
index 8a04da1bce..3bab03287c 100644
--- a/tests/testbench/com/vaadin/tests/components/listselect/ListSelects.java
+++ b/tests/testbench/com/vaadin/tests/components/listselect/ListSelects.java
@@ -1,44 +1,44 @@
-package com.vaadin.tests.components.listselect;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.ListSelect;
-
-public class ListSelects extends AbstractSelectTestCase<ListSelect> {
-
- private Command<ListSelect, Integer> rowsCommand = new Command<ListSelect, Integer>() {
- public void execute(ListSelect c, Integer value, Object data) {
- c.setRows(value);
- }
- };
-
- private Command<ListSelect, Integer> colsCommand = new Command<ListSelect, Integer>() {
- public void execute(ListSelect c, Integer value, Object data) {
- c.setColumns(value);
- }
- };
-
- @Override
- protected Class<ListSelect> getTestClass() {
- return ListSelect.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createRowsAction(CATEGORY_FEATURES);
- createColsAction(CATEGORY_FEATURES);
- };
-
- private void createRowsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Rows", category, options, "0", rowsCommand);
- }
-
- private void createColsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Columns", category, options, "0", colsCommand);
- }
-
-}
+package com.vaadin.tests.components.listselect;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.select.AbstractSelectTestCase;
+import com.vaadin.ui.ListSelect;
+
+public class ListSelects extends AbstractSelectTestCase<ListSelect> {
+
+ private Command<ListSelect, Integer> rowsCommand = new Command<ListSelect, Integer>() {
+ public void execute(ListSelect c, Integer value, Object data) {
+ c.setRows(value);
+ }
+ };
+
+ private Command<ListSelect, Integer> colsCommand = new Command<ListSelect, Integer>() {
+ public void execute(ListSelect c, Integer value, Object data) {
+ c.setColumns(value);
+ }
+ };
+
+ @Override
+ protected Class<ListSelect> getTestClass() {
+ return ListSelect.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createRowsAction(CATEGORY_FEATURES);
+ createColsAction(CATEGORY_FEATURES);
+ };
+
+ private void createRowsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Rows", category, options, "0", rowsCommand);
+ }
+
+ private void createColsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Columns", category, options, "0", colsCommand);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/menubar/HiddenAndDisabledMenus.java b/tests/testbench/com/vaadin/tests/components/menubar/HiddenAndDisabledMenus.java
index ef5d5ad395..c303aaf5a9 100644
--- a/tests/testbench/com/vaadin/tests/components/menubar/HiddenAndDisabledMenus.java
+++ b/tests/testbench/com/vaadin/tests/components/menubar/HiddenAndDisabledMenus.java
@@ -1,34 +1,34 @@
-package com.vaadin.tests.components.menubar;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public class HiddenAndDisabledMenus extends TestBase {
-
- @Override
- protected void setup() {
- MenuBar mb = new MenuBar();
- mb.addItem("Item 1", null);
- mb.addItem("Item 2 - hidden", null).setVisible(false);
- MenuItem submenu = mb.addItem("Item 3 - sub menu", null);
- mb.addItem("Item 4 - hidden", null).setVisible(false);
- submenu.addItem("Sub item 1 - disabled", null).setEnabled(false);
- submenu.addItem("Sub item 2 - enabled", null);
- submenu.addItem("Sub item 3 - visible", null);
- submenu.addItem("Sub item 4 - hidden", null).setVisible(false);
-
- addComponent(mb);
- }
-
- @Override
- protected String getDescription() {
- return "The menu contains 4 items, 2 of which are hidden. The sub menu contains 4 items, the last one is hidden";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4528;
- }
-
-}
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class HiddenAndDisabledMenus extends TestBase {
+
+ @Override
+ protected void setup() {
+ MenuBar mb = new MenuBar();
+ mb.addItem("Item 1", null);
+ mb.addItem("Item 2 - hidden", null).setVisible(false);
+ MenuItem submenu = mb.addItem("Item 3 - sub menu", null);
+ mb.addItem("Item 4 - hidden", null).setVisible(false);
+ submenu.addItem("Sub item 1 - disabled", null).setEnabled(false);
+ submenu.addItem("Sub item 2 - enabled", null);
+ submenu.addItem("Sub item 3 - visible", null);
+ submenu.addItem("Sub item 4 - hidden", null).setVisible(false);
+
+ addComponent(mb);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The menu contains 4 items, 2 of which are hidden. The sub menu contains 4 items, the last one is hidden";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4528;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarNavigation.java b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarNavigation.java
index 54b2f986a4..7e801a9faf 100644
--- a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarNavigation.java
+++ b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarNavigation.java
@@ -1,62 +1,62 @@
-package com.vaadin.tests.components.menubar;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.Command;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public class MenuBarNavigation extends TestBase implements Command {
-
- private MenuItem edit;
- private MenuItem file;
- private Log log;
- private MenuItem export;
-
- @Override
- protected void setup() {
- MenuBar mb = new MenuBar();
- file = mb.addItem("File", null);
- file.addItem("Open", this);
- file.addItem("Save", this);
- file.addItem("Save As..", this);
- file.addSeparator();
- export = file.addItem("Export..", null);
- export.addItem("As PDF...", this);
- file.addSeparator();
- file.addItem("Exit", this);
- edit = mb.addItem("Edit", null);
- edit.addItem("Copy", this);
- edit.addItem("Cut", this);
- edit.addItem("Paste", this);
- mb.addItem("Help", this);
-
- addComponent(mb);
-
- log = new Log(5);
- log.setNumberLogRows(false);
- addComponent(log);
- }
-
- @Override
- protected String getDescription() {
- return "Test case for mouse and keyboard navigation in MenuBar";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5174;
- }
-
- public void menuSelected(MenuItem selectedItem) {
- log.log("MenuItem " + getName(selectedItem) + " selected");
- }
-
- private String getName(MenuItem selectedItem) {
- String name = "";
- if (selectedItem.getParent() != null) {
- name = getName(selectedItem.getParent()) + "/";
- }
- return name + selectedItem.getText();
- }
-}
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.Command;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class MenuBarNavigation extends TestBase implements Command {
+
+ private MenuItem edit;
+ private MenuItem file;
+ private Log log;
+ private MenuItem export;
+
+ @Override
+ protected void setup() {
+ MenuBar mb = new MenuBar();
+ file = mb.addItem("File", null);
+ file.addItem("Open", this);
+ file.addItem("Save", this);
+ file.addItem("Save As..", this);
+ file.addSeparator();
+ export = file.addItem("Export..", null);
+ export.addItem("As PDF...", this);
+ file.addSeparator();
+ file.addItem("Exit", this);
+ edit = mb.addItem("Edit", null);
+ edit.addItem("Copy", this);
+ edit.addItem("Cut", this);
+ edit.addItem("Paste", this);
+ mb.addItem("Help", this);
+
+ addComponent(mb);
+
+ log = new Log(5);
+ log.setNumberLogRows(false);
+ addComponent(log);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test case for mouse and keyboard navigation in MenuBar";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5174;
+ }
+
+ public void menuSelected(MenuItem selectedItem) {
+ log.log("MenuItem " + getName(selectedItem) + " selected");
+ }
+
+ private String getName(MenuItem selectedItem) {
+ String name = "";
+ if (selectedItem.getParent() != null) {
+ name = getName(selectedItem.getParent()) + "/";
+ }
+ return name + selectedItem.getText();
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java
index 314df2c8a4..b05dbbd074 100644
--- a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java
+++ b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.menubar;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class MenuBarRunsOutOfBrowser extends AbstractTestCase {
-
- @Override
- public void init() {
- setTheme("runo");
- Window main = new Window("Test");
- main.setSizeFull();
- setMainWindow(main);
- main.getContent().setSizeFull();
-
- MenuBar menuBar = new MenuBar();
- menuBar.addItem("Test", new ThemeResource("icons/16/calendar.png"),
- null);
- menuBar.addItem("ABC", new ThemeResource("icons/16/document.png"), null);
- menuBar.addItem("123", new ThemeResource("icons/16/help.png"), null);
-
- main.getContent().addComponent(menuBar);
- ((VerticalLayout) main.getContent()).setComponentAlignment(menuBar,
- Alignment.TOP_RIGHT);
-
- }
-
- @Override
- protected String getDescription() {
- return "The menubar should be right aligned but not run out of the browser";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5894;
- }
-
-}
+package com.vaadin.tests.components.menubar;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class MenuBarRunsOutOfBrowser extends AbstractTestCase {
+
+ @Override
+ public void init() {
+ setTheme("runo");
+ Window main = new Window("Test");
+ main.setSizeFull();
+ setMainWindow(main);
+ main.getContent().setSizeFull();
+
+ MenuBar menuBar = new MenuBar();
+ menuBar.addItem("Test", new ThemeResource("icons/16/calendar.png"),
+ null);
+ menuBar.addItem("ABC", new ThemeResource("icons/16/document.png"), null);
+ menuBar.addItem("123", new ThemeResource("icons/16/help.png"), null);
+
+ main.getContent().addComponent(menuBar);
+ ((VerticalLayout) main.getContent()).setComponentAlignment(menuBar,
+ Alignment.TOP_RIGHT);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The menubar should be right aligned but not run out of the browser";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5894;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarTest.java b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarTest.java
index e41652126d..2dc119bf43 100644
--- a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarTest.java
+++ b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarTest.java
@@ -1,338 +1,338 @@
-package com.vaadin.tests.components.menubar;
-
-import java.util.Date;
-import java.util.LinkedHashMap;
-
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.AbstractComponentTest;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public class MenuBarTest extends AbstractComponentTest<MenuBar> {
-
- private static final String CATEGORY_MENU_ITEMS = "Menu items";
- private static final String CATEGORY_MENU_ITEM_STATES = "Menu item states";
-
- private int rootItems = -1;
- private int subItems = -1;
- private int subLevels = -1;
- private int subMenuDensity = -1;
- private Integer subMenuSeparatorDensity = null;
- private Boolean openRootMenuOnHover = false;
- private int iconInterval = -1;
- private Integer iconSize;
- private Integer disabledDensity;
- private Integer invisibleDensity;
- private Integer checkableDensity;
-
- @Override
- protected Class<MenuBar> getTestClass() {
- return MenuBar.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createRootMenuItemSelect(CATEGORY_MENU_ITEMS);
- createSubMenuItemSelect(CATEGORY_MENU_ITEMS);
- createSubMenuLevelsSelect(CATEGORY_MENU_ITEMS);
- createSubMenuDensitySelect(CATEGORY_MENU_ITEMS);
- createSubMenuSeparatorDensitySelect(CATEGORY_MENU_ITEMS);
-
- createBooleanAction("OpenRootMenuOnHover", CATEGORY_FEATURES,
- openRootMenuOnHover, setOpenRootOnHover);
-
- createMenuItemIconIntervalSelect(CATEGORY_MENU_ITEM_STATES);
- createMenuIconsSizeSelect(CATEGORY_MENU_ITEM_STATES);
- createMenuItemDisabledDensitySelect(CATEGORY_MENU_ITEM_STATES);
- createMenuItemInvisibleDensitySelect(CATEGORY_MENU_ITEM_STATES);
- createMenuItemCheckableDensitySelect(CATEGORY_MENU_ITEM_STATES);
-
- }
-
- private void createRootMenuItemSelect(String category) {
- createSelectAction("Root menu items", category,
- createIntegerOptions(100), "10", createRootMenuItems);
- }
-
- private void createSubMenuItemSelect(String category) {
- createSelectAction("Sub menu items", category,
- createIntegerOptions(100), "10", createSubMenuItems);
- }
-
- private void createSubMenuLevelsSelect(String category) {
- createSelectAction("Sub menu levels", category,
- createIntegerOptions(100), "2", setSubMenuLevels);
- }
-
- private void createMenuIconsSizeSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("16x16", 16);
- options.put("32x32", 32);
- options.put("64x64", 64);
- createSelectAction("Icon size", category, options, "16x16", selectIcon);
- }
-
- private void createMenuItemIconIntervalSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("None", 0);
- options.put("All", 1);
- options.put("Every second", 2);
- options.put("Every third", 3);
-
- createSelectAction("Icons", category, options, "None", setMenuIcons);
- }
-
- private void createSubMenuDensitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("All", 1);
- options.put("Every second", 2);
- options.put("Every third", 3);
-
- createSelectAction("Sub sub menus", category, options, "Every third",
- setSubMenuDensity);
- }
-
- private void createSubMenuSeparatorDensitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("No separators", null);
- options.put("Between all", 1);
- options.put("Between every second", 2);
- options.put("Between every third", 3);
-
- createSelectAction("Sub menu separators", category, options,
- "No separators", setSubMenuSeparatorDensity);
- }
-
- private void createMenuItemDisabledDensitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("All enabled", null);
- options.put("All disabled", 1);
- options.put("Every second", 2);
- options.put("Every third", 3);
-
- createSelectAction("Enabled", category, options, "All enabled",
- setMenuItemDisabledDensity);
- }
-
- private void createMenuItemInvisibleDensitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("All visible", null);
- options.put("All invisible", 1);
- options.put("Every second", 2);
- options.put("Every third", 3);
-
- createSelectAction("Visible", category, options, "All visible",
- setMenuItemInvisibleDensity);
- }
-
- private void createMenuItemCheckableDensitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("No items checkable", null);
- options.put("All checkable", 1);
- options.put("Every second", 2);
- options.put("Every third", 3);
-
- createSelectAction("Checkable", category, options,
- "No items checkable", setMenuItemCheckableDensity);
- }
-
- /* COMMANDS */
- Command<MenuBar, Integer> createRootMenuItems = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- rootItems = value;
- createRootItems(c);
- }
- };
-
- Command<MenuBar, Integer> createSubMenuItems = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- subItems = value;
- createSubItems(c);
- }
- };
-
- Command<MenuBar, Integer> setSubMenuLevels = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- subLevels = value;
- createSubItems(c);
- }
- };
- private Command<MenuBar, Integer> setMenuIcons = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- iconInterval = value;
- updateIcons(c);
- }
- };
-
- private Command<MenuBar, Integer> setSubMenuDensity = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- subMenuDensity = value;
- createSubItems(c);
- }
- };
-
- private Command<MenuBar, Integer> setMenuItemDisabledDensity = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- disabledDensity = value;
- createRootItems(c);
- }
- };
-
- private Command<MenuBar, Integer> setMenuItemInvisibleDensity = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- invisibleDensity = value;
- createRootItems(c);
- }
- };
-
- private Command<MenuBar, Integer> setMenuItemCheckableDensity = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- checkableDensity = value;
- createRootItems(c);
- }
- };
-
- private Command<MenuBar, Integer> setSubMenuSeparatorDensity = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- subMenuSeparatorDensity = value;
- createSubItems(c);
- }
- };
-
- private Command<MenuBar, Boolean> setOpenRootOnHover = new Command<MenuBar, Boolean>() {
-
- public void execute(MenuBar c, Boolean value, Object data) {
- openRootMenuOnHover = value;
- c.setAutoOpen(value);
- }
-
- };
-
- private Command<MenuBar, Integer> selectIcon = new Command<MenuBar, Integer>() {
-
- public void execute(MenuBar c, Integer value, Object data) {
- iconSize = value;
- updateIcons(c);
- }
- };
-
- /* End of commands */
-
- private MenuBar.Command menuCommand = new MenuBar.Command() {
-
- public void menuSelected(MenuItem selectedItem) {
- log("Menu item '" + selectedItem.getText() + "' selected");
-
- }
- };
-
- protected void createSubItems(MenuBar c) {
- for (MenuItem rootItem : c.getItems()) {
- createSubItems(rootItem, 1);
- }
- updateIcons(c);
-
- }
-
- private void createSubItems(MenuItem parent, int level) {
- if (level > subLevels) {
- return;
- }
-
- parent.removeChildren();
- for (int i = 0; i < subItems; i++) {
- if (subMenuSeparatorDensity != null && i > 0
- && i % subMenuSeparatorDensity == 0) {
- parent.addSeparator();
- }
-
- MenuItem subMenuItem = parent.addItem("Sub menu " + parent.getId()
- + "/" + (i + 1), menuCommand);
-
- if (disabledDensity != null && i % disabledDensity == 0) {
- subMenuItem.setEnabled(false);
- }
- if (invisibleDensity != null && i % invisibleDensity == 0) {
- subMenuItem.setVisible(false);
- }
-
- if (i % subMenuDensity == 0 && level < subLevels) {
- subMenuItem.setCommand(null);
- createSubItems(subMenuItem, level + 1);
- }
-
- if (!subMenuItem.hasChildren() && level > 0
- && checkableDensity != null && i % checkableDensity == 0) {
- subMenuItem.setCheckable(true);
- }
- }
-
- }
-
- protected void updateIcons(MenuBar c) {
- int idx = 0;
- for (MenuItem rootItem : c.getItems()) {
- updateIcons(rootItem, idx++);
- }
- }
-
- private void updateIcons(MenuItem item, int idx) {
- if (iconInterval > 0 && idx % iconInterval == 0) {
- item.setIcon(getIcon());
- } else {
- item.setIcon(null);
- }
- if (item.getChildren() != null) {
- int i = 0;
- for (MenuItem child : item.getChildren()) {
- updateIcons(child, i++);
- }
- }
- }
-
- private long iconCacheIndex = new Date().getTime();
-
- private Resource getIcon() {
- String resourceID = null;
- if (iconSize == 16) {
- resourceID = "../runo/icons/16/user.png";
- } else if (iconSize == 32) {
- resourceID = "../runo/icons/32/user.png";
- } else if (iconSize == 64) {
- resourceID = "../runo/icons/64/user.png";
- }
-
- if (resourceID != null) {
- return new ThemeResource(resourceID + "?" + iconCacheIndex++);
- }
- return null;
- }
-
- protected void createRootItems(MenuBar c) {
- // Remove all existing items
- c.removeItems();
- for (int i = 0; i < rootItems; i++) {
- MenuItem rootItem = c.addItem("Root menu " + (i + 1), null);
- if (disabledDensity != null && i % disabledDensity == 0) {
- rootItem.setEnabled(false);
- }
- if (invisibleDensity != null && i % invisibleDensity == 0) {
- rootItem.setVisible(false);
- }
- }
- createSubItems(c);
-
- }
-
-}
+package com.vaadin.tests.components.menubar;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class MenuBarTest extends AbstractComponentTest<MenuBar> {
+
+ private static final String CATEGORY_MENU_ITEMS = "Menu items";
+ private static final String CATEGORY_MENU_ITEM_STATES = "Menu item states";
+
+ private int rootItems = -1;
+ private int subItems = -1;
+ private int subLevels = -1;
+ private int subMenuDensity = -1;
+ private Integer subMenuSeparatorDensity = null;
+ private Boolean openRootMenuOnHover = false;
+ private int iconInterval = -1;
+ private Integer iconSize;
+ private Integer disabledDensity;
+ private Integer invisibleDensity;
+ private Integer checkableDensity;
+
+ @Override
+ protected Class<MenuBar> getTestClass() {
+ return MenuBar.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createRootMenuItemSelect(CATEGORY_MENU_ITEMS);
+ createSubMenuItemSelect(CATEGORY_MENU_ITEMS);
+ createSubMenuLevelsSelect(CATEGORY_MENU_ITEMS);
+ createSubMenuDensitySelect(CATEGORY_MENU_ITEMS);
+ createSubMenuSeparatorDensitySelect(CATEGORY_MENU_ITEMS);
+
+ createBooleanAction("OpenRootMenuOnHover", CATEGORY_FEATURES,
+ openRootMenuOnHover, setOpenRootOnHover);
+
+ createMenuItemIconIntervalSelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuIconsSizeSelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuItemDisabledDensitySelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuItemInvisibleDensitySelect(CATEGORY_MENU_ITEM_STATES);
+ createMenuItemCheckableDensitySelect(CATEGORY_MENU_ITEM_STATES);
+
+ }
+
+ private void createRootMenuItemSelect(String category) {
+ createSelectAction("Root menu items", category,
+ createIntegerOptions(100), "10", createRootMenuItems);
+ }
+
+ private void createSubMenuItemSelect(String category) {
+ createSelectAction("Sub menu items", category,
+ createIntegerOptions(100), "10", createSubMenuItems);
+ }
+
+ private void createSubMenuLevelsSelect(String category) {
+ createSelectAction("Sub menu levels", category,
+ createIntegerOptions(100), "2", setSubMenuLevels);
+ }
+
+ private void createMenuIconsSizeSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("16x16", 16);
+ options.put("32x32", 32);
+ options.put("64x64", 64);
+ createSelectAction("Icon size", category, options, "16x16", selectIcon);
+ }
+
+ private void createMenuItemIconIntervalSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("None", 0);
+ options.put("All", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Icons", category, options, "None", setMenuIcons);
+ }
+
+ private void createSubMenuDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("All", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Sub sub menus", category, options, "Every third",
+ setSubMenuDensity);
+ }
+
+ private void createSubMenuSeparatorDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("No separators", null);
+ options.put("Between all", 1);
+ options.put("Between every second", 2);
+ options.put("Between every third", 3);
+
+ createSelectAction("Sub menu separators", category, options,
+ "No separators", setSubMenuSeparatorDensity);
+ }
+
+ private void createMenuItemDisabledDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("All enabled", null);
+ options.put("All disabled", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Enabled", category, options, "All enabled",
+ setMenuItemDisabledDensity);
+ }
+
+ private void createMenuItemInvisibleDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("All visible", null);
+ options.put("All invisible", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Visible", category, options, "All visible",
+ setMenuItemInvisibleDensity);
+ }
+
+ private void createMenuItemCheckableDensitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("No items checkable", null);
+ options.put("All checkable", 1);
+ options.put("Every second", 2);
+ options.put("Every third", 3);
+
+ createSelectAction("Checkable", category, options,
+ "No items checkable", setMenuItemCheckableDensity);
+ }
+
+ /* COMMANDS */
+ Command<MenuBar, Integer> createRootMenuItems = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ rootItems = value;
+ createRootItems(c);
+ }
+ };
+
+ Command<MenuBar, Integer> createSubMenuItems = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subItems = value;
+ createSubItems(c);
+ }
+ };
+
+ Command<MenuBar, Integer> setSubMenuLevels = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subLevels = value;
+ createSubItems(c);
+ }
+ };
+ private Command<MenuBar, Integer> setMenuIcons = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ iconInterval = value;
+ updateIcons(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setSubMenuDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subMenuDensity = value;
+ createSubItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setMenuItemDisabledDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ disabledDensity = value;
+ createRootItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setMenuItemInvisibleDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ invisibleDensity = value;
+ createRootItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setMenuItemCheckableDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ checkableDensity = value;
+ createRootItems(c);
+ }
+ };
+
+ private Command<MenuBar, Integer> setSubMenuSeparatorDensity = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ subMenuSeparatorDensity = value;
+ createSubItems(c);
+ }
+ };
+
+ private Command<MenuBar, Boolean> setOpenRootOnHover = new Command<MenuBar, Boolean>() {
+
+ public void execute(MenuBar c, Boolean value, Object data) {
+ openRootMenuOnHover = value;
+ c.setAutoOpen(value);
+ }
+
+ };
+
+ private Command<MenuBar, Integer> selectIcon = new Command<MenuBar, Integer>() {
+
+ public void execute(MenuBar c, Integer value, Object data) {
+ iconSize = value;
+ updateIcons(c);
+ }
+ };
+
+ /* End of commands */
+
+ private MenuBar.Command menuCommand = new MenuBar.Command() {
+
+ public void menuSelected(MenuItem selectedItem) {
+ log("Menu item '" + selectedItem.getText() + "' selected");
+
+ }
+ };
+
+ protected void createSubItems(MenuBar c) {
+ for (MenuItem rootItem : c.getItems()) {
+ createSubItems(rootItem, 1);
+ }
+ updateIcons(c);
+
+ }
+
+ private void createSubItems(MenuItem parent, int level) {
+ if (level > subLevels) {
+ return;
+ }
+
+ parent.removeChildren();
+ for (int i = 0; i < subItems; i++) {
+ if (subMenuSeparatorDensity != null && i > 0
+ && i % subMenuSeparatorDensity == 0) {
+ parent.addSeparator();
+ }
+
+ MenuItem subMenuItem = parent.addItem("Sub menu " + parent.getId()
+ + "/" + (i + 1), menuCommand);
+
+ if (disabledDensity != null && i % disabledDensity == 0) {
+ subMenuItem.setEnabled(false);
+ }
+ if (invisibleDensity != null && i % invisibleDensity == 0) {
+ subMenuItem.setVisible(false);
+ }
+
+ if (i % subMenuDensity == 0 && level < subLevels) {
+ subMenuItem.setCommand(null);
+ createSubItems(subMenuItem, level + 1);
+ }
+
+ if (!subMenuItem.hasChildren() && level > 0
+ && checkableDensity != null && i % checkableDensity == 0) {
+ subMenuItem.setCheckable(true);
+ }
+ }
+
+ }
+
+ protected void updateIcons(MenuBar c) {
+ int idx = 0;
+ for (MenuItem rootItem : c.getItems()) {
+ updateIcons(rootItem, idx++);
+ }
+ }
+
+ private void updateIcons(MenuItem item, int idx) {
+ if (iconInterval > 0 && idx % iconInterval == 0) {
+ item.setIcon(getIcon());
+ } else {
+ item.setIcon(null);
+ }
+ if (item.getChildren() != null) {
+ int i = 0;
+ for (MenuItem child : item.getChildren()) {
+ updateIcons(child, i++);
+ }
+ }
+ }
+
+ private long iconCacheIndex = new Date().getTime();
+
+ private Resource getIcon() {
+ String resourceID = null;
+ if (iconSize == 16) {
+ resourceID = "../runo/icons/16/user.png";
+ } else if (iconSize == 32) {
+ resourceID = "../runo/icons/32/user.png";
+ } else if (iconSize == 64) {
+ resourceID = "../runo/icons/64/user.png";
+ }
+
+ if (resourceID != null) {
+ return new ThemeResource(resourceID + "?" + iconCacheIndex++);
+ }
+ return null;
+ }
+
+ protected void createRootItems(MenuBar c) {
+ // Remove all existing items
+ c.removeItems();
+ for (int i = 0; i < rootItems; i++) {
+ MenuItem rootItem = c.addItem("Root menu " + (i + 1), null);
+ if (disabledDensity != null && i % disabledDensity == 0) {
+ rootItem.setEnabled(false);
+ }
+ if (invisibleDensity != null && i % invisibleDensity == 0) {
+ rootItem.setVisible(false);
+ }
+ }
+ createSubItems(c);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/menubar/Menubars.java b/tests/testbench/com/vaadin/tests/components/menubar/Menubars.java
index 593b3b7fa5..40e566194a 100644
--- a/tests/testbench/com/vaadin/tests/components/menubar/Menubars.java
+++ b/tests/testbench/com/vaadin/tests/components/menubar/Menubars.java
@@ -1,88 +1,88 @@
-package com.vaadin.tests.components.menubar;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.MenuBar;
-import com.vaadin.ui.MenuBar.MenuItem;
-
-public class Menubars extends ComponentTestCase<MenuBar> {
-
- @Override
- protected Class<MenuBar> getTestClass() {
- return MenuBar.class;
- }
-
- @Override
- protected void initializeComponents() {
-
- MenuBar m;
- m = createMenuBar("This is an undefined wide menubar with 3 items", 3);
-
- m.setWidth(null);
- addTestComponent(m);
-
- m = createMenuBar(
- "This is an undefined wide menubar with fixed 100px height (4 items)",
- 4);
- m.setWidth(null);
- m.setHeight("100px");
- addTestComponent(m);
-
- m = createMenuBar("This is a 200px wide menubar with 10 items", 10);
- m.setWidth("200px");
- addTestComponent(m);
-
- m = createMenuBar("This is a 200px wide menubar with 2 items", 2);
- m.setWidth("200px");
- addTestComponent(m);
-
- m = createMenuBar("This is a 100% wide menubar with 3 items ", 3);
- m.setWidth("100%");
- addTestComponent(m);
-
- m = createMenuBar("This is a 100% wide menubar with 40 items ", 40);
- m.setWidth("100%");
- addTestComponent(m);
-
- m = createMenuBar(
- "This is a 100% wide menubar with fixed 65px height (5 items). ",
- 5);
- m.setWidth("100%");
- m.setHeight("65px");
-
- addTestComponent(m);
-
- }
-
- private MenuBar createMenuBar(String text, int items) {
- MenuBar m = new MenuBar();
- m.setCaption(text);
-
- for (int i = 1; i <= items; i++) {
- MenuItem mi = m.addItem("Item " + i, null);
- for (int j = 1; j <= items; j++) {
- mi.addItem("Sub menu " + i + "/" + j, null);
- }
- }
-
- return m;
- }
-
- @Override
- protected String getDescription() {
- return "A generic test for MenuBars in different configurations";
- }
-
- @Override
- protected List<Component> createActions() {
- ArrayList<Component> actions = new ArrayList<Component>();
- actions.add(createErrorIndicatorAction(false));
- actions.add(createEnabledAction(true));
-
- return actions;
- }
-
-}
+package com.vaadin.tests.components.menubar;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+public class Menubars extends ComponentTestCase<MenuBar> {
+
+ @Override
+ protected Class<MenuBar> getTestClass() {
+ return MenuBar.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+
+ MenuBar m;
+ m = createMenuBar("This is an undefined wide menubar with 3 items", 3);
+
+ m.setWidth(null);
+ addTestComponent(m);
+
+ m = createMenuBar(
+ "This is an undefined wide menubar with fixed 100px height (4 items)",
+ 4);
+ m.setWidth(null);
+ m.setHeight("100px");
+ addTestComponent(m);
+
+ m = createMenuBar("This is a 200px wide menubar with 10 items", 10);
+ m.setWidth("200px");
+ addTestComponent(m);
+
+ m = createMenuBar("This is a 200px wide menubar with 2 items", 2);
+ m.setWidth("200px");
+ addTestComponent(m);
+
+ m = createMenuBar("This is a 100% wide menubar with 3 items ", 3);
+ m.setWidth("100%");
+ addTestComponent(m);
+
+ m = createMenuBar("This is a 100% wide menubar with 40 items ", 40);
+ m.setWidth("100%");
+ addTestComponent(m);
+
+ m = createMenuBar(
+ "This is a 100% wide menubar with fixed 65px height (5 items). ",
+ 5);
+ m.setWidth("100%");
+ m.setHeight("65px");
+
+ addTestComponent(m);
+
+ }
+
+ private MenuBar createMenuBar(String text, int items) {
+ MenuBar m = new MenuBar();
+ m.setCaption(text);
+
+ for (int i = 1; i <= items; i++) {
+ MenuItem mi = m.addItem("Item " + i, null);
+ for (int j = 1; j <= items; j++) {
+ mi.addItem("Sub menu " + i + "/" + j, null);
+ }
+ }
+
+ return m;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A generic test for MenuBars in different configurations";
+ }
+
+ @Override
+ protected List<Component> createActions() {
+ ArrayList<Component> actions = new ArrayList<Component>();
+ actions.add(createErrorIndicatorAction(false));
+ actions.add(createEnabledAction(true));
+
+ return actions;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonTest.java b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonTest.java
index d806790f4d..7b1e75a3da 100644
--- a/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonTest.java
+++ b/tests/testbench/com/vaadin/tests/components/nativebutton/NativeButtonTest.java
@@ -1,12 +1,12 @@
-package com.vaadin.tests.components.nativebutton;
-
-import com.vaadin.tests.components.button.Buttons2;
-import com.vaadin.ui.NativeButton;
-
-public class NativeButtonTest extends Buttons2<NativeButton> {
-
- @Override
- protected Class<NativeButton> getTestClass() {
- return NativeButton.class;
- }
-}
+package com.vaadin.tests.components.nativebutton;
+
+import com.vaadin.tests.components.button.Buttons2;
+import com.vaadin.ui.NativeButton;
+
+public class NativeButtonTest extends Buttons2<NativeButton> {
+
+ @Override
+ protected Class<NativeButton> getTestClass() {
+ return NativeButton.class;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/nativeselect/NativeSelects.java b/tests/testbench/com/vaadin/tests/components/nativeselect/NativeSelects.java
index 5f19073e66..ec46757106 100644
--- a/tests/testbench/com/vaadin/tests/components/nativeselect/NativeSelects.java
+++ b/tests/testbench/com/vaadin/tests/components/nativeselect/NativeSelects.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.nativeselect;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.NativeSelect;
-
-public class NativeSelects extends AbstractSelectTestCase<NativeSelect> {
-
- @Override
- protected Class<NativeSelect> getTestClass() {
- return NativeSelect.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createColumnSelectAction();
- }
-
- private void createColumnSelectAction() {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("-", 0);
- for (int i = 1; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("50", 50);
- options.put("100", 100);
- options.put("1000", 1000);
-
- super.createSelectAction("Columns", CATEGORY_DATA_SOURCE, options, "-",
- columnsAction);
-
- }
-
- private Command<NativeSelect, Integer> columnsAction = new Command<NativeSelect, Integer>() {
-
- public void execute(NativeSelect c, Integer value, Object data) {
- c.setColumns(value);
- }
- };
-}
+package com.vaadin.tests.components.nativeselect;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.select.AbstractSelectTestCase;
+import com.vaadin.ui.NativeSelect;
+
+public class NativeSelects extends AbstractSelectTestCase<NativeSelect> {
+
+ @Override
+ protected Class<NativeSelect> getTestClass() {
+ return NativeSelect.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createColumnSelectAction();
+ }
+
+ private void createColumnSelectAction() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("-", 0);
+ for (int i = 1; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("50", 50);
+ options.put("100", 100);
+ options.put("1000", 1000);
+
+ super.createSelectAction("Columns", CATEGORY_DATA_SOURCE, options, "-",
+ columnsAction);
+
+ }
+
+ private Command<NativeSelect, Integer> columnsAction = new Command<NativeSelect, Integer>() {
+
+ public void execute(NativeSelect c, Integer value, Object data) {
+ c.setColumns(value);
+ }
+ };
+}
diff --git a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
index e938495e9f..0e054eba3b 100644
--- a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
+++ b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java
@@ -1,58 +1,58 @@
-package com.vaadin.tests.components.notification;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window.Notification;
-
-public class Notifications extends TestBase implements ClickListener {
-
- private static final String CAPTION = "CAPTION";
- private TextField tf;
- private NativeSelect type;
-
- @SuppressWarnings("deprecation")
- @Override
- protected void setup() {
- tf = new TextField("Text", "Hello world");
- tf.setRows(10);
- addComponent(tf);
- type = new NativeSelect();
- type.setNullSelectionAllowed(false);
- type.addContainerProperty(CAPTION, String.class, "");
- type.setItemCaptionPropertyId(CAPTION);
- type.addItem(Notification.TYPE_HUMANIZED_MESSAGE)
- .getItemProperty(CAPTION).setValue("Humanized");
- type.addItem(Notification.TYPE_ERROR_MESSAGE).getItemProperty(CAPTION)
- .setValue("Error");
- type.addItem(Notification.TYPE_WARNING_MESSAGE)
- .getItemProperty(CAPTION).setValue("Warning");
- type.addItem(Notification.TYPE_TRAY_NOTIFICATION)
- .getItemProperty(CAPTION).setValue("Tray");
- type.setValue(type.getItemIds().iterator().next());
- addComponent(type);
- Button showNotification = new Button("Show notification", this);
- addComponent(showNotification);
- }
-
- @Override
- protected String getDescription() {
- return "Generic test case for notifications";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void buttonClick(ClickEvent event) {
- Notification n = new Notification((String) tf.getValue(),
- (Integer) type.getValue());
- event.getButton().getWindow().showNotification(n);
-
- }
-}
+package com.vaadin.tests.components.notification;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window.Notification;
+
+public class Notifications extends TestBase implements ClickListener {
+
+ private static final String CAPTION = "CAPTION";
+ private TextField tf;
+ private NativeSelect type;
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void setup() {
+ tf = new TextField("Text", "Hello world");
+ tf.setRows(10);
+ addComponent(tf);
+ type = new NativeSelect();
+ type.setNullSelectionAllowed(false);
+ type.addContainerProperty(CAPTION, String.class, "");
+ type.setItemCaptionPropertyId(CAPTION);
+ type.addItem(Notification.TYPE_HUMANIZED_MESSAGE)
+ .getItemProperty(CAPTION).setValue("Humanized");
+ type.addItem(Notification.TYPE_ERROR_MESSAGE).getItemProperty(CAPTION)
+ .setValue("Error");
+ type.addItem(Notification.TYPE_WARNING_MESSAGE)
+ .getItemProperty(CAPTION).setValue("Warning");
+ type.addItem(Notification.TYPE_TRAY_NOTIFICATION)
+ .getItemProperty(CAPTION).setValue("Tray");
+ type.setValue(type.getItemIds().iterator().next());
+ addComponent(type);
+ Button showNotification = new Button("Show notification", this);
+ addComponent(showNotification);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Generic test case for notifications";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Notification n = new Notification((String) tf.getValue(),
+ (Integer) type.getValue());
+ event.getButton().getWindow().showNotification(n);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java b/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
index 9157c30174..60db11f1df 100644
--- a/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
+++ b/tests/testbench/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
@@ -1,76 +1,76 @@
-package com.vaadin.tests.components.notification;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Window.Notification;
-
-public class NotificationsHtmlAllowed extends TestBase implements ClickListener {
-
- private TextArea messageField;
- private CheckBox htmlAllowedBox;
- private TextField captionField;
- private Window subwindow;
- private CheckBox showInSubwindow;
-
- @Override
- protected void setup() {
- captionField = new TextField("Caption", "Hello <u>world</u>");
- addComponent(captionField);
- captionField.focus();
-
- messageField = new TextArea("Message",
- "Hello <i>world</i>\nWith a newline <br/>And a html line break");
- messageField.setRows(10);
- addComponent(messageField);
-
- htmlAllowedBox = new CheckBox("Html content allowed", true);
- addComponent(htmlAllowedBox);
-
- showInSubwindow = new CheckBox("Show in subwindow", false);
- addComponent(showInSubwindow);
-
- Button showNotification = new Button("Show notification", this);
- addComponent(showNotification);
-
- subwindow = new Window("Sub window");
- subwindow.setPositionX(400);
- subwindow.setPositionY(0);
- getMainWindow().addWindow(subwindow);
- }
-
- @Override
- protected String getDescription() {
- return "Test case for htmlAllowed in notifications";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6097;
- }
-
- public void buttonClick(ClickEvent event) {
- Notification n = makeNotification();
- Window window;
- if (showInSubwindow.booleanValue()) {
- window = subwindow;
- } else {
- window = event.getButton().getWindow();
- }
- window.showNotification(n);
-
- }
-
- private Notification makeNotification() {
- Notification n = new Notification((String) captionField.getValue(),
- (String) messageField.getValue(),
- Notification.TYPE_HUMANIZED_MESSAGE,
- htmlAllowedBox.booleanValue());
- return n;
- }
-}
+package com.vaadin.tests.components.notification;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.Notification;
+
+public class NotificationsHtmlAllowed extends TestBase implements ClickListener {
+
+ private TextArea messageField;
+ private CheckBox htmlAllowedBox;
+ private TextField captionField;
+ private Window subwindow;
+ private CheckBox showInSubwindow;
+
+ @Override
+ protected void setup() {
+ captionField = new TextField("Caption", "Hello <u>world</u>");
+ addComponent(captionField);
+ captionField.focus();
+
+ messageField = new TextArea("Message",
+ "Hello <i>world</i>\nWith a newline <br/>And a html line break");
+ messageField.setRows(10);
+ addComponent(messageField);
+
+ htmlAllowedBox = new CheckBox("Html content allowed", true);
+ addComponent(htmlAllowedBox);
+
+ showInSubwindow = new CheckBox("Show in subwindow", false);
+ addComponent(showInSubwindow);
+
+ Button showNotification = new Button("Show notification", this);
+ addComponent(showNotification);
+
+ subwindow = new Window("Sub window");
+ subwindow.setPositionX(400);
+ subwindow.setPositionY(0);
+ getMainWindow().addWindow(subwindow);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test case for htmlAllowed in notifications";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6097;
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Notification n = makeNotification();
+ Window window;
+ if (showInSubwindow.booleanValue()) {
+ window = subwindow;
+ } else {
+ window = event.getButton().getWindow();
+ }
+ window.showNotification(n);
+
+ }
+
+ private Notification makeNotification() {
+ Notification n = new Notification((String) captionField.getValue(),
+ (String) messageField.getValue(),
+ Notification.TYPE_HUMANIZED_MESSAGE,
+ htmlAllowedBox.booleanValue());
+ return n;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/optiongroup/OptionGroups.java b/tests/testbench/com/vaadin/tests/components/optiongroup/OptionGroups.java
index 1e752e7c26..f8af6b07e4 100644
--- a/tests/testbench/com/vaadin/tests/components/optiongroup/OptionGroups.java
+++ b/tests/testbench/com/vaadin/tests/components/optiongroup/OptionGroups.java
@@ -1,67 +1,67 @@
-package com.vaadin.tests.components.optiongroup;
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.OptionGroup;
-
-public class OptionGroups extends AbstractSelectTestCase<OptionGroup> {
-
- @Override
- protected Class<OptionGroup> getTestClass() {
- return OptionGroup.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createDisabledItemsMultiToggle("Disabled items");
- createBooleanAction("HTML content allowed", CATEGORY_STATE, false,
- new Command<OptionGroup, Boolean>() {
- public void execute(OptionGroup og, Boolean value,
- Object data) {
- og.setHtmlContentAllowed(value.booleanValue());
- }
- });
- createIconToggle("Item icons");
- }
-
- private void createIconToggle(String string) {
- LinkedHashMap<String, ThemeResource> options = new LinkedHashMap<String, ThemeResource>();
- options.put("-", null);
- options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
- options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
- options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
-
- createSelectAction(string, CATEGORY_DECORATIONS, options, options
- .keySet().iterator().next(),
- new Command<OptionGroup, ThemeResource>() {
- public void execute(OptionGroup c, ThemeResource icon,
- Object data) {
- Collection<?> itemIds = c.getItemIds();
- for (Object itemId : itemIds) {
- c.setItemIcon(itemId, icon);
- }
- }
- });
- }
-
- private void createDisabledItemsMultiToggle(String category) {
- for (Object id : getComponent().getItemIds()) {
- createBooleanAction(id.toString() + " - enabled", category, true,
- enabledItemCommand, id);
- }
- }
-
- private Command<OptionGroup, Boolean> enabledItemCommand = new Command<OptionGroup, Boolean>() {
-
- public void execute(OptionGroup c, Boolean value, Object data) {
- c.setItemEnabled(data, value);
-
- }
- };
-
-}
+package com.vaadin.tests.components.optiongroup;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.select.AbstractSelectTestCase;
+import com.vaadin.ui.OptionGroup;
+
+public class OptionGroups extends AbstractSelectTestCase<OptionGroup> {
+
+ @Override
+ protected Class<OptionGroup> getTestClass() {
+ return OptionGroup.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createDisabledItemsMultiToggle("Disabled items");
+ createBooleanAction("HTML content allowed", CATEGORY_STATE, false,
+ new Command<OptionGroup, Boolean>() {
+ public void execute(OptionGroup og, Boolean value,
+ Object data) {
+ og.setHtmlContentAllowed(value.booleanValue());
+ }
+ });
+ createIconToggle("Item icons");
+ }
+
+ private void createIconToggle(String string) {
+ LinkedHashMap<String, ThemeResource> options = new LinkedHashMap<String, ThemeResource>();
+ options.put("-", null);
+ options.put("16x16", ICON_16_USER_PNG_CACHEABLE);
+ options.put("32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
+ options.put("64x64", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
+
+ createSelectAction(string, CATEGORY_DECORATIONS, options, options
+ .keySet().iterator().next(),
+ new Command<OptionGroup, ThemeResource>() {
+ public void execute(OptionGroup c, ThemeResource icon,
+ Object data) {
+ Collection<?> itemIds = c.getItemIds();
+ for (Object itemId : itemIds) {
+ c.setItemIcon(itemId, icon);
+ }
+ }
+ });
+ }
+
+ private void createDisabledItemsMultiToggle(String category) {
+ for (Object id : getComponent().getItemIds()) {
+ createBooleanAction(id.toString() + " - enabled", category, true,
+ enabledItemCommand, id);
+ }
+ }
+
+ private Command<OptionGroup, Boolean> enabledItemCommand = new Command<OptionGroup, Boolean>() {
+
+ public void execute(OptionGroup c, Boolean value, Object data) {
+ c.setItemEnabled(data, value);
+
+ }
+ };
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/HorizontalLayoutTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/HorizontalLayoutTest.java
index b06179efd7..fd6ecf5422 100644
--- a/tests/testbench/com/vaadin/tests/components/orderedlayout/HorizontalLayoutTest.java
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/HorizontalLayoutTest.java
@@ -1,14 +1,14 @@
-package com.vaadin.tests.components.orderedlayout;
-
-import com.vaadin.tests.components.AbstractOrderedLayoutTest;
-import com.vaadin.ui.HorizontalLayout;
-
-public class HorizontalLayoutTest extends
- AbstractOrderedLayoutTest<HorizontalLayout> {
-
- @Override
- protected Class<HorizontalLayout> getTestClass() {
- return HorizontalLayout.class;
- }
-
+package com.vaadin.tests.components.orderedlayout;
+
+import com.vaadin.tests.components.AbstractOrderedLayoutTest;
+import com.vaadin.ui.HorizontalLayout;
+
+public class HorizontalLayoutTest extends
+ AbstractOrderedLayoutTest<HorizontalLayout> {
+
+ @Override
+ protected Class<HorizontalLayout> getTestClass() {
+ return HorizontalLayout.class;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
index 555495cc58..501c377ab7 100644
--- a/tests/testbench/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
@@ -1,40 +1,40 @@
-package com.vaadin.tests.components.orderedlayout;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.VerticalLayout;
-
-public class ReplaceComponentNPE extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Clicking 'ReplaceComponent' should replace the 'Button' button with a VericalLayout, and move the button inside the verticalLayout. Visually this can be seen by the added margins of the VerticalLayout.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3195;
- }
-
- final Button button = new Button("Button");
- final VerticalLayout outer = new VerticalLayout();
-
- @Override
- protected void setup() {
- outer.setMargin(true);
-
- Button changer = new Button("ReplaceComponent");
- changer.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- getLayout().replaceComponent(button, outer);
- outer.addComponent(button);
- }
- });
-
- getLayout().addComponent(button);
- getLayout().addComponent(changer);
-
- }
-
-}
+package com.vaadin.tests.components.orderedlayout;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.VerticalLayout;
+
+public class ReplaceComponentNPE extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Clicking 'ReplaceComponent' should replace the 'Button' button with a VericalLayout, and move the button inside the verticalLayout. Visually this can be seen by the added margins of the VerticalLayout.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3195;
+ }
+
+ final Button button = new Button("Button");
+ final VerticalLayout outer = new VerticalLayout();
+
+ @Override
+ protected void setup() {
+ outer.setMargin(true);
+
+ Button changer = new Button("ReplaceComponent");
+ changer.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ getLayout().replaceComponent(button, outer);
+ outer.addComponent(button);
+ }
+ });
+
+ getLayout().addComponent(button);
+ getLayout().addComponent(changer);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutTest.java
index 20babc8576..2298364c3f 100644
--- a/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutTest.java
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutTest.java
@@ -1,14 +1,14 @@
-package com.vaadin.tests.components.orderedlayout;
-
-import com.vaadin.tests.components.AbstractOrderedLayoutTest;
-import com.vaadin.ui.VerticalLayout;
-
-public class VerticalLayoutTest extends
- AbstractOrderedLayoutTest<VerticalLayout> {
-
- @Override
- protected Class<VerticalLayout> getTestClass() {
- return VerticalLayout.class;
- }
-
-}
+package com.vaadin.tests.components.orderedlayout;
+
+import com.vaadin.tests.components.AbstractOrderedLayoutTest;
+import com.vaadin.ui.VerticalLayout;
+
+public class VerticalLayoutTest extends
+ AbstractOrderedLayoutTest<VerticalLayout> {
+
+ @Override
+ protected Class<VerticalLayout> getTestClass() {
+ return VerticalLayout.class;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/passwordfield/PasswordFieldTest.java b/tests/testbench/com/vaadin/tests/components/passwordfield/PasswordFieldTest.java
index 86d035e925..a256438494 100644
--- a/tests/testbench/com/vaadin/tests/components/passwordfield/PasswordFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/passwordfield/PasswordFieldTest.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.components.passwordfield;
-
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
-import com.vaadin.ui.PasswordField;
-
-public class PasswordFieldTest extends AbstractTextFieldTest<PasswordField>
- implements TextChangeListener {
-
- @Override
- protected Class<PasswordField> getTestClass() {
- return PasswordField.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- }
-
-}
+package com.vaadin.tests.components.passwordfield;
+
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
+import com.vaadin.ui.PasswordField;
+
+public class PasswordFieldTest extends AbstractTextFieldTest<PasswordField>
+ implements TextChangeListener {
+
+ @Override
+ protected Class<PasswordField> getTestClass() {
+ return PasswordField.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewLabelResized.java b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewLabelResized.java
index 52bdd47790..2776c63e9f 100644
--- a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewLabelResized.java
+++ b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewLabelResized.java
@@ -1,37 +1,37 @@
-package com.vaadin.tests.components.popupview;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.PopupView;
-
-public class PopupViewLabelResized extends TestBase {
-
- @Override
- protected String getDescription() {
- return "When clicking on the popup view on the left, its size should not change.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3483;
- }
-
- @Override
- protected void setup() {
- GridLayout gl = new GridLayout(3, 1);
- gl.setSizeFull();
-
- Label expander = new Label();
- gl.addComponent(expander, 1, 0);
- gl.setColumnExpandRatio(1, 1);
-
- gl.addComponent(
- new PopupView("Click here to popup", new Label("test")), 0, 0);
- gl.addComponent(
- new PopupView("Click here to popup", new Label("test")), 2, 0);
-
- addComponent(gl);
- }
-
-}
+package com.vaadin.tests.components.popupview;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupView;
+
+public class PopupViewLabelResized extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "When clicking on the popup view on the left, its size should not change.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3483;
+ }
+
+ @Override
+ protected void setup() {
+ GridLayout gl = new GridLayout(3, 1);
+ gl.setSizeFull();
+
+ Label expander = new Label();
+ gl.addComponent(expander, 1, 0);
+ gl.setColumnExpandRatio(1, 1);
+
+ gl.addComponent(
+ new PopupView("Click here to popup", new Label("test")), 0, 0);
+ gl.addComponent(
+ new PopupView("Click here to popup", new Label("test")), 2, 0);
+
+ addComponent(gl);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewNullValues.java b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewNullValues.java
index 78e66e2db3..ff71f2f381 100644
--- a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewNullValues.java
+++ b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewNullValues.java
@@ -1,103 +1,103 @@
-package com.vaadin.tests.components.popupview;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.PopupView;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window.Notification;
-
-public class PopupViewNullValues extends TestBase {
-
- private PopupView pv[] = new PopupView[4];
- private Button b[] = new Button[4];
-
- @Override
- protected void setup() {
- try {
- pv[0] = new PopupView("Popupview 1 - no component", null);
- addComponent(pv[0]);
- b[0] = new Button("Open popupview 1", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- pv[0].setPopupVisible(true);
- }
-
- });
- } catch (Exception e) {
- getMainWindow()
- .showNotification(
- "Error, 'null content' should not throw an exception at this point",
- Notification.TYPE_ERROR_MESSAGE);
- }
-
- try {
- pv[1] = new PopupView(null, new TextField(
- "Empty html, contains component"));
- addComponent(pv[1]);
- b[1] = new Button("Open popupview 2", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- pv[1].setPopupVisible(true);
- }
-
- });
- } catch (Exception e) {
- getMainWindow()
- .showNotification(
- "Error, 'null html', should not throw an exception at this point",
- Notification.TYPE_ERROR_MESSAGE);
- }
-
- try {
- pv[2] = new PopupView(null, null);
- addComponent(pv[2]);
- b[2] = new Button("Open popupview 3", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- pv[2].setPopupVisible(true);
- }
-
- });
- } catch (Exception e) {
- getMainWindow()
- .showNotification(
- "Error, 'null html, null content', should not throw an exception at this point",
- Notification.TYPE_ERROR_MESSAGE);
- }
- try {
- pv[3] = new PopupView("Popupview 4 - has component", new TextField(
- "This is the content of popupview 4"));
- addComponent(pv[3]);
- b[3] = new Button("Open popupview 4", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- pv[3].setPopupVisible(true);
- }
-
- });
- } catch (Exception e) {
- getMainWindow()
- .showNotification(
- "Error, 'null html, null content', should not throw an exception at this point",
- Notification.TYPE_ERROR_MESSAGE);
- }
-
- addComponent(b[0]);
- addComponent(b[1]);
- addComponent(b[2]);
- addComponent(b[3]);
- }
-
- @Override
- protected String getDescription() {
- return "This test case contains 3 popupviews. Only the second and the forth popup views have non-null components and can be opened. 1 and 3 will produce an exception if you try to open them.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3248;
- }
-
-}
+package com.vaadin.tests.components.popupview;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window.Notification;
+
+public class PopupViewNullValues extends TestBase {
+
+ private PopupView pv[] = new PopupView[4];
+ private Button b[] = new Button[4];
+
+ @Override
+ protected void setup() {
+ try {
+ pv[0] = new PopupView("Popupview 1 - no component", null);
+ addComponent(pv[0]);
+ b[0] = new Button("Open popupview 1", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ pv[0].setPopupVisible(true);
+ }
+
+ });
+ } catch (Exception e) {
+ getMainWindow()
+ .showNotification(
+ "Error, 'null content' should not throw an exception at this point",
+ Notification.TYPE_ERROR_MESSAGE);
+ }
+
+ try {
+ pv[1] = new PopupView(null, new TextField(
+ "Empty html, contains component"));
+ addComponent(pv[1]);
+ b[1] = new Button("Open popupview 2", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ pv[1].setPopupVisible(true);
+ }
+
+ });
+ } catch (Exception e) {
+ getMainWindow()
+ .showNotification(
+ "Error, 'null html', should not throw an exception at this point",
+ Notification.TYPE_ERROR_MESSAGE);
+ }
+
+ try {
+ pv[2] = new PopupView(null, null);
+ addComponent(pv[2]);
+ b[2] = new Button("Open popupview 3", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ pv[2].setPopupVisible(true);
+ }
+
+ });
+ } catch (Exception e) {
+ getMainWindow()
+ .showNotification(
+ "Error, 'null html, null content', should not throw an exception at this point",
+ Notification.TYPE_ERROR_MESSAGE);
+ }
+ try {
+ pv[3] = new PopupView("Popupview 4 - has component", new TextField(
+ "This is the content of popupview 4"));
+ addComponent(pv[3]);
+ b[3] = new Button("Open popupview 4", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ pv[3].setPopupVisible(true);
+ }
+
+ });
+ } catch (Exception e) {
+ getMainWindow()
+ .showNotification(
+ "Error, 'null html, null content', should not throw an exception at this point",
+ Notification.TYPE_ERROR_MESSAGE);
+ }
+
+ addComponent(b[0]);
+ addComponent(b[1]);
+ addComponent(b[2]);
+ addComponent(b[3]);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "This test case contains 3 popupviews. Only the second and the forth popup views have non-null components and can be opened. 1 and 3 will produce an exception if you try to open them.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3248;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewWithRTE.java b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewWithRTE.java
index ea94ee2185..1123f217b7 100644
--- a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewWithRTE.java
+++ b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewWithRTE.java
@@ -1,50 +1,50 @@
-package com.vaadin.tests.components.popupview;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.PopupView;
-import com.vaadin.ui.PopupView.Content;
-import com.vaadin.ui.RichTextArea;
-import com.vaadin.ui.VerticalLayout;
-
-public class PopupViewWithRTE extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Rich text editor should work properly in popupview. Try to edit text below.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3043;
- }
-
- @Override
- protected void setup() {
- PopupView pv = new PopupView(new Content() {
-
- RichTextArea rte = new RichTextArea();
-
- VerticalLayout vl = new VerticalLayout();
-
- public String getMinimizedValueAsHTML() {
- Object value = rte.getValue();
- if (value == null || "".equals(value)) {
- value = "Initial <b>content</b> for <h3>rte</h3>.";
- rte.setValue(value);
- rte.setHeight("150px");
- rte.setWidth("100%");
- vl.addComponent(rte);
- vl.setWidth("600px");
- }
- return value.toString();
- }
-
- public Component getPopupComponent() {
- return vl;
- }
- });
- getLayout().addComponent(pv);
- }
-
-}
+package com.vaadin.tests.components.popupview;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.PopupView.Content;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.VerticalLayout;
+
+public class PopupViewWithRTE extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Rich text editor should work properly in popupview. Try to edit text below.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3043;
+ }
+
+ @Override
+ protected void setup() {
+ PopupView pv = new PopupView(new Content() {
+
+ RichTextArea rte = new RichTextArea();
+
+ VerticalLayout vl = new VerticalLayout();
+
+ public String getMinimizedValueAsHTML() {
+ Object value = rte.getValue();
+ if (value == null || "".equals(value)) {
+ value = "Initial <b>content</b> for <h3>rte</h3>.";
+ rte.setValue(value);
+ rte.setHeight("150px");
+ rte.setWidth("100%");
+ vl.addComponent(rte);
+ vl.setWidth("600px");
+ }
+ return value.toString();
+ }
+
+ public Component getPopupComponent() {
+ return vl;
+ }
+ });
+ getLayout().addComponent(pv);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java b/tests/testbench/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java
index 7e6cfd17ea..62dba61191 100644
--- a/tests/testbench/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java
+++ b/tests/testbench/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java
@@ -1,52 +1,52 @@
-package com.vaadin.tests.components.progressindicator;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ProgressIndicator;
-import com.vaadin.ui.VerticalLayout;
-
-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;
- }
-
-}
+package com.vaadin.tests.components.progressindicator;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ProgressIndicator;
+import com.vaadin.ui.VerticalLayout;
+
+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/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaTest.java b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaTest.java
index ad2f82aca6..cb7b991bda 100644
--- a/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaTest.java
+++ b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaTest.java
@@ -1,54 +1,54 @@
-package com.vaadin.tests.components.richtextarea;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.ui.RichTextArea;
-
-public class RichTextAreaTest extends AbstractFieldTest<RichTextArea> {
-
- @Override
- protected Class<RichTextArea> getTestClass() {
- return RichTextArea.class;
- }
-
- private Command<RichTextArea, Boolean> nullSelectionAllowedCommand = new Command<RichTextArea, Boolean>() {
-
- public void execute(RichTextArea c, Boolean value, Object data) {
- c.setNullSettingAllowed(value);
-
- }
- };
- private Command<RichTextArea, String> nullRepresentationCommand = new Command<RichTextArea, String>() {
-
- public void execute(RichTextArea c, String value, Object data) {
- c.setNullRepresentation(value);
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createSetTextValueAction(CATEGORY_ACTIONS);
-
- createNullSettingAllowedAction(CATEGORY_FEATURES);
- createNullRepresentationAction(CATEGORY_FEATURES);
- }
-
- private void createNullSettingAllowedAction(String category) {
- createBooleanAction("Null selection allowed", category, true,
- nullSelectionAllowedCommand);
- }
-
- private void createNullRepresentationAction(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("-", null);
- options.put("null", "null");
- options.put("This is empty", "This is empty");
- options.put("- Nothing -", "- Nothing -");
- createSelectAction("Null representation", category, options, "null",
- nullRepresentationCommand);
- }
-
-}
+package com.vaadin.tests.components.richtextarea;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.ui.RichTextArea;
+
+public class RichTextAreaTest extends AbstractFieldTest<RichTextArea> {
+
+ @Override
+ protected Class<RichTextArea> getTestClass() {
+ return RichTextArea.class;
+ }
+
+ private Command<RichTextArea, Boolean> nullSelectionAllowedCommand = new Command<RichTextArea, Boolean>() {
+
+ public void execute(RichTextArea c, Boolean value, Object data) {
+ c.setNullSettingAllowed(value);
+
+ }
+ };
+ private Command<RichTextArea, String> nullRepresentationCommand = new Command<RichTextArea, String>() {
+
+ public void execute(RichTextArea c, String value, Object data) {
+ c.setNullRepresentation(value);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createSetTextValueAction(CATEGORY_ACTIONS);
+
+ createNullSettingAllowedAction(CATEGORY_FEATURES);
+ createNullRepresentationAction(CATEGORY_FEATURES);
+ }
+
+ private void createNullSettingAllowedAction(String category) {
+ createBooleanAction("Null selection allowed", category, true,
+ nullSelectionAllowedCommand);
+ }
+
+ private void createNullRepresentationAction(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("-", null);
+ options.put("null", "null");
+ options.put("This is empty", "This is empty");
+ options.put("- Nothing -", "- Nothing -");
+ createSelectAction("Null representation", category, options, "null",
+ nullRepresentationCommand);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/AbstractSelectTestCase.java b/tests/testbench/com/vaadin/tests/components/select/AbstractSelectTestCase.java
index a9ef32fa9f..0565811e15 100644
--- a/tests/testbench/com/vaadin/tests/components/select/AbstractSelectTestCase.java
+++ b/tests/testbench/com/vaadin/tests/components/select/AbstractSelectTestCase.java
@@ -1,240 +1,240 @@
-package com.vaadin.tests.components.select;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.event.Action;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.event.ItemClickEvent.ItemClickNotifier;
-import com.vaadin.terminal.Resource;
-import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.ui.AbstractSelect;
-
-public abstract class AbstractSelectTestCase<T extends AbstractSelect> extends
- AbstractFieldTest<T> implements ItemClickListener {
-
- public static final String CATEGORY_DATA_SOURCE = "Data source";
-
- private int items = 0;
- private int properties = 0;
-
- protected static class ContextMenu {
-
- private List<Action> items = new ArrayList<Action>();
-
- public ContextMenu(String caption, Resource icon) {
- addItem(caption, icon);
- }
-
- public ContextMenu() {
- }
-
- public void addItem(String caption, Resource icon) {
- items.add(new Action(caption, icon));
- }
-
- public Action[] getActions(Object target, Object sender) {
- Action[] actions = new Action[items.size()];
- for (int i = 0; i < items.size(); i++) {
- actions[i] = items.get(i);
- }
-
- return actions;
- }
-
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createNullSelectAllowedCheckbox(CATEGORY_SELECTION);
- createMultiSelectCheckbox(CATEGORY_SELECTION);
-
- createPropertiesInContainerSelect(CATEGORY_DATA_SOURCE);
- createItemsInContainerSelect(CATEGORY_DATA_SOURCE);
-
- }
-
- protected void createNullSelectAllowedCheckbox(String category) {
- createBooleanAction("Null Selection Allowed", category, false,
- nullSelectionAllowedCommand);
-
- }
-
- protected void createMultiSelectCheckbox(String category) {
- createBooleanAction("Multi select", category, false, multiselectCommand);
-
- }
-
- protected void createNullSelectItemId(String category) {
- LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
- options.put("- None -", null);
- for (Object id : (getComponent()).getContainerDataSource()
- .getContainerPropertyIds()) {
- options.put(id.toString(), id);
- }
- createSelectAction("Null Selection Item Id", category, options,
- "- None -", nullSelectItemIdCommand);
- }
-
- protected Container createContainer(int properties, int items) {
- return createIndexedContainer(properties, items);
- }
-
- private Container createIndexedContainer(int properties, int items) {
- IndexedContainer c = new IndexedContainer();
- populateContainer(c, properties, items);
-
- return c;
- }
-
- protected void populateContainer(Container c, int properties, int items) {
- c.removeAllItems();
- for (int i = 1; i <= properties; i++) {
- c.addContainerProperty("Property " + i, String.class, "");
- }
- for (int i = 1; i <= items; i++) {
- Item item = c.addItem("Item " + i);
- for (int j = 1; j <= properties; j++) {
- item.getItemProperty("Property " + j).setValue(
- "Item " + i + "," + j);
- }
- }
-
- }
-
- protected void createItemsInContainerSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- for (int i = 0; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("20", 20);
- options.put("100", 100);
- options.put("1000", 1000);
- options.put("10000", 10000);
- options.put("100000", 100000);
-
- createSelectAction("Items in container", category, options, "20",
- itemsInContainerCommand);
- }
-
- protected void createPropertiesInContainerSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("0", 0);
- for (int i = 0; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("50", 50);
- options.put("100", 100);
- options.put("1000", 1000);
-
- createSelectAction("Properties in container", category, options, "10",
- propertiesInContainerCommand);
- }
-
- protected void createItemClickListener(String category) {
- createBooleanAction("Item click listener", category, false,
- itemClickListenerCommand);
- }
-
- /* COMMANDS */
-
- protected Command<T, Boolean> nullSelectionAllowedCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- (c).setNullSelectionAllowed(value);
- }
- };
-
- protected Command<T, Boolean> multiselectCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setMultiSelect(value);
- }
- };
-
- protected Command<T, Object> nullSelectItemIdCommand = new Command<T, Object>() {
-
- public void execute(T c, Object value, Object data) {
- c.setNullSelectionItemId(value);
- }
- };
-
- protected Command<T, Integer> itemsInContainerCommand = new Command<T, Integer>() {
-
- public void execute(T t, Integer value, Object data) {
- items = value;
- updateContainer();
- }
- };
-
- protected Command<T, Integer> propertiesInContainerCommand = new Command<T, Integer>() {
-
- public void execute(T t, Integer value, Object data) {
- properties = value;
- updateContainer();
- }
- };
-
- protected Command<T, Boolean> itemClickListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- ((ItemClickNotifier) c)
- .addListener(AbstractSelectTestCase.this);
- } else {
- ((ItemClickNotifier) c)
- .removeListener(AbstractSelectTestCase.this);
- }
-
- }
- };
-
- protected void setContainer(Container newContainer) {
- getComponent().setContainerDataSource(newContainer);
-
- }
-
- protected void updateContainer() {
- setContainer(createContainer(properties, items));
- }
-
- /* COMMANDS END */
-
- public void itemClick(ItemClickEvent event) {
- String type = event.getButtonName();
- if (event.isDoubleClick()) {
- type += " double-click";
- } else {
- type += " click";
- }
-
- String target = "source: " + event.getSource();
- target += ", client: [" + event.getClientX() + "," + event.getClientY()
- + "];";
- target += ", relative: [" + event.getRelativeX() + ","
- + event.getRelativeY() + "]";
- target += ", itemId: " + event.getItemId();
- target += ", propertyId: " + event.getPropertyId();
-
- String modifierKeys = "";
- if (event.isCtrlKey()) {
- modifierKeys += "CTRL ";
- }
- if (event.isAltKey()) {
- modifierKeys += "ALT ";
- }
- if (event.isMetaKey()) {
- modifierKeys += "META ";
- }
- if (event.isShiftKey()) {
- modifierKeys += "SHIFT ";
- }
- log(modifierKeys + type + " on " + target);
- }
-}
+package com.vaadin.tests.components.select;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.event.Action;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ItemClickEvent.ItemClickNotifier;
+import com.vaadin.terminal.Resource;
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.ui.AbstractSelect;
+
+public abstract class AbstractSelectTestCase<T extends AbstractSelect> extends
+ AbstractFieldTest<T> implements ItemClickListener {
+
+ public static final String CATEGORY_DATA_SOURCE = "Data source";
+
+ private int items = 0;
+ private int properties = 0;
+
+ protected static class ContextMenu {
+
+ private List<Action> items = new ArrayList<Action>();
+
+ public ContextMenu(String caption, Resource icon) {
+ addItem(caption, icon);
+ }
+
+ public ContextMenu() {
+ }
+
+ public void addItem(String caption, Resource icon) {
+ items.add(new Action(caption, icon));
+ }
+
+ public Action[] getActions(Object target, Object sender) {
+ Action[] actions = new Action[items.size()];
+ for (int i = 0; i < items.size(); i++) {
+ actions[i] = items.get(i);
+ }
+
+ return actions;
+ }
+
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createNullSelectAllowedCheckbox(CATEGORY_SELECTION);
+ createMultiSelectCheckbox(CATEGORY_SELECTION);
+
+ createPropertiesInContainerSelect(CATEGORY_DATA_SOURCE);
+ createItemsInContainerSelect(CATEGORY_DATA_SOURCE);
+
+ }
+
+ protected void createNullSelectAllowedCheckbox(String category) {
+ createBooleanAction("Null Selection Allowed", category, false,
+ nullSelectionAllowedCommand);
+
+ }
+
+ protected void createMultiSelectCheckbox(String category) {
+ createBooleanAction("Multi select", category, false, multiselectCommand);
+
+ }
+
+ protected void createNullSelectItemId(String category) {
+ LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
+ options.put("- None -", null);
+ for (Object id : (getComponent()).getContainerDataSource()
+ .getContainerPropertyIds()) {
+ options.put(id.toString(), id);
+ }
+ createSelectAction("Null Selection Item Id", category, options,
+ "- None -", nullSelectItemIdCommand);
+ }
+
+ protected Container createContainer(int properties, int items) {
+ return createIndexedContainer(properties, items);
+ }
+
+ private Container createIndexedContainer(int properties, int items) {
+ IndexedContainer c = new IndexedContainer();
+ populateContainer(c, properties, items);
+
+ return c;
+ }
+
+ protected void populateContainer(Container c, int properties, int items) {
+ c.removeAllItems();
+ for (int i = 1; i <= properties; i++) {
+ c.addContainerProperty("Property " + i, String.class, "");
+ }
+ for (int i = 1; i <= items; i++) {
+ Item item = c.addItem("Item " + i);
+ for (int j = 1; j <= properties; j++) {
+ item.getItemProperty("Property " + j).setValue(
+ "Item " + i + "," + j);
+ }
+ }
+
+ }
+
+ protected void createItemsInContainerSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ for (int i = 0; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("20", 20);
+ options.put("100", 100);
+ options.put("1000", 1000);
+ options.put("10000", 10000);
+ options.put("100000", 100000);
+
+ createSelectAction("Items in container", category, options, "20",
+ itemsInContainerCommand);
+ }
+
+ protected void createPropertiesInContainerSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ for (int i = 0; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("50", 50);
+ options.put("100", 100);
+ options.put("1000", 1000);
+
+ createSelectAction("Properties in container", category, options, "10",
+ propertiesInContainerCommand);
+ }
+
+ protected void createItemClickListener(String category) {
+ createBooleanAction("Item click listener", category, false,
+ itemClickListenerCommand);
+ }
+
+ /* COMMANDS */
+
+ protected Command<T, Boolean> nullSelectionAllowedCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ (c).setNullSelectionAllowed(value);
+ }
+ };
+
+ protected Command<T, Boolean> multiselectCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setMultiSelect(value);
+ }
+ };
+
+ protected Command<T, Object> nullSelectItemIdCommand = new Command<T, Object>() {
+
+ public void execute(T c, Object value, Object data) {
+ c.setNullSelectionItemId(value);
+ }
+ };
+
+ protected Command<T, Integer> itemsInContainerCommand = new Command<T, Integer>() {
+
+ public void execute(T t, Integer value, Object data) {
+ items = value;
+ updateContainer();
+ }
+ };
+
+ protected Command<T, Integer> propertiesInContainerCommand = new Command<T, Integer>() {
+
+ public void execute(T t, Integer value, Object data) {
+ properties = value;
+ updateContainer();
+ }
+ };
+
+ protected Command<T, Boolean> itemClickListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ ((ItemClickNotifier) c)
+ .addListener(AbstractSelectTestCase.this);
+ } else {
+ ((ItemClickNotifier) c)
+ .removeListener(AbstractSelectTestCase.this);
+ }
+
+ }
+ };
+
+ protected void setContainer(Container newContainer) {
+ getComponent().setContainerDataSource(newContainer);
+
+ }
+
+ protected void updateContainer() {
+ setContainer(createContainer(properties, items));
+ }
+
+ /* COMMANDS END */
+
+ public void itemClick(ItemClickEvent event) {
+ String type = event.getButtonName();
+ if (event.isDoubleClick()) {
+ type += " double-click";
+ } else {
+ type += " click";
+ }
+
+ String target = "source: " + event.getSource();
+ target += ", client: [" + event.getClientX() + "," + event.getClientY()
+ + "];";
+ target += ", relative: [" + event.getRelativeX() + ","
+ + event.getRelativeY() + "]";
+ target += ", itemId: " + event.getItemId();
+ target += ", propertyId: " + event.getPropertyId();
+
+ String modifierKeys = "";
+ if (event.isCtrlKey()) {
+ modifierKeys += "CTRL ";
+ }
+ if (event.isAltKey()) {
+ modifierKeys += "ALT ";
+ }
+ if (event.isMetaKey()) {
+ modifierKeys += "META ";
+ }
+ if (event.isShiftKey()) {
+ modifierKeys += "SHIFT ";
+ }
+ log(modifierKeys + type + " on " + target);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/MultiSelect.java b/tests/testbench/com/vaadin/tests/components/select/MultiSelect.java
index b3c15251a1..d823d1fd10 100644
--- a/tests/testbench/com/vaadin/tests/components/select/MultiSelect.java
+++ b/tests/testbench/com/vaadin/tests/components/select/MultiSelect.java
@@ -1,32 +1,32 @@
-package com.vaadin.tests.components.select;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Select;
-
-public class MultiSelect extends TestBase {
-
- @SuppressWarnings("deprecation")
- @Override
- protected void setup() {
- Select selectComponent = new Select();
- selectComponent.setMultiSelect(true);
-
- String[] selection = { "One", "Hund", "Three" };
- for (String word : selection) {
- selectComponent.addItem(word);
- }
-
- addComponent(selectComponent);
- }
-
- @Override
- protected String getDescription() {
- return "The select is in multi select mode and should be rendered as such";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4553;
- }
-
-}
+package com.vaadin.tests.components.select;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Select;
+
+public class MultiSelect extends TestBase {
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void setup() {
+ Select selectComponent = new Select();
+ selectComponent.setMultiSelect(true);
+
+ String[] selection = { "One", "Hund", "Three" };
+ for (String word : selection) {
+ selectComponent.addItem(word);
+ }
+
+ addComponent(selectComponent);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The select is in multi select mode and should be rendered as such";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4553;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/NullSelectionItemId.java b/tests/testbench/com/vaadin/tests/components/select/NullSelectionItemId.java
index 4298cfc525..74ebb08826 100644
--- a/tests/testbench/com/vaadin/tests/components/select/NullSelectionItemId.java
+++ b/tests/testbench/com/vaadin/tests/components/select/NullSelectionItemId.java
@@ -1,77 +1,77 @@
-package com.vaadin.tests.components.select;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Select;
-
-public class NullSelectionItemId extends TestBase implements ClickListener {
-
- private static final String NULL_ITEM_ID = "Null item id";
-
- private Select mySelect;
-
- @Override
- protected void setup() {
-
- mySelect = new Select("My Select");
-
- // add items
- mySelect.addItem(NULL_ITEM_ID);
- mySelect.addItem("Another item");
-
- // allow null and set the null item id
- mySelect.setNullSelectionAllowed(true);
- mySelect.setNullSelectionItemId(NULL_ITEM_ID);
-
- // select the null item
- mySelect.select(NULL_ITEM_ID);
-
- Button button = new Button("Show selected value", this);
-
- addComponent(mySelect);
- addComponent(button);
-
- button = new Button(
- "Select null with select(NULL_ITEM_ID) (should make value null)",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- mySelect.select(NULL_ITEM_ID);
- }
- });
-
- addComponent(button);
-
- button = new Button(
- "Select null with setValue(null) (should make value null)",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- mySelect.setValue(null);
- }
- });
-
- addComponent(button);
-
- }
-
- public void buttonClick(ClickEvent event) {
- getMainWindow().showNotification(
- "mySelect.getValue() returns: " + mySelect.getValue());
- }
-
- @Override
- protected String getDescription() {
- return "Steps to reproduce:<br />"
- + "<ol><li>Click the button -> value is the item id \"Null item id\" (should be null).</li>"
- + "<li>Select the \"Another item\".</li>"
- + "<li>Select back the first item.</li>"
- + "<li>Click the button -> the value is null (as it should)</li></ol>";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3203;
- }
-
-}
+package com.vaadin.tests.components.select;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Select;
+
+public class NullSelectionItemId extends TestBase implements ClickListener {
+
+ private static final String NULL_ITEM_ID = "Null item id";
+
+ private Select mySelect;
+
+ @Override
+ protected void setup() {
+
+ mySelect = new Select("My Select");
+
+ // add items
+ mySelect.addItem(NULL_ITEM_ID);
+ mySelect.addItem("Another item");
+
+ // allow null and set the null item id
+ mySelect.setNullSelectionAllowed(true);
+ mySelect.setNullSelectionItemId(NULL_ITEM_ID);
+
+ // select the null item
+ mySelect.select(NULL_ITEM_ID);
+
+ Button button = new Button("Show selected value", this);
+
+ addComponent(mySelect);
+ addComponent(button);
+
+ button = new Button(
+ "Select null with select(NULL_ITEM_ID) (should make value null)",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ mySelect.select(NULL_ITEM_ID);
+ }
+ });
+
+ addComponent(button);
+
+ button = new Button(
+ "Select null with setValue(null) (should make value null)",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ mySelect.setValue(null);
+ }
+ });
+
+ addComponent(button);
+
+ }
+
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().showNotification(
+ "mySelect.getValue() returns: " + mySelect.getValue());
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Steps to reproduce:<br />"
+ + "<ol><li>Click the button -> value is the item id \"Null item id\" (should be null).</li>"
+ + "<li>Select the \"Another item\".</li>"
+ + "<li>Select back the first item.</li>"
+ + "<li>Click the button -> the value is null (as it should)</li></ol>";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3203;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java b/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java
index 56953e298c..743dc071c9 100644
--- a/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java
+++ b/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java
@@ -1,163 +1,163 @@
-package com.vaadin.tests.components.select;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Select;
-
-public class SelectDisplaysOldValue extends TestBase {
-
- @Override
- protected void setup() {
- addComponent(new DynamicSelectTestCase());
- }
-
- public class DynamicSelectTestCase extends HorizontalLayout {
-
- private static final String CONTROLLER_COMBO_BOX_CAPTION = "Master : ";
- private static final String SLAVE_COMBO_BOX_CAPTION = "Slave :";
-
- private Select controllerComboBox;
- private Select slaveComboBox;
-
- private Map<Integer, String> controllerOptionMap = new HashMap<Integer, String>();
-
- private Map<String, List<String>> slaveOptionMapping = new HashMap<String, List<String>>();
- private final Object NAME_PROPERTY_ID = "name";
-
- public DynamicSelectTestCase() {
- populateControllerOptionMapping();
- populateSlaveOptionMappings();
- buildDynamicSelectTestCase();
- }
-
- private void populateControllerOptionMapping() {
- for (int i = 1; i <= 3; i++) {
- controllerOptionMap.put(i, "Master " + i);
- }
- }
-
- private void populateSlaveOptionMappings() {
- for (String controllerOption : controllerOptionMap.values()) {
- List<String> slaveOptions = new ArrayList<String>();
-
- for (int i = 1; i <= 3; i++) {
- slaveOptions.add(controllerOption + " - Slave " + i);
- }
-
- slaveOptionMapping.put(controllerOption, slaveOptions);
- }
- }
-
- private void buildDynamicSelectTestCase() {
- setSpacing(true);
- setMargin(true);
- buildAndConfigureComboBoxes();
- addComponent(controllerComboBox);
- addComponent(slaveComboBox);
- }
-
- private void buildAndConfigureComboBoxes() {
- IndexedContainer masterOptionContainer = initMasterOptionContainer();
- controllerComboBox = new Select(CONTROLLER_COMBO_BOX_CAPTION,
- masterOptionContainer);
- configureMasterOptionDropdown();
- controllerComboBox.addListener(new ControllerUpdatedListener());
-
- buildSlaveDropdown(1);
- }
-
- private void buildSlaveDropdown(Integer masterId) {
- IndexedContainer slaveOptionContainer = initSlaveOptionContainer(masterId);
- slaveComboBox = new Select(SLAVE_COMBO_BOX_CAPTION,
- slaveOptionContainer);
- configureSlaveOptionDropdown();
- }
-
- private IndexedContainer initMasterOptionContainer() {
- IndexedContainer containerToReturn = new IndexedContainer();
- Object defaultValue = null;
- Item itemAdded;
-
- containerToReturn.addContainerProperty(NAME_PROPERTY_ID,
- String.class, defaultValue);
-
- for (Integer optionId : controllerOptionMap.keySet()) {
- itemAdded = containerToReturn.addItem(optionId);
- itemAdded.getItemProperty(NAME_PROPERTY_ID).setValue(
- controllerOptionMap.get(optionId));
- }
-
- return containerToReturn;
- }
-
- private IndexedContainer initSlaveOptionContainer(Integer masterId) {
- IndexedContainer containerToReturn = new IndexedContainer();
- Object defaultValue = null;
- Item itemAdded;
- List<String> options;
-
- options = slaveOptionMapping.get(controllerOptionMap.get(masterId));
- containerToReturn.addContainerProperty(NAME_PROPERTY_ID,
- String.class, defaultValue);
-
- for (String option : options) {
- itemAdded = containerToReturn.addItem(option);
- itemAdded.getItemProperty(NAME_PROPERTY_ID).setValue(option);
- }
-
- return containerToReturn;
- }
-
- private void configureMasterOptionDropdown() {
- controllerComboBox.setItemCaptionPropertyId(NAME_PROPERTY_ID);
- controllerComboBox.setNullSelectionAllowed(false);
- controllerComboBox.setNewItemsAllowed(false);
- controllerComboBox.setImmediate(true);
- controllerComboBox.setWriteThrough(false);
- controllerComboBox.setReadThrough(false);
-
- }
-
- private void configureSlaveOptionDropdown() {
- slaveComboBox.setItemCaptionPropertyId(NAME_PROPERTY_ID);
- slaveComboBox.setNullSelectionAllowed(false);
- slaveComboBox.setNewItemsAllowed(false);
- slaveComboBox.setImmediate(true);
- slaveComboBox.setWriteThrough(false);
- slaveComboBox.setReadThrough(false);
- }
-
- private void refreshSlaveDropdown(Integer masterId) {
- slaveComboBox
- .setContainerDataSource(initSlaveOptionContainer(masterId));
- System.out.println("Slave value: " + slaveComboBox.getValue());
- }
-
- private class ControllerUpdatedListener implements
- Property.ValueChangeListener {
- public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
- refreshSlaveDropdown((Integer) valueChangeEvent.getProperty()
- .getValue());
- }
- }
- }
-
- @Override
- protected String getDescription() {
- return "Select an 'master' item from the first combo box, a slave from the second, select another master and focus+blur the slave combo box and the slave combobox will show a value not in the combo box";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5556;
- }
-
-}
+package com.vaadin.tests.components.select;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Select;
+
+public class SelectDisplaysOldValue extends TestBase {
+
+ @Override
+ protected void setup() {
+ addComponent(new DynamicSelectTestCase());
+ }
+
+ public class DynamicSelectTestCase extends HorizontalLayout {
+
+ private static final String CONTROLLER_COMBO_BOX_CAPTION = "Master : ";
+ private static final String SLAVE_COMBO_BOX_CAPTION = "Slave :";
+
+ private Select controllerComboBox;
+ private Select slaveComboBox;
+
+ private Map<Integer, String> controllerOptionMap = new HashMap<Integer, String>();
+
+ private Map<String, List<String>> slaveOptionMapping = new HashMap<String, List<String>>();
+ private final Object NAME_PROPERTY_ID = "name";
+
+ public DynamicSelectTestCase() {
+ populateControllerOptionMapping();
+ populateSlaveOptionMappings();
+ buildDynamicSelectTestCase();
+ }
+
+ private void populateControllerOptionMapping() {
+ for (int i = 1; i <= 3; i++) {
+ controllerOptionMap.put(i, "Master " + i);
+ }
+ }
+
+ private void populateSlaveOptionMappings() {
+ for (String controllerOption : controllerOptionMap.values()) {
+ List<String> slaveOptions = new ArrayList<String>();
+
+ for (int i = 1; i <= 3; i++) {
+ slaveOptions.add(controllerOption + " - Slave " + i);
+ }
+
+ slaveOptionMapping.put(controllerOption, slaveOptions);
+ }
+ }
+
+ private void buildDynamicSelectTestCase() {
+ setSpacing(true);
+ setMargin(true);
+ buildAndConfigureComboBoxes();
+ addComponent(controllerComboBox);
+ addComponent(slaveComboBox);
+ }
+
+ private void buildAndConfigureComboBoxes() {
+ IndexedContainer masterOptionContainer = initMasterOptionContainer();
+ controllerComboBox = new Select(CONTROLLER_COMBO_BOX_CAPTION,
+ masterOptionContainer);
+ configureMasterOptionDropdown();
+ controllerComboBox.addListener(new ControllerUpdatedListener());
+
+ buildSlaveDropdown(1);
+ }
+
+ private void buildSlaveDropdown(Integer masterId) {
+ IndexedContainer slaveOptionContainer = initSlaveOptionContainer(masterId);
+ slaveComboBox = new Select(SLAVE_COMBO_BOX_CAPTION,
+ slaveOptionContainer);
+ configureSlaveOptionDropdown();
+ }
+
+ private IndexedContainer initMasterOptionContainer() {
+ IndexedContainer containerToReturn = new IndexedContainer();
+ Object defaultValue = null;
+ Item itemAdded;
+
+ containerToReturn.addContainerProperty(NAME_PROPERTY_ID,
+ String.class, defaultValue);
+
+ for (Integer optionId : controllerOptionMap.keySet()) {
+ itemAdded = containerToReturn.addItem(optionId);
+ itemAdded.getItemProperty(NAME_PROPERTY_ID).setValue(
+ controllerOptionMap.get(optionId));
+ }
+
+ return containerToReturn;
+ }
+
+ private IndexedContainer initSlaveOptionContainer(Integer masterId) {
+ IndexedContainer containerToReturn = new IndexedContainer();
+ Object defaultValue = null;
+ Item itemAdded;
+ List<String> options;
+
+ options = slaveOptionMapping.get(controllerOptionMap.get(masterId));
+ containerToReturn.addContainerProperty(NAME_PROPERTY_ID,
+ String.class, defaultValue);
+
+ for (String option : options) {
+ itemAdded = containerToReturn.addItem(option);
+ itemAdded.getItemProperty(NAME_PROPERTY_ID).setValue(option);
+ }
+
+ return containerToReturn;
+ }
+
+ private void configureMasterOptionDropdown() {
+ controllerComboBox.setItemCaptionPropertyId(NAME_PROPERTY_ID);
+ controllerComboBox.setNullSelectionAllowed(false);
+ controllerComboBox.setNewItemsAllowed(false);
+ controllerComboBox.setImmediate(true);
+ controllerComboBox.setWriteThrough(false);
+ controllerComboBox.setReadThrough(false);
+
+ }
+
+ private void configureSlaveOptionDropdown() {
+ slaveComboBox.setItemCaptionPropertyId(NAME_PROPERTY_ID);
+ slaveComboBox.setNullSelectionAllowed(false);
+ slaveComboBox.setNewItemsAllowed(false);
+ slaveComboBox.setImmediate(true);
+ slaveComboBox.setWriteThrough(false);
+ slaveComboBox.setReadThrough(false);
+ }
+
+ private void refreshSlaveDropdown(Integer masterId) {
+ slaveComboBox
+ .setContainerDataSource(initSlaveOptionContainer(masterId));
+ System.out.println("Slave value: " + slaveComboBox.getValue());
+ }
+
+ private class ControllerUpdatedListener implements
+ Property.ValueChangeListener {
+ public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
+ refreshSlaveDropdown((Integer) valueChangeEvent.getProperty()
+ .getValue());
+ }
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Select an 'master' item from the first combo box, a slave from the second, select another master and focus+blur the slave combo box and the slave combobox will show a value not in the combo box";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5556;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/SelectTest.java b/tests/testbench/com/vaadin/tests/components/select/SelectTest.java
index cdc30921fa..efea508681 100644
--- a/tests/testbench/com/vaadin/tests/components/select/SelectTest.java
+++ b/tests/testbench/com/vaadin/tests/components/select/SelectTest.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.components.select;
-
-import com.vaadin.ui.Select;
-
-public class SelectTest<T extends Select> extends AbstractSelectTestCase<T> {
-
- @SuppressWarnings("unchecked")
- @Override
- protected Class<T> getTestClass() {
- return (Class<T>) Select.class;
- }
-
-}
+package com.vaadin.tests.components.select;
+
+import com.vaadin.ui.Select;
+
+public class SelectTest<T extends Select> extends AbstractSelectTestCase<T> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Class<T> getTestClass() {
+ return (Class<T>) Select.class;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java b/tests/testbench/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java
index f3d147e32a..cf33e2c7ff 100644
--- a/tests/testbench/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java
+++ b/tests/testbench/com/vaadin/tests/components/select/TwinColSelectCaptionStyles.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.select;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.TwinColSelect;
-
-public class TwinColSelectCaptionStyles extends TestBase {
-
- @Override
- protected void setup() {
- setTheme("tests-tickets");
- final TwinColSelect sel = new TwinColSelect("Component caption");
- sel.setLeftColumnCaption("Left caption");
- sel.setRightColumnCaption("Right caption");
- sel.setStyleName("styled-twincol-captions");
- sel.setWidth("300px");
- addComponent(sel);
-
- Button b = new Button("Set height and width to 500px",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- sel.setHeight("500px");
- sel.setWidth("500px");
-
- }
- });
- addComponent(b);
- }
-
- @Override
- protected String getDescription() {
- return "Tests that caption styling for TwinColSelect captions work properly. The left caption should be red and the right caption blue and larger than the left one.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
+package com.vaadin.tests.components.select;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.TwinColSelect;
+
+public class TwinColSelectCaptionStyles extends TestBase {
+
+ @Override
+ protected void setup() {
+ setTheme("tests-tickets");
+ final TwinColSelect sel = new TwinColSelect("Component caption");
+ sel.setLeftColumnCaption("Left caption");
+ sel.setRightColumnCaption("Right caption");
+ sel.setStyleName("styled-twincol-captions");
+ sel.setWidth("300px");
+ addComponent(sel);
+
+ Button b = new Button("Set height and width to 500px",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ sel.setHeight("500px");
+ sel.setWidth("500px");
+
+ }
+ });
+ addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests that caption styling for TwinColSelect captions work properly. The left caption should be red and the right caption blue and larger than the left one.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/TwinColSelectTest.java b/tests/testbench/com/vaadin/tests/components/select/TwinColSelectTest.java
index 2fb9ed2079..fef9c4172d 100644
--- a/tests/testbench/com/vaadin/tests/components/select/TwinColSelectTest.java
+++ b/tests/testbench/com/vaadin/tests/components/select/TwinColSelectTest.java
@@ -1,65 +1,65 @@
-package com.vaadin.tests.components.select;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.ui.TwinColSelect;
-
-public class TwinColSelectTest extends AbstractSelectTestCase<TwinColSelect> {
-
- private Command<TwinColSelect, Integer> rowsCommand = new Command<TwinColSelect, Integer>() {
- public void execute(TwinColSelect c, Integer value, Object data) {
- c.setRows(value);
- }
- };
-
- private Command<TwinColSelect, Integer> colsCommand = new Command<TwinColSelect, Integer>() {
- public void execute(TwinColSelect c, Integer value, Object data) {
- c.setColumns(value);
- }
- };
-
- private Command<TwinColSelect, String> leftColumnCaptionCommand = new Command<TwinColSelect, String>() {
-
- public void execute(TwinColSelect c, String value, Object data) {
- c.setLeftColumnCaption(value);
- }
- };
-
- private Command<TwinColSelect, String> rightColumnCaptionCommand = new Command<TwinColSelect, String>() {
-
- public void execute(TwinColSelect c, String value, Object data) {
- c.setRightColumnCaption(value);
- }
- };
-
-
- @Override
- protected Class<TwinColSelect> getTestClass() {
- return TwinColSelect.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createRowsAction(CATEGORY_FEATURES);
- createColsAction(CATEGORY_FEATURES);
- createCaptionActions(CATEGORY_FEATURES);
- }
-
- private void createRowsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Rows", category, options, "0", rowsCommand);
- }
-
- private void createColsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Columns", category, options, "0", colsCommand);
- }
-
- private void createCaptionActions(String category) {
- createSelectAction("Left column caption", category,
- createCaptionOptions(), "-", leftColumnCaptionCommand);
- createSelectAction("Right column caption", category,
- createCaptionOptions(), "-", rightColumnCaptionCommand);
- }
-}
+package com.vaadin.tests.components.select;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.ui.TwinColSelect;
+
+public class TwinColSelectTest extends AbstractSelectTestCase<TwinColSelect> {
+
+ private Command<TwinColSelect, Integer> rowsCommand = new Command<TwinColSelect, Integer>() {
+ public void execute(TwinColSelect c, Integer value, Object data) {
+ c.setRows(value);
+ }
+ };
+
+ private Command<TwinColSelect, Integer> colsCommand = new Command<TwinColSelect, Integer>() {
+ public void execute(TwinColSelect c, Integer value, Object data) {
+ c.setColumns(value);
+ }
+ };
+
+ private Command<TwinColSelect, String> leftColumnCaptionCommand = new Command<TwinColSelect, String>() {
+
+ public void execute(TwinColSelect c, String value, Object data) {
+ c.setLeftColumnCaption(value);
+ }
+ };
+
+ private Command<TwinColSelect, String> rightColumnCaptionCommand = new Command<TwinColSelect, String>() {
+
+ public void execute(TwinColSelect c, String value, Object data) {
+ c.setRightColumnCaption(value);
+ }
+ };
+
+
+ @Override
+ protected Class<TwinColSelect> getTestClass() {
+ return TwinColSelect.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createRowsAction(CATEGORY_FEATURES);
+ createColsAction(CATEGORY_FEATURES);
+ createCaptionActions(CATEGORY_FEATURES);
+ }
+
+ private void createRowsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Rows", category, options, "0", rowsCommand);
+ }
+
+ private void createColsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Columns", category, options, "0", colsCommand);
+ }
+
+ private void createCaptionActions(String category) {
+ createSelectAction("Left column caption", category,
+ createCaptionOptions(), "-", leftColumnCaptionCommand);
+ createSelectAction("Right column caption", category,
+ createCaptionOptions(), "-", rightColumnCaptionCommand);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/select/TwinColSelects.java b/tests/testbench/com/vaadin/tests/components/select/TwinColSelects.java
index cf59eaa03b..64b3d37c0d 100644
--- a/tests/testbench/com/vaadin/tests/components/select/TwinColSelects.java
+++ b/tests/testbench/com/vaadin/tests/components/select/TwinColSelects.java
@@ -1,48 +1,48 @@
-package com.vaadin.tests.components.select;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.TwinColSelect;
-
-public class TwinColSelects extends ComponentTestCase<TwinColSelect> {
-
- @Override
- protected Class<TwinColSelect> getTestClass() {
- return TwinColSelect.class;
- }
-
- @Override
- protected void initializeComponents() {
-
- TwinColSelect tws = createTwinColSelect("400x<auto>");
- tws.setWidth("400px");
- tws.setHeight("-1px");
- addTestComponent(tws);
-
- tws = createTwinColSelect("400x100");
- tws.setWidth("400px");
- tws.setHeight("100px");
- addTestComponent(tws);
-
- tws = createTwinColSelect("<auto>x100");
- tws.setWidth("-1px");
- tws.setHeight("100px");
- addTestComponent(tws);
-
- tws = createTwinColSelect("<auto>x<auto>");
- tws.setSizeUndefined();
- addTestComponent(tws);
-
- }
-
- private TwinColSelect createTwinColSelect(String caption) {
- TwinColSelect select = new TwinColSelect(caption);
- select.addContainerProperty(CAPTION, String.class, null);
- for (int i = 0; i < 20; i++) {
- select.addItem("" + i).getItemProperty(CAPTION)
- .setValue("Item " + i);
- }
- select.setImmediate(true);
- return select;
- }
-
-}
+package com.vaadin.tests.components.select;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.TwinColSelect;
+
+public class TwinColSelects extends ComponentTestCase<TwinColSelect> {
+
+ @Override
+ protected Class<TwinColSelect> getTestClass() {
+ return TwinColSelect.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+
+ TwinColSelect tws = createTwinColSelect("400x<auto>");
+ tws.setWidth("400px");
+ tws.setHeight("-1px");
+ addTestComponent(tws);
+
+ tws = createTwinColSelect("400x100");
+ tws.setWidth("400px");
+ tws.setHeight("100px");
+ addTestComponent(tws);
+
+ tws = createTwinColSelect("<auto>x100");
+ tws.setWidth("-1px");
+ tws.setHeight("100px");
+ addTestComponent(tws);
+
+ tws = createTwinColSelect("<auto>x<auto>");
+ tws.setSizeUndefined();
+ addTestComponent(tws);
+
+ }
+
+ private TwinColSelect createTwinColSelect(String caption) {
+ TwinColSelect select = new TwinColSelect(caption);
+ select.addContainerProperty(CAPTION, String.class, null);
+ for (int i = 0; i < 20; i++) {
+ select.addItem("" + i).getItemProperty(CAPTION)
+ .setValue("Item " + i);
+ }
+ select.setImmediate(true);
+ return select;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java b/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java
index 65a2fdd1b5..e34a294740 100644
--- a/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java
+++ b/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java
@@ -1,74 +1,74 @@
-package com.vaadin.tests.components.slider;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.ui.Slider;
-
-public class SliderTest extends AbstractFieldTest<Slider> {
-
- private Command<Slider, Double> minCommand = new Command<Slider, Double>() {
- public void execute(Slider c, Double value, Object data) {
- c.setMin(value);
- }
- };
-
- private Command<Slider, Double> maxCommand = new Command<Slider, Double>() {
- public void execute(Slider c, Double value, Object data) {
- c.setMax(value);
- }
- };
-
- private Command<Slider, Integer> orientationCommand = new Command<Slider, Integer>() {
- public void execute(Slider c, Integer value, Object data) {
- c.setOrientation(value);
- }
- };
- private Command<Slider, Integer> resolutionCommand = new Command<Slider, Integer>() {
- public void execute(Slider c, Integer value, Object data) {
- c.setResolution(value);
- }
- };
-
- @Override
- protected Class<Slider> getTestClass() {
- return Slider.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createMinSelect(CATEGORY_FEATURES);
- createMaxSelect(CATEGORY_FEATURES);
- createResolutionSelect(CATEGORY_FEATURES);
- createOrientationSelect(CATEGORY_FEATURES);
- }
-
- private void createResolutionSelect(String category) {
- createSelectAction("Resolution", category, createIntegerOptions(10),
- "1", resolutionCommand);
-
- }
-
- private void createOrientationSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Horizontal", Slider.ORIENTATION_HORIZONTAL);
- options.put("Vertical", Slider.ORIENTATION_VERTICAL);
- createSelectAction("Orientation", category, options, "Horizontal",
- orientationCommand);
-
- }
-
- private void createMaxSelect(String category) {
- createSelectAction("Max", category, createDoubleOptions(100), "0",
- maxCommand);
- }
-
- private void createMinSelect(String category) {
- createSelectAction("Min", category, createDoubleOptions(100), "0",
- minCommand);
-
- }
-
-}
+package com.vaadin.tests.components.slider;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.ui.Slider;
+
+public class SliderTest extends AbstractFieldTest<Slider> {
+
+ private Command<Slider, Double> minCommand = new Command<Slider, Double>() {
+ public void execute(Slider c, Double value, Object data) {
+ c.setMin(value);
+ }
+ };
+
+ private Command<Slider, Double> maxCommand = new Command<Slider, Double>() {
+ public void execute(Slider c, Double value, Object data) {
+ c.setMax(value);
+ }
+ };
+
+ private Command<Slider, Integer> orientationCommand = new Command<Slider, Integer>() {
+ public void execute(Slider c, Integer value, Object data) {
+ c.setOrientation(value);
+ }
+ };
+ private Command<Slider, Integer> resolutionCommand = new Command<Slider, Integer>() {
+ public void execute(Slider c, Integer value, Object data) {
+ c.setResolution(value);
+ }
+ };
+
+ @Override
+ protected Class<Slider> getTestClass() {
+ return Slider.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createMinSelect(CATEGORY_FEATURES);
+ createMaxSelect(CATEGORY_FEATURES);
+ createResolutionSelect(CATEGORY_FEATURES);
+ createOrientationSelect(CATEGORY_FEATURES);
+ }
+
+ private void createResolutionSelect(String category) {
+ createSelectAction("Resolution", category, createIntegerOptions(10),
+ "1", resolutionCommand);
+
+ }
+
+ private void createOrientationSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Horizontal", Slider.ORIENTATION_HORIZONTAL);
+ options.put("Vertical", Slider.ORIENTATION_VERTICAL);
+ createSelectAction("Orientation", category, options, "Horizontal",
+ orientationCommand);
+
+ }
+
+ private void createMaxSelect(String category) {
+ createSelectAction("Max", category, createDoubleOptions(100), "0",
+ maxCommand);
+ }
+
+ private void createMinSelect(String category) {
+ createSelectAction("Min", category, createDoubleOptions(100), "0",
+ minCommand);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java b/tests/testbench/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
index 0b702db33a..d633618ef4 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
@@ -1,127 +1,127 @@
-package com.vaadin.tests.components.splitpanel;
-
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.tests.components.AbstractLayoutTest;
-import com.vaadin.ui.AbstractSplitPanel;
-import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent;
-import com.vaadin.ui.AbstractSplitPanel.SplitterClickListener;
-
-public abstract class AbstractSplitPanelTest<T extends AbstractSplitPanel>
- extends AbstractLayoutTest<T> implements SplitterClickListener {
-
- private Command<T, Boolean> splitterClickListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((SplitterClickListener) AbstractSplitPanelTest.this);
- } else {
- c.removeListener((SplitterClickListener) AbstractSplitPanelTest.this);
- }
-
- }
- };
- private Command<T, SplitPosition> setSplitPositionCommand = new Command<T, AbstractSplitPanelTest.SplitPosition>() {
- public void execute(T c, SplitPosition value, Object data) {
- value.apply(c);
- }
- };
- private Command<T, Boolean> splitterLockCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setLocked(value);
- }
- };
-
- @Override
- protected void createActions() {
- super.createActions();
- createSetSplitPositionAction(CATEGORY_FEATURES);
- createSplitterClickListenerAction(CATEGORY_LISTENERS);
- createSplitterLockAction(CATEGORY_FEATURES);
-
- // Default to 100% x 100% as SplitPanel does not work as undefined
- for (T c : getTestComponents()) {
- c.setSizeFull();
- }
- }
-
- private void createSplitterLockAction(String categoryFeatures) {
- createBooleanAction("Splitter locked", categoryFeatures, false,
- splitterLockCommand);
-
- }
-
- public static class SplitPosition {
-
- private boolean reverse = false;
- private int position;
- private int unit;
- private String posString;
-
- public SplitPosition(String pos) {
- this.posString = pos;
- if (pos.startsWith("-")) {
- reverse = true;
- pos = pos.substring(1);
- }
-
- if (pos.endsWith("px")) {
- position = Integer.parseInt(pos.substring(0, pos.length() - 2));
- unit = Sizeable.UNITS_PIXELS;
- } else if (pos.endsWith("%")) {
- position = Integer.parseInt(pos.substring(0, pos.length() - 1));
- unit = Sizeable.UNITS_PERCENTAGE;
- } else {
- throw new RuntimeException("Could not parse " + pos);
- }
- }
-
- public void apply(AbstractSplitPanel sp) {
- sp.setSplitPosition(position, unit, reverse);
- }
-
- @Override
- public String toString() {
- return posString;
- }
- }
-
- private void createSetSplitPositionAction(String categoryFeatures) {
- String subCategory = "Set splitter position";
- createCategory(subCategory, categoryFeatures);
-
- createClickAction("0px from left/top", subCategory,
- setSplitPositionCommand, new SplitPosition("0px"));
- createClickAction("200px from left/top", subCategory,
- setSplitPositionCommand, new SplitPosition("200px"));
- createClickAction("0px from right/bottom", subCategory,
- setSplitPositionCommand, new SplitPosition("-0px"));
- createClickAction("200px from right/bottom", subCategory,
- setSplitPositionCommand, new SplitPosition("-200px"));
-
- createClickAction("0% from left/top", subCategory,
- setSplitPositionCommand, new SplitPosition("0%"));
- createClickAction("0% from right/bottom", subCategory,
- setSplitPositionCommand, new SplitPosition("-0%"));
- createClickAction("50% from left/top", subCategory,
- setSplitPositionCommand, new SplitPosition("50%"));
- createClickAction("50% from right/bottom", subCategory,
- setSplitPositionCommand, new SplitPosition("-50%"));
- createClickAction("100% from left/top", subCategory,
- setSplitPositionCommand, new SplitPosition("100%"));
- createClickAction("100% from right/bottom", subCategory,
- setSplitPositionCommand, new SplitPosition("-100%"));
-
- }
-
- private void createSplitterClickListenerAction(String category) {
- createBooleanAction("SplitterClickListener", category, false,
- splitterClickListenerCommand);
-
- }
-
- public void splitterClick(SplitterClickEvent event) {
- log(event.getClass().getSimpleName() + ": " + event.getButtonName()
- + " at " + event.getRelativeX() + "," + event.getRelativeY());
- }
-}
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.AbstractLayoutTest;
+import com.vaadin.ui.AbstractSplitPanel;
+import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent;
+import com.vaadin.ui.AbstractSplitPanel.SplitterClickListener;
+
+public abstract class AbstractSplitPanelTest<T extends AbstractSplitPanel>
+ extends AbstractLayoutTest<T> implements SplitterClickListener {
+
+ private Command<T, Boolean> splitterClickListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((SplitterClickListener) AbstractSplitPanelTest.this);
+ } else {
+ c.removeListener((SplitterClickListener) AbstractSplitPanelTest.this);
+ }
+
+ }
+ };
+ private Command<T, SplitPosition> setSplitPositionCommand = new Command<T, AbstractSplitPanelTest.SplitPosition>() {
+ public void execute(T c, SplitPosition value, Object data) {
+ value.apply(c);
+ }
+ };
+ private Command<T, Boolean> splitterLockCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setLocked(value);
+ }
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createSetSplitPositionAction(CATEGORY_FEATURES);
+ createSplitterClickListenerAction(CATEGORY_LISTENERS);
+ createSplitterLockAction(CATEGORY_FEATURES);
+
+ // Default to 100% x 100% as SplitPanel does not work as undefined
+ for (T c : getTestComponents()) {
+ c.setSizeFull();
+ }
+ }
+
+ private void createSplitterLockAction(String categoryFeatures) {
+ createBooleanAction("Splitter locked", categoryFeatures, false,
+ splitterLockCommand);
+
+ }
+
+ public static class SplitPosition {
+
+ private boolean reverse = false;
+ private int position;
+ private int unit;
+ private String posString;
+
+ public SplitPosition(String pos) {
+ this.posString = pos;
+ if (pos.startsWith("-")) {
+ reverse = true;
+ pos = pos.substring(1);
+ }
+
+ if (pos.endsWith("px")) {
+ position = Integer.parseInt(pos.substring(0, pos.length() - 2));
+ unit = Sizeable.UNITS_PIXELS;
+ } else if (pos.endsWith("%")) {
+ position = Integer.parseInt(pos.substring(0, pos.length() - 1));
+ unit = Sizeable.UNITS_PERCENTAGE;
+ } else {
+ throw new RuntimeException("Could not parse " + pos);
+ }
+ }
+
+ public void apply(AbstractSplitPanel sp) {
+ sp.setSplitPosition(position, unit, reverse);
+ }
+
+ @Override
+ public String toString() {
+ return posString;
+ }
+ }
+
+ private void createSetSplitPositionAction(String categoryFeatures) {
+ String subCategory = "Set splitter position";
+ createCategory(subCategory, categoryFeatures);
+
+ createClickAction("0px from left/top", subCategory,
+ setSplitPositionCommand, new SplitPosition("0px"));
+ createClickAction("200px from left/top", subCategory,
+ setSplitPositionCommand, new SplitPosition("200px"));
+ createClickAction("0px from right/bottom", subCategory,
+ setSplitPositionCommand, new SplitPosition("-0px"));
+ createClickAction("200px from right/bottom", subCategory,
+ setSplitPositionCommand, new SplitPosition("-200px"));
+
+ createClickAction("0% from left/top", subCategory,
+ setSplitPositionCommand, new SplitPosition("0%"));
+ createClickAction("0% from right/bottom", subCategory,
+ setSplitPositionCommand, new SplitPosition("-0%"));
+ createClickAction("50% from left/top", subCategory,
+ setSplitPositionCommand, new SplitPosition("50%"));
+ createClickAction("50% from right/bottom", subCategory,
+ setSplitPositionCommand, new SplitPosition("-50%"));
+ createClickAction("100% from left/top", subCategory,
+ setSplitPositionCommand, new SplitPosition("100%"));
+ createClickAction("100% from right/bottom", subCategory,
+ setSplitPositionCommand, new SplitPosition("-100%"));
+
+ }
+
+ private void createSplitterClickListenerAction(String category) {
+ createBooleanAction("SplitterClickListener", category, false,
+ splitterClickListenerCommand);
+
+ }
+
+ public void splitterClick(SplitterClickEvent event) {
+ log(event.getClass().getSimpleName() + ": " + event.getButtonName()
+ + " at " + event.getRelativeX() + "," + event.getRelativeY());
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/HorizontalSplitPanels.java b/tests/testbench/com/vaadin/tests/components/splitpanel/HorizontalSplitPanels.java
index a92143963b..a330581f22 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/HorizontalSplitPanels.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/HorizontalSplitPanels.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.components.splitpanel;
-
-import com.vaadin.ui.HorizontalSplitPanel;
-
-public class HorizontalSplitPanels extends
- AbstractSplitPanelTest<HorizontalSplitPanel> {
-
- @Override
- protected Class<HorizontalSplitPanel> getTestClass() {
- return HorizontalSplitPanel.class;
- }
-
-}
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.ui.HorizontalSplitPanel;
+
+public class HorizontalSplitPanels extends
+ AbstractSplitPanelTest<HorizontalSplitPanel> {
+
+ @Override
+ protected Class<HorizontalSplitPanel> getTestClass() {
+ return HorizontalSplitPanel.class;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
index 872828c97e..a7cb1a857a 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
@@ -1,68 +1,68 @@
-package com.vaadin.tests.components.splitpanel;
-
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.Window;
-
-public class SplitPanelExtraScrollbars extends AbstractTestCase implements
- ClickListener {
-
- private HorizontalSplitPanel sp;
- private HorizontalLayout hl;
- private Button b;
-
- @Override
- public void init() {
- sp = new HorizontalSplitPanel();
- sp.setSizeFull();
- sp.setSplitPosition(0, Sizeable.UNITS_PIXELS);
-
- hl = new HorizontalLayout();
- hl.setMargin(true);
- hl.setWidth("100%");
- hl.setHeight(null);
-
- b = createButton("200px");
- sp.setSecondComponent(hl);
- hl.addComponent(b);
-
- Window w = new Window("Test", sp);
- setMainWindow(w);
- }
-
- private Button createButton(String height) {
- Button b = new NativeButton("A BIG button");
- b.setHeight(height);
- b.addListener(this);
- return b;
- }
-
- @Override
- protected String getDescription() {
- return "Click the button to change its height. Making the button higher than the browser should not cause vertical but not horizontal scrollbars to appear.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3458;
- }
-
- public void buttonClick(ClickEvent event) {
- if (b.getHeight() == 200) {
- b.setHeight("1200px");
- } else {
- b.setHeight("200px");
- }
-
- // Sending all changes in one repaint triggers the bug
- hl.requestRepaint();
- sp.requestRepaint();
- }
-
-}
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.Window;
+
+public class SplitPanelExtraScrollbars extends AbstractTestCase implements
+ ClickListener {
+
+ private HorizontalSplitPanel sp;
+ private HorizontalLayout hl;
+ private Button b;
+
+ @Override
+ public void init() {
+ sp = new HorizontalSplitPanel();
+ sp.setSizeFull();
+ sp.setSplitPosition(0, Sizeable.UNITS_PIXELS);
+
+ hl = new HorizontalLayout();
+ hl.setMargin(true);
+ hl.setWidth("100%");
+ hl.setHeight(null);
+
+ b = createButton("200px");
+ sp.setSecondComponent(hl);
+ hl.addComponent(b);
+
+ Window w = new Window("Test", sp);
+ setMainWindow(w);
+ }
+
+ private Button createButton(String height) {
+ Button b = new NativeButton("A BIG button");
+ b.setHeight(height);
+ b.addListener(this);
+ return b;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the button to change its height. Making the button higher than the browser should not cause vertical but not horizontal scrollbars to appear.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3458;
+ }
+
+ public void buttonClick(ClickEvent event) {
+ if (b.getHeight() == 200) {
+ b.setHeight("1200px");
+ } else {
+ b.setHeight("200px");
+ }
+
+ // Sending all changes in one repaint triggers the bug
+ hl.requestRepaint();
+ sp.requestRepaint();
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java
index 8d5256ece7..4e6a7730e7 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java
@@ -1,43 +1,43 @@
-package com.vaadin.tests.components.splitpanel;
-
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class SplitPanelWidthOnResize extends AbstractTestCase {
-
- @Override
- public void init() {
- VerticalLayout layout = new VerticalLayout();
- layout.setSizeFull();
- Window w = new Window("", layout);
- setMainWindow(w);
- HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
- Button button = new NativeButton("A huge button");
- button.setSizeFull();
- TextField textField = new TextField("A small textfield");
-
- splitPanel.setFirstComponent(button);
- splitPanel.setSecondComponent(textField);
- splitPanel.setSizeFull();
- splitPanel.setSplitPosition(100, Sizeable.UNITS_PERCENTAGE);
-
- layout.addComponent(splitPanel);
- }
-
- @Override
- protected String getDescription() {
- return "Make the browser window smaller and then larger again. The huge button should always stay visible and the TextField should never be shown.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3322;
- }
-
-}
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class SplitPanelWidthOnResize extends AbstractTestCase {
+
+ @Override
+ public void init() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setSizeFull();
+ Window w = new Window("", layout);
+ setMainWindow(w);
+ HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
+ Button button = new NativeButton("A huge button");
+ button.setSizeFull();
+ TextField textField = new TextField("A small textfield");
+
+ splitPanel.setFirstComponent(button);
+ splitPanel.setSecondComponent(textField);
+ splitPanel.setSizeFull();
+ splitPanel.setSplitPosition(100, Sizeable.UNITS_PERCENTAGE);
+
+ layout.addComponent(splitPanel);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Make the browser window smaller and then larger again. The huge button should always stay visible and the TextField should never be shown.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3322;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanels.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanels.java
index ebe94271cc..e0a4c19836 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanels.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanels.java
@@ -1,37 +1,37 @@
-package com.vaadin.tests.components.splitpanel;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.ui.SplitPanel;
-
-@SuppressWarnings("deprecation")
-public class SplitPanels extends AbstractSplitPanelTest<SplitPanel> {
-
- private Command<SplitPanel, Integer> orientationCommand = new Command<SplitPanel, Integer>() {
-
- public void execute(SplitPanel c, Integer value, Object data) {
- c.setOrientation(value);
- }
- };
-
- @Override
- protected Class<SplitPanel> getTestClass() {
- return SplitPanel.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createOrientationSelect(CATEGORY_FEATURES);
-
- }
-
- private void createOrientationSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Horizontal", SplitPanel.ORIENTATION_HORIZONTAL);
- options.put("Vertical", SplitPanel.ORIENTATION_VERTICAL);
- createSelectAction("Orientation", category, options, "Horizontal",
- orientationCommand);
-
- }
-}
+package com.vaadin.tests.components.splitpanel;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.ui.SplitPanel;
+
+@SuppressWarnings("deprecation")
+public class SplitPanels extends AbstractSplitPanelTest<SplitPanel> {
+
+ private Command<SplitPanel, Integer> orientationCommand = new Command<SplitPanel, Integer>() {
+
+ public void execute(SplitPanel c, Integer value, Object data) {
+ c.setOrientation(value);
+ }
+ };
+
+ @Override
+ protected Class<SplitPanel> getTestClass() {
+ return SplitPanel.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createOrientationSelect(CATEGORY_FEATURES);
+
+ }
+
+ private void createOrientationSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Horizontal", SplitPanel.ORIENTATION_HORIZONTAL);
+ options.put("Vertical", SplitPanel.ORIENTATION_VERTICAL);
+ createSelectAction("Orientation", category, options, "Horizontal",
+ orientationCommand);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/VerticalSplitPanels.java b/tests/testbench/com/vaadin/tests/components/splitpanel/VerticalSplitPanels.java
index 4ff0445d71..219a72c196 100644
--- a/tests/testbench/com/vaadin/tests/components/splitpanel/VerticalSplitPanels.java
+++ b/tests/testbench/com/vaadin/tests/components/splitpanel/VerticalSplitPanels.java
@@ -1,13 +1,13 @@
-package com.vaadin.tests.components.splitpanel;
-
-import com.vaadin.ui.VerticalSplitPanel;
-
-public class VerticalSplitPanels extends
- AbstractSplitPanelTest<VerticalSplitPanel> {
-
- @Override
- protected Class<VerticalSplitPanel> getTestClass() {
- return VerticalSplitPanel.class;
- }
-
-}
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.ui.VerticalSplitPanel;
+
+public class VerticalSplitPanels extends
+ AbstractSplitPanelTest<VerticalSplitPanel> {
+
+ @Override
+ protected Class<VerticalSplitPanel> getTestClass() {
+ return VerticalSplitPanel.class;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/ClippedComponentsInTable.java b/tests/testbench/com/vaadin/tests/components/table/ClippedComponentsInTable.java
index 8b6775cc74..6b8532a9ad 100644
--- a/tests/testbench/com/vaadin/tests/components/table/ClippedComponentsInTable.java
+++ b/tests/testbench/com/vaadin/tests/components/table/ClippedComponentsInTable.java
@@ -1,40 +1,40 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-
-public class ClippedComponentsInTable extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The table below should display 3 rows. Each with a textfield containing the row number.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- @Override
- protected void setup() {
- Table t = new Table();
- addComponent(t);
-
- t.addContainerProperty("Name", TextField.class, null);
- t.addContainerProperty("Button", Button.class, null);
-
- for (int i = 0; i < 3; i++) {
- Item item = t.addItem(i);
- TextField tf = new TextField("", String.valueOf(i + 1));
- tf.setColumns(10);
- item.getItemProperty("Name").setValue(tf);
-
- Button b = new Button("OK");
- item.getItemProperty("Button").setValue(b);
- }
-
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+
+public class ClippedComponentsInTable extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The table below should display 3 rows. Each with a textfield containing the row number.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+ @Override
+ protected void setup() {
+ Table t = new Table();
+ addComponent(t);
+
+ t.addContainerProperty("Name", TextField.class, null);
+ t.addContainerProperty("Button", Button.class, null);
+
+ for (int i = 0; i < 3; i++) {
+ Item item = t.addItem(i);
+ TextField tf = new TextField("", String.valueOf(i + 1));
+ tf.setColumns(10);
+ item.getItemProperty("Name").setValue(tf);
+
+ Button b = new Button("OK");
+ item.getItemProperty("Button").setValue(b);
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java b/tests/testbench/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java
index 9bf77f42bd..95e94bcd47 100644
--- a/tests/testbench/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java
+++ b/tests/testbench/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.java
@@ -1,91 +1,91 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-
-public class ColumnCollapsingAndColumnExpansion extends TestBase {
-
- private Table table;
-
- @Override
- public void setup() {
-
- table = new Table();
-
- table.addContainerProperty("Col1", String.class, null);
- table.addContainerProperty("Col2", String.class, null);
- table.addContainerProperty("Col3", String.class, null);
- table.setColumnCollapsingAllowed(true);
-
- table.addActionHandler(new Handler() {
-
- final Action H = new Action("Toggle Col2");
- final Action[] actions = new Action[] { H };
-
- public Action[] getActions(Object target, Object sender) {
- return actions;
- }
-
- public void handleAction(Action action, Object sender, Object target) {
- table.setColumnCollapsed("Col2",
- !table.isColumnCollapsed("Col2"));
-
- }
- });
-
- table.setSizeFull();
-
- for (int y = 1; y < 5; y++) {
- table.addItem(new Object[] { "cell " + 1 + "-" + y,
- "cell " + 2 + "-" + y, "cell " + 3 + "-" + y, },
- new Object());
- }
-
- addComponent(table);
-
- HorizontalLayout hl = new HorizontalLayout();
- final TextField tf = new TextField("Column name (ColX)");
- Button hide = new Button("Collapse", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- table.setColumnCollapsed(tf.getValue(), true);
- }
-
- });
-
- Button show = new Button("Show", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- table.setColumnCollapsed(tf.getValue(), false);
- }
-
- });
-
- hl.addComponent(tf);
- hl.addComponent(hide);
- hl.addComponent(show);
- hl.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
- hl.setComponentAlignment(hide, Alignment.BOTTOM_LEFT);
- hl.setComponentAlignment(show, Alignment.BOTTOM_LEFT);
- addComponent(hl);
-
- }
-
- @Override
- protected String getDescription() {
- return "After hiding column 2 the remaining columns (1 and 3) should use all available space in the table";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3246;
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+
+public class ColumnCollapsingAndColumnExpansion extends TestBase {
+
+ private Table table;
+
+ @Override
+ public void setup() {
+
+ table = new Table();
+
+ table.addContainerProperty("Col1", String.class, null);
+ table.addContainerProperty("Col2", String.class, null);
+ table.addContainerProperty("Col3", String.class, null);
+ table.setColumnCollapsingAllowed(true);
+
+ table.addActionHandler(new Handler() {
+
+ final Action H = new Action("Toggle Col2");
+ final Action[] actions = new Action[] { H };
+
+ public Action[] getActions(Object target, Object sender) {
+ return actions;
+ }
+
+ public void handleAction(Action action, Object sender, Object target) {
+ table.setColumnCollapsed("Col2",
+ !table.isColumnCollapsed("Col2"));
+
+ }
+ });
+
+ table.setSizeFull();
+
+ for (int y = 1; y < 5; y++) {
+ table.addItem(new Object[] { "cell " + 1 + "-" + y,
+ "cell " + 2 + "-" + y, "cell " + 3 + "-" + y, },
+ new Object());
+ }
+
+ addComponent(table);
+
+ HorizontalLayout hl = new HorizontalLayout();
+ final TextField tf = new TextField("Column name (ColX)");
+ Button hide = new Button("Collapse", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setColumnCollapsed(tf.getValue(), true);
+ }
+
+ });
+
+ Button show = new Button("Show", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setColumnCollapsed(tf.getValue(), false);
+ }
+
+ });
+
+ hl.addComponent(tf);
+ hl.addComponent(hide);
+ hl.addComponent(show);
+ hl.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+ hl.setComponentAlignment(hide, Alignment.BOTTOM_LEFT);
+ hl.setComponentAlignment(show, Alignment.BOTTOM_LEFT);
+ addComponent(hl);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "After hiding column 2 the remaining columns (1 and 3) should use all available space in the table";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3246;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/ColumnExpandWithFixedColumns.java b/tests/testbench/com/vaadin/tests/components/table/ColumnExpandWithFixedColumns.java
index 198e29be61..78b6c0982c 100644
--- a/tests/testbench/com/vaadin/tests/components/table/ColumnExpandWithFixedColumns.java
+++ b/tests/testbench/com/vaadin/tests/components/table/ColumnExpandWithFixedColumns.java
@@ -1,45 +1,45 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-
-public class ColumnExpandWithFixedColumns extends TestBase {
-
- private Table createTable() {
- Table t = new Table();
- t.addContainerProperty("id", Integer.class, null);
- t.addContainerProperty("txt", Component.class, null);
- t.addContainerProperty("button", Button.class, null);
- t.setColumnWidth("id", 30);
- t.setColumnWidth("button", 200);
- t.setColumnExpandRatio("txt", 10);// This column should be 400px wide.
- t.setSelectable(true);
- t.setSizeFull();
-
- for (int i = 0; i < 10; i++) {
- t.addItem(new Object[] { i, new Label("test " + i),
- new Button("Button " + i) }, i);
- }
-
- return t;
-
- }
-
- @Override
- protected String getDescription() {
- return "The second column has expand ratio and should use the maximum available space";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3143;
- }
-
- @Override
- protected void setup() {
- addComponent(createTable());
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+public class ColumnExpandWithFixedColumns extends TestBase {
+
+ private Table createTable() {
+ Table t = new Table();
+ t.addContainerProperty("id", Integer.class, null);
+ t.addContainerProperty("txt", Component.class, null);
+ t.addContainerProperty("button", Button.class, null);
+ t.setColumnWidth("id", 30);
+ t.setColumnWidth("button", 200);
+ t.setColumnExpandRatio("txt", 10);// This column should be 400px wide.
+ t.setSelectable(true);
+ t.setSizeFull();
+
+ for (int i = 0; i < 10; i++) {
+ t.addItem(new Object[] { i, new Label("test " + i),
+ new Button("Button " + i) }, i);
+ }
+
+ return t;
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The second column has expand ratio and should use the maximum available space";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3143;
+ }
+
+ @Override
+ protected void setup() {
+ addComponent(createTable());
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/EditableModeChange.java b/tests/testbench/com/vaadin/tests/components/table/EditableModeChange.java
index f2163f6df3..5f64dec443 100644
--- a/tests/testbench/com/vaadin/tests/components/table/EditableModeChange.java
+++ b/tests/testbench/com/vaadin/tests/components/table/EditableModeChange.java
@@ -1,99 +1,99 @@
-package com.vaadin.tests.components.table;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.data.Container;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TableFieldFactory;
-
-public class EditableModeChange extends TestBase {
-
- private ItemClickEvent selectionEvent;
-
- private final String[] names = { "Teemu", "Teppo", "Seppo", "Matti",
- "Pekka" };
-
- @Override
- public void setup() {
-
- final Table items = new Table("Items - double-click to edit");
- items.setSelectable(true);
- items.addContainerProperty("name", String.class, "");
- items.addContainerProperty("birthday", Date.class, "");
-
- final TableFieldFactory fieldFactory = new ItemFieldFactory();
- items.setTableFieldFactory(fieldFactory);
-
- Calendar cal = Calendar.getInstance();
- cal.set(2010, 7, 12, 12, 7, 54);
-
- for (String name : names) {
- items.addItem(name);
- items.getItem(name).getItemProperty("name").setValue(name);
- items.getItem(name).getItemProperty("birthday")
- .setValue(new FormattedDate(cal.getTime().getTime()));
- }
-
- items.addListener(new ItemClickEvent.ItemClickListener() {
-
- public void itemClick(ItemClickEvent event) {
- if (event.isDoubleClick()) {
- selectionEvent = event;
- items.setEditable(true);
- } else if (items.isEditable()) {
- items.setEditable(false);
- }
- }
- });
-
- addComponent(items);
- }
-
- private class FormattedDate extends Date {
-
- private DateFormat formatter = DateFormat.getDateTimeInstance(
- DateFormat.MEDIUM, DateFormat.MEDIUM, new Locale("en", "US"));
-
- public FormattedDate(long time) {
- super(time);
- }
-
- @Override
- public String toString() {
- return formatter.format(this);
- }
- }
-
- private class ItemFieldFactory extends DefaultFieldFactory {
- @Override
- public Field createField(Container container, Object itemId,
- Object propertyId, Component uiContext) {
- if (selectionEvent != null) {
- if ((selectionEvent.getItemId().equals(itemId))
- && (selectionEvent.getPropertyId().equals(propertyId))) {
- return super.createField(container, itemId, propertyId,
- uiContext);
- }
- }
- return null;
- }
- }
-
- @Override
- protected String getDescription() {
- return "Double click a cell to edit, then click on another row to select it (editmode is set to false). The clicked row should now be selected without any flickering.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5427;
- }
+package com.vaadin.tests.components.table;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+
+import com.vaadin.data.Container;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DefaultFieldFactory;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TableFieldFactory;
+
+public class EditableModeChange extends TestBase {
+
+ private ItemClickEvent selectionEvent;
+
+ private final String[] names = { "Teemu", "Teppo", "Seppo", "Matti",
+ "Pekka" };
+
+ @Override
+ public void setup() {
+
+ final Table items = new Table("Items - double-click to edit");
+ items.setSelectable(true);
+ items.addContainerProperty("name", String.class, "");
+ items.addContainerProperty("birthday", Date.class, "");
+
+ final TableFieldFactory fieldFactory = new ItemFieldFactory();
+ items.setTableFieldFactory(fieldFactory);
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(2010, 7, 12, 12, 7, 54);
+
+ for (String name : names) {
+ items.addItem(name);
+ items.getItem(name).getItemProperty("name").setValue(name);
+ items.getItem(name).getItemProperty("birthday")
+ .setValue(new FormattedDate(cal.getTime().getTime()));
+ }
+
+ items.addListener(new ItemClickEvent.ItemClickListener() {
+
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ selectionEvent = event;
+ items.setEditable(true);
+ } else if (items.isEditable()) {
+ items.setEditable(false);
+ }
+ }
+ });
+
+ addComponent(items);
+ }
+
+ private class FormattedDate extends Date {
+
+ private DateFormat formatter = DateFormat.getDateTimeInstance(
+ DateFormat.MEDIUM, DateFormat.MEDIUM, new Locale("en", "US"));
+
+ public FormattedDate(long time) {
+ super(time);
+ }
+
+ @Override
+ public String toString() {
+ return formatter.format(this);
+ }
+ }
+
+ private class ItemFieldFactory extends DefaultFieldFactory {
+ @Override
+ public Field createField(Container container, Object itemId,
+ Object propertyId, Component uiContext) {
+ if (selectionEvent != null) {
+ if ((selectionEvent.getItemId().equals(itemId))
+ && (selectionEvent.getPropertyId().equals(propertyId))) {
+ return super.createField(container, itemId, propertyId,
+ uiContext);
+ }
+ }
+ return null;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Double click a cell to edit, then click on another row to select it (editmode is set to false). The clicked row should now be selected without any flickering.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5427;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/EditableTableFocus.java b/tests/testbench/com/vaadin/tests/components/table/EditableTableFocus.java
index 149e32579b..b5c8aa0296 100644
--- a/tests/testbench/com/vaadin/tests/components/table/EditableTableFocus.java
+++ b/tests/testbench/com/vaadin/tests/components/table/EditableTableFocus.java
@@ -1,35 +1,35 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-
-public class EditableTableFocus extends TestBase {
- @Override
- public void setup() {
- Table table = new Table();
-
- table.addContainerProperty("TextField", String.class, null);
- table.setColumnWidth("TextField", 150);
- for (int i = 1; i < 100; i++) {
- table.addItem(new String[] { "" }, new Integer(i));
- }
- table.setEditable(true);
-
- addComponent(table);
- }
-
- @Override
- protected String getDescription() {
- return "<b>IE-Problem: TextFields in table lose their focus, no input possible</b><p>"
- + "Try inputs in the table's textfields in the freshly started programm. For the moment all works fine.<p>"
- + "Then scroll the table down one page or more.<br>"
- + "Try again to make some inputs. Nothing happens...<br>"
- + "Now the textfields always lose their focus immediately after they got it and no input is taken.<p>"
- + "<b>This problem is exclusive to Microsoft's Internet Explorer!</b>";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7965;
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+
+public class EditableTableFocus extends TestBase {
+ @Override
+ public void setup() {
+ Table table = new Table();
+
+ table.addContainerProperty("TextField", String.class, null);
+ table.setColumnWidth("TextField", 150);
+ for (int i = 1; i < 100; i++) {
+ table.addItem(new String[] { "" }, new Integer(i));
+ }
+ table.setEditable(true);
+
+ addComponent(table);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "<b>IE-Problem: TextFields in table lose their focus, no input possible</b><p>"
+ + "Try inputs in the table's textfields in the freshly started programm. For the moment all works fine.<p>"
+ + "Then scroll the table down one page or more.<br>"
+ + "Try again to make some inputs. Nothing happens...<br>"
+ + "Now the textfields always lose their focus immediately after they got it and no input is taken.<p>"
+ + "<b>This problem is exclusive to Microsoft's Internet Explorer!</b>";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7965;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/FixedHeightTable.java b/tests/testbench/com/vaadin/tests/components/table/FixedHeightTable.java
index e193a8a949..174c166320 100644
--- a/tests/testbench/com/vaadin/tests/components/table/FixedHeightTable.java
+++ b/tests/testbench/com/vaadin/tests/components/table/FixedHeightTable.java
@@ -1,39 +1,39 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-
-public class FixedHeightTable extends TestBase {
-
- private static final long serialVersionUID = -929892889178757852L;
- Table table;
- VerticalLayout layout;
-
- @Override
- public void setup() {
-
- table = new Table();
- table.addContainerProperty("test", String.class, null);
- table.setSizeFull();
- // bug: settings rows to 16 or more => last line is not rendered at all
- // on the client-side.
- final int maxRows = 16;
- for (int i = 1; i <= maxRows; i++) {
- table.addItem(new Object[] { "" + i }, i);
- }
-
- getLayout().setHeight("400px");
- addComponent(table);
- }
-
- @Override
- protected String getDescription() {
- return "The table contains 16 (1-16) rows which all should be visible";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3814;
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class FixedHeightTable extends TestBase {
+
+ private static final long serialVersionUID = -929892889178757852L;
+ Table table;
+ VerticalLayout layout;
+
+ @Override
+ public void setup() {
+
+ table = new Table();
+ table.addContainerProperty("test", String.class, null);
+ table.setSizeFull();
+ // bug: settings rows to 16 or more => last line is not rendered at all
+ // on the client-side.
+ final int maxRows = 16;
+ for (int i = 1; i <= maxRows; i++) {
+ table.addItem(new Object[] { "" + i }, i);
+ }
+
+ getLayout().setHeight("400px");
+ addComponent(table);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The table contains 16 (1-16) rows which all should be visible";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3814;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/ModifyContainerProperty.java b/tests/testbench/com/vaadin/tests/components/table/ModifyContainerProperty.java
index be3b6d3ec0..a472b43ce7 100644
--- a/tests/testbench/com/vaadin/tests/components/table/ModifyContainerProperty.java
+++ b/tests/testbench/com/vaadin/tests/components/table/ModifyContainerProperty.java
@@ -1,60 +1,60 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Table;
-
-@SuppressWarnings("serial")
-public class ModifyContainerProperty extends TestBase {
-
- private Table table = new Table();
- private IndexedContainer ic = new IndexedContainer();
-
- @Override
- protected void setup() {
- addComponent(table);
-
- ic.addContainerProperty("one", String.class, "one");
- ic.addContainerProperty("two", String.class, "two");
-
- ic.addItem("foo");
-
- ic.getContainerProperty("foo", "one").setValue("bar");
- ic.getContainerProperty("foo", "two").setValue("baz");
-
- table.setContainerDataSource(ic);
- addComponent(new Button("Remove container property",
- new Button.ClickListener() {
- public void buttonClick(com.vaadin.ui.Button.ClickEvent arg0) {
- ic.removeContainerProperty("one");
- }
- }));
- addComponent(new Button("Add container property",
- new Button.ClickListener() {
- public void buttonClick(com.vaadin.ui.Button.ClickEvent arg0) {
- boolean added = ic.addContainerProperty("three",
- String.class, "three");
- if (added) {
- Object[] current = table.getVisibleColumns();
- Object[] vis = new Object[current.length + 1];
- for (int i = 0; i < current.length; i++) {
- vis[i] = current[i];
- }
- vis[current.length] = "three";
- table.setVisibleColumns(vis);
- }
- }
- }));
- }
-
- @Override
- protected String getDescription() {
- return "Clicking on \"Add container property\" adds a property to the container and sets it visible. The table should then show a \"three\" column in addition to the others. Clicking on \"Remove container property\" should remove column \"two\" from the table.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3165;
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Table;
+
+@SuppressWarnings("serial")
+public class ModifyContainerProperty extends TestBase {
+
+ private Table table = new Table();
+ private IndexedContainer ic = new IndexedContainer();
+
+ @Override
+ protected void setup() {
+ addComponent(table);
+
+ ic.addContainerProperty("one", String.class, "one");
+ ic.addContainerProperty("two", String.class, "two");
+
+ ic.addItem("foo");
+
+ ic.getContainerProperty("foo", "one").setValue("bar");
+ ic.getContainerProperty("foo", "two").setValue("baz");
+
+ table.setContainerDataSource(ic);
+ addComponent(new Button("Remove container property",
+ new Button.ClickListener() {
+ public void buttonClick(com.vaadin.ui.Button.ClickEvent arg0) {
+ ic.removeContainerProperty("one");
+ }
+ }));
+ addComponent(new Button("Add container property",
+ new Button.ClickListener() {
+ public void buttonClick(com.vaadin.ui.Button.ClickEvent arg0) {
+ boolean added = ic.addContainerProperty("three",
+ String.class, "three");
+ if (added) {
+ Object[] current = table.getVisibleColumns();
+ Object[] vis = new Object[current.length + 1];
+ for (int i = 0; i < current.length; i++) {
+ vis[i] = current[i];
+ }
+ vis[current.length] = "three";
+ table.setVisibleColumns(vis);
+ }
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Clicking on \"Add container property\" adds a property to the container and sets it visible. The table should then show a \"three\" column in addition to the others. Clicking on \"Remove container property\" should remove column \"two\" from the table.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3165;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/NotselectablePaintSelections.java b/tests/testbench/com/vaadin/tests/components/table/NotselectablePaintSelections.java
index 9d3011365d..cb609b856b 100644
--- a/tests/testbench/com/vaadin/tests/components/table/NotselectablePaintSelections.java
+++ b/tests/testbench/com/vaadin/tests/components/table/NotselectablePaintSelections.java
@@ -1,55 +1,55 @@
-package com.vaadin.tests.components.table;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.vaadin.data.Item;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-
-public class NotselectablePaintSelections extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Table should paint selections even if it's not selectable.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3500;
- }
-
- @Override
- protected void setup() {
- // Multiselect
- Table t = new Table("Multiselect");
- addComponent(t);
- t.setSelectable(false);
- t.setMultiSelect(true);
- t.setPageLength(5);
- t.addContainerProperty("Name", String.class, null);
- Set<Object> selected = new HashSet<Object>();
- for (int i = 0; i < 30; i++) {
- Item item = t.addItem(i);
- item.getItemProperty("Name").setValue("Name " + i);
- if (i % 2 == 0) {
- selected.add(i);
- }
- }
- t.setValue(selected);
-
- // Singleselect
- t = new Table("Singleselect");
- addComponent(t);
- t.setSelectable(false);
- t.setMultiSelect(false);
- t.setPageLength(5);
- t.addContainerProperty("Name", String.class, null);
- for (int i = 0; i < 30; i++) {
- Item item = t.addItem(i);
- item.getItemProperty("Name").setValue("Name " + i);
- }
- t.setValue(3);
-
- }
-}
+package com.vaadin.tests.components.table;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.vaadin.data.Item;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+
+public class NotselectablePaintSelections extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Table should paint selections even if it's not selectable.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3500;
+ }
+
+ @Override
+ protected void setup() {
+ // Multiselect
+ Table t = new Table("Multiselect");
+ addComponent(t);
+ t.setSelectable(false);
+ t.setMultiSelect(true);
+ t.setPageLength(5);
+ t.addContainerProperty("Name", String.class, null);
+ Set<Object> selected = new HashSet<Object>();
+ for (int i = 0; i < 30; i++) {
+ Item item = t.addItem(i);
+ item.getItemProperty("Name").setValue("Name " + i);
+ if (i % 2 == 0) {
+ selected.add(i);
+ }
+ }
+ t.setValue(selected);
+
+ // Singleselect
+ t = new Table("Singleselect");
+ addComponent(t);
+ t.setSelectable(false);
+ t.setMultiSelect(false);
+ t.setPageLength(5);
+ t.addContainerProperty("Name", String.class, null);
+ for (int i = 0; i < 30; i++) {
+ Item item = t.addItem(i);
+ item.getItemProperty("Name").setValue("Name " + i);
+ }
+ t.setValue(3);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/RowAdditionTest.java b/tests/testbench/com/vaadin/tests/components/table/RowAdditionTest.java
index 742cc0acf3..82d5508c72 100644
--- a/tests/testbench/com/vaadin/tests/components/table/RowAdditionTest.java
+++ b/tests/testbench/com/vaadin/tests/components/table/RowAdditionTest.java
@@ -1,59 +1,59 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-
-public class RowAdditionTest extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Adding a row should refresh client area only if newly added row is in the rendered area.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return new Integer(2799);
- }
-
- @Override
- protected void setup() {
- final Table table = new Table();
- final IndexedContainer container = (IndexedContainer) table
- .getContainerDataSource();
- table.addContainerProperty("column1", String.class, "test");
-
- for (int i = 0; i < 100; ++i) {
- table.addItem();
- }
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.addComponent(new Button("Add first", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Item item = container.addItemAt(0, new Object());
- item.getItemProperty("column1").setValue("0");
- }
- }));
- hl.addComponent(new Button("Add at position 50",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Item item = container.addItemAt(50, new Object());
- item.getItemProperty("column1").setValue("50");
- }
- }));
- hl.addComponent(new Button("Add at position 100",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Item item = container.addItemAt(100, new Object());
- item.getItemProperty("column1").setValue("100");
- }
- }));
-
- getLayout().addComponent(table);
- getLayout().addComponent(hl);
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+
+public class RowAdditionTest extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Adding a row should refresh client area only if newly added row is in the rendered area.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return new Integer(2799);
+ }
+
+ @Override
+ protected void setup() {
+ final Table table = new Table();
+ final IndexedContainer container = (IndexedContainer) table
+ .getContainerDataSource();
+ table.addContainerProperty("column1", String.class, "test");
+
+ for (int i = 0; i < 100; ++i) {
+ table.addItem();
+ }
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.addComponent(new Button("Add first", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Item item = container.addItemAt(0, new Object());
+ item.getItemProperty("column1").setValue("0");
+ }
+ }));
+ hl.addComponent(new Button("Add at position 50",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Item item = container.addItemAt(50, new Object());
+ item.getItemProperty("column1").setValue("50");
+ }
+ }));
+ hl.addComponent(new Button("Add at position 100",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Item item = container.addItemAt(100, new Object());
+ item.getItemProperty("column1").setValue("100");
+ }
+ }));
+
+ getLayout().addComponent(table);
+ getLayout().addComponent(hl);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java b/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java
index d88b36abb1..1916dcd0d7 100644
--- a/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java
+++ b/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java
@@ -1,65 +1,65 @@
-package com.vaadin.tests.components.table;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Person;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-public class ScrollCausesRequestLoop extends TestBase {
-
- @Override
- protected void setup() {
- setMainWindow(new Window("", new TestView()));
- }
-
- @Override
- protected String getDescription() {
- return "Scrolling a table causes an infinite loop of UIDL requests in some cases";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 8040;
- }
-
- private static class TestView extends HorizontalLayout {
-
- TestView() {
- Table table = new Table();
- List<Person> data = createData();
- BeanItemContainer<Person> container = new BeanItemContainer<Person>(
- Person.class, data) {
-
- @Override
- public Person getIdByIndex(int index) {
- try {
- // Simulate some loading delay with some exaggeration
- // to make easier to reproduce
- Thread.sleep(50);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new RuntimeException(e);
- }
- return super.getIdByIndex(index);
- }
- };
- table.setContainerDataSource(container);
- addComponent(table);
- }
- }
-
- private static List<Person> createData() {
- int count = 500;
- List<Person> data = new ArrayList<Person>(count);
- for (int i = 0; i < count; i++) {
- data.add(new Person("Person", "" + i, "Email", "Phone", "Street",
- 12345, "City"));
- }
- return data;
- }
-}
+package com.vaadin.tests.components.table;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Person;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+public class ScrollCausesRequestLoop extends TestBase {
+
+ @Override
+ protected void setup() {
+ setMainWindow(new Window("", new TestView()));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Scrolling a table causes an infinite loop of UIDL requests in some cases";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8040;
+ }
+
+ private static class TestView extends HorizontalLayout {
+
+ TestView() {
+ Table table = new Table();
+ List<Person> data = createData();
+ BeanItemContainer<Person> container = new BeanItemContainer<Person>(
+ Person.class, data) {
+
+ @Override
+ public Person getIdByIndex(int index) {
+ try {
+ // Simulate some loading delay with some exaggeration
+ // to make easier to reproduce
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+ }
+ return super.getIdByIndex(index);
+ }
+ };
+ table.setContainerDataSource(container);
+ addComponent(table);
+ }
+ }
+
+ private static List<Person> createData() {
+ int count = 500;
+ List<Person> data = new ArrayList<Person>(count);
+ for (int i = 0; i < count; i++) {
+ data.add(new Person("Person", "" + i, "Email", "Phone", "Street",
+ 12345, "City"));
+ }
+ return data;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java b/tests/testbench/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
index d1fce928d4..a616d4dfb3 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
@@ -1,150 +1,150 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.event.Action;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Table;
-
-public class TableAndBrowserContextMenu extends TestBase implements
- Action.Handler, ItemClickListener {
-
- private Table table;
- private boolean actionHandlerHasActions = false;
-
- @Override
- public void setup() {
- CheckBox cb = new CheckBox("Item click listener");
- cb.setImmediate(true);
- cb.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- if (((Boolean) event.getProperty().getValue())) {
- table.addListener(TableAndBrowserContextMenu.this);
- } else {
- table.removeListener(TableAndBrowserContextMenu.this);
- }
-
- }
- });
- addComponent(cb);
-
- CheckBox cbActionHandler = new CheckBox("Action handler");
- cbActionHandler.setImmediate(true);
- cbActionHandler.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- if (((Boolean) event.getProperty().getValue())) {
- table.addActionHandler(TableAndBrowserContextMenu.this);
- } else {
- table.removeActionHandler(TableAndBrowserContextMenu.this);
- }
-
- }
- });
- addComponent(cbActionHandler);
-
- CheckBox cbActionHasActions = new CheckBox("Action handler has actions");
- cbActionHasActions.setImmediate(true);
- cbActionHasActions.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- actionHandlerHasActions = ((Boolean) event.getProperty()
- .getValue());
-
- // Workaround to ensure actions are repainted
- removeComponent(table);
- addComponent(table);
-
- }
- });
- addComponent(cbActionHasActions);
-
- createTable();
- addComponent(table);
-
- }
-
- private void createTable() {
- // Have a table with a numeric column
- table = new Table("A table");
- table.addContainerProperty("Name", String.class, null);
- table.addContainerProperty("Died At Age", Integer.class, null);
-
- // Add a generated column with a link to Google
- table.addGeneratedColumn("Search", new Table.ColumnGenerator() {
- public Component generateCell(Table source, Object itemId,
- Object columnId) {
- Item item = source.getItem(itemId);
- String name = (String) item.getItemProperty("Name").getValue();
- return new Link("Google for " + name, new ExternalResource(
- "http://www.google.co.uk/search?q=" + name));
- }
- });
-
- // Insert some data
- Object people[][] = { { "Galileo", 77 }, { "Monnier", 83 },
- { "Vaisala", 79 }, { "Oterma", 86 } };
-
- for (int i = 0; i < people.length; i++) {
- table.addItem(people[i], i);
- }
-
- // Calculate the average of the numeric column
- double avgAge = 0;
- for (int i = 0; i < people.length; i++) {
- avgAge += (Integer) people[i][1];
- }
- avgAge /= people.length;
-
- // Set the footers
- table.setFooterVisible(true);
- table.setColumnFooter("Name", "Average");
- table.setColumnFooter("Died At Age", String.valueOf(avgAge));
-
- // Adjust the table height a bit
- table.setPageLength(table.size() + 2);
-
- for (int i = 0; i < people.length; i++) {
- Object[] person = people[i];
- String name = (String) person[0];
- addComponent(new Link("Google for " + name, new ExternalResource(
- "http://www.google.co.uk/search?q=" + name)));
- }
-
- }
-
- @Override
- protected String getDescription() {
- return "Table should only prevent the browser context menu when the right click is used for some Table specific operation. In practice these are either action handlers/context menu or item click listeners (right click). Note that item click listeners affects rows only, not the body.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5924;
- }
-
- public void itemClick(ItemClickEvent event) {
- getMainWindow()
- .showNotification("Click using " + event.getButtonName());
- }
-
- public Action[] getActions(Object target, Object sender) {
- if (!actionHandlerHasActions) {
- return null;
- }
-
- return new Action[] { new Action("test") };
- }
-
- public void handleAction(Action action, Object sender, Object target) {
- getMainWindow().showNotification("Action: " + action.getCaption());
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.Action;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Table;
+
+public class TableAndBrowserContextMenu extends TestBase implements
+ Action.Handler, ItemClickListener {
+
+ private Table table;
+ private boolean actionHandlerHasActions = false;
+
+ @Override
+ public void setup() {
+ CheckBox cb = new CheckBox("Item click listener");
+ cb.setImmediate(true);
+ cb.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ if (((Boolean) event.getProperty().getValue())) {
+ table.addListener(TableAndBrowserContextMenu.this);
+ } else {
+ table.removeListener(TableAndBrowserContextMenu.this);
+ }
+
+ }
+ });
+ addComponent(cb);
+
+ CheckBox cbActionHandler = new CheckBox("Action handler");
+ cbActionHandler.setImmediate(true);
+ cbActionHandler.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ if (((Boolean) event.getProperty().getValue())) {
+ table.addActionHandler(TableAndBrowserContextMenu.this);
+ } else {
+ table.removeActionHandler(TableAndBrowserContextMenu.this);
+ }
+
+ }
+ });
+ addComponent(cbActionHandler);
+
+ CheckBox cbActionHasActions = new CheckBox("Action handler has actions");
+ cbActionHasActions.setImmediate(true);
+ cbActionHasActions.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ actionHandlerHasActions = ((Boolean) event.getProperty()
+ .getValue());
+
+ // Workaround to ensure actions are repainted
+ removeComponent(table);
+ addComponent(table);
+
+ }
+ });
+ addComponent(cbActionHasActions);
+
+ createTable();
+ addComponent(table);
+
+ }
+
+ private void createTable() {
+ // Have a table with a numeric column
+ table = new Table("A table");
+ table.addContainerProperty("Name", String.class, null);
+ table.addContainerProperty("Died At Age", Integer.class, null);
+
+ // Add a generated column with a link to Google
+ table.addGeneratedColumn("Search", new Table.ColumnGenerator() {
+ public Component generateCell(Table source, Object itemId,
+ Object columnId) {
+ Item item = source.getItem(itemId);
+ String name = (String) item.getItemProperty("Name").getValue();
+ return new Link("Google for " + name, new ExternalResource(
+ "http://www.google.co.uk/search?q=" + name));
+ }
+ });
+
+ // Insert some data
+ Object people[][] = { { "Galileo", 77 }, { "Monnier", 83 },
+ { "Vaisala", 79 }, { "Oterma", 86 } };
+
+ for (int i = 0; i < people.length; i++) {
+ table.addItem(people[i], i);
+ }
+
+ // Calculate the average of the numeric column
+ double avgAge = 0;
+ for (int i = 0; i < people.length; i++) {
+ avgAge += (Integer) people[i][1];
+ }
+ avgAge /= people.length;
+
+ // Set the footers
+ table.setFooterVisible(true);
+ table.setColumnFooter("Name", "Average");
+ table.setColumnFooter("Died At Age", String.valueOf(avgAge));
+
+ // Adjust the table height a bit
+ table.setPageLength(table.size() + 2);
+
+ for (int i = 0; i < people.length; i++) {
+ Object[] person = people[i];
+ String name = (String) person[0];
+ addComponent(new Link("Google for " + name, new ExternalResource(
+ "http://www.google.co.uk/search?q=" + name)));
+ }
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Table should only prevent the browser context menu when the right click is used for some Table specific operation. In practice these are either action handlers/context menu or item click listeners (right click). Note that item click listeners affects rows only, not the body.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5924;
+ }
+
+ public void itemClick(ItemClickEvent event) {
+ getMainWindow()
+ .showNotification("Click using " + event.getButtonName());
+ }
+
+ public Action[] getActions(Object target, Object sender) {
+ if (!actionHandlerHasActions) {
+ return null;
+ }
+
+ return new Action[] { new Action("test") };
+ }
+
+ public void handleAction(Action action, Object sender, Object target) {
+ getMainWindow().showNotification("Action: " + action.getCaption());
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java
index e0449dea8b..47216033e9 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java
@@ -1,86 +1,86 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TableClickValueChangeInteraction extends TestBase {
-
- final Window mainWindow = new Window();
-
- @Override
- public void setup() {
- setMainWindow(mainWindow);
-
- GridLayout layout = new GridLayout(4, 4);
- layout.setSpacing(true);
- layout.setMargin(true);
- mainWindow.setContent(layout);
-
- for (int i = 0; i < 16; ++i) {
- mainWindow.addComponent(makeTable((i & 8) > 0, (i & 4) > 0,
- (i & 2) > 0, (i & 1) > 0));
- }
-
- }
-
- @Override
- protected String getDescription() {
- return "Table selection breaks if ItemClickListener requests repaint";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7127;
- }
-
- private Component makeTable(boolean immediate, boolean selectable,
- boolean listenClicks, boolean listenValueChanges) {
-
- final Table table = new Table((immediate ? "I" : "i")
- + (selectable ? "S" : "s") + (listenClicks ? "C" : "c")
- + (listenValueChanges ? "V" : "v"));
- final Label clickLabel = new Label("Click?");
- final Label valueChangeLabel = new Label("Value?");
-
- table.addContainerProperty("foo", String.class, null);
- for (int i = 0; i < 3; i++) {
- table.addItem("item" + i).getItemProperty("foo")
- .setValue("An item " + i);
- }
- table.setImmediate(immediate);
- table.setSelectable(selectable);
- table.setWidth("100px");
- table.setHeight("100px");
- if (listenClicks) {
- table.addListener(new ItemClickListener() {
- public void itemClick(ItemClickEvent event) {
- table.requestRepaint();
- clickLabel.setValue("Click " + event.getItemId());
- }
- });
- }
- if (listenValueChanges) {
- table.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- valueChangeLabel.setValue("Value " + event.getProperty());
- }
- });
- }
-
- Layout result = new VerticalLayout();
- result.addComponent(table);
- result.addComponent(clickLabel);
- result.addComponent(valueChangeLabel);
- return result;
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TableClickValueChangeInteraction extends TestBase {
+
+ final Window mainWindow = new Window();
+
+ @Override
+ public void setup() {
+ setMainWindow(mainWindow);
+
+ GridLayout layout = new GridLayout(4, 4);
+ layout.setSpacing(true);
+ layout.setMargin(true);
+ mainWindow.setContent(layout);
+
+ for (int i = 0; i < 16; ++i) {
+ mainWindow.addComponent(makeTable((i & 8) > 0, (i & 4) > 0,
+ (i & 2) > 0, (i & 1) > 0));
+ }
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Table selection breaks if ItemClickListener requests repaint";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7127;
+ }
+
+ private Component makeTable(boolean immediate, boolean selectable,
+ boolean listenClicks, boolean listenValueChanges) {
+
+ final Table table = new Table((immediate ? "I" : "i")
+ + (selectable ? "S" : "s") + (listenClicks ? "C" : "c")
+ + (listenValueChanges ? "V" : "v"));
+ final Label clickLabel = new Label("Click?");
+ final Label valueChangeLabel = new Label("Value?");
+
+ table.addContainerProperty("foo", String.class, null);
+ for (int i = 0; i < 3; i++) {
+ table.addItem("item" + i).getItemProperty("foo")
+ .setValue("An item " + i);
+ }
+ table.setImmediate(immediate);
+ table.setSelectable(selectable);
+ table.setWidth("100px");
+ table.setHeight("100px");
+ if (listenClicks) {
+ table.addListener(new ItemClickListener() {
+ public void itemClick(ItemClickEvent event) {
+ table.requestRepaint();
+ clickLabel.setValue("Click " + event.getItemId());
+ }
+ });
+ }
+ if (listenValueChanges) {
+ table.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ valueChangeLabel.setValue("Value " + event.getProperty());
+ }
+ });
+ }
+
+ Layout result = new VerticalLayout();
+ result.addComponent(table);
+ result.addComponent(clickLabel);
+ result.addComponent(valueChangeLabel);
+ return result;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java b/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java
index bc8c40108c..8fde820749 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java
@@ -1,61 +1,61 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TableExtraScrollbars extends AbstractTestCase {
-
- private static int PROPS = 15;
- private static int ROWS = 1000;
-
- @Override
- public void init() {
- setTheme("runo");
- Window w = new Window("Table scrollbars bug example");
- setMainWindow(w);
-
- VerticalLayout vl = new VerticalLayout();
- vl.setSizeFull();
- vl.addComponent(createTable());
- w.setContent(vl);
- }
-
- protected Table createTable() {
- Table table = new Table(null, createContainer());
- table.setSizeFull();
- table.setPageLength(50);
- table.setColumnReorderingAllowed(true);
- table.setSelectable(true);
- return table;
- }
-
- protected Container createContainer() {
- Container container = new IndexedContainer();
- for (int i = 0; i < PROPS; ++i) {
- container.addContainerProperty("prop" + i, String.class, null);
- }
- for (int i = 0; i < ROWS; ++i) {
- Item item = container.addItem(i);
- for (int p = 0; p < PROPS; ++p) {
- item.getItemProperty("prop" + p).setValue(
- "property value 1234567890");
- }
- }
- return container;
- }
-
- @Override
- protected String getDescription() {
- return "Scrolling down in the table should not add extra scrollbars";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4489;
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TableExtraScrollbars extends AbstractTestCase {
+
+ private static int PROPS = 15;
+ private static int ROWS = 1000;
+
+ @Override
+ public void init() {
+ setTheme("runo");
+ Window w = new Window("Table scrollbars bug example");
+ setMainWindow(w);
+
+ VerticalLayout vl = new VerticalLayout();
+ vl.setSizeFull();
+ vl.addComponent(createTable());
+ w.setContent(vl);
+ }
+
+ protected Table createTable() {
+ Table table = new Table(null, createContainer());
+ table.setSizeFull();
+ table.setPageLength(50);
+ table.setColumnReorderingAllowed(true);
+ table.setSelectable(true);
+ return table;
+ }
+
+ protected Container createContainer() {
+ Container container = new IndexedContainer();
+ for (int i = 0; i < PROPS; ++i) {
+ container.addContainerProperty("prop" + i, String.class, null);
+ }
+ for (int i = 0; i < ROWS; ++i) {
+ Item item = container.addItem(i);
+ for (int p = 0; p < PROPS; ++p) {
+ item.getItemProperty("prop" + p).setValue(
+ "property value 1234567890");
+ }
+ }
+ return container;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Scrolling down in the table should not add extra scrollbars";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4489;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableLastRowMissing.java b/tests/testbench/com/vaadin/tests/components/table/TableLastRowMissing.java
index 4e4a223e23..18d13e676b 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableLastRowMissing.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableLastRowMissing.java
@@ -1,35 +1,35 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-
-public class TableLastRowMissing extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The table below should display 3 rows. Each with a textfield containing the row number.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2933;
- }
-
- @Override
- protected void setup() {
- Table t = new Table();
- addComponent(t);
-
- t.addContainerProperty("Name", TextField.class, null);
-
- for (int i = 0; i < 3; i++) {
- Item item = t.addItem(i);
- TextField tf = new TextField("", String.valueOf(i + 1));
- tf.setColumns(10);
- item.getItemProperty("Name").setValue(tf);
- }
-
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+
+public class TableLastRowMissing extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The table below should display 3 rows. Each with a textfield containing the row number.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2933;
+ }
+
+ @Override
+ protected void setup() {
+ Table t = new Table();
+ addComponent(t);
+
+ t.addContainerProperty("Name", TextField.class, null);
+
+ for (int i = 0; i < 3; i++) {
+ Item item = t.addItem(i);
+ TextField tf = new TextField("", String.valueOf(i + 1));
+ tf.setColumns(10);
+ item.getItemProperty("Name").setValue(tf);
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java b/tests/testbench/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
index 7d29b8650e..91ca8256c8 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
@@ -1,51 +1,51 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Table;
-
-public class TableModifcationsWhenScrolledRight extends TestBase {
-
- @Override
- protected void setup() {
- final Table t = new Table();
- Button btn = new Button("Add row");
- Integer row = 1;
-
- t.setPageLength(5);
- t.setWidth("400px");
- t.addContainerProperty("name", String.class, "NA");
- t.setColumnCollapsingAllowed(true);
-
- for (Integer col = 0; col < 10; col++) {
- t.addContainerProperty(col, Integer.class, col);
- t.setColumnWidth(col, 50);
- }
- t.addItem(row).getItemProperty("name").setValue("Row" + row);
-
- btn.addListener(new ClickListener() {
- Integer row = 2;
-
- public void buttonClick(ClickEvent event) {
- t.addItem(row).getItemProperty("name").setValue("Row" + row);
- row++;
- }
- });
-
- addComponent(t);
- addComponent(btn);
- }
-
- @Override
- protected String getDescription() {
- return "Scroll right and then click \"Add row\". The table will scroll back left and the headers should also.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5382;
- }
-
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+
+public class TableModifcationsWhenScrolledRight extends TestBase {
+
+ @Override
+ protected void setup() {
+ final Table t = new Table();
+ Button btn = new Button("Add row");
+ Integer row = 1;
+
+ t.setPageLength(5);
+ t.setWidth("400px");
+ t.addContainerProperty("name", String.class, "NA");
+ t.setColumnCollapsingAllowed(true);
+
+ for (Integer col = 0; col < 10; col++) {
+ t.addContainerProperty(col, Integer.class, col);
+ t.setColumnWidth(col, 50);
+ }
+ t.addItem(row).getItemProperty("name").setValue("Row" + row);
+
+ btn.addListener(new ClickListener() {
+ Integer row = 2;
+
+ public void buttonClick(ClickEvent event) {
+ t.addItem(row).getItemProperty("name").setValue("Row" + row);
+ row++;
+ }
+ });
+
+ addComponent(t);
+ addComponent(btn);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Scroll right and then click \"Add row\". The table will scroll back left and the headers should also.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5382;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TablePageLengthCalculation.java b/tests/testbench/com/vaadin/tests/components/table/TablePageLengthCalculation.java
index 5847450f89..55089ff56b 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TablePageLengthCalculation.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TablePageLengthCalculation.java
@@ -1,50 +1,50 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-public class TablePageLengthCalculation extends TestBase {
-
- @Override
- public void setup() {
-
- Window window = new Window();
- window.setCaption("usermanagement");
- window.center();
- window.setWidth(40, Window.UNITS_PERCENTAGE);
- window.setHeight(40, Window.UNITS_PERCENTAGE);
- window.setModal(true);
- getMainWindow().addWindow(window);
-
- TabSheet tab = new TabSheet();
- tab.setSizeFull();
-
- tab.addTab(new TableView(), "users", null);
- tab.addTab(new TableView(), "groups", null);
-
- window.setContent(tab);
- }
-
- public class TableView extends Table {
- private static final long serialVersionUID = 1L;
-
- public TableView() {
- setSizeFull();
-
- addContainerProperty("name", String.class, "name");
- addContainerProperty("right", Boolean.class, "right");
- }
- }
-
- @Override
- protected String getDescription() {
- return "Resize the window and change the selected tab. In Opera 10.50 the updated pagelength will be calculated as a float and not an integer, causing an \"Internal Error\"";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4374;
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+public class TablePageLengthCalculation extends TestBase {
+
+ @Override
+ public void setup() {
+
+ Window window = new Window();
+ window.setCaption("usermanagement");
+ window.center();
+ window.setWidth(40, Window.UNITS_PERCENTAGE);
+ window.setHeight(40, Window.UNITS_PERCENTAGE);
+ window.setModal(true);
+ getMainWindow().addWindow(window);
+
+ TabSheet tab = new TabSheet();
+ tab.setSizeFull();
+
+ tab.addTab(new TableView(), "users", null);
+ tab.addTab(new TableView(), "groups", null);
+
+ window.setContent(tab);
+ }
+
+ public class TableView extends Table {
+ private static final long serialVersionUID = 1L;
+
+ public TableView() {
+ setSizeFull();
+
+ addContainerProperty("name", String.class, "name");
+ addContainerProperty("right", Boolean.class, "right");
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Resize the window and change the selected tab. In Opera 10.50 the updated pagelength will be calculated as a float and not an integer, causing an \"Internal Error\"";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4374;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
index a536303061..5354525f1e 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
@@ -1,43 +1,43 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Table;
-
-public class TableRepaintWhenMadeVisibile extends TestBase {
-
- @Override
- public void setup() {
- final Table table = new Table();
- table.addContainerProperty("sth", String.class, null);
- table.addItem(new Object[] { "something" }, 1);
- addComponent(table);
-
- Button show = new Button("show", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- table.setVisible(true);
- }
- });
- addComponent(show);
- Button hide = new Button("hide", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- table.setVisible(false);
- }
- });
- addComponent(hide);
- }
-
- @Override
- protected String getDescription() {
- return "A Table should be rendered correctly when made visible again after being initially rendered invisible. Click 'hide', refresh the application and then click 'show'";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7986;
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+
+public class TableRepaintWhenMadeVisibile extends TestBase {
+
+ @Override
+ public void setup() {
+ final Table table = new Table();
+ table.addContainerProperty("sth", String.class, null);
+ table.addItem(new Object[] { "something" }, 1);
+ addComponent(table);
+
+ Button show = new Button("show", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setVisible(true);
+ }
+ });
+ addComponent(show);
+ Button hide = new Button("hide", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setVisible(false);
+ }
+ });
+ addComponent(hide);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A Table should be rendered correctly when made visible again after being initially rendered invisible. Click 'hide', refresh the application and then click 'show'";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7986;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableScrollOnFocus.java b/tests/testbench/com/vaadin/tests/components/table/TableScrollOnFocus.java
index 05e101a5f9..2c7193956a 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableScrollOnFocus.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableScrollOnFocus.java
@@ -1,49 +1,49 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Table;
-
-public class TableScrollOnFocus extends TestBase {
- @Override
- protected void setup() {
- final Table table = new Table();
- final CheckBox chkSelectable = new CheckBox("selectable");
-
- chkSelectable.setImmediate(true);
- chkSelectable.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- table.setSelectable(chkSelectable.booleanValue());
- }
- });
-
- table.addContainerProperty("row #", String.class, "-");
- table.setColumnWidth("row #", 150);
- for (int i = 1; i < 200; i++) {
- table.addItem(new String[] { "" + i }, null);
- }
- table.setSortDisabled(true);
-
- chkSelectable.setValue(true);
-
- addComponent(chkSelectable);
- addComponent(table);
- }
-
- @Override
- protected String getDescription() {
- return "The table scrolls up 2 pages after loosing and regaining the focus!</b><p>"
- + "Drag scrollbar to top then to the bottom of the table.<br>"
- + "Click somewhere beside the table to take away the focus,<br>"
- + "then click back on the table (header or scrollbar) to give back the focus<br>"
- + "(Pressing Tab and Shift-Tab does the same job).<p>"
- + "If the table is set to non-selectable-mode, no self-scrolling occurs.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6774;
- }
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Table;
+
+public class TableScrollOnFocus extends TestBase {
+ @Override
+ protected void setup() {
+ final Table table = new Table();
+ final CheckBox chkSelectable = new CheckBox("selectable");
+
+ chkSelectable.setImmediate(true);
+ chkSelectable.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ table.setSelectable(chkSelectable.booleanValue());
+ }
+ });
+
+ table.addContainerProperty("row #", String.class, "-");
+ table.setColumnWidth("row #", 150);
+ for (int i = 1; i < 200; i++) {
+ table.addItem(new String[] { "" + i }, null);
+ }
+ table.setSortDisabled(true);
+
+ chkSelectable.setValue(true);
+
+ addComponent(chkSelectable);
+ addComponent(table);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The table scrolls up 2 pages after loosing and regaining the focus!</b><p>"
+ + "Drag scrollbar to top then to the bottom of the table.<br>"
+ + "Click somewhere beside the table to take away the focus,<br>"
+ + "then click back on the table (header or scrollbar) to give back the focus<br>"
+ + "(Pressing Tab and Shift-Tab does the same job).<p>"
+ + "If the table is set to non-selectable-mode, no self-scrolling occurs.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6774;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableScrollsOnSelection.java b/tests/testbench/com/vaadin/tests/components/table/TableScrollsOnSelection.java
index c76fe05d47..f49fdfd3b9 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableScrollsOnSelection.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableScrollsOnSelection.java
@@ -1,36 +1,36 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-
-public class TableScrollsOnSelection extends TestBase {
-
- @Override
- protected void setup() {
- getMainWindow().getContent().setSizeUndefined();
-
- IndexedContainer cont = new IndexedContainer();
- cont.addContainerProperty("number", String.class, null);
- for (int i = 0; i < 80; i++) {
- Item item = cont.addItem(i);
- item.getItemProperty("number").setValue(i + "");
- }
- Table table = new Table();
- table.setPageLength(0);
- table.setContainerDataSource(cont);
- table.setSelectable(true);
- addComponent(table);
- }
-
- @Override
- protected String getDescription() {
- return "The scroll position should not change when an item is selected in a Table that is higher than the view.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6197;
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+
+public class TableScrollsOnSelection extends TestBase {
+
+ @Override
+ protected void setup() {
+ getMainWindow().getContent().setSizeUndefined();
+
+ IndexedContainer cont = new IndexedContainer();
+ cont.addContainerProperty("number", String.class, null);
+ for (int i = 0; i < 80; i++) {
+ Item item = cont.addItem(i);
+ item.getItemProperty("number").setValue(i + "");
+ }
+ Table table = new Table();
+ table.setPageLength(0);
+ table.setContainerDataSource(cont);
+ table.setSelectable(true);
+ addComponent(table);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The scroll position should not change when an item is selected in a Table that is higher than the view.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6197;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableSelectPagingOff.java b/tests/testbench/com/vaadin/tests/components/table/TableSelectPagingOff.java
index 4d97a1a669..d97e0a5cef 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableSelectPagingOff.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableSelectPagingOff.java
@@ -1,69 +1,69 @@
-package com.vaadin.tests.components.table;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-
-public class TableSelectPagingOff extends TestBase {
-
- @Override
- protected void setup() {
- Table table = new Table();
- BeanItemContainer<MyBean> dataSource = new BeanItemContainer<MyBean>(
- getBeans());
- table.setContainerDataSource(dataSource);
- table.setSelectable(true);
- table.setPageLength(0);
- addComponent(table);
- }
-
- private Collection<MyBean> getBeans() {
- return Arrays.asList(new MyBean("a", "description a"), new MyBean("b",
- "description b"), new MyBean("c", "description c"), new MyBean(
- "d", "description d"));
- }
-
- public class MyBean {
-
- private String name;
- private String description;
-
- public MyBean() {
- }
-
- public MyBean(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- }
-
- @Override
- protected String getDescription() {
- return "No flickering (scrollbars) should happen on select";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5746;
- }
-}
+package com.vaadin.tests.components.table;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+
+public class TableSelectPagingOff extends TestBase {
+
+ @Override
+ protected void setup() {
+ Table table = new Table();
+ BeanItemContainer<MyBean> dataSource = new BeanItemContainer<MyBean>(
+ getBeans());
+ table.setContainerDataSource(dataSource);
+ table.setSelectable(true);
+ table.setPageLength(0);
+ addComponent(table);
+ }
+
+ private Collection<MyBean> getBeans() {
+ return Arrays.asList(new MyBean("a", "description a"), new MyBean("b",
+ "description b"), new MyBean("c", "description c"), new MyBean(
+ "d", "description d"));
+ }
+
+ public class MyBean {
+
+ private String name;
+ private String description;
+
+ public MyBean() {
+ }
+
+ public MyBean(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "No flickering (scrollbars) should happen on select";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5746;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableSingleSelect.java b/tests/testbench/com/vaadin/tests/components/table/TableSingleSelect.java
index edde284848..911c59b5c5 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableSingleSelect.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableSingleSelect.java
@@ -1,54 +1,54 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Table;
-
-public class TableSingleSelect extends TestBase {
- Log log = new Log(3);
-
- @Override
- protected void setup() {
- log.setDebugId("eventlog");
-
- Table t = new Table();
-
- t.setSelectable(true);
- t.setNullSelectionAllowed(true);
- t.setImmediate(true);
- t.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- log.log("Selected value: " + event.getProperty().getValue());
- }
- });
-
- t.addContainerProperty("string", String.class, null);
- t.addContainerProperty("button", Component.class, null);
-
- for (int i = 0; i < 10; i++) {
- t.addItem(i);
- t.getContainerProperty(i, "string").setValue(i);
- t.getContainerProperty(i, "button")
- .setValue(new Button("Click me"));
- }
-
- addComponent(log);
- addComponent(t);
- }
-
- @Override
- protected String getDescription() {
- return "Table in single-select mode with null selection allowed. Tests that single select does not select multiple items, selects and deselects properly.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5431;
- }
-
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Table;
+
+public class TableSingleSelect extends TestBase {
+ Log log = new Log(3);
+
+ @Override
+ protected void setup() {
+ log.setDebugId("eventlog");
+
+ Table t = new Table();
+
+ t.setSelectable(true);
+ t.setNullSelectionAllowed(true);
+ t.setImmediate(true);
+ t.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ log.log("Selected value: " + event.getProperty().getValue());
+ }
+ });
+
+ t.addContainerProperty("string", String.class, null);
+ t.addContainerProperty("button", Component.class, null);
+
+ for (int i = 0; i < 10; i++) {
+ t.addItem(i);
+ t.getContainerProperty(i, "string").setValue(i);
+ t.getContainerProperty(i, "button")
+ .setValue(new Button("Click me"));
+ }
+
+ addComponent(log);
+ addComponent(t);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Table in single-select mode with null selection allowed. Tests that single select does not select multiple items, selects and deselects properly.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5431;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableSorting.java b/tests/testbench/com/vaadin/tests/components/table/TableSorting.java
index 4cbb1934e4..a0d9b8e69d 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableSorting.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableSorting.java
@@ -1,67 +1,67 @@
-package com.vaadin.tests.components.table;
-
-import java.io.Serializable;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-
-public class TableSorting extends TestBase {
-
- @Override
- public void setup() {
- final Label showID = new Label("");
- final Table testTable = new Table();
-
- BeanItemContainer<TestItem> cont = new BeanItemContainer<TestItem>(
- TestItem.class);
-
- for (int i = 0; i < 20; i++) {
- TestItem ti = new TestItem();
- ti.setTestName("Name_" + i);
- cont.addBean(ti);
- }
- testTable.setContainerDataSource(cont);
- testTable.setImmediate(true);
- testTable.setSelectable(true);
- testTable.setMultiSelect(false);
- testTable.setVisibleColumns(new Object[] { "testName" });
-
- // Handle selection change.
- testTable.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- System.out.println("ValueChanged: "
- + testTable.getValue().toString());
- showID.setCaption("ID: " + testTable.getValue().toString());
- }
- });
- addComponent(testTable);
- addComponent(showID);
- }
-
- public class TestItem implements Serializable {
- private static final long serialVersionUID = -745849615488792221L;
- private String testName;
-
- public String getTestName() {
- return testName;
- }
-
- public void setTestName(String testName) {
- this.testName = testName;
- }
- }
-
- @Override
- protected String getDescription() {
- return "Click the header to sort the table, then click on \"Name_10\". This should show ID: com.vaadin.tests.components.table.TableSorting$TestItem@<hex id> below the table";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4537;
- }
+package com.vaadin.tests.components.table;
+
+import java.io.Serializable;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+public class TableSorting extends TestBase {
+
+ @Override
+ public void setup() {
+ final Label showID = new Label("");
+ final Table testTable = new Table();
+
+ BeanItemContainer<TestItem> cont = new BeanItemContainer<TestItem>(
+ TestItem.class);
+
+ for (int i = 0; i < 20; i++) {
+ TestItem ti = new TestItem();
+ ti.setTestName("Name_" + i);
+ cont.addBean(ti);
+ }
+ testTable.setContainerDataSource(cont);
+ testTable.setImmediate(true);
+ testTable.setSelectable(true);
+ testTable.setMultiSelect(false);
+ testTable.setVisibleColumns(new Object[] { "testName" });
+
+ // Handle selection change.
+ testTable.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ System.out.println("ValueChanged: "
+ + testTable.getValue().toString());
+ showID.setCaption("ID: " + testTable.getValue().toString());
+ }
+ });
+ addComponent(testTable);
+ addComponent(showID);
+ }
+
+ public class TestItem implements Serializable {
+ private static final long serialVersionUID = -745849615488792221L;
+ private String testName;
+
+ public String getTestName() {
+ return testName;
+ }
+
+ public void setTestName(String testName) {
+ this.testName = testName;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the header to sort the table, then click on \"Name_10\". This should show ID: com.vaadin.tests.components.table.TableSorting$TestItem@<hex id> below the table";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4537;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java b/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java
index 5c456ab230..f5f87599d9 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java
@@ -1,169 +1,169 @@
-package com.vaadin.tests.components.table;
-
-import java.text.DecimalFormat;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TableToggleVisibility extends AbstractTestCase {
-
- private static final int[] LENGTHS = new int[] { 20, 22, 10 };
-
- @Override
- public void init() {
-
- DecimalFormat format = new DecimalFormat("000");
- Table[] tables = new Table[3];
- Button[] buttons = new Button[3];
-
- VerticalLayout leftComponent = new VerticalLayout();
- leftComponent.setMargin(true);
- leftComponent.setSpacing(true);
-
- // Toolbar with buttons to hide or show lists
-
- HorizontalLayout toolBar = new HorizontalLayout();
- toolBar.setSpacing(true);
- toolBar.setMargin(true);
-
- leftComponent.addComponent(toolBar);
- leftComponent.setExpandRatio(toolBar, 0.0f);
-
- // List of trucks -----------------------
-
- tables[0] = new Table("Trucks");
- tables[0].addContainerProperty("Brand", String.class, null);
- tables[0].addContainerProperty("Model", String.class, null);
- tables[0].addContainerProperty("License Plate", String.class, null);
-
- for (int i = 1; i < LENGTHS[0]; i++) {
- tables[0].addItem(
- new Object[] { "MAN", "XYZ", "1-ABC-" + format.format(i) },
- Integer.valueOf(i));
- }
- tables[0].setPageLength(LENGTHS[0]);
-
- tables[0].setWidth("100%");
- tables[0].setHeight("100%");
- tables[0].setSelectable(true);
-
- leftComponent.addComponent(tables[0]);
- leftComponent.setExpandRatio(tables[0], 1.0f);
-
- // List of trailers ----------------------
-
- tables[1] = new Table("Trailers");
- tables[1].addContainerProperty("Type", String.class, null);
- tables[1].addContainerProperty("License Plate", String.class, null);
- for (int i = 1; i < LENGTHS[1]; i++) {
- tables[1].addItem(
- new Object[] { "Cooler", "1-QQQ-" + format.format(i) },
- Integer.valueOf(i));
- }
- tables[1].setPageLength(LENGTHS[1]);
-
- tables[1].setWidth("100%");
- tables[1].setHeight("100%");
- tables[1].setSelectable(true);
-
- leftComponent.addComponent(tables[1]);
- leftComponent.setExpandRatio(tables[1], 1.0f);
-
- // List of drivers ------------------------
-
- tables[2] = new Table("Drivers");
- tables[2].addContainerProperty("First Name", String.class, null);
- tables[2].addContainerProperty("Last Name", String.class, null);
- tables[2].addContainerProperty("HR ID", String.class, null);
- for (int i = 1; i < LENGTHS[2]; i++) {
- tables[2].addItem(
- new Object[] { "King", "Vabis", "HR-" + format.format(i) },
- Integer.valueOf(i));
- }
- tables[2].setPageLength(LENGTHS[2]);
-
- tables[2].setWidth("100%");
- tables[2].setHeight("100%");
- tables[2].setSelectable(true);
-
- leftComponent.addComponent(tables[2]);
- leftComponent.setExpandRatio(tables[2], 1.0f);
-
- leftComponent.setWidth("100%");
-
- HorizontalSplitPanel split = new HorizontalSplitPanel();
- split.setFirstComponent(leftComponent);
-
- VerticalLayout rightComponent = new VerticalLayout();
- rightComponent.setMargin(true);
- rightComponent.addComponent(new Label("Left blank!"));
- split.setSecondComponent(rightComponent);
-
- split.setSizeFull();
-
- VerticalLayout mainLayout = new VerticalLayout();
- mainLayout.setSizeFull();
- mainLayout.addComponent(split);
- mainLayout.setExpandRatio(split, 1.0f);
-
- Window mainWindow = new Window("Visibilitybug Application", mainLayout);
- mainWindow.setSizeFull();
-
- setMainWindow(mainWindow);
-
- // complete toolbar
-
- for (int i = 0; i < buttons.length; i++) {
- buttons[i] = new ToggleButton(tables[i]);
- toolBar.addComponent(buttons[i]);
- }
-
- }
-
- // Button to switch the visibility of a table.
-
- private static class ToggleButton extends Button {
-
- private Table table;
-
- private ToggleButton(Table table) {
- this.table = table;
-
- setCaption("- " + table.getCaption());
-
- addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
-
- boolean wasVisible = ToggleButton.this.table.isVisible();
-
- ToggleButton.this.table.setVisible(!wasVisible);
- setCaption((wasVisible ? "+ " : "- ")
- + ToggleButton.this.table.getCaption());
- setDescription((wasVisible ? "Show " : "Hide ")
- + "the list with "
- + ToggleButton.this.table.getCaption());
-
- }
- });
- }
-
- }
-
- @Override
- protected String getDescription() {
- return "Test for hiding and showing tables. Click a button to show/hide one of the tables. The tables are all 100% wide and should be rendered the same way after being hidden and shown again.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6494;
- }
-
+package com.vaadin.tests.components.table;
+
+import java.text.DecimalFormat;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TableToggleVisibility extends AbstractTestCase {
+
+ private static final int[] LENGTHS = new int[] { 20, 22, 10 };
+
+ @Override
+ public void init() {
+
+ DecimalFormat format = new DecimalFormat("000");
+ Table[] tables = new Table[3];
+ Button[] buttons = new Button[3];
+
+ VerticalLayout leftComponent = new VerticalLayout();
+ leftComponent.setMargin(true);
+ leftComponent.setSpacing(true);
+
+ // Toolbar with buttons to hide or show lists
+
+ HorizontalLayout toolBar = new HorizontalLayout();
+ toolBar.setSpacing(true);
+ toolBar.setMargin(true);
+
+ leftComponent.addComponent(toolBar);
+ leftComponent.setExpandRatio(toolBar, 0.0f);
+
+ // List of trucks -----------------------
+
+ tables[0] = new Table("Trucks");
+ tables[0].addContainerProperty("Brand", String.class, null);
+ tables[0].addContainerProperty("Model", String.class, null);
+ tables[0].addContainerProperty("License Plate", String.class, null);
+
+ for (int i = 1; i < LENGTHS[0]; i++) {
+ tables[0].addItem(
+ new Object[] { "MAN", "XYZ", "1-ABC-" + format.format(i) },
+ Integer.valueOf(i));
+ }
+ tables[0].setPageLength(LENGTHS[0]);
+
+ tables[0].setWidth("100%");
+ tables[0].setHeight("100%");
+ tables[0].setSelectable(true);
+
+ leftComponent.addComponent(tables[0]);
+ leftComponent.setExpandRatio(tables[0], 1.0f);
+
+ // List of trailers ----------------------
+
+ tables[1] = new Table("Trailers");
+ tables[1].addContainerProperty("Type", String.class, null);
+ tables[1].addContainerProperty("License Plate", String.class, null);
+ for (int i = 1; i < LENGTHS[1]; i++) {
+ tables[1].addItem(
+ new Object[] { "Cooler", "1-QQQ-" + format.format(i) },
+ Integer.valueOf(i));
+ }
+ tables[1].setPageLength(LENGTHS[1]);
+
+ tables[1].setWidth("100%");
+ tables[1].setHeight("100%");
+ tables[1].setSelectable(true);
+
+ leftComponent.addComponent(tables[1]);
+ leftComponent.setExpandRatio(tables[1], 1.0f);
+
+ // List of drivers ------------------------
+
+ tables[2] = new Table("Drivers");
+ tables[2].addContainerProperty("First Name", String.class, null);
+ tables[2].addContainerProperty("Last Name", String.class, null);
+ tables[2].addContainerProperty("HR ID", String.class, null);
+ for (int i = 1; i < LENGTHS[2]; i++) {
+ tables[2].addItem(
+ new Object[] { "King", "Vabis", "HR-" + format.format(i) },
+ Integer.valueOf(i));
+ }
+ tables[2].setPageLength(LENGTHS[2]);
+
+ tables[2].setWidth("100%");
+ tables[2].setHeight("100%");
+ tables[2].setSelectable(true);
+
+ leftComponent.addComponent(tables[2]);
+ leftComponent.setExpandRatio(tables[2], 1.0f);
+
+ leftComponent.setWidth("100%");
+
+ HorizontalSplitPanel split = new HorizontalSplitPanel();
+ split.setFirstComponent(leftComponent);
+
+ VerticalLayout rightComponent = new VerticalLayout();
+ rightComponent.setMargin(true);
+ rightComponent.addComponent(new Label("Left blank!"));
+ split.setSecondComponent(rightComponent);
+
+ split.setSizeFull();
+
+ VerticalLayout mainLayout = new VerticalLayout();
+ mainLayout.setSizeFull();
+ mainLayout.addComponent(split);
+ mainLayout.setExpandRatio(split, 1.0f);
+
+ Window mainWindow = new Window("Visibilitybug Application", mainLayout);
+ mainWindow.setSizeFull();
+
+ setMainWindow(mainWindow);
+
+ // complete toolbar
+
+ for (int i = 0; i < buttons.length; i++) {
+ buttons[i] = new ToggleButton(tables[i]);
+ toolBar.addComponent(buttons[i]);
+ }
+
+ }
+
+ // Button to switch the visibility of a table.
+
+ private static class ToggleButton extends Button {
+
+ private Table table;
+
+ private ToggleButton(Table table) {
+ this.table = table;
+
+ setCaption("- " + table.getCaption());
+
+ addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+
+ boolean wasVisible = ToggleButton.this.table.isVisible();
+
+ ToggleButton.this.table.setVisible(!wasVisible);
+ setCaption((wasVisible ? "+ " : "- ")
+ + ToggleButton.this.table.getCaption());
+ setDescription((wasVisible ? "Show " : "Hide ")
+ + "the list with "
+ + ToggleButton.this.table.getCaption());
+
+ }
+ });
+ }
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test for hiding and showing tables. Click a button to show/hide one of the tables. The tables are all 100% wide and should be rendered the same way after being hidden and shown again.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6494;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableWithManyColumns.java b/tests/testbench/com/vaadin/tests/components/table/TableWithManyColumns.java
index 543c1ebae2..7040391721 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableWithManyColumns.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableWithManyColumns.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Table;
-
-public class TableWithManyColumns extends TestBase {
-
- private static final int ROWS = 20;
- private static final int COLS = 100;
-
- @Override
- protected void setup() {
- Table t = new Table();
-
- for (int i = 0; i < COLS; i++) {
- t.addContainerProperty("COLUMN_" + i, String.class, "");
- }
- for (int row = 0; row < ROWS; row++) {
- Item i = t.addItem(String.valueOf(row));
- for (int col = 0; col < COLS; col++) {
- Property p = i.getItemProperty("COLUMN_" + col);
- p.setValue("item " + row + "/" + col);
- }
- }
- t.setFooterVisible(true);
- t.setSizeFull();
- addComponent(t);
- }
-
- @Override
- protected String getDescription() {
- return "The footer, header and content cells should be as wide, even when the Table contains many columns";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5185;
- }
-
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+
+public class TableWithManyColumns extends TestBase {
+
+ private static final int ROWS = 20;
+ private static final int COLS = 100;
+
+ @Override
+ protected void setup() {
+ Table t = new Table();
+
+ for (int i = 0; i < COLS; i++) {
+ t.addContainerProperty("COLUMN_" + i, String.class, "");
+ }
+ for (int row = 0; row < ROWS; row++) {
+ Item i = t.addItem(String.valueOf(row));
+ for (int col = 0; col < COLS; col++) {
+ Property p = i.getItemProperty("COLUMN_" + col);
+ p.setValue("item " + row + "/" + col);
+ }
+ }
+ t.setFooterVisible(true);
+ t.setSizeFull();
+ addComponent(t);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The footer, header and content cells should be as wide, even when the Table contains many columns";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5185;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/Tables.java b/tests/testbench/com/vaadin/tests/components/table/Tables.java
index 3a34fb47b2..3f37a178b6 100644
--- a/tests/testbench/com/vaadin/tests/components/table/Tables.java
+++ b/tests/testbench/com/vaadin/tests/components/table/Tables.java
@@ -1,838 +1,838 @@
-package com.vaadin.tests.components.table;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.terminal.Resource;
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.AbstractSelect.MultiSelectMode;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Table.CellStyleGenerator;
-import com.vaadin.ui.Table.ColumnGenerator;
-import com.vaadin.ui.Table.ColumnResizeEvent;
-import com.vaadin.ui.Table.ColumnResizeListener;
-import com.vaadin.ui.Table.FooterClickEvent;
-import com.vaadin.ui.Table.FooterClickListener;
-import com.vaadin.ui.Table.GeneratedRow;
-import com.vaadin.ui.Table.HeaderClickEvent;
-import com.vaadin.ui.Table.HeaderClickListener;
-import com.vaadin.ui.Table.RowGenerator;
-
-public class Tables<T extends Table> extends AbstractSelectTestCase<T>
- implements ItemClickListener, HeaderClickListener, FooterClickListener,
- ColumnResizeListener {
-
- protected static final String CATEGORY_ROWS = "Rows";
- private static final String CATEGORY_HEADER = "Header";
- private static final String CATEGORY_FOOTER = "Footer";
- private static final String CATEGORY_COLUMNS = "Columns";
-
- @Override
- protected Class<T> getTestClass() {
- return (Class) Table.class;
- }
-
- /* COMMANDS */
- private Command<T, String> columnAlignmentCommand = new Command<T, String>() {
-
- public void execute(T c, String alignment, Object propertyId) {
- c.setColumnAlignment(propertyId, alignment);
- }
-
- };
-
- private Command<T, Boolean> columnVisibleCommand = new Command<T, Boolean>() {
- public void execute(Table c, Boolean visible, Object propertyId) {
- List<Object> visibleColumns = new ArrayList<Object>(Arrays.asList(c
- .getVisibleColumns()));
- if (visible) {
- // Table should really check this... Completely fails without
- // the check (#
- if (!visibleColumns.contains(propertyId)) {
- visibleColumns.add(propertyId);
- }
- } else {
- visibleColumns.remove(propertyId);
- }
- c.setVisibleColumns(visibleColumns.toArray());
- }
- };
-
- private Command<T, Boolean> columnCollapsed = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean collapsed, Object propertyId) {
- c.setColumnCollapsed(propertyId, collapsed);
-
- }
- };
-
- protected Command<T, Boolean> columnResizeListenerCommand = new Command<T, Boolean>() {
-
- public void execute(Table c, Boolean value, Object data) {
- if (value) {
- c.addListener((ColumnResizeListener) Tables.this);
- } else {
- c.removeListener((ColumnResizeListener) Tables.this);
- }
- }
- };
-
- protected Command<T, Boolean> headerClickListenerCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((HeaderClickListener) Tables.this);
- } else {
- c.removeListener((HeaderClickListener) Tables.this);
- }
- }
- };
-
- protected Command<T, Boolean> footerClickListenerCommand = new Command<T, Boolean>() {
-
- public void execute(Table c, Boolean value, Object data) {
- if (value) {
- c.addListener((FooterClickListener) Tables.this);
- } else {
- c.removeListener((FooterClickListener) Tables.this);
- }
- }
- };
-
- protected Command<T, Integer> rowHeaderModeCommand = new Command<T, Integer>() {
-
- public void execute(Table c, Integer value, Object data) {
- if (value == Table.ROW_HEADER_MODE_PROPERTY) {
- c.setItemCaptionPropertyId("Property 3");
- }
- c.setRowHeaderMode(value);
- }
- };
-
- protected Command<T, String> footerTextCommand = new Command<T, String>() {
-
- public void execute(Table c, String value, Object data) {
- for (Object propertyId : c.getContainerPropertyIds()) {
- if (value != null) {
- c.setColumnFooter(propertyId,
- value.replace("{id}", propertyId.toString()));
- } else {
- c.setColumnFooter(propertyId, null);
- }
- }
- }
- };
-
- protected Command<T, Object> alignColumnLeftCommand = new Command<T, Object>() {
-
- public void execute(T c, Object propertyId, Object data) {
- c.setColumnAlignment(propertyId, (String) data);
- }
- };
-
- private Command<T, ContextMenu> contextMenuCommand = new Command<T, ContextMenu>() {
-
- public void execute(T c, final ContextMenu value, Object data) {
- c.removeAllActionHandlers();
- if (value != null) {
- c.addActionHandler(new Handler() {
-
- public void handleAction(Action action, Object sender,
- Object target) {
- log("Action " + action.getCaption() + " performed on "
- + target);
- }
-
- public Action[] getActions(Object target, Object sender) {
- return value.getActions(target, sender);
- }
- });
- }
- }
- };
- private Command<T, Integer> columnWidthCommand = new Command<T, Integer>() {
-
- public void execute(T c, Integer width, Object propertyId) {
- c.setColumnWidth(propertyId, width);
-
- }
- };
-
- private Command<T, Resource> columnIconCommand = new Command<T, Resource>() {
-
- public void execute(T c, Resource icon, Object propertyId) {
- c.setColumnIcon(propertyId, icon);
-
- }
- };
- private Command<T, Integer> columnHeaderModeCommand = new Command<T, Integer>() {
-
- public void execute(T c, Integer columnHeaderMode, Object data) {
- c.setColumnHeaderMode(columnHeaderMode);
-
- }
- };
- private Command<T, String> columnHeaderCommand = new Command<T, String>() {
-
- public void execute(T c, String header, Object propertyId) {
- c.setColumnHeader(propertyId, header);
-
- }
- };
- private Command<T, Float> columnExpandRatioCommand = new Command<T, Float>() {
-
- public void execute(T c, Float expandRatio, Object propertyId) {
- c.setColumnExpandRatio(propertyId, expandRatio);
- }
- };
-
- private class GeneratedColumn {
- private Class<?> type;
- private String width;
- private boolean html;
-
- public GeneratedColumn(Class<?> type, String width, boolean html) {
- super();
- this.type = type;
- this.width = width;
- this.html = html;
- }
- }
-
- String generatedColumnId = "Generated ";
- int generatedColumnNextNr = 1;
-
- private Command<T, GeneratedColumn> addGeneratedColumnCommand = new Command<T, GeneratedColumn>() {
-
- public void execute(T c, final GeneratedColumn col, Object data) {
- while (c.getColumnGenerator(generatedColumnId
- + generatedColumnNextNr) != null) {
- generatedColumnNextNr++;
- }
-
- c.addGeneratedColumn(generatedColumnId + generatedColumnNextNr,
- new ColumnGenerator() {
-
- public Object generateCell(Table source, Object itemId,
- Object columnId) {
- String value = "";
- if (col.html) {
- value = "<i>" + itemId + "</i>" + "/" + "<b>"
- + columnId + "</b>";
- } else {
- value = itemId + "/" + columnId;
- }
- if (col.type == Button.class) {
- Button b = new Button();
- b.setCaption(value);
- b.setWidth(col.width);
- return b;
- } else if (col.type == Label.class) {
- Label l = new Label();
- l.setWidth(col.width);
- if (col.html) {
- l.setValue(value);
- l.setContentMode(Label.CONTENT_XHTML);
- } else {
- l.setValue(value);
- }
- return l;
- } else if (col.type == String.class) {
- return value;
- } else if (col.type == Object.class) {
- return new Object();
- }
-
- return null;
- }
- });
- generatedColumnNextNr++;
- createColumnOptions(false);
-
- }
- };
- private Command<T, Object> removeGeneratedColumnsCommand = new Command<T, Object>() {
-
- public void execute(T c, Object value, Object data) {
- for (int i = 0; i < generatedColumnNextNr; i++) {
- String columnId = generatedColumnId + i;
- if (c.getColumnGenerator(columnId) != null) {
- c.removeGeneratedColumn(columnId);
- }
-
- }
- createColumnOptions(false);
-
- }
- };
-
- private class CellStyleInfo {
- private final String styleName;
- private final Object itemId;
- private final Object propertyId;
-
- public CellStyleInfo(String styleName, Object itemId, Object propertyId) {
- this.styleName = styleName;
- this.itemId = itemId;
- this.propertyId = propertyId;
- }
-
- public boolean appliesTo(Object itemId, Object propertyId) {
- return (this.itemId != null && this.itemId.equals(itemId))
- && (this.propertyId == propertyId || (this.propertyId != null && this.propertyId
- .equals(propertyId)));
- }
- }
-
- private Command<T, CellStyleInfo> cellStyleCommand = new Command<T, CellStyleInfo>() {
-
- public void execute(T c, final CellStyleInfo cellStyleInfo, Object data) {
- if (cellStyleInfo == null) {
- c.setCellStyleGenerator(null);
- } else {
- c.setCellStyleGenerator(new CellStyleGenerator() {
-
- public String getStyle(Object itemId, Object propertyId) {
- if (cellStyleInfo.appliesTo(itemId, propertyId)) {
- return cellStyleInfo.styleName;
- }
- return null;
- }
- });
- }
- }
- };
-
- private class GeneratedRowInfo {
-
- private final int nth;
- private final String[] text;
- private final boolean isHtml;
-
- public GeneratedRowInfo(int nth, boolean isHtml, String... text) {
- this.nth = nth;
- this.isHtml = isHtml;
- this.text = text;
- }
-
- public boolean appliesTo(Object itemId) {
- int ix = Integer.valueOf(itemId.toString().substring(5));
- return ix % nth == 0;
- }
-
- @Override
- public String toString() {
- return String.format("%d, %s, %s", nth, isHtml ? "true" : "false",
- Arrays.toString(text));
- }
- }
-
- private Command<T, GeneratedRowInfo> rowGeneratorCommand = new Command<T, GeneratedRowInfo>() {
-
- public void execute(T c, final GeneratedRowInfo generatedRowInfo,
- Object data) {
- if (generatedRowInfo == null) {
- c.setRowGenerator(null);
- } else {
- c.setRowGenerator(new RowGenerator() {
-
- public GeneratedRow generateRow(Table table, Object itemId) {
- if (generatedRowInfo.appliesTo(itemId)) {
- GeneratedRow generatedRow = new GeneratedRow(
- generatedRowInfo.text);
- generatedRow
- .setHtmlContentAllowed(generatedRowInfo.isHtml);
- return generatedRow;
- }
- return null;
- }
- });
- }
- }
- };
-
- private Command<T, Boolean> setSortEnabledCommand = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setSortDisabled(!value);
-
- }
- };
-
- /* COMMANDS END */
-
- @Override
- protected void createActions() {
- super.createActions();
-
- createPageLengthSelect(CATEGORY_SIZE);
-
- createSelectionModeSelect(CATEGORY_SELECTION);
- createValueSelection(CATEGORY_SELECTION);
-
- createItemClickListener(CATEGORY_LISTENERS);
- createColumnResizeListenerCheckbox(CATEGORY_LISTENERS);
- createHeaderClickListenerCheckbox(CATEGORY_LISTENERS);
- createFooterClickListenerCheckbox(CATEGORY_LISTENERS);
-
- createRowHeaderModeSelect(CATEGORY_DATA_SOURCE);
-
- createHeaderVisibilitySelect(CATEGORY_HEADER);
- createHeaderTextCheckbox(CATEGORY_HEADER);
-
- createFooterVisibilityCheckbox(CATEGORY_FOOTER);
- createFooterTextSelect(CATEGORY_FOOTER);
-
- createColumnReorderingAllowedCheckbox(CATEGORY_FEATURES);
- createColumnCollapsingAllowedCheckbox(CATEGORY_FEATURES);
-
- createContextMenuAction(CATEGORY_FEATURES);
-
- createColumnHeaderMode(CATEGORY_FEATURES);
- createAddGeneratedColumnAction(CATEGORY_FEATURES);
- createCellStyleAction(CATEGORY_FEATURES);
- createGeneratedRowAction(CATEGORY_FEATURES);
-
- createBooleanAction("Sort enabled", CATEGORY_FEATURES, true,
- setSortEnabledCommand);
- createColumnOptions(true);
- }
-
- private void createAddGeneratedColumnAction(String categoryFeatures) {
- String category = "Generated columns";
- createCategory(category, categoryFeatures);
- createClickAction("Add Button", category, addGeneratedColumnCommand,
- new GeneratedColumn(Button.class, null, false));
- createClickAction("Add 200px wide Button", category,
- addGeneratedColumnCommand, new GeneratedColumn(Button.class,
- "200px", false));
- createClickAction("Add 100% wide Button", category,
- addGeneratedColumnCommand, new GeneratedColumn(Button.class,
- "100%", false));
- createClickAction("Add Label", category, addGeneratedColumnCommand,
- new GeneratedColumn(Label.class, null, false));
- createClickAction("Add 100px Label", category,
- addGeneratedColumnCommand, new GeneratedColumn(Label.class,
- "100px", false));
- createClickAction("Add 100% wide Label", category,
- addGeneratedColumnCommand, new GeneratedColumn(Label.class,
- "100%", false));
-
- createClickAction("Remove generated columns", category,
- removeGeneratedColumnsCommand, null);
- createClickAction("Add string as generated column", category,
- addGeneratedColumnCommand, new GeneratedColumn(String.class,
- "", false));
- createClickAction("Add HTML string as generated column", category,
- addGeneratedColumnCommand, new GeneratedColumn(String.class,
- "", true));
- createClickAction("Add 100px HTML Label", category,
- addGeneratedColumnCommand, new GeneratedColumn(Label.class,
- "100px", true));
- createClickAction("Add Object as generated column", category,
- addGeneratedColumnCommand, new GeneratedColumn(Object.class,
- "", false));
- }
-
- private void createCellStyleAction(String categoryFeatures) {
- LinkedHashMap<String, CellStyleInfo> options = new LinkedHashMap<String, CellStyleInfo>();
- options.put("None", null);
- options.put("Red row", new CellStyleInfo(
- "tables-test-cell-style-red-row", "Item 2", null));
- options.put("Red cell", new CellStyleInfo(
- "tables-test-cell-style-red-row", "Item 2", "Property 2"));
- createSelectAction("Cell style generator", categoryFeatures, options,
- "None", cellStyleCommand, true);
- }
-
- private void createGeneratedRowAction(String categoryFeatures) {
- LinkedHashMap<String, GeneratedRowInfo> options = new LinkedHashMap<String, GeneratedRowInfo>();
- options.put("None", null);
- options.put("Every fifth row, spanned", new GeneratedRowInfo(5, false,
- "foobarbaz this is a long one that should span."));
- int props = getComponent().getContainerPropertyIds().size();
- String[] text = new String[props];
- for (int ix = 0; ix < props; ix++) {
- text[ix] = "foo" + ix;
- }
- options.put("Every tenth row, no spanning", new GeneratedRowInfo(10,
- false, text));
- options.put(
- "Every eight row, spanned, html formatted",
- new GeneratedRowInfo(8, true,
- "<b>foo</b> <i>bar</i> <span style='color:red;text-size:0.5em;'>baz</span>"));
- options.put("Every row, spanned", new GeneratedRowInfo(1, false,
- "spanned"));
- createSelectAction("Row generator", categoryFeatures, options, "None",
- rowGeneratorCommand, true);
- }
-
- private void createColumnHeaderMode(String category) {
- LinkedHashMap<String, Integer> columnHeaderModeOptions = new LinkedHashMap<String, Integer>();
- columnHeaderModeOptions.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
- columnHeaderModeOptions.put("Id", Table.COLUMN_HEADER_MODE_ID);
- columnHeaderModeOptions.put("Explicit",
- Table.COLUMN_HEADER_MODE_EXPLICIT);
- columnHeaderModeOptions.put("Explicit defaults id",
- Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
-
- createSelectAction("Column header mode", category,
- columnHeaderModeOptions, "Explicit defaults id",
- columnHeaderModeCommand);
- }
-
- private void createValueSelection(String categorySelection) {
- LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
- options.put("null", null);
- for (int i = 1; i <= 10; i++) {
- options.put("Item " + i, "Item " + i);
- }
- createSelectAction("Value", categorySelection, options, null,
- setValueCommand);
- }
-
- private void createContextMenuAction(String category) {
- LinkedHashMap<String, ContextMenu> options = new LinkedHashMap<String, ContextMenu>();
- options.put("None", null);
- options.put("Item without icon", new ContextMenu("No icon", null));
- ContextMenu cm = new ContextMenu();
- cm.addItem("Caption only", null);
- cm.addItem("Has icon", ICON_16_USER_PNG_UNCACHEABLE);
- options.put("With and without icon", cm);
- options.put("Only one large icon", new ContextMenu("Icon",
- ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE));
- options.put("Empty", new ContextMenu() {
- @Override
- public Action[] getActions(Object target, Object sender) {
- return null;
- }
- });
- options.put("Edit/New", new ContextMenu() {
- @Override
- public Action[] getActions(Object itemId, Object component) {
- if (itemId == null) {
- return new Action[] { new Action("New..."),
- new Action("Common action") };
- } else {
- return new Action[] { new Action("Edit " + itemId),
- new Action("Common action") };
- }
- }
- });
-
- createSelectAction("Context menu", category, options, "None",
- contextMenuCommand, true);
- }
-
- private void createColumnReorderingAllowedCheckbox(String category) {
- createBooleanAction("Column reordering allowed", category, true,
- new Command<T, Boolean>() {
- public void execute(Table c, Boolean value, Object data) {
- c.setColumnReorderingAllowed(value);
- }
- });
- }
-
- private void createColumnCollapsingAllowedCheckbox(String category) {
- createBooleanAction("Column collapsing allowed", category, true,
- new Command<T, Boolean>() {
- public void execute(T c, Boolean value, Object data) {
- c.setColumnCollapsingAllowed(value);
- }
- });
- }
-
- private void createColumnOptions(boolean init) {
- if (!init && !hasCategory(CATEGORY_COLUMNS)) {
- return;
- }
-
- long start = System.currentTimeMillis();
- if (!init) {
- removeCategory(CATEGORY_COLUMNS);
- }
-
- for (Object id : getComponent().getContainerPropertyIds()) {
- String name = id.toString();
- createCategory(name, CATEGORY_COLUMNS);
- createColumnOption(name, id);
- }
- for (int i = 0; i < generatedColumnNextNr; i++) {
- String id = generatedColumnId + i;
- String name = id;
- if (getTestComponents().get(0).getColumnGenerator(id) != null) {
- createCategory(name, CATEGORY_COLUMNS);
- createColumnOption(name, id);
- }
- }
-
- long end = System.currentTimeMillis();
- System.err.println("Create options took " + (end - start) + "ms");
- }
-
- private class Timer {
- private long start, last;
-
- private Timer() {
- start = System.currentTimeMillis();
- last = System.currentTimeMillis();
- }
-
- public void log(String msg) {
- long now = System.currentTimeMillis();
- System.err.println("[This: " + (now - last) + "ms, total: "
- + (now - start) + "ms]: " + msg);
- last = now;
- }
- }
-
- private void createColumnOption(String category, Object propertyId) {
- Timer t = new Timer();
- createBooleanAction("Visible", category, true, columnVisibleCommand,
- propertyId);
- t.log("Visible");
- createBooleanAction("Collapsed", category, false, columnCollapsed,
- propertyId);
- t.log("Collapsed");
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("Left", Table.ALIGN_LEFT);
- options.put("Center", Table.ALIGN_CENTER);
- options.put("Right", Table.ALIGN_RIGHT);
-
- createSelectAction("Alignment", category, options, "Left",
- columnAlignmentCommand, propertyId);
- t.log("Alignment");
- LinkedHashMap<String, Integer> widthOptions = new LinkedHashMap<String, Integer>();
- widthOptions.put("- remove -", -1);
- for (int i : new int[] { 0, 1, 10, 100, 200, 400 }) {
- widthOptions.put(i + "px", i);
- }
- createSelectAction("Width", category, widthOptions, "- remove -",
- columnWidthCommand, propertyId);
- t.log("Width");
-
- LinkedHashMap<String, Resource> iconOptions = new LinkedHashMap<String, Resource>();
- iconOptions.put("- none -", null);
- iconOptions.put("ok 16x16", ICON_16_USER_PNG_CACHEABLE);
- iconOptions.put("help 16x16", ICON_16_HELP_PNG_CACHEABLE);
- iconOptions.put("folder 16x16", ICON_16_FOLDER_PNG_CACHEABLE);
- iconOptions.put("attention 32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
- createSelectAction("Icon", category, iconOptions, "- none -",
- columnIconCommand, propertyId);
-
- t.log("Icon");
- LinkedHashMap<String, String> columnHeaderOptions = new LinkedHashMap<String, String>();
- columnHeaderOptions.put("- none -", null);
- columnHeaderOptions.put("A", "A");
- columnHeaderOptions.put("A nice column", "A nice column");
-
- createSelectAction("Column header", category, columnHeaderOptions,
- "- none -", columnHeaderCommand, propertyId);
- t.log("Header");
- LinkedHashMap<String, Float> expandOptions = new LinkedHashMap<String, Float>();
- expandOptions.put("- remove -", -1f);
- for (float i : new float[] { 0, 1, 2, 3, 4, 5 }) {
- expandOptions.put(i + "", i);
- }
- createSelectAction("Expand ratio", category, expandOptions,
- "- remove -", columnExpandRatioCommand, propertyId);
- t.log("Expand");
- // Footer text (move)
- // Header text (move)
-
- }
-
- private void createRowHeaderModeSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Explicit", Table.ROW_HEADER_MODE_EXPLICIT);
- options.put("Explicit defaults id",
- Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
- options.put("Hidden", Table.ROW_HEADER_MODE_HIDDEN);
- options.put("Icon only", Table.ROW_HEADER_MODE_ICON_ONLY);
- options.put("Id", Table.ROW_HEADER_MODE_ID);
- options.put("Index", Table.ROW_HEADER_MODE_INDEX);
- options.put("Item", Table.ROW_HEADER_MODE_ITEM);
- options.put("'Property 3' property", Table.ROW_HEADER_MODE_PROPERTY);
-
- createSelectAction("Row header mode", category, options, "Hidden",
- rowHeaderModeCommand);
- }
-
- private void createFooterTextSelect(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("None", null);
- options.put("Footer X", "Footer {id}");
- options.put("X", "{id}");
-
- createSelectAction("Texts in footer", category, options, "None",
- footerTextCommand);
- }
-
- private void createHeaderTextCheckbox(String category) {
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("None", null);
- options.put("Col: {id}", "Col: {id}");
- options.put("Header {id} - every second", "Header {id}");
-
- createSelectAction("Texts in header", category, options, "None",
- new Command<T, String>() {
- public void execute(T c, String value, Object data) {
- int nr = 0;
- for (Object propertyId : c.getContainerPropertyIds()) {
- nr++;
- if (value != null && value.equals("Header {id}")
- && nr % 2 == 0) {
- c.setColumnHeader(propertyId, null);
- } else if (value != null) {
- c.setColumnHeader(
- propertyId,
- value.replace("{id}",
- propertyId.toString()));
- } else {
- c.setColumnHeader(propertyId, null);
- }
- }
-
- }
- });
- }
-
- private void createHeaderClickListenerCheckbox(String category) {
-
- createBooleanAction("Header click listener", category, false,
- headerClickListenerCommand);
- }
-
- private void createFooterClickListenerCheckbox(String category) {
-
- createBooleanAction("Footer click listener", category, false,
- footerClickListenerCommand);
- }
-
- private void createColumnResizeListenerCheckbox(String category) {
-
- createBooleanAction("Column resize listener", category, false,
- columnResizeListenerCommand);
- }
-
- // TODO:
- // setCurrentPageFirstItemIndex()
- // Editable
- // Cache rate
- // CurrentPageFirstItemId
-
- protected void createFooterVisibilityCheckbox(String category) {
- createBooleanAction("Footer visible", category, true,
- new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.setFooterVisible(value);
- }
- });
- }
-
- protected void createHeaderVisibilitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Explicit", Table.COLUMN_HEADER_MODE_EXPLICIT);
- options.put("Explicit defaults id",
- Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
- options.put("Id", Table.COLUMN_HEADER_MODE_ID);
- options.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
-
- createSelectAction("Header mode", category, options,
- "Explicit defaults id", new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.setColumnHeaderMode(value);
-
- }
- });
- }
-
- protected void createPageLengthSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("0", 0);
- options.put("5", 5);
- options.put("10", 10);
- options.put("20", 20);
- options.put("50", 50);
-
- createSelectAction("PageLength", category, options, "10",
- new Command<T, Integer>() {
-
- public void execute(Table t, Integer value, Object data) {
- t.setPageLength(value);
- }
- });
- }
-
- private enum SelectMode {
- NONE, SINGLE, MULTI_SIMPLE, MULTI;
- }
-
- protected void createSelectionModeSelect(String category) {
- LinkedHashMap<String, SelectMode> options = new LinkedHashMap<String, SelectMode>();
- options.put("None", SelectMode.NONE);
- options.put("Single", SelectMode.SINGLE);
- options.put("Multi - simple", SelectMode.MULTI_SIMPLE);
- options.put("Multi - ctrl/shift", SelectMode.MULTI);
-
- createSelectAction("Selection Mode", category, options,
- "Multi - ctrl/shift", new Command<T, SelectMode>() {
-
- public void execute(Table t, SelectMode value, Object data) {
- switch (value) {
- case NONE:
- t.setSelectable(false);
- break;
- case SINGLE:
- t.setMultiSelect(false);
- t.setSelectable(true);
- break;
- case MULTI_SIMPLE:
- t.setSelectable(true);
- t.setMultiSelect(true);
- t.setMultiSelectMode(MultiSelectMode.SIMPLE);
- break;
- case MULTI:
- t.setSelectable(true);
- t.setMultiSelect(true);
- t.setMultiSelectMode(MultiSelectMode.DEFAULT);
- break;
- }
- }
- });
- }
-
- public void columnResize(ColumnResizeEvent event) {
- log("ColumnResize on " + event.getPropertyId() + " from "
- + event.getPreviousWidth() + " to " + event.getCurrentWidth());
- }
-
- public void footerClick(FooterClickEvent event) {
- log("FooterClick on " + event.getPropertyId() + " using "
- + event.getButtonName());
- }
-
- public void headerClick(HeaderClickEvent event) {
- log("HeaderClick on " + event.getPropertyId() + " using "
- + event.getButtonName());
- }
-
- @Override
- protected void updateContainer() {
- super.updateContainer();
-
- // Recreate for the new properties
- createColumnOptions(false);
-
- }
-
-}
+package com.vaadin.tests.components.table;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.terminal.Resource;
+import com.vaadin.tests.components.select.AbstractSelectTestCase;
+import com.vaadin.ui.AbstractSelect.MultiSelectMode;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.CellStyleGenerator;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.Table.ColumnResizeEvent;
+import com.vaadin.ui.Table.ColumnResizeListener;
+import com.vaadin.ui.Table.FooterClickEvent;
+import com.vaadin.ui.Table.FooterClickListener;
+import com.vaadin.ui.Table.GeneratedRow;
+import com.vaadin.ui.Table.HeaderClickEvent;
+import com.vaadin.ui.Table.HeaderClickListener;
+import com.vaadin.ui.Table.RowGenerator;
+
+public class Tables<T extends Table> extends AbstractSelectTestCase<T>
+ implements ItemClickListener, HeaderClickListener, FooterClickListener,
+ ColumnResizeListener {
+
+ protected static final String CATEGORY_ROWS = "Rows";
+ private static final String CATEGORY_HEADER = "Header";
+ private static final String CATEGORY_FOOTER = "Footer";
+ private static final String CATEGORY_COLUMNS = "Columns";
+
+ @Override
+ protected Class<T> getTestClass() {
+ return (Class) Table.class;
+ }
+
+ /* COMMANDS */
+ private Command<T, String> columnAlignmentCommand = new Command<T, String>() {
+
+ public void execute(T c, String alignment, Object propertyId) {
+ c.setColumnAlignment(propertyId, alignment);
+ }
+
+ };
+
+ private Command<T, Boolean> columnVisibleCommand = new Command<T, Boolean>() {
+ public void execute(Table c, Boolean visible, Object propertyId) {
+ List<Object> visibleColumns = new ArrayList<Object>(Arrays.asList(c
+ .getVisibleColumns()));
+ if (visible) {
+ // Table should really check this... Completely fails without
+ // the check (#
+ if (!visibleColumns.contains(propertyId)) {
+ visibleColumns.add(propertyId);
+ }
+ } else {
+ visibleColumns.remove(propertyId);
+ }
+ c.setVisibleColumns(visibleColumns.toArray());
+ }
+ };
+
+ private Command<T, Boolean> columnCollapsed = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean collapsed, Object propertyId) {
+ c.setColumnCollapsed(propertyId, collapsed);
+
+ }
+ };
+
+ protected Command<T, Boolean> columnResizeListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(Table c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ColumnResizeListener) Tables.this);
+ } else {
+ c.removeListener((ColumnResizeListener) Tables.this);
+ }
+ }
+ };
+
+ protected Command<T, Boolean> headerClickListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((HeaderClickListener) Tables.this);
+ } else {
+ c.removeListener((HeaderClickListener) Tables.this);
+ }
+ }
+ };
+
+ protected Command<T, Boolean> footerClickListenerCommand = new Command<T, Boolean>() {
+
+ public void execute(Table c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((FooterClickListener) Tables.this);
+ } else {
+ c.removeListener((FooterClickListener) Tables.this);
+ }
+ }
+ };
+
+ protected Command<T, Integer> rowHeaderModeCommand = new Command<T, Integer>() {
+
+ public void execute(Table c, Integer value, Object data) {
+ if (value == Table.ROW_HEADER_MODE_PROPERTY) {
+ c.setItemCaptionPropertyId("Property 3");
+ }
+ c.setRowHeaderMode(value);
+ }
+ };
+
+ protected Command<T, String> footerTextCommand = new Command<T, String>() {
+
+ public void execute(Table c, String value, Object data) {
+ for (Object propertyId : c.getContainerPropertyIds()) {
+ if (value != null) {
+ c.setColumnFooter(propertyId,
+ value.replace("{id}", propertyId.toString()));
+ } else {
+ c.setColumnFooter(propertyId, null);
+ }
+ }
+ }
+ };
+
+ protected Command<T, Object> alignColumnLeftCommand = new Command<T, Object>() {
+
+ public void execute(T c, Object propertyId, Object data) {
+ c.setColumnAlignment(propertyId, (String) data);
+ }
+ };
+
+ private Command<T, ContextMenu> contextMenuCommand = new Command<T, ContextMenu>() {
+
+ public void execute(T c, final ContextMenu value, Object data) {
+ c.removeAllActionHandlers();
+ if (value != null) {
+ c.addActionHandler(new Handler() {
+
+ public void handleAction(Action action, Object sender,
+ Object target) {
+ log("Action " + action.getCaption() + " performed on "
+ + target);
+ }
+
+ public Action[] getActions(Object target, Object sender) {
+ return value.getActions(target, sender);
+ }
+ });
+ }
+ }
+ };
+ private Command<T, Integer> columnWidthCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer width, Object propertyId) {
+ c.setColumnWidth(propertyId, width);
+
+ }
+ };
+
+ private Command<T, Resource> columnIconCommand = new Command<T, Resource>() {
+
+ public void execute(T c, Resource icon, Object propertyId) {
+ c.setColumnIcon(propertyId, icon);
+
+ }
+ };
+ private Command<T, Integer> columnHeaderModeCommand = new Command<T, Integer>() {
+
+ public void execute(T c, Integer columnHeaderMode, Object data) {
+ c.setColumnHeaderMode(columnHeaderMode);
+
+ }
+ };
+ private Command<T, String> columnHeaderCommand = new Command<T, String>() {
+
+ public void execute(T c, String header, Object propertyId) {
+ c.setColumnHeader(propertyId, header);
+
+ }
+ };
+ private Command<T, Float> columnExpandRatioCommand = new Command<T, Float>() {
+
+ public void execute(T c, Float expandRatio, Object propertyId) {
+ c.setColumnExpandRatio(propertyId, expandRatio);
+ }
+ };
+
+ private class GeneratedColumn {
+ private Class<?> type;
+ private String width;
+ private boolean html;
+
+ public GeneratedColumn(Class<?> type, String width, boolean html) {
+ super();
+ this.type = type;
+ this.width = width;
+ this.html = html;
+ }
+ }
+
+ String generatedColumnId = "Generated ";
+ int generatedColumnNextNr = 1;
+
+ private Command<T, GeneratedColumn> addGeneratedColumnCommand = new Command<T, GeneratedColumn>() {
+
+ public void execute(T c, final GeneratedColumn col, Object data) {
+ while (c.getColumnGenerator(generatedColumnId
+ + generatedColumnNextNr) != null) {
+ generatedColumnNextNr++;
+ }
+
+ c.addGeneratedColumn(generatedColumnId + generatedColumnNextNr,
+ new ColumnGenerator() {
+
+ public Object generateCell(Table source, Object itemId,
+ Object columnId) {
+ String value = "";
+ if (col.html) {
+ value = "<i>" + itemId + "</i>" + "/" + "<b>"
+ + columnId + "</b>";
+ } else {
+ value = itemId + "/" + columnId;
+ }
+ if (col.type == Button.class) {
+ Button b = new Button();
+ b.setCaption(value);
+ b.setWidth(col.width);
+ return b;
+ } else if (col.type == Label.class) {
+ Label l = new Label();
+ l.setWidth(col.width);
+ if (col.html) {
+ l.setValue(value);
+ l.setContentMode(Label.CONTENT_XHTML);
+ } else {
+ l.setValue(value);
+ }
+ return l;
+ } else if (col.type == String.class) {
+ return value;
+ } else if (col.type == Object.class) {
+ return new Object();
+ }
+
+ return null;
+ }
+ });
+ generatedColumnNextNr++;
+ createColumnOptions(false);
+
+ }
+ };
+ private Command<T, Object> removeGeneratedColumnsCommand = new Command<T, Object>() {
+
+ public void execute(T c, Object value, Object data) {
+ for (int i = 0; i < generatedColumnNextNr; i++) {
+ String columnId = generatedColumnId + i;
+ if (c.getColumnGenerator(columnId) != null) {
+ c.removeGeneratedColumn(columnId);
+ }
+
+ }
+ createColumnOptions(false);
+
+ }
+ };
+
+ private class CellStyleInfo {
+ private final String styleName;
+ private final Object itemId;
+ private final Object propertyId;
+
+ public CellStyleInfo(String styleName, Object itemId, Object propertyId) {
+ this.styleName = styleName;
+ this.itemId = itemId;
+ this.propertyId = propertyId;
+ }
+
+ public boolean appliesTo(Object itemId, Object propertyId) {
+ return (this.itemId != null && this.itemId.equals(itemId))
+ && (this.propertyId == propertyId || (this.propertyId != null && this.propertyId
+ .equals(propertyId)));
+ }
+ }
+
+ private Command<T, CellStyleInfo> cellStyleCommand = new Command<T, CellStyleInfo>() {
+
+ public void execute(T c, final CellStyleInfo cellStyleInfo, Object data) {
+ if (cellStyleInfo == null) {
+ c.setCellStyleGenerator(null);
+ } else {
+ c.setCellStyleGenerator(new CellStyleGenerator() {
+
+ public String getStyle(Object itemId, Object propertyId) {
+ if (cellStyleInfo.appliesTo(itemId, propertyId)) {
+ return cellStyleInfo.styleName;
+ }
+ return null;
+ }
+ });
+ }
+ }
+ };
+
+ private class GeneratedRowInfo {
+
+ private final int nth;
+ private final String[] text;
+ private final boolean isHtml;
+
+ public GeneratedRowInfo(int nth, boolean isHtml, String... text) {
+ this.nth = nth;
+ this.isHtml = isHtml;
+ this.text = text;
+ }
+
+ public boolean appliesTo(Object itemId) {
+ int ix = Integer.valueOf(itemId.toString().substring(5));
+ return ix % nth == 0;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%d, %s, %s", nth, isHtml ? "true" : "false",
+ Arrays.toString(text));
+ }
+ }
+
+ private Command<T, GeneratedRowInfo> rowGeneratorCommand = new Command<T, GeneratedRowInfo>() {
+
+ public void execute(T c, final GeneratedRowInfo generatedRowInfo,
+ Object data) {
+ if (generatedRowInfo == null) {
+ c.setRowGenerator(null);
+ } else {
+ c.setRowGenerator(new RowGenerator() {
+
+ public GeneratedRow generateRow(Table table, Object itemId) {
+ if (generatedRowInfo.appliesTo(itemId)) {
+ GeneratedRow generatedRow = new GeneratedRow(
+ generatedRowInfo.text);
+ generatedRow
+ .setHtmlContentAllowed(generatedRowInfo.isHtml);
+ return generatedRow;
+ }
+ return null;
+ }
+ });
+ }
+ }
+ };
+
+ private Command<T, Boolean> setSortEnabledCommand = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setSortDisabled(!value);
+
+ }
+ };
+
+ /* COMMANDS END */
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ createPageLengthSelect(CATEGORY_SIZE);
+
+ createSelectionModeSelect(CATEGORY_SELECTION);
+ createValueSelection(CATEGORY_SELECTION);
+
+ createItemClickListener(CATEGORY_LISTENERS);
+ createColumnResizeListenerCheckbox(CATEGORY_LISTENERS);
+ createHeaderClickListenerCheckbox(CATEGORY_LISTENERS);
+ createFooterClickListenerCheckbox(CATEGORY_LISTENERS);
+
+ createRowHeaderModeSelect(CATEGORY_DATA_SOURCE);
+
+ createHeaderVisibilitySelect(CATEGORY_HEADER);
+ createHeaderTextCheckbox(CATEGORY_HEADER);
+
+ createFooterVisibilityCheckbox(CATEGORY_FOOTER);
+ createFooterTextSelect(CATEGORY_FOOTER);
+
+ createColumnReorderingAllowedCheckbox(CATEGORY_FEATURES);
+ createColumnCollapsingAllowedCheckbox(CATEGORY_FEATURES);
+
+ createContextMenuAction(CATEGORY_FEATURES);
+
+ createColumnHeaderMode(CATEGORY_FEATURES);
+ createAddGeneratedColumnAction(CATEGORY_FEATURES);
+ createCellStyleAction(CATEGORY_FEATURES);
+ createGeneratedRowAction(CATEGORY_FEATURES);
+
+ createBooleanAction("Sort enabled", CATEGORY_FEATURES, true,
+ setSortEnabledCommand);
+ createColumnOptions(true);
+ }
+
+ private void createAddGeneratedColumnAction(String categoryFeatures) {
+ String category = "Generated columns";
+ createCategory(category, categoryFeatures);
+ createClickAction("Add Button", category, addGeneratedColumnCommand,
+ new GeneratedColumn(Button.class, null, false));
+ createClickAction("Add 200px wide Button", category,
+ addGeneratedColumnCommand, new GeneratedColumn(Button.class,
+ "200px", false));
+ createClickAction("Add 100% wide Button", category,
+ addGeneratedColumnCommand, new GeneratedColumn(Button.class,
+ "100%", false));
+ createClickAction("Add Label", category, addGeneratedColumnCommand,
+ new GeneratedColumn(Label.class, null, false));
+ createClickAction("Add 100px Label", category,
+ addGeneratedColumnCommand, new GeneratedColumn(Label.class,
+ "100px", false));
+ createClickAction("Add 100% wide Label", category,
+ addGeneratedColumnCommand, new GeneratedColumn(Label.class,
+ "100%", false));
+
+ createClickAction("Remove generated columns", category,
+ removeGeneratedColumnsCommand, null);
+ createClickAction("Add string as generated column", category,
+ addGeneratedColumnCommand, new GeneratedColumn(String.class,
+ "", false));
+ createClickAction("Add HTML string as generated column", category,
+ addGeneratedColumnCommand, new GeneratedColumn(String.class,
+ "", true));
+ createClickAction("Add 100px HTML Label", category,
+ addGeneratedColumnCommand, new GeneratedColumn(Label.class,
+ "100px", true));
+ createClickAction("Add Object as generated column", category,
+ addGeneratedColumnCommand, new GeneratedColumn(Object.class,
+ "", false));
+ }
+
+ private void createCellStyleAction(String categoryFeatures) {
+ LinkedHashMap<String, CellStyleInfo> options = new LinkedHashMap<String, CellStyleInfo>();
+ options.put("None", null);
+ options.put("Red row", new CellStyleInfo(
+ "tables-test-cell-style-red-row", "Item 2", null));
+ options.put("Red cell", new CellStyleInfo(
+ "tables-test-cell-style-red-row", "Item 2", "Property 2"));
+ createSelectAction("Cell style generator", categoryFeatures, options,
+ "None", cellStyleCommand, true);
+ }
+
+ private void createGeneratedRowAction(String categoryFeatures) {
+ LinkedHashMap<String, GeneratedRowInfo> options = new LinkedHashMap<String, GeneratedRowInfo>();
+ options.put("None", null);
+ options.put("Every fifth row, spanned", new GeneratedRowInfo(5, false,
+ "foobarbaz this is a long one that should span."));
+ int props = getComponent().getContainerPropertyIds().size();
+ String[] text = new String[props];
+ for (int ix = 0; ix < props; ix++) {
+ text[ix] = "foo" + ix;
+ }
+ options.put("Every tenth row, no spanning", new GeneratedRowInfo(10,
+ false, text));
+ options.put(
+ "Every eight row, spanned, html formatted",
+ new GeneratedRowInfo(8, true,
+ "<b>foo</b> <i>bar</i> <span style='color:red;text-size:0.5em;'>baz</span>"));
+ options.put("Every row, spanned", new GeneratedRowInfo(1, false,
+ "spanned"));
+ createSelectAction("Row generator", categoryFeatures, options, "None",
+ rowGeneratorCommand, true);
+ }
+
+ private void createColumnHeaderMode(String category) {
+ LinkedHashMap<String, Integer> columnHeaderModeOptions = new LinkedHashMap<String, Integer>();
+ columnHeaderModeOptions.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
+ columnHeaderModeOptions.put("Id", Table.COLUMN_HEADER_MODE_ID);
+ columnHeaderModeOptions.put("Explicit",
+ Table.COLUMN_HEADER_MODE_EXPLICIT);
+ columnHeaderModeOptions.put("Explicit defaults id",
+ Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+
+ createSelectAction("Column header mode", category,
+ columnHeaderModeOptions, "Explicit defaults id",
+ columnHeaderModeCommand);
+ }
+
+ private void createValueSelection(String categorySelection) {
+ LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
+ options.put("null", null);
+ for (int i = 1; i <= 10; i++) {
+ options.put("Item " + i, "Item " + i);
+ }
+ createSelectAction("Value", categorySelection, options, null,
+ setValueCommand);
+ }
+
+ private void createContextMenuAction(String category) {
+ LinkedHashMap<String, ContextMenu> options = new LinkedHashMap<String, ContextMenu>();
+ options.put("None", null);
+ options.put("Item without icon", new ContextMenu("No icon", null));
+ ContextMenu cm = new ContextMenu();
+ cm.addItem("Caption only", null);
+ cm.addItem("Has icon", ICON_16_USER_PNG_UNCACHEABLE);
+ options.put("With and without icon", cm);
+ options.put("Only one large icon", new ContextMenu("Icon",
+ ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE));
+ options.put("Empty", new ContextMenu() {
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ return null;
+ }
+ });
+ options.put("Edit/New", new ContextMenu() {
+ @Override
+ public Action[] getActions(Object itemId, Object component) {
+ if (itemId == null) {
+ return new Action[] { new Action("New..."),
+ new Action("Common action") };
+ } else {
+ return new Action[] { new Action("Edit " + itemId),
+ new Action("Common action") };
+ }
+ }
+ });
+
+ createSelectAction("Context menu", category, options, "None",
+ contextMenuCommand, true);
+ }
+
+ private void createColumnReorderingAllowedCheckbox(String category) {
+ createBooleanAction("Column reordering allowed", category, true,
+ new Command<T, Boolean>() {
+ public void execute(Table c, Boolean value, Object data) {
+ c.setColumnReorderingAllowed(value);
+ }
+ });
+ }
+
+ private void createColumnCollapsingAllowedCheckbox(String category) {
+ createBooleanAction("Column collapsing allowed", category, true,
+ new Command<T, Boolean>() {
+ public void execute(T c, Boolean value, Object data) {
+ c.setColumnCollapsingAllowed(value);
+ }
+ });
+ }
+
+ private void createColumnOptions(boolean init) {
+ if (!init && !hasCategory(CATEGORY_COLUMNS)) {
+ return;
+ }
+
+ long start = System.currentTimeMillis();
+ if (!init) {
+ removeCategory(CATEGORY_COLUMNS);
+ }
+
+ for (Object id : getComponent().getContainerPropertyIds()) {
+ String name = id.toString();
+ createCategory(name, CATEGORY_COLUMNS);
+ createColumnOption(name, id);
+ }
+ for (int i = 0; i < generatedColumnNextNr; i++) {
+ String id = generatedColumnId + i;
+ String name = id;
+ if (getTestComponents().get(0).getColumnGenerator(id) != null) {
+ createCategory(name, CATEGORY_COLUMNS);
+ createColumnOption(name, id);
+ }
+ }
+
+ long end = System.currentTimeMillis();
+ System.err.println("Create options took " + (end - start) + "ms");
+ }
+
+ private class Timer {
+ private long start, last;
+
+ private Timer() {
+ start = System.currentTimeMillis();
+ last = System.currentTimeMillis();
+ }
+
+ public void log(String msg) {
+ long now = System.currentTimeMillis();
+ System.err.println("[This: " + (now - last) + "ms, total: "
+ + (now - start) + "ms]: " + msg);
+ last = now;
+ }
+ }
+
+ private void createColumnOption(String category, Object propertyId) {
+ Timer t = new Timer();
+ createBooleanAction("Visible", category, true, columnVisibleCommand,
+ propertyId);
+ t.log("Visible");
+ createBooleanAction("Collapsed", category, false, columnCollapsed,
+ propertyId);
+ t.log("Collapsed");
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("Left", Table.ALIGN_LEFT);
+ options.put("Center", Table.ALIGN_CENTER);
+ options.put("Right", Table.ALIGN_RIGHT);
+
+ createSelectAction("Alignment", category, options, "Left",
+ columnAlignmentCommand, propertyId);
+ t.log("Alignment");
+ LinkedHashMap<String, Integer> widthOptions = new LinkedHashMap<String, Integer>();
+ widthOptions.put("- remove -", -1);
+ for (int i : new int[] { 0, 1, 10, 100, 200, 400 }) {
+ widthOptions.put(i + "px", i);
+ }
+ createSelectAction("Width", category, widthOptions, "- remove -",
+ columnWidthCommand, propertyId);
+ t.log("Width");
+
+ LinkedHashMap<String, Resource> iconOptions = new LinkedHashMap<String, Resource>();
+ iconOptions.put("- none -", null);
+ iconOptions.put("ok 16x16", ICON_16_USER_PNG_CACHEABLE);
+ iconOptions.put("help 16x16", ICON_16_HELP_PNG_CACHEABLE);
+ iconOptions.put("folder 16x16", ICON_16_FOLDER_PNG_CACHEABLE);
+ iconOptions.put("attention 32x32", ICON_32_ATTENTION_PNG_CACHEABLE);
+ createSelectAction("Icon", category, iconOptions, "- none -",
+ columnIconCommand, propertyId);
+
+ t.log("Icon");
+ LinkedHashMap<String, String> columnHeaderOptions = new LinkedHashMap<String, String>();
+ columnHeaderOptions.put("- none -", null);
+ columnHeaderOptions.put("A", "A");
+ columnHeaderOptions.put("A nice column", "A nice column");
+
+ createSelectAction("Column header", category, columnHeaderOptions,
+ "- none -", columnHeaderCommand, propertyId);
+ t.log("Header");
+ LinkedHashMap<String, Float> expandOptions = new LinkedHashMap<String, Float>();
+ expandOptions.put("- remove -", -1f);
+ for (float i : new float[] { 0, 1, 2, 3, 4, 5 }) {
+ expandOptions.put(i + "", i);
+ }
+ createSelectAction("Expand ratio", category, expandOptions,
+ "- remove -", columnExpandRatioCommand, propertyId);
+ t.log("Expand");
+ // Footer text (move)
+ // Header text (move)
+
+ }
+
+ private void createRowHeaderModeSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Explicit", Table.ROW_HEADER_MODE_EXPLICIT);
+ options.put("Explicit defaults id",
+ Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+ options.put("Hidden", Table.ROW_HEADER_MODE_HIDDEN);
+ options.put("Icon only", Table.ROW_HEADER_MODE_ICON_ONLY);
+ options.put("Id", Table.ROW_HEADER_MODE_ID);
+ options.put("Index", Table.ROW_HEADER_MODE_INDEX);
+ options.put("Item", Table.ROW_HEADER_MODE_ITEM);
+ options.put("'Property 3' property", Table.ROW_HEADER_MODE_PROPERTY);
+
+ createSelectAction("Row header mode", category, options, "Hidden",
+ rowHeaderModeCommand);
+ }
+
+ private void createFooterTextSelect(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("None", null);
+ options.put("Footer X", "Footer {id}");
+ options.put("X", "{id}");
+
+ createSelectAction("Texts in footer", category, options, "None",
+ footerTextCommand);
+ }
+
+ private void createHeaderTextCheckbox(String category) {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("None", null);
+ options.put("Col: {id}", "Col: {id}");
+ options.put("Header {id} - every second", "Header {id}");
+
+ createSelectAction("Texts in header", category, options, "None",
+ new Command<T, String>() {
+ public void execute(T c, String value, Object data) {
+ int nr = 0;
+ for (Object propertyId : c.getContainerPropertyIds()) {
+ nr++;
+ if (value != null && value.equals("Header {id}")
+ && nr % 2 == 0) {
+ c.setColumnHeader(propertyId, null);
+ } else if (value != null) {
+ c.setColumnHeader(
+ propertyId,
+ value.replace("{id}",
+ propertyId.toString()));
+ } else {
+ c.setColumnHeader(propertyId, null);
+ }
+ }
+
+ }
+ });
+ }
+
+ private void createHeaderClickListenerCheckbox(String category) {
+
+ createBooleanAction("Header click listener", category, false,
+ headerClickListenerCommand);
+ }
+
+ private void createFooterClickListenerCheckbox(String category) {
+
+ createBooleanAction("Footer click listener", category, false,
+ footerClickListenerCommand);
+ }
+
+ private void createColumnResizeListenerCheckbox(String category) {
+
+ createBooleanAction("Column resize listener", category, false,
+ columnResizeListenerCommand);
+ }
+
+ // TODO:
+ // setCurrentPageFirstItemIndex()
+ // Editable
+ // Cache rate
+ // CurrentPageFirstItemId
+
+ protected void createFooterVisibilityCheckbox(String category) {
+ createBooleanAction("Footer visible", category, true,
+ new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.setFooterVisible(value);
+ }
+ });
+ }
+
+ protected void createHeaderVisibilitySelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Explicit", Table.COLUMN_HEADER_MODE_EXPLICIT);
+ options.put("Explicit defaults id",
+ Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+ options.put("Id", Table.COLUMN_HEADER_MODE_ID);
+ options.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
+
+ createSelectAction("Header mode", category, options,
+ "Explicit defaults id", new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.setColumnHeaderMode(value);
+
+ }
+ });
+ }
+
+ protected void createPageLengthSelect(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ options.put("5", 5);
+ options.put("10", 10);
+ options.put("20", 20);
+ options.put("50", 50);
+
+ createSelectAction("PageLength", category, options, "10",
+ new Command<T, Integer>() {
+
+ public void execute(Table t, Integer value, Object data) {
+ t.setPageLength(value);
+ }
+ });
+ }
+
+ private enum SelectMode {
+ NONE, SINGLE, MULTI_SIMPLE, MULTI;
+ }
+
+ protected void createSelectionModeSelect(String category) {
+ LinkedHashMap<String, SelectMode> options = new LinkedHashMap<String, SelectMode>();
+ options.put("None", SelectMode.NONE);
+ options.put("Single", SelectMode.SINGLE);
+ options.put("Multi - simple", SelectMode.MULTI_SIMPLE);
+ options.put("Multi - ctrl/shift", SelectMode.MULTI);
+
+ createSelectAction("Selection Mode", category, options,
+ "Multi - ctrl/shift", new Command<T, SelectMode>() {
+
+ public void execute(Table t, SelectMode value, Object data) {
+ switch (value) {
+ case NONE:
+ t.setSelectable(false);
+ break;
+ case SINGLE:
+ t.setMultiSelect(false);
+ t.setSelectable(true);
+ break;
+ case MULTI_SIMPLE:
+ t.setSelectable(true);
+ t.setMultiSelect(true);
+ t.setMultiSelectMode(MultiSelectMode.SIMPLE);
+ break;
+ case MULTI:
+ t.setSelectable(true);
+ t.setMultiSelect(true);
+ t.setMultiSelectMode(MultiSelectMode.DEFAULT);
+ break;
+ }
+ }
+ });
+ }
+
+ public void columnResize(ColumnResizeEvent event) {
+ log("ColumnResize on " + event.getPropertyId() + " from "
+ + event.getPreviousWidth() + " to " + event.getCurrentWidth());
+ }
+
+ public void footerClick(FooterClickEvent event) {
+ log("FooterClick on " + event.getPropertyId() + " using "
+ + event.getButtonName());
+ }
+
+ public void headerClick(HeaderClickEvent event) {
+ log("HeaderClick on " + event.getPropertyId() + " using "
+ + event.getButtonName());
+ }
+
+ @Override
+ protected void updateContainer() {
+ super.updateContainer();
+
+ // Recreate for the new properties
+ createColumnOptions(false);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
index 9c3b2de3e0..1733b15e80 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
@@ -1,60 +1,60 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.Application;
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TestCurrentPageFirstItem extends Application implements
- ClickListener {
-
- private Button buttonIndex;
- private Button buttonItem;
- private Table table;
- private int counter = 0;
- IndexedContainer container = new IndexedContainer();
-
- @Override
- public void init() {
- try {
- Window main = new Window("Table header Test");
- setMainWindow(main);
- main.setSizeFull();
- // setTheme("testtheme");
- VerticalLayout baseLayout = new VerticalLayout();
- main.setContent(baseLayout);
-
- table = new Table();
- container.addContainerProperty("row", String.class, "");
- table.setContainerDataSource(container);
- table.setWidth("100%");
- table.setPageLength(3);
- buttonIndex = new Button("Add row and select last index", this);
- buttonItem = new Button("Add row and select last item", this);
-
- baseLayout.addComponent(table);
- baseLayout.addComponent(buttonIndex);
- baseLayout.addComponent(buttonItem);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void buttonClick(ClickEvent event) {
- Item item = container.addItem(++counter);
- item.getItemProperty("row").setValue(counter + "");
- table.select(counter);
- if (event.getButton() == buttonIndex) {
- table.setCurrentPageFirstItemIndex(((Container.Indexed) table
- .getContainerDataSource()).indexOfId(counter));
- } else {
- table.setCurrentPageFirstItemId(counter);
- }
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.Application;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TestCurrentPageFirstItem extends Application implements
+ ClickListener {
+
+ private Button buttonIndex;
+ private Button buttonItem;
+ private Table table;
+ private int counter = 0;
+ IndexedContainer container = new IndexedContainer();
+
+ @Override
+ public void init() {
+ try {
+ Window main = new Window("Table header Test");
+ setMainWindow(main);
+ main.setSizeFull();
+ // setTheme("testtheme");
+ VerticalLayout baseLayout = new VerticalLayout();
+ main.setContent(baseLayout);
+
+ table = new Table();
+ container.addContainerProperty("row", String.class, "");
+ table.setContainerDataSource(container);
+ table.setWidth("100%");
+ table.setPageLength(3);
+ buttonIndex = new Button("Add row and select last index", this);
+ buttonItem = new Button("Add row and select last item", this);
+
+ baseLayout.addComponent(table);
+ baseLayout.addComponent(buttonIndex);
+ baseLayout.addComponent(buttonItem);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Item item = container.addItem(++counter);
+ item.getItemProperty("row").setValue(counter + "");
+ table.select(counter);
+ if (event.getButton() == buttonIndex) {
+ table.setCurrentPageFirstItemIndex(((Container.Indexed) table
+ .getContainerDataSource()).indexOfId(counter));
+ } else {
+ table.setCurrentPageFirstItemId(counter);
+ }
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java b/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java
index 13ca9f8cf3..865a50c5f7 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TextFieldRelativeWidth.java
@@ -1,129 +1,129 @@
-package com.vaadin.tests.components.table;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-
-public class TextFieldRelativeWidth extends TestBase {
-
- @Override
- public void setup() {
- TextField tf = new TextField("test", "testing");
- tf.setWidth("100%");
-
- EditTable t = new EditTable();
- t.setButtonCaption("Click to add new Key Research Question");
- t.setInputPrompt("Key Reseach question");
- t.setInputPromptChild("Question details");
- t.addNewRow();
- addComponent(t);
- }
-
- public class EditTable extends Table implements Button.ClickListener {
-
- private Button addButton = new Button("Add new row",
- (Button.ClickListener) this);
-
- private String inputPrompt;
-
- private String inputPromptChild;
-
- private int nextItemIndex = 1;
-
- private static final long serialVersionUID = 3326806911297977454L;
-
- public EditTable() {
- setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
- inputPrompt = "";
- setPageLength(100);
- setHeight("100%");
- setSizeFull();
- addContainerProperty("id", Integer.class, null);
- addContainerProperty("text", Component.class, null);
- addContainerProperty("button", Button.class, null);
- setColumnExpandRatio("text", 1);
- Item i = getItem(addItem());
- i.getItemProperty("text").setValue(addButton);
- setImmediate(true);
- setSelectable(true);
- addListener(new Property.ValueChangeListener() {
- private static final long serialVersionUID = 448896474865195605L;
-
- public void valueChange(
- com.vaadin.data.Property.ValueChangeEvent event) {
- // IndexedContainer idc = (IndexedContainer)
- // getContainerDataSource();
-
- }
-
- });
- }
-
- public void addNewRow() {
- IndexedContainer idc = (IndexedContainer) getContainerDataSource();
- int size = idc.size();
- Object itemId = idc.addItemAt(size - 1);
- Item newItem = idc.getItem(itemId);
- TextField tf = new TextField();
- if (inputPrompt != null && inputPrompt.length() > 0) {
- tf.setInputPrompt(inputPrompt);
- }
- tf.setWidth("100%");
-
- newItem.getItemProperty("id").setValue(nextItemIndex);
- nextItemIndex++;
- newItem.getItemProperty("text").setValue(tf);
- setValue(itemId);
- itemId = idc.addItemAt(size);
- newItem = idc.getItem(itemId);
-
- tf = new TextField();
- if (inputPromptChild != null && inputPromptChild.length() > 0) {
- tf.setInputPrompt(inputPromptChild);
- }
- // tf.setRows(1);
- // tf.setHeight("45px");
- tf.setWidth("100%");
- tf.addStyleName("childtf");
- newItem.getItemProperty("text").setValue(tf);
-
- }
-
- public void setButtonCaption(String caption) {
- addButton.setCaption(caption);
- }
-
- public void buttonClick(ClickEvent event) {
- Button b = event.getButton();
- if (b == addButton) {
- select(getNullSelectionItemId());
- addNewRow();
- }
- }
-
- public void setInputPrompt(String string) {
- inputPrompt = string;
- }
-
- public void setInputPromptChild(String string) {
- inputPromptChild = string;
- }
-
- }
-
- @Override
- protected String getDescription() {
- return "The table has 3 columns. The second column is expanded and contains 100% wide textfields. These should fill the available space. The third column is empty.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3145;
- }
-}
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+
+public class TextFieldRelativeWidth extends TestBase {
+
+ @Override
+ public void setup() {
+ TextField tf = new TextField("test", "testing");
+ tf.setWidth("100%");
+
+ EditTable t = new EditTable();
+ t.setButtonCaption("Click to add new Key Research Question");
+ t.setInputPrompt("Key Reseach question");
+ t.setInputPromptChild("Question details");
+ t.addNewRow();
+ addComponent(t);
+ }
+
+ public class EditTable extends Table implements Button.ClickListener {
+
+ private Button addButton = new Button("Add new row",
+ (Button.ClickListener) this);
+
+ private String inputPrompt;
+
+ private String inputPromptChild;
+
+ private int nextItemIndex = 1;
+
+ private static final long serialVersionUID = 3326806911297977454L;
+
+ public EditTable() {
+ setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
+ inputPrompt = "";
+ setPageLength(100);
+ setHeight("100%");
+ setSizeFull();
+ addContainerProperty("id", Integer.class, null);
+ addContainerProperty("text", Component.class, null);
+ addContainerProperty("button", Button.class, null);
+ setColumnExpandRatio("text", 1);
+ Item i = getItem(addItem());
+ i.getItemProperty("text").setValue(addButton);
+ setImmediate(true);
+ setSelectable(true);
+ addListener(new Property.ValueChangeListener() {
+ private static final long serialVersionUID = 448896474865195605L;
+
+ public void valueChange(
+ com.vaadin.data.Property.ValueChangeEvent event) {
+ // IndexedContainer idc = (IndexedContainer)
+ // getContainerDataSource();
+
+ }
+
+ });
+ }
+
+ public void addNewRow() {
+ IndexedContainer idc = (IndexedContainer) getContainerDataSource();
+ int size = idc.size();
+ Object itemId = idc.addItemAt(size - 1);
+ Item newItem = idc.getItem(itemId);
+ TextField tf = new TextField();
+ if (inputPrompt != null && inputPrompt.length() > 0) {
+ tf.setInputPrompt(inputPrompt);
+ }
+ tf.setWidth("100%");
+
+ newItem.getItemProperty("id").setValue(nextItemIndex);
+ nextItemIndex++;
+ newItem.getItemProperty("text").setValue(tf);
+ setValue(itemId);
+ itemId = idc.addItemAt(size);
+ newItem = idc.getItem(itemId);
+
+ tf = new TextField();
+ if (inputPromptChild != null && inputPromptChild.length() > 0) {
+ tf.setInputPrompt(inputPromptChild);
+ }
+ // tf.setRows(1);
+ // tf.setHeight("45px");
+ tf.setWidth("100%");
+ tf.addStyleName("childtf");
+ newItem.getItemProperty("text").setValue(tf);
+
+ }
+
+ public void setButtonCaption(String caption) {
+ addButton.setCaption(caption);
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Button b = event.getButton();
+ if (b == addButton) {
+ select(getNullSelectionItemId());
+ addNewRow();
+ }
+ }
+
+ public void setInputPrompt(String string) {
+ inputPrompt = string;
+ }
+
+ public void setInputPromptChild(String string) {
+ inputPromptChild = string;
+ }
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The table has 3 columns. The second column is expanded and contains 100% wide textfields. These should fill the available space. The third column is empty.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3145;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/RemoveTabs.java b/tests/testbench/com/vaadin/tests/components/tabsheet/RemoveTabs.java
index 8602a9a3b4..1cd96c5c4c 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/RemoveTabs.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/RemoveTabs.java
@@ -1,145 +1,145 @@
-package com.vaadin.tests.components.tabsheet;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbstractComponentContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-
-public class RemoveTabs extends TestBase {
-
- protected TabSheet tabsheet;
-
- protected Component[] tab = new Component[5];
-
- private Button closeCurrent;
- private Button closeCurrentWithTab;
- private Button closeFirst;
- private Button closeLast;
- private Button reorderTabs;
-
- @Override
- protected Integer getTicketNumber() {
- return 2425;
- }
-
- @Override
- protected String getDescription() {
- return "Tests the removal of individual tabs from a Tabsheet. No matter what is done in this test the tab caption \"Tab X\" should always match the content \"Tab X\". Use \"remove first\" and \"remove active\" buttons to remove the first or the active tab. The \"reorder\" button reverses the order by adding and removing all components.";
- }
-
- @Override
- protected void setup() {
- tabsheet = new TabSheet();
- for (int i = 1; i <= tab.length; i++) {
- tab[i - 1] = new Label("This is the contents of tab " + i);
- tab[i - 1].setCaption("Tab " + i);
-
- tabsheet.addComponent(tab[i - 1]);
- }
-
- getLayout().addComponent(tabsheet);
-
- closeCurrent = new Button("Close current tab");
- closeCurrent.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeCurrentTab();
-
- }
- });
-
- closeCurrentWithTab = new Button("Close current tab with Tab");
- closeCurrentWithTab.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeCurrentTabWithTab();
-
- }
- });
-
- closeFirst = new Button("close first tab");
- closeFirst.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeFirstTab();
-
- }
- });
-
- closeLast = new Button("close last tab");
- closeLast.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- closeLastTab();
-
- }
- });
-
- reorderTabs = new Button("reorder");
- reorderTabs.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- reorder();
-
- }
- });
-
- getLayout().addComponent(closeFirst);
- getLayout().addComponent(closeLast);
- getLayout().addComponent(closeCurrent);
- getLayout().addComponent(closeCurrentWithTab);
- getLayout().addComponent(reorderTabs);
-
- }
-
- private void closeCurrentTab() {
- Component c = tabsheet.getSelectedTab();
- if (c != null) {
- tabsheet.removeComponent(c);
- }
- }
-
- private void closeCurrentTabWithTab() {
- Component c = tabsheet.getSelectedTab();
- if (c != null) {
- Tab t = tabsheet.getTab(c);
- tabsheet.removeTab(t);
- }
- }
-
- private void closeFirstTab() {
- tabsheet.removeComponent(tabsheet.getComponentIterator().next());
- }
-
- private void closeLastTab() {
- Iterator<Component> i = tabsheet.getComponentIterator();
- Component last = null;
- while (i.hasNext()) {
- last = i.next();
-
- }
- tabsheet.removeComponent(last);
- }
-
- private void reorder() {
- AbstractComponentContainer container = tabsheet;
-
- if (container != null) {
- List<Component> c = new ArrayList<Component>();
- Iterator<Component> i = container.getComponentIterator();
- while (i.hasNext()) {
- Component comp = i.next();
- c.add(comp);
- }
- container.removeAllComponents();
-
- for (int j = c.size() - 1; j >= 0; j--) {
- container.addComponent(c.get(j));
- }
-
- }
- }
-}
+package com.vaadin.tests.components.tabsheet;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractComponentContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class RemoveTabs extends TestBase {
+
+ protected TabSheet tabsheet;
+
+ protected Component[] tab = new Component[5];
+
+ private Button closeCurrent;
+ private Button closeCurrentWithTab;
+ private Button closeFirst;
+ private Button closeLast;
+ private Button reorderTabs;
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2425;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests the removal of individual tabs from a Tabsheet. No matter what is done in this test the tab caption \"Tab X\" should always match the content \"Tab X\". Use \"remove first\" and \"remove active\" buttons to remove the first or the active tab. The \"reorder\" button reverses the order by adding and removing all components.";
+ }
+
+ @Override
+ protected void setup() {
+ tabsheet = new TabSheet();
+ for (int i = 1; i <= tab.length; i++) {
+ tab[i - 1] = new Label("This is the contents of tab " + i);
+ tab[i - 1].setCaption("Tab " + i);
+
+ tabsheet.addComponent(tab[i - 1]);
+ }
+
+ getLayout().addComponent(tabsheet);
+
+ closeCurrent = new Button("Close current tab");
+ closeCurrent.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeCurrentTab();
+
+ }
+ });
+
+ closeCurrentWithTab = new Button("Close current tab with Tab");
+ closeCurrentWithTab.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeCurrentTabWithTab();
+
+ }
+ });
+
+ closeFirst = new Button("close first tab");
+ closeFirst.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeFirstTab();
+
+ }
+ });
+
+ closeLast = new Button("close last tab");
+ closeLast.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ closeLastTab();
+
+ }
+ });
+
+ reorderTabs = new Button("reorder");
+ reorderTabs.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ reorder();
+
+ }
+ });
+
+ getLayout().addComponent(closeFirst);
+ getLayout().addComponent(closeLast);
+ getLayout().addComponent(closeCurrent);
+ getLayout().addComponent(closeCurrentWithTab);
+ getLayout().addComponent(reorderTabs);
+
+ }
+
+ private void closeCurrentTab() {
+ Component c = tabsheet.getSelectedTab();
+ if (c != null) {
+ tabsheet.removeComponent(c);
+ }
+ }
+
+ private void closeCurrentTabWithTab() {
+ Component c = tabsheet.getSelectedTab();
+ if (c != null) {
+ Tab t = tabsheet.getTab(c);
+ tabsheet.removeTab(t);
+ }
+ }
+
+ private void closeFirstTab() {
+ tabsheet.removeComponent(tabsheet.getComponentIterator().next());
+ }
+
+ private void closeLastTab() {
+ Iterator<Component> i = tabsheet.getComponentIterator();
+ Component last = null;
+ while (i.hasNext()) {
+ last = i.next();
+
+ }
+ tabsheet.removeComponent(last);
+ }
+
+ private void reorder() {
+ AbstractComponentContainer container = tabsheet;
+
+ if (container != null) {
+ List<Component> c = new ArrayList<Component>();
+ Iterator<Component> i = container.getComponentIterator();
+ while (i.hasNext()) {
+ Component comp = i.next();
+ c.add(comp);
+ }
+ container.removeAllComponents();
+
+ for (int j = c.size() - 1; j >= 0; j--) {
+ container.addComponent(c.get(j));
+ }
+
+ }
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java
index 8449dd42bf..3d8d02b8b6 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetCaptions.java
@@ -1,64 +1,64 @@
-package com.vaadin.tests.components.tabsheet;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TabSheet;
-
-public class TabSheetCaptions extends TestBase {
-
- Panel panel1;
-
- @Override
- protected String getDescription() {
- return "Updating the tabsheet tab text should not change the caption of the component. Click on the button to change the tab text. This must update the tab and not touch the Panel's caption.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2846;
- }
-
- @Override
- protected void setup() {
- final TabSheet tabSheet = new TabSheet();
- // Define date and locale so that it doesn't change for machine/time
- final SimpleDateFormat dateFormatter = new SimpleDateFormat(
- "EEE, yyyy-MMM-dd", Locale.ENGLISH);
- final Date date = new Date();
- date.setTime((long) 1000000000000.0);
-
- panel1 = new Panel("Panel initial caption (should also be tab caption)");
- panel1.setSizeFull();
- panel1.getContent().setSizeFull();
- panel1.addComponent(new Label("This is a panel"));
- tabSheet.addTab(panel1);
-
- Button button = new Button("Update tab caption");
- button.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- tabSheet.getTab(panel1).setCaption(
- "This is a new tab caption "
- + dateFormatter.format(date));
- }
- });
-
- Button button2 = new Button("Update panel caption");
- button2.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- panel1.setCaption("This is a new panel caption "
- + dateFormatter.format(date));
- }
- });
-
- addComponent(tabSheet);
- addComponent(button);
- addComponent(button2);
- }
-}
+package com.vaadin.tests.components.tabsheet;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TabSheet;
+
+public class TabSheetCaptions extends TestBase {
+
+ Panel panel1;
+
+ @Override
+ protected String getDescription() {
+ return "Updating the tabsheet tab text should not change the caption of the component. Click on the button to change the tab text. This must update the tab and not touch the Panel's caption.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2846;
+ }
+
+ @Override
+ protected void setup() {
+ final TabSheet tabSheet = new TabSheet();
+ // Define date and locale so that it doesn't change for machine/time
+ final SimpleDateFormat dateFormatter = new SimpleDateFormat(
+ "EEE, yyyy-MMM-dd", Locale.ENGLISH);
+ final Date date = new Date();
+ date.setTime((long) 1000000000000.0);
+
+ panel1 = new Panel("Panel initial caption (should also be tab caption)");
+ panel1.setSizeFull();
+ panel1.getContent().setSizeFull();
+ panel1.addComponent(new Label("This is a panel"));
+ tabSheet.addTab(panel1);
+
+ Button button = new Button("Update tab caption");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ tabSheet.getTab(panel1).setCaption(
+ "This is a new tab caption "
+ + dateFormatter.format(date));
+ }
+ });
+
+ Button button2 = new Button("Update panel caption");
+ button2.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ panel1.setCaption("This is a new panel caption "
+ + dateFormatter.format(date));
+ }
+ });
+
+ addComponent(tabSheet);
+ addComponent(button);
+ addComponent(button2);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java
index 4f4ab836ed..bdce3e83d0 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDisabling.java
@@ -1,62 +1,62 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.TabSheet;
-
-public class TabSheetDisabling extends TestBase {
-
- private static final int NR_BUTTONS = 10;
- private Button buttons[] = new Button[NR_BUTTONS];
- private TabSheet tabSheet;
-
- @Override
- public void setup() {
- tabSheet = new TabSheet();
- for (int i = 0; i < NR_BUTTONS; i++) {
- if (i % 2 == 0) {
- buttons[i] = new Button("Disable this tab",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Button b = event.getButton();
- tabSheet.getTab(b).setEnabled(false);
-
- }
-
- });
- } else {
- buttons[i] = new Button("Hide this tab", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Button b = event.getButton();
- tabSheet.getTab(b).setVisible(false);
- }
-
- });
- }
- tabSheet.addTab(buttons[i]);
- }
-
- Button button = new Button("Enable/disable", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- tabSheet.setEnabled(!tabSheet.isEnabled());
- }
- });
- addComponent(tabSheet);
- addComponent(button);
- }
-
- @Override
- protected String getDescription() {
- return "Switching the tabsheet between disabled and enabled should not change which tab is selected. Disabling the open tab should select the first enabled tab.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2658;
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TabSheet;
+
+public class TabSheetDisabling extends TestBase {
+
+ private static final int NR_BUTTONS = 10;
+ private Button buttons[] = new Button[NR_BUTTONS];
+ private TabSheet tabSheet;
+
+ @Override
+ public void setup() {
+ tabSheet = new TabSheet();
+ for (int i = 0; i < NR_BUTTONS; i++) {
+ if (i % 2 == 0) {
+ buttons[i] = new Button("Disable this tab",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Button b = event.getButton();
+ tabSheet.getTab(b).setEnabled(false);
+
+ }
+
+ });
+ } else {
+ buttons[i] = new Button("Hide this tab", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Button b = event.getButton();
+ tabSheet.getTab(b).setVisible(false);
+ }
+
+ });
+ }
+ tabSheet.addTab(buttons[i]);
+ }
+
+ Button button = new Button("Enable/disable", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ tabSheet.setEnabled(!tabSheet.isEnabled());
+ }
+ });
+ addComponent(tabSheet);
+ addComponent(button);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Switching the tabsheet between disabled and enabled should not change which tab is selected. Disabling the open tab should select the first enabled tab.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2658;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
index 34b5dc86c8..410172ddb0 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
@@ -1,52 +1,52 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TextField;
-
-public class TabSheetDiscardsMovedComponents extends TestBase {
-
- private GridLayout grid = new GridLayout();
- private TabSheet tabSheet = new TabSheet();
-
- @Override
- public void setup() {
- tabSheet.addTab(new Label("The tabSheet"), "Initial content");
- tabSheet.setSizeUndefined();
-
- grid.setColumns(2);
- TextField textField = new TextField("Text field");
- textField.setValue("Text");
- addTestComponent(textField);
- addTestComponent(new Button("Button"));
-
- addComponent(tabSheet);
- addComponent(grid);
- }
-
- private void addTestComponent(final Component component) {
- grid.addComponent(component);
- grid.addComponent(new Button("Move to tab", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- tabSheet.addTab(component);
- grid.removeComponent(event.getButton());
- }
- }));
- }
-
- @Override
- protected String getDescription() {
- return "Moving an already rendered component to a tabsheet and not immediately selecting the new tab should cause no problems";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2669;
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextField;
+
+public class TabSheetDiscardsMovedComponents extends TestBase {
+
+ private GridLayout grid = new GridLayout();
+ private TabSheet tabSheet = new TabSheet();
+
+ @Override
+ public void setup() {
+ tabSheet.addTab(new Label("The tabSheet"), "Initial content");
+ tabSheet.setSizeUndefined();
+
+ grid.setColumns(2);
+ TextField textField = new TextField("Text field");
+ textField.setValue("Text");
+ addTestComponent(textField);
+ addTestComponent(new Button("Button"));
+
+ addComponent(tabSheet);
+ addComponent(grid);
+ }
+
+ private void addTestComponent(final Component component) {
+ grid.addComponent(component);
+ grid.addComponent(new Button("Move to tab", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ tabSheet.addTab(component);
+ grid.removeComponent(event.getButton());
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Moving an already rendered component to a tabsheet and not immediately selecting the new tab should cause no problems";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2669;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetIcons.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetIcons.java
index 49c9784eb9..2e334a836e 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetIcons.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetIcons.java
@@ -1,54 +1,54 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TextField;
-
-public class TabSheetIcons extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Tests rendering of a Tabsheet with fixed/dynamic width when the TabSheet contains icons";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- @Override
- protected void setup() {
- TabSheet ts1 = createTabsheet();
- ts1.setHeight("100px");
- TabSheet ts2 = createTabsheet();
- ts2.setHeight("100px");
- ts2.setWidth("400px");
-
- addComponent(ts1);
- addComponent(ts2);
- }
-
- private TabSheet createTabsheet() {
- TabSheet tabsheet = new TabSheet();
- tabsheet.setSizeUndefined();
-
- Component[] tab = new Component[3];
- tab[0] = new Label("This is tab 1");
- tab[0].setIcon(new ThemeResource("../runo/icons/32/folder-add.png"));
- tab[0].setCaption("tab number 1");
- tab[1] = new TextField("This is tab 2", "Contents of tab 2 textfield");
- tab[2] = new Label("This is tab 3");
- tab[2].setIcon(new ThemeResource("../runo/icons/16/folder-add.png"));
- tab[2].setCaption("tab number 3");
-
- for (Component c : tab) {
- tabsheet.addTab(c);
- }
-
- return tabsheet;
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextField;
+
+public class TabSheetIcons extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Tests rendering of a Tabsheet with fixed/dynamic width when the TabSheet contains icons";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+ @Override
+ protected void setup() {
+ TabSheet ts1 = createTabsheet();
+ ts1.setHeight("100px");
+ TabSheet ts2 = createTabsheet();
+ ts2.setHeight("100px");
+ ts2.setWidth("400px");
+
+ addComponent(ts1);
+ addComponent(ts2);
+ }
+
+ private TabSheet createTabsheet() {
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setSizeUndefined();
+
+ Component[] tab = new Component[3];
+ tab[0] = new Label("This is tab 1");
+ tab[0].setIcon(new ThemeResource("../runo/icons/32/folder-add.png"));
+ tab[0].setCaption("tab number 1");
+ tab[1] = new TextField("This is tab 2", "Contents of tab 2 textfield");
+ tab[2] = new Label("This is tab 3");
+ tab[2].setIcon(new ThemeResource("../runo/icons/16/folder-add.png"));
+ tab[2].setCaption("tab number 3");
+
+ for (Component c : tab) {
+ tabsheet.addTab(c);
+ }
+
+ return tabsheet;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java
index db647f7110..105b4149a1 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetMinimal.java
@@ -1,39 +1,39 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-
-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;
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+
+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/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabStyleNames.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabStyleNames.java
index 5c806b2ac2..3c3dec478c 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabStyleNames.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabStyleNames.java
@@ -1,51 +1,51 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-
-public class TabSheetTabStyleNames extends TestBase {
-
- private static final String STYLE_NAME = "TabSheetTabStyleNames";
-
- @Override
- public void setup() {
- setTheme("tests-tickets");
-
- TabSheet tabsheet = new TabSheet();
- final Tab tab1 = tabsheet.addTab(new Label(), "Tab 1");
- final Tab tab2 = tabsheet.addTab(new Label(), "Tab 2");
-
- tab1.setStyleName(STYLE_NAME);
-
- addComponent(new Button("Update style names",
- new Button.ClickListener() {
- int counter = 0;
-
- public void buttonClick(ClickEvent event) {
- if (tab1.getStyleName() == null) {
- tab1.setStyleName(STYLE_NAME);
- } else {
- tab1.setStyleName(null);
- }
-
- tab2.setStyleName(STYLE_NAME + "_" + (counter++));
- }
- }));
-
- addComponent(tabsheet);
- }
-
- @Override
- protected String getDescription() {
- return "Tests setting style names for individual tabs.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5880;
- }
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class TabSheetTabStyleNames extends TestBase {
+
+ private static final String STYLE_NAME = "TabSheetTabStyleNames";
+
+ @Override
+ public void setup() {
+ setTheme("tests-tickets");
+
+ TabSheet tabsheet = new TabSheet();
+ final Tab tab1 = tabsheet.addTab(new Label(), "Tab 1");
+ final Tab tab2 = tabsheet.addTab(new Label(), "Tab 2");
+
+ tab1.setStyleName(STYLE_NAME);
+
+ addComponent(new Button("Update style names",
+ new Button.ClickListener() {
+ int counter = 0;
+
+ public void buttonClick(ClickEvent event) {
+ if (tab1.getStyleName() == null) {
+ tab1.setStyleName(STYLE_NAME);
+ } else {
+ tab1.setStyleName(null);
+ }
+
+ tab2.setStyleName(STYLE_NAME + "_" + (counter++));
+ }
+ }));
+
+ addComponent(tabsheet);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests setting style names for individual tabs.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5880;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabTheming.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabTheming.java
index 94b49d4ae0..7d9a65b868 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabTheming.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTabTheming.java
@@ -1,27 +1,27 @@
-package com.vaadin.tests.components.tabsheet;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-
-public class TabSheetTabTheming extends TestBase {
-
- @Override
- public void setup() {
- TabSheet tabsheet = new TabSheet();
- tabsheet.setStyleName("pg");
- tabsheet.addTab(new Label(), "Brown fox and the fence", null);
- tabsheet.addTab(new Label(), "Something about using all the keys", null);
- addComponent(tabsheet);
- setTheme("tests-tickets");
- }
-
- @Override
- protected String getDescription() {
- return "Changing tabs should not cause flickering, cut text or text that moves back and forth.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6781;
- }
+package com.vaadin.tests.components.tabsheet;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+
+public class TabSheetTabTheming extends TestBase {
+
+ @Override
+ public void setup() {
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setStyleName("pg");
+ tabsheet.addTab(new Label(), "Brown fox and the fence", null);
+ tabsheet.addTab(new Label(), "Something about using all the keys", null);
+ addComponent(tabsheet);
+ setTheme("tests-tickets");
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Changing tabs should not cause flickering, cut text or text that moves back and forth.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6781;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTest.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTest.java
index bbbe92f069..1c5c63dcd4 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTest.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabSheetTest.java
@@ -1,202 +1,202 @@
-package com.vaadin.tests.components.tabsheet;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.terminal.Resource;
-import com.vaadin.tests.components.AbstractComponentContainerTest;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.CloseHandler;
-import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
-import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
-import com.vaadin.ui.TabSheet.Tab;
-
-public class TabSheetTest<T extends TabSheet> extends
- AbstractComponentContainerTest<T> implements SelectedTabChangeListener {
-
- private Command<T, Integer> setTabCaption = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.getTab(value).setCaption((String) data);
-
- }
- };
- private Command<T, Integer> setTabIcon = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.getTab(value).setIcon((Resource) data);
-
- }
- };
- private Command<T, Integer> setTabClosable = new Command<T, Integer>() {
-
- public void execute(T c, Integer value, Object data) {
- c.getTab(value).setClosable((Boolean) data);
- }
- };
- private Command<T, Boolean> setCloseHandlerListener = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.setCloseHandler(new CloseHandler() {
- public void onTabClose(TabSheet tabsheet, Component c) {
- tabClosed(tabsheet, tabsheet.getTab(c));
- tabsheet.removeComponent(c);
- }
-
- });
- } else {
- c.setCloseHandler(new CloseHandler() {
- public void onTabClose(TabSheet tabsheet, Component c) {
- tabsheet.removeComponent(c);
- }
- });
- }
-
- }
- };
- private Command<T, Boolean> setSelectedTabListener = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- if (value) {
- c.addListener((SelectedTabChangeListener) TabSheetTest.this);
- } else {
- c.removeListener((SelectedTabChangeListener) TabSheetTest.this);
- }
-
- }
- };
-
- private Command<T, Integer> selectTab = new Command<T, Integer>() {
- public void execute(T c, Integer index, Object data) {
- c.setSelectedTab(c.getTab(index).getComponent());
- }
- };
- private Command<T, Boolean> hideTabs = new Command<T, Boolean>() {
-
- public void execute(T c, Boolean value, Object data) {
- c.hideTabs(value);
-
- }
- };
-
- @Override
- protected Class<T> getTestClass() {
- return (Class<T>) TabSheet.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createSetTabCaptionIcon(CATEGORY_FEATURES);
- createSelectTab(CATEGORY_FEATURES);
- createClosableToggle(CATEGORY_FEATURES);
- createCloseHandlerToggle(CATEGORY_LISTENERS);
- createSelectListenerToggle(CATEGORY_LISTENERS);
- createHideTabsToggle(CATEGORY_FEATURES);
-
- // TODO
- // Insert tab at x
-
- }
-
- private void createHideTabsToggle(String category) {
- createBooleanAction("Hide tabs", category, false, hideTabs);
-
- }
-
- private void createSelectListenerToggle(String category) {
- createBooleanAction("Selected tab listener", category, false,
- setSelectedTabListener);
-
- }
-
- private void createCloseHandlerToggle(String category) {
- createBooleanAction("Close event listener (handler)", category, false,
- setCloseHandlerListener);
-
- }
-
- private void createClosableToggle(String category) {
- String closableCategory = "Set tab closable";
- createCategory(closableCategory, category);
- for (int i = 0; i < 20; i++) {
- String tabClosableCategory = "Tab " + i + " closable";
-
- createCategory(tabClosableCategory, closableCategory);
- createClickAction("true", tabClosableCategory, setTabClosable, i,
- true);
- createClickAction("false", tabClosableCategory, setTabClosable, i,
- false);
-
- }
- }
-
- private void createSelectTab(String category) {
- String selectTabCategory = "Select tab";
- createCategory(selectTabCategory, category);
- for (int i = 0; i < 20; i++) {
- createClickAction("Select tab " + i, selectTabCategory, selectTab,
- i);
-
- }
- }
-
- private void createSetTabCaptionIcon(String category) {
- String captionCategory = "Set tab caption";
- String iconCategory = "Set tab icon";
- createCategory(captionCategory, category);
- createCategory(iconCategory, category);
-
- String captionOptions[] = new String[] { "", "{id}", "Tab {id}",
- "A long caption for tab {id}" };
- LinkedHashMap<String, Resource> iconOptions = new LinkedHashMap<String, Resource>();
- iconOptions.put("-", null);
- iconOptions.put("16x16 (cachable)", ICON_16_USER_PNG_CACHEABLE);
- iconOptions.put("16x16 (uncachable)", ICON_16_USER_PNG_UNCACHEABLE);
- iconOptions.put("32x32 (cachable)", ICON_32_ATTENTION_PNG_CACHEABLE);
- iconOptions
- .put("32x32 (uncachable)", ICON_32_ATTENTION_PNG_UNCACHEABLE);
- iconOptions.put("64x64 (cachable)", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
- iconOptions.put("64x64 (uncachable)",
- ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE);
-
- for (int i = 0; i < 20; i++) {
- String tabCaptionCategory = "Tab " + i + " caption";
- String tabIconCategory = "Tab " + i + " icon";
-
- createCategory(tabCaptionCategory, captionCategory);
- createCategory(tabIconCategory, iconCategory);
-
- createClickAction("(null)", tabCaptionCategory, setTabCaption,
- Integer.valueOf(i), null);
- createClickAction("(null)", tabIconCategory, setTabIcon,
- Integer.valueOf(i), null);
-
- for (String option : captionOptions) {
- option = option.replace("{id}", String.valueOf(i));
- createClickAction(option, tabCaptionCategory, setTabCaption,
- Integer.valueOf(i), option);
- }
-
- for (String option : iconOptions.keySet()) {
- Resource icon = iconOptions.get(option);
- createClickAction(option, tabIconCategory, setTabIcon,
- Integer.valueOf(i), icon);
- }
-
- }
-
- }
-
- private void tabClosed(TabSheet tabSheet, Tab tab) {
- log("Tab " + tabSheet.getTabPosition(tab) + " closed");
- }
-
- public void selectedTabChange(SelectedTabChangeEvent event) {
- TabSheet ts = event.getTabSheet();
- log("Tab " + ts.getTabPosition(ts.getTab(ts.getSelectedTab()))
- + " selected");
-
- }
-}
+package com.vaadin.tests.components.tabsheet;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.terminal.Resource;
+import com.vaadin.tests.components.AbstractComponentContainerTest;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.CloseHandler;
+import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
+import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class TabSheetTest<T extends TabSheet> extends
+ AbstractComponentContainerTest<T> implements SelectedTabChangeListener {
+
+ private Command<T, Integer> setTabCaption = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.getTab(value).setCaption((String) data);
+
+ }
+ };
+ private Command<T, Integer> setTabIcon = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.getTab(value).setIcon((Resource) data);
+
+ }
+ };
+ private Command<T, Integer> setTabClosable = new Command<T, Integer>() {
+
+ public void execute(T c, Integer value, Object data) {
+ c.getTab(value).setClosable((Boolean) data);
+ }
+ };
+ private Command<T, Boolean> setCloseHandlerListener = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.setCloseHandler(new CloseHandler() {
+ public void onTabClose(TabSheet tabsheet, Component c) {
+ tabClosed(tabsheet, tabsheet.getTab(c));
+ tabsheet.removeComponent(c);
+ }
+
+ });
+ } else {
+ c.setCloseHandler(new CloseHandler() {
+ public void onTabClose(TabSheet tabsheet, Component c) {
+ tabsheet.removeComponent(c);
+ }
+ });
+ }
+
+ }
+ };
+ private Command<T, Boolean> setSelectedTabListener = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((SelectedTabChangeListener) TabSheetTest.this);
+ } else {
+ c.removeListener((SelectedTabChangeListener) TabSheetTest.this);
+ }
+
+ }
+ };
+
+ private Command<T, Integer> selectTab = new Command<T, Integer>() {
+ public void execute(T c, Integer index, Object data) {
+ c.setSelectedTab(c.getTab(index).getComponent());
+ }
+ };
+ private Command<T, Boolean> hideTabs = new Command<T, Boolean>() {
+
+ public void execute(T c, Boolean value, Object data) {
+ c.hideTabs(value);
+
+ }
+ };
+
+ @Override
+ protected Class<T> getTestClass() {
+ return (Class<T>) TabSheet.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createSetTabCaptionIcon(CATEGORY_FEATURES);
+ createSelectTab(CATEGORY_FEATURES);
+ createClosableToggle(CATEGORY_FEATURES);
+ createCloseHandlerToggle(CATEGORY_LISTENERS);
+ createSelectListenerToggle(CATEGORY_LISTENERS);
+ createHideTabsToggle(CATEGORY_FEATURES);
+
+ // TODO
+ // Insert tab at x
+
+ }
+
+ private void createHideTabsToggle(String category) {
+ createBooleanAction("Hide tabs", category, false, hideTabs);
+
+ }
+
+ private void createSelectListenerToggle(String category) {
+ createBooleanAction("Selected tab listener", category, false,
+ setSelectedTabListener);
+
+ }
+
+ private void createCloseHandlerToggle(String category) {
+ createBooleanAction("Close event listener (handler)", category, false,
+ setCloseHandlerListener);
+
+ }
+
+ private void createClosableToggle(String category) {
+ String closableCategory = "Set tab closable";
+ createCategory(closableCategory, category);
+ for (int i = 0; i < 20; i++) {
+ String tabClosableCategory = "Tab " + i + " closable";
+
+ createCategory(tabClosableCategory, closableCategory);
+ createClickAction("true", tabClosableCategory, setTabClosable, i,
+ true);
+ createClickAction("false", tabClosableCategory, setTabClosable, i,
+ false);
+
+ }
+ }
+
+ private void createSelectTab(String category) {
+ String selectTabCategory = "Select tab";
+ createCategory(selectTabCategory, category);
+ for (int i = 0; i < 20; i++) {
+ createClickAction("Select tab " + i, selectTabCategory, selectTab,
+ i);
+
+ }
+ }
+
+ private void createSetTabCaptionIcon(String category) {
+ String captionCategory = "Set tab caption";
+ String iconCategory = "Set tab icon";
+ createCategory(captionCategory, category);
+ createCategory(iconCategory, category);
+
+ String captionOptions[] = new String[] { "", "{id}", "Tab {id}",
+ "A long caption for tab {id}" };
+ LinkedHashMap<String, Resource> iconOptions = new LinkedHashMap<String, Resource>();
+ iconOptions.put("-", null);
+ iconOptions.put("16x16 (cachable)", ICON_16_USER_PNG_CACHEABLE);
+ iconOptions.put("16x16 (uncachable)", ICON_16_USER_PNG_UNCACHEABLE);
+ iconOptions.put("32x32 (cachable)", ICON_32_ATTENTION_PNG_CACHEABLE);
+ iconOptions
+ .put("32x32 (uncachable)", ICON_32_ATTENTION_PNG_UNCACHEABLE);
+ iconOptions.put("64x64 (cachable)", ICON_64_EMAIL_REPLY_PNG_CACHEABLE);
+ iconOptions.put("64x64 (uncachable)",
+ ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE);
+
+ for (int i = 0; i < 20; i++) {
+ String tabCaptionCategory = "Tab " + i + " caption";
+ String tabIconCategory = "Tab " + i + " icon";
+
+ createCategory(tabCaptionCategory, captionCategory);
+ createCategory(tabIconCategory, iconCategory);
+
+ createClickAction("(null)", tabCaptionCategory, setTabCaption,
+ Integer.valueOf(i), null);
+ createClickAction("(null)", tabIconCategory, setTabIcon,
+ Integer.valueOf(i), null);
+
+ for (String option : captionOptions) {
+ option = option.replace("{id}", String.valueOf(i));
+ createClickAction(option, tabCaptionCategory, setTabCaption,
+ Integer.valueOf(i), option);
+ }
+
+ for (String option : iconOptions.keySet()) {
+ Resource icon = iconOptions.get(option);
+ createClickAction(option, tabIconCategory, setTabIcon,
+ Integer.valueOf(i), icon);
+ }
+
+ }
+
+ }
+
+ private void tabClosed(TabSheet tabSheet, Tab tab) {
+ log("Tab " + tabSheet.getTabPosition(tab) + " closed");
+ }
+
+ public void selectedTabChange(SelectedTabChangeEvent event) {
+ TabSheet ts = event.getTabSheet();
+ log("Tab " + ts.getTabPosition(ts.getTab(ts.getSelectedTab()))
+ + " selected");
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
index ac460dafbb..2b1669bff0 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
@@ -1,59 +1,59 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TabsheetNPE extends AbstractTestCase implements ClickListener {
-
- @Override
- protected String getDescription() {
- return "Enable and activate tab should enable and activate the first tab.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3292;
- }
-
- private static final int TABS_COUNT = 3;
- private TabSheet tabSheet;
- private Label[] label = new Label[TABS_COUNT];
- private Tab[] tab = new Tab[TABS_COUNT];
-
- @Override
- public void init() {
- setMainWindow(new Window("TabSheet Demo", createMainLayout()));
- }
-
- private VerticalLayout createMainLayout() {
- VerticalLayout layout = new VerticalLayout();
-
- tabSheet = new TabSheet();
- for (int i = 1; i <= TABS_COUNT; i++) {
- label[i - 1] = new Label("Tab " + i);
- tab[i - 1] = tabSheet.addTab(label[i - 1], "Tab " + i, null);
- tab[i - 1].setEnabled(false);
- }
-
- layout.addComponent(tabSheet);
- Button btn = new Button("Enable and activate tab");
- btn.addListener(this);
- layout.addComponent(btn);
- return layout;
- }
-
- public void buttonClick(ClickEvent event) {
- for (int i = 0; i < TABS_COUNT; i++) {
- tab[i].setEnabled(true);
- }
- tabSheet.setSelectedTab(label[0]);
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TabsheetNPE extends AbstractTestCase implements ClickListener {
+
+ @Override
+ protected String getDescription() {
+ return "Enable and activate tab should enable and activate the first tab.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3292;
+ }
+
+ private static final int TABS_COUNT = 3;
+ private TabSheet tabSheet;
+ private Label[] label = new Label[TABS_COUNT];
+ private Tab[] tab = new Tab[TABS_COUNT];
+
+ @Override
+ public void init() {
+ setMainWindow(new Window("TabSheet Demo", createMainLayout()));
+ }
+
+ private VerticalLayout createMainLayout() {
+ VerticalLayout layout = new VerticalLayout();
+
+ tabSheet = new TabSheet();
+ for (int i = 1; i <= TABS_COUNT; i++) {
+ label[i - 1] = new Label("Tab " + i);
+ tab[i - 1] = tabSheet.addTab(label[i - 1], "Tab " + i, null);
+ tab[i - 1].setEnabled(false);
+ }
+
+ layout.addComponent(tabSheet);
+ Button btn = new Button("Enable and activate tab");
+ btn.addListener(this);
+ layout.addComponent(btn);
+ return layout;
+ }
+
+ public void buttonClick(ClickEvent event) {
+ for (int i = 0; i < TABS_COUNT; i++) {
+ tab[i].setEnabled(true);
+ }
+ tabSheet.setSelectedTab(label[0]);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java
index 0880b57eed..5321b51f9c 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetScrolling.java
@@ -1,74 +1,74 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-
-public class TabsheetScrolling extends TestBase {
-
- private TabSheet fixedSizeTabSheet;
- private TabSheet autoWideTabSheet;
-
- @Override
- protected void setup() {
- fixedSizeTabSheet = new TabSheet();
- fixedSizeTabSheet.setHeight("200px");
- fixedSizeTabSheet.setWidth("400px");
-
- for (int i = 0; i < 100; i++) {
- Button b = new Button("Hide this tab (" + i + ")",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- fixedSizeTabSheet.getTab(event.getButton())
- .setVisible(false);
- }
-
- });
- Tab t = fixedSizeTabSheet.addTab(b, "Tab " + i, null);
- if (i % 2 == 0) {
- t.setVisible(false);
- }
- }
-
- addComponent(fixedSizeTabSheet);
-
- autoWideTabSheet = new TabSheet();
- autoWideTabSheet.setHeight("200px");
- autoWideTabSheet.setWidth(null);
-
- for (int i = 0; i < 10; i++) {
- Button b = new Button("Hide this tab (" + i + ")",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- autoWideTabSheet.getTab(event.getButton())
- .setVisible(false);
- }
- });
-
- Tab t = autoWideTabSheet.addTab(b, "Tab " + i, null);
- if (i % 2 == 0) {
- t.setVisible(false);
-
- }
- }
-
- addComponent(autoWideTabSheet);
-
- }
-
- @Override
- protected String getDescription() {
- return "Two tabsheets, upper has fixed width, lower has dynamic width. Every other tab in both tabsheets are hidden (even numbered tabs). Scrolling the upper tab sheet should never display a hidden tab. Hiding a tab in the upper tabsheet should not affect scrolling. Hiding a tab in the lower tabsheet should make the tabsheet width change (auto wide).";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3141;
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+
+public class TabsheetScrolling extends TestBase {
+
+ private TabSheet fixedSizeTabSheet;
+ private TabSheet autoWideTabSheet;
+
+ @Override
+ protected void setup() {
+ fixedSizeTabSheet = new TabSheet();
+ fixedSizeTabSheet.setHeight("200px");
+ fixedSizeTabSheet.setWidth("400px");
+
+ for (int i = 0; i < 100; i++) {
+ Button b = new Button("Hide this tab (" + i + ")",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ fixedSizeTabSheet.getTab(event.getButton())
+ .setVisible(false);
+ }
+
+ });
+ Tab t = fixedSizeTabSheet.addTab(b, "Tab " + i, null);
+ if (i % 2 == 0) {
+ t.setVisible(false);
+ }
+ }
+
+ addComponent(fixedSizeTabSheet);
+
+ autoWideTabSheet = new TabSheet();
+ autoWideTabSheet.setHeight("200px");
+ autoWideTabSheet.setWidth(null);
+
+ for (int i = 0; i < 10; i++) {
+ Button b = new Button("Hide this tab (" + i + ")",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ autoWideTabSheet.getTab(event.getButton())
+ .setVisible(false);
+ }
+ });
+
+ Tab t = autoWideTabSheet.addTab(b, "Tab " + i, null);
+ if (i % 2 == 0) {
+ t.setVisible(false);
+
+ }
+ }
+
+ addComponent(autoWideTabSheet);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Two tabsheets, upper has fixed width, lower has dynamic width. Every other tab in both tabsheets are hidden (even numbered tabs). Scrolling the upper tab sheet should never display a hidden tab. Hiding a tab in the upper tabsheet should not affect scrolling. Hiding a tab in the lower tabsheet should make the tabsheet width change (auto wide).";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3141;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java b/tests/testbench/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java
index b6e00a1e59..66d19f6935 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/VerticalScrollbarPosition.java
@@ -1,40 +1,40 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-
-public class VerticalScrollbarPosition extends TestBase {
-
- @Override
- protected String getDescription() {
- return "A vertical scrollbar in a TabSheet should always be placed at the right edge";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2473;
- }
-
- @Override
- protected void setup() {
- TabSheet tabsheet = new TabSheet();
- tabsheet.setWidth(null);
- tabsheet.setHeight("200px");
- TextArea tf = new TextArea();
- tf.setRows(2);
- tf.setHeight("300px");
- tf.setWidth("200px");
- tabsheet.addTab(
- tf,
- "A text field that is 200px wide, the tab bar for the tabsheet is wider",
- null);
- TextField tf2 = new TextField("Another tab", "b");
- tf2.setWidth("1000px");
- tf2.setHeight("50px");
- tabsheet.addTab(tf2);
- addComponent(tabsheet);
- }
-
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+
+public class VerticalScrollbarPosition extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "A vertical scrollbar in a TabSheet should always be placed at the right edge";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2473;
+ }
+
+ @Override
+ protected void setup() {
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setWidth(null);
+ tabsheet.setHeight("200px");
+ TextArea tf = new TextArea();
+ tf.setRows(2);
+ tf.setHeight("300px");
+ tf.setWidth("200px");
+ tabsheet.addTab(
+ tf,
+ "A text field that is 200px wide, the tab bar for the tabsheet is wider",
+ null);
+ TextField tf2 = new TextField("Another tab", "b");
+ tf2.setWidth("1000px");
+ tf2.setHeight("50px");
+ tabsheet.addTab(tf2);
+ addComponent(tabsheet);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
index e5947576a2..869b981ac1 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.components.tabsheet;
-
-import com.vaadin.Application;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class WrapTabSheetInTabSheet extends TestBase {
- @Override
- protected void setup() {
- final VerticalLayout mainLayout = new VerticalLayout();
- mainLayout.addComponent(new Label("This is main layout"));
- addComponent(mainLayout);
-
- Button b = new Button("Wrap main layout in a TabSheet");
- b.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- TabSheet tabsheet = new TabSheet();
- ComponentContainer mainParent = (ComponentContainer) mainLayout
- .getParent();
- mainParent.replaceComponent(mainLayout, tabsheet);
- tabsheet.addTab(mainLayout, "Default tab");
- }
- });
- mainLayout.addComponent(b);
- }
-
- @Override
- protected String getDescription() {
- return "Click the button to add a TabSheet and move the window content into the TabSheet. Every click should wrap the contents with a new TabSheet and the contents should remain visible.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 8238;
- }
-}
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.Application;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class WrapTabSheetInTabSheet extends TestBase {
+ @Override
+ protected void setup() {
+ final VerticalLayout mainLayout = new VerticalLayout();
+ mainLayout.addComponent(new Label("This is main layout"));
+ addComponent(mainLayout);
+
+ Button b = new Button("Wrap main layout in a TabSheet");
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ TabSheet tabsheet = new TabSheet();
+ ComponentContainer mainParent = (ComponentContainer) mainLayout
+ .getParent();
+ mainParent.replaceComponent(mainLayout, tabsheet);
+ tabsheet.addTab(mainLayout, "Default tab");
+ }
+ });
+ mainLayout.addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the button to add a TabSheet and move the window content into the TabSheet. Every click should wrap the contents with a new TabSheet and the contents should remain visible.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8238;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textarea/TextAreaTest.java b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaTest.java
index 8d7b6b3dc9..278d14e43d 100644
--- a/tests/testbench/com/vaadin/tests/components/textarea/TextAreaTest.java
+++ b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaTest.java
@@ -1,43 +1,43 @@
-package com.vaadin.tests.components.textarea;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
-import com.vaadin.ui.TextArea;
-
-public class TextAreaTest extends AbstractTextFieldTest<TextArea> {
-
- private Command<TextArea, Boolean> wordwrapCommand = new Command<TextArea, Boolean>() {
- public void execute(TextArea c, Boolean value, Object data) {
- c.setWordwrap(value);
- }
- };
-
- private Command<TextArea, Integer> rowsCommand = new Command<TextArea, Integer>() {
- public void execute(TextArea c, Integer value, Object data) {
- c.setRows(value);
- }
- };
-
- @Override
- protected Class<TextArea> getTestClass() {
- return TextArea.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createWordwrapAction(CATEGORY_FEATURES);
- createRowsAction(CATEGORY_FEATURES);
- }
-
- private void createRowsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Rows", category, options, "3", rowsCommand);
- }
-
- private void createWordwrapAction(String category) {
- createBooleanAction("Wordwrap", category, false, wordwrapCommand);
- }
-
-}
+package com.vaadin.tests.components.textarea;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
+import com.vaadin.ui.TextArea;
+
+public class TextAreaTest extends AbstractTextFieldTest<TextArea> {
+
+ private Command<TextArea, Boolean> wordwrapCommand = new Command<TextArea, Boolean>() {
+ public void execute(TextArea c, Boolean value, Object data) {
+ c.setWordwrap(value);
+ }
+ };
+
+ private Command<TextArea, Integer> rowsCommand = new Command<TextArea, Integer>() {
+ public void execute(TextArea c, Integer value, Object data) {
+ c.setRows(value);
+ }
+ };
+
+ @Override
+ protected Class<TextArea> getTestClass() {
+ return TextArea.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createWordwrapAction(CATEGORY_FEATURES);
+ createRowsAction(CATEGORY_FEATURES);
+ }
+
+ private void createRowsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Rows", category, options, "3", rowsCommand);
+ }
+
+ private void createWordwrapAction(String category) {
+ createBooleanAction("Wordwrap", category, false, wordwrapCommand);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textarea/Wordwrap.java b/tests/testbench/com/vaadin/tests/components/textarea/Wordwrap.java
index 9a443ea757..b33a1a4765 100644
--- a/tests/testbench/com/vaadin/tests/components/textarea/Wordwrap.java
+++ b/tests/testbench/com/vaadin/tests/components/textarea/Wordwrap.java
@@ -1,59 +1,59 @@
-package com.vaadin.tests.components.textarea;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.LoremIpsum;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.TextArea;
-
-public class Wordwrap extends TestBase {
-
- @Override
- public void setup() {
- HorizontalLayout layout = new HorizontalLayout();
-
- TextArea area1 = new TextArea("Wrapping");
- area1.setWordwrap(true); // The default
- area1.setValue(LoremIpsum.get(50) + "\n" + "Another row");
-
- final TextArea area2 = new TextArea("Nonwrapping");
- area2.setWordwrap(false);
- area2.setValue(LoremIpsum.get(50) + "\n" + "Another row");
-
- layout.addComponent(area1);
- layout.addComponent(area2);
- layout.setSpacing(true);
-
- addComponent(layout);
-
- CheckBox onoff = new CheckBox("Wrap state for the right field");
- onoff.setValue(false);
- onoff.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- boolean wrap = (Boolean) event.getProperty().getValue();
- area2.setWordwrap(wrap);
- if (wrap) {
- area2.setCaption("Wrapping");
- } else {
- area2.setCaption("Nonwrapping");
- }
-
- }
- });
- onoff.setImmediate(true);
-
- addComponent(onoff);
- }
-
- @Override
- protected String getDescription() {
- return "";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6003;
- }
-}
+package com.vaadin.tests.components.textarea;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.LoremIpsum;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextArea;
+
+public class Wordwrap extends TestBase {
+
+ @Override
+ public void setup() {
+ HorizontalLayout layout = new HorizontalLayout();
+
+ TextArea area1 = new TextArea("Wrapping");
+ area1.setWordwrap(true); // The default
+ area1.setValue(LoremIpsum.get(50) + "\n" + "Another row");
+
+ final TextArea area2 = new TextArea("Nonwrapping");
+ area2.setWordwrap(false);
+ area2.setValue(LoremIpsum.get(50) + "\n" + "Another row");
+
+ layout.addComponent(area1);
+ layout.addComponent(area2);
+ layout.setSpacing(true);
+
+ addComponent(layout);
+
+ CheckBox onoff = new CheckBox("Wrap state for the right field");
+ onoff.setValue(false);
+ onoff.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ boolean wrap = (Boolean) event.getProperty().getValue();
+ area2.setWordwrap(wrap);
+ if (wrap) {
+ area2.setCaption("Wrapping");
+ } else {
+ area2.setCaption("Nonwrapping");
+ }
+
+ }
+ });
+ onoff.setImmediate(true);
+
+ addComponent(onoff);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6003;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/IE6Cursor.java b/tests/testbench/com/vaadin/tests/components/textfield/IE6Cursor.java
index ed25567921..eb3d3fdd51 100644
--- a/tests/testbench/com/vaadin/tests/components/textfield/IE6Cursor.java
+++ b/tests/testbench/com/vaadin/tests/components/textfield/IE6Cursor.java
@@ -1,28 +1,28 @@
-package com.vaadin.tests.components.textfield;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.TextField;
-
-public class IE6Cursor extends TestBase {
-
- @Override
- protected void setup() {
- TextField tf1 = new TextField("First");
- TextField tf2 = new TextField("Second");
- tf2.setInputPrompt("prompt");
-
- addComponent(tf1);
- addComponent(tf2);
- }
-
- @Override
- protected String getDescription() {
- return "Tabbing from the first field to the second should clear the second textfield and show the normal, blinking cursor in the field";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3343;
- }
-
-}
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.TextField;
+
+public class IE6Cursor extends TestBase {
+
+ @Override
+ protected void setup() {
+ TextField tf1 = new TextField("First");
+ TextField tf2 = new TextField("Second");
+ tf2.setInputPrompt("prompt");
+
+ addComponent(tf1);
+ addComponent(tf2);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tabbing from the first field to the second should clear the second textfield and show the normal, blinking cursor in the field";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3343;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java
index 451bc03f05..4fb91db973 100644
--- a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java
+++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java
@@ -1,34 +1,34 @@
-package com.vaadin.tests.components.textfield;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-@SuppressWarnings("serial")
-public class TextFieldInLayoutInTable extends Application {
-
- @Override
- public void init() {
-
- final Window mainWindow = new Window(this.getClass().getName());
- setMainWindow(mainWindow);
-
- final Table table = new Table();
- table.addContainerProperty("column1", Component.class, null);
- final Panel panel = new Panel("Panel");
- ((VerticalLayout) panel.getContent()).setMargin(false);
- VerticalLayout vl = new VerticalLayout();
- final TextField textField = new TextField();
- vl.addComponent(textField);
-
- table.addItem(new Object[] { vl }, 1);
-
- table.setSizeFull();
- mainWindow.addComponent(table);
- }
-
-}
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+@SuppressWarnings("serial")
+public class TextFieldInLayoutInTable extends Application {
+
+ @Override
+ public void init() {
+
+ final Window mainWindow = new Window(this.getClass().getName());
+ setMainWindow(mainWindow);
+
+ final Table table = new Table();
+ table.addContainerProperty("column1", Component.class, null);
+ final Panel panel = new Panel("Panel");
+ ((VerticalLayout) panel.getContent()).setMargin(false);
+ VerticalLayout vl = new VerticalLayout();
+ final TextField textField = new TextField();
+ vl.addComponent(textField);
+
+ table.addItem(new Object[] { vl }, 1);
+
+ table.setSizeFull();
+ mainWindow.addComponent(table);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldTest.java b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldTest.java
index 81b753d6e4..bc7a6fcf76 100644
--- a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldTest.java
@@ -1,59 +1,59 @@
-package com.vaadin.tests.components.textfield;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.event.FieldEvents.TextChangeListener;
-import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
-import com.vaadin.ui.TextField;
-
-public class TextFieldTest extends AbstractTextFieldTest<TextField> implements
- TextChangeListener {
-
- private Command<TextField, Boolean> secretCommand = new Command<TextField, Boolean>() {
- @SuppressWarnings("deprecation")
- public void execute(TextField c, Boolean value, Object data) {
- c.setSecret(value);
- }
- };
-
- private Command<TextField, Boolean> wordwrapCommand = new Command<TextField, Boolean>() {
- @SuppressWarnings("deprecation")
- public void execute(TextField c, Boolean value, Object data) {
- c.setWordwrap(value);
- }
- };
-
- private Command<TextField, Integer> rowsCommand = new Command<TextField, Integer>() {
- @SuppressWarnings("deprecation")
- public void execute(TextField c, Integer value, Object data) {
- c.setRows(value);
- }
- };
-
- @Override
- protected Class<TextField> getTestClass() {
- return TextField.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createSecretAction(CATEGORY_FEATURES);
- createWordwrapAction(CATEGORY_FEATURES);
- createRowsAction(CATEGORY_FEATURES);
- }
-
- private void createRowsAction(String category) {
- LinkedHashMap<String, Integer> options = createIntegerOptions(20);
- createSelectAction("Rows", category, options, "0", rowsCommand);
- }
-
- private void createSecretAction(String category) {
- createBooleanAction("Secret", category, false, secretCommand);
- }
-
- private void createWordwrapAction(String category) {
- createBooleanAction("Wordwrap", category, false, wordwrapCommand);
- }
-
-}
+package com.vaadin.tests.components.textfield;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.components.abstractfield.AbstractTextFieldTest;
+import com.vaadin.ui.TextField;
+
+public class TextFieldTest extends AbstractTextFieldTest<TextField> implements
+ TextChangeListener {
+
+ private Command<TextField, Boolean> secretCommand = new Command<TextField, Boolean>() {
+ @SuppressWarnings("deprecation")
+ public void execute(TextField c, Boolean value, Object data) {
+ c.setSecret(value);
+ }
+ };
+
+ private Command<TextField, Boolean> wordwrapCommand = new Command<TextField, Boolean>() {
+ @SuppressWarnings("deprecation")
+ public void execute(TextField c, Boolean value, Object data) {
+ c.setWordwrap(value);
+ }
+ };
+
+ private Command<TextField, Integer> rowsCommand = new Command<TextField, Integer>() {
+ @SuppressWarnings("deprecation")
+ public void execute(TextField c, Integer value, Object data) {
+ c.setRows(value);
+ }
+ };
+
+ @Override
+ protected Class<TextField> getTestClass() {
+ return TextField.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createSecretAction(CATEGORY_FEATURES);
+ createWordwrapAction(CATEGORY_FEATURES);
+ createRowsAction(CATEGORY_FEATURES);
+ }
+
+ private void createRowsAction(String category) {
+ LinkedHashMap<String, Integer> options = createIntegerOptions(20);
+ createSelectAction("Rows", category, options, "0", rowsCommand);
+ }
+
+ private void createSecretAction(String category) {
+ createBooleanAction("Secret", category, false, secretCommand);
+ }
+
+ private void createWordwrapAction(String category) {
+ createBooleanAction("Wordwrap", category, false, wordwrapCommand);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeContainerChange.java b/tests/testbench/com/vaadin/tests/components/tree/TreeContainerChange.java
index f33bbae7b5..df2682a14c 100644
--- a/tests/testbench/com/vaadin/tests/components/tree/TreeContainerChange.java
+++ b/tests/testbench/com/vaadin/tests/components/tree/TreeContainerChange.java
@@ -1,101 +1,101 @@
-package com.vaadin.tests.components.tree;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Tree;
-
-@SuppressWarnings("serial")
-public class TreeContainerChange extends TestBase {
-
- private Tree tree;
-
- @Override
- protected void setup() {
- final IndexedContainer ds1 = new IndexedContainer();
- // ds1.addContainerProperty("caption", String.class, "");
- for (int i = 0; i < 32; i++) {
- ds1.addItem("ds1-" + i);
- }
-
- final IndexedContainer ds2 = new IndexedContainer();
- // ds2.addContainerProperty("caption", String.class, "");
- for (int i = 0; i < 32; i++) {
- ds2.addItem("ds2-" + i);
- }
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.setWidth("100%");
-
- tree = new Tree();
- tree.setImmediate(true);
- hl.addComponent(tree);
- HorizontalLayout state = new HorizontalLayout();
- state.setSpacing(true);
- hl.addComponent(state);
-
- final Label currentValue = new Label();
- currentValue.setCaption("Current Value:");
- currentValue.setSizeUndefined();
- final Label currentDS = new Label();
- currentDS.setCaption("Current DS:");
- currentDS.setSizeUndefined();
- state.addComponent(currentValue);
- state.addComponent(currentDS);
-
- Table t = new Table("ds1");
- t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- t.setContainerDataSource(ds1);
- state.addComponent(t);
-
- Button b = new Button("Use ds1");
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tree.setContainerDataSource(ds1);
- currentDS.setValue("ds1");
- }
- });
- state.addComponent(b);
-
- t = new Table("ds2");
- t.setContainerDataSource(ds2);
- t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- state.addComponent(t);
-
- b = new Button("Use ds2");
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- tree.setContainerDataSource(ds2);
- currentDS.setValue("ds2");
- }
- });
- state.addComponent(b);
-
- addComponent(hl);
-
- tree.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- currentValue.setValue(event.getProperty().getValue());
- }
- });
- }
-
- @Override
- protected String getDescription() {
- return "A test for tree and its container changes. Value should be cleared on container change.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5281;
- }
-
-}
+package com.vaadin.tests.components.tree;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Tree;
+
+@SuppressWarnings("serial")
+public class TreeContainerChange extends TestBase {
+
+ private Tree tree;
+
+ @Override
+ protected void setup() {
+ final IndexedContainer ds1 = new IndexedContainer();
+ // ds1.addContainerProperty("caption", String.class, "");
+ for (int i = 0; i < 32; i++) {
+ ds1.addItem("ds1-" + i);
+ }
+
+ final IndexedContainer ds2 = new IndexedContainer();
+ // ds2.addContainerProperty("caption", String.class, "");
+ for (int i = 0; i < 32; i++) {
+ ds2.addItem("ds2-" + i);
+ }
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setWidth("100%");
+
+ tree = new Tree();
+ tree.setImmediate(true);
+ hl.addComponent(tree);
+ HorizontalLayout state = new HorizontalLayout();
+ state.setSpacing(true);
+ hl.addComponent(state);
+
+ final Label currentValue = new Label();
+ currentValue.setCaption("Current Value:");
+ currentValue.setSizeUndefined();
+ final Label currentDS = new Label();
+ currentDS.setCaption("Current DS:");
+ currentDS.setSizeUndefined();
+ state.addComponent(currentValue);
+ state.addComponent(currentDS);
+
+ Table t = new Table("ds1");
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ t.setContainerDataSource(ds1);
+ state.addComponent(t);
+
+ Button b = new Button("Use ds1");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tree.setContainerDataSource(ds1);
+ currentDS.setValue("ds1");
+ }
+ });
+ state.addComponent(b);
+
+ t = new Table("ds2");
+ t.setContainerDataSource(ds2);
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ state.addComponent(t);
+
+ b = new Button("Use ds2");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ tree.setContainerDataSource(ds2);
+ currentDS.setValue("ds2");
+ }
+ });
+ state.addComponent(b);
+
+ addComponent(hl);
+
+ tree.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentValue.setValue(event.getProperty().getValue());
+ }
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A test for tree and its container changes. Value should be cleared on container change.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5281;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java b/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java
index ff1ac96e26..e69e5f50f9 100644
--- a/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java
+++ b/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java
@@ -1,126 +1,126 @@
-package com.vaadin.tests.components.tree;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Tree;
-
-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 CheckBox filterType = new CheckBox(
- "Include parent when filtering", true);
- filterType.setImmediate(true);
- filterType.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- cont.setIncludeParentsWhenFiltering(((CheckBox) event
- .getProperty()).booleanValue());
- ccTree.requestRepaint();
- }
- });
- addComponent(filterType);
-
- 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 num2 = new Button("Add filter '0-'", new ClickListener() {
- public void buttonClick(final ClickEvent event) {
- cont.addContainerFilter("caption", "0-", true, false);
-
- }
- });
-
- addComponent(num2);
- final Button num3 = new Button("Add filter 'Number 4'",
- new ClickListener() {
- public void buttonClick(final ClickEvent event) {
- cont.addContainerFilter("caption", "Number 4", true,
- false);
-
- }
- });
-
- addComponent(num3);
- final Button p1 = new Button("Set Number 3 parent to Number 0",
- new ClickListener() {
- public void buttonClick(final ClickEvent event) {
- cont.setParent(3, 0);
-
- }
- });
- addComponent(p1);
- final Button r = new Button("Remove filters", 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;
- }
-
+package com.vaadin.tests.components.tree;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Tree;
+
+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 CheckBox filterType = new CheckBox(
+ "Include parent when filtering", true);
+ filterType.setImmediate(true);
+ filterType.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ cont.setIncludeParentsWhenFiltering(((CheckBox) event
+ .getProperty()).booleanValue());
+ ccTree.requestRepaint();
+ }
+ });
+ addComponent(filterType);
+
+ 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 num2 = new Button("Add filter '0-'", new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.addContainerFilter("caption", "0-", true, false);
+
+ }
+ });
+
+ addComponent(num2);
+ final Button num3 = new Button("Add filter 'Number 4'",
+ new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.addContainerFilter("caption", "Number 4", true,
+ false);
+
+ }
+ });
+
+ addComponent(num3);
+ final Button p1 = new Button("Set Number 3 parent to Number 0",
+ new ClickListener() {
+ public void buttonClick(final ClickEvent event) {
+ cont.setParent(3, 0);
+
+ }
+ });
+ addComponent(p1);
+ final Button r = new Button("Remove filters", 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/testbench/com/vaadin/tests/components/tree/TreeScrolling.java b/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java
index 38bf07ef59..c17855996e 100644
--- a/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java
+++ b/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java
@@ -1,54 +1,54 @@
-package com.vaadin.tests.components.tree;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.RichTextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TreeScrolling extends AbstractTestCase {
-
- @Override
- public void init() {
- VerticalLayout layout = new VerticalLayout();
- layout.setSizeUndefined();
- Window w = new Window("", layout);
- setMainWindow(w);
-
- TextField filler1 = new TextField();
- RichTextArea filler2 = new RichTextArea();
- Tree tree = new Tree();
- for (int i = 0; i < 20; i++) {
- String parentId = "Item " + i;
- // Item parentItem =
- tree.addItem(parentId);
- for (int j = 0; j < 20; j++) {
- String subId = "Item " + i + " - " + j;
- // Item subItem =
- tree.addItem(subId);
- tree.setParent(subId, parentId);
- }
-
- }
-
- for (Object id : tree.rootItemIds()) {
- tree.expandItemsRecursively(id);
- }
-
- layout.addComponent(filler1);
- layout.addComponent(filler2);
- layout.addComponent(tree);
- }
-
- @Override
- protected String getDescription() {
- return "Tests what happens when a tree is partly out of view when an item is selected";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5400;
- }
-
-}
+package com.vaadin.tests.components.tree;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TreeScrolling extends AbstractTestCase {
+
+ @Override
+ public void init() {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setSizeUndefined();
+ Window w = new Window("", layout);
+ setMainWindow(w);
+
+ TextField filler1 = new TextField();
+ RichTextArea filler2 = new RichTextArea();
+ Tree tree = new Tree();
+ for (int i = 0; i < 20; i++) {
+ String parentId = "Item " + i;
+ // Item parentItem =
+ tree.addItem(parentId);
+ for (int j = 0; j < 20; j++) {
+ String subId = "Item " + i + " - " + j;
+ // Item subItem =
+ tree.addItem(subId);
+ tree.setParent(subId, parentId);
+ }
+
+ }
+
+ for (Object id : tree.rootItemIds()) {
+ tree.expandItemsRecursively(id);
+ }
+
+ layout.addComponent(filler1);
+ layout.addComponent(filler2);
+ layout.addComponent(tree);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests what happens when a tree is partly out of view when an item is selected";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5400;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/tree/Trees.java b/tests/testbench/com/vaadin/tests/components/tree/Trees.java
index 076e0c9dda..79de4de412 100644
--- a/tests/testbench/com/vaadin/tests/components/tree/Trees.java
+++ b/tests/testbench/com/vaadin/tests/components/tree/Trees.java
@@ -1,391 +1,391 @@
-package com.vaadin.tests.components.tree;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Hierarchical;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.AbstractSelect.MultiSelectMode;
-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;
-import com.vaadin.ui.Tree.ItemStyleGenerator;
-
-public class Trees extends AbstractSelectTestCase<Tree> implements
- ExpandListener, CollapseListener {
-
- private int rootItemIds = 3;
-
- private ItemStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Tree.ItemStyleGenerator() {
-
- public String getStyle(Object itemId) {
- Hierarchical c = (Container.Hierarchical) getComponent()
- .getContainerDataSource();
- if (c.isRoot(itemId)) {
- return "green";
- }
-
- Object parent = c.getParent(itemId);
- if (!c.isRoot(parent)) {
- return "red";
- }
-
- return null;
- }
-
- @Override
- public String toString() {
- return "Root green, second level red";
- };
-
- };
-
- private ItemStyleGenerator evenItemsBold = new com.vaadin.ui.Tree.ItemStyleGenerator() {
-
- public String getStyle(Object itemId) {
- Hierarchical c = (Container.Hierarchical) getComponent()
- .getContainerDataSource();
- int idx = 0;
-
- for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) {
- Object id = i.next();
- if (id == itemId) {
- if (idx % 2 == 1) {
- return "bold";
- } else {
- return null;
- }
- }
-
- idx++;
- }
-
- return null;
- }
-
- @Override
- public String toString() {
- return "Even items bold";
- };
-
- };
-
- private Command<Tree, ContextMenu> contextMenuCommand = new Command<Tree, ContextMenu>() {
-
- public void execute(Tree c, final ContextMenu value, Object data) {
- c.removeAllActionHandlers();
- if (value != null) {
- c.addActionHandler(new Handler() {
-
- public void handleAction(Action action, Object sender,
- Object target) {
- log("Action " + action.getCaption() + " performed on "
- + target);
- }
-
- public Action[] getActions(Object target, Object sender) {
- return value.getActions(target, sender);
- }
- });
- }
- }
- };
-
- @Override
- protected Class<Tree> getTestClass() {
- return Tree.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
-
- // Causes container changes so doing this first..
- createRootItemSelectAction(CATEGORY_DATA_SOURCE);
-
- createExpandCollapseActions(CATEGORY_FEATURES);
- createSelectionModeSelect(CATEGORY_SELECTION);
- createChildrenAllowedAction(CATEGORY_DATA_SOURCE);
-
- createListeners(CATEGORY_LISTENERS);
- createItemStyleGenerator(CATEGORY_FEATURES);
- createContextMenuAction(CATEGORY_FEATURES);
- // TODO: DropHandler
- // TODO: DragMode
- // TODO: ActionHandler
-
- }
-
- private void createContextMenuAction(String category) {
- LinkedHashMap<String, ContextMenu> options = new LinkedHashMap<String, ContextMenu>();
- options.put("None", null);
- options.put("Item without icon", new ContextMenu("No icon", null));
- ContextMenu cm = new ContextMenu();
- cm.addItem("Caption only", null);
- cm.addItem("Has icon", ICON_16_USER_PNG_UNCACHEABLE);
- options.put("With and without icon", cm);
- options.put("Only one large icon", new ContextMenu("Icon",
- ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE));
-
- createSelectAction("Context menu", category, options, "None",
- contextMenuCommand, true);
- }
-
- private void createItemStyleGenerator(String category) {
-
- LinkedHashMap<String, com.vaadin.ui.Tree.ItemStyleGenerator> options = new LinkedHashMap<String, com.vaadin.ui.Tree.ItemStyleGenerator>();
-
- options.put("-", null);
- options.put(rootGreenSecondLevelRed.toString(), rootGreenSecondLevelRed);
- options.put(evenItemsBold.toString(), evenItemsBold);
-
- createSelectAction("Item Style generator", category, options, "-",
- itemStyleGeneratorCommand);
-
- }
-
- private void createListeners(String category) {
- createBooleanAction("Expand listener", category, false,
- expandListenerCommand);
- createBooleanAction("Collapse listener", category, false,
- collapseListenerCommand);
- createBooleanAction("Item click listener", category, false,
- itemClickListenerCommand);
-
- }
-
- private enum SelectMode {
- NONE, SINGLE, MULTI_SIMPLE, MULTI;
- }
-
- protected void createSelectionModeSelect(String category) {
- LinkedHashMap<String, SelectMode> options = new LinkedHashMap<String, SelectMode>();
- options.put("None", SelectMode.NONE);
- options.put("Single", SelectMode.SINGLE);
- options.put("Multi - simple", SelectMode.MULTI_SIMPLE);
- options.put("Multi - ctrl/shift", SelectMode.MULTI);
-
- createSelectAction("Selection Mode", category, options,
- "Multi - ctrl/shift", new Command<Tree, SelectMode>() {
-
- public void execute(Tree t, SelectMode value, Object data) {
- switch (value) {
- case NONE:
- t.setSelectable(false);
- break;
- case SINGLE:
- t.setMultiSelect(false);
- t.setSelectable(true);
- break;
- case MULTI_SIMPLE:
- t.setSelectable(true);
- t.setMultiSelect(true);
- t.setMultiselectMode(MultiSelectMode.SIMPLE);
- break;
- case MULTI:
- t.setSelectable(true);
- t.setMultiSelect(true);
- t.setMultiselectMode(MultiSelectMode.DEFAULT);
- break;
- }
- }
- });
- }
-
- @Override
- protected Container createContainer(int properties, int items) {
- return createHierarchicalContainer(properties, items, rootItemIds);
- }
-
- private Container.Hierarchical createHierarchicalContainer(int properties,
- int items, int roots) {
- Container.Hierarchical c = new HierarchicalContainer();
-
- populateContainer(c, properties, items);
-
- if (items <= roots) {
- return c;
- }
-
- // "roots" roots, each with
- // "firstLevel" children, two with no children (one with childAllowed,
- // one without)
- // ("firstLevel"-2)*"secondLevel" children ("secondLevel"/2 with
- // childAllowed, "secondLevel"/2 without)
-
- // N*M+N*(M-2)*C = items
- // items=N(M+MC-2C)
-
- // Using secondLevel=firstLevel/2 =>
- // items = roots*(firstLevel+firstLevel*firstLevel/2-2*firstLevel/2)
- // =roots*(firstLevel+firstLevel^2/2-firstLevel)
- // = roots*firstLevel^2/2
- // => firstLevel = sqrt(items/roots*2)
-
- int firstLevel = (int) Math.ceil(Math.sqrt(items / roots * 2.0));
- int secondLevel = firstLevel / 2;
-
- while (roots * (1 + 2 + (firstLevel - 2) * secondLevel) < items) {
- // Increase something so we get enough items
- secondLevel++;
- }
-
- List<Object> itemIds = new ArrayList<Object>(c.getItemIds());
-
- int nextItemId = roots;
- for (int rootIndex = 0; rootIndex < roots; rootIndex++) {
- // roots use items 0..roots-1
- Object rootItemId = itemIds.get(rootIndex);
-
- // force roots to be roots even though they automatically should be
- c.setParent(rootItemId, null);
-
- for (int firstLevelIndex = 0; firstLevelIndex < firstLevel; firstLevelIndex++) {
- if (nextItemId >= items) {
- break;
- }
- Object firstLevelItemId = itemIds.get(nextItemId++);
- c.setParent(firstLevelItemId, rootItemId);
-
- if (firstLevelIndex < 2) {
- continue;
- }
-
- // firstLevelChildren 2.. have child nodes
- for (int secondLevelIndex = 0; secondLevelIndex < secondLevel; secondLevelIndex++) {
- if (nextItemId >= items) {
- break;
- }
-
- Object secondLevelItemId = itemIds.get(nextItemId++);
- c.setParent(secondLevelItemId, firstLevelItemId);
- }
- }
- }
-
- return c;
- }
-
- private void createRootItemSelectAction(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- for (int i = 1; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("20", 20);
- options.put("50", 50);
- options.put("100", 100);
-
- createSelectAction("Number of root items", category, options, "3",
- rootItemIdsCommand);
- }
-
- private void createExpandCollapseActions(String category) {
- LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
-
- for (Object id : getComponent().getItemIds()) {
- options.put(id.toString(), id);
- }
- createMultiClickAction("Expand", category, options, expandItemCommand,
- null);
- createMultiClickAction("Expand recursively", category, options,
- expandItemRecursivelyCommand, null);
- createMultiClickAction("Collapse", category, options,
- collapseItemCommand, null);
-
- }
-
- private void createChildrenAllowedAction(String category) {
- LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
-
- for (Object id : getComponent().getItemIds()) {
- options.put(id.toString(), id);
- }
- createMultiToggleAction("Children allowed", category, options,
- setChildrenAllowedCommand, true);
-
- }
-
- /*
- * COMMANDS
- */
- private Command<Tree, Integer> rootItemIdsCommand = new Command<Tree, Integer>() {
-
- public void execute(Tree c, Integer value, Object data) {
- rootItemIds = value;
- updateContainer();
- }
- };
-
- private Command<Tree, Object> expandItemCommand = new Command<Tree, Object>() {
-
- public void execute(Tree c, Object itemId, Object data) {
- c.expandItem(itemId);
- }
- };
- private Command<Tree, Object> expandItemRecursivelyCommand = new Command<Tree, Object>() {
-
- public void execute(Tree c, Object itemId, Object data) {
- c.expandItemsRecursively(itemId);
- }
- };
-
- private Command<Tree, Object> collapseItemCommand = new Command<Tree, Object>() {
-
- public void execute(Tree c, Object itemId, Object data) {
- c.collapseItem(itemId);
- }
- };
-
- private Command<Tree, Boolean> setChildrenAllowedCommand = new Command<Tree, Boolean>() {
-
- public void execute(Tree c, Boolean areChildrenAllowed, Object itemId) {
- c.setChildrenAllowed(itemId, areChildrenAllowed);
- }
- };
-
- private Command<Tree, Boolean> expandListenerCommand = new Command<Tree, Boolean>() {
- public void execute(Tree c, Boolean value, Object data) {
- if (value) {
- c.addListener((ExpandListener) Trees.this);
- } else {
- c.removeListener((ExpandListener) Trees.this);
- }
- }
- };
-
- private Command<Tree, Boolean> collapseListenerCommand = new Command<Tree, Boolean>() {
- public void execute(Tree c, Boolean value, Object data) {
- if (value) {
- c.addListener((CollapseListener) Trees.this);
- } else {
- c.removeListener((CollapseListener) Trees.this);
- }
- }
- };
-
- private Command<Tree, com.vaadin.ui.Tree.ItemStyleGenerator> itemStyleGeneratorCommand = new Command<Tree, com.vaadin.ui.Tree.ItemStyleGenerator>() {
-
- public void execute(Tree c,
- com.vaadin.ui.Tree.ItemStyleGenerator value, Object data) {
- c.setItemStyleGenerator(value);
-
- }
- };
-
- public void nodeCollapse(CollapseEvent event) {
- log(event.getClass().getSimpleName() + ": " + event.getItemId());
- }
-
- public void nodeExpand(ExpandEvent event) {
- log(event.getClass().getSimpleName() + ": " + event.getItemId());
- }
-
-}
+package com.vaadin.tests.components.tree;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Hierarchical;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.tests.components.select.AbstractSelectTestCase;
+import com.vaadin.ui.AbstractSelect.MultiSelectMode;
+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;
+import com.vaadin.ui.Tree.ItemStyleGenerator;
+
+public class Trees extends AbstractSelectTestCase<Tree> implements
+ ExpandListener, CollapseListener {
+
+ private int rootItemIds = 3;
+
+ private ItemStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Tree.ItemStyleGenerator() {
+
+ public String getStyle(Object itemId) {
+ Hierarchical c = (Container.Hierarchical) getComponent()
+ .getContainerDataSource();
+ if (c.isRoot(itemId)) {
+ return "green";
+ }
+
+ Object parent = c.getParent(itemId);
+ if (!c.isRoot(parent)) {
+ return "red";
+ }
+
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "Root green, second level red";
+ };
+
+ };
+
+ private ItemStyleGenerator evenItemsBold = new com.vaadin.ui.Tree.ItemStyleGenerator() {
+
+ public String getStyle(Object itemId) {
+ Hierarchical c = (Container.Hierarchical) getComponent()
+ .getContainerDataSource();
+ int idx = 0;
+
+ for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) {
+ Object id = i.next();
+ if (id == itemId) {
+ if (idx % 2 == 1) {
+ return "bold";
+ } else {
+ return null;
+ }
+ }
+
+ idx++;
+ }
+
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "Even items bold";
+ };
+
+ };
+
+ private Command<Tree, ContextMenu> contextMenuCommand = new Command<Tree, ContextMenu>() {
+
+ public void execute(Tree c, final ContextMenu value, Object data) {
+ c.removeAllActionHandlers();
+ if (value != null) {
+ c.addActionHandler(new Handler() {
+
+ public void handleAction(Action action, Object sender,
+ Object target) {
+ log("Action " + action.getCaption() + " performed on "
+ + target);
+ }
+
+ public Action[] getActions(Object target, Object sender) {
+ return value.getActions(target, sender);
+ }
+ });
+ }
+ }
+ };
+
+ @Override
+ protected Class<Tree> getTestClass() {
+ return Tree.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ // Causes container changes so doing this first..
+ createRootItemSelectAction(CATEGORY_DATA_SOURCE);
+
+ createExpandCollapseActions(CATEGORY_FEATURES);
+ createSelectionModeSelect(CATEGORY_SELECTION);
+ createChildrenAllowedAction(CATEGORY_DATA_SOURCE);
+
+ createListeners(CATEGORY_LISTENERS);
+ createItemStyleGenerator(CATEGORY_FEATURES);
+ createContextMenuAction(CATEGORY_FEATURES);
+ // TODO: DropHandler
+ // TODO: DragMode
+ // TODO: ActionHandler
+
+ }
+
+ private void createContextMenuAction(String category) {
+ LinkedHashMap<String, ContextMenu> options = new LinkedHashMap<String, ContextMenu>();
+ options.put("None", null);
+ options.put("Item without icon", new ContextMenu("No icon", null));
+ ContextMenu cm = new ContextMenu();
+ cm.addItem("Caption only", null);
+ cm.addItem("Has icon", ICON_16_USER_PNG_UNCACHEABLE);
+ options.put("With and without icon", cm);
+ options.put("Only one large icon", new ContextMenu("Icon",
+ ICON_64_EMAIL_REPLY_PNG_UNCACHEABLE));
+
+ createSelectAction("Context menu", category, options, "None",
+ contextMenuCommand, true);
+ }
+
+ private void createItemStyleGenerator(String category) {
+
+ LinkedHashMap<String, com.vaadin.ui.Tree.ItemStyleGenerator> options = new LinkedHashMap<String, com.vaadin.ui.Tree.ItemStyleGenerator>();
+
+ options.put("-", null);
+ options.put(rootGreenSecondLevelRed.toString(), rootGreenSecondLevelRed);
+ options.put(evenItemsBold.toString(), evenItemsBold);
+
+ createSelectAction("Item Style generator", category, options, "-",
+ itemStyleGeneratorCommand);
+
+ }
+
+ private void createListeners(String category) {
+ createBooleanAction("Expand listener", category, false,
+ expandListenerCommand);
+ createBooleanAction("Collapse listener", category, false,
+ collapseListenerCommand);
+ createBooleanAction("Item click listener", category, false,
+ itemClickListenerCommand);
+
+ }
+
+ private enum SelectMode {
+ NONE, SINGLE, MULTI_SIMPLE, MULTI;
+ }
+
+ protected void createSelectionModeSelect(String category) {
+ LinkedHashMap<String, SelectMode> options = new LinkedHashMap<String, SelectMode>();
+ options.put("None", SelectMode.NONE);
+ options.put("Single", SelectMode.SINGLE);
+ options.put("Multi - simple", SelectMode.MULTI_SIMPLE);
+ options.put("Multi - ctrl/shift", SelectMode.MULTI);
+
+ createSelectAction("Selection Mode", category, options,
+ "Multi - ctrl/shift", new Command<Tree, SelectMode>() {
+
+ public void execute(Tree t, SelectMode value, Object data) {
+ switch (value) {
+ case NONE:
+ t.setSelectable(false);
+ break;
+ case SINGLE:
+ t.setMultiSelect(false);
+ t.setSelectable(true);
+ break;
+ case MULTI_SIMPLE:
+ t.setSelectable(true);
+ t.setMultiSelect(true);
+ t.setMultiselectMode(MultiSelectMode.SIMPLE);
+ break;
+ case MULTI:
+ t.setSelectable(true);
+ t.setMultiSelect(true);
+ t.setMultiselectMode(MultiSelectMode.DEFAULT);
+ break;
+ }
+ }
+ });
+ }
+
+ @Override
+ protected Container createContainer(int properties, int items) {
+ return createHierarchicalContainer(properties, items, rootItemIds);
+ }
+
+ private Container.Hierarchical createHierarchicalContainer(int properties,
+ int items, int roots) {
+ Container.Hierarchical c = new HierarchicalContainer();
+
+ populateContainer(c, properties, items);
+
+ if (items <= roots) {
+ return c;
+ }
+
+ // "roots" roots, each with
+ // "firstLevel" children, two with no children (one with childAllowed,
+ // one without)
+ // ("firstLevel"-2)*"secondLevel" children ("secondLevel"/2 with
+ // childAllowed, "secondLevel"/2 without)
+
+ // N*M+N*(M-2)*C = items
+ // items=N(M+MC-2C)
+
+ // Using secondLevel=firstLevel/2 =>
+ // items = roots*(firstLevel+firstLevel*firstLevel/2-2*firstLevel/2)
+ // =roots*(firstLevel+firstLevel^2/2-firstLevel)
+ // = roots*firstLevel^2/2
+ // => firstLevel = sqrt(items/roots*2)
+
+ int firstLevel = (int) Math.ceil(Math.sqrt(items / roots * 2.0));
+ int secondLevel = firstLevel / 2;
+
+ while (roots * (1 + 2 + (firstLevel - 2) * secondLevel) < items) {
+ // Increase something so we get enough items
+ secondLevel++;
+ }
+
+ List<Object> itemIds = new ArrayList<Object>(c.getItemIds());
+
+ int nextItemId = roots;
+ for (int rootIndex = 0; rootIndex < roots; rootIndex++) {
+ // roots use items 0..roots-1
+ Object rootItemId = itemIds.get(rootIndex);
+
+ // force roots to be roots even though they automatically should be
+ c.setParent(rootItemId, null);
+
+ for (int firstLevelIndex = 0; firstLevelIndex < firstLevel; firstLevelIndex++) {
+ if (nextItemId >= items) {
+ break;
+ }
+ Object firstLevelItemId = itemIds.get(nextItemId++);
+ c.setParent(firstLevelItemId, rootItemId);
+
+ if (firstLevelIndex < 2) {
+ continue;
+ }
+
+ // firstLevelChildren 2.. have child nodes
+ for (int secondLevelIndex = 0; secondLevelIndex < secondLevel; secondLevelIndex++) {
+ if (nextItemId >= items) {
+ break;
+ }
+
+ Object secondLevelItemId = itemIds.get(nextItemId++);
+ c.setParent(secondLevelItemId, firstLevelItemId);
+ }
+ }
+ }
+
+ return c;
+ }
+
+ private void createRootItemSelectAction(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ for (int i = 1; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("20", 20);
+ options.put("50", 50);
+ options.put("100", 100);
+
+ createSelectAction("Number of root items", category, options, "3",
+ rootItemIdsCommand);
+ }
+
+ private void createExpandCollapseActions(String category) {
+ LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
+
+ for (Object id : getComponent().getItemIds()) {
+ options.put(id.toString(), id);
+ }
+ createMultiClickAction("Expand", category, options, expandItemCommand,
+ null);
+ createMultiClickAction("Expand recursively", category, options,
+ expandItemRecursivelyCommand, null);
+ createMultiClickAction("Collapse", category, options,
+ collapseItemCommand, null);
+
+ }
+
+ private void createChildrenAllowedAction(String category) {
+ LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
+
+ for (Object id : getComponent().getItemIds()) {
+ options.put(id.toString(), id);
+ }
+ createMultiToggleAction("Children allowed", category, options,
+ setChildrenAllowedCommand, true);
+
+ }
+
+ /*
+ * COMMANDS
+ */
+ private Command<Tree, Integer> rootItemIdsCommand = new Command<Tree, Integer>() {
+
+ public void execute(Tree c, Integer value, Object data) {
+ rootItemIds = value;
+ updateContainer();
+ }
+ };
+
+ private Command<Tree, Object> expandItemCommand = new Command<Tree, Object>() {
+
+ public void execute(Tree c, Object itemId, Object data) {
+ c.expandItem(itemId);
+ }
+ };
+ private Command<Tree, Object> expandItemRecursivelyCommand = new Command<Tree, Object>() {
+
+ public void execute(Tree c, Object itemId, Object data) {
+ c.expandItemsRecursively(itemId);
+ }
+ };
+
+ private Command<Tree, Object> collapseItemCommand = new Command<Tree, Object>() {
+
+ public void execute(Tree c, Object itemId, Object data) {
+ c.collapseItem(itemId);
+ }
+ };
+
+ private Command<Tree, Boolean> setChildrenAllowedCommand = new Command<Tree, Boolean>() {
+
+ public void execute(Tree c, Boolean areChildrenAllowed, Object itemId) {
+ c.setChildrenAllowed(itemId, areChildrenAllowed);
+ }
+ };
+
+ private Command<Tree, Boolean> expandListenerCommand = new Command<Tree, Boolean>() {
+ public void execute(Tree c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ExpandListener) Trees.this);
+ } else {
+ c.removeListener((ExpandListener) Trees.this);
+ }
+ }
+ };
+
+ private Command<Tree, Boolean> collapseListenerCommand = new Command<Tree, Boolean>() {
+ public void execute(Tree c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((CollapseListener) Trees.this);
+ } else {
+ c.removeListener((CollapseListener) Trees.this);
+ }
+ }
+ };
+
+ private Command<Tree, com.vaadin.ui.Tree.ItemStyleGenerator> itemStyleGeneratorCommand = new Command<Tree, com.vaadin.ui.Tree.ItemStyleGenerator>() {
+
+ public void execute(Tree c,
+ com.vaadin.ui.Tree.ItemStyleGenerator value, Object data) {
+ c.setItemStyleGenerator(value);
+
+ }
+ };
+
+ public void nodeCollapse(CollapseEvent event) {
+ log(event.getClass().getSimpleName() + ": " + event.getItemId());
+ }
+
+ public void nodeExpand(ExpandEvent event) {
+ log(event.getClass().getSimpleName() + ": " + event.getItemId());
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java b/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
index 3d01883deb..9cb60efd74 100644
--- a/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
+++ b/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
@@ -1,90 +1,90 @@
-package com.vaadin.tests.components.treetable;
-
-import com.vaadin.data.Container.Hierarchical;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.TreeTable;
-
-public class ChangeDataSourcePageLengthZero extends TestBase {
- @Override
- public void setup() {
- final TreeTable tt = new TreeTable();
- tt.setSizeUndefined();
- tt.setWidth("100%");
- tt.setImmediate(true);
- tt.setPageLength(0);
- setupContainer(tt, 20);
- addComponent(tt);
- Button page1 = new Button("Set new data source (20 items)");
- page1.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- setupContainer(tt, 20);
- }
- });
- Button page2 = new Button("Set new data source (10 items)");
- page2.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- setupContainer(tt, 10);
- }
- });
- Button addButton = new Button("Add item");
- addButton.addListener(new Button.ClickListener() {
- private int i = 1;
-
- public void buttonClick(ClickEvent event) {
- HierarchicalContainer container = (HierarchicalContainer) tt
- .getContainerDataSource();
- Object itemId = container.addItem();
- container.getContainerProperty(itemId, "i").setValue(i++);
- container.getContainerProperty(itemId, "link").setValue(
- new Link(String.valueOf(i + 1), new ExternalResource(
- "http://www.google.fi")));
- container.setChildrenAllowed(itemId, false);
- container.setParent(itemId, null);
- }
- });
- addComponent(page1);
- addComponent(page2);
- addComponent(addButton);
- }
-
- private static void setupContainer(TreeTable tt, int num) {
- HierarchicalContainer container = new HierarchicalContainer();
- container.addContainerProperty("i", Integer.class, null);
- container.addContainerProperty("link", Link.class, null);
- fillContainer(container, num);
- tt.setContainerDataSource(container);
- }
-
- private static void fillContainer(Hierarchical container, int num) {
- Object previous = null;
- for (int i = 0; i < num; i++) {
- Object item = container.addItem();
- container.getContainerProperty(item, "i").setValue(i + 1);
- container.getContainerProperty(item, "link").setValue(
- new Link(String.valueOf(i + 1), new ExternalResource(
- "http://www.google.fi")));
- if (i > 0 && (i + 1) % 2 == 0) {
- container.setChildrenAllowed(item, false);
- container.setParent(item, previous);
- } else {
- container.setChildrenAllowed(item, true);
- }
- previous = item;
- }
- }
-
- @Override
- protected String getDescription() {
- return "Changing the data source should update the height of a TreeTable with pagelength zero";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7908;
- }
+package com.vaadin.tests.components.treetable;
+
+import com.vaadin.data.Container.Hierarchical;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.TreeTable;
+
+public class ChangeDataSourcePageLengthZero extends TestBase {
+ @Override
+ public void setup() {
+ final TreeTable tt = new TreeTable();
+ tt.setSizeUndefined();
+ tt.setWidth("100%");
+ tt.setImmediate(true);
+ tt.setPageLength(0);
+ setupContainer(tt, 20);
+ addComponent(tt);
+ Button page1 = new Button("Set new data source (20 items)");
+ page1.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ setupContainer(tt, 20);
+ }
+ });
+ Button page2 = new Button("Set new data source (10 items)");
+ page2.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ setupContainer(tt, 10);
+ }
+ });
+ Button addButton = new Button("Add item");
+ addButton.addListener(new Button.ClickListener() {
+ private int i = 1;
+
+ public void buttonClick(ClickEvent event) {
+ HierarchicalContainer container = (HierarchicalContainer) tt
+ .getContainerDataSource();
+ Object itemId = container.addItem();
+ container.getContainerProperty(itemId, "i").setValue(i++);
+ container.getContainerProperty(itemId, "link").setValue(
+ new Link(String.valueOf(i + 1), new ExternalResource(
+ "http://www.google.fi")));
+ container.setChildrenAllowed(itemId, false);
+ container.setParent(itemId, null);
+ }
+ });
+ addComponent(page1);
+ addComponent(page2);
+ addComponent(addButton);
+ }
+
+ private static void setupContainer(TreeTable tt, int num) {
+ HierarchicalContainer container = new HierarchicalContainer();
+ container.addContainerProperty("i", Integer.class, null);
+ container.addContainerProperty("link", Link.class, null);
+ fillContainer(container, num);
+ tt.setContainerDataSource(container);
+ }
+
+ private static void fillContainer(Hierarchical container, int num) {
+ Object previous = null;
+ for (int i = 0; i < num; i++) {
+ Object item = container.addItem();
+ container.getContainerProperty(item, "i").setValue(i + 1);
+ container.getContainerProperty(item, "link").setValue(
+ new Link(String.valueOf(i + 1), new ExternalResource(
+ "http://www.google.fi")));
+ if (i > 0 && (i + 1) % 2 == 0) {
+ container.setChildrenAllowed(item, false);
+ container.setParent(item, previous);
+ } else {
+ container.setChildrenAllowed(item, true);
+ }
+ previous = item;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Changing the data source should update the height of a TreeTable with pagelength zero";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7908;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java b/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java
index da6cccc0c8..89211dbecc 100644
--- a/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java
+++ b/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java
@@ -1,125 +1,125 @@
-package com.vaadin.tests.components.treetable;
-
-import java.util.Collection;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.Tree.CollapseEvent;
-import com.vaadin.ui.Tree.ExpandEvent;
-import com.vaadin.ui.TreeTable;
-
-public class DynamicallyModified extends TestBase implements
- Tree.ExpandListener, Tree.CollapseListener {
- protected static final String NAME_PROPERTY = "Name";
- protected static final String HOURS_PROPERTY = "Hours done";
- protected static final String MODIFIED_PROPERTY = "Last Modified";
- private static final String DEFAULT_DATE = "Wed Nov 30 14:40:26 EET 2011";
-
- protected TreeTable treetable;
-
- @Override
- protected void setup() {
- getLayout().setWidth("100%");
-
- // Create the treetable
- treetable = new TreeTable();
- treetable.setWidth("100%");
- treetable.addListener((Tree.ExpandListener) this);
- treetable.addListener((Tree.CollapseListener) this);
-
- addComponent(treetable);
-
- // Add Table columns
- treetable.addContainerProperty(NAME_PROPERTY, String.class, "");
- treetable.addContainerProperty(HOURS_PROPERTY, Integer.class, 0);
- treetable.addContainerProperty(MODIFIED_PROPERTY, String.class,
- DEFAULT_DATE);
-
- // Populate table
- Object allProjects = treetable.addItem(new Object[] { "All Projects",
- 18, DEFAULT_DATE }, null);
- Object year2010 = treetable.addItem(new Object[] { "Year 2010", 18,
- DEFAULT_DATE }, null);
- Object customerProject1 = treetable.addItem(new Object[] {
- "Customer Project 1", 13, DEFAULT_DATE }, null);
- Object customerProject1Implementation = treetable.addItem(new Object[] {
- "Implementation", 5, DEFAULT_DATE }, null);
- Object customerProject1Planning = treetable.addItem(new Object[] {
- "Planning", 2, DEFAULT_DATE }, null);
- Object customerProject1Prototype = treetable.addItem(new Object[] {
- "Prototype", 5, DEFAULT_DATE }, null);
- Object customerProject2 = treetable.addItem(new Object[] {
- "Customer Project 2", 5, DEFAULT_DATE }, null);
- Object customerProject2Planning = treetable.addItem(new Object[] {
- "Planning", 5, DEFAULT_DATE }, null);
-
- // Set hierarchy
- treetable.setParent(year2010, allProjects);
- treetable.setParent(customerProject1, year2010);
- treetable.setParent(customerProject1Implementation, customerProject1);
- treetable.setParent(customerProject1Planning, customerProject1);
- treetable.setParent(customerProject1Prototype, customerProject1);
- treetable.setParent(customerProject2, year2010);
- treetable.setParent(customerProject2Planning, customerProject2);
-
- // Disallow children from leaves
- treetable.setChildrenAllowed(customerProject1Implementation, false);
- treetable.setChildrenAllowed(customerProject1Planning, false);
- treetable.setChildrenAllowed(customerProject1Prototype, false);
- treetable.setChildrenAllowed(customerProject2Planning, false);
-
- // Expand all
- treetable.setCollapsed(allProjects, false);
- treetable.setCollapsed(year2010, false);
- treetable.setCollapsed(customerProject1, false);
- treetable.setCollapsed(customerProject2, false);
- }
-
- @Override
- protected String getDescription() {
- return "Collaps 'Customer Project 1' will cause the first child if it to be removed. Expanding 'Custom Project 2' will cause a new child to be added. These events should be rendered correctly.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7780;
- }
-
- private int newChild = 1;
-
- public void nodeExpand(ExpandEvent event) {
- Object expandedItemId = event.getItemId();
- // 7 == "Customer Project 1"
- if (expandedItemId != Integer.valueOf(7)) {
- return;
- }
- Object newChildId = treetable.addItem(new Object[] {
- "New child " + newChild++, 5, "Fri Nov 04 10:53:16 EET 2011" },
- null);
- treetable.setParent(newChildId, expandedItemId);
- treetable.setChildrenAllowed(newChildId, false);
- }
-
- public void nodeCollapse(CollapseEvent event) {
-
- Object collapsedItemId = event.getItemId();
-
- // 3 == "Customer Project 1"
- if (collapsedItemId != Integer.valueOf(3)) {
- return;
- }
- @SuppressWarnings("unchecked")
- Collection<Object> childs = (Collection<Object>) treetable
- .getChildren(event.getItemId());
-
- if (childs == null) {
- return;
- }
- Object[] arr = childs.toArray();
-
- if (arr.length > 0) {
- treetable.removeItem(arr[0]);
- }
-
- }
+package com.vaadin.tests.components.treetable;
+
+import java.util.Collection;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.TreeTable;
+
+public class DynamicallyModified extends TestBase implements
+ Tree.ExpandListener, Tree.CollapseListener {
+ protected static final String NAME_PROPERTY = "Name";
+ protected static final String HOURS_PROPERTY = "Hours done";
+ protected static final String MODIFIED_PROPERTY = "Last Modified";
+ private static final String DEFAULT_DATE = "Wed Nov 30 14:40:26 EET 2011";
+
+ protected TreeTable treetable;
+
+ @Override
+ protected void setup() {
+ getLayout().setWidth("100%");
+
+ // Create the treetable
+ treetable = new TreeTable();
+ treetable.setWidth("100%");
+ treetable.addListener((Tree.ExpandListener) this);
+ treetable.addListener((Tree.CollapseListener) this);
+
+ addComponent(treetable);
+
+ // Add Table columns
+ treetable.addContainerProperty(NAME_PROPERTY, String.class, "");
+ treetable.addContainerProperty(HOURS_PROPERTY, Integer.class, 0);
+ treetable.addContainerProperty(MODIFIED_PROPERTY, String.class,
+ DEFAULT_DATE);
+
+ // Populate table
+ Object allProjects = treetable.addItem(new Object[] { "All Projects",
+ 18, DEFAULT_DATE }, null);
+ Object year2010 = treetable.addItem(new Object[] { "Year 2010", 18,
+ DEFAULT_DATE }, null);
+ Object customerProject1 = treetable.addItem(new Object[] {
+ "Customer Project 1", 13, DEFAULT_DATE }, null);
+ Object customerProject1Implementation = treetable.addItem(new Object[] {
+ "Implementation", 5, DEFAULT_DATE }, null);
+ Object customerProject1Planning = treetable.addItem(new Object[] {
+ "Planning", 2, DEFAULT_DATE }, null);
+ Object customerProject1Prototype = treetable.addItem(new Object[] {
+ "Prototype", 5, DEFAULT_DATE }, null);
+ Object customerProject2 = treetable.addItem(new Object[] {
+ "Customer Project 2", 5, DEFAULT_DATE }, null);
+ Object customerProject2Planning = treetable.addItem(new Object[] {
+ "Planning", 5, DEFAULT_DATE }, null);
+
+ // Set hierarchy
+ treetable.setParent(year2010, allProjects);
+ treetable.setParent(customerProject1, year2010);
+ treetable.setParent(customerProject1Implementation, customerProject1);
+ treetable.setParent(customerProject1Planning, customerProject1);
+ treetable.setParent(customerProject1Prototype, customerProject1);
+ treetable.setParent(customerProject2, year2010);
+ treetable.setParent(customerProject2Planning, customerProject2);
+
+ // Disallow children from leaves
+ treetable.setChildrenAllowed(customerProject1Implementation, false);
+ treetable.setChildrenAllowed(customerProject1Planning, false);
+ treetable.setChildrenAllowed(customerProject1Prototype, false);
+ treetable.setChildrenAllowed(customerProject2Planning, false);
+
+ // Expand all
+ treetable.setCollapsed(allProjects, false);
+ treetable.setCollapsed(year2010, false);
+ treetable.setCollapsed(customerProject1, false);
+ treetable.setCollapsed(customerProject2, false);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Collaps 'Customer Project 1' will cause the first child if it to be removed. Expanding 'Custom Project 2' will cause a new child to be added. These events should be rendered correctly.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7780;
+ }
+
+ private int newChild = 1;
+
+ public void nodeExpand(ExpandEvent event) {
+ Object expandedItemId = event.getItemId();
+ // 7 == "Customer Project 1"
+ if (expandedItemId != Integer.valueOf(7)) {
+ return;
+ }
+ Object newChildId = treetable.addItem(new Object[] {
+ "New child " + newChild++, 5, "Fri Nov 04 10:53:16 EET 2011" },
+ null);
+ treetable.setParent(newChildId, expandedItemId);
+ treetable.setChildrenAllowed(newChildId, false);
+ }
+
+ public void nodeCollapse(CollapseEvent event) {
+
+ Object collapsedItemId = event.getItemId();
+
+ // 3 == "Customer Project 1"
+ if (collapsedItemId != Integer.valueOf(3)) {
+ return;
+ }
+ @SuppressWarnings("unchecked")
+ Collection<Object> childs = (Collection<Object>) treetable
+ .getChildren(event.getItemId());
+
+ if (childs == null) {
+ return;
+ }
+ Object[] arr = childs.toArray();
+
+ if (arr.length > 0) {
+ treetable.removeItem(arr[0]);
+ }
+
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java b/tests/testbench/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java
index bc1b632daf..ae6a9d0c0b 100644
--- a/tests/testbench/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java
+++ b/tests/testbench/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java
@@ -1,238 +1,238 @@
-package com.vaadin.tests.components.treetable;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Ordered;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.data.util.ContainerHierarchicalWrapper;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Table.ColumnGenerator;
-import com.vaadin.ui.Tree.CollapseEvent;
-import com.vaadin.ui.Tree.CollapseListener;
-import com.vaadin.ui.Tree.ExpandEvent;
-import com.vaadin.ui.Tree.ExpandListener;
-import com.vaadin.ui.TreeTable;
-
-public class TreeTableCacheOnPartialUpdates extends TestBase {
- private Log log = new Log(5);
-
- public class TestBean implements Serializable {
- private String col1;
- private String col2;
-
- public TestBean() {
- col1 = "";
- col2 = "";
- }
-
- public TestBean(String col1, String col2) {
- this.col1 = col1;
- this.col2 = col2;
- }
-
- public String getCol1() {
- return col1;
- }
-
- public void setCol1(String col1) {
- this.col1 = col1;
- }
-
- public String getCol2() {
- return col2;
- }
-
- public void setCol2(String col2) {
- this.col2 = col2;
- }
-
- @Override
- public String toString() {
- return "TestBean [col1=" + col1 + ", col2=" + col2 + "]";
- }
-
- }
-
- public class Col3ColumnGenerator implements ColumnGenerator {
- public Component generateCell(final com.vaadin.ui.Table source,
- final Object itemId, Object columnId) {
- TestBean tb = (TestBean) itemId;
- // if (!tb.getCol1().contains("children")) {
- // return null;
- // }
- String identifier = "Item " + itemId + "/" + columnId;
- System.out.println("Generating new Button for " + identifier);
- Button btnCol3 = new NativeButton(identifier);
- btnCol3.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- log.log("Button " + event.getButton().getCaption()
- + " clicked. Row index: "
- + indexOfId(source, itemId));
- }
- });
- return btnCol3;
- }
-
- }
-
- protected int indexOfId(Table source, Object itemId) {
- Container.Ordered c = (Ordered) source.getContainerDataSource();
- if (c instanceof Container.Indexed) {
- return ((Container.Indexed) source).indexOfId(itemId);
- } else {
- ArrayList<Object> list = new ArrayList<Object>(source.getItemIds());
- return list.indexOf(itemId);
-
- }
- }
-
- private TreeTable treeTable;
- private BeanItemContainer<TestBean> testBeanContainer;
- private static String[] columnHeaders = new String[] { "Col1", "Col2",
- "Col3" };
- private static Object[] visibleColumns = new Object[] { "col1", "col2",
- "col3" };
-
- @Override
- public void setup() {
- setTheme("reindeer-tests");
-
- // Force row height to be the same in all browsers so scrolling based on
- // pixels works as expected
- Button b = new Button("Show first");
- addComponent(b);
- b.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- log.log("First visible item id is: "
- + treeTable.getCurrentPageFirstItemId());
- }
- });
- NativeSelect cacheRateSelect = new NativeSelect("Cache rate");
- cacheRateSelect.setImmediate(true);
- cacheRateSelect.setNullSelectionAllowed(false);
- cacheRateSelect.addItem(new Integer(0));
- cacheRateSelect.addItem(new Integer(1));
- cacheRateSelect.addItem(new Integer(2));
- cacheRateSelect.setValue(2);
- cacheRateSelect.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- treeTable
- .setCacheRate((Integer) event.getProperty().getValue());
- }
- });
- addComponent(cacheRateSelect);
- treeTable = new TreeTable();
- treeTable.addStyleName("table-equal-rowheight");
- // treeTable.setPageLength(0);
- testBeanContainer = new BeanItemContainer<TestBean>(TestBean.class);
-
- Map<String, Integer> hasChildren = new HashMap<String, Integer>();
- hasChildren.put("1", 5);
- hasChildren.put("3", 10);
- hasChildren.put("5", 20);
- hasChildren.put("6", 7);
- hasChildren.put("7", 1);
- hasChildren.put("40", 20);
- hasChildren.put("99", 20);
- treeTable.setContainerDataSource(createContainer(100, hasChildren));
- treeTable.addGeneratedColumn("col3", new Col3ColumnGenerator());
- treeTable.addListener(new ExpandListener() {
-
- public void nodeExpand(ExpandEvent event) {
- logExpandCollapse(event.getItemId(), "expanded");
-
- }
- });
- treeTable.addListener(new CollapseListener() {
-
- public void nodeCollapse(CollapseEvent event) {
- logExpandCollapse(event.getItemId(), "collapsed");
-
- }
- });
- treeTable.setColumnHeaders(columnHeaders);
- treeTable.setVisibleColumns(visibleColumns);
- treeTable.setColumnWidth("col1", 150);
- treeTable.setColumnWidth("col2", 50);
- treeTable.setHeight("430px");
- // treeTable.setColumnWidth("col3", 150);
- addComponent(log);
- addComponent(treeTable);
- }
-
- protected void logExpandCollapse(Object itemId, String operation) {
- String identifier = "Item " + itemId;
- log.log("Row " + identifier + " " + operation + ". Row index: "
- + indexOfId(treeTable, itemId));
-
- }
-
- private Container createContainer(int items,
- Map<String, Integer> hasChildren) {
- ContainerHierarchicalWrapper container;
-
- container = new ContainerHierarchicalWrapper(testBeanContainer);
- populate(container, items, hasChildren);
- return container;
- }
-
- private void populate(Container.Hierarchical container, int items,
- Map<String, Integer> children) {
-
- for (int i = 0; i < items; i++) {
- String row = String.valueOf(i + 1);
- String rowText = stringForInt(i);
-
- TestBean itemId = new TestBean(row, rowText);
- container.addItem(itemId);
- if (children.containsKey(row)) {
- itemId.setCol1(itemId.getCol1() + " (children)");
- for (int j = 0; j < children.get(row); j++) {
- TestBean childItemId = new TestBean(row + "." + (j + 1),
- rowText + "." + stringForInt(j));
- container.addItem(childItemId);
- container.setParent(childItemId, itemId);
- }
- }
-
- }
- }
-
- private String stringForInt(int i) {
- int charsAllowed = 26; // a-z
- if (i >= charsAllowed) {
- return stringForInt(i / charsAllowed - 1)
- + stringForInt(i % charsAllowed);
- } else {
- return String.valueOf((char) (i + 'A'));
- }
- }
-
- @Override
- protected String getDescription() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
+package com.vaadin.tests.components.treetable;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Ordered;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.data.util.ContainerHierarchicalWrapper;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.CollapseListener;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.Tree.ExpandListener;
+import com.vaadin.ui.TreeTable;
+
+public class TreeTableCacheOnPartialUpdates extends TestBase {
+ private Log log = new Log(5);
+
+ public class TestBean implements Serializable {
+ private String col1;
+ private String col2;
+
+ public TestBean() {
+ col1 = "";
+ col2 = "";
+ }
+
+ public TestBean(String col1, String col2) {
+ this.col1 = col1;
+ this.col2 = col2;
+ }
+
+ public String getCol1() {
+ return col1;
+ }
+
+ public void setCol1(String col1) {
+ this.col1 = col1;
+ }
+
+ public String getCol2() {
+ return col2;
+ }
+
+ public void setCol2(String col2) {
+ this.col2 = col2;
+ }
+
+ @Override
+ public String toString() {
+ return "TestBean [col1=" + col1 + ", col2=" + col2 + "]";
+ }
+
+ }
+
+ public class Col3ColumnGenerator implements ColumnGenerator {
+ public Component generateCell(final com.vaadin.ui.Table source,
+ final Object itemId, Object columnId) {
+ TestBean tb = (TestBean) itemId;
+ // if (!tb.getCol1().contains("children")) {
+ // return null;
+ // }
+ String identifier = "Item " + itemId + "/" + columnId;
+ System.out.println("Generating new Button for " + identifier);
+ Button btnCol3 = new NativeButton(identifier);
+ btnCol3.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("Button " + event.getButton().getCaption()
+ + " clicked. Row index: "
+ + indexOfId(source, itemId));
+ }
+ });
+ return btnCol3;
+ }
+
+ }
+
+ protected int indexOfId(Table source, Object itemId) {
+ Container.Ordered c = (Ordered) source.getContainerDataSource();
+ if (c instanceof Container.Indexed) {
+ return ((Container.Indexed) source).indexOfId(itemId);
+ } else {
+ ArrayList<Object> list = new ArrayList<Object>(source.getItemIds());
+ return list.indexOf(itemId);
+
+ }
+ }
+
+ private TreeTable treeTable;
+ private BeanItemContainer<TestBean> testBeanContainer;
+ private static String[] columnHeaders = new String[] { "Col1", "Col2",
+ "Col3" };
+ private static Object[] visibleColumns = new Object[] { "col1", "col2",
+ "col3" };
+
+ @Override
+ public void setup() {
+ setTheme("reindeer-tests");
+
+ // Force row height to be the same in all browsers so scrolling based on
+ // pixels works as expected
+ Button b = new Button("Show first");
+ addComponent(b);
+ b.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ log.log("First visible item id is: "
+ + treeTable.getCurrentPageFirstItemId());
+ }
+ });
+ NativeSelect cacheRateSelect = new NativeSelect("Cache rate");
+ cacheRateSelect.setImmediate(true);
+ cacheRateSelect.setNullSelectionAllowed(false);
+ cacheRateSelect.addItem(new Integer(0));
+ cacheRateSelect.addItem(new Integer(1));
+ cacheRateSelect.addItem(new Integer(2));
+ cacheRateSelect.setValue(2);
+ cacheRateSelect.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ treeTable
+ .setCacheRate((Integer) event.getProperty().getValue());
+ }
+ });
+ addComponent(cacheRateSelect);
+ treeTable = new TreeTable();
+ treeTable.addStyleName("table-equal-rowheight");
+ // treeTable.setPageLength(0);
+ testBeanContainer = new BeanItemContainer<TestBean>(TestBean.class);
+
+ Map<String, Integer> hasChildren = new HashMap<String, Integer>();
+ hasChildren.put("1", 5);
+ hasChildren.put("3", 10);
+ hasChildren.put("5", 20);
+ hasChildren.put("6", 7);
+ hasChildren.put("7", 1);
+ hasChildren.put("40", 20);
+ hasChildren.put("99", 20);
+ treeTable.setContainerDataSource(createContainer(100, hasChildren));
+ treeTable.addGeneratedColumn("col3", new Col3ColumnGenerator());
+ treeTable.addListener(new ExpandListener() {
+
+ public void nodeExpand(ExpandEvent event) {
+ logExpandCollapse(event.getItemId(), "expanded");
+
+ }
+ });
+ treeTable.addListener(new CollapseListener() {
+
+ public void nodeCollapse(CollapseEvent event) {
+ logExpandCollapse(event.getItemId(), "collapsed");
+
+ }
+ });
+ treeTable.setColumnHeaders(columnHeaders);
+ treeTable.setVisibleColumns(visibleColumns);
+ treeTable.setColumnWidth("col1", 150);
+ treeTable.setColumnWidth("col2", 50);
+ treeTable.setHeight("430px");
+ // treeTable.setColumnWidth("col3", 150);
+ addComponent(log);
+ addComponent(treeTable);
+ }
+
+ protected void logExpandCollapse(Object itemId, String operation) {
+ String identifier = "Item " + itemId;
+ log.log("Row " + identifier + " " + operation + ". Row index: "
+ + indexOfId(treeTable, itemId));
+
+ }
+
+ private Container createContainer(int items,
+ Map<String, Integer> hasChildren) {
+ ContainerHierarchicalWrapper container;
+
+ container = new ContainerHierarchicalWrapper(testBeanContainer);
+ populate(container, items, hasChildren);
+ return container;
+ }
+
+ private void populate(Container.Hierarchical container, int items,
+ Map<String, Integer> children) {
+
+ for (int i = 0; i < items; i++) {
+ String row = String.valueOf(i + 1);
+ String rowText = stringForInt(i);
+
+ TestBean itemId = new TestBean(row, rowText);
+ container.addItem(itemId);
+ if (children.containsKey(row)) {
+ itemId.setCol1(itemId.getCol1() + " (children)");
+ for (int j = 0; j < children.get(row); j++) {
+ TestBean childItemId = new TestBean(row + "." + (j + 1),
+ rowText + "." + stringForInt(j));
+ container.addItem(childItemId);
+ container.setParent(childItemId, itemId);
+ }
+ }
+
+ }
+ }
+
+ private String stringForInt(int i) {
+ int charsAllowed = 26; // a-z
+ if (i >= charsAllowed) {
+ return stringForInt(i / charsAllowed - 1)
+ + stringForInt(i % charsAllowed);
+ } else {
+ return String.valueOf((char) (i + 'A'));
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/TreeTableTest.java b/tests/testbench/com/vaadin/tests/components/treetable/TreeTableTest.java
index 010c735047..d7d9c18d7e 100644
--- a/tests/testbench/com/vaadin/tests/components/treetable/TreeTableTest.java
+++ b/tests/testbench/com/vaadin/tests/components/treetable/TreeTableTest.java
@@ -1,300 +1,300 @@
-package com.vaadin.tests.components.treetable;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Hierarchical;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.tests.components.table.Tables;
-import com.vaadin.ui.Table.CellStyleGenerator;
-import com.vaadin.ui.Tree.CollapseEvent;
-import com.vaadin.ui.Tree.CollapseListener;
-import com.vaadin.ui.Tree.ExpandEvent;
-import com.vaadin.ui.Tree.ExpandListener;
-import com.vaadin.ui.TreeTable;
-
-public class TreeTableTest extends Tables<TreeTable> implements
- CollapseListener, ExpandListener {
-
- @Override
- protected Class<TreeTable> getTestClass() {
- return TreeTable.class;
- }
-
- private int rootItemIds = 3;
- private CellStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Table.CellStyleGenerator() {
-
- public String getStyle(Object itemId, Object propertyId) {
- if (propertyId != null) {
- return null;
- }
-
- Hierarchical c = getComponent().getContainerDataSource();
- if (c.isRoot(itemId)) {
- return "green";
- }
-
- Object parent = c.getParent(itemId);
- if (!c.isRoot(parent)) {
- return "red";
- }
-
- return null;
- }
-
- @Override
- public String toString() {
- return "Root green, second level red";
- }
-
- };
-
- private CellStyleGenerator evenItemsBold = new CellStyleGenerator() {
-
- public String getStyle(Object itemId, Object propertyId) {
- if (propertyId != null) {
- return null;
- }
-
- Hierarchical c = getComponent().getContainerDataSource();
- int idx = 0;
-
- for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) {
- Object id = i.next();
- if (id == itemId) {
- if (idx % 2 == 1) {
- return "bold";
- } else {
- return null;
- }
- }
-
- idx++;
- }
-
- return null;
- }
-
- @Override
- public String toString() {
- return "Even items bold";
- };
-
- };
-
- @Override
- protected void createActions() {
- super.createActions();
-
- // Causes container changes so doing this first..
- createRootItemSelectAction(CATEGORY_DATA_SOURCE);
-
- createExpandCollapseActions(CATEGORY_FEATURES);
- createChildrenAllowedAction(CATEGORY_DATA_SOURCE);
-
- createListeners(CATEGORY_LISTENERS);
- // createItemStyleGenerator(CATEGORY_FEATURES);
-
- createBooleanAction("Animate collapse/expand", CATEGORY_STATE, false,
- animationCommand);
-
- // TODO: DropHandler
- // TODO: DragMode
- // TODO: ActionHandler
-
- }
-
- @Override
- protected Container createContainer(int properties, int items) {
- return createHierarchicalContainer(properties, items, rootItemIds);
- }
-
- private void createListeners(String category) {
- createBooleanAction("Item click listener", category, false,
- itemClickListenerCommand);
- createBooleanAction("Expand listener", category, false,
- expandListenerCommand);
- createBooleanAction("Collapse listener", category, false,
- collapseListenerCommand);
-
- }
-
- private Container.Hierarchical createHierarchicalContainer(int properties,
- int items, int roots) {
- Container.Hierarchical c = new HierarchicalContainer();
-
- populateContainer(c, properties, items);
-
- if (items <= roots) {
- return c;
- }
-
- // "roots" roots, each with
- // "firstLevel" children, two with no children (one with childAllowed,
- // one without)
- // ("firstLevel"-2)*"secondLevel" children ("secondLevel"/2 with
- // childAllowed, "secondLevel"/2 without)
-
- // N*M+N*(M-2)*C = items
- // items=N(M+MC-2C)
-
- // Using secondLevel=firstLevel/2 =>
- // items = roots*(firstLevel+firstLevel*firstLevel/2-2*firstLevel/2)
- // =roots*(firstLevel+firstLevel^2/2-firstLevel)
- // = roots*firstLevel^2/2
- // => firstLevel = sqrt(items/roots*2)
-
- int firstLevel = (int) Math.ceil(Math.sqrt(items / roots * 2.0));
- int secondLevel = firstLevel / 2;
-
- while (roots * (1 + 2 + (firstLevel - 2) * secondLevel) < items) {
- // Increase something so we get enough items
- secondLevel++;
- }
-
- List<Object> itemIds = new ArrayList<Object>(c.getItemIds());
-
- int nextItemId = roots;
- for (int rootIndex = 0; rootIndex < roots; rootIndex++) {
- // roots use items 0..roots-1
- Object rootItemId = itemIds.get(rootIndex);
-
- // force roots to be roots even though they automatically should be
- c.setParent(rootItemId, null);
-
- for (int firstLevelIndex = 0; firstLevelIndex < firstLevel; firstLevelIndex++) {
- if (nextItemId >= items) {
- break;
- }
- Object firstLevelItemId = itemIds.get(nextItemId++);
- c.setParent(firstLevelItemId, rootItemId);
-
- if (firstLevelIndex < 2) {
- continue;
- }
-
- // firstLevelChildren 2.. have child nodes
- for (int secondLevelIndex = 0; secondLevelIndex < secondLevel; secondLevelIndex++) {
- if (nextItemId >= items) {
- break;
- }
-
- Object secondLevelItemId = itemIds.get(nextItemId++);
- c.setParent(secondLevelItemId, firstLevelItemId);
- }
- }
- }
-
- return c;
- }
-
- private void createRootItemSelectAction(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- for (int i = 1; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("20", 20);
- options.put("50", 50);
- options.put("100", 100);
-
- createSelectAction("Number of root items", category, options, "3",
- rootItemIdsCommand);
- }
-
- private void createExpandCollapseActions(String category) {
- LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
-
- for (Object id : getComponent().getItemIds()) {
- options.put(id.toString(), id);
- }
- createMultiClickAction("Expand", category, options, expandItemCommand,
- null);
- // createMultiClickAction("Expand recursively", category, options,
- // expandItemRecursivelyCommand, null);
- createMultiClickAction("Collapse", category, options,
- collapseItemCommand, null);
-
- }
-
- private void createChildrenAllowedAction(String category) {
- LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
-
- for (Object id : getComponent().getItemIds()) {
- options.put(id.toString(), id);
- }
- createMultiToggleAction("Children allowed", category, options,
- setChildrenAllowedCommand, true);
-
- }
-
- /*
- * COMMANDS
- */
- private Command<TreeTable, Integer> rootItemIdsCommand = new Command<TreeTable, Integer>() {
-
- public void execute(TreeTable c, Integer value, Object data) {
- rootItemIds = value;
- updateContainer();
- }
- };
-
- private Command<TreeTable, Object> expandItemCommand = new Command<TreeTable, Object>() {
-
- public void execute(TreeTable c, Object itemId, Object data) {
- c.setCollapsed(itemId, false);
- }
- };
-
- private Command<TreeTable, Object> collapseItemCommand = new Command<TreeTable, Object>() {
-
- public void execute(TreeTable c, Object itemId, Object data) {
- c.setCollapsed(itemId, true);
- }
- };
-
- private Command<TreeTable, Boolean> setChildrenAllowedCommand = new Command<TreeTable, Boolean>() {
-
- public void execute(TreeTable c, Boolean areChildrenAllowed,
- Object itemId) {
- c.setChildrenAllowed(itemId, areChildrenAllowed);
- }
- };
-
- private Command<TreeTable, Boolean> expandListenerCommand = new Command<TreeTable, Boolean>() {
- public void execute(TreeTable c, Boolean value, Object data) {
- if (value) {
- c.addListener((ExpandListener) TreeTableTest.this);
- } else {
- c.removeListener((ExpandListener) TreeTableTest.this);
- }
- }
- };
-
- private Command<TreeTable, Boolean> collapseListenerCommand = new Command<TreeTable, Boolean>() {
- public void execute(TreeTable c, Boolean value, Object data) {
- if (value) {
- c.addListener((CollapseListener) TreeTableTest.this);
- } else {
- c.removeListener((CollapseListener) TreeTableTest.this);
- }
- }
- };
-
- protected Command<TreeTable, Boolean> animationCommand = new Command<TreeTable, Boolean>() {
-
- public void execute(TreeTable c, Boolean enabled, Object data) {
- c.setAnimationsEnabled(enabled);
- }
- };
-
- public void nodeCollapse(CollapseEvent event) {
- log(event.getClass().getSimpleName() + ": " + event.getItemId());
- }
-
- public void nodeExpand(ExpandEvent event) {
- log(event.getClass().getSimpleName() + ": " + event.getItemId());
- }
-}
+package com.vaadin.tests.components.treetable;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Hierarchical;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.tests.components.table.Tables;
+import com.vaadin.ui.Table.CellStyleGenerator;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.CollapseListener;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.Tree.ExpandListener;
+import com.vaadin.ui.TreeTable;
+
+public class TreeTableTest extends Tables<TreeTable> implements
+ CollapseListener, ExpandListener {
+
+ @Override
+ protected Class<TreeTable> getTestClass() {
+ return TreeTable.class;
+ }
+
+ private int rootItemIds = 3;
+ private CellStyleGenerator rootGreenSecondLevelRed = new com.vaadin.ui.Table.CellStyleGenerator() {
+
+ public String getStyle(Object itemId, Object propertyId) {
+ if (propertyId != null) {
+ return null;
+ }
+
+ Hierarchical c = getComponent().getContainerDataSource();
+ if (c.isRoot(itemId)) {
+ return "green";
+ }
+
+ Object parent = c.getParent(itemId);
+ if (!c.isRoot(parent)) {
+ return "red";
+ }
+
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "Root green, second level red";
+ }
+
+ };
+
+ private CellStyleGenerator evenItemsBold = new CellStyleGenerator() {
+
+ public String getStyle(Object itemId, Object propertyId) {
+ if (propertyId != null) {
+ return null;
+ }
+
+ Hierarchical c = getComponent().getContainerDataSource();
+ int idx = 0;
+
+ for (Iterator<?> i = c.getItemIds().iterator(); i.hasNext();) {
+ Object id = i.next();
+ if (id == itemId) {
+ if (idx % 2 == 1) {
+ return "bold";
+ } else {
+ return null;
+ }
+ }
+
+ idx++;
+ }
+
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "Even items bold";
+ };
+
+ };
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+
+ // Causes container changes so doing this first..
+ createRootItemSelectAction(CATEGORY_DATA_SOURCE);
+
+ createExpandCollapseActions(CATEGORY_FEATURES);
+ createChildrenAllowedAction(CATEGORY_DATA_SOURCE);
+
+ createListeners(CATEGORY_LISTENERS);
+ // createItemStyleGenerator(CATEGORY_FEATURES);
+
+ createBooleanAction("Animate collapse/expand", CATEGORY_STATE, false,
+ animationCommand);
+
+ // TODO: DropHandler
+ // TODO: DragMode
+ // TODO: ActionHandler
+
+ }
+
+ @Override
+ protected Container createContainer(int properties, int items) {
+ return createHierarchicalContainer(properties, items, rootItemIds);
+ }
+
+ private void createListeners(String category) {
+ createBooleanAction("Item click listener", category, false,
+ itemClickListenerCommand);
+ createBooleanAction("Expand listener", category, false,
+ expandListenerCommand);
+ createBooleanAction("Collapse listener", category, false,
+ collapseListenerCommand);
+
+ }
+
+ private Container.Hierarchical createHierarchicalContainer(int properties,
+ int items, int roots) {
+ Container.Hierarchical c = new HierarchicalContainer();
+
+ populateContainer(c, properties, items);
+
+ if (items <= roots) {
+ return c;
+ }
+
+ // "roots" roots, each with
+ // "firstLevel" children, two with no children (one with childAllowed,
+ // one without)
+ // ("firstLevel"-2)*"secondLevel" children ("secondLevel"/2 with
+ // childAllowed, "secondLevel"/2 without)
+
+ // N*M+N*(M-2)*C = items
+ // items=N(M+MC-2C)
+
+ // Using secondLevel=firstLevel/2 =>
+ // items = roots*(firstLevel+firstLevel*firstLevel/2-2*firstLevel/2)
+ // =roots*(firstLevel+firstLevel^2/2-firstLevel)
+ // = roots*firstLevel^2/2
+ // => firstLevel = sqrt(items/roots*2)
+
+ int firstLevel = (int) Math.ceil(Math.sqrt(items / roots * 2.0));
+ int secondLevel = firstLevel / 2;
+
+ while (roots * (1 + 2 + (firstLevel - 2) * secondLevel) < items) {
+ // Increase something so we get enough items
+ secondLevel++;
+ }
+
+ List<Object> itemIds = new ArrayList<Object>(c.getItemIds());
+
+ int nextItemId = roots;
+ for (int rootIndex = 0; rootIndex < roots; rootIndex++) {
+ // roots use items 0..roots-1
+ Object rootItemId = itemIds.get(rootIndex);
+
+ // force roots to be roots even though they automatically should be
+ c.setParent(rootItemId, null);
+
+ for (int firstLevelIndex = 0; firstLevelIndex < firstLevel; firstLevelIndex++) {
+ if (nextItemId >= items) {
+ break;
+ }
+ Object firstLevelItemId = itemIds.get(nextItemId++);
+ c.setParent(firstLevelItemId, rootItemId);
+
+ if (firstLevelIndex < 2) {
+ continue;
+ }
+
+ // firstLevelChildren 2.. have child nodes
+ for (int secondLevelIndex = 0; secondLevelIndex < secondLevel; secondLevelIndex++) {
+ if (nextItemId >= items) {
+ break;
+ }
+
+ Object secondLevelItemId = itemIds.get(nextItemId++);
+ c.setParent(secondLevelItemId, firstLevelItemId);
+ }
+ }
+ }
+
+ return c;
+ }
+
+ private void createRootItemSelectAction(String category) {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ for (int i = 1; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("20", 20);
+ options.put("50", 50);
+ options.put("100", 100);
+
+ createSelectAction("Number of root items", category, options, "3",
+ rootItemIdsCommand);
+ }
+
+ private void createExpandCollapseActions(String category) {
+ LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
+
+ for (Object id : getComponent().getItemIds()) {
+ options.put(id.toString(), id);
+ }
+ createMultiClickAction("Expand", category, options, expandItemCommand,
+ null);
+ // createMultiClickAction("Expand recursively", category, options,
+ // expandItemRecursivelyCommand, null);
+ createMultiClickAction("Collapse", category, options,
+ collapseItemCommand, null);
+
+ }
+
+ private void createChildrenAllowedAction(String category) {
+ LinkedHashMap<String, Object> options = new LinkedHashMap<String, Object>();
+
+ for (Object id : getComponent().getItemIds()) {
+ options.put(id.toString(), id);
+ }
+ createMultiToggleAction("Children allowed", category, options,
+ setChildrenAllowedCommand, true);
+
+ }
+
+ /*
+ * COMMANDS
+ */
+ private Command<TreeTable, Integer> rootItemIdsCommand = new Command<TreeTable, Integer>() {
+
+ public void execute(TreeTable c, Integer value, Object data) {
+ rootItemIds = value;
+ updateContainer();
+ }
+ };
+
+ private Command<TreeTable, Object> expandItemCommand = new Command<TreeTable, Object>() {
+
+ public void execute(TreeTable c, Object itemId, Object data) {
+ c.setCollapsed(itemId, false);
+ }
+ };
+
+ private Command<TreeTable, Object> collapseItemCommand = new Command<TreeTable, Object>() {
+
+ public void execute(TreeTable c, Object itemId, Object data) {
+ c.setCollapsed(itemId, true);
+ }
+ };
+
+ private Command<TreeTable, Boolean> setChildrenAllowedCommand = new Command<TreeTable, Boolean>() {
+
+ public void execute(TreeTable c, Boolean areChildrenAllowed,
+ Object itemId) {
+ c.setChildrenAllowed(itemId, areChildrenAllowed);
+ }
+ };
+
+ private Command<TreeTable, Boolean> expandListenerCommand = new Command<TreeTable, Boolean>() {
+ public void execute(TreeTable c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((ExpandListener) TreeTableTest.this);
+ } else {
+ c.removeListener((ExpandListener) TreeTableTest.this);
+ }
+ }
+ };
+
+ private Command<TreeTable, Boolean> collapseListenerCommand = new Command<TreeTable, Boolean>() {
+ public void execute(TreeTable c, Boolean value, Object data) {
+ if (value) {
+ c.addListener((CollapseListener) TreeTableTest.this);
+ } else {
+ c.removeListener((CollapseListener) TreeTableTest.this);
+ }
+ }
+ };
+
+ protected Command<TreeTable, Boolean> animationCommand = new Command<TreeTable, Boolean>() {
+
+ public void execute(TreeTable c, Boolean enabled, Object data) {
+ c.setAnimationsEnabled(enabled);
+ }
+ };
+
+ public void nodeCollapse(CollapseEvent event) {
+ log(event.getClass().getSimpleName() + ": " + event.getItemId());
+ }
+
+ public void nodeExpand(ExpandEvent event) {
+ log(event.getClass().getSimpleName() + ": " + event.getItemId());
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/twincolselect/TwinColSelects.java b/tests/testbench/com/vaadin/tests/components/twincolselect/TwinColSelects.java
index ebbddc5f6a..ddb418dab3 100644
--- a/tests/testbench/com/vaadin/tests/components/twincolselect/TwinColSelects.java
+++ b/tests/testbench/com/vaadin/tests/components/twincolselect/TwinColSelects.java
@@ -1,64 +1,64 @@
-package com.vaadin.tests.components.twincolselect;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.ui.TwinColSelect;
-
-public class TwinColSelects extends AbstractSelectTestCase<TwinColSelect> {
-
- @Override
- protected Class<TwinColSelect> getTestClass() {
- return TwinColSelect.class;
- }
-
- @Override
- protected void createActions() {
- super.createActions();
- createColumnSelectAction();
- createRowSelectAction();
- }
-
- private void createColumnSelectAction() {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("-", 0);
- for (int i = 1; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("50", 50);
- options.put("100", 100);
- options.put("1000", 1000);
-
- super.createSelectAction("Columns", CATEGORY_DATA_SOURCE, options, "-",
- columnsAction);
-
- }
-
- private void createRowSelectAction() {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("-", 0);
- for (int i = 1; i <= 10; i++) {
- options.put(String.valueOf(i), i);
- }
- options.put("50", 50);
- options.put("100", 100);
- options.put("1000", 1000);
-
- super.createSelectAction("Rows", CATEGORY_DATA_SOURCE, options, "-",
- rowsAction);
-
- }
-
- private Command<TwinColSelect, Integer> columnsAction = new Command<TwinColSelect, Integer>() {
-
- public void execute(TwinColSelect c, Integer value, Object data) {
- c.setColumns(value);
- }
- };
- private Command<TwinColSelect, Integer> rowsAction = new Command<TwinColSelect, Integer>() {
-
- public void execute(TwinColSelect c, Integer value, Object data) {
- c.setRows(value);
- }
- };
-}
+package com.vaadin.tests.components.twincolselect;
+
+import java.util.LinkedHashMap;
+
+import com.vaadin.tests.components.select.AbstractSelectTestCase;
+import com.vaadin.ui.TwinColSelect;
+
+public class TwinColSelects extends AbstractSelectTestCase<TwinColSelect> {
+
+ @Override
+ protected Class<TwinColSelect> getTestClass() {
+ return TwinColSelect.class;
+ }
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createColumnSelectAction();
+ createRowSelectAction();
+ }
+
+ private void createColumnSelectAction() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("-", 0);
+ for (int i = 1; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("50", 50);
+ options.put("100", 100);
+ options.put("1000", 1000);
+
+ super.createSelectAction("Columns", CATEGORY_DATA_SOURCE, options, "-",
+ columnsAction);
+
+ }
+
+ private void createRowSelectAction() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("-", 0);
+ for (int i = 1; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("50", 50);
+ options.put("100", 100);
+ options.put("1000", 1000);
+
+ super.createSelectAction("Rows", CATEGORY_DATA_SOURCE, options, "-",
+ rowsAction);
+
+ }
+
+ private Command<TwinColSelect, Integer> columnsAction = new Command<TwinColSelect, Integer>() {
+
+ public void execute(TwinColSelect c, Integer value, Object data) {
+ c.setColumns(value);
+ }
+ };
+ private Command<TwinColSelect, Integer> rowsAction = new Command<TwinColSelect, Integer>() {
+
+ public void execute(TwinColSelect c, Integer value, Object data) {
+ c.setRows(value);
+ }
+ };
+}
diff --git a/tests/testbench/com/vaadin/tests/components/upload/ForceSubmit.java b/tests/testbench/com/vaadin/tests/components/upload/ForceSubmit.java
index 9f5c2b67e2..84e266dea2 100644
--- a/tests/testbench/com/vaadin/tests/components/upload/ForceSubmit.java
+++ b/tests/testbench/com/vaadin/tests/components/upload/ForceSubmit.java
@@ -1,85 +1,85 @@
-package com.vaadin.tests.components.upload;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Upload.FailedEvent;
-import com.vaadin.ui.Upload.FinishedEvent;
-import com.vaadin.ui.Upload.Receiver;
-import com.vaadin.ui.Upload.StartedEvent;
-
-public class ForceSubmit extends TestBase implements Receiver {
-
- @Override
- protected Integer getTicketNumber() {
- return 6630;
- }
-
- public OutputStream receiveUpload(String filename, String MIMEType) {
- return new ByteArrayOutputStream();
- }
-
- @Override
- protected void setup() {
-
- final TextField textField = new TextField("Test field");
- addComponent(textField);
-
- final Upload u;
-
- u = new Upload("Upload", this);
-
- u.setButtonCaption(null);
-
- addComponent(u);
-
- u.addListener(new Upload.FinishedListener() {
- public void uploadFinished(FinishedEvent event) {
- String filename = event.getFilename();
- long length = event.getLength();
- getMainWindow().showNotification(
- "Done. Filename : " + filename + " Lenght: " + length);
- }
- });
-
- u.addListener(new Upload.FailedListener() {
- public void uploadFailed(FailedEvent event) {
- getMainWindow().showNotification("Failed. No file selected?");
- }
- });
-
- u.addListener(new Upload.StartedListener() {
- public void uploadStarted(StartedEvent event) {
- getMainWindow().showNotification(
- "Started upload. TF value :" + textField.getValue());
- }
- });
-
- Button button = new Button(
- "I'm an external button (not the uploads builtin), hit me to start upload.");
- button.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- u.submitUpload();
- }
- });
-
- addComponent(button);
-
- }
-
- @Override
- protected String getDescription() {
- return "Some wireframists are just so web 1.0. If requirements "
- + "say the upload must not start until the whole form "
- + "is 'Oukeyd', that is what we gotta do. In these cases "
- + "developers most probably also want to hide the uploads"
- + " internal button by setting its caption to null.";
- }
-
-}
+package com.vaadin.tests.components.upload;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.FailedEvent;
+import com.vaadin.ui.Upload.FinishedEvent;
+import com.vaadin.ui.Upload.Receiver;
+import com.vaadin.ui.Upload.StartedEvent;
+
+public class ForceSubmit extends TestBase implements Receiver {
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6630;
+ }
+
+ public OutputStream receiveUpload(String filename, String MIMEType) {
+ return new ByteArrayOutputStream();
+ }
+
+ @Override
+ protected void setup() {
+
+ final TextField textField = new TextField("Test field");
+ addComponent(textField);
+
+ final Upload u;
+
+ u = new Upload("Upload", this);
+
+ u.setButtonCaption(null);
+
+ addComponent(u);
+
+ u.addListener(new Upload.FinishedListener() {
+ public void uploadFinished(FinishedEvent event) {
+ String filename = event.getFilename();
+ long length = event.getLength();
+ getMainWindow().showNotification(
+ "Done. Filename : " + filename + " Lenght: " + length);
+ }
+ });
+
+ u.addListener(new Upload.FailedListener() {
+ public void uploadFailed(FailedEvent event) {
+ getMainWindow().showNotification("Failed. No file selected?");
+ }
+ });
+
+ u.addListener(new Upload.StartedListener() {
+ public void uploadStarted(StartedEvent event) {
+ getMainWindow().showNotification(
+ "Started upload. TF value :" + textField.getValue());
+ }
+ });
+
+ Button button = new Button(
+ "I'm an external button (not the uploads builtin), hit me to start upload.");
+ button.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ u.submitUpload();
+ }
+ });
+
+ addComponent(button);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Some wireframists are just so web 1.0. If requirements "
+ + "say the upload must not start until the whole form "
+ + "is 'Oukeyd', that is what we gotta do. In these cases "
+ + "developers most probably also want to hide the uploads"
+ + " internal button by setting its caption to null.";
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/upload/TestFileUpload.java b/tests/testbench/com/vaadin/tests/components/upload/TestFileUpload.java
index 10f54e9ce6..4f1e8358f4 100644
--- a/tests/testbench/com/vaadin/tests/components/upload/TestFileUpload.java
+++ b/tests/testbench/com/vaadin/tests/components/upload/TestFileUpload.java
@@ -1,58 +1,58 @@
-package com.vaadin.tests.components.upload;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-
-import org.apache.commons.codec.digest.DigestUtils;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Upload.FinishedEvent;
-import com.vaadin.ui.Upload.Receiver;
-
-public class TestFileUpload extends TestBase implements Receiver {
-
- private Log log = new Log(5);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- @Override
- protected void setup() {
- Upload u = new Upload("Upload", new Upload.Receiver() {
-
- public OutputStream receiveUpload(String filename, String mimeType) {
- return baos;
- }
- });
- u.setDebugId("UPL");
- u.addListener(new Upload.FinishedListener() {
-
- public void uploadFinished(FinishedEvent event) {
- String hash = DigestUtils.md5Hex(baos.toByteArray());
- log.log("Upload finished. Name: " + event.getFilename()
- + ", Size: " + baos.size() + ", md5: " + hash);
- baos.reset();
- }
- });
-
- addComponent(log);
- addComponent(u);
- }
-
- public OutputStream receiveUpload(String filename, String MIMEType) {
- getMainWindow().showNotification("Receiving upload");
- return new ByteArrayOutputStream();
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6465;
- }
-
- @Override
- protected String getDescription() {
- return "Creates and prints an MD5 hash of any uploaded file.";
- }
-
-}
+package com.vaadin.tests.components.upload;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.codec.digest.DigestUtils;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.FinishedEvent;
+import com.vaadin.ui.Upload.Receiver;
+
+public class TestFileUpload extends TestBase implements Receiver {
+
+ private Log log = new Log(5);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ @Override
+ protected void setup() {
+ Upload u = new Upload("Upload", new Upload.Receiver() {
+
+ public OutputStream receiveUpload(String filename, String mimeType) {
+ return baos;
+ }
+ });
+ u.setDebugId("UPL");
+ u.addListener(new Upload.FinishedListener() {
+
+ public void uploadFinished(FinishedEvent event) {
+ String hash = DigestUtils.md5Hex(baos.toByteArray());
+ log.log("Upload finished. Name: " + event.getFilename()
+ + ", Size: " + baos.size() + ", md5: " + hash);
+ baos.reset();
+ }
+ });
+
+ addComponent(log);
+ addComponent(u);
+ }
+
+ public OutputStream receiveUpload(String filename, String MIMEType) {
+ getMainWindow().showNotification("Receiving upload");
+ return new ByteArrayOutputStream();
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6465;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Creates and prints an MD5 hash of any uploaded file.";
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java b/tests/testbench/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java
index d1a77d0e49..b6126f41da 100644
--- a/tests/testbench/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/upload/TestImmediateUploadInFormLayout.java
@@ -1,53 +1,53 @@
-package com.vaadin.tests.components.upload;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.util.Collections;
-import java.util.List;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Upload.Receiver;
-
-public class TestImmediateUploadInFormLayout extends
- ComponentTestCase<FormLayout> implements Receiver {
-
- @Override
- protected String getDescription() {
- return "On Firefox 3.5 and Opera 10.10, clicking on an immediate upload in a wide FormLayout has no effect";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4359;
- }
-
- @Override
- protected Class<FormLayout> getTestClass() {
- return FormLayout.class;
- }
-
- @Override
- protected void initializeComponents() {
-
- FormLayout formLayout = new FormLayout();
- formLayout.setWidth("100%");
- Upload u = new Upload("Upload in FormLayout", this);
- u.setImmediate(true);
- formLayout.addComponent(u);
- addTestComponent(formLayout);
-
- }
-
- @Override
- protected List<Component> createActions() {
- return Collections.emptyList();
- }
-
- public OutputStream receiveUpload(String filename, String MIMEType) {
- getMainWindow().showNotification("Receiving upload");
- return new ByteArrayOutputStream();
- }
-}
+package com.vaadin.tests.components.upload;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.List;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.Receiver;
+
+public class TestImmediateUploadInFormLayout extends
+ ComponentTestCase<FormLayout> implements Receiver {
+
+ @Override
+ protected String getDescription() {
+ return "On Firefox 3.5 and Opera 10.10, clicking on an immediate upload in a wide FormLayout has no effect";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4359;
+ }
+
+ @Override
+ protected Class<FormLayout> getTestClass() {
+ return FormLayout.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+
+ FormLayout formLayout = new FormLayout();
+ formLayout.setWidth("100%");
+ Upload u = new Upload("Upload in FormLayout", this);
+ u.setImmediate(true);
+ formLayout.addComponent(u);
+ addTestComponent(formLayout);
+
+ }
+
+ @Override
+ protected List<Component> createActions() {
+ return Collections.emptyList();
+ }
+
+ public OutputStream receiveUpload(String filename, String MIMEType) {
+ getMainWindow().showNotification("Receiving upload");
+ return new ByteArrayOutputStream();
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/upload/TestUpload.java b/tests/testbench/com/vaadin/tests/components/upload/TestUpload.java
index 6690603958..535372f710 100644
--- a/tests/testbench/com/vaadin/tests/components/upload/TestUpload.java
+++ b/tests/testbench/com/vaadin/tests/components/upload/TestUpload.java
@@ -1,59 +1,59 @@
-package com.vaadin.tests.components.upload;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Upload.FinishedEvent;
-import com.vaadin.ui.Upload.Receiver;
-
-public class TestUpload extends ComponentTestCase<Upload> implements Receiver {
-
- @Override
- protected Integer getTicketNumber() {
- return 3525;
- }
-
- @Override
- protected Class<Upload> getTestClass() {
- return Upload.class;
- }
-
- @Override
- protected void initializeComponents() {
- Upload u;
-
- u = new Upload("Undefined wide upload", this);
- u.setSizeUndefined();
- addTestComponent(u);
-
- u.addListener(new Upload.FinishedListener() {
- public void uploadFinished(FinishedEvent event) {
- getMainWindow().showNotification("Done");
- }
- });
-
- u = new Upload("300px wide upload", this);
- u.setWidth("300px");
- addTestComponent(u);
-
- }
-
- @Override
- protected List<Component> createActions() {
- List<Component> actions = new ArrayList<Component>();
- actions.add(createEnabledAction(true));
-
- return actions;
- }
-
- public OutputStream receiveUpload(String filename, String MIMEType) {
- getMainWindow().showNotification("Receiving upload");
- return new ByteArrayOutputStream();
- }
-
-}
+package com.vaadin.tests.components.upload;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.FinishedEvent;
+import com.vaadin.ui.Upload.Receiver;
+
+public class TestUpload extends ComponentTestCase<Upload> implements Receiver {
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3525;
+ }
+
+ @Override
+ protected Class<Upload> getTestClass() {
+ return Upload.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+ Upload u;
+
+ u = new Upload("Undefined wide upload", this);
+ u.setSizeUndefined();
+ addTestComponent(u);
+
+ u.addListener(new Upload.FinishedListener() {
+ public void uploadFinished(FinishedEvent event) {
+ getMainWindow().showNotification("Done");
+ }
+ });
+
+ u = new Upload("300px wide upload", this);
+ u.setWidth("300px");
+ addTestComponent(u);
+
+ }
+
+ @Override
+ protected List<Component> createActions() {
+ List<Component> actions = new ArrayList<Component>();
+ actions.add(createEnabledAction(true));
+
+ return actions;
+ }
+
+ public OutputStream receiveUpload(String filename, String MIMEType) {
+ getMainWindow().showNotification("Receiving upload");
+ return new ByteArrayOutputStream();
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java b/tests/testbench/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java
index 009cc63168..0aa8e809c4 100644
--- a/tests/testbench/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java
+++ b/tests/testbench/com/vaadin/tests/components/upload/TestUploadAndDisableOnSuccess.java
@@ -1,102 +1,102 @@
-package com.vaadin.tests.components.upload;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Upload;
-import com.vaadin.ui.Upload.FinishedEvent;
-import com.vaadin.ui.Upload.Receiver;
-import com.vaadin.ui.Upload.StartedEvent;
-
-public class TestUploadAndDisableOnSuccess extends ComponentTestCase<Upload>
- implements Receiver {
-
- @Override
- protected String getDescription() {
- return "If upload is detached and attached during upload, the client side componenent never receives information that the upload has finished. Second update will not be successful.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4605;
- }
-
- @Override
- protected Class<Upload> getTestClass() {
- return Upload.class;
- }
-
- int counter = 0;
- private Label l;
-
- @Override
- protected void initializeComponents() {
-
- final Label labe = new Label();
-
- addComponent(labe);
-
- final Upload u;
- u = new Upload(null, this);
- u.setImmediate(true);
- addTestComponent(u);
-
- l = new Label(getUploadcount());
- addComponent(l);
-
- u.addListener(new Upload.StartedListener() {
-
- public void uploadStarted(StartedEvent event) {
- /*
- * Remove component before upload from the same vertical layout.
- * Causes upload to be detached/attached -> upload loses it
- * target iframes onload listener -> puts VUpload inappropriate
- * state.
- */
- getLayout().removeComponent(labe);
- }
- });
-
- u.addListener(new Upload.FinishedListener() {
- public void uploadFinished(FinishedEvent event) {
- getMainWindow().showNotification("Done");
- l.setValue(getUploadcount());
- }
- });
-
- }
-
- private String getUploadcount() {
- return counter++ + " uploads";
- }
-
- @Override
- protected List<Component> createActions() {
- List<Component> actions = new ArrayList<Component>();
- actions.add(createButtonAction("Toggle Enabled",
- new Command<Upload, Boolean>() {
-
- public void execute(Upload c, Boolean value, Object data) {
- c.setEnabled(!c.isEnabled());
- }
- }));
-
- return actions;
- }
-
- public OutputStream receiveUpload(String filename, String MIMEType) {
- // sleep to ensure change before upload is complete
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return new ByteArrayOutputStream();
- }
-
-}
+package com.vaadin.tests.components.upload;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.FinishedEvent;
+import com.vaadin.ui.Upload.Receiver;
+import com.vaadin.ui.Upload.StartedEvent;
+
+public class TestUploadAndDisableOnSuccess extends ComponentTestCase<Upload>
+ implements Receiver {
+
+ @Override
+ protected String getDescription() {
+ return "If upload is detached and attached during upload, the client side componenent never receives information that the upload has finished. Second update will not be successful.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4605;
+ }
+
+ @Override
+ protected Class<Upload> getTestClass() {
+ return Upload.class;
+ }
+
+ int counter = 0;
+ private Label l;
+
+ @Override
+ protected void initializeComponents() {
+
+ final Label labe = new Label();
+
+ addComponent(labe);
+
+ final Upload u;
+ u = new Upload(null, this);
+ u.setImmediate(true);
+ addTestComponent(u);
+
+ l = new Label(getUploadcount());
+ addComponent(l);
+
+ u.addListener(new Upload.StartedListener() {
+
+ public void uploadStarted(StartedEvent event) {
+ /*
+ * Remove component before upload from the same vertical layout.
+ * Causes upload to be detached/attached -> upload loses it
+ * target iframes onload listener -> puts VUpload inappropriate
+ * state.
+ */
+ getLayout().removeComponent(labe);
+ }
+ });
+
+ u.addListener(new Upload.FinishedListener() {
+ public void uploadFinished(FinishedEvent event) {
+ getMainWindow().showNotification("Done");
+ l.setValue(getUploadcount());
+ }
+ });
+
+ }
+
+ private String getUploadcount() {
+ return counter++ + " uploads";
+ }
+
+ @Override
+ protected List<Component> createActions() {
+ List<Component> actions = new ArrayList<Component>();
+ actions.add(createButtonAction("Toggle Enabled",
+ new Command<Upload, Boolean>() {
+
+ public void execute(Upload c, Boolean value, Object data) {
+ c.setEnabled(!c.isEnabled());
+ }
+ }));
+
+ return actions;
+ }
+
+ public OutputStream receiveUpload(String filename, String MIMEType) {
+ // sleep to ensure change before upload is complete
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return new ByteArrayOutputStream();
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
index a6040c06d3..ea04c3ad30 100644
--- a/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
+++ b/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
@@ -1,129 +1,129 @@
-package com.vaadin.tests.components.window;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.terminal.gwt.server.HttpServletRequestListener;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class AttachShouldBeCalledForSubWindows extends AbstractTestCase
- implements HttpServletRequestListener {
- private static final long serialVersionUID = 1L;
-
- private Log log = new Log(20);
-
- boolean addSubWindowBeforeMainWindow = true;
-
- @Override
- public void init() {
-
- Window mainWindow = new Window() {
- @Override
- public void attach() {
- log(this);
- super.attach();
- }
-
- @Override
- public void addWindow(Window w) {
- log.log("Adding sub window");
- super.addWindow(w);
- log.log("Sub window added");
-
- }
- };
- mainWindow.setCaption("Main window");
- mainWindow.addComponent(log);
- mainWindow.getContent().setSizeFull();
- Label label = new Label("This is the main app") {
- @Override
- public void attach() {
- log(this);
- super.attach();
- }
- };
-
- mainWindow.addComponent(label);
- Window loginWindow = createSubWindow();
- if (addSubWindowBeforeMainWindow) {
- mainWindow.addWindow(loginWindow);
- }
-
- log.log("Setting main window");
- setMainWindow(mainWindow); // At this point
- log.log("Main window set");
-
- if (!addSubWindowBeforeMainWindow) {
- mainWindow.addWindow(loginWindow);
- }
- }
-
- private Window createSubWindow() {
- Window w = new Window("Sub window") {
- @Override
- public void attach() {
- log(this);
- super.attach();
- }
- };
- Button okButton = new Button("OK") {
- @Override
- public void attach() {
- super.attach();
- log(this);
- }
- };
- okButton.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- log.log("Button clicked");
-
- }
- });
- okButton.setClickShortcut(KeyCode.ENTER);
- w.addComponent(okButton);
- w.center();
- return w;
- }
-
- public void log(Component c) {
- Class<?> cls = c.getClass();
- if (cls.isAnonymousClass()) {
- cls = cls.getSuperclass();
- }
- log.log(cls.getName() + " '" + c.getCaption()
- + "' attached to application");
- }
-
- @Override
- protected String getDescription() {
- return "By default attaches a sub window with a button to the main window and then set the main window to the application. Use ?attachMainFirst to reverse the order. In both cases attach events should be sent for the components in the sub window";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 8170;
- }
-
- public void onRequestStart(HttpServletRequest request,
- HttpServletResponse response) {
- if (request.getParameter("attachMainFirst") != null) {
- addSubWindowBeforeMainWindow = false;
- }
-
- }
-
- public void onRequestEnd(HttpServletRequest request,
- HttpServletResponse response) {
- // TODO Auto-generated method stub
-
- }
-}
+package com.vaadin.tests.components.window;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.terminal.gwt.server.HttpServletRequestListener;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class AttachShouldBeCalledForSubWindows extends AbstractTestCase
+ implements HttpServletRequestListener {
+ private static final long serialVersionUID = 1L;
+
+ private Log log = new Log(20);
+
+ boolean addSubWindowBeforeMainWindow = true;
+
+ @Override
+ public void init() {
+
+ Window mainWindow = new Window() {
+ @Override
+ public void attach() {
+ log(this);
+ super.attach();
+ }
+
+ @Override
+ public void addWindow(Window w) {
+ log.log("Adding sub window");
+ super.addWindow(w);
+ log.log("Sub window added");
+
+ }
+ };
+ mainWindow.setCaption("Main window");
+ mainWindow.addComponent(log);
+ mainWindow.getContent().setSizeFull();
+ Label label = new Label("This is the main app") {
+ @Override
+ public void attach() {
+ log(this);
+ super.attach();
+ }
+ };
+
+ mainWindow.addComponent(label);
+ Window loginWindow = createSubWindow();
+ if (addSubWindowBeforeMainWindow) {
+ mainWindow.addWindow(loginWindow);
+ }
+
+ log.log("Setting main window");
+ setMainWindow(mainWindow); // At this point
+ log.log("Main window set");
+
+ if (!addSubWindowBeforeMainWindow) {
+ mainWindow.addWindow(loginWindow);
+ }
+ }
+
+ private Window createSubWindow() {
+ Window w = new Window("Sub window") {
+ @Override
+ public void attach() {
+ log(this);
+ super.attach();
+ }
+ };
+ Button okButton = new Button("OK") {
+ @Override
+ public void attach() {
+ super.attach();
+ log(this);
+ }
+ };
+ okButton.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ log.log("Button clicked");
+
+ }
+ });
+ okButton.setClickShortcut(KeyCode.ENTER);
+ w.addComponent(okButton);
+ w.center();
+ return w;
+ }
+
+ public void log(Component c) {
+ Class<?> cls = c.getClass();
+ if (cls.isAnonymousClass()) {
+ cls = cls.getSuperclass();
+ }
+ log.log(cls.getName() + " '" + c.getCaption()
+ + "' attached to application");
+ }
+
+ @Override
+ protected String getDescription() {
+ return "By default attaches a sub window with a button to the main window and then set the main window to the application. Use ?attachMainFirst to reverse the order. In both cases attach events should be sent for the components in the sub window";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8170;
+ }
+
+ public void onRequestStart(HttpServletRequest request,
+ HttpServletResponse response) {
+ if (request.getParameter("attachMainFirst") != null) {
+ addSubWindowBeforeMainWindow = false;
+ }
+
+ }
+
+ public void onRequestEnd(HttpServletRequest request,
+ HttpServletResponse response) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/CloseSubWindow.java b/tests/testbench/com/vaadin/tests/components/window/CloseSubWindow.java
index 9a5fff18ed..c1104836a8 100644
--- a/tests/testbench/com/vaadin/tests/components/window/CloseSubWindow.java
+++ b/tests/testbench/com/vaadin/tests/components/window/CloseSubWindow.java
@@ -1,129 +1,129 @@
-package com.vaadin.tests.components.window;
-
-import java.net.URL;
-
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Window.CloseEvent;
-import com.vaadin.ui.Window.CloseListener;
-
-public class CloseSubWindow extends TestBase {
-
- private Window browserWindow;
- private Log log = new Log(5);
-
- @Override
- protected void setup() {
- Button openWindowButton = new Button("Open sub-window");
- openWindowButton.setDebugId("opensub");
- openWindowButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- Window sub = createClosableSubWindow("Sub-window");
- getMainWindow().addWindow(sub);
- }
- });
-
- addComponent(log);
- addComponent(openWindowButton);
-
- Button openBrowserWindowButton = new Button("Open browser window");
- openWindowButton.setDebugId("opennative");
- openBrowserWindowButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- browserWindow = new Window("Window");
- Button closeButton = new Button("Close this window",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- event.getButton().getWindow()
- .executeJavaScript("window.close();");
-
- }
- });
- browserWindow.addComponent(closeButton);
-
- browserWindow.addListener(new CloseListener() {
- public void windowClose(CloseEvent e) {
- logBrowserWindowClosed();
- // there is no push, so the user needs to click a button
- // to see the notification
-
- // Opera does not send a notification about the window
- // having been closed
- }
-
- });
-
- addWindow(browserWindow);
- URL windowUrl = browserWindow.getURL();
- // named for easier access by test tools
- getMainWindow().open(new ExternalResource(windowUrl),
- "nativewindow");
- if (getBrowser().isOpera()) {
- // Immediately log a close event in Opera so this test can
- // be run for all browsers. Vaadin ticket #5687.
- logBrowserWindowClosed();
- }
- }
- });
-
- addComponent(openBrowserWindowButton);
-
- Button pollButton = new Button("Poll server");
- pollButton.setDebugId("poll");
- addComponent(pollButton);
-
- }
-
- private Window createClosableSubWindow(final String title) {
- final Window window = new Window(title);
- window.setSizeUndefined();
- window.getContent().setSizeFull();
- window.setClosable(true);
-
- Button closeButton = new Button("Close");
- closeButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- window.getParent().removeWindow(window);
- }
- });
- window.addComponent(closeButton);
-
- Button removeButton = new Button("Remove from parent");
- removeButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- window.getParent().removeWindow(window);
- }
- });
- window.addComponent(closeButton);
-
- window.addListener(new CloseListener() {
- public void windowClose(CloseEvent e) {
- log.log("Window '" + title + "' closed");
- }
- });
-
- return window;
- }
-
- @Override
- protected String getDescription() {
- return "Close sub-windows both from code and with the close button in the window title bar, and check for close events. Contains an ugly workaround for the Opera bug (Opera does not send close events)";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3865;
- }
-
- private void logBrowserWindowClosed() {
- log.log("Browser window closed");
-
- }
-
-}
+package com.vaadin.tests.components.window;
+
+import java.net.URL;
+
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class CloseSubWindow extends TestBase {
+
+ private Window browserWindow;
+ private Log log = new Log(5);
+
+ @Override
+ protected void setup() {
+ Button openWindowButton = new Button("Open sub-window");
+ openWindowButton.setDebugId("opensub");
+ openWindowButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Window sub = createClosableSubWindow("Sub-window");
+ getMainWindow().addWindow(sub);
+ }
+ });
+
+ addComponent(log);
+ addComponent(openWindowButton);
+
+ Button openBrowserWindowButton = new Button("Open browser window");
+ openWindowButton.setDebugId("opennative");
+ openBrowserWindowButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ browserWindow = new Window("Window");
+ Button closeButton = new Button("Close this window",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ event.getButton().getWindow()
+ .executeJavaScript("window.close();");
+
+ }
+ });
+ browserWindow.addComponent(closeButton);
+
+ browserWindow.addListener(new CloseListener() {
+ public void windowClose(CloseEvent e) {
+ logBrowserWindowClosed();
+ // there is no push, so the user needs to click a button
+ // to see the notification
+
+ // Opera does not send a notification about the window
+ // having been closed
+ }
+
+ });
+
+ addWindow(browserWindow);
+ URL windowUrl = browserWindow.getURL();
+ // named for easier access by test tools
+ getMainWindow().open(new ExternalResource(windowUrl),
+ "nativewindow");
+ if (getBrowser().isOpera()) {
+ // Immediately log a close event in Opera so this test can
+ // be run for all browsers. Vaadin ticket #5687.
+ logBrowserWindowClosed();
+ }
+ }
+ });
+
+ addComponent(openBrowserWindowButton);
+
+ Button pollButton = new Button("Poll server");
+ pollButton.setDebugId("poll");
+ addComponent(pollButton);
+
+ }
+
+ private Window createClosableSubWindow(final String title) {
+ final Window window = new Window(title);
+ window.setSizeUndefined();
+ window.getContent().setSizeFull();
+ window.setClosable(true);
+
+ Button closeButton = new Button("Close");
+ closeButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ window.getParent().removeWindow(window);
+ }
+ });
+ window.addComponent(closeButton);
+
+ Button removeButton = new Button("Remove from parent");
+ removeButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ window.getParent().removeWindow(window);
+ }
+ });
+ window.addComponent(closeButton);
+
+ window.addListener(new CloseListener() {
+ public void windowClose(CloseEvent e) {
+ log.log("Window '" + title + "' closed");
+ }
+ });
+
+ return window;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Close sub-windows both from code and with the close button in the window title bar, and check for close events. Contains an ugly workaround for the Opera bug (Opera does not send close events)";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3865;
+ }
+
+ private void logBrowserWindowClosed() {
+ log.log("Browser window closed");
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/ExtraLargeSubWindow.java b/tests/testbench/com/vaadin/tests/components/window/ExtraLargeSubWindow.java
index bcaa44dc76..5ce0636f6f 100644
--- a/tests/testbench/com/vaadin/tests/components/window/ExtraLargeSubWindow.java
+++ b/tests/testbench/com/vaadin/tests/components/window/ExtraLargeSubWindow.java
@@ -1,32 +1,32 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.Window;
-
-public class ExtraLargeSubWindow extends TestBase {
-
- @Override
- protected void setup() {
- Window w = new Window("full sized window");
- w.setWidth("2000px");
- w.setHeight("2000px");
- w.getContent().setSizeFull();
- NativeButton b = new NativeButton("A large button");
- b.setSizeFull();
- w.addComponent(b);
-
- getMainWindow().addWindow(w);
- }
-
- @Override
- protected String getDescription() {
- return "A 100%x100% sub window should not produce scrollbars in the main view or in the sub window. The button inside the sub window is 100%x100%, as is the layout";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3407;
- }
-
-}
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.Window;
+
+public class ExtraLargeSubWindow extends TestBase {
+
+ @Override
+ protected void setup() {
+ Window w = new Window("full sized window");
+ w.setWidth("2000px");
+ w.setHeight("2000px");
+ w.getContent().setSizeFull();
+ NativeButton b = new NativeButton("A large button");
+ b.setSizeFull();
+ w.addComponent(b);
+
+ getMainWindow().addWindow(w);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A 100%x100% sub window should not produce scrollbars in the main view or in the sub window. The button inside the sub window is 100%x100%, as is the layout";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3407;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java b/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java
index a7079b2d99..284a63543a 100644
--- a/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java
+++ b/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java
@@ -1,53 +1,53 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Window;
-
-public class ExtraWindowShown extends TestBase {
-
- @Override
- protected void setup() {
- Button b = new Button("Open window", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
-
- final Window w = new Window("Sub window");
- w.center();
- w.addComponent(new Button("Close", new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Window main = w.getParent();
- // main = w.getWindow();
- main.removeWindow(w);
- }
- }));
- Button iconButton = new Button("A button with icon");
- iconButton
- .setIcon(new ThemeResource("../runo/icons/16/ok.png"));
- w.addComponent(iconButton);
- event.getButton().getWindow().addWindow(w);
- }
-
- });
- getLayout().setHeight("100%");
- getLayout().addComponent(b);
- getLayout().setComponentAlignment(b, Alignment.MIDDLE_CENTER);
- }
-
- @Override
- protected String getDescription() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
+package com.vaadin.tests.components.window;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Window;
+
+public class ExtraWindowShown extends TestBase {
+
+ @Override
+ protected void setup() {
+ Button b = new Button("Open window", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+
+ final Window w = new Window("Sub window");
+ w.center();
+ w.addComponent(new Button("Close", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Window main = w.getParent();
+ // main = w.getWindow();
+ main.removeWindow(w);
+ }
+ }));
+ Button iconButton = new Button("A button with icon");
+ iconButton
+ .setIcon(new ThemeResource("../runo/icons/16/ok.png"));
+ w.addComponent(iconButton);
+ event.getButton().getWindow().addWindow(w);
+ }
+
+ });
+ getLayout().setHeight("100%");
+ getLayout().addComponent(b);
+ getLayout().setComponentAlignment(b, Alignment.MIDDLE_CENTER);
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/FullSizedWindow.java b/tests/testbench/com/vaadin/tests/components/window/FullSizedWindow.java
index 3cb5f45712..6d0dc74e93 100644
--- a/tests/testbench/com/vaadin/tests/components/window/FullSizedWindow.java
+++ b/tests/testbench/com/vaadin/tests/components/window/FullSizedWindow.java
@@ -1,31 +1,31 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.Window;
-
-public class FullSizedWindow extends TestBase {
-
- @Override
- protected void setup() {
- Window w = new Window("full sized window");
- w.setSizeFull();
- w.getContent().setSizeFull();
- NativeButton b = new NativeButton("A large button");
- b.setSizeFull();
- w.getContent().addComponent(b);
- getMainWindow().addWindow(w);
- setTheme("runo");
- }
-
- @Override
- protected String getDescription() {
- return "A 100%x100% sub window should not produce scrollbars in the main view or in the sub window. The button inside the sub window is 100%x100%, as is the layout";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3407;
- }
-
-}
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.Window;
+
+public class FullSizedWindow extends TestBase {
+
+ @Override
+ protected void setup() {
+ Window w = new Window("full sized window");
+ w.setSizeFull();
+ w.getContent().setSizeFull();
+ NativeButton b = new NativeButton("A large button");
+ b.setSizeFull();
+ w.getContent().addComponent(b);
+ getMainWindow().addWindow(w);
+ setTheme("runo");
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A 100%x100% sub window should not produce scrollbars in the main view or in the sub window. The button inside the sub window is 100%x100%, as is the layout";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3407;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/ModalWindowNativeSelect.java b/tests/testbench/com/vaadin/tests/components/window/ModalWindowNativeSelect.java
index d7672a88d5..2c6d3c942f 100644
--- a/tests/testbench/com/vaadin/tests/components/window/ModalWindowNativeSelect.java
+++ b/tests/testbench/com/vaadin/tests/components/window/ModalWindowNativeSelect.java
@@ -1,32 +1,32 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.Window;
-
-public class ModalWindowNativeSelect extends TestBase {
-
- @Override
- protected void setup() {
- NativeSelect ns = new NativeSelect();
-
- Window modalWindow = new Window();
- modalWindow.setModal(true);
- modalWindow.center();
-
- addComponent(ns);
- getMainWindow().addWindow(modalWindow);
-
- }
-
- @Override
- protected String getDescription() {
- return "The native select should be behind the modality curtain and user should not be able to interact with it";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4261;
- }
-
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Window;
+
+public class ModalWindowNativeSelect extends TestBase {
+
+ @Override
+ protected void setup() {
+ NativeSelect ns = new NativeSelect();
+
+ Window modalWindow = new Window();
+ modalWindow.setModal(true);
+ modalWindow.center();
+
+ addComponent(ns);
+ getMainWindow().addWindow(modalWindow);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The native select should be behind the modality curtain and user should not be able to interact with it";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4261;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/components/window/SubwindowInvalidLayout.java b/tests/testbench/com/vaadin/tests/components/window/SubwindowInvalidLayout.java
index aeab7f6c97..03e5988fad 100644
--- a/tests/testbench/com/vaadin/tests/components/window/SubwindowInvalidLayout.java
+++ b/tests/testbench/com/vaadin/tests/components/window/SubwindowInvalidLayout.java
@@ -1,35 +1,35 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class SubwindowInvalidLayout extends TestBase {
-
- @Override
- protected String getDescription() {
- return "The subwindow contains an invalid layout, which analyze layouts should detect.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3096;
- }
-
- @Override
- protected void setup() {
- Window window = new Window("Sub window");
- window.center();
-
- VerticalLayout vl = new VerticalLayout();
- vl.setWidth(null);
- Button b = new Button("A 100% wide button, invalid");
- b.setWidth("100%");
- vl.addComponent(b);
- window.addComponent(vl);
-
- getMainWindow().addWindow(window);
- }
-
-}
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class SubwindowInvalidLayout extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "The subwindow contains an invalid layout, which analyze layouts should detect.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3096;
+ }
+
+ @Override
+ protected void setup() {
+ Window window = new Window("Sub window");
+ window.center();
+
+ VerticalLayout vl = new VerticalLayout();
+ vl.setWidth(null);
+ Button b = new Button("A 100% wide button, invalid");
+ b.setWidth("100%");
+ vl.addComponent(b);
+ window.addComponent(vl);
+
+ getMainWindow().addWindow(window);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java
index 7889a58f81..200d52a389 100644
--- a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java
+++ b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java
@@ -1,137 +1,137 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class WindowScrollingComponentIntoView 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().getContent().setSizeUndefined();
-
- Component l2 = null;
- for (int i = 0; i < 10; i++) {
- l2 = l("X" + i);
- getMainWindow().addComponent(l2);
- }
-
- final Component x9 = l2;
-
- HorizontalLayout horizontalLayout = new HorizontalLayout();
-
- Component l = null;
- for (int i = 0; i < 10; i++) {
- l = l("Y" + i);
- horizontalLayout.addComponent(l);
- }
-
- getMainWindow().addComponent(horizontalLayout);
- final Component y9 = l;
-
- final Window window = new Window();
- window.setHeight("500px");
- window.setWidth("500px");
- window.setPositionX(200);
- window.setPositionY(200);
-
- window.addComponent(new Button("Scroll mainwin to X9",
- new ClickListener() {
- public void buttonClick(ClickEvent event) {
- getMainWindow().scrollIntoView(x9);
-
- }
- }));
- window.addComponent(new Button("Scroll mainwin to Y9",
- new ClickListener() {
- public void buttonClick(ClickEvent event) {
- getMainWindow().scrollIntoView(y9);
-
- }
- }));
-
- Panel panel = new Panel("scrollable panel");
- panel.setHeight(400, Panel.UNITS_PIXELS);
- panel.setScrollable(true);
- panel.setScrollLeft(50);
- panel.setScrollTop(50);
- panel.getContent().setSizeUndefined();
- window.addComponent(l("Spacer", 500, 500));
-
- l2 = null;
- for (int i = 0; i < 10; i++) {
- l2 = l("X" + i);
- panel.addComponent(l2);
- }
-
- final Component x29 = l2;
-
- horizontalLayout = new HorizontalLayout();
-
- l = null;
- for (int i = 0; i < 10; i++) {
- l = l("Y" + i);
- horizontalLayout.addComponent(l);
- }
- panel.addComponent(horizontalLayout);
- final Component y29 = l;
-
- ((VerticalLayout) getMainWindow().getContent()).addComponent(
- new Button("Scroll win to X9", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- window.scrollIntoView(x29);
- }
- }), 0);
- ((VerticalLayout) getMainWindow().getContent()).addComponent(
- new Button("Scroll win to Y9", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- window.scrollIntoView(y29);
- }
- }), 0);
-
- window.addComponent(panel);
- getMainWindow().addWindow(window);
-
- }
-
- private Component l(String string) {
- return l(string, 200, 350);
- }
-
- private Component l(String string, int h, int w) {
- Label label = new Label(string);
- label.setHeight(h, Label.UNITS_PIXELS);
- label.setWidth(w, Label.UNITS_PIXELS);
- return label;
- }
-}
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class WindowScrollingComponentIntoView 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().getContent().setSizeUndefined();
+
+ Component l2 = null;
+ for (int i = 0; i < 10; i++) {
+ l2 = l("X" + i);
+ getMainWindow().addComponent(l2);
+ }
+
+ final Component x9 = l2;
+
+ HorizontalLayout horizontalLayout = new HorizontalLayout();
+
+ Component l = null;
+ for (int i = 0; i < 10; i++) {
+ l = l("Y" + i);
+ horizontalLayout.addComponent(l);
+ }
+
+ getMainWindow().addComponent(horizontalLayout);
+ final Component y9 = l;
+
+ final Window window = new Window();
+ window.setHeight("500px");
+ window.setWidth("500px");
+ window.setPositionX(200);
+ window.setPositionY(200);
+
+ window.addComponent(new Button("Scroll mainwin to X9",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().scrollIntoView(x9);
+
+ }
+ }));
+ window.addComponent(new Button("Scroll mainwin to Y9",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().scrollIntoView(y9);
+
+ }
+ }));
+
+ Panel panel = new Panel("scrollable panel");
+ panel.setHeight(400, Panel.UNITS_PIXELS);
+ panel.setScrollable(true);
+ panel.setScrollLeft(50);
+ panel.setScrollTop(50);
+ panel.getContent().setSizeUndefined();
+ window.addComponent(l("Spacer", 500, 500));
+
+ l2 = null;
+ for (int i = 0; i < 10; i++) {
+ l2 = l("X" + i);
+ panel.addComponent(l2);
+ }
+
+ final Component x29 = l2;
+
+ horizontalLayout = new HorizontalLayout();
+
+ l = null;
+ for (int i = 0; i < 10; i++) {
+ l = l("Y" + i);
+ horizontalLayout.addComponent(l);
+ }
+ panel.addComponent(horizontalLayout);
+ final Component y29 = l;
+
+ ((VerticalLayout) getMainWindow().getContent()).addComponent(
+ new Button("Scroll win to X9", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ window.scrollIntoView(x29);
+ }
+ }), 0);
+ ((VerticalLayout) getMainWindow().getContent()).addComponent(
+ new Button("Scroll win to Y9", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ window.scrollIntoView(y29);
+ }
+ }), 0);
+
+ window.addComponent(panel);
+ getMainWindow().addWindow(window);
+
+ }
+
+ private Component l(String string) {
+ return l(string, 200, 350);
+ }
+
+ private Component l(String string, int h, int w) {
+ Label label = new Label(string);
+ label.setHeight(h, Label.UNITS_PIXELS);
+ label.setWidth(w, Label.UNITS_PIXELS);
+ return label;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java
index 476fd22a55..44e5bf0d35 100644
--- a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java
+++ b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java
@@ -1,39 +1,39 @@
-package com.vaadin.tests.components.window;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-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);
-
- }
-}
+package com.vaadin.tests.components.window;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+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/testbench/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java b/tests/testbench/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java
index e6d3fb1651..88fb014690 100644
--- a/tests/testbench/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java
+++ b/tests/testbench/com/vaadin/tests/components/window/WindowShouldRemoveActionHandler.java
@@ -1,116 +1,116 @@
-package com.vaadin.tests.components.window;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.event.ShortcutAction;
-import com.vaadin.event.ShortcutAction.ModifierKey;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.TextField;
-
-public class WindowShouldRemoveActionHandler extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Adding action handlers to the window should make them appear on the client side. Removing the action handlers should remove them also from the client side, also if all action handlers are removed.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2941;
- }
-
- @Override
- protected void setup() {
- addComponent(new TextField());
- Button add = new Button("Add an action handler",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- add();
- }
-
- });
- Button addAnother = new Button("Add another action handler",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- addAnother();
- }
-
- });
- Button remove = new Button("Remove an action handler",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- remove();
- }
-
- });
-
- addComponent(add);
- addComponent(addAnother);
- addComponent(remove);
- }
-
- public void remove() {
- getMainWindow().setCaption(
- getMainWindow().getCaption() + " - Removed handler");
- getMainWindow().removeActionHandler(
- actionHandlers.remove(actionHandlers.size() - 1));
- }
-
- private List<Handler> actionHandlers = new ArrayList<Handler>();
-
- public void add() {
- getMainWindow().setCaption(
- getMainWindow().getCaption() + " - Added handler");
- Handler actionHandler = new Handler() {
-
- public Action[] getActions(Object target, Object sender) {
- return new Action[] { new ShortcutAction("Ctrl+Left",
- ShortcutAction.KeyCode.ARROW_LEFT,
- new int[] { ModifierKey.CTRL }) };
- }
-
- public void handleAction(Action action, Object sender, Object target) {
- getMainWindow().showNotification(
- "Handling action " + action.getCaption());
- }
-
- };
-
- addHandler(actionHandler);
- }
-
- public void addAnother() {
- Handler actionHandler = new Handler() {
-
- public Action[] getActions(Object target, Object sender) {
- return new Action[] { new ShortcutAction("Ctrl+Right",
- ShortcutAction.KeyCode.ARROW_RIGHT,
- new int[] { ModifierKey.CTRL }) };
- }
-
- public void handleAction(Action action, Object sender, Object target) {
- getMainWindow().showNotification(
- "Handling action " + action.getCaption());
- }
-
- };
-
- addHandler(actionHandler);
- }
-
- private void addHandler(Handler actionHandler) {
- actionHandlers.add(actionHandler);
- getMainWindow().addActionHandler(actionHandler);
- getMainWindow().setCaption(
- "A panel with " + actionHandlers.size() + " action handlers");
-
- }
-}
+package com.vaadin.tests.components.window;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.event.ShortcutAction.ModifierKey;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.TextField;
+
+public class WindowShouldRemoveActionHandler extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Adding action handlers to the window should make them appear on the client side. Removing the action handlers should remove them also from the client side, also if all action handlers are removed.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2941;
+ }
+
+ @Override
+ protected void setup() {
+ addComponent(new TextField());
+ Button add = new Button("Add an action handler",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ add();
+ }
+
+ });
+ Button addAnother = new Button("Add another action handler",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ addAnother();
+ }
+
+ });
+ Button remove = new Button("Remove an action handler",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ remove();
+ }
+
+ });
+
+ addComponent(add);
+ addComponent(addAnother);
+ addComponent(remove);
+ }
+
+ public void remove() {
+ getMainWindow().setCaption(
+ getMainWindow().getCaption() + " - Removed handler");
+ getMainWindow().removeActionHandler(
+ actionHandlers.remove(actionHandlers.size() - 1));
+ }
+
+ private List<Handler> actionHandlers = new ArrayList<Handler>();
+
+ public void add() {
+ getMainWindow().setCaption(
+ getMainWindow().getCaption() + " - Added handler");
+ Handler actionHandler = new Handler() {
+
+ public Action[] getActions(Object target, Object sender) {
+ return new Action[] { new ShortcutAction("Ctrl+Left",
+ ShortcutAction.KeyCode.ARROW_LEFT,
+ new int[] { ModifierKey.CTRL }) };
+ }
+
+ public void handleAction(Action action, Object sender, Object target) {
+ getMainWindow().showNotification(
+ "Handling action " + action.getCaption());
+ }
+
+ };
+
+ addHandler(actionHandler);
+ }
+
+ public void addAnother() {
+ Handler actionHandler = new Handler() {
+
+ public Action[] getActions(Object target, Object sender) {
+ return new Action[] { new ShortcutAction("Ctrl+Right",
+ ShortcutAction.KeyCode.ARROW_RIGHT,
+ new int[] { ModifierKey.CTRL }) };
+ }
+
+ public void handleAction(Action action, Object sender, Object target) {
+ getMainWindow().showNotification(
+ "Handling action " + action.getCaption());
+ }
+
+ };
+
+ addHandler(actionHandler);
+ }
+
+ private void addHandler(Handler actionHandler) {
+ actionHandlers.add(actionHandler);
+ getMainWindow().addActionHandler(actionHandler);
+ getMainWindow().setCaption(
+ "A panel with " + actionHandlers.size() + " action handlers");
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java b/tests/testbench/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java
index 0d47cc426d..24ff586b7b 100644
--- a/tests/testbench/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java
+++ b/tests/testbench/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java
@@ -1,172 +1,172 @@
-package com.vaadin.tests.containers;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class BeanItemContainerFilteringTest extends TestBase {
-
- private Table table;
- private BeanItemContainer<TestBean> container;
- private TextField filterString;
- private TextField position;
- private int nextToAdd = 1;
- private Label nextLabel;
-
- protected static class TestBean {
- private String id;
- private String value;
-
- public TestBean() {
- }
-
- public TestBean(String id, String value) {
- setId(id);
- setValue(value);
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
- }
-
- @Override
- protected String getDescription() {
- return "Test adding items in a filtered BeanItemContainer.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return new Integer(1061);
- }
-
- @Override
- protected void setup() {
- table = new Table();
- try {
- container = new BeanItemContainer<TestBean>(TestBean.class);
- table.setContainerDataSource(container);
-
- table.setWidth(300, Sizeable.UNITS_PIXELS);
- table.setSelectable(true);
- table.setMultiSelect(false);
- table.setEditable(true);
- table.setImmediate(true);
- // table.addContainerProperty("column1", String.class, "test");
-
- for (int i = 0; i < 25; ++i) {
- container.addItem(new TestBean("Item " + i, "Value for " + i));
- }
-
- VerticalLayout vl = new VerticalLayout();
-
- // activate & deactivate filtering
- filterString = new TextField("Filter string:", "1");
- vl.addComponent(filterString);
-
- final CheckBox cb = new CheckBox("Filter on value",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- container.removeAllContainerFilters();
- if (((CheckBox) event.getSource()).booleanValue()) {
- container.addContainerFilter("value",
- filterString.getValue().toString(),
- false, false);
- }
- }
- });
- cb.setImmediate(true);
- vl.addComponent(cb);
-
- nextLabel = new Label();
- nextLabel.setCaption("Next id: " + nextToAdd);
- vl.addComponent(nextLabel);
-
- // addItemAt(idx), addItemAfter(selection), addItem()
-
- final Button addItemButton = new Button("addItem()",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- container.addItem(new TestBean("addItem() "
- + nextToAdd, "value " + nextToAdd));
- nextToAdd++;
- nextLabel.setCaption("Next id: " + nextToAdd);
- }
- });
- addItemButton.setImmediate(true);
- vl.addComponent(addItemButton);
-
- final Button addItemAfterButton = new Button("addItemAfter()",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Object selection = table.getValue();
- if (selection == null) {
- return;
- }
- TestBean bean = new TestBean("addItemAfter() "
- + nextToAdd, "value " + nextToAdd);
- Item item = container.addItemAfter(selection, bean);
- if (item == null) {
- getMainWindow().showNotification(
- "Adding item after " + selection
- + " failed");
- }
- nextToAdd++;
- nextLabel.setCaption("Next id: " + nextToAdd);
- }
- });
- addItemAfterButton.setImmediate(true);
- vl.addComponent(addItemAfterButton);
-
- position = new TextField("Position:", "0");
- vl.addComponent(position);
-
- final Button addItemAtButton = new Button("addItemAt()",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- int index = Integer.parseInt(position.getValue()
- .toString());
- TestBean bean = new TestBean("addItemAt() "
- + nextToAdd, "value " + nextToAdd);
- Item item = container.addItemAt(index, bean);
- if (item == null) {
- getMainWindow().showNotification(
- "Adding item at index "
- + position.getValue()
- + " failed");
- }
- nextToAdd++;
- nextLabel.setCaption("Next id: " + nextToAdd);
- }
- });
- addItemAtButton.setImmediate(true);
- vl.addComponent(addItemAtButton);
-
- getLayout().addComponent(table);
- getLayout().addComponent(vl);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
-}
+package com.vaadin.tests.containers;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class BeanItemContainerFilteringTest extends TestBase {
+
+ private Table table;
+ private BeanItemContainer<TestBean> container;
+ private TextField filterString;
+ private TextField position;
+ private int nextToAdd = 1;
+ private Label nextLabel;
+
+ protected static class TestBean {
+ private String id;
+ private String value;
+
+ public TestBean() {
+ }
+
+ public TestBean(String id, String value) {
+ setId(id);
+ setValue(value);
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Test adding items in a filtered BeanItemContainer.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return new Integer(1061);
+ }
+
+ @Override
+ protected void setup() {
+ table = new Table();
+ try {
+ container = new BeanItemContainer<TestBean>(TestBean.class);
+ table.setContainerDataSource(container);
+
+ table.setWidth(300, Sizeable.UNITS_PIXELS);
+ table.setSelectable(true);
+ table.setMultiSelect(false);
+ table.setEditable(true);
+ table.setImmediate(true);
+ // table.addContainerProperty("column1", String.class, "test");
+
+ for (int i = 0; i < 25; ++i) {
+ container.addItem(new TestBean("Item " + i, "Value for " + i));
+ }
+
+ VerticalLayout vl = new VerticalLayout();
+
+ // activate & deactivate filtering
+ filterString = new TextField("Filter string:", "1");
+ vl.addComponent(filterString);
+
+ final CheckBox cb = new CheckBox("Filter on value",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ container.removeAllContainerFilters();
+ if (((CheckBox) event.getSource()).booleanValue()) {
+ container.addContainerFilter("value",
+ filterString.getValue().toString(),
+ false, false);
+ }
+ }
+ });
+ cb.setImmediate(true);
+ vl.addComponent(cb);
+
+ nextLabel = new Label();
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ vl.addComponent(nextLabel);
+
+ // addItemAt(idx), addItemAfter(selection), addItem()
+
+ final Button addItemButton = new Button("addItem()",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ container.addItem(new TestBean("addItem() "
+ + nextToAdd, "value " + nextToAdd));
+ nextToAdd++;
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ }
+ });
+ addItemButton.setImmediate(true);
+ vl.addComponent(addItemButton);
+
+ final Button addItemAfterButton = new Button("addItemAfter()",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Object selection = table.getValue();
+ if (selection == null) {
+ return;
+ }
+ TestBean bean = new TestBean("addItemAfter() "
+ + nextToAdd, "value " + nextToAdd);
+ Item item = container.addItemAfter(selection, bean);
+ if (item == null) {
+ getMainWindow().showNotification(
+ "Adding item after " + selection
+ + " failed");
+ }
+ nextToAdd++;
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ }
+ });
+ addItemAfterButton.setImmediate(true);
+ vl.addComponent(addItemAfterButton);
+
+ position = new TextField("Position:", "0");
+ vl.addComponent(position);
+
+ final Button addItemAtButton = new Button("addItemAt()",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ int index = Integer.parseInt(position.getValue()
+ .toString());
+ TestBean bean = new TestBean("addItemAt() "
+ + nextToAdd, "value " + nextToAdd);
+ Item item = container.addItemAt(index, bean);
+ if (item == null) {
+ getMainWindow().showNotification(
+ "Adding item at index "
+ + position.getValue()
+ + " failed");
+ }
+ nextToAdd++;
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ }
+ });
+ addItemAtButton.setImmediate(true);
+ vl.addComponent(addItemAtButton);
+
+ getLayout().addComponent(table);
+ getLayout().addComponent(vl);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/containers/IndexedContainerFilteringTest.java b/tests/testbench/com/vaadin/tests/containers/IndexedContainerFilteringTest.java
index 154118a393..bfa9ed5512 100644
--- a/tests/testbench/com/vaadin/tests/containers/IndexedContainerFilteringTest.java
+++ b/tests/testbench/com/vaadin/tests/containers/IndexedContainerFilteringTest.java
@@ -1,139 +1,139 @@
-package com.vaadin.tests.containers;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.terminal.Sizeable;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class IndexedContainerFilteringTest extends TestBase {
-
- private Table table;
- private IndexedContainer container;
- private TextField filterString;
- private TextField position;
- private int nextToAdd = 1;
- private Label nextLabel;
-
- @Override
- protected String getDescription() {
- return "Adding items to a filtered IndexedContainer inserts the items at the wrong location.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return new Integer(2809);
- }
-
- @Override
- protected void setup() {
- table = new Table();
- container = (IndexedContainer) table.getContainerDataSource();
-
- table.setWidth(300, Sizeable.UNITS_PIXELS);
- table.setSelectable(true);
- table.setMultiSelect(false);
- table.addContainerProperty("column1", String.class, "test");
-
- for (int i = 0; i < 25; ++i) {
- table.addItem(new Object[] { "Item " + i }, "Item " + i);
- }
-
- VerticalLayout vl = new VerticalLayout();
-
- // activate & deactivate filtering
- filterString = new TextField("Filter string:", "1");
- vl.addComponent(filterString);
-
- final CheckBox cb = new CheckBox("Filter", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- container.removeAllContainerFilters();
- if (((CheckBox) event.getSource()).booleanValue()) {
- container.addContainerFilter("column1", filterString
- .getValue().toString(), false, false);
- }
- }
- });
- cb.setImmediate(true);
- vl.addComponent(cb);
-
- nextLabel = new Label();
- nextLabel.setCaption("Next id: " + nextToAdd);
- vl.addComponent(nextLabel);
-
- // addItemAt(idx), addItemAfter(selection), addItem()
-
- final Button addItemButton = new Button("addItem()",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Item item = container.addItem("addItem() " + nextToAdd);
- if (item != null) {
- item.getItemProperty("column1").setValue(
- "addItem() " + nextToAdd);
- }
- nextToAdd++;
- nextLabel.setCaption("Next id: " + nextToAdd);
- }
- });
- addItemButton.setImmediate(true);
- vl.addComponent(addItemButton);
-
- final Button addItemAfterButton = new Button("addItemAfter()",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- Object selection = table.getValue();
- if (selection == null) {
- return;
- }
- String id = "addItemAfter() " + nextToAdd;
- Item item = container.addItemAfter(selection, id);
- if (item != null) {
- item.getItemProperty("column1").setValue(id);
- table.setValue(id);
- } else {
- getMainWindow().showNotification(
- "Adding item after " + selection
- + " failed");
- }
- nextToAdd++;
- nextLabel.setCaption("Next id: " + nextToAdd);
- }
- });
- addItemAfterButton.setImmediate(true);
- vl.addComponent(addItemAfterButton);
-
- position = new TextField("Position:", "0");
- vl.addComponent(position);
-
- final Button addItemAtButton = new Button("addItemAt()",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- int index = Integer.parseInt(position.getValue()
- .toString());
- String id = "addItemAt() " + nextToAdd;
- Item item = container.addItemAt(index, id);
- if (item != null) {
- item.getItemProperty("column1").setValue(id);
- table.setValue(id);
- } else {
- getMainWindow().showNotification(
- "Adding item at index "
- + position.getValue() + " failed");
- }
- nextToAdd++;
- nextLabel.setCaption("Next id: " + nextToAdd);
- }
- });
- addItemAtButton.setImmediate(true);
- vl.addComponent(addItemAtButton);
-
- getLayout().addComponent(table);
- getLayout().addComponent(vl);
- }
-}
+package com.vaadin.tests.containers;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class IndexedContainerFilteringTest extends TestBase {
+
+ private Table table;
+ private IndexedContainer container;
+ private TextField filterString;
+ private TextField position;
+ private int nextToAdd = 1;
+ private Label nextLabel;
+
+ @Override
+ protected String getDescription() {
+ return "Adding items to a filtered IndexedContainer inserts the items at the wrong location.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return new Integer(2809);
+ }
+
+ @Override
+ protected void setup() {
+ table = new Table();
+ container = (IndexedContainer) table.getContainerDataSource();
+
+ table.setWidth(300, Sizeable.UNITS_PIXELS);
+ table.setSelectable(true);
+ table.setMultiSelect(false);
+ table.addContainerProperty("column1", String.class, "test");
+
+ for (int i = 0; i < 25; ++i) {
+ table.addItem(new Object[] { "Item " + i }, "Item " + i);
+ }
+
+ VerticalLayout vl = new VerticalLayout();
+
+ // activate & deactivate filtering
+ filterString = new TextField("Filter string:", "1");
+ vl.addComponent(filterString);
+
+ final CheckBox cb = new CheckBox("Filter", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ container.removeAllContainerFilters();
+ if (((CheckBox) event.getSource()).booleanValue()) {
+ container.addContainerFilter("column1", filterString
+ .getValue().toString(), false, false);
+ }
+ }
+ });
+ cb.setImmediate(true);
+ vl.addComponent(cb);
+
+ nextLabel = new Label();
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ vl.addComponent(nextLabel);
+
+ // addItemAt(idx), addItemAfter(selection), addItem()
+
+ final Button addItemButton = new Button("addItem()",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Item item = container.addItem("addItem() " + nextToAdd);
+ if (item != null) {
+ item.getItemProperty("column1").setValue(
+ "addItem() " + nextToAdd);
+ }
+ nextToAdd++;
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ }
+ });
+ addItemButton.setImmediate(true);
+ vl.addComponent(addItemButton);
+
+ final Button addItemAfterButton = new Button("addItemAfter()",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Object selection = table.getValue();
+ if (selection == null) {
+ return;
+ }
+ String id = "addItemAfter() " + nextToAdd;
+ Item item = container.addItemAfter(selection, id);
+ if (item != null) {
+ item.getItemProperty("column1").setValue(id);
+ table.setValue(id);
+ } else {
+ getMainWindow().showNotification(
+ "Adding item after " + selection
+ + " failed");
+ }
+ nextToAdd++;
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ }
+ });
+ addItemAfterButton.setImmediate(true);
+ vl.addComponent(addItemAfterButton);
+
+ position = new TextField("Position:", "0");
+ vl.addComponent(position);
+
+ final Button addItemAtButton = new Button("addItemAt()",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ int index = Integer.parseInt(position.getValue()
+ .toString());
+ String id = "addItemAt() " + nextToAdd;
+ Item item = container.addItemAt(index, id);
+ if (item != null) {
+ item.getItemProperty("column1").setValue(id);
+ table.setValue(id);
+ } else {
+ getMainWindow().showNotification(
+ "Adding item at index "
+ + position.getValue() + " failed");
+ }
+ nextToAdd++;
+ nextLabel.setCaption("Next id: " + nextToAdd);
+ }
+ });
+ addItemAtButton.setImmediate(true);
+ vl.addComponent(addItemAtButton);
+
+ getLayout().addComponent(table);
+ getLayout().addComponent(vl);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java b/tests/testbench/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java
index b3b5185505..91403f54d6 100644
--- a/tests/testbench/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java
+++ b/tests/testbench/com/vaadin/tests/containers/filesystemcontainer/FileSystemContainerInTreeTable.java
@@ -1,141 +1,141 @@
-package com.vaadin.tests.containers.filesystemcontainer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Ordered;
-import com.vaadin.data.util.FilesystemContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Tree.CollapseEvent;
-import com.vaadin.ui.Tree.CollapseListener;
-import com.vaadin.ui.Tree.ExpandEvent;
-import com.vaadin.ui.Tree.ExpandListener;
-import com.vaadin.ui.TreeTable;
-
-public class FileSystemContainerInTreeTable extends TestBase {
-
- private Log log = new Log(5);
- private TreeTable treeTable;
-
- @Override
- protected void setup() {
- setTheme("reindeer-tests");
-
- final File folder;
- try {
- File tempFile = File.createTempFile("fsc-tt", "");
- tempFile.delete();
- folder = new File(tempFile.getParent(), tempFile.getName());
- folder.mkdir();
- System.out.println(folder.getPath());
- folder.deleteOnExit();
-
- populate(folder, 3, 10);
-
- FilesystemContainer fsc = new FilesystemContainer(folder);
-
- treeTable = new TreeTable();
- treeTable.addStyleName("table-equal-rowheight");
- treeTable.setWidth("450px");
- treeTable.setHeight("550px");
- treeTable.setContainerDataSource(fsc);
- treeTable.setItemIconPropertyId(FilesystemContainer.PROPERTY_ICON);
- treeTable.setVisibleColumns(new String[] { "Name" });
- treeTable.setColumnWidth("Name", 400);
- treeTable.addListener(new ExpandListener() {
-
- public void nodeExpand(ExpandEvent event) {
- logExpandCollapse(event.getItemId(), "expanded");
-
- }
- });
- treeTable.addListener(new CollapseListener() {
-
- public void nodeCollapse(CollapseEvent event) {
- logExpandCollapse(event.getItemId(), "collapsed");
-
- }
- });
-
- addComponent(log);
- addComponent(treeTable);
-
- HorizontalLayout buttonLayout = new HorizontalLayout();
- buttonLayout.setSpacing(true);
- buttonLayout.addComponent(new Button("Create dir11",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- new File(folder, "dir11").mkdir();
- log.log("Row dir11 created");
- }
- }));
- buttonLayout.addComponent(new Button("Delete dir11",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- new File(folder, "dir11").delete();
- log.log("Row dir11 deleted");
- }
- }));
- // to clean up explicitly before ending an automated test
- buttonLayout.addComponent(new Button("Clean all files",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- folder.delete();
- }
- }));
- addComponent(buttonLayout);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private void populate(File folder, int subDirectories, int files)
- throws IOException {
- for (int i = 1; i <= files; i++) {
- File f = new File(folder, "file" + i + ".txt");
- f.createNewFile();
- }
-
- for (int i = 1; i <= subDirectories; i++) {
- File f = new File(folder, "dir" + i);
- f.mkdir();
- populate(f, 0, 2);
- }
- }
-
- protected int indexOfId(Table source, Object itemId) {
- Container.Ordered c = (Ordered) source.getContainerDataSource();
- if (c instanceof Container.Indexed) {
- return ((Container.Indexed) source).indexOfId(itemId);
- } else {
- ArrayList<Object> list = new ArrayList<Object>(source.getItemIds());
- return list.indexOf(itemId);
- }
- }
-
- protected void logExpandCollapse(Object itemId, String operation) {
- File file = (File) itemId;
- // do not use the variable part (path) of file name
- log.log("Row " + file.getName() + " " + operation + ". Row index: "
- + indexOfId(treeTable, itemId));
-
- }
-
- @Override
- protected String getDescription() {
- return "TreeTable partial updates can only be used with a container that notifies the TreeTable of item set changes";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7837;
- }
-
+package com.vaadin.tests.containers.filesystemcontainer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Ordered;
+import com.vaadin.data.util.FilesystemContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.CollapseListener;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.Tree.ExpandListener;
+import com.vaadin.ui.TreeTable;
+
+public class FileSystemContainerInTreeTable extends TestBase {
+
+ private Log log = new Log(5);
+ private TreeTable treeTable;
+
+ @Override
+ protected void setup() {
+ setTheme("reindeer-tests");
+
+ final File folder;
+ try {
+ File tempFile = File.createTempFile("fsc-tt", "");
+ tempFile.delete();
+ folder = new File(tempFile.getParent(), tempFile.getName());
+ folder.mkdir();
+ System.out.println(folder.getPath());
+ folder.deleteOnExit();
+
+ populate(folder, 3, 10);
+
+ FilesystemContainer fsc = new FilesystemContainer(folder);
+
+ treeTable = new TreeTable();
+ treeTable.addStyleName("table-equal-rowheight");
+ treeTable.setWidth("450px");
+ treeTable.setHeight("550px");
+ treeTable.setContainerDataSource(fsc);
+ treeTable.setItemIconPropertyId(FilesystemContainer.PROPERTY_ICON);
+ treeTable.setVisibleColumns(new String[] { "Name" });
+ treeTable.setColumnWidth("Name", 400);
+ treeTable.addListener(new ExpandListener() {
+
+ public void nodeExpand(ExpandEvent event) {
+ logExpandCollapse(event.getItemId(), "expanded");
+
+ }
+ });
+ treeTable.addListener(new CollapseListener() {
+
+ public void nodeCollapse(CollapseEvent event) {
+ logExpandCollapse(event.getItemId(), "collapsed");
+
+ }
+ });
+
+ addComponent(log);
+ addComponent(treeTable);
+
+ HorizontalLayout buttonLayout = new HorizontalLayout();
+ buttonLayout.setSpacing(true);
+ buttonLayout.addComponent(new Button("Create dir11",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ new File(folder, "dir11").mkdir();
+ log.log("Row dir11 created");
+ }
+ }));
+ buttonLayout.addComponent(new Button("Delete dir11",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ new File(folder, "dir11").delete();
+ log.log("Row dir11 deleted");
+ }
+ }));
+ // to clean up explicitly before ending an automated test
+ buttonLayout.addComponent(new Button("Clean all files",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ folder.delete();
+ }
+ }));
+ addComponent(buttonLayout);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void populate(File folder, int subDirectories, int files)
+ throws IOException {
+ for (int i = 1; i <= files; i++) {
+ File f = new File(folder, "file" + i + ".txt");
+ f.createNewFile();
+ }
+
+ for (int i = 1; i <= subDirectories; i++) {
+ File f = new File(folder, "dir" + i);
+ f.mkdir();
+ populate(f, 0, 2);
+ }
+ }
+
+ protected int indexOfId(Table source, Object itemId) {
+ Container.Ordered c = (Ordered) source.getContainerDataSource();
+ if (c instanceof Container.Indexed) {
+ return ((Container.Indexed) source).indexOfId(itemId);
+ } else {
+ ArrayList<Object> list = new ArrayList<Object>(source.getItemIds());
+ return list.indexOf(itemId);
+ }
+ }
+
+ protected void logExpandCollapse(Object itemId, String operation) {
+ File file = (File) itemId;
+ // do not use the variable part (path) of file name
+ log.log("Row " + file.getName() + " " + operation + ". Row index: "
+ + indexOfId(treeTable, itemId));
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "TreeTable partial updates can only be used with a container that notifies the TreeTable of item set changes";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7837;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/layouts/CaptionsInLayouts.java b/tests/testbench/com/vaadin/tests/layouts/CaptionsInLayouts.java
index ec825a3404..7ad433e5c9 100644
--- a/tests/testbench/com/vaadin/tests/layouts/CaptionsInLayouts.java
+++ b/tests/testbench/com/vaadin/tests/layouts/CaptionsInLayouts.java
@@ -1,277 +1,277 @@
-package com.vaadin.tests.layouts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class CaptionsInLayouts extends TestBase {
-
- private static final Object CAPTION = "CAPTION";
- private static final Object CLASS = "C";
- private static final Object WIDTH = "W";
-
- private NativeSelect layoutSelect;
- private Layout layout;
- private VerticalLayout verticalLayout;
- private HorizontalLayout horizontalLayout;
- private GridLayout gridLayout;
- private FormLayout formLayout;
- private List<AbstractField> components = new ArrayList<AbstractField>();
- private CssLayout cssLayout;
- private HorizontalLayout layoutParent = new HorizontalLayout();
-
- @Override
- protected void setup() {
- // setTheme("tests-tickets");
- addComponent(createLayoutSelect());
- addComponent(toggleRequired());
- // addComponent(toggleCaptions());
- addComponent(toggleError());
- addComponent(toggleIcon());
- addComponent(addCaptionText());
- layoutParent.addComponent(new NativeButton("Button right of layout"));
- addComponent(layoutParent);
- addComponent(new NativeButton("Button below layout"));
- createComponents();
- layoutSelect.setValue(layoutSelect.getItemIds().iterator().next());
- }
-
- private Component addCaptionText() {
- Button b = new Button("Add caption text");
- b.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- prependCaptions("a");
- }
- });
- return b;
- }
-
- protected void prependCaptions(String prepend) {
- for (AbstractField c : components) {
- c.setCaption(prepend + c.getCaption());
- }
-
- }
-
- private Component toggleRequired() {
- CheckBox requiredToggle = new CheckBox();
- requiredToggle.setImmediate(true);
- requiredToggle.setCaption("Required");
- requiredToggle.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- setRequired((Boolean) event.getProperty().getValue());
- }
- });
- return requiredToggle;
- }
-
- private Component toggleIcon() {
- CheckBox iconToggle = new CheckBox();
- iconToggle.setImmediate(true);
- iconToggle.setCaption("Icons");
- iconToggle.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- setIcon((Boolean) event.getProperty().getValue());
- }
- });
- return iconToggle;
- }
-
- protected void setRequired(boolean value) {
- for (AbstractField c : components) {
- c.setRequired(value);
- }
-
- }
-
- protected void setIcon(boolean value) {
- for (AbstractField c : components) {
- if (!value) {
- c.setIcon(null);
- } else {
- c.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
- }
- }
-
- }
-
- private Component toggleError() {
- CheckBox errorToggle = new CheckBox();
- errorToggle.setImmediate(true);
- errorToggle.setCaption("Error");
- errorToggle.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- setError((Boolean) event.getProperty().getValue());
- }
- });
- return errorToggle;
- }
-
- protected void setError(boolean value) {
- for (AbstractField c : components) {
- if (value) {
- c.setComponentError(new UserError("error"));
- } else {
- c.setComponentError(null);
-
- }
- }
-
- }
-
- private void createComponents() {
- TextField tfUndefWide = new TextField(
- "Undefined wide text field with a very long caption, longer than the field and the layout. Lorem ipsum dolor sit amet.");
- TextField tf100pxWide = new TextField(
- "100 px wide text field with a very long caption, longer than 100px.");
- tf100pxWide.setWidth("100px");
-
- TextField tf500pxWide = new TextField(
- "500 px wide text field with a very long caption, longer than 500px. Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
- tf500pxWide.setWidth("500px");
-
- components.add(tfUndefWide);
- components.add(tf100pxWide);
- components.add(tf500pxWide);
-
- }
-
- private void setLayout(Layout newLayout) {
- if (layout == null) {
- layoutParent.addComponent(newLayout, 0);
- } else {
- layoutParent.replaceComponent(layout, newLayout);
- }
- layout = newLayout;
-
- for (Component c : components) {
- if (c.getParent() != layout) {
- layout.addComponent(c);
- }
- }
-
- }
-
- private Layout getLayout(String caption,
- Class<? extends Layout> layoutClass, String width) {
- Layout l;
- if (layoutClass == VerticalLayout.class) {
- if (verticalLayout == null) {
- verticalLayout = new VerticalLayout();
- verticalLayout.setStyleName("borders");
- }
- l = verticalLayout;
- } else if (layoutClass == HorizontalLayout.class) {
- if (horizontalLayout == null) {
- horizontalLayout = new HorizontalLayout();
- horizontalLayout.setStyleName("borders");
- }
- l = horizontalLayout;
- } else if (layoutClass == GridLayout.class) {
- if (gridLayout == null) {
- gridLayout = new GridLayout();
- gridLayout.setStyleName("borders");
- }
- l = gridLayout;
- } else if (layoutClass == CssLayout.class) {
- if (cssLayout == null) {
- cssLayout = new CssLayout();
- cssLayout.setStyleName("borders");
- }
- l = cssLayout;
- } else if (layoutClass == FormLayout.class) {
- if (formLayout == null) {
- formLayout = new FormLayout();
- formLayout.setStyleName("borders");
- }
- l = formLayout;
- } else {
- return null;
- }
-
- l.setCaption(caption);
- if (width.equals("auto")) {
- width = null;
- }
-
- l.setWidth(width);
-
- // addComponent(l);
-
- return l;
- }
-
- private Component createLayoutSelect() {
- layoutSelect = new NativeSelect("Layout");
- layoutSelect.addContainerProperty(CAPTION, String.class, "");
- layoutSelect.addContainerProperty(CLASS, Class.class, "");
- layoutSelect.addContainerProperty(WIDTH, String.class, "");
- layoutSelect.setItemCaptionPropertyId(CAPTION);
- layoutSelect.setNullSelectionAllowed(false);
-
- for (Class<?> cls : new Class[] { HorizontalLayout.class,
- VerticalLayout.class, GridLayout.class, CssLayout.class,
- FormLayout.class }) {
- for (String width : new String[] { "400px", "auto" }) {
- Object id = layoutSelect.addItem();
- Item i = layoutSelect.getItem(id);
- i.getItemProperty(CAPTION).setValue(
- cls.getSimpleName() + ", " + width);
- i.getItemProperty(CLASS).setValue(cls);
- i.getItemProperty(WIDTH).setValue(width);
- }
-
- }
- layoutSelect.setImmediate(true);
- layoutSelect.addListener(new ValueChangeListener() {
-
- @SuppressWarnings("unchecked")
- public void valueChange(ValueChangeEvent event) {
- Item i = layoutSelect.getItem(event.getProperty().getValue());
-
- setLayout(getLayout((String) i.getItemProperty(CAPTION)
- .getValue(), (Class<? extends Layout>) i
- .getItemProperty(CLASS).getValue(), (String) i
- .getItemProperty(WIDTH).getValue()));
- }
- });
-
- return layoutSelect;
- }
-
- @Override
- protected String getDescription() {
- return "Tests what happens when the caption changes in various layouts. Behavior should be consistent.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5424;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class CaptionsInLayouts extends TestBase {
+
+ private static final Object CAPTION = "CAPTION";
+ private static final Object CLASS = "C";
+ private static final Object WIDTH = "W";
+
+ private NativeSelect layoutSelect;
+ private Layout layout;
+ private VerticalLayout verticalLayout;
+ private HorizontalLayout horizontalLayout;
+ private GridLayout gridLayout;
+ private FormLayout formLayout;
+ private List<AbstractField> components = new ArrayList<AbstractField>();
+ private CssLayout cssLayout;
+ private HorizontalLayout layoutParent = new HorizontalLayout();
+
+ @Override
+ protected void setup() {
+ // setTheme("tests-tickets");
+ addComponent(createLayoutSelect());
+ addComponent(toggleRequired());
+ // addComponent(toggleCaptions());
+ addComponent(toggleError());
+ addComponent(toggleIcon());
+ addComponent(addCaptionText());
+ layoutParent.addComponent(new NativeButton("Button right of layout"));
+ addComponent(layoutParent);
+ addComponent(new NativeButton("Button below layout"));
+ createComponents();
+ layoutSelect.setValue(layoutSelect.getItemIds().iterator().next());
+ }
+
+ private Component addCaptionText() {
+ Button b = new Button("Add caption text");
+ b.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ prependCaptions("a");
+ }
+ });
+ return b;
+ }
+
+ protected void prependCaptions(String prepend) {
+ for (AbstractField c : components) {
+ c.setCaption(prepend + c.getCaption());
+ }
+
+ }
+
+ private Component toggleRequired() {
+ CheckBox requiredToggle = new CheckBox();
+ requiredToggle.setImmediate(true);
+ requiredToggle.setCaption("Required");
+ requiredToggle.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ setRequired((Boolean) event.getProperty().getValue());
+ }
+ });
+ return requiredToggle;
+ }
+
+ private Component toggleIcon() {
+ CheckBox iconToggle = new CheckBox();
+ iconToggle.setImmediate(true);
+ iconToggle.setCaption("Icons");
+ iconToggle.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ setIcon((Boolean) event.getProperty().getValue());
+ }
+ });
+ return iconToggle;
+ }
+
+ protected void setRequired(boolean value) {
+ for (AbstractField c : components) {
+ c.setRequired(value);
+ }
+
+ }
+
+ protected void setIcon(boolean value) {
+ for (AbstractField c : components) {
+ if (!value) {
+ c.setIcon(null);
+ } else {
+ c.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
+ }
+ }
+
+ }
+
+ private Component toggleError() {
+ CheckBox errorToggle = new CheckBox();
+ errorToggle.setImmediate(true);
+ errorToggle.setCaption("Error");
+ errorToggle.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ setError((Boolean) event.getProperty().getValue());
+ }
+ });
+ return errorToggle;
+ }
+
+ protected void setError(boolean value) {
+ for (AbstractField c : components) {
+ if (value) {
+ c.setComponentError(new UserError("error"));
+ } else {
+ c.setComponentError(null);
+
+ }
+ }
+
+ }
+
+ private void createComponents() {
+ TextField tfUndefWide = new TextField(
+ "Undefined wide text field with a very long caption, longer than the field and the layout. Lorem ipsum dolor sit amet.");
+ TextField tf100pxWide = new TextField(
+ "100 px wide text field with a very long caption, longer than 100px.");
+ tf100pxWide.setWidth("100px");
+
+ TextField tf500pxWide = new TextField(
+ "500 px wide text field with a very long caption, longer than 500px. Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ tf500pxWide.setWidth("500px");
+
+ components.add(tfUndefWide);
+ components.add(tf100pxWide);
+ components.add(tf500pxWide);
+
+ }
+
+ private void setLayout(Layout newLayout) {
+ if (layout == null) {
+ layoutParent.addComponent(newLayout, 0);
+ } else {
+ layoutParent.replaceComponent(layout, newLayout);
+ }
+ layout = newLayout;
+
+ for (Component c : components) {
+ if (c.getParent() != layout) {
+ layout.addComponent(c);
+ }
+ }
+
+ }
+
+ private Layout getLayout(String caption,
+ Class<? extends Layout> layoutClass, String width) {
+ Layout l;
+ if (layoutClass == VerticalLayout.class) {
+ if (verticalLayout == null) {
+ verticalLayout = new VerticalLayout();
+ verticalLayout.setStyleName("borders");
+ }
+ l = verticalLayout;
+ } else if (layoutClass == HorizontalLayout.class) {
+ if (horizontalLayout == null) {
+ horizontalLayout = new HorizontalLayout();
+ horizontalLayout.setStyleName("borders");
+ }
+ l = horizontalLayout;
+ } else if (layoutClass == GridLayout.class) {
+ if (gridLayout == null) {
+ gridLayout = new GridLayout();
+ gridLayout.setStyleName("borders");
+ }
+ l = gridLayout;
+ } else if (layoutClass == CssLayout.class) {
+ if (cssLayout == null) {
+ cssLayout = new CssLayout();
+ cssLayout.setStyleName("borders");
+ }
+ l = cssLayout;
+ } else if (layoutClass == FormLayout.class) {
+ if (formLayout == null) {
+ formLayout = new FormLayout();
+ formLayout.setStyleName("borders");
+ }
+ l = formLayout;
+ } else {
+ return null;
+ }
+
+ l.setCaption(caption);
+ if (width.equals("auto")) {
+ width = null;
+ }
+
+ l.setWidth(width);
+
+ // addComponent(l);
+
+ return l;
+ }
+
+ private Component createLayoutSelect() {
+ layoutSelect = new NativeSelect("Layout");
+ layoutSelect.addContainerProperty(CAPTION, String.class, "");
+ layoutSelect.addContainerProperty(CLASS, Class.class, "");
+ layoutSelect.addContainerProperty(WIDTH, String.class, "");
+ layoutSelect.setItemCaptionPropertyId(CAPTION);
+ layoutSelect.setNullSelectionAllowed(false);
+
+ for (Class<?> cls : new Class[] { HorizontalLayout.class,
+ VerticalLayout.class, GridLayout.class, CssLayout.class,
+ FormLayout.class }) {
+ for (String width : new String[] { "400px", "auto" }) {
+ Object id = layoutSelect.addItem();
+ Item i = layoutSelect.getItem(id);
+ i.getItemProperty(CAPTION).setValue(
+ cls.getSimpleName() + ", " + width);
+ i.getItemProperty(CLASS).setValue(cls);
+ i.getItemProperty(WIDTH).setValue(width);
+ }
+
+ }
+ layoutSelect.setImmediate(true);
+ layoutSelect.addListener(new ValueChangeListener() {
+
+ @SuppressWarnings("unchecked")
+ public void valueChange(ValueChangeEvent event) {
+ Item i = layoutSelect.getItem(event.getProperty().getValue());
+
+ setLayout(getLayout((String) i.getItemProperty(CAPTION)
+ .getValue(), (Class<? extends Layout>) i
+ .getItemProperty(CLASS).getValue(), (String) i
+ .getItemProperty(WIDTH).getValue()));
+ }
+ });
+
+ return layoutSelect;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tests what happens when the caption changes in various layouts. Behavior should be consistent.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5424;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponent.java b/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponent.java
index 4959e0cc3e..ef07b2c5f5 100644
--- a/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponent.java
+++ b/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponent.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.TextField;
-
-@SuppressWarnings("serial")
-public class CssLayoutRemoveComponent extends TestBase {
-
- @Override
- protected void setup() {
- final CssLayout layout = new CssLayout();
- final TextField tf = new TextField("Caption1");
- Button b = new Button("Remove field ", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- layout.removeComponent(tf);
- }
-
- });
- layout.addComponent(tf);
- layout.addComponent(b);
- layout.addComponent(new TextField("Caption2"));
- layout.addComponent(new TextField("Caption3"));
-
- addComponent(layout);
- }
-
- @Override
- protected String getDescription() {
- return "Clicking on the button should remove one text field but other textfields and their captions should stay intact.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5778;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.TextField;
+
+@SuppressWarnings("serial")
+public class CssLayoutRemoveComponent extends TestBase {
+
+ @Override
+ protected void setup() {
+ final CssLayout layout = new CssLayout();
+ final TextField tf = new TextField("Caption1");
+ Button b = new Button("Remove field ", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ layout.removeComponent(tf);
+ }
+
+ });
+ layout.addComponent(tf);
+ layout.addComponent(b);
+ layout.addComponent(new TextField("Caption2"));
+ layout.addComponent(new TextField("Caption3"));
+
+ addComponent(layout);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Clicking on the button should remove one text field but other textfields and their captions should stay intact.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5778;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java b/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java
index 946e778ead..4f081af347 100644
--- a/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java
+++ b/tests/testbench/com/vaadin/tests/layouts/CssLayoutRemoveComponentWithCaption.java
@@ -1,41 +1,41 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.TextField;
-
-public class CssLayoutRemoveComponentWithCaption extends TestBase {
-
- @Override
- protected void setup() {
- final CssLayout layout = new CssLayout();
- final TextField tf = new TextField("Caption");
- Button b = new Button("Remove field and add new", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- layout.removeComponent(tf);
- addComponent(new TextField("new field"));
-
- }
-
- });
- layout.addComponent(tf);
- layout.addComponent(b);
-
- addComponent(layout);
- }
-
- @Override
- protected String getDescription() {
- return "Clicking on the button should remove the text field and add a new 'new field' text field";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4204;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.TextField;
+
+public class CssLayoutRemoveComponentWithCaption extends TestBase {
+
+ @Override
+ protected void setup() {
+ final CssLayout layout = new CssLayout();
+ final TextField tf = new TextField("Caption");
+ Button b = new Button("Remove field and add new", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ layout.removeComponent(tf);
+ addComponent(new TextField("new field"));
+
+ }
+
+ });
+ layout.addComponent(tf);
+ layout.addComponent(b);
+
+ addComponent(layout);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Clicking on the button should remove the text field and add a new 'new field' text field";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4204;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/DeepComponentTrees.java b/tests/testbench/com/vaadin/tests/layouts/DeepComponentTrees.java
index 3a6414cff5..47cb095efa 100644
--- a/tests/testbench/com/vaadin/tests/layouts/DeepComponentTrees.java
+++ b/tests/testbench/com/vaadin/tests/layouts/DeepComponentTrees.java
@@ -1,114 +1,114 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-
-public class DeepComponentTrees extends TestBase {
-
- private Panel root;
-
- @Override
- protected String getDescription() {
- return "Vaadin should not choke on deep component trees. 15 levels should be minimum to survive.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- private int i = 0;
- private Class<?> currentValue = VerticalLayout.class;
-
- @Override
- protected void setup() {
- Layout main = getLayout();
- main.setSizeUndefined();
- getMainWindow().getContent().setHeight(null);
-
- Label l = new Label(
- "This is a nice game to guess how many Layouts your FF2 (or any other browser) can deal with. Due to the worldwide attempt to decrease energy consumption, playing this game is only allowed above 60° longitude betwheen August and May (as excess energy consumed by you CPU is used to heat your room). It is considered wise to save all your work before starting the game.");
-
- root = new Panel("Test box");
- root.setWidth("600px");
- root.setHeight("200px");
- final Button b = new Button("Go try your luck with " + i + " layouts!");
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- FF2KILLER(i++);
- b.setCaption("Go try your luck with " + i + " layouts!");
- }
-
- });
-
- final ComboBox s = new ComboBox("Restart game with select:");
- s.setNullSelectionAllowed(false);
- s.addItem("-- Choose value --");
- s.setValue("-- Choose value --");
- s.addItem(VerticalLayout.class);
- s.addItem(HorizontalLayout.class);
- s.addItem(GridLayout.class);
- s.addListener(new ComboBox.ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- Object value = s.getValue();
- if (!value.equals("-- Choose value --")) {
- currentValue = (Class<?>) value;
- i = 0;
- s.setValue("-- Choose value --");
- b.setCaption("Go try your luck with " + i + " layouts!");
- }
-
- }
- });
- s.setImmediate(true);
-
- main.addComponent(l);
- main.addComponent(b);
- main.addComponent(s);
- main.addComponent(root);
-
- }
-
- private void FF2KILLER(int layouts) {
- Layout layout = getTestLayout();
- Layout r = layout;
- for (int i = 0; i < layouts; i++) {
- Layout lo = getTestLayout();
- layout.addComponent(lo);
- layout = lo;
- }
- layout.addComponent(new Label(
- "FF did it! Vaadin, Mozilla and you win! Dare to try again?"));
- root.setContent(r);
- }
-
- Layout getTestLayout() {
- Layout l = new VerticalLayout();
- if (currentValue == GridLayout.class) {
- l = new GridLayout(1, 1);
- } else {
- try {
- l = (Layout) currentValue.newInstance();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return l;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+
+public class DeepComponentTrees extends TestBase {
+
+ private Panel root;
+
+ @Override
+ protected String getDescription() {
+ return "Vaadin should not choke on deep component trees. 15 levels should be minimum to survive.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+ private int i = 0;
+ private Class<?> currentValue = VerticalLayout.class;
+
+ @Override
+ protected void setup() {
+ Layout main = getLayout();
+ main.setSizeUndefined();
+ getMainWindow().getContent().setHeight(null);
+
+ Label l = new Label(
+ "This is a nice game to guess how many Layouts your FF2 (or any other browser) can deal with. Due to the worldwide attempt to decrease energy consumption, playing this game is only allowed above 60° longitude betwheen August and May (as excess energy consumed by you CPU is used to heat your room). It is considered wise to save all your work before starting the game.");
+
+ root = new Panel("Test box");
+ root.setWidth("600px");
+ root.setHeight("200px");
+ final Button b = new Button("Go try your luck with " + i + " layouts!");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ FF2KILLER(i++);
+ b.setCaption("Go try your luck with " + i + " layouts!");
+ }
+
+ });
+
+ final ComboBox s = new ComboBox("Restart game with select:");
+ s.setNullSelectionAllowed(false);
+ s.addItem("-- Choose value --");
+ s.setValue("-- Choose value --");
+ s.addItem(VerticalLayout.class);
+ s.addItem(HorizontalLayout.class);
+ s.addItem(GridLayout.class);
+ s.addListener(new ComboBox.ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ Object value = s.getValue();
+ if (!value.equals("-- Choose value --")) {
+ currentValue = (Class<?>) value;
+ i = 0;
+ s.setValue("-- Choose value --");
+ b.setCaption("Go try your luck with " + i + " layouts!");
+ }
+
+ }
+ });
+ s.setImmediate(true);
+
+ main.addComponent(l);
+ main.addComponent(b);
+ main.addComponent(s);
+ main.addComponent(root);
+
+ }
+
+ private void FF2KILLER(int layouts) {
+ Layout layout = getTestLayout();
+ Layout r = layout;
+ for (int i = 0; i < layouts; i++) {
+ Layout lo = getTestLayout();
+ layout.addComponent(lo);
+ layout = lo;
+ }
+ layout.addComponent(new Label(
+ "FF did it! Vaadin, Mozilla and you win! Dare to try again?"));
+ root.setContent(r);
+ }
+
+ Layout getTestLayout() {
+ Layout l = new VerticalLayout();
+ if (currentValue == GridLayout.class) {
+ l = new GridLayout(1, 1);
+ } else {
+ try {
+ l = (Layout) currentValue.newInstance();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return l;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutMoveComponent.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutMoveComponent.java
index 265187e878..1442dc3421 100644
--- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutMoveComponent.java
+++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutMoveComponent.java
@@ -1,66 +1,66 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-
-public class GridLayoutMoveComponent extends TestBase {
-
- @Override
- protected void setup() {
- final GridLayout grid = new GridLayout(2, 3);
- grid.setCaption("Fixed size grid");
- grid.setWidth("300px");
- grid.setHeight("100px");
- addComponent(grid);
-
- final Label l = new Label("100% label");
- final Button b = new Button("100px button");
- b.setWidth("100px");
- final TextField tf = new TextField("Undef textfield");
-
- // Adding component to grid
- grid.addComponent(l, 0, 0);
- grid.addComponent(b, 0, 1);
- grid.addComponent(tf, 0, 2);
-
- addComponent(new Button("Shift label right",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- // Moving component from 0,0 -> 1,0
- grid.removeComponent(l);
- grid.addComponent(l, 1, 0);
- }
- }));
-
- addComponent(new Button("Shift button right",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- grid.removeComponent(b);
- grid.addComponent(b, 1, 1);
- }
- }));
-
- addComponent(new Button("Shift text field right",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- grid.removeComponent(tf);
- grid.addComponent(tf, 1, 2);
- }
- }));
- }
-
- @Override
- protected String getDescription() {
- return "Click the buttons below the GridLayout to move the components to the right. Should definitely work no matter what.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5525;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+
+public class GridLayoutMoveComponent extends TestBase {
+
+ @Override
+ protected void setup() {
+ final GridLayout grid = new GridLayout(2, 3);
+ grid.setCaption("Fixed size grid");
+ grid.setWidth("300px");
+ grid.setHeight("100px");
+ addComponent(grid);
+
+ final Label l = new Label("100% label");
+ final Button b = new Button("100px button");
+ b.setWidth("100px");
+ final TextField tf = new TextField("Undef textfield");
+
+ // Adding component to grid
+ grid.addComponent(l, 0, 0);
+ grid.addComponent(b, 0, 1);
+ grid.addComponent(tf, 0, 2);
+
+ addComponent(new Button("Shift label right",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ // Moving component from 0,0 -> 1,0
+ grid.removeComponent(l);
+ grid.addComponent(l, 1, 0);
+ }
+ }));
+
+ addComponent(new Button("Shift button right",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ grid.removeComponent(b);
+ grid.addComponent(b, 1, 1);
+ }
+ }));
+
+ addComponent(new Button("Shift text field right",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ grid.removeComponent(tf);
+ grid.addComponent(tf, 1, 2);
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the buttons below the GridLayout to move the components to the right. Should definitely work no matter what.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5525;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutNPE.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutNPE.java
index 48ecb5832a..6424177fe1 100644
--- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutNPE.java
+++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutNPE.java
@@ -1,72 +1,72 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-public class GridLayoutNPE extends TestBase {
-
- @Override
- protected void setup() {
- final VerticalLayout lo = new VerticalLayout();
-
- final GridLayout gl = new GridLayout(2, 1);
- gl.setSpacing(true);
-
- final Label toRemove = new Label("First");
- gl.addComponent(toRemove);
- final Label toEdit = new Label("Second");
- gl.addComponent(toEdit);
-
- final Button b = new Button("remove 'First'");
- final Button b2 = new Button("edit 'Second'");
- b2.setVisible(false);
-
- lo.addComponent(gl);
- lo.addComponent(b);
- lo.addComponent(b2);
-
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(Button.ClickEvent event) {
- gl.removeComponent(toRemove);
-
- // move another component to where the first was removed
- // before rendering to the client
- gl.removeComponent(toEdit);
- // this could also be the result of removeAllComponents()
- // followed by a loop of addComponent(c)
- gl.addComponent(toEdit, 0, 0);
-
- b.setVisible(false);
- b2.setVisible(true);
-
- }
-
- });
-
- b2.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- toEdit.setValue("Second (edited)");
- }
-
- });
-
- addComponent(lo);
- }
-
- @Override
- protected String getDescription() {
- return "VGridLayout throws an NPE, causing client side to crash";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4019;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridLayoutNPE extends TestBase {
+
+ @Override
+ protected void setup() {
+ final VerticalLayout lo = new VerticalLayout();
+
+ final GridLayout gl = new GridLayout(2, 1);
+ gl.setSpacing(true);
+
+ final Label toRemove = new Label("First");
+ gl.addComponent(toRemove);
+ final Label toEdit = new Label("Second");
+ gl.addComponent(toEdit);
+
+ final Button b = new Button("remove 'First'");
+ final Button b2 = new Button("edit 'Second'");
+ b2.setVisible(false);
+
+ lo.addComponent(gl);
+ lo.addComponent(b);
+ lo.addComponent(b2);
+
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(Button.ClickEvent event) {
+ gl.removeComponent(toRemove);
+
+ // move another component to where the first was removed
+ // before rendering to the client
+ gl.removeComponent(toEdit);
+ // this could also be the result of removeAllComponents()
+ // followed by a loop of addComponent(c)
+ gl.addComponent(toEdit, 0, 0);
+
+ b.setVisible(false);
+ b2.setVisible(true);
+
+ }
+
+ });
+
+ b2.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ toEdit.setValue("Second (edited)");
+ }
+
+ });
+
+ addComponent(lo);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "VGridLayout throws an NPE, causing client side to crash";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4019;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutWidthChange.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutWidthChange.java
index 08bef51163..78984d33a2 100644
--- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutWidthChange.java
+++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutWidthChange.java
@@ -1,64 +1,64 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class GridLayoutWidthChange extends TestBase {
-
- private GridLayout generateLayout() {
- VerticalLayout fields1 = new VerticalLayout();
-
- NativeButton nb = new NativeButton("A button");
- nb.setHeight("300px");
- fields1.addComponent(nb);
-
- VerticalLayout fields3 = new VerticalLayout();
- fields3.addComponent(new TextField("field14"));
-
- NativeButton b = new NativeButton("A big button");
- b.setWidth("200px");
- b.setHeight("200px");
-
- GridLayout layout = new GridLayout(3, 2);
- layout.setWidth("100%");
- layout.addComponent(fields1, 0, 0, 0, 1);
- layout.addComponent(b, 2, 1);
-
- return layout;
- }
-
- @Override
- protected void setup() {
- final GridLayout layout1 = generateLayout();
- final CustomComponent cc = new CustomComponent(layout1);
- cc.setWidth("500px");
- addComponent(cc);
-
- Button testButton = new Button("Reduce GridLayout parent width",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- cc.setWidth((cc.getWidth() - 10) + "px");
- }
-
- });
- addComponent(testButton);
- }
-
- @Override
- protected String getDescription() {
- return "A 100% wide GridLayout is wrapped inside a CustomComponent. When the width of the CustomComponent is reduced, the size of the GridLayout should be reduced accordingly. The Buttons should stay in place vertically and just move closer to each other horizontally.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
- }
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridLayoutWidthChange extends TestBase {
+
+ private GridLayout generateLayout() {
+ VerticalLayout fields1 = new VerticalLayout();
+
+ NativeButton nb = new NativeButton("A button");
+ nb.setHeight("300px");
+ fields1.addComponent(nb);
+
+ VerticalLayout fields3 = new VerticalLayout();
+ fields3.addComponent(new TextField("field14"));
+
+ NativeButton b = new NativeButton("A big button");
+ b.setWidth("200px");
+ b.setHeight("200px");
+
+ GridLayout layout = new GridLayout(3, 2);
+ layout.setWidth("100%");
+ layout.addComponent(fields1, 0, 0, 0, 1);
+ layout.addComponent(b, 2, 1);
+
+ return layout;
+ }
+
+ @Override
+ protected void setup() {
+ final GridLayout layout1 = generateLayout();
+ final CustomComponent cc = new CustomComponent(layout1);
+ cc.setWidth("500px");
+ addComponent(cc);
+
+ Button testButton = new Button("Reduce GridLayout parent width",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cc.setWidth((cc.getWidth() - 10) + "px");
+ }
+
+ });
+ addComponent(testButton);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A 100% wide GridLayout is wrapped inside a CustomComponent. When the width of the CustomComponent is reduced, the size of the GridLayout should be reduced accordingly. The Buttons should stay in place vertically and just move closer to each other horizontally.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/HiddenHorizontalLayout.java b/tests/testbench/com/vaadin/tests/layouts/HiddenHorizontalLayout.java
index 50cf41f095..8de59ccf00 100644
--- a/tests/testbench/com/vaadin/tests/layouts/HiddenHorizontalLayout.java
+++ b/tests/testbench/com/vaadin/tests/layouts/HiddenHorizontalLayout.java
@@ -1,57 +1,57 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-public class HiddenHorizontalLayout extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Test to verify that toggling layout visibility works properly.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3183;
- }
-
- @Override
- public void setup() {
-
- VerticalLayout vl = new VerticalLayout();
- vl.setSizeFull();
- getLayout().addComponent(vl);
-
- final HorizontalLayout hl = new HorizontalLayout();
- hl.setWidth("100%");
- hl.setHeight("30px");
- hl.addComponent(new Label("label1"));
- hl.addComponent(new Label("label2"));
- hl.addComponent(new Label("label3"));
- hl.addComponent(new Label("label4"));
- vl.addComponent(hl);
-
- Label l = new Label("Steps to reproduce with Vaadin 6.0.1:<br/>"
- + "1. set browser size smaller than fullscreen<br/>"
- + "2. Refresh page with browser<br/>"
- + "3. Click \"toggle layout visibility\"<br>"
- + "4. Resize browser window to full <br/>"
- + "5. Click \"toggle layout visibility\"<br/>",
- Label.CONTENT_XHTML);
- vl.addComponent(l);
- Button b = new Button("toggle layout visibility",
- new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- hl.setVisible(!hl.isVisible());
- }
-
- });
- vl.addComponent(b);
- }
-
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class HiddenHorizontalLayout extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Test to verify that toggling layout visibility works properly.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3183;
+ }
+
+ @Override
+ public void setup() {
+
+ VerticalLayout vl = new VerticalLayout();
+ vl.setSizeFull();
+ getLayout().addComponent(vl);
+
+ final HorizontalLayout hl = new HorizontalLayout();
+ hl.setWidth("100%");
+ hl.setHeight("30px");
+ hl.addComponent(new Label("label1"));
+ hl.addComponent(new Label("label2"));
+ hl.addComponent(new Label("label3"));
+ hl.addComponent(new Label("label4"));
+ vl.addComponent(hl);
+
+ Label l = new Label("Steps to reproduce with Vaadin 6.0.1:<br/>"
+ + "1. set browser size smaller than fullscreen<br/>"
+ + "2. Refresh page with browser<br/>"
+ + "3. Click \"toggle layout visibility\"<br>"
+ + "4. Resize browser window to full <br/>"
+ + "5. Click \"toggle layout visibility\"<br/>",
+ Label.CONTENT_XHTML);
+ vl.addComponent(l);
+ Button b = new Button("toggle layout visibility",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ hl.setVisible(!hl.isVisible());
+ }
+
+ });
+ vl.addComponent(b);
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/layouts/OrderedLayoutBasics.java b/tests/testbench/com/vaadin/tests/layouts/OrderedLayoutBasics.java
index 620d33d43e..1fe11f1a92 100644
--- a/tests/testbench/com/vaadin/tests/layouts/OrderedLayoutBasics.java
+++ b/tests/testbench/com/vaadin/tests/layouts/OrderedLayoutBasics.java
@@ -1,1202 +1,1202 @@
-package com.vaadin.tests.layouts;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class OrderedLayoutBasics extends TestBase {
-
- String valignName[] = new String[] { "top", "middle", "bottom" };
-
- Set<AbstractOrderedLayout> layouts = new HashSet<AbstractOrderedLayout>();
- private AbstractOrderedLayout layoutContainer;
- private int suffix = 0;
-
- @Override
- protected String getDescription() {
- return "Various layout tests for VerticalLayout and HorizontalLayout";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- @Override
- public void setup() {
- getMainWindow().getContent().setHeight(null);
-
- layoutContainer = new VerticalLayout();
- createUI(layoutContainer);
- addComponent(layoutContainer);
- }
-
- private void createUI(Layout layout) {
- layout.addComponent(wrapLayout(layout_field_100pct_button_field(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_field_100pct_button_field(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_overfilled(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_overfilled(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_overfilled_dynamic_height(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_overfilled_dynamic_height(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_symmetric_fields(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_symmetric_fields(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_leftAndRight(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_leftAndRight(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_fixed_filled(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_fixed_filled(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_dynamic(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_dynamic(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_labels(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_labels(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_captions(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_captions(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_captions_fixed_size(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_captions_fixed_size(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_captions_fixed_size_and_relative_size(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_captions_fixed_size_and_relative_size(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_captions_fixed_size_and_fixed_size(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_captions_fixed_size_and_fixed_size(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_add_remove_components(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_add_remove_components(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_pctFilled(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_pctFilled(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_underFilled(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_underFilled(new VerticalLayout())));
- layout.addComponent(wrapLayout(layout_basic_test(new HorizontalLayout())));
- layout.addComponent(wrapLayout(layout_basic_test(new VerticalLayout())));
- }
-
- private Layout wrapLayout(Layout ol) {
- Panel p = new Panel(ol);
- p.setSizeUndefined();
- p.setCaption(ol.getCaption());
- ol.setCaption(null);
-
- VerticalLayout l = new VerticalLayout();
- l.setSizeUndefined();
- l.addComponent(p);
- // p.setWidth("600px");
-
- if (ol instanceof AbstractOrderedLayout) {
- layouts.add((AbstractOrderedLayout) ol);
- }
- return l;
- }
-
- /* LAYOUTS */
-
- @SuppressWarnings({ "unused", "deprecation" })
- private Layout layout1() {
- HorizontalLayout ol = new HorizontalLayout();
- ol.setHeight("200px");
- ol.setWidth("");
- ol.setCaption("Fixed height (200px) and dynamic width");
-
- TextField tf = new TextField("100px high TextField, valign: bottom");
- tf.setHeight("100px");
- tf.setWidth("");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- Select s = new Select("100% high select");
- s.setMultiSelect(true);
- s.setHeight("100%");
- s.setWidth("");
- ol.addComponent(s);
-
- s = new Select("200 px high select");
- s.setMultiSelect(true);
- s.setHeight("200px");
- s.setWidth("");
- ol.addComponent(s);
-
- // tf = new TextField("100% high TextField, right/bottom");
- // tf.setHeight("100%");
- // tf.setWidth("");
- // ol.addComponent(tf);
- // ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_RIGHT,
- // AlignmentHandler.ALIGNMENT_BOTTOM);
-
- // tf = new TextField("100% high, 200px wide TextField");
- // tf.setHeight("100%");
- // tf.setWidth("200px");
- // ol.addComponent(tf);
-
- return ol;
-
- }
-
- @SuppressWarnings({ "unused", "deprecation" })
- private Layout layout2() {
- HorizontalLayout ol = new HorizontalLayout();
- ol.setHeight("70px");
- ol.setWidth("");
- ol.setCaption("Fixed height (50px) and dynamic width");
-
- TextField tf = new TextField(
- "100px high TextField, valign: bottom, should be partly outside");
- tf.setHeight("100px");
- tf.setWidth("");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- tf = new TextField(
- "100% high, 50px wide TextField, valign: bottom, should fill full height");
- tf.setHeight("100%");
- tf.setWidth("50px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- Label l = new Label(
- "100% high, 50px wide Label, valign: bottom, does not fill full height, only needed space");
- tf.setHeight("100%");
- tf.setWidth("50px");
- ol.addComponent(l);
- ol.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
-
- Select s = new Select("100% high select, should fit into layout");
- s.setMultiSelect(true);
- s.setHeight("100%");
- s.setWidth("");
- for (int i = 0; i < 10; i++) {
- s.addItem(new Object());
- }
-
- ol.addComponent(s);
-
- s = new Select("200 px high select, should be partly outside");
- s.setMultiSelect(true);
- s.setHeight("200px");
- s.setWidth("");
- ol.addComponent(s);
-
- return ol;
- }
-
- @SuppressWarnings({ "unused", "deprecation" })
- private Layout layout3() {
- HorizontalLayout ol = new HorizontalLayout();
- ol.setHeight("");
- ol.setWidth("500px");
- ol.setCaption("Fixed width (500px) and dynamic height");
- TextField tf;
-
- tf = new TextField("100px high TextField, valign: bottom");
- tf.setHeight("100px");
- tf.setWidth("100%");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- tf = new TextField("100px high TextField, valign: top");
- tf.setHeight("100px");
- tf.setWidth("100%");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- tf = new TextField("100% high, 50px wide TextField, valign: bottom");
- tf.setHeight("100%");
- tf.setWidth("50px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- Label l = new Label(
- "100% high, 50px wide Label, valign: bottom, does not fill full height, only needed space");
- tf.setHeight("100%");
- tf.setWidth("50px");
- ol.addComponent(l);
- ol.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
-
- Select s = new Select("100% high select, should fit into layout");
- s.setMultiSelect(true);
- s.setHeight("100%");
- s.setWidth("100%");
- for (int i = 0; i < 10; i++) {
- s.addItem(new Object());
- }
-
- ol.addComponent(s);
-
- s = new Select("200 px high select, should make the layout 200px high");
- s.setMultiSelect(true);
- s.setHeight("200px");
- s.setWidth("100%");
- ol.addComponent(s);
-
- return ol;
- }
-
- @SuppressWarnings({ "unused", "deprecation" })
- private Layout layout3New() {
- HorizontalLayout ol = new HorizontalLayout();
- ol.setHeight("300px");
- // ol.setWidth("500px");
- ol.setWidth("");
- ol.setCaption("Dynamic width and fixed height(300px)");
- TextField tf;
-
- tf = new TextField("100px high TextField, valign: bottom");
- tf.setHeight("100px");
- tf.setWidth("100%");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- tf = new TextField("100px high TextField, valign: top");
- tf.setHeight("100px");
- tf.setWidth("100%");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- tf = new TextField("100% high, 50px wide TextField, valign: bottom");
- tf.setHeight("100%");
- tf.setWidth("50px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
-
- Label l = new Label(
- "100% high, 50px wide Label, valign: bottom, does not fill full height, only needed space");
- tf.setHeight("100%");
- tf.setWidth("50px");
- ol.addComponent(l);
- ol.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
-
- Select s = new Select("100% high select, should fit into layout");
- s.setMultiSelect(true);
- s.setHeight("100%");
- s.setWidth("100%");
- for (int i = 0; i < 10; i++) {
- s.addItem(new Object());
- }
-
- ol.addComponent(s);
-
- s = new Select("200 px high select, should make the layout 200px high");
- s.setMultiSelect(true);
- s.setHeight("200px");
- s.setWidth("100%");
- ol.addComponent(s);
-
- return ol;
- }
-
- @SuppressWarnings("unused")
- private Layout layout4(AbstractOrderedLayout ol) {
- // ol.setHeight("300px");
- // ol.setWidth("500px");
- ol.setMargin(true);
- ol.setSpacing(true);
- ol.setWidth("");
- ol.setCaption("Dynamic width and dynamic height");
- TextArea tf;
-
- tf = new TextArea("100% high TextField");
- tf.setCaption(null);
- tf.setRequired(true);
- tf.setValue("100% high Field");
- tf.setHeight("100%");
- tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
-
- tf = new TextArea("100% high TextField");
- tf.setCaption("100% high TextField");
- tf.setRequired(true);
- tf.setValue("100% high Field");
- tf.setHeight("100%");
- tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
-
- for (int i = 1; i < 4; i++) {
- int w = i * 100;
- tf = new TextArea("Field " + i);
- tf.setRows(2);
- tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
- + valignName[i % 3]);
- tf.setWidth(w + "px");
- tf.setHeight(w + "px");
- ol.addComponent(tf);
- if (i % 3 == 0) {
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
- } else if (i % 3 == 1) {
- ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
- } else {
- ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
- }
-
- }
-
- tf = new TextArea("100% high TextField");
- tf.setValue("100% high 100px wide");
- tf.setRows(2);
- tf.setHeight("100%");
- tf.setWidth("100px");
- ol.addComponent(tf);
- return ol;
- }
-
- private Layout layout_field_100pct_button_field(AbstractOrderedLayout ol) {
- ol.setHeight("500px");
- ol.setWidth("916px");
- ol.setMargin(false);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight()
- + "px) / layout_field_100pct_button_field");
- TextArea tf;
-
- tf = new TextArea("300px x 300px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("300x300 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- Button b;
- b = new Button("This is a 100%x50% valign middle button");
- b.setSizeFull();
- b.setHeight("50%");
- ol.addComponent(b);
- ol.setExpandRatio(b, 1.0f);
- ol.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
-
- tf = new TextArea("300px x 300px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("300x300 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- return ol;
- }
-
- private Layout layout_basic_test(AbstractOrderedLayout ol) {
- ol.setHeight("700px");
- ol.setWidth("900px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight()
- + "px) / layout_basic_test");
- TextArea tf;
-
- tf = new TextArea("300px x 300px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("300x300 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- // Button b;
- // b = new Button("This is a 100%x50% valign middle button");
- // b.setSizeFull();
- // b.setHeight("50%");
- // ol.addComponent(b, 1.0f);
- // ol.setComponentAlignment(b, AlignmentHandler.ALIGNMENT_RIGHT,
- // AlignmentHandler.ALIGNMENT_VERTICAL_CENTER);
-
- tf = new TextArea("300px x 300px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("300x300 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- return ol;
- }
-
- private Layout layout_symmetric_fields(AbstractOrderedLayout ol) {
- ol.setHeight("900px");
- ol.setWidth("900px");
- ol.setMargin(false);
- ol.setSpacing(false);
-
- // ol.setWidth("");
- ol.setCaption("Fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight()
- + "px) / layout_symmetric_fields");
- TextArea tf;
-
- tf = new TextArea("300px x 300px Field");
- tf.setValue("300x300 field");
- tf.setRows(2);
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- tf = new TextArea("300px x 300px Field");
- tf.setValue("300x300 field");
- tf.setRows(2);
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
-
- tf = new TextArea("300px x 300px Field");
- tf.setValue("300x300 field");
- tf.setRows(2);
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- return ol;
- }
-
- private Layout layout_leftAndRight(AbstractOrderedLayout ol) {
- ol.setHeight("700px");
- ol.setWidth("700px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight()
- + "px) / layout_leftAndRight");
- TextArea tf;
-
- // tf = new TextField("100%x100% Field");
- // tf.setCaption(null);
- // tf.setValue("100% x 100% TextField");
- // tf.setSizeFull();
- // tf.setRequired(true);
- // // tf.setComponentError(new UserError("It's broken!"));
- //
- // // tf.setHeight("100%");
- // // tf.setWidth("100px");
- // tf.setRows(2);
- // ol.addComponent(tf);
- //
- // for (int i = 1; i < 5; i++) {
- // int w = i * 100;
- // tf = new TextField("Caption field " + i);
- // tf.setRows(2);
- // tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
- // + valignName[i % 3]);
- // tf.setWidth(w + "px");
- // tf.setHeight(w + "px");
- // ol.addComponent(tf);
- // ol.setComponentAlignment(tf,
- // AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, valign[i % 3]);
- // }
- //
- // tf.setValue(tf.getValue().toString() + " (100% wide)");
- // tf.setWidth("100%");
-
- // tf = new TextField("100%x70px Field");
- // tf.setCaption(null);
- // tf.setRequired(true);
- // // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- // tf.setComponentError(new UserError("abc"));
- // tf.setValue("100% high 70px wide TextField");
- // tf.setRows(2);
- // // tf.setSizeFull();
- // tf.setHeight("100%");
- // tf.setWidth("70px");
- // ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_RIGHT,
- // AlignmentHandler.ALIGNMENT_TOP);
- // ol.addComponent(tf);
-
- tf = new TextArea("300px x 300px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("300x300 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- tf = new TextArea("300px x 300px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("300x300 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("300px");
- tf.setWidth("300px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- return ol;
- }
-
- private Layout layout_fixed_filled(AbstractOrderedLayout ol) {
- ol.setHeight("700px");
- ol.setWidth("700px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Filled with fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight() + "px)");
- TextArea tf;
-
- tf = new TextArea("60%x100% Field");
- tf.setCaption("This one has a caption");
- tf.setValue("60% x 100% TextField");
- tf.setWidth("100%");
- tf.setHeight("100%");
- tf.setRequired(true);
- // tf.setComponentError(new UserError("It's broken!"));
-
- // tf.setHeight("100%");
- // tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
- ol.setExpandRatio(tf, 1f);
- //
-
- tf = new TextArea("60%x60% Field");
- tf.setCaption(null);
- tf.setValue("60% x 60% TextField");
- tf.setWidth("100%");
- tf.setHeight("60%");
- tf.setRequired(true);
- ol.addComponent(tf);
- ol.setExpandRatio(tf, 1f);
- ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
- // tf.setComponentError(new UserError("It's broken!"));
-
- // tf.setHeight("100%");
- // tf.setWidth("100px");
- tf.setRows(2);
- //
- // for (int i = 1; i < 5; i++) {
- // int w = i * 100;
- // tf = new TextField("Caption field " + i);
- // tf.setRows(2);
- // tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
- // + valignName[i % 3]);
- // tf.setWidth(w + "px");
- // tf.setHeight(w + "px");
- // ol.addComponent(tf);
- // ol.setComponentAlignment(tf,
- // AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, valign[i % 3]);
- // }
- //
- // tf.setValue(tf.getValue().toString() + " (100% wide)");
- // tf.setWidth("100%");
-
- // tf = new TextField("100%x70px Field");
- // tf.setCaption(null);
- // tf.setRequired(true);
- // // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- // tf.setComponentError(new UserError("abc"));
- // tf.setValue("100% high 70px wide TextField");
- // tf.setRows(2);
- // // tf.setSizeFull();
- // tf.setHeight("100%");
- // tf.setWidth("70px");
- // ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_RIGHT,
- // AlignmentHandler.ALIGNMENT_TOP);
- // ol.addComponent(tf);
-
- tf = new TextArea("200px x 200px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("200x200 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("200px");
- tf.setWidth("200px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
-
- tf = new TextArea("200px x 200px Field");
- // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setValue("200x200 field");
- tf.setRows(2);
- // tf.setSizeFull();
- tf.setHeight("200px");
- tf.setWidth("200px");
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- return ol;
- }
-
- private Layout layout_overfilled(AbstractOrderedLayout ol) {
- ol.setHeight("300px");
- ol.setWidth("700px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("OverFilled with fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight() + "px)");
- TextArea tf;
-
- for (int i = 0; i < 5; i++) {
- tf = new TextArea("200x200px Field");
- tf.setCaption("This one has a caption");
- tf.setValue("200x200 TextField");
- tf.setWidth("200px");
- tf.setHeight("200px");
- tf.setRequired(true);
- // tf.setComponentError(new UserError("It's broken!"));
-
- // tf.setHeight("100%");
- // tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
- }
-
- return ol;
- }
-
- private Layout layout_overfilled_dynamic_height(AbstractOrderedLayout ol) {
- ol.setHeight(null);
- ol.setWidth("700px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("OverFilled with fixed width (" + ol.getWidth()
- + "px) and dynamic height");
- TextArea tf;
-
- for (int i = 0; i < 10; i++) {
- tf = new TextArea("200x200px Field");
- tf.setCaption("This one has a caption");
- tf.setWidth("200px");
- tf.setHeight(((i + 1) * 50) + "px");
- tf.setValue(tf.getWidth() + "x" + tf.getHeight() + " TextField");
- tf.setRequired(true);
- // tf.setComponentError(new UserError("It's broken!"));
-
- // tf.setHeight("100%");
- // tf.setWidth("100px");
- tf.setRows(2);
- ol.addComponent(tf);
- }
-
- return ol;
- }
-
- // private Layout layout_add_components(AbstractOrderedLayout ol) {
- // ol.setHeight("600px");
- // ol.setWidth("600px");
- // ol.setMargin(true);
- // ol.setSpacing(true);
- //
- // // ol.setWidth("");
- // ol.setCaption("Fixed width (" + ol.getWidth()
- // + "px) and fixed height (" + ol.getHeight() + "px)");
- //
- // for (int i = 0; i < 3; i++) {
- // Button b = createAddButton(ol);
- // ol.addComponent(b);
- // }
- //
- // return ol;
- //
- // }
-
- private Layout layout_add_remove_components(AbstractOrderedLayout ol) {
- ol.setHeight("600px");
- ol.setWidth("600px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight()
- + "px) / layout_add_remove_components");
-
- for (int i = 0; i < 2; i++) {
- AbstractOrderedLayout inner = createAddRemove(ol, "", "");
- ol.addComponent(inner);
- ol.setComponentAlignment(inner, Alignment.BOTTOM_RIGHT);
- }
-
- return ol;
-
- }
-
- private Layout layout_dynamic(AbstractOrderedLayout ol) {
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Dynamic width, dynamic height");
-
- for (int i = 0; i < 3; i++) {
- Button b = new Button("Button " + i);
- if (i == 2) {
- b.setHeight("200px");
- } else {
- b.setHeight("100%");
- }
- ol.addComponent(b);
- }
-
- return ol;
-
- }
-
- private Layout layout_captions(AbstractOrderedLayout ol) {
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Caption test with dynamic width");
-
- TextField tf;
- tf = new TextField("Short caption");
- ol.addComponent(tf);
-
- tf = new TextField(
- "A very long caption which is probably much longer than the field");
- ol.addComponent(tf);
-
- tf = new TextField(
- "A very long caption which is probably much longer than the field and includes indicators");
- tf.setRequired(true);
- tf.setComponentError(new UserError("abc123"));
- ol.addComponent(tf);
-
- // for (int i = 0; i < 3; i++) {
- // Button b = new Button("Button " + i);
- // if (i == 2) {
- // b.setHeight("200px");
- // } else {
- // b.setHeight("100%");
- // }
- // ol.addComponent(b);
- // }
-
- return ol;
-
- }
-
- private Layout layout_captions_fixed_size(AbstractOrderedLayout ol) {
- ol.setWidth("700px");
- ol.setHeight("250px");
-
- ol.setMargin(false);
- ol.setSpacing(false);
-
- // ol.setWidth("");
- ol.setCaption("Caption test with fixed size");
-
- TextField tf;
- tf = new TextField("Short caption");
- tf.setValue("Undefined width");
- tf.setComponentError(new UserError("123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- tf = new TextField(
- "A long caption which is probably much longer than the field");
- tf.setValue("Undefined width");
- tf.setRequired(true);
- tf.setComponentError(new UserError("123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- tf = new TextField(
- "A very long caption which is probably much longer than the field and includes indicators");
- tf.setValue("Undefined width");
- tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setRequired(true);
- tf.setComponentError(new UserError("abc123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- // for (int i = 0; i < 3; i++) {
- // Button b = new Button("Button " + i);
- // if (i == 2) {
- // b.setHeight("200px");
- // } else {
- // b.setHeight("100%");
- // }
- // ol.addComponent(b);
- // }
-
- return ol;
-
- }
-
- private Layout layout_captions_fixed_size_and_relative_size(
- AbstractOrderedLayout ol) {
- ol.setWidth("700px");
- ol.setHeight("250px");
-
- ol.setMargin(false);
- ol.setSpacing(false);
-
- // ol.setWidth("");
- ol.setCaption("Caption test with fixed width (700x250)");
-
- TextField tf;
- tf = new TextField("Short caption");
- tf.setSizeFull();
- tf.setValue("100% wide field, ratio 1");
-
- tf.setComponentError(new UserError("123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- ol.setExpandRatio(tf, 1);
-
- tf = new TextField(
- "A long caption which is probably much longer than the field");
- tf.setValue("100% wide field, ratio 2");
- tf.setSizeFull();
- tf.setRequired(true);
- tf.setComponentError(new UserError("123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- ol.setExpandRatio(tf, 2);
-
- tf = new TextField(
- "A very long caption which is probably much longer than the field and includes indicators");
- tf.setValue("100% wide field, ratio 3");
- tf.setSizeFull();
- tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setRequired(true);
- tf.setComponentError(new UserError("abc123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
- ol.setExpandRatio(tf, 3);
-
- // for (int i = 0; i < 3; i++) {
- // Button b = new Button("Button " + i);
- // if (i == 2) {
- // b.setHeight("200px");
- // } else {
- // b.setHeight("100%");
- // }
- // ol.addComponent(b);
- // }
-
- return ol;
-
- }
-
- private Layout layout_captions_fixed_size_and_fixed_size(
- AbstractOrderedLayout ol) {
- ol.setWidth("700px");
- ol.setHeight("250px");
-
- ol.setMargin(false);
- ol.setSpacing(false);
-
- // ol.setWidth("");
- ol.setCaption("Caption test with fixed width");
-
- TextField tf;
- tf = new TextField("Short caption");
- tf.setValue("250px wide field");
- tf.setWidth("250px");
- tf.setComponentError(new UserError("123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- tf = new TextField(
- "A long caption which is probably much longer than the field");
- tf.setWidth("250px");
- tf.setValue("250px wide field");
- tf.setRequired(true);
- tf.setComponentError(new UserError("123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- tf = new TextField(
- "A very long caption which is probably much longer than the field and includes indicators");
- tf.setValue("200px wide field");
- tf.setWidth("200px");
- tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setRequired(true);
- tf.setComponentError(new UserError("abc123"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
-
- // for (int i = 0; i < 3; i++) {
- // Button b = new Button("Button " + i);
- // if (i == 2) {
- // b.setHeight("200px");
- // } else {
- // b.setHeight("100%");
- // }
- // ol.addComponent(b);
- // }
-
- return ol;
-
- }
-
- private Layout layout_labels(AbstractOrderedLayout ol) {
- // ol.setWidth("700px");
- // ol.setHeight("200px");
-
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Caption test with fixed width");
-
- Label l;
- l = new Label(
- "This is a long text and should remain on one line as there is nothing forcing line breaks");
- ol.addComponent(l);
- // ol.setComponentAlignment(l, AlignmentHandler.ALIGNMENT_RIGHT,
- // AlignmentHandler.ALIGNMENT_BOTTOM);
-
- l = new Label("WTF OMG LOL");
- ol.addComponent(l);
- // ol.setComponentAlignment(l, AlignmentHandler.ALIGNMENT_RIGHT,
- // AlignmentHandler.ALIGNMENT_BOTTOM);
-
- return ol;
-
- }
-
- private AbstractOrderedLayout createAddRemove(AbstractOrderedLayout ol,
- String width, String buttonSuffix) {
- Button b = createAddButton(ol);
- Button wb = createWideAddButton(ol);
- Button r = createRemoveButton(ol, buttonSuffix);
- VerticalLayout inner = new VerticalLayout();
- inner.setCaption("Width: " + width);
- inner.setWidth(width);
-
- inner.addComponent(b);
- inner.addComponent(wb);
- inner.addComponent(r);
-
- // inner.setHeight("132px");
- return inner;
- }
-
- private Button createAddButton(AbstractOrderedLayout ol) {
- Button b = new Button("Add before", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- addBefore((AbstractOrderedLayout) event.getButton().getData(),
- event.getButton().getParent(), "");
- }
-
- });
- b.setData(ol);
-
- return b;
- }
-
- private Button createWideAddButton(AbstractOrderedLayout ol) {
- Button b = new Button("Add 100% before", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- addBefore((AbstractOrderedLayout) event.getButton().getData(),
- event.getButton().getParent(), "100%");
- }
-
- });
- b.setData(ol);
-
- return b;
- }
-
- private Button createRemoveButton(AbstractOrderedLayout ol, String suffix) {
- Button b = new Button("Remove this " + suffix, new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- remove((AbstractOrderedLayout) event.getButton().getData(),
- event.getButton().getParent());
- }
-
- });
- b.setWidth("100%");
- b.setData(ol);
-
- return b;
- }
-
- protected void remove(AbstractOrderedLayout ol, Component c) {
- ol.removeComponent(c);
-
- }
-
- protected void addBefore(AbstractOrderedLayout ol, Component c, String width) {
- int index = 0;
- Iterator<Component> iter = ol.getComponentIterator();
- while (iter.hasNext()) {
- if (iter.next() == c) {
- break;
- }
- index++;
- }
- AbstractOrderedLayout inner = createAddRemove(ol, width,
- String.valueOf(suffix++));
- ol.addComponent(inner, index);
- if (width.contains("%")) {
- ol.setExpandRatio(inner, 1.0f);
- }
-
- ol.setComponentAlignment(inner, Alignment.BOTTOM_RIGHT);
-
- }
-
- private Layout layout_pctFilled(AbstractOrderedLayout ol) {
- ol.setHeight("600px");
- ol.setWidth("600px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("100 % filled with fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight() + "px)");
- TextArea ta;
-
- ta = new TextArea();
- ta.setCaption("This one has a caption");
- ta.setValue("60% expand TextField");
- ta.setWidth("100%");
- ta.setHeight("100%");
- // ta.setRequired(true);
- // ta.setComponentError(new UserError("It's broken!"));
-
- // ta.setHeight("100%");
- // ta.setWidth("100px");
- ta.setRows(2);
- ol.addComponent(ta);
- ol.setExpandRatio(ta, 60);
-
- ta = new TextArea();
- ta.setValue("100px 100px TextField");
- ta.setWidth("100px");
- ta.setHeight("100px");
- ta.setRows(2);
- ol.addComponent(ta);
- ol.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
-
- //
-
- ta = new TextArea("40%x40% Field");
- // ta.setCaption(null);
- ta.setValue("40% expand (40% height) TextField");
- ta.setWidth("100%");
- ta.setHeight("40%");
- ol.addComponent(ta);
- ol.setExpandRatio(ta, 40);
- // ta.setRequired(true);
- ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
-
- ta.setRows(2);
-
- return ol;
- }
-
- @SuppressWarnings("unused")
- private Layout layout_pctFilled2(AbstractOrderedLayout ol) {
- ol.setHeight("600px");
- ol.setWidth("600px");
- ol.setMargin(true);
- ol.setSpacing(false);
-
- // ol.setWidth("");
- ol.setCaption("100 % filled with fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight() + "px)");
- TextArea ta;
-
- ta = new TextArea();
- // ta.setCaption("This one has a caption");
- ta.setValue("80% x 20% TextField");
- ta.setWidth("80%");
- ta.setHeight("20%");
- // ta.setRequired(true);
- // ta.setComponentError(new UserError("It's broken!"));
-
- // ta.setHeight("100%");
- // ta.setWidth("100px");
- ta.setRows(2);
- ol.addComponent(ta);
- //
-
- ta = new TextArea("20%x60% Field");
- ta.setCaption(null);
- ta.setValue("20% x 60% TextField");
- ta.setWidth("20%");
- ta.setHeight("60%");
- // ta.setRequired(true);
- ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
-
- ta.setRows(2);
- ol.addComponent(ta);
-
- return ol;
- }
-
- private Layout layout_underFilled(AbstractOrderedLayout ol) {
- ol.setHeight("700px");
- ol.setWidth("700px");
- ol.setMargin(true);
- ol.setSpacing(true);
-
- // ol.setWidth("");
- ol.setCaption("Underfilled with fixed width (" + ol.getWidth()
- + "px) and fixed height (" + ol.getHeight() + "px)");
- TextArea ta;
-
- ta = new TextArea("60%x100% Field");
- ta.setCaption("Short capt");
- ta.setValue("60% x 100% TextField");
- ta.setWidth("60%");
- ta.setHeight("100%");
- ta.setRequired(true);
- ta.setRows(2);
-
- ol.addComponent(ta);
- ol.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
-
- ta = new TextArea("200px x 200px Field");
- // ta.setIcon(new ThemeResource("icons/16/document-add.png"));
- ta.setValue("200x200 field");
- ta.setRows(2);
- // ta.setSizeFull();
- ta.setHeight("200px");
- ta.setWidth("200px");
- ol.addComponent(ta);
- ol.setComponentAlignment(ta, Alignment.TOP_LEFT);
-
- ta = new TextArea("200px x 200px Field");
- // ta.setIcon(new ThemeResource("icons/16/document-add.png"));
- ta.setValue("200x200 field");
- ta.setRows(2);
- // ta.setSizeFull();
- ta.setHeight("200px");
- ta.setWidth("200px");
- ol.addComponent(ta);
- ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
- return ol;
- }
-
+package com.vaadin.tests.layouts;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class OrderedLayoutBasics extends TestBase {
+
+ String valignName[] = new String[] { "top", "middle", "bottom" };
+
+ Set<AbstractOrderedLayout> layouts = new HashSet<AbstractOrderedLayout>();
+ private AbstractOrderedLayout layoutContainer;
+ private int suffix = 0;
+
+ @Override
+ protected String getDescription() {
+ return "Various layout tests for VerticalLayout and HorizontalLayout";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+ @Override
+ public void setup() {
+ getMainWindow().getContent().setHeight(null);
+
+ layoutContainer = new VerticalLayout();
+ createUI(layoutContainer);
+ addComponent(layoutContainer);
+ }
+
+ private void createUI(Layout layout) {
+ layout.addComponent(wrapLayout(layout_field_100pct_button_field(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_field_100pct_button_field(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_overfilled(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_overfilled(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_overfilled_dynamic_height(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_overfilled_dynamic_height(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_symmetric_fields(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_symmetric_fields(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_leftAndRight(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_leftAndRight(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_fixed_filled(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_fixed_filled(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_dynamic(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_dynamic(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_labels(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_labels(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_captions(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_captions(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_captions_fixed_size(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_captions_fixed_size(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_captions_fixed_size_and_relative_size(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_captions_fixed_size_and_relative_size(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_captions_fixed_size_and_fixed_size(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_captions_fixed_size_and_fixed_size(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_add_remove_components(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_add_remove_components(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_pctFilled(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_pctFilled(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_underFilled(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_underFilled(new VerticalLayout())));
+ layout.addComponent(wrapLayout(layout_basic_test(new HorizontalLayout())));
+ layout.addComponent(wrapLayout(layout_basic_test(new VerticalLayout())));
+ }
+
+ private Layout wrapLayout(Layout ol) {
+ Panel p = new Panel(ol);
+ p.setSizeUndefined();
+ p.setCaption(ol.getCaption());
+ ol.setCaption(null);
+
+ VerticalLayout l = new VerticalLayout();
+ l.setSizeUndefined();
+ l.addComponent(p);
+ // p.setWidth("600px");
+
+ if (ol instanceof AbstractOrderedLayout) {
+ layouts.add((AbstractOrderedLayout) ol);
+ }
+ return l;
+ }
+
+ /* LAYOUTS */
+
+ @SuppressWarnings({ "unused", "deprecation" })
+ private Layout layout1() {
+ HorizontalLayout ol = new HorizontalLayout();
+ ol.setHeight("200px");
+ ol.setWidth("");
+ ol.setCaption("Fixed height (200px) and dynamic width");
+
+ TextField tf = new TextField("100px high TextField, valign: bottom");
+ tf.setHeight("100px");
+ tf.setWidth("");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ Select s = new Select("100% high select");
+ s.setMultiSelect(true);
+ s.setHeight("100%");
+ s.setWidth("");
+ ol.addComponent(s);
+
+ s = new Select("200 px high select");
+ s.setMultiSelect(true);
+ s.setHeight("200px");
+ s.setWidth("");
+ ol.addComponent(s);
+
+ // tf = new TextField("100% high TextField, right/bottom");
+ // tf.setHeight("100%");
+ // tf.setWidth("");
+ // ol.addComponent(tf);
+ // ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_RIGHT,
+ // AlignmentHandler.ALIGNMENT_BOTTOM);
+
+ // tf = new TextField("100% high, 200px wide TextField");
+ // tf.setHeight("100%");
+ // tf.setWidth("200px");
+ // ol.addComponent(tf);
+
+ return ol;
+
+ }
+
+ @SuppressWarnings({ "unused", "deprecation" })
+ private Layout layout2() {
+ HorizontalLayout ol = new HorizontalLayout();
+ ol.setHeight("70px");
+ ol.setWidth("");
+ ol.setCaption("Fixed height (50px) and dynamic width");
+
+ TextField tf = new TextField(
+ "100px high TextField, valign: bottom, should be partly outside");
+ tf.setHeight("100px");
+ tf.setWidth("");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ tf = new TextField(
+ "100% high, 50px wide TextField, valign: bottom, should fill full height");
+ tf.setHeight("100%");
+ tf.setWidth("50px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ Label l = new Label(
+ "100% high, 50px wide Label, valign: bottom, does not fill full height, only needed space");
+ tf.setHeight("100%");
+ tf.setWidth("50px");
+ ol.addComponent(l);
+ ol.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
+
+ Select s = new Select("100% high select, should fit into layout");
+ s.setMultiSelect(true);
+ s.setHeight("100%");
+ s.setWidth("");
+ for (int i = 0; i < 10; i++) {
+ s.addItem(new Object());
+ }
+
+ ol.addComponent(s);
+
+ s = new Select("200 px high select, should be partly outside");
+ s.setMultiSelect(true);
+ s.setHeight("200px");
+ s.setWidth("");
+ ol.addComponent(s);
+
+ return ol;
+ }
+
+ @SuppressWarnings({ "unused", "deprecation" })
+ private Layout layout3() {
+ HorizontalLayout ol = new HorizontalLayout();
+ ol.setHeight("");
+ ol.setWidth("500px");
+ ol.setCaption("Fixed width (500px) and dynamic height");
+ TextField tf;
+
+ tf = new TextField("100px high TextField, valign: bottom");
+ tf.setHeight("100px");
+ tf.setWidth("100%");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ tf = new TextField("100px high TextField, valign: top");
+ tf.setHeight("100px");
+ tf.setWidth("100%");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ tf = new TextField("100% high, 50px wide TextField, valign: bottom");
+ tf.setHeight("100%");
+ tf.setWidth("50px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ Label l = new Label(
+ "100% high, 50px wide Label, valign: bottom, does not fill full height, only needed space");
+ tf.setHeight("100%");
+ tf.setWidth("50px");
+ ol.addComponent(l);
+ ol.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
+
+ Select s = new Select("100% high select, should fit into layout");
+ s.setMultiSelect(true);
+ s.setHeight("100%");
+ s.setWidth("100%");
+ for (int i = 0; i < 10; i++) {
+ s.addItem(new Object());
+ }
+
+ ol.addComponent(s);
+
+ s = new Select("200 px high select, should make the layout 200px high");
+ s.setMultiSelect(true);
+ s.setHeight("200px");
+ s.setWidth("100%");
+ ol.addComponent(s);
+
+ return ol;
+ }
+
+ @SuppressWarnings({ "unused", "deprecation" })
+ private Layout layout3New() {
+ HorizontalLayout ol = new HorizontalLayout();
+ ol.setHeight("300px");
+ // ol.setWidth("500px");
+ ol.setWidth("");
+ ol.setCaption("Dynamic width and fixed height(300px)");
+ TextField tf;
+
+ tf = new TextField("100px high TextField, valign: bottom");
+ tf.setHeight("100px");
+ tf.setWidth("100%");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ tf = new TextField("100px high TextField, valign: top");
+ tf.setHeight("100px");
+ tf.setWidth("100%");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ tf = new TextField("100% high, 50px wide TextField, valign: bottom");
+ tf.setHeight("100%");
+ tf.setWidth("50px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+
+ Label l = new Label(
+ "100% high, 50px wide Label, valign: bottom, does not fill full height, only needed space");
+ tf.setHeight("100%");
+ tf.setWidth("50px");
+ ol.addComponent(l);
+ ol.setComponentAlignment(l, Alignment.BOTTOM_LEFT);
+
+ Select s = new Select("100% high select, should fit into layout");
+ s.setMultiSelect(true);
+ s.setHeight("100%");
+ s.setWidth("100%");
+ for (int i = 0; i < 10; i++) {
+ s.addItem(new Object());
+ }
+
+ ol.addComponent(s);
+
+ s = new Select("200 px high select, should make the layout 200px high");
+ s.setMultiSelect(true);
+ s.setHeight("200px");
+ s.setWidth("100%");
+ ol.addComponent(s);
+
+ return ol;
+ }
+
+ @SuppressWarnings("unused")
+ private Layout layout4(AbstractOrderedLayout ol) {
+ // ol.setHeight("300px");
+ // ol.setWidth("500px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+ ol.setWidth("");
+ ol.setCaption("Dynamic width and dynamic height");
+ TextArea tf;
+
+ tf = new TextArea("100% high TextField");
+ tf.setCaption(null);
+ tf.setRequired(true);
+ tf.setValue("100% high Field");
+ tf.setHeight("100%");
+ tf.setWidth("100px");
+ tf.setRows(2);
+ ol.addComponent(tf);
+
+ tf = new TextArea("100% high TextField");
+ tf.setCaption("100% high TextField");
+ tf.setRequired(true);
+ tf.setValue("100% high Field");
+ tf.setHeight("100%");
+ tf.setWidth("100px");
+ tf.setRows(2);
+ ol.addComponent(tf);
+
+ for (int i = 1; i < 4; i++) {
+ int w = i * 100;
+ tf = new TextArea("Field " + i);
+ tf.setRows(2);
+ tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
+ + valignName[i % 3]);
+ tf.setWidth(w + "px");
+ tf.setHeight(w + "px");
+ ol.addComponent(tf);
+ if (i % 3 == 0) {
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+ } else if (i % 3 == 1) {
+ ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
+ } else {
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+ }
+
+ }
+
+ tf = new TextArea("100% high TextField");
+ tf.setValue("100% high 100px wide");
+ tf.setRows(2);
+ tf.setHeight("100%");
+ tf.setWidth("100px");
+ ol.addComponent(tf);
+ return ol;
+ }
+
+ private Layout layout_field_100pct_button_field(AbstractOrderedLayout ol) {
+ ol.setHeight("500px");
+ ol.setWidth("916px");
+ ol.setMargin(false);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight()
+ + "px) / layout_field_100pct_button_field");
+ TextArea tf;
+
+ tf = new TextArea("300px x 300px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ Button b;
+ b = new Button("This is a 100%x50% valign middle button");
+ b.setSizeFull();
+ b.setHeight("50%");
+ ol.addComponent(b);
+ ol.setExpandRatio(b, 1.0f);
+ ol.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);
+
+ tf = new TextArea("300px x 300px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ return ol;
+ }
+
+ private Layout layout_basic_test(AbstractOrderedLayout ol) {
+ ol.setHeight("700px");
+ ol.setWidth("900px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight()
+ + "px) / layout_basic_test");
+ TextArea tf;
+
+ tf = new TextArea("300px x 300px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ // Button b;
+ // b = new Button("This is a 100%x50% valign middle button");
+ // b.setSizeFull();
+ // b.setHeight("50%");
+ // ol.addComponent(b, 1.0f);
+ // ol.setComponentAlignment(b, AlignmentHandler.ALIGNMENT_RIGHT,
+ // AlignmentHandler.ALIGNMENT_VERTICAL_CENTER);
+
+ tf = new TextArea("300px x 300px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ return ol;
+ }
+
+ private Layout layout_symmetric_fields(AbstractOrderedLayout ol) {
+ ol.setHeight("900px");
+ ol.setWidth("900px");
+ ol.setMargin(false);
+ ol.setSpacing(false);
+
+ // ol.setWidth("");
+ ol.setCaption("Fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight()
+ + "px) / layout_symmetric_fields");
+ TextArea tf;
+
+ tf = new TextArea("300px x 300px Field");
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ tf = new TextArea("300px x 300px Field");
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
+
+ tf = new TextArea("300px x 300px Field");
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ return ol;
+ }
+
+ private Layout layout_leftAndRight(AbstractOrderedLayout ol) {
+ ol.setHeight("700px");
+ ol.setWidth("700px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight()
+ + "px) / layout_leftAndRight");
+ TextArea tf;
+
+ // tf = new TextField("100%x100% Field");
+ // tf.setCaption(null);
+ // tf.setValue("100% x 100% TextField");
+ // tf.setSizeFull();
+ // tf.setRequired(true);
+ // // tf.setComponentError(new UserError("It's broken!"));
+ //
+ // // tf.setHeight("100%");
+ // // tf.setWidth("100px");
+ // tf.setRows(2);
+ // ol.addComponent(tf);
+ //
+ // for (int i = 1; i < 5; i++) {
+ // int w = i * 100;
+ // tf = new TextField("Caption field " + i);
+ // tf.setRows(2);
+ // tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
+ // + valignName[i % 3]);
+ // tf.setWidth(w + "px");
+ // tf.setHeight(w + "px");
+ // ol.addComponent(tf);
+ // ol.setComponentAlignment(tf,
+ // AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, valign[i % 3]);
+ // }
+ //
+ // tf.setValue(tf.getValue().toString() + " (100% wide)");
+ // tf.setWidth("100%");
+
+ // tf = new TextField("100%x70px Field");
+ // tf.setCaption(null);
+ // tf.setRequired(true);
+ // // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ // tf.setComponentError(new UserError("abc"));
+ // tf.setValue("100% high 70px wide TextField");
+ // tf.setRows(2);
+ // // tf.setSizeFull();
+ // tf.setHeight("100%");
+ // tf.setWidth("70px");
+ // ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_RIGHT,
+ // AlignmentHandler.ALIGNMENT_TOP);
+ // ol.addComponent(tf);
+
+ tf = new TextArea("300px x 300px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ tf = new TextArea("300px x 300px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("300x300 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("300px");
+ tf.setWidth("300px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ return ol;
+ }
+
+ private Layout layout_fixed_filled(AbstractOrderedLayout ol) {
+ ol.setHeight("700px");
+ ol.setWidth("700px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Filled with fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight() + "px)");
+ TextArea tf;
+
+ tf = new TextArea("60%x100% Field");
+ tf.setCaption("This one has a caption");
+ tf.setValue("60% x 100% TextField");
+ tf.setWidth("100%");
+ tf.setHeight("100%");
+ tf.setRequired(true);
+ // tf.setComponentError(new UserError("It's broken!"));
+
+ // tf.setHeight("100%");
+ // tf.setWidth("100px");
+ tf.setRows(2);
+ ol.addComponent(tf);
+ ol.setExpandRatio(tf, 1f);
+ //
+
+ tf = new TextArea("60%x60% Field");
+ tf.setCaption(null);
+ tf.setValue("60% x 60% TextField");
+ tf.setWidth("100%");
+ tf.setHeight("60%");
+ tf.setRequired(true);
+ ol.addComponent(tf);
+ ol.setExpandRatio(tf, 1f);
+ ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
+ // tf.setComponentError(new UserError("It's broken!"));
+
+ // tf.setHeight("100%");
+ // tf.setWidth("100px");
+ tf.setRows(2);
+ //
+ // for (int i = 1; i < 5; i++) {
+ // int w = i * 100;
+ // tf = new TextField("Caption field " + i);
+ // tf.setRows(2);
+ // tf.setValue(w + "px high, " + w + "px wide TextField, valign: "
+ // + valignName[i % 3]);
+ // tf.setWidth(w + "px");
+ // tf.setHeight(w + "px");
+ // ol.addComponent(tf);
+ // ol.setComponentAlignment(tf,
+ // AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER, valign[i % 3]);
+ // }
+ //
+ // tf.setValue(tf.getValue().toString() + " (100% wide)");
+ // tf.setWidth("100%");
+
+ // tf = new TextField("100%x70px Field");
+ // tf.setCaption(null);
+ // tf.setRequired(true);
+ // // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ // tf.setComponentError(new UserError("abc"));
+ // tf.setValue("100% high 70px wide TextField");
+ // tf.setRows(2);
+ // // tf.setSizeFull();
+ // tf.setHeight("100%");
+ // tf.setWidth("70px");
+ // ol.setComponentAlignment(tf, AlignmentHandler.ALIGNMENT_RIGHT,
+ // AlignmentHandler.ALIGNMENT_TOP);
+ // ol.addComponent(tf);
+
+ tf = new TextArea("200px x 200px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("200x200 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("200px");
+ tf.setWidth("200px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_LEFT);
+
+ tf = new TextArea("200px x 200px Field");
+ // tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setValue("200x200 field");
+ tf.setRows(2);
+ // tf.setSizeFull();
+ tf.setHeight("200px");
+ tf.setWidth("200px");
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ return ol;
+ }
+
+ private Layout layout_overfilled(AbstractOrderedLayout ol) {
+ ol.setHeight("300px");
+ ol.setWidth("700px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("OverFilled with fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight() + "px)");
+ TextArea tf;
+
+ for (int i = 0; i < 5; i++) {
+ tf = new TextArea("200x200px Field");
+ tf.setCaption("This one has a caption");
+ tf.setValue("200x200 TextField");
+ tf.setWidth("200px");
+ tf.setHeight("200px");
+ tf.setRequired(true);
+ // tf.setComponentError(new UserError("It's broken!"));
+
+ // tf.setHeight("100%");
+ // tf.setWidth("100px");
+ tf.setRows(2);
+ ol.addComponent(tf);
+ }
+
+ return ol;
+ }
+
+ private Layout layout_overfilled_dynamic_height(AbstractOrderedLayout ol) {
+ ol.setHeight(null);
+ ol.setWidth("700px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("OverFilled with fixed width (" + ol.getWidth()
+ + "px) and dynamic height");
+ TextArea tf;
+
+ for (int i = 0; i < 10; i++) {
+ tf = new TextArea("200x200px Field");
+ tf.setCaption("This one has a caption");
+ tf.setWidth("200px");
+ tf.setHeight(((i + 1) * 50) + "px");
+ tf.setValue(tf.getWidth() + "x" + tf.getHeight() + " TextField");
+ tf.setRequired(true);
+ // tf.setComponentError(new UserError("It's broken!"));
+
+ // tf.setHeight("100%");
+ // tf.setWidth("100px");
+ tf.setRows(2);
+ ol.addComponent(tf);
+ }
+
+ return ol;
+ }
+
+ // private Layout layout_add_components(AbstractOrderedLayout ol) {
+ // ol.setHeight("600px");
+ // ol.setWidth("600px");
+ // ol.setMargin(true);
+ // ol.setSpacing(true);
+ //
+ // // ol.setWidth("");
+ // ol.setCaption("Fixed width (" + ol.getWidth()
+ // + "px) and fixed height (" + ol.getHeight() + "px)");
+ //
+ // for (int i = 0; i < 3; i++) {
+ // Button b = createAddButton(ol);
+ // ol.addComponent(b);
+ // }
+ //
+ // return ol;
+ //
+ // }
+
+ private Layout layout_add_remove_components(AbstractOrderedLayout ol) {
+ ol.setHeight("600px");
+ ol.setWidth("600px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight()
+ + "px) / layout_add_remove_components");
+
+ for (int i = 0; i < 2; i++) {
+ AbstractOrderedLayout inner = createAddRemove(ol, "", "");
+ ol.addComponent(inner);
+ ol.setComponentAlignment(inner, Alignment.BOTTOM_RIGHT);
+ }
+
+ return ol;
+
+ }
+
+ private Layout layout_dynamic(AbstractOrderedLayout ol) {
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Dynamic width, dynamic height");
+
+ for (int i = 0; i < 3; i++) {
+ Button b = new Button("Button " + i);
+ if (i == 2) {
+ b.setHeight("200px");
+ } else {
+ b.setHeight("100%");
+ }
+ ol.addComponent(b);
+ }
+
+ return ol;
+
+ }
+
+ private Layout layout_captions(AbstractOrderedLayout ol) {
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Caption test with dynamic width");
+
+ TextField tf;
+ tf = new TextField("Short caption");
+ ol.addComponent(tf);
+
+ tf = new TextField(
+ "A very long caption which is probably much longer than the field");
+ ol.addComponent(tf);
+
+ tf = new TextField(
+ "A very long caption which is probably much longer than the field and includes indicators");
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("abc123"));
+ ol.addComponent(tf);
+
+ // for (int i = 0; i < 3; i++) {
+ // Button b = new Button("Button " + i);
+ // if (i == 2) {
+ // b.setHeight("200px");
+ // } else {
+ // b.setHeight("100%");
+ // }
+ // ol.addComponent(b);
+ // }
+
+ return ol;
+
+ }
+
+ private Layout layout_captions_fixed_size(AbstractOrderedLayout ol) {
+ ol.setWidth("700px");
+ ol.setHeight("250px");
+
+ ol.setMargin(false);
+ ol.setSpacing(false);
+
+ // ol.setWidth("");
+ ol.setCaption("Caption test with fixed size");
+
+ TextField tf;
+ tf = new TextField("Short caption");
+ tf.setValue("Undefined width");
+ tf.setComponentError(new UserError("123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ tf = new TextField(
+ "A long caption which is probably much longer than the field");
+ tf.setValue("Undefined width");
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ tf = new TextField(
+ "A very long caption which is probably much longer than the field and includes indicators");
+ tf.setValue("Undefined width");
+ tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("abc123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ // for (int i = 0; i < 3; i++) {
+ // Button b = new Button("Button " + i);
+ // if (i == 2) {
+ // b.setHeight("200px");
+ // } else {
+ // b.setHeight("100%");
+ // }
+ // ol.addComponent(b);
+ // }
+
+ return ol;
+
+ }
+
+ private Layout layout_captions_fixed_size_and_relative_size(
+ AbstractOrderedLayout ol) {
+ ol.setWidth("700px");
+ ol.setHeight("250px");
+
+ ol.setMargin(false);
+ ol.setSpacing(false);
+
+ // ol.setWidth("");
+ ol.setCaption("Caption test with fixed width (700x250)");
+
+ TextField tf;
+ tf = new TextField("Short caption");
+ tf.setSizeFull();
+ tf.setValue("100% wide field, ratio 1");
+
+ tf.setComponentError(new UserError("123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ ol.setExpandRatio(tf, 1);
+
+ tf = new TextField(
+ "A long caption which is probably much longer than the field");
+ tf.setValue("100% wide field, ratio 2");
+ tf.setSizeFull();
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ ol.setExpandRatio(tf, 2);
+
+ tf = new TextField(
+ "A very long caption which is probably much longer than the field and includes indicators");
+ tf.setValue("100% wide field, ratio 3");
+ tf.setSizeFull();
+ tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("abc123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+ ol.setExpandRatio(tf, 3);
+
+ // for (int i = 0; i < 3; i++) {
+ // Button b = new Button("Button " + i);
+ // if (i == 2) {
+ // b.setHeight("200px");
+ // } else {
+ // b.setHeight("100%");
+ // }
+ // ol.addComponent(b);
+ // }
+
+ return ol;
+
+ }
+
+ private Layout layout_captions_fixed_size_and_fixed_size(
+ AbstractOrderedLayout ol) {
+ ol.setWidth("700px");
+ ol.setHeight("250px");
+
+ ol.setMargin(false);
+ ol.setSpacing(false);
+
+ // ol.setWidth("");
+ ol.setCaption("Caption test with fixed width");
+
+ TextField tf;
+ tf = new TextField("Short caption");
+ tf.setValue("250px wide field");
+ tf.setWidth("250px");
+ tf.setComponentError(new UserError("123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ tf = new TextField(
+ "A long caption which is probably much longer than the field");
+ tf.setWidth("250px");
+ tf.setValue("250px wide field");
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ tf = new TextField(
+ "A very long caption which is probably much longer than the field and includes indicators");
+ tf.setValue("200px wide field");
+ tf.setWidth("200px");
+ tf.setIcon(new ThemeResource("icons/16/document-add.png"));
+ tf.setRequired(true);
+ tf.setComponentError(new UserError("abc123"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
+
+ // for (int i = 0; i < 3; i++) {
+ // Button b = new Button("Button " + i);
+ // if (i == 2) {
+ // b.setHeight("200px");
+ // } else {
+ // b.setHeight("100%");
+ // }
+ // ol.addComponent(b);
+ // }
+
+ return ol;
+
+ }
+
+ private Layout layout_labels(AbstractOrderedLayout ol) {
+ // ol.setWidth("700px");
+ // ol.setHeight("200px");
+
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Caption test with fixed width");
+
+ Label l;
+ l = new Label(
+ "This is a long text and should remain on one line as there is nothing forcing line breaks");
+ ol.addComponent(l);
+ // ol.setComponentAlignment(l, AlignmentHandler.ALIGNMENT_RIGHT,
+ // AlignmentHandler.ALIGNMENT_BOTTOM);
+
+ l = new Label("WTF OMG LOL");
+ ol.addComponent(l);
+ // ol.setComponentAlignment(l, AlignmentHandler.ALIGNMENT_RIGHT,
+ // AlignmentHandler.ALIGNMENT_BOTTOM);
+
+ return ol;
+
+ }
+
+ private AbstractOrderedLayout createAddRemove(AbstractOrderedLayout ol,
+ String width, String buttonSuffix) {
+ Button b = createAddButton(ol);
+ Button wb = createWideAddButton(ol);
+ Button r = createRemoveButton(ol, buttonSuffix);
+ VerticalLayout inner = new VerticalLayout();
+ inner.setCaption("Width: " + width);
+ inner.setWidth(width);
+
+ inner.addComponent(b);
+ inner.addComponent(wb);
+ inner.addComponent(r);
+
+ // inner.setHeight("132px");
+ return inner;
+ }
+
+ private Button createAddButton(AbstractOrderedLayout ol) {
+ Button b = new Button("Add before", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ addBefore((AbstractOrderedLayout) event.getButton().getData(),
+ event.getButton().getParent(), "");
+ }
+
+ });
+ b.setData(ol);
+
+ return b;
+ }
+
+ private Button createWideAddButton(AbstractOrderedLayout ol) {
+ Button b = new Button("Add 100% before", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ addBefore((AbstractOrderedLayout) event.getButton().getData(),
+ event.getButton().getParent(), "100%");
+ }
+
+ });
+ b.setData(ol);
+
+ return b;
+ }
+
+ private Button createRemoveButton(AbstractOrderedLayout ol, String suffix) {
+ Button b = new Button("Remove this " + suffix, new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ remove((AbstractOrderedLayout) event.getButton().getData(),
+ event.getButton().getParent());
+ }
+
+ });
+ b.setWidth("100%");
+ b.setData(ol);
+
+ return b;
+ }
+
+ protected void remove(AbstractOrderedLayout ol, Component c) {
+ ol.removeComponent(c);
+
+ }
+
+ protected void addBefore(AbstractOrderedLayout ol, Component c, String width) {
+ int index = 0;
+ Iterator<Component> iter = ol.getComponentIterator();
+ while (iter.hasNext()) {
+ if (iter.next() == c) {
+ break;
+ }
+ index++;
+ }
+ AbstractOrderedLayout inner = createAddRemove(ol, width,
+ String.valueOf(suffix++));
+ ol.addComponent(inner, index);
+ if (width.contains("%")) {
+ ol.setExpandRatio(inner, 1.0f);
+ }
+
+ ol.setComponentAlignment(inner, Alignment.BOTTOM_RIGHT);
+
+ }
+
+ private Layout layout_pctFilled(AbstractOrderedLayout ol) {
+ ol.setHeight("600px");
+ ol.setWidth("600px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("100 % filled with fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight() + "px)");
+ TextArea ta;
+
+ ta = new TextArea();
+ ta.setCaption("This one has a caption");
+ ta.setValue("60% expand TextField");
+ ta.setWidth("100%");
+ ta.setHeight("100%");
+ // ta.setRequired(true);
+ // ta.setComponentError(new UserError("It's broken!"));
+
+ // ta.setHeight("100%");
+ // ta.setWidth("100px");
+ ta.setRows(2);
+ ol.addComponent(ta);
+ ol.setExpandRatio(ta, 60);
+
+ ta = new TextArea();
+ ta.setValue("100px 100px TextField");
+ ta.setWidth("100px");
+ ta.setHeight("100px");
+ ta.setRows(2);
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
+
+ //
+
+ ta = new TextArea("40%x40% Field");
+ // ta.setCaption(null);
+ ta.setValue("40% expand (40% height) TextField");
+ ta.setWidth("100%");
+ ta.setHeight("40%");
+ ol.addComponent(ta);
+ ol.setExpandRatio(ta, 40);
+ // ta.setRequired(true);
+ ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
+
+ ta.setRows(2);
+
+ return ol;
+ }
+
+ @SuppressWarnings("unused")
+ private Layout layout_pctFilled2(AbstractOrderedLayout ol) {
+ ol.setHeight("600px");
+ ol.setWidth("600px");
+ ol.setMargin(true);
+ ol.setSpacing(false);
+
+ // ol.setWidth("");
+ ol.setCaption("100 % filled with fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight() + "px)");
+ TextArea ta;
+
+ ta = new TextArea();
+ // ta.setCaption("This one has a caption");
+ ta.setValue("80% x 20% TextField");
+ ta.setWidth("80%");
+ ta.setHeight("20%");
+ // ta.setRequired(true);
+ // ta.setComponentError(new UserError("It's broken!"));
+
+ // ta.setHeight("100%");
+ // ta.setWidth("100px");
+ ta.setRows(2);
+ ol.addComponent(ta);
+ //
+
+ ta = new TextArea("20%x60% Field");
+ ta.setCaption(null);
+ ta.setValue("20% x 60% TextField");
+ ta.setWidth("20%");
+ ta.setHeight("60%");
+ // ta.setRequired(true);
+ ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
+
+ ta.setRows(2);
+ ol.addComponent(ta);
+
+ return ol;
+ }
+
+ private Layout layout_underFilled(AbstractOrderedLayout ol) {
+ ol.setHeight("700px");
+ ol.setWidth("700px");
+ ol.setMargin(true);
+ ol.setSpacing(true);
+
+ // ol.setWidth("");
+ ol.setCaption("Underfilled with fixed width (" + ol.getWidth()
+ + "px) and fixed height (" + ol.getHeight() + "px)");
+ TextArea ta;
+
+ ta = new TextArea("60%x100% Field");
+ ta.setCaption("Short capt");
+ ta.setValue("60% x 100% TextField");
+ ta.setWidth("60%");
+ ta.setHeight("100%");
+ ta.setRequired(true);
+ ta.setRows(2);
+
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.MIDDLE_CENTER);
+
+ ta = new TextArea("200px x 200px Field");
+ // ta.setIcon(new ThemeResource("icons/16/document-add.png"));
+ ta.setValue("200x200 field");
+ ta.setRows(2);
+ // ta.setSizeFull();
+ ta.setHeight("200px");
+ ta.setWidth("200px");
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.TOP_LEFT);
+
+ ta = new TextArea("200px x 200px Field");
+ // ta.setIcon(new ThemeResource("icons/16/document-add.png"));
+ ta.setValue("200x200 field");
+ ta.setRows(2);
+ // ta.setSizeFull();
+ ta.setHeight("200px");
+ ta.setWidth("200px");
+ ol.addComponent(ta);
+ ol.setComponentAlignment(ta, Alignment.BOTTOM_RIGHT);
+ return ol;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java b/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java
index baf8218922..9a98cd17bd 100644
--- a/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java
+++ b/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java
@@ -1,314 +1,314 @@
-package com.vaadin.tests.layouts;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbsoluteLayout;
-import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.Window;
-
-public class TestAbsoluteLayout extends TestBase {
-
- private static class MFieldFactory extends DefaultFieldFactory {
-
- @Override
- public Field createField(Item item, Object propertyId,
- Component uiContext) {
- if (propertyId.equals("CSSString")) {
- TextArea f = new TextArea();
- f.setRows(5);
- f.setHeight("8em");
- f.setCaption("CSS string");
- return f;
- } else if (((String) propertyId).contains("Units")) {
- NativeSelect s = new NativeSelect() {
- };
- s.addContainerProperty("caption", String.class, "");
- s.setItemCaptionPropertyId("caption");
- s.setNullSelectionAllowed(false);
- for (int i = 0; i < Layout.UNIT_SYMBOLS.length; i++) {
- Item unitItem = s.addItem(i);
- unitItem.getItemProperty("caption").setValue(
- Layout.UNIT_SYMBOLS[i]);
- }
- return s;
- }
-
- return super.createField(item, propertyId, uiContext);
- }
-
- private static MFieldFactory instance;
-
- public static DefaultFieldFactory get() {
- if (instance == null) {
- instance = new MFieldFactory();
- }
- return instance;
- }
- };
-
- @Override
- protected String getDescription() {
- return "This is absolute layout tester.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- @Override
- protected void setup() {
- AbsoluteLayout layout = new AbsoluteLayout();
- setTheme("tests-tickets");
- layout.setStyleName("cyan");
- layout.setWidth("1000px");
- layout.setHeight("500px");
-
- layout.addComponent(new Label("Hello World"));
-
- Button button = new Button("Centered button,z-index:10;");
- button.setSizeFull();
- layout.addComponent(button,
- "top:40%;bottom:40%;right:20%;left:20%;z-index:10;");
-
- Label label = new Label(
- "Exotic positioned label. Fullsize, top:100px; left:2cm; right: 3.5in; bottom:12.12mm ");
- label.setStyleName("yellow");
- label.setSizeFull();
- layout.addComponent(label,
- "top:100px; left:2cm; right: 3.5in; bottom:12.12mm");
-
- label = new Label("fullize, bottom:80%;left:80%;");
- label.setStyleName("green");
- label.setSizeFull();
- layout.addComponent(label, "bottom:80%;left:80%;");
-
- label = new Label("bottomright");
- label.setSizeUndefined();
- label.setStyleName("green");
- layout.addComponent(label, "bottom:0px; right:0px;");
-
- getLayout().setSizeFull();
- getLayout().addComponent(layout);
-
- getMainWindow().addWindow(new EditorWindow(layout));
-
- }
-
- public class EditorWindow extends Window {
- private final AbsoluteLayout l;
- private Form componentEditor;
- private Form positionEditor;
-
- public EditorWindow(AbsoluteLayout lo) {
- super("AbsoluteLayout editor aka köyhän miehen wysiwyg");
- l = lo;
-
- setHeight("600px");
-
- Button componentChooser = new Button("choose component to edit");
- componentChooser.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window chooser = new Window("Choose component");
- chooser.getContent().setSizeUndefined();
- chooser.setModal(true);
-
- NativeSelect select = new NativeSelect(
- "Choose component to edit");
-
- select.setNullSelectionAllowed(false);
-
- IndexedContainer container = new IndexedContainer();
- container.addContainerProperty("caption", String.class, "");
- Iterator<Component> componentIterator = l
- .getComponentIterator();
- while (componentIterator.hasNext()) {
- AbstractComponent next = (AbstractComponent) componentIterator
- .next();
- Item item = container.addItem(next);
-
- String caption = next.getClass().getSimpleName();
-
- caption += "; cap: " + next.getCaption() + "; debugid"
- + getDebugId();
-
- if (next instanceof Property) {
- caption += " value:" + ((Property) next).getValue();
- }
-
- item.getItemProperty("caption").setValue(caption);
- }
- select.setContainerDataSource(container);
- select.setItemCaptionPropertyId("caption");
- select.setImmediate(true);
-
- select.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- editcomponent((Component) event.getProperty()
- .getValue());
- getMainWindow().removeWindow(chooser);
- }
-
- });
-
- chooser.addComponent(select);
-
- getMainWindow().addWindow(chooser);
-
- }
- });
-
- addComponent(componentChooser);
-
- Button addComp = new Button("add component");
- addComp.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- final Window chooser = new Window(
- "Choose component type to add");
- chooser.getContent().setSizeUndefined();
- chooser.setModal(true);
-
- NativeSelect select = new NativeSelect(
- "Choose component to edit");
-
- select.setNullSelectionAllowed(false);
-
- IndexedContainer container = new IndexedContainer();
-
- URL resource = AbstractComponent.class.getResource(".");
- File directory = new File(resource.getFile());
- if (directory.exists()) {
- // Get the list of the files contained in the
- // package
- final String[] files = directory.list();
- for (int j = 0; j < files.length; j++) {
- // we are only interested in .class files
- if (files[j].endsWith(".class")) {
- // removes the .class extension
- String p = resource.toString()
- + files[j].substring(0,
- files[j].length() - 6);
- p = p.replaceAll(".*classes/", "");
- p = p.replaceAll("/", ".");
- Class<?> c;
- try {
- c = Class.forName(p);
- if (AbstractComponent.class
- .isAssignableFrom(c)
- && !p.toLowerCase().contains(
- "layout")
- && !p.toLowerCase().contains(
- "abstract")) {
- container.addItem(c);
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- select.setContainerDataSource(container);
- select.setImmediate(true);
-
- select.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- Class<?> c = (Class<?>) event.getProperty()
- .getValue();
-
- try {
- Component newInstance = (Component) c
- .newInstance();
- l.addComponent(newInstance);
- editcomponent(newInstance);
- getMainWindow().removeWindow(chooser);
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- });
-
- chooser.addComponent(select);
-
- getMainWindow().addWindow(chooser);
-
- }
- });
-
- addComponent(addComp);
-
- componentEditor = new Form();
- componentEditor.setWriteThrough(false);
- componentEditor.setCaption("Component properties:");
- componentEditor.setFormFieldFactory(MFieldFactory.get());
- addComponent(componentEditor);
-
- positionEditor = new Form();
- positionEditor.setCaption("Component position");
- positionEditor.setWriteThrough(false);
- positionEditor.setFormFieldFactory(MFieldFactory.get());
- addComponent(positionEditor);
-
- Button b = new Button("Commit changes", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- positionEditor.commit();
- componentEditor.commit();
- }
- });
- addComponent(b);
-
- }
-
- private void editcomponent(Component value) {
-
- BeanItem<Component> beanItem = new BeanItem<Component>(value);
- String c = "Component properties for "
- + value.getClass().getSimpleName();
- ArrayList<String> fields = new ArrayList<String>(
- Arrays.asList(new String[] { "width", "widthUnits",
- "height", "heightUnits", "caption", "styleName" }));
- if (value instanceof Label) {
- c += "(" + ((Label) value).getValue() + ")";
- fields.add("value");
- }
-
- componentEditor.setItemDataSource(beanItem, fields);
-
- BeanItem<ComponentPosition> positionItem = new BeanItem<ComponentPosition>(
- l.getPosition(value));
- componentEditor.setCaption(c);
-
- positionEditor.setItemDataSource(positionItem);
-
- }
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DefaultFieldFactory;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.Window;
+
+public class TestAbsoluteLayout extends TestBase {
+
+ private static class MFieldFactory extends DefaultFieldFactory {
+
+ @Override
+ public Field createField(Item item, Object propertyId,
+ Component uiContext) {
+ if (propertyId.equals("CSSString")) {
+ TextArea f = new TextArea();
+ f.setRows(5);
+ f.setHeight("8em");
+ f.setCaption("CSS string");
+ return f;
+ } else if (((String) propertyId).contains("Units")) {
+ NativeSelect s = new NativeSelect() {
+ };
+ s.addContainerProperty("caption", String.class, "");
+ s.setItemCaptionPropertyId("caption");
+ s.setNullSelectionAllowed(false);
+ for (int i = 0; i < Layout.UNIT_SYMBOLS.length; i++) {
+ Item unitItem = s.addItem(i);
+ unitItem.getItemProperty("caption").setValue(
+ Layout.UNIT_SYMBOLS[i]);
+ }
+ return s;
+ }
+
+ return super.createField(item, propertyId, uiContext);
+ }
+
+ private static MFieldFactory instance;
+
+ public static DefaultFieldFactory get() {
+ if (instance == null) {
+ instance = new MFieldFactory();
+ }
+ return instance;
+ }
+ };
+
+ @Override
+ protected String getDescription() {
+ return "This is absolute layout tester.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+ @Override
+ protected void setup() {
+ AbsoluteLayout layout = new AbsoluteLayout();
+ setTheme("tests-tickets");
+ layout.setStyleName("cyan");
+ layout.setWidth("1000px");
+ layout.setHeight("500px");
+
+ layout.addComponent(new Label("Hello World"));
+
+ Button button = new Button("Centered button,z-index:10;");
+ button.setSizeFull();
+ layout.addComponent(button,
+ "top:40%;bottom:40%;right:20%;left:20%;z-index:10;");
+
+ Label label = new Label(
+ "Exotic positioned label. Fullsize, top:100px; left:2cm; right: 3.5in; bottom:12.12mm ");
+ label.setStyleName("yellow");
+ label.setSizeFull();
+ layout.addComponent(label,
+ "top:100px; left:2cm; right: 3.5in; bottom:12.12mm");
+
+ label = new Label("fullize, bottom:80%;left:80%;");
+ label.setStyleName("green");
+ label.setSizeFull();
+ layout.addComponent(label, "bottom:80%;left:80%;");
+
+ label = new Label("bottomright");
+ label.setSizeUndefined();
+ label.setStyleName("green");
+ layout.addComponent(label, "bottom:0px; right:0px;");
+
+ getLayout().setSizeFull();
+ getLayout().addComponent(layout);
+
+ getMainWindow().addWindow(new EditorWindow(layout));
+
+ }
+
+ public class EditorWindow extends Window {
+ private final AbsoluteLayout l;
+ private Form componentEditor;
+ private Form positionEditor;
+
+ public EditorWindow(AbsoluteLayout lo) {
+ super("AbsoluteLayout editor aka köyhän miehen wysiwyg");
+ l = lo;
+
+ setHeight("600px");
+
+ Button componentChooser = new Button("choose component to edit");
+ componentChooser.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window chooser = new Window("Choose component");
+ chooser.getContent().setSizeUndefined();
+ chooser.setModal(true);
+
+ NativeSelect select = new NativeSelect(
+ "Choose component to edit");
+
+ select.setNullSelectionAllowed(false);
+
+ IndexedContainer container = new IndexedContainer();
+ container.addContainerProperty("caption", String.class, "");
+ Iterator<Component> componentIterator = l
+ .getComponentIterator();
+ while (componentIterator.hasNext()) {
+ AbstractComponent next = (AbstractComponent) componentIterator
+ .next();
+ Item item = container.addItem(next);
+
+ String caption = next.getClass().getSimpleName();
+
+ caption += "; cap: " + next.getCaption() + "; debugid"
+ + getDebugId();
+
+ if (next instanceof Property) {
+ caption += " value:" + ((Property) next).getValue();
+ }
+
+ item.getItemProperty("caption").setValue(caption);
+ }
+ select.setContainerDataSource(container);
+ select.setItemCaptionPropertyId("caption");
+ select.setImmediate(true);
+
+ select.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ editcomponent((Component) event.getProperty()
+ .getValue());
+ getMainWindow().removeWindow(chooser);
+ }
+
+ });
+
+ chooser.addComponent(select);
+
+ getMainWindow().addWindow(chooser);
+
+ }
+ });
+
+ addComponent(componentChooser);
+
+ Button addComp = new Button("add component");
+ addComp.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ final Window chooser = new Window(
+ "Choose component type to add");
+ chooser.getContent().setSizeUndefined();
+ chooser.setModal(true);
+
+ NativeSelect select = new NativeSelect(
+ "Choose component to edit");
+
+ select.setNullSelectionAllowed(false);
+
+ IndexedContainer container = new IndexedContainer();
+
+ URL resource = AbstractComponent.class.getResource(".");
+ File directory = new File(resource.getFile());
+ if (directory.exists()) {
+ // Get the list of the files contained in the
+ // package
+ final String[] files = directory.list();
+ for (int j = 0; j < files.length; j++) {
+ // we are only interested in .class files
+ if (files[j].endsWith(".class")) {
+ // removes the .class extension
+ String p = resource.toString()
+ + files[j].substring(0,
+ files[j].length() - 6);
+ p = p.replaceAll(".*classes/", "");
+ p = p.replaceAll("/", ".");
+ Class<?> c;
+ try {
+ c = Class.forName(p);
+ if (AbstractComponent.class
+ .isAssignableFrom(c)
+ && !p.toLowerCase().contains(
+ "layout")
+ && !p.toLowerCase().contains(
+ "abstract")) {
+ container.addItem(c);
+ }
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ select.setContainerDataSource(container);
+ select.setImmediate(true);
+
+ select.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ Class<?> c = (Class<?>) event.getProperty()
+ .getValue();
+
+ try {
+ Component newInstance = (Component) c
+ .newInstance();
+ l.addComponent(newInstance);
+ editcomponent(newInstance);
+ getMainWindow().removeWindow(chooser);
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ });
+
+ chooser.addComponent(select);
+
+ getMainWindow().addWindow(chooser);
+
+ }
+ });
+
+ addComponent(addComp);
+
+ componentEditor = new Form();
+ componentEditor.setWriteThrough(false);
+ componentEditor.setCaption("Component properties:");
+ componentEditor.setFormFieldFactory(MFieldFactory.get());
+ addComponent(componentEditor);
+
+ positionEditor = new Form();
+ positionEditor.setCaption("Component position");
+ positionEditor.setWriteThrough(false);
+ positionEditor.setFormFieldFactory(MFieldFactory.get());
+ addComponent(positionEditor);
+
+ Button b = new Button("Commit changes", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ positionEditor.commit();
+ componentEditor.commit();
+ }
+ });
+ addComponent(b);
+
+ }
+
+ private void editcomponent(Component value) {
+
+ BeanItem<Component> beanItem = new BeanItem<Component>(value);
+ String c = "Component properties for "
+ + value.getClass().getSimpleName();
+ ArrayList<String> fields = new ArrayList<String>(
+ Arrays.asList(new String[] { "width", "widthUnits",
+ "height", "heightUnits", "caption", "styleName" }));
+ if (value instanceof Label) {
+ c += "(" + ((Label) value).getValue() + ")";
+ fields.add("value");
+ }
+
+ componentEditor.setItemDataSource(beanItem, fields);
+
+ BeanItem<ComponentPosition> positionItem = new BeanItem<ComponentPosition>(
+ l.getPosition(value));
+ componentEditor.setCaption(c);
+
+ positionEditor.setItemDataSource(positionItem);
+
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/TestLayoutPerformance.java b/tests/testbench/com/vaadin/tests/layouts/TestLayoutPerformance.java
index 31ee15983e..c7cf89e8b6 100644
--- a/tests/testbench/com/vaadin/tests/layouts/TestLayoutPerformance.java
+++ b/tests/testbench/com/vaadin/tests/layouts/TestLayoutPerformance.java
@@ -1,133 +1,133 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class TestLayoutPerformance extends TestBase {
- private NativeSelect ns;
- private int i;
- private NativeSelect ns2;
- private VerticalLayout testarea = new VerticalLayout();
-
- @Override
- protected String getDescription() {
- return "Test app to test simple rendering to various layouts.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- @Override
- protected void setup() {
- Label label = new Label("<h1>CssLayout performance test.</h1>",
- Label.CONTENT_XHTML);
- getLayout().addComponent(label);
-
- label = new Label(
- "<em>Hint</em>. Use debug dialog to measure rendering times TODO: extend with size settings (to both layout and content).",
- Label.CONTENT_XHTML);
- getLayout().addComponent(label);
-
- ns = new NativeSelect("Select component to test");
- ns.addItem(CssLayout.class);
- ns.addItem(GridLayout.class);
- ns.addItem(VerticalLayout.class);
- ns.setNullSelectionAllowed(false);
- ns.setValue(CssLayout.class);
-
- ns2 = new NativeSelect("Select component to render inside layout.");
- ns2.addItem(Label.class);
- ns2.addItem(Button.class);
- ns2.setNullSelectionAllowed(false);
- ns2.setValue(Label.class);
-
- final TextField n = new TextField("Number of components");
-
- n.setValue("1000");
-
- final CheckBox cb = new CheckBox("Generate captions", false);
-
- Button b = new Button("Render component");
-
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- int components = Integer.parseInt((String) n.getValue());
- Layout layout = getCurrentLayout();
- for (int i = 0; i < components; i++) {
- Component component = newTestComponent();
- if (cb.booleanValue()) {
- component.setCaption("caption " + i);
- }
- layout.addComponent(component);
- }
-
- testarea.removeAllComponents();
- testarea.addComponent(layout);
- }
-
- });
-
- getLayout().addComponent(ns);
- getLayout().addComponent(ns2);
- getLayout().addComponent(n);
- getLayout().addComponent(cb);
- getLayout().addComponent(b);
- getLayout().addComponent(testarea);
-
- }
-
- private Layout getCurrentLayout() {
- Class<?> value = (Class<?>) ns.getValue();
- if (value == GridLayout.class) {
- return new GridLayout(10, 1);
- }
-
- try {
- return (Layout) value.newInstance();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
-
- }
-
- private Component newTestComponent() {
- Class<?> componentClass = (Class<?>) ns2.getValue();
- AbstractComponent newInstance = null;
- try {
- newInstance = (AbstractComponent) componentClass.newInstance();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (componentClass == Label.class) {
- ((Label) newInstance).setValue("Test l " + (i++));
- ((Label) newInstance).setSizeUndefined();
- } else {
- newInstance.setCaption("Test l " + (i++));
- }
- return newInstance;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class TestLayoutPerformance extends TestBase {
+ private NativeSelect ns;
+ private int i;
+ private NativeSelect ns2;
+ private VerticalLayout testarea = new VerticalLayout();
+
+ @Override
+ protected String getDescription() {
+ return "Test app to test simple rendering to various layouts.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+
+ @Override
+ protected void setup() {
+ Label label = new Label("<h1>CssLayout performance test.</h1>",
+ Label.CONTENT_XHTML);
+ getLayout().addComponent(label);
+
+ label = new Label(
+ "<em>Hint</em>. Use debug dialog to measure rendering times TODO: extend with size settings (to both layout and content).",
+ Label.CONTENT_XHTML);
+ getLayout().addComponent(label);
+
+ ns = new NativeSelect("Select component to test");
+ ns.addItem(CssLayout.class);
+ ns.addItem(GridLayout.class);
+ ns.addItem(VerticalLayout.class);
+ ns.setNullSelectionAllowed(false);
+ ns.setValue(CssLayout.class);
+
+ ns2 = new NativeSelect("Select component to render inside layout.");
+ ns2.addItem(Label.class);
+ ns2.addItem(Button.class);
+ ns2.setNullSelectionAllowed(false);
+ ns2.setValue(Label.class);
+
+ final TextField n = new TextField("Number of components");
+
+ n.setValue("1000");
+
+ final CheckBox cb = new CheckBox("Generate captions", false);
+
+ Button b = new Button("Render component");
+
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ int components = Integer.parseInt((String) n.getValue());
+ Layout layout = getCurrentLayout();
+ for (int i = 0; i < components; i++) {
+ Component component = newTestComponent();
+ if (cb.booleanValue()) {
+ component.setCaption("caption " + i);
+ }
+ layout.addComponent(component);
+ }
+
+ testarea.removeAllComponents();
+ testarea.addComponent(layout);
+ }
+
+ });
+
+ getLayout().addComponent(ns);
+ getLayout().addComponent(ns2);
+ getLayout().addComponent(n);
+ getLayout().addComponent(cb);
+ getLayout().addComponent(b);
+ getLayout().addComponent(testarea);
+
+ }
+
+ private Layout getCurrentLayout() {
+ Class<?> value = (Class<?>) ns.getValue();
+ if (value == GridLayout.class) {
+ return new GridLayout(10, 1);
+ }
+
+ try {
+ return (Layout) value.newInstance();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+ private Component newTestComponent() {
+ Class<?> componentClass = (Class<?>) ns2.getValue();
+ AbstractComponent newInstance = null;
+ try {
+ newInstance = (AbstractComponent) componentClass.newInstance();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (componentClass == Label.class) {
+ ((Label) newInstance).setValue("Test l " + (i++));
+ ((Label) newInstance).setSizeUndefined();
+ } else {
+ newInstance.setCaption("Test l " + (i++));
+ }
+ return newInstance;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java b/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java
index 27b1ce6462..bce30f8fea 100644
--- a/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java
+++ b/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class TreeWithBordersInLayout extends AbstractTestCase {
-
- private static final Object CAPTION = "caption";
-
- @Override
- public void init() {
- Layout mainLayout = new VerticalLayout();
- mainLayout.setSizeUndefined();
- setMainWindow(new Window("main window", mainLayout));
-
- setTheme("tests-tickets");
-
- Tree t = new Tree();
- t.addContainerProperty(CAPTION, String.class, "");
- t.setItemCaptionPropertyId(CAPTION);
- t.addItem("Item 1").getItemProperty(CAPTION).setValue("Item 1");
-
- t.setSizeUndefined();
- t.setStyleName("redblueborders");
- mainLayout.addComponent(t);
-
- }
-
- @Override
- protected String getDescription() {
- return "The tree consists of one node and has a 10px blue red border and a 10px red right border. The tree node should be visible between the borders.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3915;
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class TreeWithBordersInLayout extends AbstractTestCase {
+
+ private static final Object CAPTION = "caption";
+
+ @Override
+ public void init() {
+ Layout mainLayout = new VerticalLayout();
+ mainLayout.setSizeUndefined();
+ setMainWindow(new Window("main window", mainLayout));
+
+ setTheme("tests-tickets");
+
+ Tree t = new Tree();
+ t.addContainerProperty(CAPTION, String.class, "");
+ t.setItemCaptionPropertyId(CAPTION);
+ t.addItem("Item 1").getItemProperty(CAPTION).setValue("Item 1");
+
+ t.setSizeUndefined();
+ t.setStyleName("redblueborders");
+ mainLayout.addComponent(t);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The tree consists of one node and has a 10px blue red border and a 10px red right border. The tree node should be visible between the borders.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3915;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java
index bbac07d20f..e2c02a629b 100644
--- a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java
+++ b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java
@@ -1,77 +1,77 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class VerticalLayoutExpandRatioModification extends TestBase implements
- ClickListener {
-
- private boolean isVisible = false;
- private VerticalLayout mainLayout;
- private VerticalLayout vl1;
- private VerticalLayout vl2;
- private Button button;
-
- @Override
- public void setup() {
- Window main = new Window("The Main Window");
- mainLayout = new VerticalLayout();
- main.setContent(mainLayout);
- setMainWindow(main);
-
- // The upper layout
- vl1 = new VerticalLayout();
- Label label1 = new Label("The upper layout");
- vl1.addComponent(label1);
-
- // Button that hides or shows the bottom part
- button = new Button("show / hide", this);
-
- // The bottom layout
- vl2 = new VerticalLayout();
- TextField tf = new TextField("The bottom field");
- tf.setHeight("100%");
- vl2.addComponent(tf);
-
- // Add everything to the view
- mainLayout.addComponent(vl1);
- mainLayout.addComponent(button);
- mainLayout.addComponent(vl2);
-
- // Set expand ratios, hide lower
- mainLayout.setExpandRatio(vl1, 1);
- mainLayout.setExpandRatio(vl2, 0);
-
- // Maximize everything
- main.setSizeFull();
- mainLayout.setSizeFull();
- vl1.setSizeFull();
- vl2.setSizeFull();
- }
-
- public void buttonClick(ClickEvent event) {
- if (isVisible) {
- mainLayout.setExpandRatio(vl2, 0);
- isVisible = false;
- } else {
- mainLayout.setExpandRatio(vl2, 1);
- isVisible = true;
- }
- }
-
- @Override
- protected String getDescription() {
- return "Changing the expand ratio should repaint the layout correctly. Changing from 0 to something else should render the previously invisible component";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2454;
- }
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class VerticalLayoutExpandRatioModification extends TestBase implements
+ ClickListener {
+
+ private boolean isVisible = false;
+ private VerticalLayout mainLayout;
+ private VerticalLayout vl1;
+ private VerticalLayout vl2;
+ private Button button;
+
+ @Override
+ public void setup() {
+ Window main = new Window("The Main Window");
+ mainLayout = new VerticalLayout();
+ main.setContent(mainLayout);
+ setMainWindow(main);
+
+ // The upper layout
+ vl1 = new VerticalLayout();
+ Label label1 = new Label("The upper layout");
+ vl1.addComponent(label1);
+
+ // Button that hides or shows the bottom part
+ button = new Button("show / hide", this);
+
+ // The bottom layout
+ vl2 = new VerticalLayout();
+ TextField tf = new TextField("The bottom field");
+ tf.setHeight("100%");
+ vl2.addComponent(tf);
+
+ // Add everything to the view
+ mainLayout.addComponent(vl1);
+ mainLayout.addComponent(button);
+ mainLayout.addComponent(vl2);
+
+ // Set expand ratios, hide lower
+ mainLayout.setExpandRatio(vl1, 1);
+ mainLayout.setExpandRatio(vl2, 0);
+
+ // Maximize everything
+ main.setSizeFull();
+ mainLayout.setSizeFull();
+ vl1.setSizeFull();
+ vl2.setSizeFull();
+ }
+
+ public void buttonClick(ClickEvent event) {
+ if (isVisible) {
+ mainLayout.setExpandRatio(vl2, 0);
+ isVisible = false;
+ } else {
+ mainLayout.setExpandRatio(vl2, 1);
+ isVisible = true;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Changing the expand ratio should repaint the layout correctly. Changing from 0 to something else should render the previously invisible component";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2454;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java
index 361707a86c..906de9bb77 100644
--- a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java
+++ b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponents.java
@@ -1,38 +1,38 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Label;
-
-public class VerticalLayoutWithRelativeSizeComponents extends TestBase {
-
- @Override
- protected String getDescription() {
- return "A undefined wide VerticalLayout containing a 100% wide label, a Button and another identical label. The labels should be as wide as the button (400px) and there should be no extra space between the bottom of the first label and the button.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2591;
- }
-
- @Override
- protected void setup() {
- getLayout().setSizeUndefined();
- getMainWindow().getContent().setHeight(null);
-
- Label l = new Label(
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc condimentum urna quis leo. In hac habitasse platea dictumst. Pellentesque tincidunt. Sed libero nisl, faucibus in, laoreet pellentesque, consectetur non, dolor. Sed tortor. Ut pretium sapien. Cras elementum enim non lacus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla velit est, aliquam a, pellentesque a, iaculis nec, sapien. Ut ultrices ligula vitae nulla. Morbi sem pede, iaculis ac, condimentum a, ornare eget, nisi. Aliquam hendrerit pulvinar massa. Vestibulum pretium purus eu augue. Sed posuere elit ut magna. Cras consequat faucibus nunc. Vestibulum quis diam.");
- Label l2 = new Label(
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc condimentum urna quis leo. In hac habitasse platea dictumst. Pellentesque tincidunt. Sed libero nisl, faucibus in, laoreet pellentesque, consectetur non, dolor. Sed tortor. Ut pretium sapien. Cras elementum enim non lacus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla velit est, aliquam a, pellentesque a, iaculis nec, sapien. Ut ultrices ligula vitae nulla. Morbi sem pede, iaculis ac, condimentum a, ornare eget, nisi. Aliquam hendrerit pulvinar massa. Vestibulum pretium purus eu augue. Sed posuere elit ut magna. Cras consequat faucibus nunc. Vestibulum quis diam.");
- l.setWidth("100%");
- l2.setWidth("100%");
-
- Button b = new Button("This defines the width");
- b.setWidth("400px");
- addComponent(l);
- addComponent(b);
- addComponent(l2);
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+
+public class VerticalLayoutWithRelativeSizeComponents extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "A undefined wide VerticalLayout containing a 100% wide label, a Button and another identical label. The labels should be as wide as the button (400px) and there should be no extra space between the bottom of the first label and the button.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2591;
+ }
+
+ @Override
+ protected void setup() {
+ getLayout().setSizeUndefined();
+ getMainWindow().getContent().setHeight(null);
+
+ Label l = new Label(
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc condimentum urna quis leo. In hac habitasse platea dictumst. Pellentesque tincidunt. Sed libero nisl, faucibus in, laoreet pellentesque, consectetur non, dolor. Sed tortor. Ut pretium sapien. Cras elementum enim non lacus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla velit est, aliquam a, pellentesque a, iaculis nec, sapien. Ut ultrices ligula vitae nulla. Morbi sem pede, iaculis ac, condimentum a, ornare eget, nisi. Aliquam hendrerit pulvinar massa. Vestibulum pretium purus eu augue. Sed posuere elit ut magna. Cras consequat faucibus nunc. Vestibulum quis diam.");
+ Label l2 = new Label(
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc condimentum urna quis leo. In hac habitasse platea dictumst. Pellentesque tincidunt. Sed libero nisl, faucibus in, laoreet pellentesque, consectetur non, dolor. Sed tortor. Ut pretium sapien. Cras elementum enim non lacus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla velit est, aliquam a, pellentesque a, iaculis nec, sapien. Ut ultrices ligula vitae nulla. Morbi sem pede, iaculis ac, condimentum a, ornare eget, nisi. Aliquam hendrerit pulvinar massa. Vestibulum pretium purus eu augue. Sed posuere elit ut magna. Cras consequat faucibus nunc. Vestibulum quis diam.");
+ l.setWidth("100%");
+ l2.setWidth("100%");
+
+ Button b = new Button("This defines the width");
+ b.setWidth("400px");
+ addComponent(l);
+ addComponent(b);
+ addComponent(l2);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
index 360cc73f5e..98c5425bc6 100644
--- a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
+++ b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
@@ -1,58 +1,58 @@
-package com.vaadin.tests.layouts;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-public class VerticalLayoutWithRelativeSizeComponentsInitiallyHidden extends
- TestBase {
-
- @Override
- protected String getDescription() {
- return "Size calculations fail if expanded component is relative sized "
- + "and initially invisible and when becoming visible at the "
- + "same time some other component size changes.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4608;
- }
-
- @Override
- protected void setup() {
-
- VerticalLayout verticalLayout = getLayout();
- verticalLayout.setHeight("500px");
-
- final Label bar = new Label("Bar");
- bar.setSizeUndefined();
- final Label foobar = new Label("FooBar");
- foobar.setSizeFull();
- foobar.setVisible(false);
-
- bar.setHeight("100px");
-
- // bar.setHeight("100px");
- bar.setVisible(false);
-
- Button b = new Button(
- "Click to set bar visible. Button should stay visible.");
- b.addListener(new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- bar.setVisible(true);
- foobar.setVisible(true);
- }
- });
-
- verticalLayout.addComponent(bar);
- verticalLayout.addComponent(foobar);
- verticalLayout.setExpandRatio(foobar, 1);
- verticalLayout.addComponent(b);
- }
-
-}
+package com.vaadin.tests.layouts;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class VerticalLayoutWithRelativeSizeComponentsInitiallyHidden extends
+ TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Size calculations fail if expanded component is relative sized "
+ + "and initially invisible and when becoming visible at the "
+ + "same time some other component size changes.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4608;
+ }
+
+ @Override
+ protected void setup() {
+
+ VerticalLayout verticalLayout = getLayout();
+ verticalLayout.setHeight("500px");
+
+ final Label bar = new Label("Bar");
+ bar.setSizeUndefined();
+ final Label foobar = new Label("FooBar");
+ foobar.setSizeFull();
+ foobar.setVisible(false);
+
+ bar.setHeight("100px");
+
+ // bar.setHeight("100px");
+ bar.setVisible(false);
+
+ Button b = new Button(
+ "Click to set bar visible. Button should stay visible.");
+ b.addListener(new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ bar.setVisible(true);
+ foobar.setVisible(true);
+ }
+ });
+
+ verticalLayout.addComponent(bar);
+ verticalLayout.addComponent(foobar);
+ verticalLayout.setExpandRatio(foobar, 1);
+ verticalLayout.addComponent(b);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java b/tests/testbench/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java
index 9bfbebc439..c96d542a4c 100644
--- a/tests/testbench/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java
+++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.layouts.layouttester;
-
-import com.vaadin.ui.Layout;
-
-public abstract class AbstractLayoutTests {
-
- protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png";
- protected static final String CALENDAR_32_PNG = "../runo/icons/32/calendar.png";
- protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png";
- protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png";
-
- abstract protected Layout getCaptionsTests();
-
- abstract protected Layout getIconsTests();
-
- abstract protected Layout getRequiredErrorIndicatorsTests();
-
- abstract protected Layout getAlignmentTests();
-
- abstract protected Layout getExpandRatiosTests();
-
- abstract protected Layout getMarginSpacingTests();
-
- abstract protected Layout getComponentAddReplaceMoveTests();
-
- abstract protected Layout getComponentSizingTests();
-
- abstract protected Layout getLayoutSizingTests();
-
-}
+package com.vaadin.tests.layouts.layouttester;
+
+import com.vaadin.ui.Layout;
+
+public abstract class AbstractLayoutTests {
+
+ protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png";
+ protected static final String CALENDAR_32_PNG = "../runo/icons/32/calendar.png";
+ protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png";
+ protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png";
+
+ abstract protected Layout getCaptionsTests();
+
+ abstract protected Layout getIconsTests();
+
+ abstract protected Layout getRequiredErrorIndicatorsTests();
+
+ abstract protected Layout getAlignmentTests();
+
+ abstract protected Layout getExpandRatiosTests();
+
+ abstract protected Layout getMarginSpacingTests();
+
+ abstract protected Layout getComponentAddReplaceMoveTests();
+
+ abstract protected Layout getComponentSizingTests();
+
+ abstract protected Layout getLayoutSizingTests();
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java b/tests/testbench/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java
index 6b56d93a30..2b006fbfca 100644
--- a/tests/testbench/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java
+++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java
@@ -1,593 +1,593 @@
-package com.vaadin.tests.layouts.layouttester;
-
-import java.util.Date;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.SystemError;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.InlineDateField;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.themes.Reindeer;
-
-public class GridLayoutTests extends AbstractLayoutTests {
-
- private AbstractComponent rc1, col1, col2, col3, row1, row2, row3, x3, x22;
-
- public GridLayoutTests(Application application) {
- super();
- }
-
- @Override
- protected Layout getAlignmentTests() {
- HorizontalLayout hlo = new HorizontalLayout();
- hlo.setSpacing(true);
- GridLayout glo = getTestGrid();
- glo.addStyleName(Reindeer.LAYOUT_WHITE);
- Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT,
- Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT,
- Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
- Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT,
- Alignment.TOP_CENTER, Alignment.TOP_RIGHT };
-
- glo.replaceComponent(col1, col1 = new TextField());
- glo.replaceComponent(col2, col2 = new TextField());
- glo.replaceComponent(col3, col3 = new TextField());
- ((TextField) col1).setValue("BOTTOM_RIGHT");
- ((TextField) col2).setValue("BOTTOM_LEFT");
- ((TextField) col3).setValue("BOTTOM_CENTER");
- glo.setComponentAlignment(col2, alignments[0]);
- glo.setComponentAlignment(col3, alignments[1]);
- glo.setComponentAlignment(col1, alignments[2]);
-
- glo.setComponentAlignment(row1, alignments[3]);
- glo.setComponentAlignment(row2, alignments[4]);
- glo.setComponentAlignment(row3, alignments[5]);
- hlo.addComponent(glo);
- glo = getTestGrid();
- glo.replaceComponent(row1, row1 = new DateField());
- glo.replaceComponent(row2, row2 = new DateField());
- glo.replaceComponent(row3, row3 = new DateField());
- glo.setComponentAlignment(col2, alignments[6]);
- glo.setComponentAlignment(col3, alignments[7]);
- glo.setComponentAlignment(col1, alignments[8]);
- hlo.addComponent(glo);
- return hlo;
- }
-
- @Override
- protected Layout getCaptionsTests() {
- GridLayout glo = getTestGrid();
- glo.setWidth("600px");
- String[] captions = new String[] {
- "",
- "abcdefghijklmnopq",
- "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
- glo.replaceComponent(col1, col1 = new TextField());
- glo.replaceComponent(col2, col2 = new TextField());
- glo.replaceComponent(col3, col3 = new TextField());
-
- col1.setCaption(captions[0]);
- col2.setCaption(captions[1]);
- col3.setCaption(captions[2]);
- col3.setIcon(new ThemeResource(LOCK_16_PNG));
-
- glo.replaceComponent(row1, row1 = new Label());
- glo.replaceComponent(row2, row2 = new Label());
- glo.replaceComponent(row3, row3 = new Label());
-
- row1.setCaption(captions[0]);
- row2.setCaption(captions[1]);
- row3.setCaption(captions[2]);
-
- glo.replaceComponent(x3, x3 = getTestTabsheet());
- glo.replaceComponent(x22, x22 = getTestTable());
- x22.setComponentError(new UserError("component error, user error"));
-
- x3.setCaption(captions[1]);
- x22.setCaption(captions[2]);
-
- return glo;
- }
-
- @Override
- protected Layout getComponentAddReplaceMoveTests() {
- final GridLayout glo = getTestGrid();
- glo.setHeight("350px");
- Layout baseLayout = getBaseLayout();
- final Button button1 = new Button("Test add");
- final Button button2 = new Button("Test replace");
- final Button button3 = new Button("Test move");
- final Button button4 = new Button("Test remove comp 1,1");
- final Button button5 = new Button("Test remove row 0");
- final Button button6 = new Button("Test remove comp row3");
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- baseLayout.addComponent(button5);
- baseLayout.addComponent(button6);
- baseLayout.addComponent(glo);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
- button5.setEnabled(false);
- button6.setEnabled(false);
-
- final HorizontalLayout source = new HorizontalLayout();
- source.addComponent(new Label("MOVE LABEL 1"));
- source.addComponent(new Label("MOVE LABEL 2"));
-
- final AbstractComponent cc1 = getTestTabsheet();
- cc1.setCaption("ADDED COMPONENT");
-
- final AbstractComponent cc2 = getTestTabsheet();
- cc2.setCaption("REPLACEMENT COMPONENT");
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.addComponent(cc1);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.replaceComponent(x22, cc2);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.moveComponentsFrom(source);
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.removeComponent(1, 1);
- button4.setEnabled(false);
- button5.setEnabled(true);
- }
- });
-
- button5.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.removeRow(0);
- button5.setEnabled(false);
- button6.setEnabled(true);
- }
- });
- button6.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.removeComponent(row3);
- button6.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getComponentSizingTests() {
- final GridLayout glo = getTestGrid();
- glo.setHeight("350px");
- Layout baseLayout = getBaseLayout();
- final Button button1 = new Button("full size, 3x1");
- final Button button2 = new Button("200 px width, 3x1");
- final Button button3 = new Button("200 px width, table");
- final Button button4 = new Button("undefined size+add, table");
-
- glo.replaceComponent(x22, x22 = getTestTable());
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- baseLayout.addComponent(glo);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- x3.setSizeFull();
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- x3.setWidth("200px");
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- x22.setWidth("200px");
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- x22.setSizeUndefined();
- ((Table) x22).addItem(new Object[] { "NEW ROW1" }, 3);
- ((Table) x22).addItem(new Object[] { "NEW ROW2" }, 4);
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getExpandRatiosTests() {
- final GridLayout glo = getTestGrid();
- Layout baseLayout = getBaseLayout();
- final Button button1 = new Button("set col 3 expand 1");
- final Button button2 = new Button("set all cols expand 0.25");
- final Button button3 = new Button("set row 0 expand 0.5");
- final Button button4 = new Button("set row 3 expand 0.2");
- glo.setHeight("400px");
- glo.replaceComponent(x22, x22 = getTestTable());
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- baseLayout.addComponent(glo);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setColumnExpandRatio(3, 1);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setColumnExpandRatio(0, 0.25f);
- glo.setColumnExpandRatio(1, 0.25f);
- glo.setColumnExpandRatio(2, 0.25f);
- glo.setColumnExpandRatio(3, 0.25f);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setRowExpandRatio(0, 0.5f);
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setRowExpandRatio(3, 0.3f);
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getIconsTests() {
- GridLayout glo = getTestGrid();
- glo.setWidth("600px");
- Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
- new ThemeResource(LOCK_16_PNG) };
-
- glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD"));
- glo.replaceComponent(col2, col2 = new Label("LABEL"));
- glo.replaceComponent(col3, col3 = new Link("LINK", null));
-
- col1.setIcon(icons[0]);
- col2.setIcon(icons[1]);
- col3.setIcon(icons[0]);
- rc1.setIcon(icons[1]);
- col3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
- col3.setComponentError(new UserError("component error, user error"));
-
- glo.replaceComponent(row1, row1 = new DateField());
- glo.replaceComponent(row2, row2 = new NativeSelect());
- glo.replaceComponent(row3, row3 = getTestTabsheet());
-
- row1.setIcon(icons[1]);
- row2.setIcon(icons[0]);
- row3.setIcon(icons[1]);
-
- glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
- glo.replaceComponent(x22, x22 = new Panel("PANEL"));
- x22.setIcon(new ThemeResource(CALENDAR_32_PNG));
-
- x3.setIcon(icons[0]);
- x22.setIcon(icons[1]);
-
- return glo;
- }
-
- @Override
- protected Layout getLayoutSizingTests() {
- final GridLayout glo = getTestGrid();
- Layout baseLayout = getBaseLayout();
- baseLayout.setWidth("500px");
- baseLayout.setHeight("500px");
- final Button button1 = new Button("Set fixed height 350px");
- final Button button2 = new Button(
- "Set undefined size and add component");
- final Button button3 = new Button("Set fixed width and height 75%");
- final Button button4 = new Button("Set size full");
-
- glo.replaceComponent(x22, x22 = getTestTable());
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- baseLayout.addComponent(glo);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setHeight("350px");
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setSizeUndefined();
- glo.addComponent(new Label("--- NEW LABEL ---"));
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setWidth("75%");
- glo.setHeight("75%");
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setSizeFull();
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getMarginSpacingTests() {
- final GridLayout glo = getTestGrid();
- Layout baseLayout = getBaseLayout();
- baseLayout.setWidth("500px");
- baseLayout.setHeight("500px");
- final Button button1 = new Button("Set margin on");
- final Button button2 = new Button("Set spacing on");
- final Button button3 = new Button("Set margin off");
- final Button button4 = new Button("Set spacing off");
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- baseLayout.addComponent(glo);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setMargin(true);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setSpacing(true);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setMargin(false);
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- glo.setSpacing(false);
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getRequiredErrorIndicatorsTests() {
- GridLayout glo = getTestGrid();
- glo.setWidth("600px");
- Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
- new ThemeResource(LOCK_16_PNG) };
-
- glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD"));
- glo.replaceComponent(col2, col2 = new Label("LABEL"));
- glo.replaceComponent(col3, col3 = new Link("LINK", null));
-
- col1.setIcon(icons[0]);
- col1.setComponentError(new UserError("component error, user error"));
- col2.setComponentError(new SystemError("component error, system error"));
- col3.setComponentError(new UserError("component error, user error"));
-
- glo.replaceComponent(row1, row1 = new DateField());
- glo.replaceComponent(row2, row2 = new NativeSelect());
- glo.replaceComponent(row3, row3 = getTestTabsheet());
-
- ((AbstractField) col1).setRequired(true);
- ((AbstractField) col1).setValidationVisible(true);
- ((AbstractField) col1).setRequiredError("required error");
-
- ((AbstractField) row1).setRequired(true);
- ((AbstractField) row1).setValidationVisible(true);
- ((AbstractField) row1).setRequiredError("required error");
-
- ((AbstractField) row2).setRequired(true);
- ((AbstractField) row2).setValidationVisible(true);
- ((AbstractField) row2).setRequiredError("required error");
- row2.setComponentError(new UserError("component error, user error"));
-
- row3.setComponentError(new UserError("component error, user error"));
- row3.setIcon(icons[1]);
- row3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
-
- glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
- glo.replaceComponent(x22, x22 = new Panel("PANEL"));
-
- x3.setComponentError(new UserError("component error, user error"));
- x22.setComponentError(new UserError("component error, user error"));
- x22.setIcon(icons[0]);
-
- return glo;
- }
-
- private GridLayout getTestGrid() {
- // Create a 4 by 4 grid layout.
- GridLayout grid = new GridLayout(4, 4);
- // Fill out the first row using the cursor.
- grid.addComponent(rc1 = new Button("R/C 1"));
-
- grid.addComponent(col1 = new Button("Col " + (grid.getCursorX() + 1)));
- grid.addComponent(col2 = new Button("Col " + (grid.getCursorX() + 1)));
- grid.addComponent(col3 = new Button("Col " + (grid.getCursorX() + 1)));
-
- // Fill out the first column using coordinates.
-
- grid.addComponent(row1 = new Button("Row " + 1), 0, 1);
- grid.addComponent(row2 = new Button("Row " + 2), 0, 2);
- grid.addComponent(row3 = new Button("Row " + 3), 0, 3);
-
- // Add some components of various shapes.
- grid.addComponent(x3 = new Button("3x1 button"), 1, 1, 3, 1);
- grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3);
- x22 = new InlineDateField("A 2x2 date field");
- ((InlineDateField) x22).setResolution(DateField.RESOLUTION_DAY);
- ((InlineDateField) x22).setValue(new Date(128028960000l));
- grid.addComponent(x22, 2, 2, 3, 3);
- grid.setWidth("450px");
- grid.setHeight("450px");
- return grid;
- }
-
- private VerticalLayout getBaseLayout() {
- VerticalLayout vlo = new VerticalLayout();
- vlo.setSizeUndefined();
- return vlo;
- }
-
- private AbstractComponent getTestTabsheet() {
- TabSheet tabsheet = new TabSheet();
- tabsheet.setSizeUndefined();
- tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
- GLOBE_16_PNG));
- tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
- return tabsheet;
- }
-
- private Table getTestTable() {
- Table t = new Table();
- t.setSizeUndefined();
- t.setPageLength(5);
- t.addContainerProperty("test", String.class, null);
- t.addItem(new Object[] { "qwertyuiop asdfghjklzxccvbnm,m,." }, 1);
- t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
- return t;
- }
-
-}
+package com.vaadin.tests.layouts.layouttester;
+
+import java.util.Date;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.InlineDateField;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
+
+public class GridLayoutTests extends AbstractLayoutTests {
+
+ private AbstractComponent rc1, col1, col2, col3, row1, row2, row3, x3, x22;
+
+ public GridLayoutTests(Application application) {
+ super();
+ }
+
+ @Override
+ protected Layout getAlignmentTests() {
+ HorizontalLayout hlo = new HorizontalLayout();
+ hlo.setSpacing(true);
+ GridLayout glo = getTestGrid();
+ glo.addStyleName(Reindeer.LAYOUT_WHITE);
+ Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT,
+ Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT,
+ Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
+ Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT,
+ Alignment.TOP_CENTER, Alignment.TOP_RIGHT };
+
+ glo.replaceComponent(col1, col1 = new TextField());
+ glo.replaceComponent(col2, col2 = new TextField());
+ glo.replaceComponent(col3, col3 = new TextField());
+ ((TextField) col1).setValue("BOTTOM_RIGHT");
+ ((TextField) col2).setValue("BOTTOM_LEFT");
+ ((TextField) col3).setValue("BOTTOM_CENTER");
+ glo.setComponentAlignment(col2, alignments[0]);
+ glo.setComponentAlignment(col3, alignments[1]);
+ glo.setComponentAlignment(col1, alignments[2]);
+
+ glo.setComponentAlignment(row1, alignments[3]);
+ glo.setComponentAlignment(row2, alignments[4]);
+ glo.setComponentAlignment(row3, alignments[5]);
+ hlo.addComponent(glo);
+ glo = getTestGrid();
+ glo.replaceComponent(row1, row1 = new DateField());
+ glo.replaceComponent(row2, row2 = new DateField());
+ glo.replaceComponent(row3, row3 = new DateField());
+ glo.setComponentAlignment(col2, alignments[6]);
+ glo.setComponentAlignment(col3, alignments[7]);
+ glo.setComponentAlignment(col1, alignments[8]);
+ hlo.addComponent(glo);
+ return hlo;
+ }
+
+ @Override
+ protected Layout getCaptionsTests() {
+ GridLayout glo = getTestGrid();
+ glo.setWidth("600px");
+ String[] captions = new String[] {
+ "",
+ "abcdefghijklmnopq",
+ "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
+ glo.replaceComponent(col1, col1 = new TextField());
+ glo.replaceComponent(col2, col2 = new TextField());
+ glo.replaceComponent(col3, col3 = new TextField());
+
+ col1.setCaption(captions[0]);
+ col2.setCaption(captions[1]);
+ col3.setCaption(captions[2]);
+ col3.setIcon(new ThemeResource(LOCK_16_PNG));
+
+ glo.replaceComponent(row1, row1 = new Label());
+ glo.replaceComponent(row2, row2 = new Label());
+ glo.replaceComponent(row3, row3 = new Label());
+
+ row1.setCaption(captions[0]);
+ row2.setCaption(captions[1]);
+ row3.setCaption(captions[2]);
+
+ glo.replaceComponent(x3, x3 = getTestTabsheet());
+ glo.replaceComponent(x22, x22 = getTestTable());
+ x22.setComponentError(new UserError("component error, user error"));
+
+ x3.setCaption(captions[1]);
+ x22.setCaption(captions[2]);
+
+ return glo;
+ }
+
+ @Override
+ protected Layout getComponentAddReplaceMoveTests() {
+ final GridLayout glo = getTestGrid();
+ glo.setHeight("350px");
+ Layout baseLayout = getBaseLayout();
+ final Button button1 = new Button("Test add");
+ final Button button2 = new Button("Test replace");
+ final Button button3 = new Button("Test move");
+ final Button button4 = new Button("Test remove comp 1,1");
+ final Button button5 = new Button("Test remove row 0");
+ final Button button6 = new Button("Test remove comp row3");
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ baseLayout.addComponent(button5);
+ baseLayout.addComponent(button6);
+ baseLayout.addComponent(glo);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+ button5.setEnabled(false);
+ button6.setEnabled(false);
+
+ final HorizontalLayout source = new HorizontalLayout();
+ source.addComponent(new Label("MOVE LABEL 1"));
+ source.addComponent(new Label("MOVE LABEL 2"));
+
+ final AbstractComponent cc1 = getTestTabsheet();
+ cc1.setCaption("ADDED COMPONENT");
+
+ final AbstractComponent cc2 = getTestTabsheet();
+ cc2.setCaption("REPLACEMENT COMPONENT");
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.addComponent(cc1);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.replaceComponent(x22, cc2);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.moveComponentsFrom(source);
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.removeComponent(1, 1);
+ button4.setEnabled(false);
+ button5.setEnabled(true);
+ }
+ });
+
+ button5.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.removeRow(0);
+ button5.setEnabled(false);
+ button6.setEnabled(true);
+ }
+ });
+ button6.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.removeComponent(row3);
+ button6.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getComponentSizingTests() {
+ final GridLayout glo = getTestGrid();
+ glo.setHeight("350px");
+ Layout baseLayout = getBaseLayout();
+ final Button button1 = new Button("full size, 3x1");
+ final Button button2 = new Button("200 px width, 3x1");
+ final Button button3 = new Button("200 px width, table");
+ final Button button4 = new Button("undefined size+add, table");
+
+ glo.replaceComponent(x22, x22 = getTestTable());
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ baseLayout.addComponent(glo);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ x3.setSizeFull();
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ x3.setWidth("200px");
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ x22.setWidth("200px");
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ x22.setSizeUndefined();
+ ((Table) x22).addItem(new Object[] { "NEW ROW1" }, 3);
+ ((Table) x22).addItem(new Object[] { "NEW ROW2" }, 4);
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getExpandRatiosTests() {
+ final GridLayout glo = getTestGrid();
+ Layout baseLayout = getBaseLayout();
+ final Button button1 = new Button("set col 3 expand 1");
+ final Button button2 = new Button("set all cols expand 0.25");
+ final Button button3 = new Button("set row 0 expand 0.5");
+ final Button button4 = new Button("set row 3 expand 0.2");
+ glo.setHeight("400px");
+ glo.replaceComponent(x22, x22 = getTestTable());
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ baseLayout.addComponent(glo);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setColumnExpandRatio(3, 1);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setColumnExpandRatio(0, 0.25f);
+ glo.setColumnExpandRatio(1, 0.25f);
+ glo.setColumnExpandRatio(2, 0.25f);
+ glo.setColumnExpandRatio(3, 0.25f);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setRowExpandRatio(0, 0.5f);
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setRowExpandRatio(3, 0.3f);
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getIconsTests() {
+ GridLayout glo = getTestGrid();
+ glo.setWidth("600px");
+ Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
+ new ThemeResource(LOCK_16_PNG) };
+
+ glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD"));
+ glo.replaceComponent(col2, col2 = new Label("LABEL"));
+ glo.replaceComponent(col3, col3 = new Link("LINK", null));
+
+ col1.setIcon(icons[0]);
+ col2.setIcon(icons[1]);
+ col3.setIcon(icons[0]);
+ rc1.setIcon(icons[1]);
+ col3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
+ col3.setComponentError(new UserError("component error, user error"));
+
+ glo.replaceComponent(row1, row1 = new DateField());
+ glo.replaceComponent(row2, row2 = new NativeSelect());
+ glo.replaceComponent(row3, row3 = getTestTabsheet());
+
+ row1.setIcon(icons[1]);
+ row2.setIcon(icons[0]);
+ row3.setIcon(icons[1]);
+
+ glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
+ glo.replaceComponent(x22, x22 = new Panel("PANEL"));
+ x22.setIcon(new ThemeResource(CALENDAR_32_PNG));
+
+ x3.setIcon(icons[0]);
+ x22.setIcon(icons[1]);
+
+ return glo;
+ }
+
+ @Override
+ protected Layout getLayoutSizingTests() {
+ final GridLayout glo = getTestGrid();
+ Layout baseLayout = getBaseLayout();
+ baseLayout.setWidth("500px");
+ baseLayout.setHeight("500px");
+ final Button button1 = new Button("Set fixed height 350px");
+ final Button button2 = new Button(
+ "Set undefined size and add component");
+ final Button button3 = new Button("Set fixed width and height 75%");
+ final Button button4 = new Button("Set size full");
+
+ glo.replaceComponent(x22, x22 = getTestTable());
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ baseLayout.addComponent(glo);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setHeight("350px");
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setSizeUndefined();
+ glo.addComponent(new Label("--- NEW LABEL ---"));
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setWidth("75%");
+ glo.setHeight("75%");
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setSizeFull();
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getMarginSpacingTests() {
+ final GridLayout glo = getTestGrid();
+ Layout baseLayout = getBaseLayout();
+ baseLayout.setWidth("500px");
+ baseLayout.setHeight("500px");
+ final Button button1 = new Button("Set margin on");
+ final Button button2 = new Button("Set spacing on");
+ final Button button3 = new Button("Set margin off");
+ final Button button4 = new Button("Set spacing off");
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ baseLayout.addComponent(glo);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setMargin(true);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setSpacing(true);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setMargin(false);
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ glo.setSpacing(false);
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getRequiredErrorIndicatorsTests() {
+ GridLayout glo = getTestGrid();
+ glo.setWidth("600px");
+ Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
+ new ThemeResource(LOCK_16_PNG) };
+
+ glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD"));
+ glo.replaceComponent(col2, col2 = new Label("LABEL"));
+ glo.replaceComponent(col3, col3 = new Link("LINK", null));
+
+ col1.setIcon(icons[0]);
+ col1.setComponentError(new UserError("component error, user error"));
+ col2.setComponentError(new SystemError("component error, system error"));
+ col3.setComponentError(new UserError("component error, user error"));
+
+ glo.replaceComponent(row1, row1 = new DateField());
+ glo.replaceComponent(row2, row2 = new NativeSelect());
+ glo.replaceComponent(row3, row3 = getTestTabsheet());
+
+ ((AbstractField) col1).setRequired(true);
+ ((AbstractField) col1).setValidationVisible(true);
+ ((AbstractField) col1).setRequiredError("required error");
+
+ ((AbstractField) row1).setRequired(true);
+ ((AbstractField) row1).setValidationVisible(true);
+ ((AbstractField) row1).setRequiredError("required error");
+
+ ((AbstractField) row2).setRequired(true);
+ ((AbstractField) row2).setValidationVisible(true);
+ ((AbstractField) row2).setRequiredError("required error");
+ row2.setComponentError(new UserError("component error, user error"));
+
+ row3.setComponentError(new UserError("component error, user error"));
+ row3.setIcon(icons[1]);
+ row3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
+
+ glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX"));
+ glo.replaceComponent(x22, x22 = new Panel("PANEL"));
+
+ x3.setComponentError(new UserError("component error, user error"));
+ x22.setComponentError(new UserError("component error, user error"));
+ x22.setIcon(icons[0]);
+
+ return glo;
+ }
+
+ private GridLayout getTestGrid() {
+ // Create a 4 by 4 grid layout.
+ GridLayout grid = new GridLayout(4, 4);
+ // Fill out the first row using the cursor.
+ grid.addComponent(rc1 = new Button("R/C 1"));
+
+ grid.addComponent(col1 = new Button("Col " + (grid.getCursorX() + 1)));
+ grid.addComponent(col2 = new Button("Col " + (grid.getCursorX() + 1)));
+ grid.addComponent(col3 = new Button("Col " + (grid.getCursorX() + 1)));
+
+ // Fill out the first column using coordinates.
+
+ grid.addComponent(row1 = new Button("Row " + 1), 0, 1);
+ grid.addComponent(row2 = new Button("Row " + 2), 0, 2);
+ grid.addComponent(row3 = new Button("Row " + 3), 0, 3);
+
+ // Add some components of various shapes.
+ grid.addComponent(x3 = new Button("3x1 button"), 1, 1, 3, 1);
+ grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3);
+ x22 = new InlineDateField("A 2x2 date field");
+ ((InlineDateField) x22).setResolution(DateField.RESOLUTION_DAY);
+ ((InlineDateField) x22).setValue(new Date(128028960000l));
+ grid.addComponent(x22, 2, 2, 3, 3);
+ grid.setWidth("450px");
+ grid.setHeight("450px");
+ return grid;
+ }
+
+ private VerticalLayout getBaseLayout() {
+ VerticalLayout vlo = new VerticalLayout();
+ vlo.setSizeUndefined();
+ return vlo;
+ }
+
+ private AbstractComponent getTestTabsheet() {
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setSizeUndefined();
+ tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
+ GLOBE_16_PNG));
+ tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
+ return tabsheet;
+ }
+
+ private Table getTestTable() {
+ Table t = new Table();
+ t.setSizeUndefined();
+ t.setPageLength(5);
+ t.addContainerProperty("test", String.class, null);
+ t.addItem(new Object[] { "qwertyuiop asdfghjklzxccvbnm,m,." }, 1);
+ t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
+ return t;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/tests/testbench/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java
index ff6e76e480..caebbc8532 100644
--- a/tests/testbench/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java
+++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java
@@ -1,559 +1,559 @@
-package com.vaadin.tests.layouts.layouttester;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.SystemError;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.themes.Reindeer;
-
-public class HorizontalLayoutTests extends AbstractLayoutTests {
-
- public HorizontalLayoutTests(Application application) {
- super();
- }
-
- @Override
- protected Layout getAlignmentTests() {
- Layout baseLayout = getBaseLayout();
- HorizontalLayout vlo = getTestLaytout();
- AbstractComponent[] components = new AbstractComponent[9];
- String[] styles = { Reindeer.LAYOUT_BLUE, Reindeer.LAYOUT_WHITE };
- Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT,
- Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT,
- Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
- Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT,
- Alignment.TOP_CENTER, Alignment.TOP_RIGHT };
-
- vlo.addStyleName(Reindeer.LAYOUT_WHITE);
- baseLayout.addComponent(vlo);
- int index = 0;
- for (int i = 0; i < components.length; i++) {
- if (i > 0 && i % 3 == 0) {
- vlo = getTestLaytout();
- vlo.addStyleName(styles[index++]);
- baseLayout.addComponent(vlo);
- }
- components[i] = new TextField();
- ((TextField) components[i]).setValue("FIELD " + i);
- vlo.addComponent(components[i]);
- vlo.setComponentAlignment(components[i], alignments[i]);
- }
- return baseLayout;
- }
-
- @Override
- protected Layout getCaptionsTests() {
- Layout baseLayout = getBaseLayout();
- AbstractComponent component = null;
-
- String[] captions = new String[] {
- "",
- "abcdefghijklmnopq",
- "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
-
- HorizontalLayout vlo = getTestLaytout();
- for (int i = 0; i < captions.length; i++) {
- component = new TextField();
- ((TextField) component).setValue("FIELD " + i);
- component.setCaption(captions[i]);
- vlo.addComponent(component);
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = 0; i < captions.length; i++) {
- component = new Label();
- ((Label) component).setValue("Label " + i);
- component.setCaption(captions[i]);
- vlo.addComponent(component);
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = 0; i < captions.length; i++) {
- component = new Select();
- component.setCaption(captions[i]);
- component.setIcon(new ThemeResource(LOCK_16_PNG));
- vlo.addComponent(component);
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = 0; i < captions.length; i++) {
- component = getTestTabsheet();
- component.setCaption(captions[i]);
- component.setComponentError(new UserError(
- "component error, user error"));
- vlo.addComponent(component);
- }
- baseLayout.addComponent(vlo);
- return baseLayout;
- }
-
- @Override
- protected Layout getComponentAddReplaceMoveTests() {
- final HorizontalLayout vlo = getTestLaytout();
- Layout baseLayout = getBaseLayout();
- final HorizontalLayout source = new HorizontalLayout();
- source.addComponent(new Label("OTHER LABEL 1"));
- source.addComponent(new Label("OTHER LABEL 2"));
-
- final AbstractComponent c1 = new Button("BUTTON");
- final AbstractComponent c2 = new Label("<b>LABEL</b>",
- Label.CONTENT_XHTML);
- final AbstractComponent c3 = new Table("TABLE");
- c3.setHeight("100px");
- c3.setWidth("100%");
-
- final Button addButton = new Button("Test add");
- final Button replaceButton = new Button("Test replace");
- final Button moveButton = new Button("Test move");
- final Button removeButton = new Button("Test remove");
-
- replaceButton.setEnabled(false);
- moveButton.setEnabled(false);
- removeButton.setEnabled(false);
-
- addButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.addComponent(new TextField());
- addButton.setEnabled(false);
- replaceButton.setEnabled(true);
- }
- });
- replaceButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.replaceComponent(c1, c3);
- replaceButton.setEnabled(false);
- moveButton.setEnabled(true);
- }
- });
- moveButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.moveComponentsFrom(source);
- moveButton.setEnabled(false);
- removeButton.setEnabled(true);
- }
- });
- removeButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.removeComponent(c1);
- vlo.removeComponent(c2);
- removeButton.setEnabled(false);
- }
- });
-
- baseLayout.addComponent(addButton);
- baseLayout.addComponent(replaceButton);
- baseLayout.addComponent(moveButton);
- baseLayout.addComponent(removeButton);
-
- vlo.addComponent(c1);
- vlo.addComponent(c2);
- vlo.addComponent(c3);
- baseLayout.addComponent(vlo);
-
- return baseLayout;
- }
-
- @Override
- protected Layout getComponentSizingTests() {
- final HorizontalLayout vlo = getTestLaytout();
- Layout baseLayout = getBaseLayout();
-
- final AbstractComponent c = getTestTable();
-
- final Button biggerButton = new Button("full size");
- final Button smallerButton = new Button("200 px width");
- final Button originalButton = new Button("undefined size+add");
-
- baseLayout.addComponent(biggerButton);
- baseLayout.addComponent(smallerButton);
- baseLayout.addComponent(originalButton);
- vlo.addComponent(c);
- baseLayout.addComponent(vlo);
-
- biggerButton.setEnabled(true);
- smallerButton.setEnabled(false);
- originalButton.setEnabled(false);
-
- biggerButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- c.setSizeFull();
- biggerButton.setEnabled(false);
- smallerButton.setEnabled(true);
- }
- });
- smallerButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- c.setWidth("200px");
- smallerButton.setEnabled(false);
- originalButton.setEnabled(true);
- }
- });
- originalButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- originalButton.setEnabled(false);
- c.setSizeUndefined();
- ((Table) c)
- .addItem(
- new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" },
- 3);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getLayoutSizingTests() {
- final HorizontalLayout vlo = getTestLaytout();
- vlo.setSpacing(false);
- vlo.setMargin(false);
- Layout baseLayout = getBaseLayout();
- final AbstractComponent c1 = getTestTable();
- c1.setSizeFull();
- final AbstractComponent c2 = getTestTable();
- c2.setSizeFull();
-
- final Button button1 = new Button("Set fixed height 350px");
- final Button button2 = new Button(
- "Set undefined size and add component");
- final Button button3 = new Button("Set fixed width and height 75%");
- final Button button4 = new Button("Set size full");
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- vlo.addComponent(c1);
- vlo.addComponent(c2);
- vlo.setExpandRatio(c1, 0.5f);
- vlo.setExpandRatio(c2, 0.5f);
-
- baseLayout.addComponent(vlo);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setHeight("350px");
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setSizeUndefined();
- vlo.addComponent(new Label("--- NEW LABEL ---"));
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setWidth("75%");
- vlo.setHeight("75%");
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setSizeFull();
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getExpandRatiosTests() {
- final HorizontalLayout vlo = getTestLaytout();
- Layout baseLayout = getBaseLayout();
- final AbstractComponent c1 = getTestTable();
- c1.setSizeFull();
- final AbstractComponent c2 = getTestTable();
- c2.setSizeFull();
-
- final Button button1 = new Button("Expand to 1/undefined");
- final Button button2 = new Button("Expand to 0.5/0.5");
- final Button button3 = new Button("Expand to 0.75/0.25");
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
-
- vlo.addComponent(c1);
- vlo.addComponent(c2);
- baseLayout.addComponent(vlo);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setExpandRatio(c1, 1.0f);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setExpandRatio(c1, 0.5f);
- vlo.setExpandRatio(c2, 0.5f);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setExpandRatio(c1, 0.75f);
- vlo.setExpandRatio(c2, 0.25f);
- button3.setEnabled(false);
- }
- });
- return baseLayout;
- }
-
- @Override
- protected Layout getIconsTests() {
- HorizontalLayout vlo = getTestLaytout();
- AbstractComponent[] components = new AbstractComponent[2];
- Layout baseLayout = getBaseLayout();
- Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
- new ThemeResource(LOCK_16_PNG) };
-
- for (int i = 0; i < components.length; i++) {
- components[i] = new TextField();
- ((TextField) components[i]).setValue("FIELD " + i);
- components[i].setIcon(icons[i]);
- components[i]
- .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
- vlo.addComponent(components[i]);
- }
- for (int i = 0; i < components.length; i++) {
- components[i] = new Label();
- ((Label) components[i]).setValue("Label " + i);
- components[i].setIcon(icons[i]);
- vlo.addComponent(components[i]);
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = 0; i < components.length; i++) {
- components[i] = new Select();
- components[i].setIcon(icons[i]);
- vlo.addComponent(components[i]);
- }
- for (int i = 0; i < components.length; i++) {
- components[i] = new Button();
- components[i].setComponentError(new UserError(
- "component error, user error"));
- components[i].setIcon(icons[i]);
- vlo.addComponent(components[i]);
- }
- for (int i = 0; i < components.length; i++) {
- components[i] = new Link("Link", null);
- components[i].setIcon(icons[i]);
- vlo.addComponent(components[i]);
- }
- baseLayout.addComponent(vlo);
- return baseLayout;
- }
-
- @Override
- protected Layout getMarginSpacingTests() {
- final HorizontalLayout vlo = getTestLaytout();
- vlo.setSpacing(false);
- vlo.setMargin(false);
- Layout baseLayout = getBaseLayout();
- final AbstractComponent c1 = getTestTable();
- c1.setSizeFull();
- final AbstractComponent c2 = getTestTable();
- c2.setSizeFull();
-
- final Button button1 = new Button("Set margin on");
- final Button button2 = new Button("Set spacing on");
- final Button button3 = new Button("Set margin off");
- final Button button4 = new Button("Set spacing off");
-
- baseLayout.addComponent(button1);
- baseLayout.addComponent(button2);
- baseLayout.addComponent(button3);
- baseLayout.addComponent(button4);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- vlo.addComponent(c1);
- vlo.addComponent(c2);
- vlo.setExpandRatio(c1, 0.5f);
- vlo.setExpandRatio(c2, 0.5f);
- baseLayout.addComponent(vlo);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setMargin(true);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setSpacing(true);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setMargin(false);
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo.setSpacing(false);
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getRequiredErrorIndicatorsTests() {
- HorizontalLayout vlo = getTestLaytout();
- Layout baseLayout = getBaseLayout();
- AbstractComponent[] components = new AbstractComponent[4];
- components[0] = new Label("LABEL");
- components[0].setSizeUndefined();
- components[1] = new Button("BUTTON");
- components[2] = getTestTable();
- components[3] = getTestTabsheet();
- components[3].setIcon(new ThemeResource(LOCK_16_PNG));
-
- AbstractField[] fields = new AbstractField[5];
- fields[0] = new TextField();
- fields[0].setRequired(true);
- fields[0].setValidationVisible(true);
- fields[0].setRequiredError("required error");
-
- fields[1] = new TextField();
- fields[1].setValue("TEXTFIELD2");
- fields[1]
- .setComponentError(new UserError("component error, user error"));
-
- fields[2] = new Select();
- fields[2].setComponentError(new SystemError(
- "component error, system error"));
- fields[3] = new DateField();
- fields[3].setComponentError(new SystemError(
- "component error, system error"));
-
- fields[4] = new CheckBox();
- fields[4]
- .setComponentError(new UserError("component error, user error"));
-
- for (int i = 0; i < components.length; i++) {
- components[i].setComponentError(new UserError(
- "component error, user error"));
- vlo.addComponent(components[i]);
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = 0; i < fields.length; i++) {
- vlo.addComponent(fields[i]);
- }
- baseLayout.addComponent(vlo);
- return baseLayout;
- }
-
- private VerticalLayout getBaseLayout() {
- VerticalLayout vlo = new VerticalLayout();
- vlo.setSizeUndefined();
- return vlo;
- }
-
- private HorizontalLayout getTestLaytout() {
- HorizontalLayout vlo = new HorizontalLayout();
- vlo.setHeight("100px");
- vlo.setWidth("750px");
- return vlo;
- }
-
- private AbstractComponent getTestTabsheet() {
- TabSheet tabsheet = new TabSheet();
- tabsheet.setSizeUndefined();
- tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
- GLOBE_16_PNG));
- tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
- return tabsheet;
- }
-
- private Table getTestTable() {
- Table t = new Table();
- t.setSizeUndefined();
- t.setPageLength(5);
- t.addContainerProperty("test", String.class, null);
- t.addItem(new Object[] { "qwertyuiop asdfghjkl zxccvbnm,m,." }, 1);
- t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
- return t;
- }
-}
+package com.vaadin.tests.layouts.layouttester;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
+
+public class HorizontalLayoutTests extends AbstractLayoutTests {
+
+ public HorizontalLayoutTests(Application application) {
+ super();
+ }
+
+ @Override
+ protected Layout getAlignmentTests() {
+ Layout baseLayout = getBaseLayout();
+ HorizontalLayout vlo = getTestLaytout();
+ AbstractComponent[] components = new AbstractComponent[9];
+ String[] styles = { Reindeer.LAYOUT_BLUE, Reindeer.LAYOUT_WHITE };
+ Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT,
+ Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT,
+ Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER,
+ Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT,
+ Alignment.TOP_CENTER, Alignment.TOP_RIGHT };
+
+ vlo.addStyleName(Reindeer.LAYOUT_WHITE);
+ baseLayout.addComponent(vlo);
+ int index = 0;
+ for (int i = 0; i < components.length; i++) {
+ if (i > 0 && i % 3 == 0) {
+ vlo = getTestLaytout();
+ vlo.addStyleName(styles[index++]);
+ baseLayout.addComponent(vlo);
+ }
+ components[i] = new TextField();
+ ((TextField) components[i]).setValue("FIELD " + i);
+ vlo.addComponent(components[i]);
+ vlo.setComponentAlignment(components[i], alignments[i]);
+ }
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getCaptionsTests() {
+ Layout baseLayout = getBaseLayout();
+ AbstractComponent component = null;
+
+ String[] captions = new String[] {
+ "",
+ "abcdefghijklmnopq",
+ "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
+
+ HorizontalLayout vlo = getTestLaytout();
+ for (int i = 0; i < captions.length; i++) {
+ component = new TextField();
+ ((TextField) component).setValue("FIELD " + i);
+ component.setCaption(captions[i]);
+ vlo.addComponent(component);
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = 0; i < captions.length; i++) {
+ component = new Label();
+ ((Label) component).setValue("Label " + i);
+ component.setCaption(captions[i]);
+ vlo.addComponent(component);
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = 0; i < captions.length; i++) {
+ component = new Select();
+ component.setCaption(captions[i]);
+ component.setIcon(new ThemeResource(LOCK_16_PNG));
+ vlo.addComponent(component);
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = 0; i < captions.length; i++) {
+ component = getTestTabsheet();
+ component.setCaption(captions[i]);
+ component.setComponentError(new UserError(
+ "component error, user error"));
+ vlo.addComponent(component);
+ }
+ baseLayout.addComponent(vlo);
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getComponentAddReplaceMoveTests() {
+ final HorizontalLayout vlo = getTestLaytout();
+ Layout baseLayout = getBaseLayout();
+ final HorizontalLayout source = new HorizontalLayout();
+ source.addComponent(new Label("OTHER LABEL 1"));
+ source.addComponent(new Label("OTHER LABEL 2"));
+
+ final AbstractComponent c1 = new Button("BUTTON");
+ final AbstractComponent c2 = new Label("<b>LABEL</b>",
+ Label.CONTENT_XHTML);
+ final AbstractComponent c3 = new Table("TABLE");
+ c3.setHeight("100px");
+ c3.setWidth("100%");
+
+ final Button addButton = new Button("Test add");
+ final Button replaceButton = new Button("Test replace");
+ final Button moveButton = new Button("Test move");
+ final Button removeButton = new Button("Test remove");
+
+ replaceButton.setEnabled(false);
+ moveButton.setEnabled(false);
+ removeButton.setEnabled(false);
+
+ addButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.addComponent(new TextField());
+ addButton.setEnabled(false);
+ replaceButton.setEnabled(true);
+ }
+ });
+ replaceButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.replaceComponent(c1, c3);
+ replaceButton.setEnabled(false);
+ moveButton.setEnabled(true);
+ }
+ });
+ moveButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.moveComponentsFrom(source);
+ moveButton.setEnabled(false);
+ removeButton.setEnabled(true);
+ }
+ });
+ removeButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.removeComponent(c1);
+ vlo.removeComponent(c2);
+ removeButton.setEnabled(false);
+ }
+ });
+
+ baseLayout.addComponent(addButton);
+ baseLayout.addComponent(replaceButton);
+ baseLayout.addComponent(moveButton);
+ baseLayout.addComponent(removeButton);
+
+ vlo.addComponent(c1);
+ vlo.addComponent(c2);
+ vlo.addComponent(c3);
+ baseLayout.addComponent(vlo);
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getComponentSizingTests() {
+ final HorizontalLayout vlo = getTestLaytout();
+ Layout baseLayout = getBaseLayout();
+
+ final AbstractComponent c = getTestTable();
+
+ final Button biggerButton = new Button("full size");
+ final Button smallerButton = new Button("200 px width");
+ final Button originalButton = new Button("undefined size+add");
+
+ baseLayout.addComponent(biggerButton);
+ baseLayout.addComponent(smallerButton);
+ baseLayout.addComponent(originalButton);
+ vlo.addComponent(c);
+ baseLayout.addComponent(vlo);
+
+ biggerButton.setEnabled(true);
+ smallerButton.setEnabled(false);
+ originalButton.setEnabled(false);
+
+ biggerButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ c.setSizeFull();
+ biggerButton.setEnabled(false);
+ smallerButton.setEnabled(true);
+ }
+ });
+ smallerButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ c.setWidth("200px");
+ smallerButton.setEnabled(false);
+ originalButton.setEnabled(true);
+ }
+ });
+ originalButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ originalButton.setEnabled(false);
+ c.setSizeUndefined();
+ ((Table) c)
+ .addItem(
+ new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" },
+ 3);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getLayoutSizingTests() {
+ final HorizontalLayout vlo = getTestLaytout();
+ vlo.setSpacing(false);
+ vlo.setMargin(false);
+ Layout baseLayout = getBaseLayout();
+ final AbstractComponent c1 = getTestTable();
+ c1.setSizeFull();
+ final AbstractComponent c2 = getTestTable();
+ c2.setSizeFull();
+
+ final Button button1 = new Button("Set fixed height 350px");
+ final Button button2 = new Button(
+ "Set undefined size and add component");
+ final Button button3 = new Button("Set fixed width and height 75%");
+ final Button button4 = new Button("Set size full");
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ vlo.addComponent(c1);
+ vlo.addComponent(c2);
+ vlo.setExpandRatio(c1, 0.5f);
+ vlo.setExpandRatio(c2, 0.5f);
+
+ baseLayout.addComponent(vlo);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setHeight("350px");
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setSizeUndefined();
+ vlo.addComponent(new Label("--- NEW LABEL ---"));
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setWidth("75%");
+ vlo.setHeight("75%");
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setSizeFull();
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getExpandRatiosTests() {
+ final HorizontalLayout vlo = getTestLaytout();
+ Layout baseLayout = getBaseLayout();
+ final AbstractComponent c1 = getTestTable();
+ c1.setSizeFull();
+ final AbstractComponent c2 = getTestTable();
+ c2.setSizeFull();
+
+ final Button button1 = new Button("Expand to 1/undefined");
+ final Button button2 = new Button("Expand to 0.5/0.5");
+ final Button button3 = new Button("Expand to 0.75/0.25");
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+
+ vlo.addComponent(c1);
+ vlo.addComponent(c2);
+ baseLayout.addComponent(vlo);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setExpandRatio(c1, 1.0f);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setExpandRatio(c1, 0.5f);
+ vlo.setExpandRatio(c2, 0.5f);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setExpandRatio(c1, 0.75f);
+ vlo.setExpandRatio(c2, 0.25f);
+ button3.setEnabled(false);
+ }
+ });
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getIconsTests() {
+ HorizontalLayout vlo = getTestLaytout();
+ AbstractComponent[] components = new AbstractComponent[2];
+ Layout baseLayout = getBaseLayout();
+ Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
+ new ThemeResource(LOCK_16_PNG) };
+
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new TextField();
+ ((TextField) components[i]).setValue("FIELD " + i);
+ components[i].setIcon(icons[i]);
+ components[i]
+ .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
+ vlo.addComponent(components[i]);
+ }
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Label();
+ ((Label) components[i]).setValue("Label " + i);
+ components[i].setIcon(icons[i]);
+ vlo.addComponent(components[i]);
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Select();
+ components[i].setIcon(icons[i]);
+ vlo.addComponent(components[i]);
+ }
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Button();
+ components[i].setComponentError(new UserError(
+ "component error, user error"));
+ components[i].setIcon(icons[i]);
+ vlo.addComponent(components[i]);
+ }
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Link("Link", null);
+ components[i].setIcon(icons[i]);
+ vlo.addComponent(components[i]);
+ }
+ baseLayout.addComponent(vlo);
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getMarginSpacingTests() {
+ final HorizontalLayout vlo = getTestLaytout();
+ vlo.setSpacing(false);
+ vlo.setMargin(false);
+ Layout baseLayout = getBaseLayout();
+ final AbstractComponent c1 = getTestTable();
+ c1.setSizeFull();
+ final AbstractComponent c2 = getTestTable();
+ c2.setSizeFull();
+
+ final Button button1 = new Button("Set margin on");
+ final Button button2 = new Button("Set spacing on");
+ final Button button3 = new Button("Set margin off");
+ final Button button4 = new Button("Set spacing off");
+
+ baseLayout.addComponent(button1);
+ baseLayout.addComponent(button2);
+ baseLayout.addComponent(button3);
+ baseLayout.addComponent(button4);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ vlo.addComponent(c1);
+ vlo.addComponent(c2);
+ vlo.setExpandRatio(c1, 0.5f);
+ vlo.setExpandRatio(c2, 0.5f);
+ baseLayout.addComponent(vlo);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setMargin(true);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setSpacing(true);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setMargin(false);
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo.setSpacing(false);
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getRequiredErrorIndicatorsTests() {
+ HorizontalLayout vlo = getTestLaytout();
+ Layout baseLayout = getBaseLayout();
+ AbstractComponent[] components = new AbstractComponent[4];
+ components[0] = new Label("LABEL");
+ components[0].setSizeUndefined();
+ components[1] = new Button("BUTTON");
+ components[2] = getTestTable();
+ components[3] = getTestTabsheet();
+ components[3].setIcon(new ThemeResource(LOCK_16_PNG));
+
+ AbstractField[] fields = new AbstractField[5];
+ fields[0] = new TextField();
+ fields[0].setRequired(true);
+ fields[0].setValidationVisible(true);
+ fields[0].setRequiredError("required error");
+
+ fields[1] = new TextField();
+ fields[1].setValue("TEXTFIELD2");
+ fields[1]
+ .setComponentError(new UserError("component error, user error"));
+
+ fields[2] = new Select();
+ fields[2].setComponentError(new SystemError(
+ "component error, system error"));
+ fields[3] = new DateField();
+ fields[3].setComponentError(new SystemError(
+ "component error, system error"));
+
+ fields[4] = new CheckBox();
+ fields[4]
+ .setComponentError(new UserError("component error, user error"));
+
+ for (int i = 0; i < components.length; i++) {
+ components[i].setComponentError(new UserError(
+ "component error, user error"));
+ vlo.addComponent(components[i]);
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = 0; i < fields.length; i++) {
+ vlo.addComponent(fields[i]);
+ }
+ baseLayout.addComponent(vlo);
+ return baseLayout;
+ }
+
+ private VerticalLayout getBaseLayout() {
+ VerticalLayout vlo = new VerticalLayout();
+ vlo.setSizeUndefined();
+ return vlo;
+ }
+
+ private HorizontalLayout getTestLaytout() {
+ HorizontalLayout vlo = new HorizontalLayout();
+ vlo.setHeight("100px");
+ vlo.setWidth("750px");
+ return vlo;
+ }
+
+ private AbstractComponent getTestTabsheet() {
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setSizeUndefined();
+ tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
+ GLOBE_16_PNG));
+ tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
+ return tabsheet;
+ }
+
+ private Table getTestTable() {
+ Table t = new Table();
+ t.setSizeUndefined();
+ t.setPageLength(5);
+ t.addContainerProperty("test", String.class, null);
+ t.addItem(new Object[] { "qwertyuiop asdfghjkl zxccvbnm,m,." }, 1);
+ t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
+ return t;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/tests/testbench/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java
index 8019ae5aca..941dfcd877 100644
--- a/tests/testbench/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java
+++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java
@@ -1,589 +1,589 @@
-package com.vaadin.tests.layouts.layouttester;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.SystemError;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-
-public class VerticalLayoutTests extends AbstractLayoutTests {
-
- public VerticalLayoutTests(Application application) {
- super();
- }
-
- @Override
- protected Layout getAlignmentTests() {
- Layout baseLayout = getBaseLayout();
- ((HorizontalLayout) baseLayout).setSpacing(true);
- VerticalLayout vlo = getTestLaytout();
- AbstractComponent[] components = new AbstractComponent[9];
- Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_CENTER,
- Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT,
- Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT,
- Alignment.MIDDLE_RIGHT, Alignment.TOP_CENTER,
- Alignment.TOP_LEFT, Alignment.TOP_RIGHT };
-
- for (int i = 0; i < components.length / 2; i++) {
- components[i] = new TextField();
- ((TextField) components[i]).setValue("FIELD " + i);
- vlo.addComponent(components[i]);
- vlo.setComponentAlignment(components[i], alignments[i]);
- vlo.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = components.length / 2; i < components.length; i++) {
- components[i] = new TextField();
- ((TextField) components[i]).setValue("FIELD " + i);
- vlo.addComponent(components[i]);
- vlo.setComponentAlignment(components[i], alignments[i]);
- vlo.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
- }
- baseLayout.addComponent(vlo);
- return baseLayout;
- }
-
- @Override
- protected Layout getCaptionsTests() {
- Layout baseLayout = getBaseLayout();
- VerticalLayout vlo = getTestLaytout();
- AbstractComponent component = null;
-
- String[] captions = new String[] {
- "",
- "abcdefghijklmnopq",
- "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
-
- for (int i = 0; i < captions.length; i++) {
- component = new TextField();
- ((TextField) component).setValue("FIELD " + i);
- component.setCaption(captions[i]);
- vlo.addComponent(component);
- }
- for (int i = 0; i < captions.length; i++) {
- component = new Label();
- ((Label) component).setValue("Label " + i);
- component.setCaption(captions[i]);
- vlo.addComponent(component);
- }
- baseLayout.addComponent(vlo);
- vlo = getTestLaytout();
- for (int i = 0; i < captions.length; i++) {
- component = new Select();
- component.setCaption(captions[i]);
- component.setIcon(new ThemeResource(LOCK_16_PNG));
- vlo.addComponent(component);
- }
- for (int i = 0; i < captions.length; i++) {
- component = getTestTabsheet();
- component.setCaption(captions[i]);
- component.setComponentError(new UserError(
- "component error, user error"));
- vlo.addComponent(component);
- }
- baseLayout.addComponent(vlo);
- return baseLayout;
- }
-
- @Override
- protected Layout getComponentAddReplaceMoveTests() {
- Layout baseLayout = getBaseLayout();
- final VerticalLayout vlo = getTestLaytout();
- final VerticalLayout vlo2 = getTestLaytout();
-
- final HorizontalLayout source = new HorizontalLayout();
- source.addComponent(new Label("OTHER LABEL 1"));
- source.addComponent(new Label("OTHER LABEL 2"));
-
- final AbstractComponent c1 = new Button("BUTTON");
- final AbstractComponent c2 = new Label("<b>LABEL</b>",
- Label.CONTENT_XHTML);
- final AbstractComponent c3 = new Table("TABLE");
- c3.setHeight("100px");
- c3.setWidth("100%");
-
- final Button addButton = new Button("Test add");
- final Button replaceButton = new Button("Test replace");
- final Button moveButton = new Button("Test move");
- final Button removeButton = new Button("Test remove");
-
- replaceButton.setEnabled(false);
- moveButton.setEnabled(false);
- removeButton.setEnabled(false);
-
- addButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.addComponent(new TextField());
- addButton.setEnabled(false);
- replaceButton.setEnabled(true);
- }
- });
- replaceButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.replaceComponent(c1, c3);
- replaceButton.setEnabled(false);
- moveButton.setEnabled(true);
- }
- });
- moveButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.moveComponentsFrom(source);
- moveButton.setEnabled(false);
- removeButton.setEnabled(true);
- }
- });
- removeButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.removeComponent(c1);
- vlo2.removeComponent(c2);
- removeButton.setEnabled(false);
- }
- });
-
- vlo.addComponent(addButton);
- vlo.addComponent(replaceButton);
- vlo.addComponent(moveButton);
- vlo.addComponent(removeButton);
-
- baseLayout.addComponent(vlo);
- vlo2.addComponent(c1);
- vlo2.addComponent(c2);
- vlo2.addComponent(c3);
- baseLayout.addComponent(vlo2);
- return baseLayout;
- }
-
- @Override
- protected Layout getComponentSizingTests() {
- Layout baseLayout = getBaseLayout();
- final VerticalLayout vlo = getTestLaytout();
-
- final AbstractComponent c = getTestTable();
-
- final Button biggerButton = new Button("full size");
- final Button smallerButton = new Button("200 px width");
- final Button originalButton = new Button("undefined size and add");
-
- vlo.addComponent(biggerButton);
- vlo.addComponent(smallerButton);
- vlo.addComponent(originalButton);
- baseLayout.addComponent(vlo);
- final VerticalLayout vlo2 = getTestLaytout();
- vlo2.addComponent(c);
- baseLayout.addComponent(vlo2);
-
- biggerButton.setEnabled(true);
- smallerButton.setEnabled(false);
- originalButton.setEnabled(false);
-
- biggerButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- c.setSizeFull();
- biggerButton.setEnabled(false);
- smallerButton.setEnabled(true);
- }
- });
- smallerButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- c.setWidth("200px");
- smallerButton.setEnabled(false);
- originalButton.setEnabled(true);
- }
- });
- originalButton.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- originalButton.setEnabled(false);
- c.setSizeUndefined();
- ((Table) c)
- .addItem(
- new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" },
- 3);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getLayoutSizingTests() {
- Layout baseLayout = getBaseLayout();
- final VerticalLayout vlo = getTestLaytout();
-
- vlo.setSpacing(false);
- vlo.setMargin(false);
-
- final AbstractComponent c1 = getTestTable();
- c1.setSizeFull();
- final AbstractComponent c2 = getTestTable();
- c2.setSizeFull();
-
- final Button button1 = new Button("Set fixed height 350px");
- final Button button2 = new Button(
- "Set undefined size and add component");
- final Button button3 = new Button("Set fixed width and height 75%");
- final Button button4 = new Button("Set size full");
-
- vlo.addComponent(button1);
- vlo.addComponent(button2);
- vlo.addComponent(button3);
- vlo.addComponent(button4);
- baseLayout.addComponent(vlo);
- final VerticalLayout vlo2 = getTestLaytout();
-
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- vlo2.addComponent(c1);
- vlo2.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
- vlo2.addComponent(c2);
- vlo2.setExpandRatio(c1, 0.5f);
- vlo2.setExpandRatio(c2, 0.5f);
- baseLayout.addComponent(vlo2);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setHeight("350px");
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setSizeUndefined();
- vlo2.addComponent(new Label("--- NEW LABEL ---"));
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setWidth("75%");
- vlo2.setHeight("75%");
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setSizeFull();
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getExpandRatiosTests() {
- Layout baseLayout = getBaseLayout();
- final VerticalLayout vlo = getTestLaytout();
-
- final AbstractComponent c1 = getTestTable();
- c1.setSizeFull();
- final AbstractComponent c2 = getTestTable();
- c2.setSizeFull();
-
- final Button button1 = new Button("Expand to 1/undefined");
- final Button button2 = new Button("Expand to 0.5/0.5");
- final Button button3 = new Button("Expand to 0.75/0.25");
-
- vlo.addComponent(button1);
- vlo.addComponent(button2);
- vlo.addComponent(button3);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
-
- baseLayout.addComponent(vlo);
- final VerticalLayout vlo2 = getTestLaytout();
-
- vlo2.addComponent(c1);
- vlo2.addComponent(c2);
- baseLayout.addComponent(vlo2);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setExpandRatio(c1, 1.0f);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setExpandRatio(c1, 0.5f);
- vlo2.setExpandRatio(c2, 0.5f);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setExpandRatio(c1, 0.75f);
- vlo2.setExpandRatio(c2, 0.25f);
- button3.setEnabled(false);
- }
- });
- return baseLayout;
- }
-
- @Override
- protected Layout getIconsTests() {
- Layout baseLayout = getBaseLayout();
- VerticalLayout vlo = getTestLaytout();
- AbstractComponent[] components = new AbstractComponent[2];
-
- Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
- new ThemeResource(LOCK_16_PNG) };
-
- for (int i = 0; i < components.length; i++) {
- components[i] = new TextField();
- ((TextField) components[i]).setValue("FIELD " + i);
- components[i].setIcon(icons[i]);
- components[i]
- .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
- vlo.addComponent(components[i]);
- }
-
- for (int i = 0; i < components.length; i++) {
- components[i] = new Label();
- ((Label) components[i]).setValue("Label " + i);
- components[i].setIcon(icons[i]);
- vlo.addComponent(components[i]);
- }
-
- for (int i = 0; i < components.length; i++) {
- components[i] = new Select();
- components[i].setIcon(icons[i]);
- vlo.addComponent(components[i]);
- }
- baseLayout.addComponent(vlo);
- final VerticalLayout vlo2 = getTestLaytout();
- for (int i = 0; i < components.length; i++) {
- components[i] = new Button();
- components[i].setComponentError(new UserError(
- "component error, user error"));
- components[i].setIcon(icons[i]);
- vlo2.addComponent(components[i]);
- }
-
- for (int i = 0; i < components.length; i++) {
- components[i] = new Link("Link", null);
- components[i].setIcon(icons[i]);
- vlo2.addComponent(components[i]);
- }
- baseLayout.addComponent(vlo2);
- return baseLayout;
- }
-
- @Override
- protected Layout getMarginSpacingTests() {
- Layout baseLayout = getBaseLayout();
- final VerticalLayout vlo = getTestLaytout();
- vlo.setSpacing(false);
- vlo.setMargin(false);
-
- final AbstractComponent c1 = getTestTable();
- c1.setSizeFull();
- final AbstractComponent c2 = getTestTable();
- c2.setSizeFull();
-
- final Button button1 = new Button("Set margin on");
- final Button button2 = new Button("Set spacing on");
- final Button button3 = new Button("Set margin off");
- final Button button4 = new Button("Set spacing off");
-
- vlo.addComponent(button1);
- vlo.addComponent(button2);
- vlo.addComponent(button3);
- vlo.addComponent(button4);
- button1.setEnabled(true);
- button2.setEnabled(false);
- button3.setEnabled(false);
- button4.setEnabled(false);
-
- baseLayout.addComponent(vlo);
- final VerticalLayout vlo2 = getTestLaytout();
-
- vlo2.addComponent(c1);
- vlo2.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
- vlo2.addComponent(c2);
- vlo2.setExpandRatio(c1, 0.5f);
- vlo2.setExpandRatio(c2, 0.5f);
- baseLayout.addComponent(vlo2);
-
- button1.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setMargin(true);
- button1.setEnabled(false);
- button2.setEnabled(true);
- }
- });
- button2.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setSpacing(true);
- button2.setEnabled(false);
- button3.setEnabled(true);
- }
- });
- button3.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setMargin(false);
- button3.setEnabled(false);
- button4.setEnabled(true);
- }
- });
- button4.addListener(new Button.ClickListener() {
- private static final long serialVersionUID = 7716267156088629379L;
-
- public void buttonClick(ClickEvent event) {
- vlo2.setSpacing(false);
- button4.setEnabled(false);
- }
- });
-
- return baseLayout;
- }
-
- @Override
- protected Layout getRequiredErrorIndicatorsTests() {
- Layout baseLayout = getBaseLayout();
- VerticalLayout vlo = getTestLaytout();
- AbstractComponent[] components = new AbstractComponent[4];
- components[0] = new Label("LABEL");
- components[0].setSizeUndefined();
- components[1] = new Button("BUTTON");
- components[2] = getTestTable();
- components[3] = getTestTabsheet();
- components[3].setIcon(new ThemeResource(LOCK_16_PNG));
-
- AbstractField[] fields = new AbstractField[6];
- fields[0] = new TextField();
- fields[0].setRequired(true);
- fields[0].setValidationVisible(true);
- fields[0].setRequiredError("required error");
-
- fields[1] = new TextField();
- fields[1].setValue("TEXTFIELD2");
- fields[1]
- .setComponentError(new UserError("component error, user error"));
-
- fields[2] = new Select();
- fields[2].setComponentError(new SystemError(
- "component error, system error"));
- fields[3] = new DateField();
- fields[3].setComponentError(new SystemError(
- "component error, system error"));
-
- fields[4] = new CheckBox();
- fields[4]
- .setComponentError(new UserError("component error, user error"));
-
- fields[5] = new NativeSelect();
- fields[5].setRequired(true);
- fields[5].setValidationVisible(true);
- fields[5].setRequiredError("required error");
- fields[5]
- .setComponentError(new UserError("component error, user error"));
- fields[5].setIcon(new ThemeResource(CALENDAR_32_PNG));
-
- for (int i = 0; i < components.length; i++) {
- components[i].setComponentError(new UserError(
- "component error, user error"));
- vlo.addComponent(components[i]);
- }
- baseLayout.addComponent(vlo);
- final VerticalLayout vlo2 = getTestLaytout();
- for (int i = 0; i < fields.length; i++) {
- vlo2.addComponent(fields[i]);
- }
-
- baseLayout.addComponent(vlo2);
- return baseLayout;
- }
-
- private HorizontalLayout getBaseLayout() {
- HorizontalLayout hlo = new HorizontalLayout();
- hlo.setSizeUndefined();
- return hlo;
- }
-
- private VerticalLayout getTestLaytout() {
- VerticalLayout vlo = new VerticalLayout();
- vlo.setHeight("500px");
- vlo.setWidth("400px");
- return vlo;
- }
-
- private AbstractComponent getTestTabsheet() {
- TabSheet tabsheet = new TabSheet();
- tabsheet.setSizeUndefined();
- tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
- GLOBE_16_PNG));
- tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
- return tabsheet;
- }
-
- private Table getTestTable() {
- Table t = new Table();
- t.setSizeUndefined();
- t.setPageLength(5);
- t.addContainerProperty("test", String.class, null);
- t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1);
- t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
- return t;
- }
-}
+package com.vaadin.tests.layouts.layouttester;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class VerticalLayoutTests extends AbstractLayoutTests {
+
+ public VerticalLayoutTests(Application application) {
+ super();
+ }
+
+ @Override
+ protected Layout getAlignmentTests() {
+ Layout baseLayout = getBaseLayout();
+ ((HorizontalLayout) baseLayout).setSpacing(true);
+ VerticalLayout vlo = getTestLaytout();
+ AbstractComponent[] components = new AbstractComponent[9];
+ Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_CENTER,
+ Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT,
+ Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT,
+ Alignment.MIDDLE_RIGHT, Alignment.TOP_CENTER,
+ Alignment.TOP_LEFT, Alignment.TOP_RIGHT };
+
+ for (int i = 0; i < components.length / 2; i++) {
+ components[i] = new TextField();
+ ((TextField) components[i]).setValue("FIELD " + i);
+ vlo.addComponent(components[i]);
+ vlo.setComponentAlignment(components[i], alignments[i]);
+ vlo.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = components.length / 2; i < components.length; i++) {
+ components[i] = new TextField();
+ ((TextField) components[i]).setValue("FIELD " + i);
+ vlo.addComponent(components[i]);
+ vlo.setComponentAlignment(components[i], alignments[i]);
+ vlo.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
+ }
+ baseLayout.addComponent(vlo);
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getCaptionsTests() {
+ Layout baseLayout = getBaseLayout();
+ VerticalLayout vlo = getTestLaytout();
+ AbstractComponent component = null;
+
+ String[] captions = new String[] {
+ "",
+ "abcdefghijklmnopq",
+ "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" };
+
+ for (int i = 0; i < captions.length; i++) {
+ component = new TextField();
+ ((TextField) component).setValue("FIELD " + i);
+ component.setCaption(captions[i]);
+ vlo.addComponent(component);
+ }
+ for (int i = 0; i < captions.length; i++) {
+ component = new Label();
+ ((Label) component).setValue("Label " + i);
+ component.setCaption(captions[i]);
+ vlo.addComponent(component);
+ }
+ baseLayout.addComponent(vlo);
+ vlo = getTestLaytout();
+ for (int i = 0; i < captions.length; i++) {
+ component = new Select();
+ component.setCaption(captions[i]);
+ component.setIcon(new ThemeResource(LOCK_16_PNG));
+ vlo.addComponent(component);
+ }
+ for (int i = 0; i < captions.length; i++) {
+ component = getTestTabsheet();
+ component.setCaption(captions[i]);
+ component.setComponentError(new UserError(
+ "component error, user error"));
+ vlo.addComponent(component);
+ }
+ baseLayout.addComponent(vlo);
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getComponentAddReplaceMoveTests() {
+ Layout baseLayout = getBaseLayout();
+ final VerticalLayout vlo = getTestLaytout();
+ final VerticalLayout vlo2 = getTestLaytout();
+
+ final HorizontalLayout source = new HorizontalLayout();
+ source.addComponent(new Label("OTHER LABEL 1"));
+ source.addComponent(new Label("OTHER LABEL 2"));
+
+ final AbstractComponent c1 = new Button("BUTTON");
+ final AbstractComponent c2 = new Label("<b>LABEL</b>",
+ Label.CONTENT_XHTML);
+ final AbstractComponent c3 = new Table("TABLE");
+ c3.setHeight("100px");
+ c3.setWidth("100%");
+
+ final Button addButton = new Button("Test add");
+ final Button replaceButton = new Button("Test replace");
+ final Button moveButton = new Button("Test move");
+ final Button removeButton = new Button("Test remove");
+
+ replaceButton.setEnabled(false);
+ moveButton.setEnabled(false);
+ removeButton.setEnabled(false);
+
+ addButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.addComponent(new TextField());
+ addButton.setEnabled(false);
+ replaceButton.setEnabled(true);
+ }
+ });
+ replaceButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.replaceComponent(c1, c3);
+ replaceButton.setEnabled(false);
+ moveButton.setEnabled(true);
+ }
+ });
+ moveButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.moveComponentsFrom(source);
+ moveButton.setEnabled(false);
+ removeButton.setEnabled(true);
+ }
+ });
+ removeButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.removeComponent(c1);
+ vlo2.removeComponent(c2);
+ removeButton.setEnabled(false);
+ }
+ });
+
+ vlo.addComponent(addButton);
+ vlo.addComponent(replaceButton);
+ vlo.addComponent(moveButton);
+ vlo.addComponent(removeButton);
+
+ baseLayout.addComponent(vlo);
+ vlo2.addComponent(c1);
+ vlo2.addComponent(c2);
+ vlo2.addComponent(c3);
+ baseLayout.addComponent(vlo2);
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getComponentSizingTests() {
+ Layout baseLayout = getBaseLayout();
+ final VerticalLayout vlo = getTestLaytout();
+
+ final AbstractComponent c = getTestTable();
+
+ final Button biggerButton = new Button("full size");
+ final Button smallerButton = new Button("200 px width");
+ final Button originalButton = new Button("undefined size and add");
+
+ vlo.addComponent(biggerButton);
+ vlo.addComponent(smallerButton);
+ vlo.addComponent(originalButton);
+ baseLayout.addComponent(vlo);
+ final VerticalLayout vlo2 = getTestLaytout();
+ vlo2.addComponent(c);
+ baseLayout.addComponent(vlo2);
+
+ biggerButton.setEnabled(true);
+ smallerButton.setEnabled(false);
+ originalButton.setEnabled(false);
+
+ biggerButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ c.setSizeFull();
+ biggerButton.setEnabled(false);
+ smallerButton.setEnabled(true);
+ }
+ });
+ smallerButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ c.setWidth("200px");
+ smallerButton.setEnabled(false);
+ originalButton.setEnabled(true);
+ }
+ });
+ originalButton.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ originalButton.setEnabled(false);
+ c.setSizeUndefined();
+ ((Table) c)
+ .addItem(
+ new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" },
+ 3);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getLayoutSizingTests() {
+ Layout baseLayout = getBaseLayout();
+ final VerticalLayout vlo = getTestLaytout();
+
+ vlo.setSpacing(false);
+ vlo.setMargin(false);
+
+ final AbstractComponent c1 = getTestTable();
+ c1.setSizeFull();
+ final AbstractComponent c2 = getTestTable();
+ c2.setSizeFull();
+
+ final Button button1 = new Button("Set fixed height 350px");
+ final Button button2 = new Button(
+ "Set undefined size and add component");
+ final Button button3 = new Button("Set fixed width and height 75%");
+ final Button button4 = new Button("Set size full");
+
+ vlo.addComponent(button1);
+ vlo.addComponent(button2);
+ vlo.addComponent(button3);
+ vlo.addComponent(button4);
+ baseLayout.addComponent(vlo);
+ final VerticalLayout vlo2 = getTestLaytout();
+
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ vlo2.addComponent(c1);
+ vlo2.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
+ vlo2.addComponent(c2);
+ vlo2.setExpandRatio(c1, 0.5f);
+ vlo2.setExpandRatio(c2, 0.5f);
+ baseLayout.addComponent(vlo2);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setHeight("350px");
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setSizeUndefined();
+ vlo2.addComponent(new Label("--- NEW LABEL ---"));
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setWidth("75%");
+ vlo2.setHeight("75%");
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setSizeFull();
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getExpandRatiosTests() {
+ Layout baseLayout = getBaseLayout();
+ final VerticalLayout vlo = getTestLaytout();
+
+ final AbstractComponent c1 = getTestTable();
+ c1.setSizeFull();
+ final AbstractComponent c2 = getTestTable();
+ c2.setSizeFull();
+
+ final Button button1 = new Button("Expand to 1/undefined");
+ final Button button2 = new Button("Expand to 0.5/0.5");
+ final Button button3 = new Button("Expand to 0.75/0.25");
+
+ vlo.addComponent(button1);
+ vlo.addComponent(button2);
+ vlo.addComponent(button3);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+
+ baseLayout.addComponent(vlo);
+ final VerticalLayout vlo2 = getTestLaytout();
+
+ vlo2.addComponent(c1);
+ vlo2.addComponent(c2);
+ baseLayout.addComponent(vlo2);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setExpandRatio(c1, 1.0f);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setExpandRatio(c1, 0.5f);
+ vlo2.setExpandRatio(c2, 0.5f);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setExpandRatio(c1, 0.75f);
+ vlo2.setExpandRatio(c2, 0.25f);
+ button3.setEnabled(false);
+ }
+ });
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getIconsTests() {
+ Layout baseLayout = getBaseLayout();
+ VerticalLayout vlo = getTestLaytout();
+ AbstractComponent[] components = new AbstractComponent[2];
+
+ Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG),
+ new ThemeResource(LOCK_16_PNG) };
+
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new TextField();
+ ((TextField) components[i]).setValue("FIELD " + i);
+ components[i].setIcon(icons[i]);
+ components[i]
+ .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd");
+ vlo.addComponent(components[i]);
+ }
+
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Label();
+ ((Label) components[i]).setValue("Label " + i);
+ components[i].setIcon(icons[i]);
+ vlo.addComponent(components[i]);
+ }
+
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Select();
+ components[i].setIcon(icons[i]);
+ vlo.addComponent(components[i]);
+ }
+ baseLayout.addComponent(vlo);
+ final VerticalLayout vlo2 = getTestLaytout();
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Button();
+ components[i].setComponentError(new UserError(
+ "component error, user error"));
+ components[i].setIcon(icons[i]);
+ vlo2.addComponent(components[i]);
+ }
+
+ for (int i = 0; i < components.length; i++) {
+ components[i] = new Link("Link", null);
+ components[i].setIcon(icons[i]);
+ vlo2.addComponent(components[i]);
+ }
+ baseLayout.addComponent(vlo2);
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getMarginSpacingTests() {
+ Layout baseLayout = getBaseLayout();
+ final VerticalLayout vlo = getTestLaytout();
+ vlo.setSpacing(false);
+ vlo.setMargin(false);
+
+ final AbstractComponent c1 = getTestTable();
+ c1.setSizeFull();
+ final AbstractComponent c2 = getTestTable();
+ c2.setSizeFull();
+
+ final Button button1 = new Button("Set margin on");
+ final Button button2 = new Button("Set spacing on");
+ final Button button3 = new Button("Set margin off");
+ final Button button4 = new Button("Set spacing off");
+
+ vlo.addComponent(button1);
+ vlo.addComponent(button2);
+ vlo.addComponent(button3);
+ vlo.addComponent(button4);
+ button1.setEnabled(true);
+ button2.setEnabled(false);
+ button3.setEnabled(false);
+ button4.setEnabled(false);
+
+ baseLayout.addComponent(vlo);
+ final VerticalLayout vlo2 = getTestLaytout();
+
+ vlo2.addComponent(c1);
+ vlo2.addComponent(new Label("<hr />", Label.CONTENT_XHTML));
+ vlo2.addComponent(c2);
+ vlo2.setExpandRatio(c1, 0.5f);
+ vlo2.setExpandRatio(c2, 0.5f);
+ baseLayout.addComponent(vlo2);
+
+ button1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setMargin(true);
+ button1.setEnabled(false);
+ button2.setEnabled(true);
+ }
+ });
+ button2.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setSpacing(true);
+ button2.setEnabled(false);
+ button3.setEnabled(true);
+ }
+ });
+ button3.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setMargin(false);
+ button3.setEnabled(false);
+ button4.setEnabled(true);
+ }
+ });
+ button4.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 7716267156088629379L;
+
+ public void buttonClick(ClickEvent event) {
+ vlo2.setSpacing(false);
+ button4.setEnabled(false);
+ }
+ });
+
+ return baseLayout;
+ }
+
+ @Override
+ protected Layout getRequiredErrorIndicatorsTests() {
+ Layout baseLayout = getBaseLayout();
+ VerticalLayout vlo = getTestLaytout();
+ AbstractComponent[] components = new AbstractComponent[4];
+ components[0] = new Label("LABEL");
+ components[0].setSizeUndefined();
+ components[1] = new Button("BUTTON");
+ components[2] = getTestTable();
+ components[3] = getTestTabsheet();
+ components[3].setIcon(new ThemeResource(LOCK_16_PNG));
+
+ AbstractField[] fields = new AbstractField[6];
+ fields[0] = new TextField();
+ fields[0].setRequired(true);
+ fields[0].setValidationVisible(true);
+ fields[0].setRequiredError("required error");
+
+ fields[1] = new TextField();
+ fields[1].setValue("TEXTFIELD2");
+ fields[1]
+ .setComponentError(new UserError("component error, user error"));
+
+ fields[2] = new Select();
+ fields[2].setComponentError(new SystemError(
+ "component error, system error"));
+ fields[3] = new DateField();
+ fields[3].setComponentError(new SystemError(
+ "component error, system error"));
+
+ fields[4] = new CheckBox();
+ fields[4]
+ .setComponentError(new UserError("component error, user error"));
+
+ fields[5] = new NativeSelect();
+ fields[5].setRequired(true);
+ fields[5].setValidationVisible(true);
+ fields[5].setRequiredError("required error");
+ fields[5]
+ .setComponentError(new UserError("component error, user error"));
+ fields[5].setIcon(new ThemeResource(CALENDAR_32_PNG));
+
+ for (int i = 0; i < components.length; i++) {
+ components[i].setComponentError(new UserError(
+ "component error, user error"));
+ vlo.addComponent(components[i]);
+ }
+ baseLayout.addComponent(vlo);
+ final VerticalLayout vlo2 = getTestLaytout();
+ for (int i = 0; i < fields.length; i++) {
+ vlo2.addComponent(fields[i]);
+ }
+
+ baseLayout.addComponent(vlo2);
+ return baseLayout;
+ }
+
+ private HorizontalLayout getBaseLayout() {
+ HorizontalLayout hlo = new HorizontalLayout();
+ hlo.setSizeUndefined();
+ return hlo;
+ }
+
+ private VerticalLayout getTestLaytout() {
+ VerticalLayout vlo = new VerticalLayout();
+ vlo.setHeight("500px");
+ vlo.setWidth("400px");
+ return vlo;
+ }
+
+ private AbstractComponent getTestTabsheet() {
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setSizeUndefined();
+ tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource(
+ GLOBE_16_PNG));
+ tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null);
+ return tabsheet;
+ }
+
+ private Table getTestTable() {
+ Table t = new Table();
+ t.setSizeUndefined();
+ t.setPageLength(5);
+ t.addContainerProperty("test", String.class, null);
+ t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1);
+ t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
+ return t;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java b/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java
index 2299ba4d26..d3bbeef99a 100644
--- a/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java
+++ b/tests/testbench/com/vaadin/tests/resources/NonExistingFileResource.java
@@ -1,48 +1,48 @@
-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;
- }
-
-}
+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/testbench/com/vaadin/tests/resources/ResourceDownload.java b/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java
index d7da9c2d63..69fd0b2b81 100644
--- a/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java
+++ b/tests/testbench/com/vaadin/tests/resources/ResourceDownload.java
@@ -1,89 +1,89 @@
-package com.vaadin.tests.resources;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import com.vaadin.terminal.StreamResource;
-import com.vaadin.terminal.StreamResource.StreamSource;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-
-public class ResourceDownload extends TestBase {
-
- @Override
- public void setup() {
-
- Button b = new Button("Download (_new)", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- download("_new");
- }
- });
- addComponent(b);
-
- b = new Button("Download (_blank)", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- download("_blank");
- }
- });
- addComponent(b);
-
- b = new Button("Download ()", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- download("");
- }
- });
- addComponent(b);
-
- b = new Button("Download (_top)", new ClickListener() {
- public void buttonClick(ClickEvent event) {
- download("_top");
- }
- });
- addComponent(b);
-
- b = new Button("Test", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- ResourceDownload.this.getMainWindow().showNotification(
- "Still working");
- }
-
- });
- addComponent(b);
-
- }
-
- protected void download(String target) {
- String filename = "filename";
- StreamResource streamResource = new StreamResource(new StreamSource() {
-
- public InputStream getStream() {
- try {
- return new FileInputStream("FIXME C:/temp/file.xls");
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- }
- }, filename + ".xls", this);
- streamResource.setCacheTime(5000); // no cache (<=0) does not work with
- // IE8
- streamResource.setMIMEType("application/x-msexcel");
-
- getMainWindow().open(streamResource, target);
-
- }
-
- @Override
- protected String getDescription() {
- return "Downloading with target _new should work, aswell as with target _blank and _top.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3289;
- }
-}
+package com.vaadin.tests.resources;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import com.vaadin.terminal.StreamResource;
+import com.vaadin.terminal.StreamResource.StreamSource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class ResourceDownload extends TestBase {
+
+ @Override
+ public void setup() {
+
+ Button b = new Button("Download (_new)", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("_new");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Download (_blank)", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("_blank");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Download ()", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Download (_top)", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("_top");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Test", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ ResourceDownload.this.getMainWindow().showNotification(
+ "Still working");
+ }
+
+ });
+ addComponent(b);
+
+ }
+
+ protected void download(String target) {
+ String filename = "filename";
+ StreamResource streamResource = new StreamResource(new StreamSource() {
+
+ public InputStream getStream() {
+ try {
+ return new FileInputStream("FIXME C:/temp/file.xls");
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }, filename + ".xls", this);
+ streamResource.setCacheTime(5000); // no cache (<=0) does not work with
+ // IE8
+ streamResource.setMIMEType("application/x-msexcel");
+
+ getMainWindow().open(streamResource, target);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Downloading with target _new should work, aswell as with target _blank and _top.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3289;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket124.java b/tests/testbench/com/vaadin/tests/tickets/Ticket124.java
index 985d8bccac..efd28d7f41 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket124.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket124.java
@@ -1,90 +1,90 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket124 extends Application {
-
- private TextField tf;
- private GridLayout gl;
-
- @Override
- public void init() {
- Window w = new Window("#124: Insert & remove row for GridLayout");
- setMainWindow(w);
- setTheme("tests-tickets");
- // gl = new GridLayout(4, 4);
- gl = new GridLayout(2, 2);
-
- tf = new TextField("Row nr");
- Button insert = new Button("Insert row", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- insertRow();
-
- }
- });
- Button delete = new Button("Delete row", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- deleteRow();
-
- }
- });
-
- // gl.addComponent(new Label("0-0"), 0, 0);
- // gl.addComponent(new Label("0-1"), 1, 0);
- gl.addComponent(new Label("1-0"), 1, 0);
- gl.addComponent(new Label("1-1"), 1, 1);
- gl.addComponent(new Label("0,0-1,0"), 0, 0, 1, 0);
- gl.addComponent(new Label("2,0-3,0"), 2, 0, 3, 0);
- Label l = new Label("Large cell 0,1-2,2<br/>yadayada<br/>lorem ipsum");
- l.setContentMode(Label.CONTENT_XHTML);
- gl.addComponent(l, 0, 1, 2, 2);
- gl.addComponent(new Label("3-1"), 3, 1);
- gl.addComponent(new Label("3,2-3,3"), 3, 2, 3, 3);
- gl.addComponent(tf, 0, 3);
- gl.addComponent(insert, 1, 3);
- gl.addComponent(delete, 2, 3);
-
- gl.setStyleName("border");
- w.addComponent(gl);
- }
-
- protected void deleteRow() {
- int pos = Integer.parseInt(tf.getValue().toString());
- gl.removeRow(pos);
-
- }
-
- protected void clearRow() {
- int pos = Integer.parseInt(tf.getValue().toString());
- for (int col = 0; col < gl.getColumns(); col++) {
- try {
- gl.removeComponent(col, pos);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- }
-
- protected void insertRow() {
- int pos = Integer.parseInt(tf.getValue().toString());
- gl.insertRow(pos);
- try {
- TextField t = new TextField("", "Newly added row");
- t.setWidth("100%");
- gl.addComponent(t, 0, pos, 3, pos);
- } catch (Exception e) {
- // TODO: handle exception
- }
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket124 extends Application {
+
+ private TextField tf;
+ private GridLayout gl;
+
+ @Override
+ public void init() {
+ Window w = new Window("#124: Insert & remove row for GridLayout");
+ setMainWindow(w);
+ setTheme("tests-tickets");
+ // gl = new GridLayout(4, 4);
+ gl = new GridLayout(2, 2);
+
+ tf = new TextField("Row nr");
+ Button insert = new Button("Insert row", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ insertRow();
+
+ }
+ });
+ Button delete = new Button("Delete row", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ deleteRow();
+
+ }
+ });
+
+ // gl.addComponent(new Label("0-0"), 0, 0);
+ // gl.addComponent(new Label("0-1"), 1, 0);
+ gl.addComponent(new Label("1-0"), 1, 0);
+ gl.addComponent(new Label("1-1"), 1, 1);
+ gl.addComponent(new Label("0,0-1,0"), 0, 0, 1, 0);
+ gl.addComponent(new Label("2,0-3,0"), 2, 0, 3, 0);
+ Label l = new Label("Large cell 0,1-2,2<br/>yadayada<br/>lorem ipsum");
+ l.setContentMode(Label.CONTENT_XHTML);
+ gl.addComponent(l, 0, 1, 2, 2);
+ gl.addComponent(new Label("3-1"), 3, 1);
+ gl.addComponent(new Label("3,2-3,3"), 3, 2, 3, 3);
+ gl.addComponent(tf, 0, 3);
+ gl.addComponent(insert, 1, 3);
+ gl.addComponent(delete, 2, 3);
+
+ gl.setStyleName("border");
+ w.addComponent(gl);
+ }
+
+ protected void deleteRow() {
+ int pos = Integer.parseInt(tf.getValue().toString());
+ gl.removeRow(pos);
+
+ }
+
+ protected void clearRow() {
+ int pos = Integer.parseInt(tf.getValue().toString());
+ for (int col = 0; col < gl.getColumns(); col++) {
+ try {
+ gl.removeComponent(col, pos);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ protected void insertRow() {
+ int pos = Integer.parseInt(tf.getValue().toString());
+ gl.insertRow(pos);
+ try {
+ TextField t = new TextField("", "Newly added row");
+ t.setWidth("100%");
+ gl.addComponent(t, 0, pos, 3, pos);
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java
index e83ac6aded..2e8675de7b 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java
@@ -1,93 +1,93 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.themes.Reindeer;
-
-public class Ticket1245 extends com.vaadin.Application {
-
- TextField f = new TextField();
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- main.addComponent(new TreeExample());
- }
-}
-
-class TreeExample extends CustomComponent {
-
- // Id for the caption property
- private static final Object CAPTION_PROPERTY = "caption";
-
- private static final String desc = "non-first tree in non-sized orderedlayout seems to be the problem";
-
- Tree tree;
-
- public TreeExample() {
- final VerticalLayout main = new VerticalLayout();
- setCompositionRoot(main);
-
- // Panel w/ Tree
- main.setStyleName(Reindeer.PANEL_LIGHT);
- main.setWidth("200px");
- // // Description, this is needed. Works in first slot
- main.addComponent(new Label(desc));
-
- // setting either width or height fixes the issue
- // p.setWidth(500);
- // p.setHeight(800);
-
- // Tree with a few items
- tree = new 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);
- }
- main.addComponent(tree);
- }
-
- /**
- * 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;
- }
-
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.ui.AbstractSelect;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
+
+public class Ticket1245 extends com.vaadin.Application {
+
+ TextField f = new TextField();
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ main.addComponent(new TreeExample());
+ }
+}
+
+class TreeExample extends CustomComponent {
+
+ // Id for the caption property
+ private static final Object CAPTION_PROPERTY = "caption";
+
+ private static final String desc = "non-first tree in non-sized orderedlayout seems to be the problem";
+
+ Tree tree;
+
+ public TreeExample() {
+ final VerticalLayout main = new VerticalLayout();
+ setCompositionRoot(main);
+
+ // Panel w/ Tree
+ main.setStyleName(Reindeer.PANEL_LIGHT);
+ main.setWidth("200px");
+ // // Description, this is needed. Works in first slot
+ main.addComponent(new Label(desc));
+
+ // setting either width or height fixes the issue
+ // p.setWidth(500);
+ // p.setHeight(800);
+
+ // Tree with a few items
+ tree = new 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);
+ }
+ main.addComponent(tree);
+ }
+
+ /**
+ * 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;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java
index be549ebf8c..9916ca634d 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java
@@ -1,45 +1,45 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.event.ShortcutAction;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket1365 extends com.vaadin.Application implements Handler {
-
- TextField f = new TextField();
-
- Label status = new Label("ENTER and CTRL-S fires shortcut action.");
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- main.addComponent(f);
- main.addComponent(status);
- main.addActionHandler(this);
- f.focus();
-
- }
-
- final static private Action[] actions = new Action[] {
- new ShortcutAction("Enter", ShortcutAction.KeyCode.ENTER,
- new int[] {}),
- new ShortcutAction("CTRL-S", ShortcutAction.KeyCode.S,
- new int[] { ShortcutAction.ModifierKey.CTRL }), };
-
- public Action[] getActions(Object target, Object sender) {
- return actions;
- }
-
- public void handleAction(Action action, Object sender, Object target) {
- status.setValue("Pressed " + action.getCaption()
- + " to fire shortcut. Texfield value: " + f.getValue());
- f.focus();
- }
-
+package com.vaadin.tests.tickets;
+
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket1365 extends com.vaadin.Application implements Handler {
+
+ TextField f = new TextField();
+
+ Label status = new Label("ENTER and CTRL-S fires shortcut action.");
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ main.addComponent(f);
+ main.addComponent(status);
+ main.addActionHandler(this);
+ f.focus();
+
+ }
+
+ final static private Action[] actions = new Action[] {
+ new ShortcutAction("Enter", ShortcutAction.KeyCode.ENTER,
+ new int[] {}),
+ new ShortcutAction("CTRL-S", ShortcutAction.KeyCode.S,
+ new int[] { ShortcutAction.ModifierKey.CTRL }), };
+
+ public Action[] getActions(Object target, Object sender) {
+ return actions;
+ }
+
+ public void handleAction(Action action, Object sender, Object target) {
+ status.setValue("Pressed " + action.getCaption()
+ + " to fire shortcut. Texfield value: " + f.getValue());
+ f.focus();
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1506_Panel.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1506_Panel.java
index 37690612ed..0c06a24df5 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1506_Panel.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1506_Panel.java
@@ -1,48 +1,48 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Select;
-
-/**
- * @author Efecte R&D
- * @version $Revision$, $Date$
- */
-public class Ticket1506_Panel extends Panel {
-
- public Ticket1506_Panel() {
- ObjectProperty<String> property1 = new ObjectProperty<String>(null,
- String.class);
- addComponent(initSelect(new Ticket1506_TestContainer(), "Test select",
- property1));
- addComponent(initButton(property1));
- addComponent(initSelect(new Ticket1506_TestContainer2(),
- "Test select 2", new ObjectProperty<String>(null, String.class)));
- }
-
- private Component initButton(final ObjectProperty<?> property) {
- Button button = new Button("Clear select");
- button.addListener(new Button.ClickListener() {
- public void buttonClick(Button.ClickEvent event) {
- property.setValue(null);
- }
- });
- return button;
- }
-
- private Component initSelect(Container containerDataSource, String caption,
- ObjectProperty<?> property) {
- Select select = new Select(caption);
- select.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
- select.setImmediate(true);
- select.setNullSelectionAllowed(false);
- select.setItemCaptionPropertyId(Ticket1506_TestContainer.PROPERTY_2_ID);
-
- select.setContainerDataSource(containerDataSource);
- select.setPropertyDataSource(property);
- return select;
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Select;
+
+/**
+ * @author Efecte R&D
+ * @version $Revision$, $Date$
+ */
+public class Ticket1506_Panel extends Panel {
+
+ public Ticket1506_Panel() {
+ ObjectProperty<String> property1 = new ObjectProperty<String>(null,
+ String.class);
+ addComponent(initSelect(new Ticket1506_TestContainer(), "Test select",
+ property1));
+ addComponent(initButton(property1));
+ addComponent(initSelect(new Ticket1506_TestContainer2(),
+ "Test select 2", new ObjectProperty<String>(null, String.class)));
+ }
+
+ private Component initButton(final ObjectProperty<?> property) {
+ Button button = new Button("Clear select");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(Button.ClickEvent event) {
+ property.setValue(null);
+ }
+ });
+ return button;
+ }
+
+ private Component initSelect(Container containerDataSource, String caption,
+ ObjectProperty<?> property) {
+ Select select = new Select(caption);
+ select.setFilteringMode(Select.FILTERINGMODE_CONTAINS);
+ select.setImmediate(true);
+ select.setNullSelectionAllowed(false);
+ select.setItemCaptionPropertyId(Ticket1506_TestContainer.PROPERTY_2_ID);
+
+ select.setContainerDataSource(containerDataSource);
+ select.setPropertyDataSource(property);
+ return select;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer.java
index b8b6cfe5dd..a0f3070988 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer.java
@@ -1,126 +1,126 @@
-package com.vaadin.tests.tickets;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.data.util.PropertysetItem;
-
-/**
- * @author Efecte R&D
- * @version $Revision$, $Date$
- */
-public class Ticket1506_TestContainer implements Container {
- private Map<String, PropertysetItem> items = new HashMap<String, PropertysetItem>();
- public static final String ITEM_1_ID = "1";
- public static final String ITEM_2_ID = "2";
- public static final String PROPERTY_1_ID = "property 1";
- public static final String PROPERTY_2_ID = "property 2";
-
- private void loadItems() {
- final PropertysetItem item1 = new PropertysetItem();
- item1.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
- "value 1", String.class));
- item1.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
- "name 1", String.class));
- items.put(ITEM_1_ID, item1);
-
- final PropertysetItem item2 = new PropertysetItem();
- item2.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
- "value 2", String.class));
- item2.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
- "name 2", String.class));
- items.put(ITEM_2_ID, item2);
- }
-
- public Item getItem(Object itemId) {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.get(itemId);
- }
-
- public Collection<String> getContainerPropertyIds() {
- if (items.isEmpty()) {
- loadItems();
- }
- ArrayList<String> a = new ArrayList<String>();
- a.add(PROPERTY_1_ID);
- a.add(PROPERTY_2_ID);
- return a;
- }
-
- public Collection<String> getItemIds() {
- if (items.isEmpty()) {
- loadItems();
- }
- ArrayList<String> a = new ArrayList<String>();
- a.add(ITEM_1_ID);
- a.add(ITEM_2_ID);
- return a;
- }
-
- public Property getContainerProperty(Object itemId, Object propertyId) {
- if (items.isEmpty()) {
- loadItems();
- }
- Item item = items.get(itemId);
- if (item != null) {
- return item.getItemProperty(propertyId);
- }
- return null;
- }
-
- public Class<String> getType(Object propertyId) {
- if (items.isEmpty()) {
- loadItems();
- }
- return String.class;
- }
-
- public int size() {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.size();
- }
-
- public boolean containsId(Object itemId) {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.containsKey(itemId);
- }
-
- public Item addItem(Object itemId) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public Object addItem() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean removeAllItems() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-}
+package com.vaadin.tests.tickets;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.data.util.PropertysetItem;
+
+/**
+ * @author Efecte R&D
+ * @version $Revision$, $Date$
+ */
+public class Ticket1506_TestContainer implements Container {
+ private Map<String, PropertysetItem> items = new HashMap<String, PropertysetItem>();
+ public static final String ITEM_1_ID = "1";
+ public static final String ITEM_2_ID = "2";
+ public static final String PROPERTY_1_ID = "property 1";
+ public static final String PROPERTY_2_ID = "property 2";
+
+ private void loadItems() {
+ final PropertysetItem item1 = new PropertysetItem();
+ item1.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
+ "value 1", String.class));
+ item1.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
+ "name 1", String.class));
+ items.put(ITEM_1_ID, item1);
+
+ final PropertysetItem item2 = new PropertysetItem();
+ item2.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
+ "value 2", String.class));
+ item2.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
+ "name 2", String.class));
+ items.put(ITEM_2_ID, item2);
+ }
+
+ public Item getItem(Object itemId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.get(itemId);
+ }
+
+ public Collection<String> getContainerPropertyIds() {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ ArrayList<String> a = new ArrayList<String>();
+ a.add(PROPERTY_1_ID);
+ a.add(PROPERTY_2_ID);
+ return a;
+ }
+
+ public Collection<String> getItemIds() {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ ArrayList<String> a = new ArrayList<String>();
+ a.add(ITEM_1_ID);
+ a.add(ITEM_2_ID);
+ return a;
+ }
+
+ public Property getContainerProperty(Object itemId, Object propertyId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ Item item = items.get(itemId);
+ if (item != null) {
+ return item.getItemProperty(propertyId);
+ }
+ return null;
+ }
+
+ public Class<String> getType(Object propertyId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return String.class;
+ }
+
+ public int size() {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.size();
+ }
+
+ public boolean containsId(Object itemId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.containsKey(itemId);
+ }
+
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean removeItem(Object itemId)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java
index c39454027a..4b296d2eda 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1506_TestContainer2.java
@@ -1,118 +1,118 @@
-package com.vaadin.tests.tickets;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.data.util.PropertysetItem;
-
-/**
- * @author Efecte R&D
- * @version $Revision$, $Date$
- */
-public class Ticket1506_TestContainer2 implements Container {
- private Map<String, PropertysetItem> items = new HashMap<String, PropertysetItem>();
- public static final String ITEM_1_ID = "1";
- public static final String ITEM_2_ID = "2";
- public static final String PROPERTY_1_ID = "property 1";
- public static final String PROPERTY_2_ID = "property 2";
-
- private void loadItems() {
- for (int i = 1; i < 15; i++) {
- final PropertysetItem item = new PropertysetItem();
- item.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
- "value " + i, String.class));
- item.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
- "name " + i, String.class));
- items.put(String.valueOf(i), item);
- }
- }
-
- public Item getItem(Object itemId) {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.get(itemId);
- }
-
- public Collection<String> getContainerPropertyIds() {
- if (items.isEmpty()) {
- loadItems();
- }
- ArrayList<String> a = new ArrayList<String>();
- a.add(PROPERTY_1_ID);
- a.add(PROPERTY_2_ID);
- return a;
- }
-
- public Collection<String> getItemIds() {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.keySet();
- }
-
- public Property getContainerProperty(Object itemId, Object propertyId) {
- if (items.isEmpty()) {
- loadItems();
- }
- Item item = items.get(itemId);
- if (item != null) {
- return item.getItemProperty(propertyId);
- }
- return null;
- }
-
- public Class<String> getType(Object propertyId) {
- if (items.isEmpty()) {
- loadItems();
- }
- return String.class;
- }
-
- public int size() {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.size();
- }
-
- public boolean containsId(Object itemId) {
- if (items.isEmpty()) {
- loadItems();
- }
- return items.containsKey(itemId);
- }
-
- public Item addItem(Object itemId) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public Object addItem() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean removeItem(Object itemId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean addContainerProperty(Object propertyId, Class<?> type,
- Object defaultValue) throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean removeContainerProperty(Object propertyId)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public boolean removeAllItems() throws UnsupportedOperationException {
- throw new UnsupportedOperationException("Not implemented");
- }
+package com.vaadin.tests.tickets;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.data.util.PropertysetItem;
+
+/**
+ * @author Efecte R&D
+ * @version $Revision$, $Date$
+ */
+public class Ticket1506_TestContainer2 implements Container {
+ private Map<String, PropertysetItem> items = new HashMap<String, PropertysetItem>();
+ public static final String ITEM_1_ID = "1";
+ public static final String ITEM_2_ID = "2";
+ public static final String PROPERTY_1_ID = "property 1";
+ public static final String PROPERTY_2_ID = "property 2";
+
+ private void loadItems() {
+ for (int i = 1; i < 15; i++) {
+ final PropertysetItem item = new PropertysetItem();
+ item.addItemProperty(PROPERTY_1_ID, new ObjectProperty<String>(
+ "value " + i, String.class));
+ item.addItemProperty(PROPERTY_2_ID, new ObjectProperty<String>(
+ "name " + i, String.class));
+ items.put(String.valueOf(i), item);
+ }
+ }
+
+ public Item getItem(Object itemId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.get(itemId);
+ }
+
+ public Collection<String> getContainerPropertyIds() {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ ArrayList<String> a = new ArrayList<String>();
+ a.add(PROPERTY_1_ID);
+ a.add(PROPERTY_2_ID);
+ return a;
+ }
+
+ public Collection<String> getItemIds() {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.keySet();
+ }
+
+ public Property getContainerProperty(Object itemId, Object propertyId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ Item item = items.get(itemId);
+ if (item != null) {
+ return item.getItemProperty(propertyId);
+ }
+ return null;
+ }
+
+ public Class<String> getType(Object propertyId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return String.class;
+ }
+
+ public int size() {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.size();
+ }
+
+ public boolean containsId(Object itemId) {
+ if (items.isEmpty()) {
+ loadItems();
+ }
+ return items.containsKey(itemId);
+ }
+
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean removeItem(Object itemId)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not implemented");
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java
index a928e0f69c..425a3d5ee2 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java
@@ -1,118 +1,118 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket1572 extends com.vaadin.Application {
-
- private Label state;
- private GridLayout gl;
- private Label spacingstate;
-
- @Override
- public void init() {
-
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- Panel p = new Panel("Test wrapper for gridlayout margin/spacing");
-
- p.setContent(new HorizontalLayout());
-
- gl = new GridLayout(3, 3);
- gl.setMargin(true);
- for (int i = 0; i < 3 * 3; i++) {
- gl.addComponent(new Button("test"));
- }
- p.addComponent(gl);
- p.addComponent(new Label("| next component"));
-
- Button b = new Button("next margin state");
- b.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- nextMarginState();
- }
-
- });
-
- state = new Label();
- state.setCaption("Current margin state:");
- main.addComponent(state);
- main.addComponent(b);
-
- Button b2 = new Button("next spacing state");
- b2.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- nextSpacingState();
- }
-
- });
-
- spacingstate = new Label();
- spacingstate.setCaption("Current Spacing State:");
- main.addComponent(spacingstate);
- main.addComponent(b2);
-
- main.addComponent(p);
-
- nextMarginState();
- nextSpacingState();
-
- }
-
- private int stateCounter = -1;
-
- private void nextMarginState() {
- stateCounter++;
- switch (stateCounter) {
- case 0:
- gl.setMargin(false);
- state.setValue("Margin off");
- break;
- case 1:
- gl.setMargin(true);
- state.setValue("Margin on");
- break;
- case 2:
- gl.setMargin(true, false, false, false);
- state.setValue("Margin top");
- break;
- case 3:
- gl.setMargin(false, true, false, false);
- state.setValue("Margin right");
- break;
- case 4:
- gl.setMargin(false, false, true, false);
- state.setValue("Margin bottom");
- break;
- case 5:
- gl.setMargin(false, false, false, true);
- state.setValue("Margin left");
- break;
- default:
- stateCounter = -1;
- nextMarginState();
- break;
- }
- }
-
- private boolean spacing = true;
-
- private void nextSpacingState() {
- spacing = !spacing;
- if (spacing) {
- gl.setSpacing(true);
- spacingstate.setValue("Spacing on");
- } else {
- gl.setSpacing(false);
- spacingstate.setValue("Spacing off");
- }
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket1572 extends com.vaadin.Application {
+
+ private Label state;
+ private GridLayout gl;
+ private Label spacingstate;
+
+ @Override
+ public void init() {
+
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ Panel p = new Panel("Test wrapper for gridlayout margin/spacing");
+
+ p.setContent(new HorizontalLayout());
+
+ gl = new GridLayout(3, 3);
+ gl.setMargin(true);
+ for (int i = 0; i < 3 * 3; i++) {
+ gl.addComponent(new Button("test"));
+ }
+ p.addComponent(gl);
+ p.addComponent(new Label("| next component"));
+
+ Button b = new Button("next margin state");
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ nextMarginState();
+ }
+
+ });
+
+ state = new Label();
+ state.setCaption("Current margin state:");
+ main.addComponent(state);
+ main.addComponent(b);
+
+ Button b2 = new Button("next spacing state");
+ b2.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ nextSpacingState();
+ }
+
+ });
+
+ spacingstate = new Label();
+ spacingstate.setCaption("Current Spacing State:");
+ main.addComponent(spacingstate);
+ main.addComponent(b2);
+
+ main.addComponent(p);
+
+ nextMarginState();
+ nextSpacingState();
+
+ }
+
+ private int stateCounter = -1;
+
+ private void nextMarginState() {
+ stateCounter++;
+ switch (stateCounter) {
+ case 0:
+ gl.setMargin(false);
+ state.setValue("Margin off");
+ break;
+ case 1:
+ gl.setMargin(true);
+ state.setValue("Margin on");
+ break;
+ case 2:
+ gl.setMargin(true, false, false, false);
+ state.setValue("Margin top");
+ break;
+ case 3:
+ gl.setMargin(false, true, false, false);
+ state.setValue("Margin right");
+ break;
+ case 4:
+ gl.setMargin(false, false, true, false);
+ state.setValue("Margin bottom");
+ break;
+ case 5:
+ gl.setMargin(false, false, false, true);
+ state.setValue("Margin left");
+ break;
+ default:
+ stateCounter = -1;
+ nextMarginState();
+ break;
+ }
+ }
+
+ private boolean spacing = true;
+
+ private void nextSpacingState() {
+ spacing = !spacing;
+ if (spacing) {
+ gl.setSpacing(true);
+ spacingstate.setValue("Spacing on");
+ } else {
+ gl.setSpacing(false);
+ spacingstate.setValue("Spacing off");
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java
index 6780b3c9de..e87ad848ce 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java
@@ -1,71 +1,71 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Date;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.ProgressIndicator;
-import com.vaadin.ui.Window;
-
-public class Ticket1581 extends com.vaadin.Application {
-
- private Label time;
- private ProgressIndicator poller;
- private Thread thread;
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- main.addComponent(new Label("Test the second issue in ticket #1581"));
-
- time = new Label();
- poller = new ProgressIndicator();
- poller.setPollingInterval(200);
- main.addComponent(time);
- main.addComponent(poller);
-
- thread = new Thread() {
-
- @Override
- public void run() {
- super.run();
- while (true) {
- time.setValue(new Date());
- try {
- sleep(200);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- };
-
- thread.start();
-
- final Button stop = new Button("Stop updating", new ClickListener() {
- boolean active = true;
-
- public void buttonClick(ClickEvent event) {
-
- if (active) {
- main.removeComponent(poller);
- event.getButton().setCaption("Resume");
- } else {
- main.addComponent(poller);
- event.getButton().setCaption("Stop updating");
- }
- active = !active;
- }
- });
-
- main.addComponent(stop);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Date;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.ProgressIndicator;
+import com.vaadin.ui.Window;
+
+public class Ticket1581 extends com.vaadin.Application {
+
+ private Label time;
+ private ProgressIndicator poller;
+ private Thread thread;
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ main.addComponent(new Label("Test the second issue in ticket #1581"));
+
+ time = new Label();
+ poller = new ProgressIndicator();
+ poller.setPollingInterval(200);
+ main.addComponent(time);
+ main.addComponent(poller);
+
+ thread = new Thread() {
+
+ @Override
+ public void run() {
+ super.run();
+ while (true) {
+ time.setValue(new Date());
+ try {
+ sleep(200);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ };
+
+ thread.start();
+
+ final Button stop = new Button("Stop updating", new ClickListener() {
+ boolean active = true;
+
+ public void buttonClick(ClickEvent event) {
+
+ if (active) {
+ main.removeComponent(poller);
+ event.getButton().setCaption("Resume");
+ } else {
+ main.addComponent(poller);
+ event.getButton().setCaption("Stop updating");
+ }
+ active = !active;
+ }
+ });
+
+ main.addComponent(stop);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java
index 5a2bf0c793..7074be65e4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java
@@ -1,94 +1,94 @@
-package com.vaadin.tests.tickets;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Date;
-
-import javax.imageio.ImageIO;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.DownloadStream;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.URIHandler;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Window;
-
-public class Ticket1589 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
-
- MyDynamicResource res = new MyDynamicResource();
-
- w.addURIHandler(res);
-
- w.addComponent(new Link(
- "Test (without Content-Disposition, should suggest generatedFile.png when saving, browser default for actual disposition)",
- new ExternalResource("myresource")));
-
- w.addComponent(new Link(
- "Test (with Content-Disposition, should popup download dialog that suggests filename downloadedPNG.png)",
- new ExternalResource("myresource_download")));
- }
-}
-
-class MyDynamicResource implements URIHandler {
- String textToDisplay = (new Date()).toString();
-
- /**
- * Provides the dynamic resource if the URI matches the resource URI. The
- * matching URI is "/myresource" under the application URI context.
- *
- * Returns null if the URI does not match. Otherwise returns a download
- * stream that contains the response from the server.
- */
- public DownloadStream handleURI(URL context, String relativeUri) {
- // Catch the given URI that identifies the resource, otherwise let other
- // URI handlers or the Application to handle the response.
- if (!relativeUri.startsWith("myresource")) {
- return null;
- }
-
- // Create an image and draw some background on it.
- BufferedImage image = new BufferedImage(200, 200,
- BufferedImage.TYPE_INT_RGB);
- Graphics drawable = image.getGraphics();
- drawable.setColor(Color.lightGray);
- drawable.fillRect(0, 0, 200, 200);
- drawable.setColor(Color.yellow);
- drawable.fillOval(25, 25, 150, 150);
- drawable.setColor(Color.blue);
- drawable.drawRect(0, 0, 199, 199);
-
- // Use the parameter to create dynamic content.
- drawable.setColor(Color.black);
- drawable.drawString("Time: " + textToDisplay, 75, 100);
-
- try {
- // Write the image to a buffer.
- ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream();
- ImageIO.write(image, "png", imagebuffer);
-
- // Return a stream from the buffer.
- ByteArrayInputStream istream = new ByteArrayInputStream(
- imagebuffer.toByteArray());
- DownloadStream downloadStream = new DownloadStream(istream,
- "image/png", "generatedFile.png");
-
- if (relativeUri.startsWith("myresource_download")) {
- downloadStream.setParameter("Content-Disposition",
- "attachment; filename=\"downloadedPNG.png\"");
- }
- return downloadStream;
- } catch (IOException e) {
- return null;
- }
- }
+package com.vaadin.tests.tickets;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Date;
+
+import javax.imageio.ImageIO;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.DownloadStream;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.terminal.URIHandler;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Window;
+
+public class Ticket1589 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+
+ MyDynamicResource res = new MyDynamicResource();
+
+ w.addURIHandler(res);
+
+ w.addComponent(new Link(
+ "Test (without Content-Disposition, should suggest generatedFile.png when saving, browser default for actual disposition)",
+ new ExternalResource("myresource")));
+
+ w.addComponent(new Link(
+ "Test (with Content-Disposition, should popup download dialog that suggests filename downloadedPNG.png)",
+ new ExternalResource("myresource_download")));
+ }
+}
+
+class MyDynamicResource implements URIHandler {
+ String textToDisplay = (new Date()).toString();
+
+ /**
+ * Provides the dynamic resource if the URI matches the resource URI. The
+ * matching URI is "/myresource" under the application URI context.
+ *
+ * Returns null if the URI does not match. Otherwise returns a download
+ * stream that contains the response from the server.
+ */
+ public DownloadStream handleURI(URL context, String relativeUri) {
+ // Catch the given URI that identifies the resource, otherwise let other
+ // URI handlers or the Application to handle the response.
+ if (!relativeUri.startsWith("myresource")) {
+ return null;
+ }
+
+ // Create an image and draw some background on it.
+ BufferedImage image = new BufferedImage(200, 200,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics drawable = image.getGraphics();
+ drawable.setColor(Color.lightGray);
+ drawable.fillRect(0, 0, 200, 200);
+ drawable.setColor(Color.yellow);
+ drawable.fillOval(25, 25, 150, 150);
+ drawable.setColor(Color.blue);
+ drawable.drawRect(0, 0, 199, 199);
+
+ // Use the parameter to create dynamic content.
+ drawable.setColor(Color.black);
+ drawable.drawString("Time: " + textToDisplay, 75, 100);
+
+ try {
+ // Write the image to a buffer.
+ ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream();
+ ImageIO.write(image, "png", imagebuffer);
+
+ // Return a stream from the buffer.
+ ByteArrayInputStream istream = new ByteArrayInputStream(
+ imagebuffer.toByteArray());
+ DownloadStream downloadStream = new DownloadStream(istream,
+ "image/png", "generatedFile.png");
+
+ if (relativeUri.startsWith("myresource_download")) {
+ downloadStream.setParameter("Content-Disposition",
+ "attachment; filename=\"downloadedPNG.png\"");
+ }
+ return downloadStream;
+ } catch (IOException e) {
+ return null;
+ }
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java
index e7b98a4c99..79bd22a96d 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java
@@ -1,22 +1,22 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.terminal.SystemError;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket1663 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- Window main = new Window("#1663");
- setMainWindow(main);
-
- TextField tf = new TextField("First name");
- tf.setDescription("The first name is used for the administration user interfaces only.");
- tf.setComponentError(new SystemError(
- "You must enter only one first name."));
-
- main.addComponent(tf);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.terminal.SystemError;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket1663 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ Window main = new Window("#1663");
+ setMainWindow(main);
+
+ TextField tf = new TextField("First name");
+ tf.setDescription("The first name is used for the administration user interfaces only.");
+ tf.setComponentError(new SystemError(
+ "You must enter only one first name."));
+
+ main.addComponent(tf);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java
index 845e49daed..7af141b972 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java
@@ -1,28 +1,28 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Window;
-
-public class Ticket1673 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- final Window main = new Window("#1673");
- setMainWindow(main);
-
- main.addComponent(new Button("close", this, "close"));
-
- }
-
- public static Application.SystemMessages getSystemMessages() {
- Application.CustomizedSystemMessages msgs = new Application.CustomizedSystemMessages();
-
- msgs.setSessionExpiredURL("http://www.vaadin.com/");
- msgs.setSessionExpiredCaption("Foo");
- msgs.setSessionExpiredMessage("Bar");
-
- return msgs;
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Window;
+
+public class Ticket1673 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ final Window main = new Window("#1673");
+ setMainWindow(main);
+
+ main.addComponent(new Button("close", this, "close"));
+
+ }
+
+ public static Application.SystemMessages getSystemMessages() {
+ Application.CustomizedSystemMessages msgs = new Application.CustomizedSystemMessages();
+
+ msgs.setSessionExpiredURL("http://www.vaadin.com/");
+ msgs.setSessionExpiredCaption("Foo");
+ msgs.setSessionExpiredMessage("Bar");
+
+ return msgs;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
index 404301dfa5..176f2efdd2 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java
@@ -1,411 +1,411 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Iterator;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.MethodProperty;
-import com.vaadin.terminal.SystemError;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1710 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- setTheme("tests-tickets");
-
- VerticalLayout lo = new VerticalLayout();
- setMainWindow(new Window("#1710", lo));
- lo.setMargin(true);
- lo.setSpacing(true);
- lo.setWidth("100%");
-
- // Hiding controls
- HorizontalLayout hidingControls = new HorizontalLayout();
- lo.addComponent(hidingControls);
-
- // OrderedLayout
- final VerticalLayout orderedLayout = new VerticalLayout();
- LayoutTestingPanel oltp = new LayoutTestingPanel("OrderedLayout",
- orderedLayout);
- CheckBox cb = new CheckBox("OrderedLayout",
- new MethodProperty<Boolean>(oltp, "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- lo.addComponent(oltp);
- orderedLayout.setSpacing(false);
- addFields(orderedLayout);
-
- // GridLayout
- GridLayout grid = new GridLayout(1, 1);
- Panel g1tp = new LayoutTestingPanel("Gridlayout with 1 column", grid);
- cb = new CheckBox("GridLayout (1col)", new MethodProperty<Boolean>(
- g1tp, "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- g1tp.setVisible(false);
- lo.addComponent(g1tp);
- grid.setSpacing(true);
- addFields(grid);
- GridLayout grid2 = new GridLayout(2, 1);
- Panel g2tp = new LayoutTestingPanel("Gridlayout with 2 columns", grid2);
- cb = new CheckBox("GridLayout (2cols)", new MethodProperty<Boolean>(
- g2tp, "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- g2tp.setVisible(false);
- lo.addComponent(g2tp);
- grid2.setSpacing(true);
- addFields(grid2);
-
- // ExpandLayout
- VerticalLayout el = new VerticalLayout();
- Panel elp = new LayoutTestingPanel(
- "ExpandLayout width first component expanded", el);
- cb = new CheckBox("ExpandLayout (vertical)",
- new MethodProperty<Boolean>(elp, "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- elp.setVisible(false);
- el.setHeight("700px");
- addFields(el);
- Component firstComponent = el.getComponentIterator().next();
- firstComponent.setSizeFull();
- el.setExpandRatio(firstComponent, 1);
- lo.addComponent(elp);
- HorizontalLayout elh = new HorizontalLayout();
- Panel elhp = new LayoutTestingPanel(
- "ExpandLayout width first component expanded; horizontal", elh);
- cb = new CheckBox("ExpandLayout (horizontal)",
- new MethodProperty<Boolean>(elhp, "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- elhp.setVisible(false);
- elhp.setScrollable(true);
- elh.setWidth("2000px");
- elh.setHeight("100px");
- addFields(elh);
- Component firstComponentElh = elh.getComponentIterator().next();
- firstComponentElh.setSizeFull();
- elh.setExpandRatio(firstComponentElh, 1);
- lo.addComponent(elhp);
-
- // CustomLayout
- VerticalLayout cl = new VerticalLayout();
- Panel clp = new LayoutTestingPanel("CustomLayout", cl);
- cb = new CheckBox("CustomLayout", new MethodProperty<Boolean>(clp,
- "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- clp.setVisible(false);
- lo.addComponent(clp);
- cl.addComponent(new Label("<<< Add customlayout testcase here >>>"));
-
- // Form
- Panel formPanel = new Panel("Form");
- cb = new CheckBox("Form", new MethodProperty<Boolean>(formPanel,
- "visible"));
- cb.setImmediate(true);
- hidingControls.addComponent(cb);
- formPanel.setVisible(false);
- formPanel.addComponent(getFormPanelExample());
- lo.addComponent(formPanel);
-
- for (Iterator<Component> i = hidingControls.getComponentIterator(); i
- .hasNext();) {
- ((AbstractComponent) i.next()).setImmediate(true);
- }
-
- }
-
- private Form getFormPanelExample() {
- Form f = new Form();
- f.setCaption("Test form");
- Button fb1 = new Button("Test button");
- fb1.setComponentError(new SystemError("Test error"));
- f.addField("fb1", fb1);
- CheckBox fb2 = new CheckBox("Test button", true);
- fb2.setComponentError(new SystemError("Test error"));
- f.addField("fb2", fb2);
- TextField ft1 = new TextField("With caption");
- ft1.setComponentError(new SystemError("Error"));
- f.addField("ft1", ft1);
- TextField ft2 = new TextField();
- ft2.setComponentError(new SystemError("Error"));
- ft2.setValue("Without caption");
- f.addField("ft2", ft2);
- TextField ft3 = new TextField("With caption and required");
- ft3.setComponentError(new SystemError("Error"));
- ft3.setRequired(true);
- f.addField("ft3", ft3);
- return f;
- }
-
- private void addFields(ComponentContainer lo) {
- Button button = new Button("Test button");
- button.setComponentError(new SystemError("Test error"));
- lo.addComponent(button);
-
- CheckBox b2 = new CheckBox("Test button");
- b2.setComponentError(new SystemError("Test error"));
- lo.addComponent(b2);
-
- TextField t1 = new TextField("With caption");
- t1.setComponentError(new SystemError("Error"));
- lo.addComponent(t1);
-
- TextField t2 = new TextField("With caption and required");
- t2.setComponentError(new SystemError("Error"));
- t2.setRequired(true);
- lo.addComponent(t2);
-
- TextField t3 = new TextField();
- t3.setValue("Without caption");
- t3.setComponentError(new SystemError("Error"));
- lo.addComponent(t3);
-
- lo.addComponent(new TextField("Textfield with no error in it"));
-
- TextField tt1 = new TextField("100% wide Textfield with no error in it");
- tt1.setWidth("100%");
- lo.addComponent(tt1);
-
- TextField tt2 = new TextField();
- tt2.setWidth("100%");
- tt2.setValue("100% wide Textfield with no error in it and no caption");
- lo.addComponent(tt2);
-
- TextField t4 = new TextField();
- t4.setValue("Without caption, With required");
- t4.setComponentError(new SystemError("Error"));
- t4.setRequired(true);
- lo.addComponent(t4);
-
- TextField t5 = new TextField();
- t5.setValue("Without caption, WIDE");
- t5.setComponentError(new SystemError("Error"));
- t5.setWidth("100%");
- lo.addComponent(t5);
-
- TextField t6 = new TextField();
- t6.setValue("Without caption, With required, WIDE");
- t6.setComponentError(new SystemError("Error"));
- t6.setRequired(true);
- t6.setWidth("100%");
- lo.addComponent(t6);
-
- TextField t7 = new TextField();
- t7.setValue("With icon and required and icon");
- t7.setComponentError(new SystemError("Error"));
- t7.setRequired(true);
- t7.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
- lo.addComponent(t7);
-
- DateField d1 = new DateField(
- "Datefield with caption and icon, next one without caption");
- d1.setComponentError(new SystemError("Error"));
- d1.setRequired(true);
- d1.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
- lo.addComponent(d1);
-
- DateField d2 = new DateField();
- d2.setComponentError(new SystemError("Error"));
- d2.setRequired(true);
- lo.addComponent(d2);
- }
-
- public class LayoutTestingPanel extends Panel {
-
- Layout testedLayout;
-
- HorizontalLayout controls = new HorizontalLayout();
- CheckBox marginLeft = new CheckBox("m-left", false);
- CheckBox marginRight = new CheckBox("m-right", false);
- CheckBox marginTop = new CheckBox("m-top", false);
- CheckBox marginBottom = new CheckBox("m-bottom", false);
- CheckBox spacing = new CheckBox("spacing", false);
- VerticalLayout testPanelLayout = new VerticalLayout();
-
- LayoutTestingPanel(String caption, Layout layout) {
- super(caption);
- VerticalLayout internalLayout = new VerticalLayout();
- internalLayout.setWidth("100%");
- setContent(internalLayout);
- testedLayout = layout;
- testPanelLayout.setWidth("100%");
- Panel controlWrapper = new Panel();
- controlWrapper.addComponent(controls);
- controlWrapper.setWidth("100%");
- controlWrapper.setScrollable(true);
- controlWrapper.setStyleName("controls");
- internalLayout.addComponent(controlWrapper);
- Panel testPanel = new Panel(testPanelLayout);
- testPanel.setStyleName("testarea");
- testPanelLayout.addComponent(testedLayout);
- internalLayout.addComponent(testPanel);
- internalLayout.setMargin(true);
- internalLayout.setSpacing(true);
- controls.setSpacing(true);
- controls.setMargin(false);
- controls.addComponent(new Label("width"));
- controls.addComponent(new TextField(new MethodProperty<Float>(
- testedLayout, "width")));
- controls.addComponent(new CheckBox("%",
- new MethodProperty<Boolean>(this, "widthPercents")));
- controls.addComponent(new Label("height"));
- controls.addComponent(new TextField(new MethodProperty<Float>(
- testedLayout, "height")));
- controls.addComponent(new CheckBox("%",
- new MethodProperty<Boolean>(this, "heightPercents")));
- controls.addComponent(marginLeft);
- controls.addComponent(marginRight);
- controls.addComponent(marginTop);
- controls.addComponent(marginBottom);
- if (testedLayout instanceof Layout.SpacingHandler) {
- controls.addComponent(spacing);
- }
-
- Property.ValueChangeListener marginSpacingListener = new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- updateMarginsAndSpacing();
- }
- };
-
- marginBottom.addListener(marginSpacingListener);
- marginTop.addListener(marginSpacingListener);
- marginLeft.addListener(marginSpacingListener);
- marginRight.addListener(marginSpacingListener);
- spacing.addListener(marginSpacingListener);
- updateMarginsAndSpacing();
-
- addAlignmentControls();
-
- testedLayout.setStyleName("tested-layout");
- setStyleName("layout-testing-panel");
-
- for (Iterator<Component> i = controls.getComponentIterator(); i
- .hasNext();) {
- ((AbstractComponent) i.next()).setImmediate(true);
- }
- }
-
- @SuppressWarnings("deprecation")
- private void addAlignmentControls() {
- if (!(testedLayout instanceof Layout.AlignmentHandler)) {
- return;
- }
- @SuppressWarnings("unused")
- final Layout.AlignmentHandler ah = (AlignmentHandler) testedLayout;
-
- final NativeSelect vAlign = new NativeSelect();
- final NativeSelect hAlign = new NativeSelect();
- controls.addComponent(new Label("component alignment"));
- controls.addComponent(hAlign);
- controls.addComponent(vAlign);
- hAlign.setNullSelectionAllowed(false);
- vAlign.setNullSelectionAllowed(false);
-
- vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP));
- vAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_TOP), "top");
- vAlign.addItem(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER));
- vAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER),
- "center");
- vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_BOTTOM));
- vAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_BOTTOM), "bottom");
-
- hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
- hAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_LEFT), "left");
- hAlign.addItem(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER));
- hAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER),
- "center");
- hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT));
- hAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right");
-
- Property.ValueChangeListener alignmentChangeListener = new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- updateAlignments(((Integer) hAlign.getValue()).intValue(),
- ((Integer) vAlign.getValue()).intValue());
- }
-
- };
-
- hAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
- vAlign.addListener(alignmentChangeListener);
- hAlign.addListener(alignmentChangeListener);
- vAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP));
-
- controls.addComponent(new Label("layout alignment"));
- final NativeSelect lAlign = new NativeSelect();
- controls.addComponent(lAlign);
- lAlign.setNullSelectionAllowed(false);
- lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
- lAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_LEFT), "left");
- lAlign.addItem(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER));
- lAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER),
- "center");
- lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT));
- lAlign.setItemCaption(new Integer(
- Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right");
-
- lAlign.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- testPanelLayout.setComponentAlignment(testedLayout,
- ((Integer) lAlign.getValue()).intValue(),
- VerticalLayout.ALIGNMENT_TOP);
- }
- });
- }
-
- @SuppressWarnings("deprecation")
- private void updateAlignments(int h, int v) {
- for (Iterator<Component> i = testedLayout.getComponentIterator(); i
- .hasNext();) {
- ((Layout.AlignmentHandler) testedLayout).setComponentAlignment(
- i.next(), h, v);
- }
- }
-
- private void updateMarginsAndSpacing() {
- testedLayout.setMargin(
- ((Boolean) marginTop.getValue()).booleanValue(),
- ((Boolean) marginRight.getValue()).booleanValue(),
- ((Boolean) marginBottom.getValue()).booleanValue(),
- ((Boolean) marginLeft.getValue()).booleanValue());
- if (testedLayout instanceof Layout.SpacingHandler) {
- ((Layout.SpacingHandler) testedLayout)
- .setSpacing(((Boolean) spacing.getValue())
- .booleanValue());
- }
- }
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Iterator;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.AlignmentHandler;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1710 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ setTheme("tests-tickets");
+
+ VerticalLayout lo = new VerticalLayout();
+ setMainWindow(new Window("#1710", lo));
+ lo.setMargin(true);
+ lo.setSpacing(true);
+ lo.setWidth("100%");
+
+ // Hiding controls
+ HorizontalLayout hidingControls = new HorizontalLayout();
+ lo.addComponent(hidingControls);
+
+ // OrderedLayout
+ final VerticalLayout orderedLayout = new VerticalLayout();
+ LayoutTestingPanel oltp = new LayoutTestingPanel("OrderedLayout",
+ orderedLayout);
+ CheckBox cb = new CheckBox("OrderedLayout",
+ new MethodProperty<Boolean>(oltp, "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ lo.addComponent(oltp);
+ orderedLayout.setSpacing(false);
+ addFields(orderedLayout);
+
+ // GridLayout
+ GridLayout grid = new GridLayout(1, 1);
+ Panel g1tp = new LayoutTestingPanel("Gridlayout with 1 column", grid);
+ cb = new CheckBox("GridLayout (1col)", new MethodProperty<Boolean>(
+ g1tp, "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ g1tp.setVisible(false);
+ lo.addComponent(g1tp);
+ grid.setSpacing(true);
+ addFields(grid);
+ GridLayout grid2 = new GridLayout(2, 1);
+ Panel g2tp = new LayoutTestingPanel("Gridlayout with 2 columns", grid2);
+ cb = new CheckBox("GridLayout (2cols)", new MethodProperty<Boolean>(
+ g2tp, "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ g2tp.setVisible(false);
+ lo.addComponent(g2tp);
+ grid2.setSpacing(true);
+ addFields(grid2);
+
+ // ExpandLayout
+ VerticalLayout el = new VerticalLayout();
+ Panel elp = new LayoutTestingPanel(
+ "ExpandLayout width first component expanded", el);
+ cb = new CheckBox("ExpandLayout (vertical)",
+ new MethodProperty<Boolean>(elp, "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ elp.setVisible(false);
+ el.setHeight("700px");
+ addFields(el);
+ Component firstComponent = el.getComponentIterator().next();
+ firstComponent.setSizeFull();
+ el.setExpandRatio(firstComponent, 1);
+ lo.addComponent(elp);
+ HorizontalLayout elh = new HorizontalLayout();
+ Panel elhp = new LayoutTestingPanel(
+ "ExpandLayout width first component expanded; horizontal", elh);
+ cb = new CheckBox("ExpandLayout (horizontal)",
+ new MethodProperty<Boolean>(elhp, "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ elhp.setVisible(false);
+ elhp.setScrollable(true);
+ elh.setWidth("2000px");
+ elh.setHeight("100px");
+ addFields(elh);
+ Component firstComponentElh = elh.getComponentIterator().next();
+ firstComponentElh.setSizeFull();
+ elh.setExpandRatio(firstComponentElh, 1);
+ lo.addComponent(elhp);
+
+ // CustomLayout
+ VerticalLayout cl = new VerticalLayout();
+ Panel clp = new LayoutTestingPanel("CustomLayout", cl);
+ cb = new CheckBox("CustomLayout", new MethodProperty<Boolean>(clp,
+ "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ clp.setVisible(false);
+ lo.addComponent(clp);
+ cl.addComponent(new Label("<<< Add customlayout testcase here >>>"));
+
+ // Form
+ Panel formPanel = new Panel("Form");
+ cb = new CheckBox("Form", new MethodProperty<Boolean>(formPanel,
+ "visible"));
+ cb.setImmediate(true);
+ hidingControls.addComponent(cb);
+ formPanel.setVisible(false);
+ formPanel.addComponent(getFormPanelExample());
+ lo.addComponent(formPanel);
+
+ for (Iterator<Component> i = hidingControls.getComponentIterator(); i
+ .hasNext();) {
+ ((AbstractComponent) i.next()).setImmediate(true);
+ }
+
+ }
+
+ private Form getFormPanelExample() {
+ Form f = new Form();
+ f.setCaption("Test form");
+ Button fb1 = new Button("Test button");
+ fb1.setComponentError(new SystemError("Test error"));
+ f.addField("fb1", fb1);
+ CheckBox fb2 = new CheckBox("Test button", true);
+ fb2.setComponentError(new SystemError("Test error"));
+ f.addField("fb2", fb2);
+ TextField ft1 = new TextField("With caption");
+ ft1.setComponentError(new SystemError("Error"));
+ f.addField("ft1", ft1);
+ TextField ft2 = new TextField();
+ ft2.setComponentError(new SystemError("Error"));
+ ft2.setValue("Without caption");
+ f.addField("ft2", ft2);
+ TextField ft3 = new TextField("With caption and required");
+ ft3.setComponentError(new SystemError("Error"));
+ ft3.setRequired(true);
+ f.addField("ft3", ft3);
+ return f;
+ }
+
+ private void addFields(ComponentContainer lo) {
+ Button button = new Button("Test button");
+ button.setComponentError(new SystemError("Test error"));
+ lo.addComponent(button);
+
+ CheckBox b2 = new CheckBox("Test button");
+ b2.setComponentError(new SystemError("Test error"));
+ lo.addComponent(b2);
+
+ TextField t1 = new TextField("With caption");
+ t1.setComponentError(new SystemError("Error"));
+ lo.addComponent(t1);
+
+ TextField t2 = new TextField("With caption and required");
+ t2.setComponentError(new SystemError("Error"));
+ t2.setRequired(true);
+ lo.addComponent(t2);
+
+ TextField t3 = new TextField();
+ t3.setValue("Without caption");
+ t3.setComponentError(new SystemError("Error"));
+ lo.addComponent(t3);
+
+ lo.addComponent(new TextField("Textfield with no error in it"));
+
+ TextField tt1 = new TextField("100% wide Textfield with no error in it");
+ tt1.setWidth("100%");
+ lo.addComponent(tt1);
+
+ TextField tt2 = new TextField();
+ tt2.setWidth("100%");
+ tt2.setValue("100% wide Textfield with no error in it and no caption");
+ lo.addComponent(tt2);
+
+ TextField t4 = new TextField();
+ t4.setValue("Without caption, With required");
+ t4.setComponentError(new SystemError("Error"));
+ t4.setRequired(true);
+ lo.addComponent(t4);
+
+ TextField t5 = new TextField();
+ t5.setValue("Without caption, WIDE");
+ t5.setComponentError(new SystemError("Error"));
+ t5.setWidth("100%");
+ lo.addComponent(t5);
+
+ TextField t6 = new TextField();
+ t6.setValue("Without caption, With required, WIDE");
+ t6.setComponentError(new SystemError("Error"));
+ t6.setRequired(true);
+ t6.setWidth("100%");
+ lo.addComponent(t6);
+
+ TextField t7 = new TextField();
+ t7.setValue("With icon and required and icon");
+ t7.setComponentError(new SystemError("Error"));
+ t7.setRequired(true);
+ t7.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
+ lo.addComponent(t7);
+
+ DateField d1 = new DateField(
+ "Datefield with caption and icon, next one without caption");
+ d1.setComponentError(new SystemError("Error"));
+ d1.setRequired(true);
+ d1.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
+ lo.addComponent(d1);
+
+ DateField d2 = new DateField();
+ d2.setComponentError(new SystemError("Error"));
+ d2.setRequired(true);
+ lo.addComponent(d2);
+ }
+
+ public class LayoutTestingPanel extends Panel {
+
+ Layout testedLayout;
+
+ HorizontalLayout controls = new HorizontalLayout();
+ CheckBox marginLeft = new CheckBox("m-left", false);
+ CheckBox marginRight = new CheckBox("m-right", false);
+ CheckBox marginTop = new CheckBox("m-top", false);
+ CheckBox marginBottom = new CheckBox("m-bottom", false);
+ CheckBox spacing = new CheckBox("spacing", false);
+ VerticalLayout testPanelLayout = new VerticalLayout();
+
+ LayoutTestingPanel(String caption, Layout layout) {
+ super(caption);
+ VerticalLayout internalLayout = new VerticalLayout();
+ internalLayout.setWidth("100%");
+ setContent(internalLayout);
+ testedLayout = layout;
+ testPanelLayout.setWidth("100%");
+ Panel controlWrapper = new Panel();
+ controlWrapper.addComponent(controls);
+ controlWrapper.setWidth("100%");
+ controlWrapper.setScrollable(true);
+ controlWrapper.setStyleName("controls");
+ internalLayout.addComponent(controlWrapper);
+ Panel testPanel = new Panel(testPanelLayout);
+ testPanel.setStyleName("testarea");
+ testPanelLayout.addComponent(testedLayout);
+ internalLayout.addComponent(testPanel);
+ internalLayout.setMargin(true);
+ internalLayout.setSpacing(true);
+ controls.setSpacing(true);
+ controls.setMargin(false);
+ controls.addComponent(new Label("width"));
+ controls.addComponent(new TextField(new MethodProperty<Float>(
+ testedLayout, "width")));
+ controls.addComponent(new CheckBox("%",
+ new MethodProperty<Boolean>(this, "widthPercents")));
+ controls.addComponent(new Label("height"));
+ controls.addComponent(new TextField(new MethodProperty<Float>(
+ testedLayout, "height")));
+ controls.addComponent(new CheckBox("%",
+ new MethodProperty<Boolean>(this, "heightPercents")));
+ controls.addComponent(marginLeft);
+ controls.addComponent(marginRight);
+ controls.addComponent(marginTop);
+ controls.addComponent(marginBottom);
+ if (testedLayout instanceof Layout.SpacingHandler) {
+ controls.addComponent(spacing);
+ }
+
+ Property.ValueChangeListener marginSpacingListener = new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ updateMarginsAndSpacing();
+ }
+ };
+
+ marginBottom.addListener(marginSpacingListener);
+ marginTop.addListener(marginSpacingListener);
+ marginLeft.addListener(marginSpacingListener);
+ marginRight.addListener(marginSpacingListener);
+ spacing.addListener(marginSpacingListener);
+ updateMarginsAndSpacing();
+
+ addAlignmentControls();
+
+ testedLayout.setStyleName("tested-layout");
+ setStyleName("layout-testing-panel");
+
+ for (Iterator<Component> i = controls.getComponentIterator(); i
+ .hasNext();) {
+ ((AbstractComponent) i.next()).setImmediate(true);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private void addAlignmentControls() {
+ if (!(testedLayout instanceof Layout.AlignmentHandler)) {
+ return;
+ }
+ @SuppressWarnings("unused")
+ final Layout.AlignmentHandler ah = (AlignmentHandler) testedLayout;
+
+ final NativeSelect vAlign = new NativeSelect();
+ final NativeSelect hAlign = new NativeSelect();
+ controls.addComponent(new Label("component alignment"));
+ controls.addComponent(hAlign);
+ controls.addComponent(vAlign);
+ hAlign.setNullSelectionAllowed(false);
+ vAlign.setNullSelectionAllowed(false);
+
+ vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP));
+ vAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_TOP), "top");
+ vAlign.addItem(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER));
+ vAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER),
+ "center");
+ vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_BOTTOM));
+ vAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_BOTTOM), "bottom");
+
+ hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
+ hAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_LEFT), "left");
+ hAlign.addItem(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER));
+ hAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER),
+ "center");
+ hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT));
+ hAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right");
+
+ Property.ValueChangeListener alignmentChangeListener = new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ updateAlignments(((Integer) hAlign.getValue()).intValue(),
+ ((Integer) vAlign.getValue()).intValue());
+ }
+
+ };
+
+ hAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
+ vAlign.addListener(alignmentChangeListener);
+ hAlign.addListener(alignmentChangeListener);
+ vAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP));
+
+ controls.addComponent(new Label("layout alignment"));
+ final NativeSelect lAlign = new NativeSelect();
+ controls.addComponent(lAlign);
+ lAlign.setNullSelectionAllowed(false);
+ lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT));
+ lAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_LEFT), "left");
+ lAlign.addItem(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER));
+ lAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER),
+ "center");
+ lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT));
+ lAlign.setItemCaption(new Integer(
+ Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right");
+
+ lAlign.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ testPanelLayout.setComponentAlignment(testedLayout,
+ ((Integer) lAlign.getValue()).intValue(),
+ VerticalLayout.ALIGNMENT_TOP);
+ }
+ });
+ }
+
+ @SuppressWarnings("deprecation")
+ private void updateAlignments(int h, int v) {
+ for (Iterator<Component> i = testedLayout.getComponentIterator(); i
+ .hasNext();) {
+ ((Layout.AlignmentHandler) testedLayout).setComponentAlignment(
+ i.next(), h, v);
+ }
+ }
+
+ private void updateMarginsAndSpacing() {
+ testedLayout.setMargin(
+ ((Boolean) marginTop.getValue()).booleanValue(),
+ ((Boolean) marginRight.getValue()).booleanValue(),
+ ((Boolean) marginBottom.getValue()).booleanValue(),
+ ((Boolean) marginLeft.getValue()).booleanValue());
+ if (testedLayout instanceof Layout.SpacingHandler) {
+ ((Layout.SpacingHandler) testedLayout)
+ .setSpacing(((Boolean) spacing.getValue())
+ .booleanValue());
+ }
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java
index a65a601175..92fbddeeb3 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.Window;
-
-public class Ticket1767 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- ComboBox cb = new ComboBox(" '<' item is not seen in populist?");
- cb.addItem("Te<strong>st</strong> < jep >");
- cb.addItem("<");
- cb.addItem(">");
-
- cb.addItem("< dsf");
- cb.addItem("> sdf");
-
- cb.addItem("dsfs <");
- cb.addItem("sdfsd >");
-
- main.addComponent(cb);
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Window;
+
+public class Ticket1767 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ ComboBox cb = new ComboBox(" '<' item is not seen in populist?");
+ cb.addItem("Te<strong>st</strong> < jep >");
+ cb.addItem("<");
+ cb.addItem(">");
+
+ cb.addItem("< dsf");
+ cb.addItem("> sdf");
+
+ cb.addItem("dsfs <");
+ cb.addItem("sdfsd >");
+
+ main.addComponent(cb);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java
index 68e00e7f94..7cf3483277 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java
@@ -1,37 +1,37 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket1772 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- Button b = new Button("Add content");
- main.addComponent(b);
-
- final GridLayout gridLayout = new GridLayout(2, 2);
- main.addComponent(gridLayout);
-
- b.addListener(new Button.ClickListener() {
- int counter = 0;
-
- public void buttonClick(ClickEvent event) {
-
- gridLayout
- .addComponent(new TextField("Content " + (++counter)));
-
- }
- });
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket1772 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ Button b = new Button("Add content");
+ main.addComponent(b);
+
+ final GridLayout gridLayout = new GridLayout(2, 2);
+ main.addComponent(gridLayout);
+
+ b.addListener(new Button.ClickListener() {
+ int counter = 0;
+
+ public void buttonClick(ClickEvent event) {
+
+ gridLayout
+ .addComponent(new TextField("Content " + (++counter)));
+
+ }
+ });
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java
index f37737e929..de841288e8 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java
@@ -1,48 +1,48 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CustomLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class Ticket1775 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- final Window main = new Window("#1775");
- setMainWindow(main);
- main.setTheme("tests-tickets");
- String layoutName = "Ticket1775";
- final CustomLayout layout = new CustomLayout(layoutName);
-
- main.addComponent(layout);
-
- Button button2 = new Button("Populate content");
- main.addComponent(button2);
-
- final Button button = new Button("Change content");
- main.addComponent(button);
-
- button2.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Label mainComponent = new Label("Main");
- Label header = new Label("Header");
- final Label anotherComponent = new Label("another");
- layout.addComponent(mainComponent, "body");
- layout.addComponent(header, "loginUser");
- button.addListener(new Button.ClickListener() {
- public void buttonClick(Button.ClickEvent event) {
- layout.addComponent(anotherComponent, "body");
- layout.removeComponent("loginUser");
- }
- });
-
- }
- });
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class Ticket1775 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ final Window main = new Window("#1775");
+ setMainWindow(main);
+ main.setTheme("tests-tickets");
+ String layoutName = "Ticket1775";
+ final CustomLayout layout = new CustomLayout(layoutName);
+
+ main.addComponent(layout);
+
+ Button button2 = new Button("Populate content");
+ main.addComponent(button2);
+
+ final Button button = new Button("Change content");
+ main.addComponent(button);
+
+ button2.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Label mainComponent = new Label("Main");
+ Label header = new Label("Header");
+ final Label anotherComponent = new Label("another");
+ layout.addComponent(mainComponent, "body");
+ layout.addComponent(header, "loginUser");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(Button.ClickEvent event) {
+ layout.addComponent(anotherComponent, "body");
+ layout.removeComponent("loginUser");
+ }
+ });
+
+ }
+ });
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java
index 265f3041e9..e22fbe90ee 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java
@@ -1,150 +1,150 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import com.vaadin.data.Validator;
-import com.vaadin.data.util.MethodProperty;
-import com.vaadin.terminal.SystemError;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.Window;
-
-public class Ticket1804 extends com.vaadin.Application {
-
- LinkedList<Select> listOfAllFields = new LinkedList<Select>();
-
- @Override
- public void init() {
-
- final Window main = new Window("#1804");
- setMainWindow(main);
-
- com.vaadin.ui.Select s;
-
- s = new Select("Select with null selection allowed; required=true");
- s.setNullSelectionAllowed(true);
- s.setRequired(true);
- listOfAllFields.add(s);
-
- s = new Select("Select with null selection NOT allowed; required=true");
- s.setNullSelectionAllowed(false);
- s.setRequired(true);
- listOfAllFields.add(s);
-
- s = new Select("Testcase from the ticket #1804");
- s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
- s.addValidator(new EmptyStringValidator(
- "Selection required for test-field"));
- s.setRequired(true);
- listOfAllFields.add(s);
-
- s = new Select("Testcase from the ticket #1804, but without validator");
- s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
- s.setRequired(true);
- listOfAllFields.add(s);
-
- s = new Select(
- "Testcase from the ticket #1804, but with required=false");
- s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
- s.addValidator(new EmptyStringValidator(
- "Selection required for test-field"));
- listOfAllFields.add(s);
-
- s = new Select(
- "Testcase from the ticket #1804, but without validator and with required=false");
- s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
- listOfAllFields.add(s);
-
- s = new Select(
- "Required=true, custom error message, null selection not allowed");
- s.setRequired(true);
- s.setNullSelectionAllowed(false);
- s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
- s.setValue(null);
- s.setComponentError(new SystemError("Test error message"));
- listOfAllFields.add(s);
-
- for (Iterator<Select> i = listOfAllFields.iterator(); i.hasNext();) {
- s = i.next();
- main.addComponent(s);
- s.addItem("foo");
- s.addItem("");
- s.addItem("bar");
- if (s.isNullSelectionAllowed()) {
- s.addItem("<null>");
- s.setNullSelectionItemId("<null>");
- }
- s.setImmediate(true);
- }
-
- Button checkValidity = new Button("Check validity of the fields");
- main.addComponent(checkValidity);
- checkValidity.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- StringBuffer msg = new StringBuffer();
- for (Iterator<Select> i = listOfAllFields.iterator(); i
- .hasNext();) {
- AbstractField af = i.next();
- msg.append("<h1>" + af.getCaption() + "</h1>\n");
- msg.append("Value=" + af.getValue() + "<br/>\n");
- if (af.isValid()) {
- msg.append("VALID\n<hr/>");
- } else {
- msg.append("INVALID<br/><i>" + af.getErrorMessage()
- + "</i><hr/>");
- }
- }
- Window w = new Window("Status of the fields");
- w.setModal(true);
- w.setScrollable(true);
- w.setHeight("80%");
- w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
- main.addWindow(w);
- }
- });
- }
-
- public class TestPojo {
- String id = "";
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- }
-
- /** Throws an exception when the string is empty or null. */
- class EmptyStringValidator implements Validator {
-
- String msg;
-
- EmptyStringValidator(String msg) {
- this.msg = msg;
- }
-
- public boolean isValid(Object value) {
- return !(value == null || value.toString().length() == 0);
- }
-
- public void validate(Object value) throws InvalidValueException {
- if (!isValid(value)) {
- throw new InvalidValueException(msg);
- }
- }
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import com.vaadin.data.Validator;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.Window;
+
+public class Ticket1804 extends com.vaadin.Application {
+
+ LinkedList<Select> listOfAllFields = new LinkedList<Select>();
+
+ @Override
+ public void init() {
+
+ final Window main = new Window("#1804");
+ setMainWindow(main);
+
+ com.vaadin.ui.Select s;
+
+ s = new Select("Select with null selection allowed; required=true");
+ s.setNullSelectionAllowed(true);
+ s.setRequired(true);
+ listOfAllFields.add(s);
+
+ s = new Select("Select with null selection NOT allowed; required=true");
+ s.setNullSelectionAllowed(false);
+ s.setRequired(true);
+ listOfAllFields.add(s);
+
+ s = new Select("Testcase from the ticket #1804");
+ s.setNullSelectionAllowed(false);
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
+ s.addValidator(new EmptyStringValidator(
+ "Selection required for test-field"));
+ s.setRequired(true);
+ listOfAllFields.add(s);
+
+ s = new Select("Testcase from the ticket #1804, but without validator");
+ s.setNullSelectionAllowed(false);
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
+ s.setRequired(true);
+ listOfAllFields.add(s);
+
+ s = new Select(
+ "Testcase from the ticket #1804, but with required=false");
+ s.setNullSelectionAllowed(false);
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
+ s.addValidator(new EmptyStringValidator(
+ "Selection required for test-field"));
+ listOfAllFields.add(s);
+
+ s = new Select(
+ "Testcase from the ticket #1804, but without validator and with required=false");
+ s.setNullSelectionAllowed(false);
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
+ listOfAllFields.add(s);
+
+ s = new Select(
+ "Required=true, custom error message, null selection not allowed");
+ s.setRequired(true);
+ s.setNullSelectionAllowed(false);
+ s.setPropertyDataSource(new MethodProperty<String>(new TestPojo(), "id"));
+ s.setValue(null);
+ s.setComponentError(new SystemError("Test error message"));
+ listOfAllFields.add(s);
+
+ for (Iterator<Select> i = listOfAllFields.iterator(); i.hasNext();) {
+ s = i.next();
+ main.addComponent(s);
+ s.addItem("foo");
+ s.addItem("");
+ s.addItem("bar");
+ if (s.isNullSelectionAllowed()) {
+ s.addItem("<null>");
+ s.setNullSelectionItemId("<null>");
+ }
+ s.setImmediate(true);
+ }
+
+ Button checkValidity = new Button("Check validity of the fields");
+ main.addComponent(checkValidity);
+ checkValidity.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ StringBuffer msg = new StringBuffer();
+ for (Iterator<Select> i = listOfAllFields.iterator(); i
+ .hasNext();) {
+ AbstractField af = i.next();
+ msg.append("<h1>" + af.getCaption() + "</h1>\n");
+ msg.append("Value=" + af.getValue() + "<br/>\n");
+ if (af.isValid()) {
+ msg.append("VALID\n<hr/>");
+ } else {
+ msg.append("INVALID<br/><i>" + af.getErrorMessage()
+ + "</i><hr/>");
+ }
+ }
+ Window w = new Window("Status of the fields");
+ w.setModal(true);
+ w.setScrollable(true);
+ w.setHeight("80%");
+ w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
+ main.addWindow(w);
+ }
+ });
+ }
+
+ public class TestPojo {
+ String id = "";
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ }
+
+ /** Throws an exception when the string is empty or null. */
+ class EmptyStringValidator implements Validator {
+
+ String msg;
+
+ EmptyStringValidator(String msg) {
+ this.msg = msg;
+ }
+
+ public boolean isValid(Object value) {
+ return !(value == null || value.toString().length() == 0);
+ }
+
+ public void validate(Object value) throws InvalidValueException {
+ if (!isValid(value)) {
+ throw new InvalidValueException(msg);
+ }
+ }
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java
index ad7a61d81f..d2407aae39 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java
@@ -1,57 +1,57 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket1805 extends com.vaadin.Application {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
- ((Layout) main.getContent()).setMargin(false);
-
- Label description = new Label(
- "GridLayout with 100% (no height), is wanted to "
- + "share all available width with columns "
- + "relatively to their natural width. And it "
- + "should still work with margins and spacings");
- main.addComponent(description);
-
- final GridLayout grid = new GridLayout(4, 1);
-
- final TextField size = new TextField("Grid width in css unit");
- size.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- String width = size.getValue().toString();
- if (width == null || width.equals("")) {
- grid.setSizeUndefined();
- } else {
- grid.setWidth(width);
- }
- }
- });
- main.addComponent(size);
- main.addComponent(new Button("set size"));
-
- grid.setMargin(true);
- grid.setSpacing(true);
-
- grid.addComponent(new Label("WIDE"));
- grid.addComponent(new Label("_I_"));
- grid.addComponent(new Label("VEEEEEEEEEEERY_WIDE"));
- Label label = new Label("|");
- grid.addComponent(label);
- grid.setComponentAlignment(label, Alignment.TOP_RIGHT);
- main.addComponent(grid);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket1805 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+ ((Layout) main.getContent()).setMargin(false);
+
+ Label description = new Label(
+ "GridLayout with 100% (no height), is wanted to "
+ + "share all available width with columns "
+ + "relatively to their natural width. And it "
+ + "should still work with margins and spacings");
+ main.addComponent(description);
+
+ final GridLayout grid = new GridLayout(4, 1);
+
+ final TextField size = new TextField("Grid width in css unit");
+ size.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ String width = size.getValue().toString();
+ if (width == null || width.equals("")) {
+ grid.setSizeUndefined();
+ } else {
+ grid.setWidth(width);
+ }
+ }
+ });
+ main.addComponent(size);
+ main.addComponent(new Button("set size"));
+
+ grid.setMargin(true);
+ grid.setSpacing(true);
+
+ grid.addComponent(new Label("WIDE"));
+ grid.addComponent(new Label("_I_"));
+ grid.addComponent(new Label("VEEEEEEEEEEERY_WIDE"));
+ Label label = new Label("|");
+ grid.addComponent(label);
+ grid.setComponentAlignment(label, Alignment.TOP_RIGHT);
+ main.addComponent(grid);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java
index f3406a9155..c403a8242c 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java
@@ -1,45 +1,45 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket1806 extends com.vaadin.Application {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- final ObjectProperty<String> prop = new ObjectProperty<String>("");
- final TextField tf1 = new TextField(
- "Buffered TextField bound to ObjectProperty");
- tf1.setWriteThrough(false);
- tf1.setReadThrough(false);
- tf1.setPropertyDataSource(prop);
- main.addComponent(tf1);
- main.addComponent(new Button(
- "This button does nothing (but flushes queued variable changes)"));
- main.addComponent(new Button("Commit the field to property",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- tf1.commit();
- }
- }));
- main.addComponent(new Button("Show property value",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- main.showNotification("'" + prop.getValue() + "'");
- }
- }));
- main.addComponent(new Button("Show field value",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- main.showNotification("'" + tf1.getValue() + "'");
- }
- }));
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket1806 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ final ObjectProperty<String> prop = new ObjectProperty<String>("");
+ final TextField tf1 = new TextField(
+ "Buffered TextField bound to ObjectProperty");
+ tf1.setWriteThrough(false);
+ tf1.setReadThrough(false);
+ tf1.setPropertyDataSource(prop);
+ main.addComponent(tf1);
+ main.addComponent(new Button(
+ "This button does nothing (but flushes queued variable changes)"));
+ main.addComponent(new Button("Commit the field to property",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ tf1.commit();
+ }
+ }));
+ main.addComponent(new Button("Show property value",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ main.showNotification("'" + prop.getValue() + "'");
+ }
+ }));
+ main.addComponent(new Button("Show field value",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ main.showNotification("'" + tf1.getValue() + "'");
+ }
+ }));
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java
index 8f373de6bf..6cbf37541c 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java
@@ -1,78 +1,78 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import com.vaadin.data.Validator;
-import com.vaadin.data.validator.StringLengthValidator;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket1811 extends com.vaadin.Application {
-
- LinkedList<TextField> listOfAllFields = new LinkedList<TextField>();
-
- @Override
- public void init() {
-
- final Window main = new Window("#1811");
- setMainWindow(main);
-
- Validator strLenValidator = new StringLengthValidator(
- "String must be at least 3 chars long and non-null", 3, -1,
- false);
-
- TextField tf1 = new TextField(
- "Text field with default settings (required=false)");
- listOfAllFields.add(tf1);
-
- TextField tf2 = new TextField("Text field with required=true");
- tf2.setRequired(true);
- listOfAllFields.add(tf2);
-
- TextField tf3 = new TextField(
- "Text field with required=true and strlen >= 3");
- tf3.setRequired(true);
- tf3.addValidator(strLenValidator);
- listOfAllFields.add(tf3);
-
- TextField tf4 = new TextField(
- "Text field with required=false (default) and strlen >= 3");
- tf4.addValidator(strLenValidator);
- listOfAllFields.add(tf4);
-
- for (Iterator<TextField> i = listOfAllFields.iterator(); i.hasNext();) {
- TextField tf = i.next();
- main.addComponent(tf);
- tf.setImmediate(true);
- }
-
- Button checkValidity = new Button("Check validity of the fields");
- main.addComponent(checkValidity);
- checkValidity.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- StringBuffer msg = new StringBuffer();
- for (Iterator<TextField> i = listOfAllFields.iterator(); i
- .hasNext();) {
- TextField tf = i.next();
- msg.append("<h1>" + tf.getCaption() + "</h1>\n");
- if (tf.isValid()) {
- msg.append("VALID\n<hr/>");
- } else {
- msg.append("INVALID<br/><i>" + tf.getErrorMessage()
- + "</i><hr/>");
- }
- }
- Window w = new Window("Status of the fields");
- w.setModal(true);
- w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
- main.addWindow(w);
- }
- });
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import com.vaadin.data.Validator;
+import com.vaadin.data.validator.StringLengthValidator;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket1811 extends com.vaadin.Application {
+
+ LinkedList<TextField> listOfAllFields = new LinkedList<TextField>();
+
+ @Override
+ public void init() {
+
+ final Window main = new Window("#1811");
+ setMainWindow(main);
+
+ Validator strLenValidator = new StringLengthValidator(
+ "String must be at least 3 chars long and non-null", 3, -1,
+ false);
+
+ TextField tf1 = new TextField(
+ "Text field with default settings (required=false)");
+ listOfAllFields.add(tf1);
+
+ TextField tf2 = new TextField("Text field with required=true");
+ tf2.setRequired(true);
+ listOfAllFields.add(tf2);
+
+ TextField tf3 = new TextField(
+ "Text field with required=true and strlen >= 3");
+ tf3.setRequired(true);
+ tf3.addValidator(strLenValidator);
+ listOfAllFields.add(tf3);
+
+ TextField tf4 = new TextField(
+ "Text field with required=false (default) and strlen >= 3");
+ tf4.addValidator(strLenValidator);
+ listOfAllFields.add(tf4);
+
+ for (Iterator<TextField> i = listOfAllFields.iterator(); i.hasNext();) {
+ TextField tf = i.next();
+ main.addComponent(tf);
+ tf.setImmediate(true);
+ }
+
+ Button checkValidity = new Button("Check validity of the fields");
+ main.addComponent(checkValidity);
+ checkValidity.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ StringBuffer msg = new StringBuffer();
+ for (Iterator<TextField> i = listOfAllFields.iterator(); i
+ .hasNext();) {
+ TextField tf = i.next();
+ msg.append("<h1>" + tf.getCaption() + "</h1>\n");
+ if (tf.isValid()) {
+ msg.append("VALID\n<hr/>");
+ } else {
+ msg.append("INVALID<br/><i>" + tf.getErrorMessage()
+ + "</i><hr/>");
+ }
+ }
+ Window w = new Window("Status of the fields");
+ w.setModal(true);
+ w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
+ main.addWindow(w);
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java
index 6f06055fc4..97357d8d2c 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java
@@ -1,64 +1,64 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.Window;
-
-public class Ticket1819 extends com.vaadin.Application {
-
- LinkedList<Select> listOfAllFields = new LinkedList<Select>();
-
- @Override
- public void init() {
-
- final Window main = new Window("#1819");
- setMainWindow(main);
-
- com.vaadin.ui.Select s;
-
- s = new Select("Select with null selection allowed");
- s.setNullSelectionAllowed(true);
- listOfAllFields.add(s);
-
- s = new Select("Select with null selection NOT allowed");
- s.setNullSelectionAllowed(false);
- listOfAllFields.add(s);
-
- for (Iterator<Select> i = listOfAllFields.iterator(); i.hasNext();) {
- s = i.next();
- main.addComponent(s);
- s.addItem("-null-");
- s.addItem("");
- s.addItem("foo");
- s.addItem("bar");
- s.setNullSelectionItemId("-null-");
- s.setImmediate(true);
- }
-
- Button checkValidity = new Button("Check validity of the fields");
- main.addComponent(checkValidity);
- checkValidity.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- StringBuffer msg = new StringBuffer();
- for (Iterator<Select> i = listOfAllFields.iterator(); i
- .hasNext();) {
- AbstractField af = i.next();
- msg.append("<h1>" + af.getCaption() + "</h1>\n");
- msg.append("Value=" + af.getValue() + "<br/>\n");
- }
- Window w = new Window("Status of the fields");
- w.setModal(true);
- w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
- main.addWindow(w);
- }
- });
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.Window;
+
+public class Ticket1819 extends com.vaadin.Application {
+
+ LinkedList<Select> listOfAllFields = new LinkedList<Select>();
+
+ @Override
+ public void init() {
+
+ final Window main = new Window("#1819");
+ setMainWindow(main);
+
+ com.vaadin.ui.Select s;
+
+ s = new Select("Select with null selection allowed");
+ s.setNullSelectionAllowed(true);
+ listOfAllFields.add(s);
+
+ s = new Select("Select with null selection NOT allowed");
+ s.setNullSelectionAllowed(false);
+ listOfAllFields.add(s);
+
+ for (Iterator<Select> i = listOfAllFields.iterator(); i.hasNext();) {
+ s = i.next();
+ main.addComponent(s);
+ s.addItem("-null-");
+ s.addItem("");
+ s.addItem("foo");
+ s.addItem("bar");
+ s.setNullSelectionItemId("-null-");
+ s.setImmediate(true);
+ }
+
+ Button checkValidity = new Button("Check validity of the fields");
+ main.addComponent(checkValidity);
+ checkValidity.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ StringBuffer msg = new StringBuffer();
+ for (Iterator<Select> i = listOfAllFields.iterator(); i
+ .hasNext();) {
+ AbstractField af = i.next();
+ msg.append("<h1>" + af.getCaption() + "</h1>\n");
+ msg.append("Value=" + af.getValue() + "<br/>\n");
+ }
+ Window w = new Window("Status of the fields");
+ w.setModal(true);
+ w.addComponent(new Label(msg.toString(), Label.CONTENT_XHTML));
+ main.addWindow(w);
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
index 7c9104e750..824447b6a9 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java
@@ -1,89 +1,89 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket1834PanelScrolling extends com.vaadin.Application {
-
- private static final int ROWS = 50;
-
- private Label state = new Label("State");
-
- private Panel p;
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- HorizontalLayout currentState = new HorizontalLayout();
-
- currentState.addComponent(state);
- Button b = new Button("update");
- currentState.addComponent(b);
- b.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- state.setValue("ScrollTop: " + p.getScrollTop()
- + " ScrollLeft: " + p.getScrollLeft());
- }
- });
- main.addComponent(currentState);
-
- b = new Button("ScrollBy 50px");
- b.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- p.setScrollLeft(p.getScrollLeft() + 50);
- p.setScrollTop(p.getScrollTop() + 50);
- state.setValue("ScrollTop: " + p.getScrollTop()
- + " ScrollLeft: " + p.getScrollLeft());
- }
- });
-
- main.addComponent(b);
-
- b = new Button("Add row");
- b.addListener(new ClickListener() {
- int i = 0;
-
- public void buttonClick(ClickEvent event) {
- p.addComponent(new Label("new Row" + ++i));
- }
- });
-
- main.addComponent(b);
-
- b = new Button("Repaint Panel");
- b.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- p.requestRepaint();
- }
- });
-
- main.addComponent(b);
-
- p = new Panel("TestPanel");
- p.setScrollable(true);
-
- for (int i = 0; i < ROWS; i++) {
- p.addComponent(new Label(
- "Label"
- + i
- + "................................................................................................................."));
- }
-
- p.setHeight("300px");
- p.setWidth("250px");
-
- p.setScrollTop(100);
- p.setScrollLeft(100);
-
- main.addComponent(p);
-
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket1834PanelScrolling extends com.vaadin.Application {
+
+ private static final int ROWS = 50;
+
+ private Label state = new Label("State");
+
+ private Panel p;
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ HorizontalLayout currentState = new HorizontalLayout();
+
+ currentState.addComponent(state);
+ Button b = new Button("update");
+ currentState.addComponent(b);
+ b.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ state.setValue("ScrollTop: " + p.getScrollTop()
+ + " ScrollLeft: " + p.getScrollLeft());
+ }
+ });
+ main.addComponent(currentState);
+
+ b = new Button("ScrollBy 50px");
+ b.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ p.setScrollLeft(p.getScrollLeft() + 50);
+ p.setScrollTop(p.getScrollTop() + 50);
+ state.setValue("ScrollTop: " + p.getScrollTop()
+ + " ScrollLeft: " + p.getScrollLeft());
+ }
+ });
+
+ main.addComponent(b);
+
+ b = new Button("Add row");
+ b.addListener(new ClickListener() {
+ int i = 0;
+
+ public void buttonClick(ClickEvent event) {
+ p.addComponent(new Label("new Row" + ++i));
+ }
+ });
+
+ main.addComponent(b);
+
+ b = new Button("Repaint Panel");
+ b.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ p.requestRepaint();
+ }
+ });
+
+ main.addComponent(b);
+
+ p = new Panel("TestPanel");
+ p.setScrollable(true);
+
+ for (int i = 0; i < ROWS; i++) {
+ p.addComponent(new Label(
+ "Label"
+ + i
+ + "................................................................................................................."));
+ }
+
+ p.setHeight("300px");
+ p.setWidth("250px");
+
+ p.setScrollTop(100);
+ p.setScrollLeft(100);
+
+ main.addComponent(p);
+
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java
index edf9c1207d..fe32dbc775 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java
@@ -1,20 +1,20 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket1868 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- setMainWindow(new Window("#1868"));
-
- Panel p = new Panel(
- "This is a really long caption for the panel, too long in fact!");
- p.setWidth("300px");
- p.setHeight("300px");
-
- getMainWindow().addComponent(p);
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket1868 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ setMainWindow(new Window("#1868"));
+
+ Panel p = new Panel(
+ "This is a really long caption for the panel, too long in fact!");
+ p.setWidth("300px");
+ p.setHeight("300px");
+
+ getMainWindow().addComponent(p);
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java
index 953217f907..9c2fdb762d 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java
@@ -1,55 +1,55 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1869 extends com.vaadin.Application {
-
- @Override
- public void init() {
-
- GridLayout lo = new GridLayout(2, 1);
- setMainWindow(new Window("#1869", lo));
- lo.setMargin(true);
- lo.setSpacing(true);
-
- VerticalLayout el = new VerticalLayout();
- Panel elp = new Panel(
- "Vertical ExpandLayout /w first component expanded", el);
- el.setHeight("1000px");
- for (int i = 0; i < 3; i++) {
- Button b = new Button("x");
- el.addComponent(b);
- if (i == 0) {
- b.setSizeFull();
- el.setExpandRatio(b, 1);
- }
- }
- lo.addComponent(elp);
- elp.setWidth("300px");
- elp.setHeight("300px");
- elp.setScrollable(true);
-
- HorizontalLayout elh = new HorizontalLayout();
- Panel elph = new Panel(
- "Horizontal ExpandLayout /w first component expanded", elh);
- elh.setWidth("1000px");
- for (int i = 0; i < 3; i++) {
- Button b = new Button("x");
- elh.addComponent(b);
- if (i == 0) {
- b.setSizeFull();
- elh.setExpandRatio(b, 1);
- }
- }
- lo.addComponent(elph);
- elph.setWidth("300px");
- elph.setHeight("300px");
- elph.setScrollable(true);
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1869 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+
+ GridLayout lo = new GridLayout(2, 1);
+ setMainWindow(new Window("#1869", lo));
+ lo.setMargin(true);
+ lo.setSpacing(true);
+
+ VerticalLayout el = new VerticalLayout();
+ Panel elp = new Panel(
+ "Vertical ExpandLayout /w first component expanded", el);
+ el.setHeight("1000px");
+ for (int i = 0; i < 3; i++) {
+ Button b = new Button("x");
+ el.addComponent(b);
+ if (i == 0) {
+ b.setSizeFull();
+ el.setExpandRatio(b, 1);
+ }
+ }
+ lo.addComponent(elp);
+ elp.setWidth("300px");
+ elp.setHeight("300px");
+ elp.setScrollable(true);
+
+ HorizontalLayout elh = new HorizontalLayout();
+ Panel elph = new Panel(
+ "Horizontal ExpandLayout /w first component expanded", elh);
+ elh.setWidth("1000px");
+ for (int i = 0; i < 3; i++) {
+ Button b = new Button("x");
+ elh.addComponent(b);
+ if (i == 0) {
+ b.setSizeFull();
+ elh.setExpandRatio(b, 1);
+ }
+ }
+ lo.addComponent(elph);
+ elph.setWidth("300px");
+ elph.setHeight("300px");
+ elph.setScrollable(true);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java
index 0bb631aab5..0cacb603fc 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java
@@ -1,384 +1,384 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Random;
-
-import com.vaadin.Application;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.data.validator.StringLengthValidator;
-import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1878 extends Application {
-
- private Layout orderedLayout;
- private Layout gridLayout;
- private Layout formLayout;
- private GridLayout mainLayout;
- private Button switchToGridButton;
- private Button switchToOrderedButton;
- private Button switchToFormsButton;
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
-
- mainLayout = new GridLayout(1, 2);
- w.setContent(mainLayout);
- orderedLayout = createOL();
- gridLayout = createGL();
- formLayout = createForms();
-
- switchToGridButton = new Button("Switch to GridLayout",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- changeLayout(switchToGridButton, gridLayout);
- }
-
- });
- switchToOrderedButton = new Button("Switch to OrderedLayout",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- changeLayout(switchToOrderedButton, orderedLayout);
- }
-
- });
- switchToOrderedButton.setEnabled(false);
-
- switchToFormsButton = new Button("Switch to Form", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- changeLayout(switchToFormsButton, formLayout);
- }
-
- });
-
- HorizontalLayout buttonLayout = new HorizontalLayout();
- buttonLayout.addComponent(switchToOrderedButton);
- buttonLayout.addComponent(switchToGridButton);
- buttonLayout.addComponent(switchToFormsButton);
-
- mainLayout.addComponent(buttonLayout);
- mainLayout.addComponent(orderedLayout);
- // w.setContent(orderedLayout);
- }
-
- private static Layout createOL() {
- GridLayout layout = new GridLayout(1, 5);
-
- GridLayout l1 = new GridLayout(1, 3);
- createLayout(l1, new HorizontalLayout(), "1000px", "150px", "100%",
- null, true);
- createLayout(l1, new HorizontalLayout(), "1000px", "150px", "50px",
- null, false);
- GridLayout l2 = new GridLayout(6, 1);
- createLayout(l2, new VerticalLayout(), "200px", "500px", true);
- createLayout(l2, new VerticalLayout(), "200px", "500px", "100%", null,
- true);
- createLayout(l2, new VerticalLayout(), "150px", "500px", true);
- createLayout(l2, new VerticalLayout(), "150px", "500px", "100%", null,
- true);
- createLayout(l2, new VerticalLayout(), "100px", "500px", true);
- createLayout(l2, new VerticalLayout(), "100px", "500px", "100%", null,
- true);
- layout.addComponent(l1);
- layout.addComponent(l2);
-
- return layout;
- }
-
- private static Layout createGL() {
- GridLayout layout = new GridLayout(1, 5);
-
- GridLayout l1 = new GridLayout(1, 3);
- createLayout(l1, new GridLayout(8, 1), "1000px", "150px", "100%", null,
- true);
- createLayout(l1, new GridLayout(8, 1), "1000px", "150px", "50px", null,
- false);
- GridLayout l2 = new GridLayout(6, 1);
- createLayout(l2, new GridLayout(1, 8), "200px", "500px", true);
- createLayout(l2, new GridLayout(1, 8), "200px", "500px", "100%", null,
- true);
- createLayout(l2, new GridLayout(1, 8), "150px", "500px", true);
- createLayout(l2, new GridLayout(1, 8), "150px", "500px", "100%", null,
- true);
- createLayout(l2, new GridLayout(1, 8), "100px", "500px", true);
- createLayout(l2, new GridLayout(1, 8), "100px", "500px", "100%", null,
- true);
- layout.addComponent(l1);
- layout.addComponent(l2);
-
- return layout;
- }
-
- public class FormObject {
- private String stringValue = "abc";
- private int intValue = 1;
- private long longValue = 2L;
- private Date dateValue = new Date(34587034750L);
-
- public String getStringValue() {
- return stringValue;
- }
-
- public void setStringValue(String stringValue) {
- this.stringValue = stringValue;
- }
-
- public int getIntValue() {
- return intValue;
- }
-
- public void setIntValue(int intValue) {
- this.intValue = intValue;
- }
-
- public long getLongValue() {
- return longValue;
- }
-
- public void setLongValue(long longValue) {
- this.longValue = longValue;
- }
-
- public Date getDateValue() {
- return dateValue;
- }
-
- public void setDateValue(Date dateValue) {
- this.dateValue = dateValue;
- }
-
- }
-
- private Layout createForms() {
- GridLayout layout = new GridLayout(1, 5);
- Form form;
-
- Random r = new Random();
- GridLayout l1 = new GridLayout(1, 3);
- form = createForm(l1, "200px", "500px");
- BeanItem<FormObject> item = new BeanItem<FormObject>(new FormObject());
- form.setItemDataSource(item);
- for (Iterator<?> i = item.getItemPropertyIds().iterator(); i.hasNext();) {
- Object property = i.next();
- Field f = form.getField(property);
-
- f.setRequired(r.nextBoolean());
- if (r.nextBoolean()) {
- f.setIcon(new ThemeResource("icons/16/document-add.png"));
- }
- if (r.nextBoolean()) {
- f.setCaption(null);
- }
-
- f.addValidator(new StringLengthValidator("Error", 10, 8, false));
- }
- // createLayout(l1, new
- // ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL),
- // "1000px", "150px", "50px", null, false);
-
- // GridLayout l2 = new GridLayout(6, 1);
- // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
- // "200px", "500px", true);
- // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
- // "200px", "500px", "100%", null, true);
- // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
- // "150px", "500px", true);
- // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
- // "150px", "500px", "100%", null, true);
- // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
- // "100px", "500px", true);
- // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
- // "100px", "500px", "100%", null, true);
- layout.addComponent(l1);
- // layout.addComponent(l2);
-
- return layout;
- }
-
- private Form createForm(GridLayout parentLayout, String w, String h) {
- FormLayout formLayout = new FormLayout();
- Form form = new Form(formLayout);
-
- Panel p = new Panel("Form " + w + "x" + h);
-
- p.setWidth(w);
- p.setHeight(h);
-
- p.getContent().setSizeFull();
-
- parentLayout.addComponent(p);
- p.addComponent(form);
- formLayout.setSizeFull();
-
- return form;
- }
-
- protected void changeLayout(Button b, Layout newLayout) {
- switchToOrderedButton.setEnabled(true);
- switchToGridButton.setEnabled(true);
- switchToFormsButton.setEnabled(true);
-
- b.setEnabled(false);
- Iterator<Component> i = mainLayout.getComponentIterator();
- i.next();
- Layout l = (Layout) i.next();
-
- mainLayout.replaceComponent(l, newLayout);
- }
-
- private static void createLayout(GridLayout parentLayout, Layout newLayout,
- String w, String h, boolean align) {
- createLayout(parentLayout, newLayout, w, h, null, null, align);
- }
-
- private static void createLayout(GridLayout parentLayout, Layout newLayout,
- String w, String h, String componentWidth, String componentHeight,
- boolean align) {
- String dirText = "V";
- String type;
- if (newLayout instanceof VerticalLayout) {
- type = "OL";
- } else if (newLayout instanceof HorizontalLayout) {
- dirText = "H";
- type = "OL";
- } else {
- if (((GridLayout) newLayout).getColumns() != 1) {
- dirText = "H";
- }
- type = "GL";
- }
- String alignText = align ? "-A" : "";
- String cWidth = componentWidth == null ? "" : " - " + componentWidth;
- Panel p = new Panel(type + "/" + dirText + alignText + " " + w + "x"
- + h + cWidth, newLayout);
-
- p.setWidth(w);
- p.setHeight(h);
-
- newLayout.setSizeFull();
-
- String captions[] = new String[] { "TextField with caption", null };
- Resource icons[] = new Resource[] {
- new ThemeResource("icons/16/document-delete.png"), null };
- boolean required[] = new boolean[] { true, false };
- TextField fields[][] = new TextField[captions.length][icons.length];
- for (int caption = 0; caption < captions.length; caption++) {
- for (int icon = 0; icon < icons.length; icon++) {
- for (int req = 0; req < required.length; req++) {
- TextField tf = createTextFieldWithError(captions[caption],
- icons[icon], required[req]);
-
- fields[caption][icon] = tf;
- if (componentWidth != null) {
- tf.setWidth(componentWidth);
- tf.setValue(tf.getValue() + " w:" + componentWidth);
- }
-
- if (componentHeight != null) {
- tf.setHeight(componentWidth);
- tf.setValue(tf.getValue() + " h:" + componentHeight);
- }
-
- p.addComponent(tf);
-
- if (align) {
- ((AlignmentHandler) newLayout).setComponentAlignment(
- tf, Alignment.BOTTOM_RIGHT);
- }
- }
- }
- }
-
- parentLayout.addComponent(p);
-
- }
-
- // private static void createGridLayout(GridLayout parentLayout, int dir,
- // String w, String h) {
- // createGridLayout(parentLayout, dir, w, h, null, null);
- // }
-
- // private static void createGridLayout(GridLayout parentLayout, int dir,
- // String w, String h, String componentWidth, String componentHeight) {
- // GridLayout gl;
- // if (dir == OrderedLayout.ORIENTATION_HORIZONTAL) {
- // gl = new GridLayout(8, 1);
- // } else {
- // gl = new GridLayout(1, 8);
- // }
- //
- // String dirText = (dir == OrderedLayout.ORIENTATION_HORIZONTAL ? "H"
- // : "V");
- // String cWidth = componentWidth == null ? "" : " - " + componentWidth;
- // Panel p = new Panel("GL/" + dirText + " " + w + "x" + h + cWidth, gl);
- //
- // p.setWidth(w);
- // p.setHeight(h);
- //
- // gl.setSizeFull();
- //
- // String captions[] = new String[] { "TextField with caption", null };
- // Resource icons[] = new Resource[] {
- // new ThemeResource("icons/16/document-delete.png"), null };
- // boolean required[] = new boolean[] { true, false };
- // TextField fields[][] = new TextField[captions.length][icons.length];
- // for (int caption = 0; caption < captions.length; caption++) {
- // for (int icon = 0; icon < icons.length; icon++) {
- // for (int req = 0; req < required.length; req++) {
- // TextField tf = createTextFieldWithError(captions[caption],
- // icons[icon], required[req]);
- //
- // fields[caption][icon] = tf;
- // if (componentWidth != null) {
- // tf.setWidth(componentWidth);
- // }
- //
- // if (componentHeight != null) {
- // tf.setHeight(componentWidth);
- // }
- //
- // p.addComponent(tf);
- // gl.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_LEFT,
- // OrderedLayout.ALIGNMENT_BOTTOM);
- // }
- // }
- // }
- //
- // parentLayout.addComponent(p);
- //
- // }
-
- private static TextField createTextFieldWithError(String caption,
- Resource icon, boolean required) {
- TextField tf = new TextField();
- tf.setCaption(caption);
- tf.setIcon(icon);
- tf.setRequired(required);
- tf.setComponentError(new UserError("Test error message"));
- return tf;
- }
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Random;
+
+import com.vaadin.Application;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.validator.StringLengthValidator;
+import com.vaadin.terminal.Resource;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.AlignmentHandler;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1878 extends Application {
+
+ private Layout orderedLayout;
+ private Layout gridLayout;
+ private Layout formLayout;
+ private GridLayout mainLayout;
+ private Button switchToGridButton;
+ private Button switchToOrderedButton;
+ private Button switchToFormsButton;
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+
+ mainLayout = new GridLayout(1, 2);
+ w.setContent(mainLayout);
+ orderedLayout = createOL();
+ gridLayout = createGL();
+ formLayout = createForms();
+
+ switchToGridButton = new Button("Switch to GridLayout",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ changeLayout(switchToGridButton, gridLayout);
+ }
+
+ });
+ switchToOrderedButton = new Button("Switch to OrderedLayout",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ changeLayout(switchToOrderedButton, orderedLayout);
+ }
+
+ });
+ switchToOrderedButton.setEnabled(false);
+
+ switchToFormsButton = new Button("Switch to Form", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ changeLayout(switchToFormsButton, formLayout);
+ }
+
+ });
+
+ HorizontalLayout buttonLayout = new HorizontalLayout();
+ buttonLayout.addComponent(switchToOrderedButton);
+ buttonLayout.addComponent(switchToGridButton);
+ buttonLayout.addComponent(switchToFormsButton);
+
+ mainLayout.addComponent(buttonLayout);
+ mainLayout.addComponent(orderedLayout);
+ // w.setContent(orderedLayout);
+ }
+
+ private static Layout createOL() {
+ GridLayout layout = new GridLayout(1, 5);
+
+ GridLayout l1 = new GridLayout(1, 3);
+ createLayout(l1, new HorizontalLayout(), "1000px", "150px", "100%",
+ null, true);
+ createLayout(l1, new HorizontalLayout(), "1000px", "150px", "50px",
+ null, false);
+ GridLayout l2 = new GridLayout(6, 1);
+ createLayout(l2, new VerticalLayout(), "200px", "500px", true);
+ createLayout(l2, new VerticalLayout(), "200px", "500px", "100%", null,
+ true);
+ createLayout(l2, new VerticalLayout(), "150px", "500px", true);
+ createLayout(l2, new VerticalLayout(), "150px", "500px", "100%", null,
+ true);
+ createLayout(l2, new VerticalLayout(), "100px", "500px", true);
+ createLayout(l2, new VerticalLayout(), "100px", "500px", "100%", null,
+ true);
+ layout.addComponent(l1);
+ layout.addComponent(l2);
+
+ return layout;
+ }
+
+ private static Layout createGL() {
+ GridLayout layout = new GridLayout(1, 5);
+
+ GridLayout l1 = new GridLayout(1, 3);
+ createLayout(l1, new GridLayout(8, 1), "1000px", "150px", "100%", null,
+ true);
+ createLayout(l1, new GridLayout(8, 1), "1000px", "150px", "50px", null,
+ false);
+ GridLayout l2 = new GridLayout(6, 1);
+ createLayout(l2, new GridLayout(1, 8), "200px", "500px", true);
+ createLayout(l2, new GridLayout(1, 8), "200px", "500px", "100%", null,
+ true);
+ createLayout(l2, new GridLayout(1, 8), "150px", "500px", true);
+ createLayout(l2, new GridLayout(1, 8), "150px", "500px", "100%", null,
+ true);
+ createLayout(l2, new GridLayout(1, 8), "100px", "500px", true);
+ createLayout(l2, new GridLayout(1, 8), "100px", "500px", "100%", null,
+ true);
+ layout.addComponent(l1);
+ layout.addComponent(l2);
+
+ return layout;
+ }
+
+ public class FormObject {
+ private String stringValue = "abc";
+ private int intValue = 1;
+ private long longValue = 2L;
+ private Date dateValue = new Date(34587034750L);
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public long getLongValue() {
+ return longValue;
+ }
+
+ public void setLongValue(long longValue) {
+ this.longValue = longValue;
+ }
+
+ public Date getDateValue() {
+ return dateValue;
+ }
+
+ public void setDateValue(Date dateValue) {
+ this.dateValue = dateValue;
+ }
+
+ }
+
+ private Layout createForms() {
+ GridLayout layout = new GridLayout(1, 5);
+ Form form;
+
+ Random r = new Random();
+ GridLayout l1 = new GridLayout(1, 3);
+ form = createForm(l1, "200px", "500px");
+ BeanItem<FormObject> item = new BeanItem<FormObject>(new FormObject());
+ form.setItemDataSource(item);
+ for (Iterator<?> i = item.getItemPropertyIds().iterator(); i.hasNext();) {
+ Object property = i.next();
+ Field f = form.getField(property);
+
+ f.setRequired(r.nextBoolean());
+ if (r.nextBoolean()) {
+ f.setIcon(new ThemeResource("icons/16/document-add.png"));
+ }
+ if (r.nextBoolean()) {
+ f.setCaption(null);
+ }
+
+ f.addValidator(new StringLengthValidator("Error", 10, 8, false));
+ }
+ // createLayout(l1, new
+ // ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL),
+ // "1000px", "150px", "50px", null, false);
+
+ // GridLayout l2 = new GridLayout(6, 1);
+ // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
+ // "200px", "500px", true);
+ // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
+ // "200px", "500px", "100%", null, true);
+ // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
+ // "150px", "500px", true);
+ // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
+ // "150px", "500px", "100%", null, true);
+ // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
+ // "100px", "500px", true);
+ // createLayout(l2, new ExpandLayout(ExpandLayout.ORIENTATION_VERTICAL),
+ // "100px", "500px", "100%", null, true);
+ layout.addComponent(l1);
+ // layout.addComponent(l2);
+
+ return layout;
+ }
+
+ private Form createForm(GridLayout parentLayout, String w, String h) {
+ FormLayout formLayout = new FormLayout();
+ Form form = new Form(formLayout);
+
+ Panel p = new Panel("Form " + w + "x" + h);
+
+ p.setWidth(w);
+ p.setHeight(h);
+
+ p.getContent().setSizeFull();
+
+ parentLayout.addComponent(p);
+ p.addComponent(form);
+ formLayout.setSizeFull();
+
+ return form;
+ }
+
+ protected void changeLayout(Button b, Layout newLayout) {
+ switchToOrderedButton.setEnabled(true);
+ switchToGridButton.setEnabled(true);
+ switchToFormsButton.setEnabled(true);
+
+ b.setEnabled(false);
+ Iterator<Component> i = mainLayout.getComponentIterator();
+ i.next();
+ Layout l = (Layout) i.next();
+
+ mainLayout.replaceComponent(l, newLayout);
+ }
+
+ private static void createLayout(GridLayout parentLayout, Layout newLayout,
+ String w, String h, boolean align) {
+ createLayout(parentLayout, newLayout, w, h, null, null, align);
+ }
+
+ private static void createLayout(GridLayout parentLayout, Layout newLayout,
+ String w, String h, String componentWidth, String componentHeight,
+ boolean align) {
+ String dirText = "V";
+ String type;
+ if (newLayout instanceof VerticalLayout) {
+ type = "OL";
+ } else if (newLayout instanceof HorizontalLayout) {
+ dirText = "H";
+ type = "OL";
+ } else {
+ if (((GridLayout) newLayout).getColumns() != 1) {
+ dirText = "H";
+ }
+ type = "GL";
+ }
+ String alignText = align ? "-A" : "";
+ String cWidth = componentWidth == null ? "" : " - " + componentWidth;
+ Panel p = new Panel(type + "/" + dirText + alignText + " " + w + "x"
+ + h + cWidth, newLayout);
+
+ p.setWidth(w);
+ p.setHeight(h);
+
+ newLayout.setSizeFull();
+
+ String captions[] = new String[] { "TextField with caption", null };
+ Resource icons[] = new Resource[] {
+ new ThemeResource("icons/16/document-delete.png"), null };
+ boolean required[] = new boolean[] { true, false };
+ TextField fields[][] = new TextField[captions.length][icons.length];
+ for (int caption = 0; caption < captions.length; caption++) {
+ for (int icon = 0; icon < icons.length; icon++) {
+ for (int req = 0; req < required.length; req++) {
+ TextField tf = createTextFieldWithError(captions[caption],
+ icons[icon], required[req]);
+
+ fields[caption][icon] = tf;
+ if (componentWidth != null) {
+ tf.setWidth(componentWidth);
+ tf.setValue(tf.getValue() + " w:" + componentWidth);
+ }
+
+ if (componentHeight != null) {
+ tf.setHeight(componentWidth);
+ tf.setValue(tf.getValue() + " h:" + componentHeight);
+ }
+
+ p.addComponent(tf);
+
+ if (align) {
+ ((AlignmentHandler) newLayout).setComponentAlignment(
+ tf, Alignment.BOTTOM_RIGHT);
+ }
+ }
+ }
+ }
+
+ parentLayout.addComponent(p);
+
+ }
+
+ // private static void createGridLayout(GridLayout parentLayout, int dir,
+ // String w, String h) {
+ // createGridLayout(parentLayout, dir, w, h, null, null);
+ // }
+
+ // private static void createGridLayout(GridLayout parentLayout, int dir,
+ // String w, String h, String componentWidth, String componentHeight) {
+ // GridLayout gl;
+ // if (dir == OrderedLayout.ORIENTATION_HORIZONTAL) {
+ // gl = new GridLayout(8, 1);
+ // } else {
+ // gl = new GridLayout(1, 8);
+ // }
+ //
+ // String dirText = (dir == OrderedLayout.ORIENTATION_HORIZONTAL ? "H"
+ // : "V");
+ // String cWidth = componentWidth == null ? "" : " - " + componentWidth;
+ // Panel p = new Panel("GL/" + dirText + " " + w + "x" + h + cWidth, gl);
+ //
+ // p.setWidth(w);
+ // p.setHeight(h);
+ //
+ // gl.setSizeFull();
+ //
+ // String captions[] = new String[] { "TextField with caption", null };
+ // Resource icons[] = new Resource[] {
+ // new ThemeResource("icons/16/document-delete.png"), null };
+ // boolean required[] = new boolean[] { true, false };
+ // TextField fields[][] = new TextField[captions.length][icons.length];
+ // for (int caption = 0; caption < captions.length; caption++) {
+ // for (int icon = 0; icon < icons.length; icon++) {
+ // for (int req = 0; req < required.length; req++) {
+ // TextField tf = createTextFieldWithError(captions[caption],
+ // icons[icon], required[req]);
+ //
+ // fields[caption][icon] = tf;
+ // if (componentWidth != null) {
+ // tf.setWidth(componentWidth);
+ // }
+ //
+ // if (componentHeight != null) {
+ // tf.setHeight(componentWidth);
+ // }
+ //
+ // p.addComponent(tf);
+ // gl.setComponentAlignment(tf, OrderedLayout.ALIGNMENT_LEFT,
+ // OrderedLayout.ALIGNMENT_BOTTOM);
+ // }
+ // }
+ // }
+ //
+ // parentLayout.addComponent(p);
+ //
+ // }
+
+ private static TextField createTextFieldWithError(String caption,
+ Resource icon, boolean required) {
+ TextField tf = new TextField();
+ tf.setCaption(caption);
+ tf.setIcon(icon);
+ tf.setRequired(required);
+ tf.setComponentError(new UserError("Test error message"));
+ return tf;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java
index 1e578cd8f5..70bc0e1211 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java
@@ -1,53 +1,53 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket1919 extends com.vaadin.Application {
-
- private GridLayout lo;
- private boolean on = true;
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- main.setTheme("tests-tickets");
-
- lo = new GridLayout(2, 2);
- lo.setSizeFull();
- lo.setMargin(true);
- lo.setSpacing(true);
-
- lo.addComponent(getTestComponent());
- lo.addComponent(getTestComponent());
- lo.addComponent(getTestComponent());
- lo.addComponent(getTestComponent());
-
- main.setContent(lo);
-
- }
-
- public void toggleStyleName() {
- if (on) {
- lo.setStyleName("test");
- } else {
- lo.setStyleName("");
- }
- on = !on;
- }
-
- private Component getTestComponent() {
- Panel p = new Panel();
- p.setSizeFull();
-
- Button b = new Button("toggle Values", this, "toggleStyleName");
- p.addComponent(b);
- return p;
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket1919 extends com.vaadin.Application {
+
+ private GridLayout lo;
+ private boolean on = true;
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ main.setTheme("tests-tickets");
+
+ lo = new GridLayout(2, 2);
+ lo.setSizeFull();
+ lo.setMargin(true);
+ lo.setSpacing(true);
+
+ lo.addComponent(getTestComponent());
+ lo.addComponent(getTestComponent());
+ lo.addComponent(getTestComponent());
+ lo.addComponent(getTestComponent());
+
+ main.setContent(lo);
+
+ }
+
+ public void toggleStyleName() {
+ if (on) {
+ lo.setStyleName("test");
+ } else {
+ lo.setStyleName("");
+ }
+ on = !on;
+ }
+
+ private Component getTestComponent() {
+ Panel p = new Panel();
+ p.setSizeFull();
+
+ Button b = new Button("toggle Values", this, "toggleStyleName");
+ p.addComponent(b);
+ return p;
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java
index 9fc0ecc586..9ea952a2b5 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java
@@ -1,80 +1,80 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1923 extends com.vaadin.Application {
-
- private static final int ROWS = 50;
-
- private Panel p;
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- p = new Panel("TestPanel 250x300");
- // p.getLayout().setWidth("100%");
- p.setScrollable(true);
- // p.setContent(new GridLayout(1, 100));
- for (int i = 0; i < ROWS; i++) {
- p.addComponent(new Label(
- "Label"
- + i
- + " 5067w09adsfasdjfahlsdfjhalfjhaldjfhalsjdfhlajdhflajhdfljahdslfjahldsjfhaljdfhaljfdhlajsdhflajshdflkajhsdlfkjahsldfkjahsldfhalskjfdhlksjfdh857idifhaljsdfhlajsdhflajhdflajhdfljahldfjhaljdfhalsjdfhalkjdhflkajhdfljahsdlfjahlsdjfhaldjfhaljfdhlajdhflajshdfljahsdlfjhalsjdfhalskjhfdlhusfglksuhdflgjshflgjhslfghslfjghsljfglsjhfglsjhfgljshfgljshflgjhslfghsljfgsljdfglsdjhfglsjhflgkjshfldjgh"));
- }
- // main.getLayout().setSizeFull();
-
- p.setHeight("300px");
- p.setWidth("250px");
- // p.setWidth("50%");
-
- p.setScrollTop(100);
- p.setScrollLeft(100);
-
- main.addComponent(p);
-
- VerticalLayout ol = new VerticalLayout();
- p = new Panel("a");
- p.addComponent(new Label("Longer than caption"));
- ol.addComponent(p);
-
- main.addComponent(ol);
-
- ol = new VerticalLayout();
- p = new Panel("captionasdfjahsdjfh this should be clipped god damn it");
- // p.getLayout().setSizeFull();
- p.setWidth("50px");
- p.setHeight("100px");
- p.addComponent(new Label(
- "aasdfaasdfja dslkfj lakfdj lakjdf lkaj dflkaj ldfkj alsdfj laksdj flkajs dflkj sdfsadfasdfasd"));
- ol.addComponent(p);
-
- main.addComponent(ol);
-
- ol = new VerticalLayout();
- p = new Panel("300x-1");
- // p.getLayout().setSizeFull();
- p.setWidth("300px");
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- p.addComponent(new Label("Short"));
- ol.addComponent(p);
-
- main.addComponent(ol);
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1923 extends com.vaadin.Application {
+
+ private static final int ROWS = 50;
+
+ private Panel p;
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ p = new Panel("TestPanel 250x300");
+ // p.getLayout().setWidth("100%");
+ p.setScrollable(true);
+ // p.setContent(new GridLayout(1, 100));
+ for (int i = 0; i < ROWS; i++) {
+ p.addComponent(new Label(
+ "Label"
+ + i
+ + " 5067w09adsfasdjfahlsdfjhalfjhaldjfhalsjdfhlajdhflajhdfljahdslfjahldsjfhaljdfhaljfdhlajsdhflajshdflkajhsdlfkjahsldfkjahsldfhalskjfdhlksjfdh857idifhaljsdfhlajsdhflajhdflajhdfljahldfjhaljdfhalsjdfhalkjdhflkajhdfljahsdlfjahlsdjfhaldjfhaljfdhlajdhflajshdfljahsdlfjhalsjdfhalskjhfdlhusfglksuhdflgjshflgjhslfghslfjghsljfglsjhfglsjhfgljshfgljshflgjhslfghsljfgsljdfglsdjhfglsjhflgkjshfldjgh"));
+ }
+ // main.getLayout().setSizeFull();
+
+ p.setHeight("300px");
+ p.setWidth("250px");
+ // p.setWidth("50%");
+
+ p.setScrollTop(100);
+ p.setScrollLeft(100);
+
+ main.addComponent(p);
+
+ VerticalLayout ol = new VerticalLayout();
+ p = new Panel("a");
+ p.addComponent(new Label("Longer than caption"));
+ ol.addComponent(p);
+
+ main.addComponent(ol);
+
+ ol = new VerticalLayout();
+ p = new Panel("captionasdfjahsdjfh this should be clipped god damn it");
+ // p.getLayout().setSizeFull();
+ p.setWidth("50px");
+ p.setHeight("100px");
+ p.addComponent(new Label(
+ "aasdfaasdfja dslkfj lakfdj lakjdf lkaj dflkaj ldfkj alsdfj laksdj flkajs dflkj sdfsadfasdfasd"));
+ ol.addComponent(p);
+
+ main.addComponent(ol);
+
+ ol = new VerticalLayout();
+ p = new Panel("300x-1");
+ // p.getLayout().setSizeFull();
+ p.setWidth("300px");
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ p.addComponent(new Label("Short"));
+ ol.addComponent(p);
+
+ main.addComponent(ol);
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1924ThemeChanging.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1924ThemeChanging.java
index 981fd9cd5c..11621c7fa9 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1924ThemeChanging.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1924ThemeChanging.java
@@ -1,51 +1,51 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket1924ThemeChanging extends com.vaadin.Application {
-
- private Label l = new Label("Background should be red with test theme");
-
- @SuppressWarnings("unused")
- private Panel p;
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- l.setStyleName("red");
- main.addComponent(l);
-
- Button b = new Button("Toggle tests-tickets theme");
- b.addListener(new ClickListener() {
- boolean flag = false;
-
- public void buttonClick(ClickEvent event) {
- if (flag == !flag) {
- main.setTheme("tests-tickets");
- } else {
- main.setTheme(null);
- }
- }
- });
-
- main.addComponent(b);
-
- b = new Button("Modify caption (should not reload page)");
- b.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- main.setCaption(main.getCaption() + ".");
- }
- });
-
- main.addComponent(b);
-
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket1924ThemeChanging extends com.vaadin.Application {
+
+ private Label l = new Label("Background should be red with test theme");
+
+ @SuppressWarnings("unused")
+ private Panel p;
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ l.setStyleName("red");
+ main.addComponent(l);
+
+ Button b = new Button("Toggle tests-tickets theme");
+ b.addListener(new ClickListener() {
+ boolean flag = false;
+
+ public void buttonClick(ClickEvent event) {
+ if (flag == !flag) {
+ main.setTheme("tests-tickets");
+ } else {
+ main.setTheme(null);
+ }
+ }
+ });
+
+ main.addComponent(b);
+
+ b = new Button("Modify caption (should not reload page)");
+ b.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ main.setCaption(main.getCaption() + ".");
+ }
+ });
+
+ main.addComponent(b);
+
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java
index 83e5e1cfd4..bb15f2c80e 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java
@@ -1,15 +1,15 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Window;
-
-public class Ticket1925 extends Application {
-
- @Override
- public void init() {
- Window mainWindow = new Window("Test åäö");
- setMainWindow(mainWindow);
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Window;
+
+public class Ticket1925 extends Application {
+
+ @Override
+ public void init() {
+ Window mainWindow = new Window("Test åäö");
+ setMainWindow(mainWindow);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java
index 5f1f152f3f..2245be0057 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java
@@ -1,111 +1,111 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1966 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- w.setContent(new GridLayout(2, 2));
- // w.getLayout().setSizeFull();
- createUI((Layout) w.getContent());
- }
-
- private void createUI(Layout layout) {
- orderedLayout(layout);
- gridLayout(layout);
- }
-
- private void gridLayout(Layout layout) {
- Panel p = new Panel("GridLayout");
- layout.addComponent(p);
-
- GridLayout gl = new GridLayout(1, 4);
- gl.setCaption("Horizontal");
- Button b;
-
- b = new Button("Wide button");
- b.setWidth("500px");
- gl.addComponent(b);
-
- addButtons(gl);
-
- p.addComponent(gl);
-
- /* VERTICAL */
-
- gl = new GridLayout(4, 1);
- gl.setCaption("Vertical");
-
- addButtons(gl);
-
- b = new Button("High button");
- b.setHeight("200px");
- gl.addComponent(b);
-
- p.addComponent(gl);
-
- }
-
- private void orderedLayout(Layout layout) {
- Panel p = new Panel("OrderedLayout");
- layout.addComponent(p);
-
- AbstractOrderedLayout ol = new VerticalLayout();
- ol.setCaption("Horizontal");
- // ol.setWidth("100%");
-
- Button b;
-
- b = new Button("Wide button");
- b.setWidth("500px");
- ol.addComponent(b);
-
- addButtons(ol);
- p.addComponent(ol);
-
- /* VERTICAL */
-
- ol = new HorizontalLayout();
- ol.setCaption("Vertical");
-
- addButtons(ol);
- b = new Button("High button");
- b.setHeight("200px");
- ol.addComponent(b);
-
- p.addComponent(ol);
-
- }
-
- private void addButtons(Layout ol) {
- ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
- ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
- ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
-
- }
-
- private Button getButton(Layout l, Alignment align) {
- Button b = new Button("Narrow Button - "
- + align.getHorizontalAlignment() + " - "
- + align.getVerticalAlignment());
- b.setWidth("100px");
- ((AlignmentHandler) l).setComponentAlignment(b, align);
-
- return b;
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.AlignmentHandler;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1966 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ w.setContent(new GridLayout(2, 2));
+ // w.getLayout().setSizeFull();
+ createUI((Layout) w.getContent());
+ }
+
+ private void createUI(Layout layout) {
+ orderedLayout(layout);
+ gridLayout(layout);
+ }
+
+ private void gridLayout(Layout layout) {
+ Panel p = new Panel("GridLayout");
+ layout.addComponent(p);
+
+ GridLayout gl = new GridLayout(1, 4);
+ gl.setCaption("Horizontal");
+ Button b;
+
+ b = new Button("Wide button");
+ b.setWidth("500px");
+ gl.addComponent(b);
+
+ addButtons(gl);
+
+ p.addComponent(gl);
+
+ /* VERTICAL */
+
+ gl = new GridLayout(4, 1);
+ gl.setCaption("Vertical");
+
+ addButtons(gl);
+
+ b = new Button("High button");
+ b.setHeight("200px");
+ gl.addComponent(b);
+
+ p.addComponent(gl);
+
+ }
+
+ private void orderedLayout(Layout layout) {
+ Panel p = new Panel("OrderedLayout");
+ layout.addComponent(p);
+
+ AbstractOrderedLayout ol = new VerticalLayout();
+ ol.setCaption("Horizontal");
+ // ol.setWidth("100%");
+
+ Button b;
+
+ b = new Button("Wide button");
+ b.setWidth("500px");
+ ol.addComponent(b);
+
+ addButtons(ol);
+ p.addComponent(ol);
+
+ /* VERTICAL */
+
+ ol = new HorizontalLayout();
+ ol.setCaption("Vertical");
+
+ addButtons(ol);
+ b = new Button("High button");
+ b.setHeight("200px");
+ ol.addComponent(b);
+
+ p.addComponent(ol);
+
+ }
+
+ private void addButtons(Layout ol) {
+ ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
+ ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
+ ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
+
+ }
+
+ private Button getButton(Layout l, Alignment align) {
+ Button b = new Button("Narrow Button - "
+ + align.getHorizontalAlignment() + " - "
+ + align.getVerticalAlignment());
+ b.setWidth("100px");
+ ((AlignmentHandler) l).setComponentAlignment(b, align);
+
+ return b;
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java
index 65fe2cc2ff..2d287ecdd4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java
@@ -1,168 +1,168 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1966_2 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
- w.setContent(new GridLayout(2, 2));
-
- // Panel p = new Panel("test");
- // p.setWidth(500);
- // p.setHeight(500);
- // p.setContent(new GridLayout(1, 2));
- // p.getLayout().setSizeFull();
- //
- // p.addComponent(new Button("asjkdfhakshdf"));
- // p.addComponent(new Button("öalijgto8aq5"));
-
- // GridLayout gl = new GridLayout(4, 1);
- // // gl.setCaption("Vertical");
- // gl.setWidth("100%");
- // gl.setHeight(500);
-
- // addButtons(gl);
- // gl.addComponent(new Label("abc"));
- // p.addComponent(gl);
-
- // w.getLayout().addComponent(p);
- createUI((Layout) w.getContent());
- }
-
- private void createUI(Layout layout) {
- orderedLayout(layout);
- gridLayout(layout);
- expandLayout(layout);
- }
-
- private void gridLayout(Layout layout) {
- Panel p = new Panel("GridLayout");
- p.setWidth("500px");
- p.setHeight("500px");
- p.getContent().setSizeFull();
- layout.addComponent(p);
-
- GridLayout gl = new GridLayout(1, 4);
- gl.setCaption("Horizontal");
- gl.setWidth("100%");
-
- // Button b;
-
- // b = new Button("Wide button");
- // b.setWidth("500");
- // gl.addComponent(b);
-
- addButtons(gl);
-
- p.addComponent(gl);
-
- /* VERTICAL */
-
- gl = new GridLayout(4, 1);
- // gl.setCaption("Vertical");
- gl.setHeight("100%");
- addButtons(gl);
-
- // Button b = new Button("High button");
- // b.setHeight(200);
- // gl.addComponent(b);
-
- p.addComponent(gl);
-
- }
-
- private void orderedLayout(Layout layout) {
- Panel p = new Panel("OrderedLayout");
- p.setWidth("500px");
- p.setHeight("500px");
- p.getContent().setWidth("100%");
- layout.addComponent(p);
-
- AbstractOrderedLayout ol = new VerticalLayout();
- // ol.setCaption("Horizontal");
- ol.setWidth("100%");
- addButtons(ol);
- p.addComponent(ol);
-
- /* VERTICAL */
-
- ol = new HorizontalLayout();
- // ol.setCaption("Vertical");
- ol.setHeight("200px");
- addButtons(ol);
- // Button b = new Button("High button");
- // b.setHeight(200);
- // ol.addComponent(b);
- p.addComponent(ol);
-
- }
-
- private void expandLayout(Layout layout) {
- Panel p = new Panel("ExpandLayout");
- layout.addComponent(p);
- p.getContent().setWidth("500");
- p.getContent().setHeight("400");
-
- AbstractOrderedLayout el = new VerticalLayout();
- // el.setCaption("Horizontal");
- // el.setSizeUndefined();
- // el.setWidth("100%");
- // ol.setWidth("100%");
- Button b;
-
- b = new Button("Wide button");
- b.setWidth("100%");
- // b.setHeight(200);
- // el.setExpandRatio(b,1);
- // el.addComponent(b);
-
- addButtons(el);
- p.addComponent(el);
-
- /* VERTICAL */
-
- el = new HorizontalLayout();
- // el.setHeight(400);
- // el.setWidth("100%");
- // el.setCaption("Vertical");
-
- addButtons(el);
- // b = new Button("High button");
- // el.setExpandRatio(b,1);
- // b.setHeight(100);
- // el.addComponent(b);
-
- p.addComponent(el);
-
- }
-
- private void addButtons(Layout ol) {
- ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
- ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
- ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
-
- }
-
- private Button getButton(Layout l, Alignment align) {
- Button b = new Button(align.getHorizontalAlignment() + " - "
- + align.getVerticalAlignment());
- // b.setWidth("100");
- ((AlignmentHandler) l).setComponentAlignment(b, align);
-
- return b;
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.AlignmentHandler;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1966_2 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+ w.setContent(new GridLayout(2, 2));
+
+ // Panel p = new Panel("test");
+ // p.setWidth(500);
+ // p.setHeight(500);
+ // p.setContent(new GridLayout(1, 2));
+ // p.getLayout().setSizeFull();
+ //
+ // p.addComponent(new Button("asjkdfhakshdf"));
+ // p.addComponent(new Button("öalijgto8aq5"));
+
+ // GridLayout gl = new GridLayout(4, 1);
+ // // gl.setCaption("Vertical");
+ // gl.setWidth("100%");
+ // gl.setHeight(500);
+
+ // addButtons(gl);
+ // gl.addComponent(new Label("abc"));
+ // p.addComponent(gl);
+
+ // w.getLayout().addComponent(p);
+ createUI((Layout) w.getContent());
+ }
+
+ private void createUI(Layout layout) {
+ orderedLayout(layout);
+ gridLayout(layout);
+ expandLayout(layout);
+ }
+
+ private void gridLayout(Layout layout) {
+ Panel p = new Panel("GridLayout");
+ p.setWidth("500px");
+ p.setHeight("500px");
+ p.getContent().setSizeFull();
+ layout.addComponent(p);
+
+ GridLayout gl = new GridLayout(1, 4);
+ gl.setCaption("Horizontal");
+ gl.setWidth("100%");
+
+ // Button b;
+
+ // b = new Button("Wide button");
+ // b.setWidth("500");
+ // gl.addComponent(b);
+
+ addButtons(gl);
+
+ p.addComponent(gl);
+
+ /* VERTICAL */
+
+ gl = new GridLayout(4, 1);
+ // gl.setCaption("Vertical");
+ gl.setHeight("100%");
+ addButtons(gl);
+
+ // Button b = new Button("High button");
+ // b.setHeight(200);
+ // gl.addComponent(b);
+
+ p.addComponent(gl);
+
+ }
+
+ private void orderedLayout(Layout layout) {
+ Panel p = new Panel("OrderedLayout");
+ p.setWidth("500px");
+ p.setHeight("500px");
+ p.getContent().setWidth("100%");
+ layout.addComponent(p);
+
+ AbstractOrderedLayout ol = new VerticalLayout();
+ // ol.setCaption("Horizontal");
+ ol.setWidth("100%");
+ addButtons(ol);
+ p.addComponent(ol);
+
+ /* VERTICAL */
+
+ ol = new HorizontalLayout();
+ // ol.setCaption("Vertical");
+ ol.setHeight("200px");
+ addButtons(ol);
+ // Button b = new Button("High button");
+ // b.setHeight(200);
+ // ol.addComponent(b);
+ p.addComponent(ol);
+
+ }
+
+ private void expandLayout(Layout layout) {
+ Panel p = new Panel("ExpandLayout");
+ layout.addComponent(p);
+ p.getContent().setWidth("500");
+ p.getContent().setHeight("400");
+
+ AbstractOrderedLayout el = new VerticalLayout();
+ // el.setCaption("Horizontal");
+ // el.setSizeUndefined();
+ // el.setWidth("100%");
+ // ol.setWidth("100%");
+ Button b;
+
+ b = new Button("Wide button");
+ b.setWidth("100%");
+ // b.setHeight(200);
+ // el.setExpandRatio(b,1);
+ // el.addComponent(b);
+
+ addButtons(el);
+ p.addComponent(el);
+
+ /* VERTICAL */
+
+ el = new HorizontalLayout();
+ // el.setHeight(400);
+ // el.setWidth("100%");
+ // el.setCaption("Vertical");
+
+ addButtons(el);
+ // b = new Button("High button");
+ // el.setExpandRatio(b,1);
+ // b.setHeight(100);
+ // el.addComponent(b);
+
+ p.addComponent(el);
+
+ }
+
+ private void addButtons(Layout ol) {
+ ol.addComponent(getButton(ol, Alignment.TOP_LEFT));
+ ol.addComponent(getButton(ol, Alignment.MIDDLE_CENTER));
+ ol.addComponent(getButton(ol, Alignment.BOTTOM_RIGHT));
+
+ }
+
+ private Button getButton(Layout l, Alignment align) {
+ Button b = new Button(align.getHorizontalAlignment() + " - "
+ + align.getVerticalAlignment());
+ // b.setWidth("100");
+ ((AlignmentHandler) l).setComponentAlignment(b, align);
+
+ return b;
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java
index e4f99b9023..e6953d4193 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java
@@ -1,63 +1,63 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1966_3 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- VerticalLayout ol = new VerticalLayout();
- Panel p = new Panel(ol);
- p.setWidth("300px");
- p.setHeight("300px");
- p.getContent().setSizeFull();
-
- TextField tf = new TextField("Long caption, longer than 100 pixels");
- tf.setWidth("100px");
-
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
-
- tf = new TextField("Short caption");
- tf.setWidth("100px");
-
- tf.setComponentError(new UserError("error message"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
-
- tf = new TextField("Short caption");
- tf.setComponentError(new UserError("error message"));
- tf.setIcon(new ThemeResource("icons/16/calendar.png"));
- tf.setWidth("100px");
-
- tf.setComponentError(new UserError("error message"));
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
-
- tf = new TextField();
- tf.setValue("No caption");
- tf.setWidth("100px");
-
- ol.addComponent(tf);
- ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
-
- layout.addComponent(p);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1966_3 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ VerticalLayout ol = new VerticalLayout();
+ Panel p = new Panel(ol);
+ p.setWidth("300px");
+ p.setHeight("300px");
+ p.getContent().setSizeFull();
+
+ TextField tf = new TextField("Long caption, longer than 100 pixels");
+ tf.setWidth("100px");
+
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
+
+ tf = new TextField("Short caption");
+ tf.setWidth("100px");
+
+ tf.setComponentError(new UserError("error message"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
+
+ tf = new TextField("Short caption");
+ tf.setComponentError(new UserError("error message"));
+ tf.setIcon(new ThemeResource("icons/16/calendar.png"));
+ tf.setWidth("100px");
+
+ tf.setComponentError(new UserError("error message"));
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
+
+ tf = new TextField();
+ tf.setValue("No caption");
+ tf.setWidth("100px");
+
+ ol.addComponent(tf);
+ ol.setComponentAlignment(tf, Alignment.TOP_RIGHT);
+
+ layout.addComponent(p);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java
index 26c1c69470..ffe099b067 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java
@@ -1,105 +1,105 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.terminal.UserError;
-import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1969 extends com.vaadin.Application {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- main.getContent().setSizeFull();
-
- TabSheet ts = new TabSheet();
- ts.setSizeFull();
-
- final Table t = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(7, 2000);
- t.setSizeFull();
- ts.addTab(t, "Table, scrollins should not flash", null);
-
- final Label testContent = new Label(
- "TabSheet by default uses caption, icon, errors etc. from Components. ");
-
- testContent.setCaption("Introduction to test");
-
- ts.addTab(testContent);
-
- final VerticalLayout actions = new VerticalLayout();
-
- actions.setCaption("Test actions");
-
- ts.addTab(actions);
-
- Button b;
-
- b = new Button(
- "change introduction caption (should add * to tab name)",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- testContent.setCaption(testContent.getCaption() + "*");
- }
- });
- actions.addComponent(b);
-
- b = new Button("change tab caption (should add * to tab name)",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- actions.setCaption(actions.getCaption() + "*");
- }
- });
-
- actions.addComponent(b);
-
- final UserError e = new UserError("Test error");
-
- b = new Button("Toggle error", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (testContent.getComponentError() == null) {
- testContent.setComponentError(e);
- } else {
- testContent.setComponentError(null);
- }
- }
- });
- actions.addComponent(b);
-
- b = new Button("Change table caption", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- t.setCaption(t.getCaption() + "*");
- }
- });
- actions.addComponent(b);
-
- b = new Button("Toggle Table error", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- if (t.getComponentError() == null) {
- t.setComponentError(e);
- } else {
- t.setComponentError(null);
- }
- }
- });
-
- actions.addComponent(b);
-
- for (int i = 0; i < 20; i++) {
- Label l = new Label("Test Content");
- l.setCaption("Extra tab " + i);
- ts.addComponent(l);
- }
-
- main.addComponent(ts);
-
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1969 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ main.getContent().setSizeFull();
+
+ TabSheet ts = new TabSheet();
+ ts.setSizeFull();
+
+ final Table t = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(7, 2000);
+ t.setSizeFull();
+ ts.addTab(t, "Table, scrollins should not flash", null);
+
+ final Label testContent = new Label(
+ "TabSheet by default uses caption, icon, errors etc. from Components. ");
+
+ testContent.setCaption("Introduction to test");
+
+ ts.addTab(testContent);
+
+ final VerticalLayout actions = new VerticalLayout();
+
+ actions.setCaption("Test actions");
+
+ ts.addTab(actions);
+
+ Button b;
+
+ b = new Button(
+ "change introduction caption (should add * to tab name)",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ testContent.setCaption(testContent.getCaption() + "*");
+ }
+ });
+ actions.addComponent(b);
+
+ b = new Button("change tab caption (should add * to tab name)",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ actions.setCaption(actions.getCaption() + "*");
+ }
+ });
+
+ actions.addComponent(b);
+
+ final UserError e = new UserError("Test error");
+
+ b = new Button("Toggle error", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (testContent.getComponentError() == null) {
+ testContent.setComponentError(e);
+ } else {
+ testContent.setComponentError(null);
+ }
+ }
+ });
+ actions.addComponent(b);
+
+ b = new Button("Change table caption", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ t.setCaption(t.getCaption() + "*");
+ }
+ });
+ actions.addComponent(b);
+
+ b = new Button("Toggle Table error", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (t.getComponentError() == null) {
+ t.setComponentError(e);
+ } else {
+ t.setComponentError(null);
+ }
+ }
+ });
+
+ actions.addComponent(b);
+
+ for (int i = 0; i < 20; i++) {
+ Label l = new Label("Test Content");
+ l.setCaption("Extra tab " + i);
+ ts.addComponent(l);
+ }
+
+ main.addComponent(ts);
+
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java
index 86d5b0f11d..62b001bbda 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class Ticket1972 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
- setTheme("tests-ticket");
- GridLayout layout = new GridLayout(3, 3);
- layout.setStyleName("borders");
- layout.addComponent(new Label("1-1"));
- layout.space();
- layout.space();
- layout.addComponent(new Label("2-1"));
- layout.space();
- layout.space();
- layout.addComponent(new Label("3-1"));
- layout.space();
- layout.addComponent(new Label("3-3"));
-
- w.setContent(layout);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class Ticket1972 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+ setTheme("tests-ticket");
+ GridLayout layout = new GridLayout(3, 3);
+ layout.setStyleName("borders");
+ layout.addComponent(new Label("1-1"));
+ layout.space();
+ layout.space();
+ layout.addComponent(new Label("2-1"));
+ layout.space();
+ layout.space();
+ layout.addComponent(new Label("3-1"));
+ layout.space();
+ layout.addComponent(new Label("3-3"));
+
+ w.setContent(layout);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java
index c756ca12c3..9629c4507b 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java
@@ -1,51 +1,51 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1973 extends com.vaadin.Application {
-
- Window main = new Window();
- Table table = new Table();
-
- @Override
- public void init() {
- setMainWindow(main);
-
- final IndexedContainer container1 = new IndexedContainer();
- container1.addContainerProperty("layout", Component.class, null);
-
- final IndexedContainer container2 = new IndexedContainer();
- container2.addContainerProperty("layout", Component.class, null);
-
- fill(container1, 100, "Testi 1 :");
- fill(container2, 100, "Testi 2 :");
-
- table.setContainerDataSource(container1);
-
- Button refreshTable = new Button("Change table container");
- refreshTable.addListener(new Button.ClickListener() {
- public void buttonClick(Button.ClickEvent e) {
- table.setContainerDataSource(container2);
- table.setContainerDataSource(container1);
- }
- });
-
- main.addComponent(table);
- main.addComponent(refreshTable);
- }
-
- public void fill(IndexedContainer container, int size, String prefix) {
- for (int i = 0; i < size; i++) {
- Item item = container.addItem(new Integer(i));
- VerticalLayout layout = new VerticalLayout();
- layout.addComponent(new Button(prefix + i));
- item.getItemProperty("layout").setValue(layout);
- }
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1973 extends com.vaadin.Application {
+
+ Window main = new Window();
+ Table table = new Table();
+
+ @Override
+ public void init() {
+ setMainWindow(main);
+
+ final IndexedContainer container1 = new IndexedContainer();
+ container1.addContainerProperty("layout", Component.class, null);
+
+ final IndexedContainer container2 = new IndexedContainer();
+ container2.addContainerProperty("layout", Component.class, null);
+
+ fill(container1, 100, "Testi 1 :");
+ fill(container2, 100, "Testi 2 :");
+
+ table.setContainerDataSource(container1);
+
+ Button refreshTable = new Button("Change table container");
+ refreshTable.addListener(new Button.ClickListener() {
+ public void buttonClick(Button.ClickEvent e) {
+ table.setContainerDataSource(container2);
+ table.setContainerDataSource(container1);
+ }
+ });
+
+ main.addComponent(table);
+ main.addComponent(refreshTable);
+ }
+
+ public void fill(IndexedContainer container, int size, String prefix) {
+ for (int i = 0; i < size; i++) {
+ Item item = container.addItem(new Integer(i));
+ VerticalLayout layout = new VerticalLayout();
+ layout.addComponent(new Button(prefix + i));
+ item.getItemProperty("layout").setValue(layout);
+ }
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java
index d162606ba7..4f4376721a 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java
@@ -1,62 +1,62 @@
-package com.vaadin.tests.tickets;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.gwt.server.WebApplicationContext;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CustomLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket1975 extends Application {
-
- private CustomLayout cl1;
- private CustomLayout cl2;
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
- setTheme("tests-tickets");
- GridLayout layout = new GridLayout(1, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- String s = "<b>Blah</b><input type=\"text\" value='Lorem\" ipsum'/>";
- try {
- cl1 = new CustomLayout(new ByteArrayInputStream(s.getBytes()));
- layout.addComponent(cl1);
- WebApplicationContext wc = ((WebApplicationContext) getContext());
-
- layout.addComponent(new Button("Disable/Enable",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- boolean e = cl1.isEnabled();
-
- cl1.setEnabled(!e);
- cl2.setEnabled(!e);
- }
-
- }));
- File f = new File(wc.getBaseDirectory().getAbsoluteFile()
- + "/VAADIN/themes/" + getTheme()
- + "/layouts/Ticket1975.html");
-
- cl2 = new CustomLayout(new FileInputStream(f));
- layout.addComponent(cl2);
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.gwt.server.WebApplicationContext;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket1975 extends Application {
+
+ private CustomLayout cl1;
+ private CustomLayout cl2;
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+ setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(1, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ String s = "<b>Blah</b><input type=\"text\" value='Lorem\" ipsum'/>";
+ try {
+ cl1 = new CustomLayout(new ByteArrayInputStream(s.getBytes()));
+ layout.addComponent(cl1);
+ WebApplicationContext wc = ((WebApplicationContext) getContext());
+
+ layout.addComponent(new Button("Disable/Enable",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ boolean e = cl1.isEnabled();
+
+ cl1.setEnabled(!e);
+ cl2.setEnabled(!e);
+ }
+
+ }));
+ File f = new File(wc.getBaseDirectory().getAbsoluteFile()
+ + "/VAADIN/themes/" + getTheme()
+ + "/layouts/Ticket1975.html");
+
+ cl2 = new CustomLayout(new FileInputStream(f));
+ layout.addComponent(cl2);
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java
index f2a173bcb0..44d4632427 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java
@@ -1,79 +1,79 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.ListSelect;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.OptionGroup;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.TwinColSelect;
-import com.vaadin.ui.Window;
-
-public class Ticket1986 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
-
- int index = 1;
-
- GridLayout layout = new GridLayout(2, 2);
- TextField f1 = new TextField("1");
- f1.setTabIndex(index++);
- TextField f2 = new TextField("2");
- f2.setTabIndex(index++);
-
- DateField f3 = new DateField("3");
- f3.setTabIndex(index++);
- ComboBox cb = new ComboBox("4");
- cb.setTabIndex(index++);
-
- ListSelect lss = new ListSelect("5");
- lss.addItem("foo");
- lss.addItem("Bar");
- lss.setTabIndex(index++);
-
- NativeSelect ns = new NativeSelect("6");
- ns.addItem("foo");
- ns.addItem("bar");
- ns.setTabIndex(index++);
-
- OptionGroup og = new OptionGroup("7");
- og.addItem("foo");
- og.addItem("bar");
- og.setTabIndex(index++);
-
- OptionGroup ogm = new OptionGroup("7");
- ogm.setMultiSelect(true);
- ogm.addItem("foo");
- ogm.addItem("bar");
- ogm.setTabIndex(index++);
-
- TwinColSelect ts = new TwinColSelect("8");
- ts.addItem("Foo");
- ts.addItem("Bar");
- ts.setTabIndex(index++);
-
- Button b = new Button("9");
- b.setTabIndex(index++);
-
- layout.addComponent(b);
- layout.addComponent(ts);
- layout.addComponent(ogm);
- layout.addComponent(og);
- layout.addComponent(ns);
- layout.addComponent(lss);
- layout.addComponent(cb);
- layout.addComponent(f3);
- layout.addComponent(f2);
- layout.addComponent(f1);
-
- w.setContent(layout);
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.TwinColSelect;
+import com.vaadin.ui.Window;
+
+public class Ticket1986 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+
+ int index = 1;
+
+ GridLayout layout = new GridLayout(2, 2);
+ TextField f1 = new TextField("1");
+ f1.setTabIndex(index++);
+ TextField f2 = new TextField("2");
+ f2.setTabIndex(index++);
+
+ DateField f3 = new DateField("3");
+ f3.setTabIndex(index++);
+ ComboBox cb = new ComboBox("4");
+ cb.setTabIndex(index++);
+
+ ListSelect lss = new ListSelect("5");
+ lss.addItem("foo");
+ lss.addItem("Bar");
+ lss.setTabIndex(index++);
+
+ NativeSelect ns = new NativeSelect("6");
+ ns.addItem("foo");
+ ns.addItem("bar");
+ ns.setTabIndex(index++);
+
+ OptionGroup og = new OptionGroup("7");
+ og.addItem("foo");
+ og.addItem("bar");
+ og.setTabIndex(index++);
+
+ OptionGroup ogm = new OptionGroup("7");
+ ogm.setMultiSelect(true);
+ ogm.addItem("foo");
+ ogm.addItem("bar");
+ ogm.setTabIndex(index++);
+
+ TwinColSelect ts = new TwinColSelect("8");
+ ts.addItem("Foo");
+ ts.addItem("Bar");
+ ts.setTabIndex(index++);
+
+ Button b = new Button("9");
+ b.setTabIndex(index++);
+
+ layout.addComponent(b);
+ layout.addComponent(ts);
+ layout.addComponent(ogm);
+ layout.addComponent(og);
+ layout.addComponent(ns);
+ layout.addComponent(lss);
+ layout.addComponent(cb);
+ layout.addComponent(f3);
+ layout.addComponent(f2);
+ layout.addComponent(f1);
+
+ w.setContent(layout);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java
index 430c54ec92..d2aca84848 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java
@@ -1,28 +1,28 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-public class Ticket1991 extends com.vaadin.Application {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- Table t = new Table("Test table");
-
- t.addContainerProperty(" ", CheckBox.class, "");
- t.addContainerProperty("Col1", String.class, "");
- t.addContainerProperty("Col2", String.class, "");
-
- t.setPageLength(5);
-
- t.addItem(new Object[] { new CheckBox(), "Foo", "Bar" }, "1");
- t.addItem(new Object[] { new CheckBox(), "Foo", "Bar" }, "2");
-
- main.addComponent(t);
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+public class Ticket1991 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ Table t = new Table("Test table");
+
+ t.addContainerProperty(" ", CheckBox.class, "");
+ t.addContainerProperty("Col1", String.class, "");
+ t.addContainerProperty("Col2", String.class, "");
+
+ t.setPageLength(5);
+
+ t.addItem(new Object[] { new CheckBox(), "Foo", "Bar" }, "1");
+ t.addItem(new Object[] { new CheckBox(), "Foo", "Bar" }, "2");
+
+ main.addComponent(t);
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java
index c681cb5bd0..8b66c7f012 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java
@@ -1,67 +1,67 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.data.Container;
-import com.vaadin.data.Container.Filterable;
-import com.vaadin.data.Item;
-import com.vaadin.data.util.filter.SimpleStringFilter;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-public class Ticket1995 extends Application {
-
- private static final Object PROPERTY_1 = "Test";
- private Table table;
-
- @Override
- public void init() {
- final Window mainWin = new Window(getClass().getName());
- setMainWindow(mainWin);
-
- table = new Table();
- table.addContainerProperty(PROPERTY_1, String.class, "");
- table.setPageLength(4);
-
- Item item = table.addItem("1");
- item.getItemProperty(PROPERTY_1).setValue("Row 1");
- item = table.addItem("2");
- item.getItemProperty(PROPERTY_1).setValue("Row 2");
-
- Filterable filterable = (Container.Filterable) table
- .getContainerDataSource();
- filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",
- true, false));
-
- table.setColumnHeader(PROPERTY_1, "Test (filter: Row)");
-
- mainWin.addComponent(table);
- mainWin.addComponent(new Button("Add item",
- new com.vaadin.ui.Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- addItem();
- }
- }));
- }
-
- protected void addItem() {
- Filterable filterable = (Container.Filterable) table
- .getContainerDataSource();
-
- Item i = table.addItem("abc");
- String res = "";
- if (i == null) {
- res = "FAILED";
- } else {
- res = "OK!";
- }
-
- getMainWindow().showNotification("Tried to add item 'abc', " + res);
-
- filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",
- true, false));
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Filterable;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.filter.SimpleStringFilter;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+public class Ticket1995 extends Application {
+
+ private static final Object PROPERTY_1 = "Test";
+ private Table table;
+
+ @Override
+ public void init() {
+ final Window mainWin = new Window(getClass().getName());
+ setMainWindow(mainWin);
+
+ table = new Table();
+ table.addContainerProperty(PROPERTY_1, String.class, "");
+ table.setPageLength(4);
+
+ Item item = table.addItem("1");
+ item.getItemProperty(PROPERTY_1).setValue("Row 1");
+ item = table.addItem("2");
+ item.getItemProperty(PROPERTY_1).setValue("Row 2");
+
+ Filterable filterable = (Container.Filterable) table
+ .getContainerDataSource();
+ filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",
+ true, false));
+
+ table.setColumnHeader(PROPERTY_1, "Test (filter: Row)");
+
+ mainWin.addComponent(table);
+ mainWin.addComponent(new Button("Add item",
+ new com.vaadin.ui.Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ addItem();
+ }
+ }));
+ }
+
+ protected void addItem() {
+ Filterable filterable = (Container.Filterable) table
+ .getContainerDataSource();
+
+ Item i = table.addItem("abc");
+ String res = "";
+ if (i == null) {
+ res = "FAILED";
+ } else {
+ res = "OK!";
+ }
+
+ getMainWindow().showNotification("Tried to add item 'abc', " + res);
+
+ filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",
+ true, false));
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java
index 4e07230f46..2776fbc3b4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java
@@ -1,51 +1,51 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.data.util.MethodProperty;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2002 extends Application {
- private Long long1 = new Long(1L);
- private Long long2 = new Long(2L);
-
- public Long getLong1() {
- return long1;
- }
-
- public void setLong1(Long long1) {
- this.long1 = long1;
- }
-
- public Long getLong2() {
- return long2;
- }
-
- public void setLong2(Long long2) {
- this.long2 = long2;
- }
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
-
- GridLayout layout = new GridLayout(2, 2);
- layout.setSpacing(true);
-
- TextField f1 = new TextField("Non-immediate/Long text field",
- new MethodProperty<Long>(this, "long1"));
- f1.setImmediate(false);
- f1.setNullSettingAllowed(true);
- TextField f2 = new TextField("Immediate/Long text field",
- new MethodProperty<Long>(this, "long2"));
- f2.setImmediate(true);
- f2.setNullSettingAllowed(true);
-
- layout.addComponent(f1);
- layout.addComponent(f2);
-
- w.setContent(layout);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket2002 extends Application {
+ private Long long1 = new Long(1L);
+ private Long long2 = new Long(2L);
+
+ public Long getLong1() {
+ return long1;
+ }
+
+ public void setLong1(Long long1) {
+ this.long1 = long1;
+ }
+
+ public Long getLong2() {
+ return long2;
+ }
+
+ public void setLong2(Long long2) {
+ this.long2 = long2;
+ }
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+
+ GridLayout layout = new GridLayout(2, 2);
+ layout.setSpacing(true);
+
+ TextField f1 = new TextField("Non-immediate/Long text field",
+ new MethodProperty<Long>(this, "long1"));
+ f1.setImmediate(false);
+ f1.setNullSettingAllowed(true);
+ TextField f2 = new TextField("Immediate/Long text field",
+ new MethodProperty<Long>(this, "long2"));
+ f2.setImmediate(true);
+ f2.setNullSettingAllowed(true);
+
+ layout.addComponent(f1);
+ layout.addComponent(f2);
+
+ w.setContent(layout);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java
index f726ff10de..b1138acc08 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java
@@ -1,126 +1,126 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Container;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2009 extends com.vaadin.Application {
-
- TextField f = new TextField();
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- HorizontalLayout ol = new HorizontalLayout();
- main.setContent(ol);
- ol.setSizeFull();
-
- Panel p = new Panel("Tree test");
- p.setSizeFull();
-
- Tree t = new Tree();
-
- t.addItem("Foo");
- t.addItem("Bar");
-
- final VerticalLayout events = new VerticalLayout();
-
- t.addListener(new ItemClickEvent.ItemClickListener() {
- public void itemClick(ItemClickEvent event) {
- events.addComponent(new Label(new Label("Click:"
- + (event.isDoubleClick() ? "double" : "single")
- + " button:" + event.getButton() + " propertyId:"
- + event.getPropertyId() + " itemID:"
- + event.getItemId() + " item:" + event.getItem())));
-
- }
- });
-
- main.addComponent(p);
- p.addComponent(t);
- p.addComponent(events);
-
- Panel p2 = new Panel("Table test (try dbl click also)");
- p2.setSizeFull();
-
- final VerticalLayout events2 = new VerticalLayout();
- Table table = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(5, 100);
- table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
- table.addListener(new ItemClickEvent.ItemClickListener() {
- public void itemClick(ItemClickEvent event) {
- events2.addComponent(new Label("Click:"
- + (event.isDoubleClick() ? "double" : "single")
- + " button:" + event.getButton() + " propertyId:"
- + event.getPropertyId() + " itemID:"
- + event.getItemId() + " item:" + event.getItem()));
- if (event.isDoubleClick()) {
- new PropertyEditor(event);
- }
-
- }
- });
- p2.addComponent(table);
- p2.addComponent(events2);
-
- main.addComponent(p2);
-
- }
-
- class PropertyEditor extends Window {
-
- private static final int W = 300;
- private static final int H = 150;
-
- private Container c;
- private Object itemid;
- private Object propertyid;
-
- TextField editor = new TextField();
- Button done = new Button("Done");
-
- PropertyEditor(ItemClickEvent event) {
- c = (Container) event.getSource();
-
- propertyid = event.getPropertyId();
- itemid = event.getItemId();
-
- setCaption("Editing " + itemid + " : " + propertyid);
-
- editor.setPropertyDataSource(c.getContainerProperty(itemid,
- propertyid));
- addComponent(editor);
- addComponent(done);
-
- setWidth(W + "px");
- setHeight(H + "px");
-
- setPositionX(event.getClientX() - W / 2);
- setPositionY(event.getClientY() - H / 2);
-
- getMainWindow().addWindow(this);
-
- done.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- getMainWindow().removeWindow(PropertyEditor.this);
- }
- });
-
- }
-
- }
-
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Container;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2009 extends com.vaadin.Application {
+
+ TextField f = new TextField();
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ HorizontalLayout ol = new HorizontalLayout();
+ main.setContent(ol);
+ ol.setSizeFull();
+
+ Panel p = new Panel("Tree test");
+ p.setSizeFull();
+
+ Tree t = new Tree();
+
+ t.addItem("Foo");
+ t.addItem("Bar");
+
+ final VerticalLayout events = new VerticalLayout();
+
+ t.addListener(new ItemClickEvent.ItemClickListener() {
+ public void itemClick(ItemClickEvent event) {
+ events.addComponent(new Label(new Label("Click:"
+ + (event.isDoubleClick() ? "double" : "single")
+ + " button:" + event.getButton() + " propertyId:"
+ + event.getPropertyId() + " itemID:"
+ + event.getItemId() + " item:" + event.getItem())));
+
+ }
+ });
+
+ main.addComponent(p);
+ p.addComponent(t);
+ p.addComponent(events);
+
+ Panel p2 = new Panel("Table test (try dbl click also)");
+ p2.setSizeFull();
+
+ final VerticalLayout events2 = new VerticalLayout();
+ Table table = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(5, 100);
+ table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ table.addListener(new ItemClickEvent.ItemClickListener() {
+ public void itemClick(ItemClickEvent event) {
+ events2.addComponent(new Label("Click:"
+ + (event.isDoubleClick() ? "double" : "single")
+ + " button:" + event.getButton() + " propertyId:"
+ + event.getPropertyId() + " itemID:"
+ + event.getItemId() + " item:" + event.getItem()));
+ if (event.isDoubleClick()) {
+ new PropertyEditor(event);
+ }
+
+ }
+ });
+ p2.addComponent(table);
+ p2.addComponent(events2);
+
+ main.addComponent(p2);
+
+ }
+
+ class PropertyEditor extends Window {
+
+ private static final int W = 300;
+ private static final int H = 150;
+
+ private Container c;
+ private Object itemid;
+ private Object propertyid;
+
+ TextField editor = new TextField();
+ Button done = new Button("Done");
+
+ PropertyEditor(ItemClickEvent event) {
+ c = (Container) event.getSource();
+
+ propertyid = event.getPropertyId();
+ itemid = event.getItemId();
+
+ setCaption("Editing " + itemid + " : " + propertyid);
+
+ editor.setPropertyDataSource(c.getContainerProperty(itemid,
+ propertyid));
+ addComponent(editor);
+ addComponent(done);
+
+ setWidth(W + "px");
+ setHeight(H + "px");
+
+ setPositionX(event.getClientX() - W / 2);
+ setPositionY(event.getClientY() - H / 2);
+
+ getMainWindow().addWindow(this);
+
+ done.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().removeWindow(PropertyEditor.this);
+ }
+ });
+
+ }
+
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java
index e28ee9b4e2..0cfa642ff4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java
@@ -1,26 +1,26 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.Window;
-
-public class Ticket2011 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
- // setTheme("tests-ticket");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- Select s = new Select("Select");
- s.addItem("Item 1");
- s.addItem("Item 2");
- layout.addComponent(s);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.Window;
+
+public class Ticket2011 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+ // setTheme("tests-ticket");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ Select s = new Select("Select");
+ s.addItem("Item 1");
+ s.addItem("Item 2");
+ layout.addComponent(s);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java
index b005eefd03..e4cf36b084 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java
@@ -1,63 +1,63 @@
-package com.vaadin.tests.tickets;
-
-import java.util.UUID;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket2014 extends Application {
-
- private HorizontalLayout innerLayout1;
- private Button b1;
- private Panel panel;
-
- @Override
- public void init() {
- Window w = new Window(getClass().getName());
- setMainWindow(w);
- // setTheme("tests-ticket");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- createPanel(layout);
-
- layout.addComponent(new Button("Change class name",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- b1.setStyleName(UUID.randomUUID().toString());
- }
-
- }));
-
- }
-
- private void createPanel(GridLayout layout) {
- panel = new Panel("panel caption");
- layout.addComponent(panel);
-
- innerLayout1 = new HorizontalLayout();
- innerLayout1.setSpacing(true);
- panel.addComponent(innerLayout1);
-
- b1 = new Button("Button inside orderedLayout", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- System.out.println("Clicked " + event.getButton().getCaption());
- }
-
- });
-
- innerLayout1.addComponent(b1);
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import java.util.UUID;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket2014 extends Application {
+
+ private HorizontalLayout innerLayout1;
+ private Button b1;
+ private Panel panel;
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getName());
+ setMainWindow(w);
+ // setTheme("tests-ticket");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ createPanel(layout);
+
+ layout.addComponent(new Button("Change class name",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ b1.setStyleName(UUID.randomUUID().toString());
+ }
+
+ }));
+
+ }
+
+ private void createPanel(GridLayout layout) {
+ panel = new Panel("panel caption");
+ layout.addComponent(panel);
+
+ innerLayout1 = new HorizontalLayout();
+ innerLayout1.setSpacing(true);
+ panel.addComponent(innerLayout1);
+
+ b1 = new Button("Button inside orderedLayout", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ System.out.println("Clicked " + event.getButton().getCaption());
+ }
+
+ });
+
+ innerLayout1.addComponent(b1);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java
index 69858a57d6..9f37ddfef3 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java
@@ -1,141 +1,141 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.AbstractOrderedLayout;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2021 extends Application {
-
- private TextArea tf1, tf2, tf3;
-
- private String contents = "This TextField SHOULD FILL the panel and NOT CAUSE any scrollbars to appear in the Panel. Scrollbars SHOULD appear in the TextField AND the whole scrollbars (includinc arrow down) SHOULD be visible.\n\n"
- + ""
- + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent quis justo. Vivamus nec mi eu libero convallis auctor. Mauris et arcu. Nunc luctus justo. Aenean convallis, odio in vehicula scelerisque, est magna condimentum pede, a aliquam elit eros vitae diam. Phasellus porttitor convallis tellus. Nullam elementum, ligula nec viverra malesuada, risus tortor bibendum dui, eget hendrerit sem enim at massa. Nam eu pede sed nulla congue fermentum. Vestibulum malesuada libero non nunc. Proin rutrum. Fusce erat pede, volutpat vitae, aliquam ut, sagittis vel, augue. Fusce dui pede, convallis nec, accumsan tincidunt, consectetuer ac, purus. Nulla facilisi. Ut nisi. Sed orci risus, lacinia eu, sodales molestie, gravida quis, neque. Vestibulum pharetra ornare elit. Nulla porttitor molestie mauris. Morbi fringilla tellus sed risus. Curabitur varius massa."
- + "Nulla nisi. Sed blandit, ante vitae sagittis volutpat, arcu mauris vehicula risus, vitae posuere felis lectus sit amet purus. Donec nec magna et leo eleifend scelerisque. Suspendisse condimentum pharetra ligula. Curabitur lorem. Pellentesque a augue sit amet enim fermentum placerat. Phasellus ante risus, molestie at, iaculis at, pellentesque non, tellus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus non urna eget risus tempus imperdiet. Integer est diam, sagittis sit amet, posuere sit amet, bibendum sed, lacus. Aenean adipiscing cursus ipsum. Quisque at elit. Vestibulum vitae nunc. Praesent placerat metus viverra lorem. Cras nec elit congue nisi faucibus feugiat. Nam eget mi. Vestibulum condimentum. Nunc nisl ante, cursus in, dictum ac, lobortis rutrum, mi. Nulla eu nisi. In ultricies vehicula magna."
- + "Nunc eros dui, elementum at, ullamcorper eget, varius at, velit. Ut dictum. Cras ullamcorper ante vel tortor. Quisque viverra mauris vulputate quam. Nulla dui. Suspendisse non eros at ipsum faucibus hendrerit. Morbi dignissim pharetra tortor. Etiam malesuada. Mauris lacinia elementum erat. Duis mollis placerat metus. Nunc risus felis, cursus ac, cursus vel, convallis vel, metus. Ut vehicula nibh et nulla. Vivamus id pede. Quisque egestas arcu a ligula. Maecenas vehicula. Quisque sed ligula quis tellus tempus rutrum. Curabitur vel augue sed orci egestas pharetra. Duis pharetra.";
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- w.setContent(new GridLayout(2, 2));
- setMainWindow(w);
-
- Panel p = new Panel();
- p.setCaption("ExpandLayout");
- p.setWidth("500px");
- p.setHeight("500px");
- p.setContent(new VerticalLayout());
- p.getContent().setSizeFull();
-
- w.getContent().addComponent(p);
-
- tf1 = new TextArea();
- tf1.setRows(5);
- tf1.setSizeFull();
- tf1.setValue(contents);
- tf1.setCaption("TextField caption");
- p.getContent().addComponent(tf1);
-
- /*
- *
- * OrderedLayout
- */
-
- Panel p2 = new Panel();
- p2.setCaption("OrderedLayout");
- p2.setWidth("500px");
- p2.setHeight("500px");
- p2.setContent(new VerticalLayout());
- p2.getContent().setSizeFull();
-
- w.getContent().addComponent(p2);
-
- tf2 = new TextArea();
- tf2.setRows(5);
- tf2.setSizeFull();
- tf2.setValue(contents);
- tf2.setCaption("TextField caption");
- p2.getContent().addComponent(tf2);
-
- /*
- *
- * GridLayout
- */
-
- Panel p3 = new Panel();
- p3.setCaption("GridLayout");
- p3.setWidth("500px");
- p3.setHeight("500px");
- // p3.setContent(new GridLayout());
- p3.getContent().setSizeFull();
- ((Layout) p3.getContent()).setMargin(false);
-
- GridLayout gl = new GridLayout();
- gl.setSizeFull();
- gl.setMargin(false);
- p3.getContent().addComponent(gl);
- w.getContent().addComponent(p3);
-
- tf3 = new TextArea();
- tf3.setRows(5);
- tf3.setSizeFull();
- tf3.setValue(contents);
- tf3.setCaption("TextField caption");
- // p3.getContent().addComponent(tf3);
- gl.addComponent(tf3);
-
- // Panel pp = new Panel();
- // pp.setCaption("OrderedLayout");
- // pp.setWidth("500px");
- // pp.setHeight("500px");
- // pp.getContent().setSizeFull();
- // orderedLayout = new VerticalLayout();
- // pp.getContent().addComponent(orderedLayout);
- // w.getContent().addComponent(pp);
- // createUI(orderedLayout);
- }
-
- @SuppressWarnings("unused")
- private void createUI(Layout layout) {
- Label l = new Label("Label");
- Button b = new Button("Enable/disable caption and watch button move",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- System.out.println("Enable/disable caption");
- for (AbstractComponent l : new AbstractComponent[] {
- tf1, tf2, tf3 }) {
- // AbstractComponent l = tf2;
- // Layout l = (Layout) event.getButton().getData();
- if (l.getCaption() == null) {
- l.setCaption("Expand layout caption");
- } else {
- l.setCaption(null);
- }
- }
- }
-
- });
- b.setData(layout);
- Label l2 = new Label("This should always be visible");
-
- layout.addComponent(l);
- layout.addComponent(b);
- layout.addComponent(l2);
-
- if (layout instanceof AbstractOrderedLayout) {
- ((AbstractOrderedLayout) layout).setExpandRatio(l, 1);
-
- }
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2021 extends Application {
+
+ private TextArea tf1, tf2, tf3;
+
+ private String contents = "This TextField SHOULD FILL the panel and NOT CAUSE any scrollbars to appear in the Panel. Scrollbars SHOULD appear in the TextField AND the whole scrollbars (includinc arrow down) SHOULD be visible.\n\n"
+ + ""
+ + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent quis justo. Vivamus nec mi eu libero convallis auctor. Mauris et arcu. Nunc luctus justo. Aenean convallis, odio in vehicula scelerisque, est magna condimentum pede, a aliquam elit eros vitae diam. Phasellus porttitor convallis tellus. Nullam elementum, ligula nec viverra malesuada, risus tortor bibendum dui, eget hendrerit sem enim at massa. Nam eu pede sed nulla congue fermentum. Vestibulum malesuada libero non nunc. Proin rutrum. Fusce erat pede, volutpat vitae, aliquam ut, sagittis vel, augue. Fusce dui pede, convallis nec, accumsan tincidunt, consectetuer ac, purus. Nulla facilisi. Ut nisi. Sed orci risus, lacinia eu, sodales molestie, gravida quis, neque. Vestibulum pharetra ornare elit. Nulla porttitor molestie mauris. Morbi fringilla tellus sed risus. Curabitur varius massa."
+ + "Nulla nisi. Sed blandit, ante vitae sagittis volutpat, arcu mauris vehicula risus, vitae posuere felis lectus sit amet purus. Donec nec magna et leo eleifend scelerisque. Suspendisse condimentum pharetra ligula. Curabitur lorem. Pellentesque a augue sit amet enim fermentum placerat. Phasellus ante risus, molestie at, iaculis at, pellentesque non, tellus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus non urna eget risus tempus imperdiet. Integer est diam, sagittis sit amet, posuere sit amet, bibendum sed, lacus. Aenean adipiscing cursus ipsum. Quisque at elit. Vestibulum vitae nunc. Praesent placerat metus viverra lorem. Cras nec elit congue nisi faucibus feugiat. Nam eget mi. Vestibulum condimentum. Nunc nisl ante, cursus in, dictum ac, lobortis rutrum, mi. Nulla eu nisi. In ultricies vehicula magna."
+ + "Nunc eros dui, elementum at, ullamcorper eget, varius at, velit. Ut dictum. Cras ullamcorper ante vel tortor. Quisque viverra mauris vulputate quam. Nulla dui. Suspendisse non eros at ipsum faucibus hendrerit. Morbi dignissim pharetra tortor. Etiam malesuada. Mauris lacinia elementum erat. Duis mollis placerat metus. Nunc risus felis, cursus ac, cursus vel, convallis vel, metus. Ut vehicula nibh et nulla. Vivamus id pede. Quisque egestas arcu a ligula. Maecenas vehicula. Quisque sed ligula quis tellus tempus rutrum. Curabitur vel augue sed orci egestas pharetra. Duis pharetra.";
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ w.setContent(new GridLayout(2, 2));
+ setMainWindow(w);
+
+ Panel p = new Panel();
+ p.setCaption("ExpandLayout");
+ p.setWidth("500px");
+ p.setHeight("500px");
+ p.setContent(new VerticalLayout());
+ p.getContent().setSizeFull();
+
+ w.getContent().addComponent(p);
+
+ tf1 = new TextArea();
+ tf1.setRows(5);
+ tf1.setSizeFull();
+ tf1.setValue(contents);
+ tf1.setCaption("TextField caption");
+ p.getContent().addComponent(tf1);
+
+ /*
+ *
+ * OrderedLayout
+ */
+
+ Panel p2 = new Panel();
+ p2.setCaption("OrderedLayout");
+ p2.setWidth("500px");
+ p2.setHeight("500px");
+ p2.setContent(new VerticalLayout());
+ p2.getContent().setSizeFull();
+
+ w.getContent().addComponent(p2);
+
+ tf2 = new TextArea();
+ tf2.setRows(5);
+ tf2.setSizeFull();
+ tf2.setValue(contents);
+ tf2.setCaption("TextField caption");
+ p2.getContent().addComponent(tf2);
+
+ /*
+ *
+ * GridLayout
+ */
+
+ Panel p3 = new Panel();
+ p3.setCaption("GridLayout");
+ p3.setWidth("500px");
+ p3.setHeight("500px");
+ // p3.setContent(new GridLayout());
+ p3.getContent().setSizeFull();
+ ((Layout) p3.getContent()).setMargin(false);
+
+ GridLayout gl = new GridLayout();
+ gl.setSizeFull();
+ gl.setMargin(false);
+ p3.getContent().addComponent(gl);
+ w.getContent().addComponent(p3);
+
+ tf3 = new TextArea();
+ tf3.setRows(5);
+ tf3.setSizeFull();
+ tf3.setValue(contents);
+ tf3.setCaption("TextField caption");
+ // p3.getContent().addComponent(tf3);
+ gl.addComponent(tf3);
+
+ // Panel pp = new Panel();
+ // pp.setCaption("OrderedLayout");
+ // pp.setWidth("500px");
+ // pp.setHeight("500px");
+ // pp.getContent().setSizeFull();
+ // orderedLayout = new VerticalLayout();
+ // pp.getContent().addComponent(orderedLayout);
+ // w.getContent().addComponent(pp);
+ // createUI(orderedLayout);
+ }
+
+ @SuppressWarnings("unused")
+ private void createUI(Layout layout) {
+ Label l = new Label("Label");
+ Button b = new Button("Enable/disable caption and watch button move",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ System.out.println("Enable/disable caption");
+ for (AbstractComponent l : new AbstractComponent[] {
+ tf1, tf2, tf3 }) {
+ // AbstractComponent l = tf2;
+ // Layout l = (Layout) event.getButton().getData();
+ if (l.getCaption() == null) {
+ l.setCaption("Expand layout caption");
+ } else {
+ l.setCaption(null);
+ }
+ }
+ }
+
+ });
+ b.setData(layout);
+ Label l2 = new Label("This should always be visible");
+
+ layout.addComponent(l);
+ layout.addComponent(b);
+ layout.addComponent(l2);
+
+ if (layout instanceof AbstractOrderedLayout) {
+ ((AbstractOrderedLayout) layout).setExpandRatio(l, 1);
+
+ }
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java
index 17df2a2700..501f11e0b4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java
@@ -1,32 +1,32 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.CustomLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2022 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- setTheme("tests-tickets");
- CustomLayout l;
-
- // WebApplicationContext wac = ((WebApplicationContext) getContext());
- // File f = new File(wac.getBaseDirectory().getAbsoluteFile()
- // + "/VAADIN/themes/" + getTheme() + "/layouts/Ticket2022.html");
-
- l = new CustomLayout("Ticket2022");
- // try {
- // l = new CustomLayout(new FileInputStream(f));
- w.setContent(l);
- // } catch (FileNotFoundException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // } catch (IOException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2022 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ setTheme("tests-tickets");
+ CustomLayout l;
+
+ // WebApplicationContext wac = ((WebApplicationContext) getContext());
+ // File f = new File(wac.getBaseDirectory().getAbsoluteFile()
+ // + "/VAADIN/themes/" + getTheme() + "/layouts/Ticket2022.html");
+
+ l = new CustomLayout("Ticket2022");
+ // try {
+ // l = new CustomLayout(new FileInputStream(f));
+ w.setContent(l);
+ // } catch (FileNotFoundException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // } catch (IOException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java
index 5f0b432790..41c7fd96f1 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java
@@ -1,35 +1,35 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2024 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(2, 2);
- layout.setHeight("100%");
- layout.setWidth("700");
- w.getContent().setSizeFull();
- w.getContent().setHeight("2000");
- w.getContent().addComponent(layout);
-
- layout.addComponent(new Label(
- "This should NOT get stuck when scrolling down"));
- layout.addComponent(new TextField("This should not get stuck either..."));
-
- VerticalLayout ol = new VerticalLayout();
- ol.setHeight("1000");
- ol.setWidth("200");
- w.getContent().addComponent(ol);
- ol.addComponent(new Label("Just a label to enable the scrollbar"));
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2024 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(2, 2);
+ layout.setHeight("100%");
+ layout.setWidth("700");
+ w.getContent().setSizeFull();
+ w.getContent().setHeight("2000");
+ w.getContent().addComponent(layout);
+
+ layout.addComponent(new Label(
+ "This should NOT get stuck when scrolling down"));
+ layout.addComponent(new TextField("This should not get stuck either..."));
+
+ VerticalLayout ol = new VerticalLayout();
+ ol.setHeight("1000");
+ ol.setWidth("200");
+ w.getContent().addComponent(ol);
+ ol.addComponent(new Label("Just a label to enable the scrollbar"));
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java
index be329eb5b5..aa23572e0a 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java
@@ -1,35 +1,35 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2026 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
-
- GridLayout layout = new GridLayout(2, 2);
- layout.setSpacing(true);
-
- @SuppressWarnings("unused")
- int nr = 5;
- TextField tf;
- tf = new TextField("TextField (tabIndex 1)");
- tf.setTabIndex(1);
- tf.focus();
- layout.addComponent(tf);
- layout.addComponent(new TextField("TextField without tab index"));
- layout.addComponent(new TextField("TextField without tab index"));
- layout.addComponent(new TextField("TextField without tab index"));
- layout.addComponent(new TextField("TextField without tab index"));
- tf = new TextField("TextField (tabIndex 2)");
- tf.setTabIndex(2);
- layout.addComponent(tf);
-
- w.setContent(layout);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket2026 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+
+ GridLayout layout = new GridLayout(2, 2);
+ layout.setSpacing(true);
+
+ @SuppressWarnings("unused")
+ int nr = 5;
+ TextField tf;
+ tf = new TextField("TextField (tabIndex 1)");
+ tf.setTabIndex(1);
+ tf.focus();
+ layout.addComponent(tf);
+ layout.addComponent(new TextField("TextField without tab index"));
+ layout.addComponent(new TextField("TextField without tab index"));
+ layout.addComponent(new TextField("TextField without tab index"));
+ layout.addComponent(new TextField("TextField without tab index"));
+ tf = new TextField("TextField (tabIndex 2)");
+ tf.setTabIndex(2);
+ layout.addComponent(tf);
+
+ w.setContent(layout);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java
index cabbab2c32..f13b57d110 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java
@@ -1,139 +1,139 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Random;
-
-import com.vaadin.Application;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.terminal.UserError;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2029 extends Application {
-
- int COMPONENTS;
- int DIM1, DIM2;
- Random r = new Random();
-
- @Override
- public void init() {
- COMPONENTS = 5;
- DIM1 = 504;
- DIM2 = 100;
-
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- Panel p = createPanel();
- w.getContent().addComponent(p);
- // w.getLayout().addComponent(createGLPanel());
- w.getContent().addComponent(createPanelV());
- }
-
- private Panel createPanel() {
- Panel p = new Panel(DIM1 + "x" + DIM2 + " OrderedLayout");
- p.setWidth(DIM1 + "px");
- p.setHeight(DIM2 + "px");
-
- HorizontalLayout layout = new HorizontalLayout();
- p.setContent(layout);
- p.getContent().setSizeFull();
-
- for (int i = 0; i < COMPONENTS; i++) {
- TextField tf = new TextField();
- if (r.nextBoolean()) {
- tf.setCaption("Caption");
- }
- if (r.nextBoolean()) {
- tf.setRequired(true);
- }
- if (r.nextBoolean()) {
- tf.setComponentError(new UserError("Error"));
- }
- tf.setWidth("100%");
- layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
- p.addComponent(tf);
-
- }
-
- return p;
- }
-
- @SuppressWarnings("unused")
- private Panel createGLPanel() {
- Panel p = new Panel("" + DIM1 + "x" + DIM2 + " GridLayout");
- p.setWidth("" + DIM1 + "px");
- p.setHeight("" + DIM2 + "px");
-
- GridLayout layout = new GridLayout(COMPONENTS, 1);
- p.setContent(layout);
- p.getContent().setSizeFull();
-
- for (int i = 0; i < COMPONENTS; i++) {
- TextField tf = new TextField();
- tf.setImmediate(true);
- tf.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- Component c = ((Component) event.getProperty());
- c.setCaption("askfdj");
-
- }
- });
- if (r.nextBoolean()) {
- tf.setCaption("Caption");
- }
- if (r.nextBoolean()) {
- tf.setRequired(true);
- }
- if (r.nextBoolean()) {
- tf.setComponentError(new UserError("Error"));
- }
- tf.setWidth("100%");
- layout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
- p.addComponent(tf);
-
- }
-
- return p;
- }
-
- private Panel createPanelV() {
- Panel p = new Panel("" + DIM1 + "x" + DIM2 + " OrderedLayout");
- p.setWidth("" + DIM2 + "px");
- p.setHeight("" + DIM1 + "px");
-
- VerticalLayout layout = new VerticalLayout();
- p.setContent(layout);
- p.getContent().setSizeFull();
-
- for (int i = 0; i < COMPONENTS; i++) {
- TextArea tf = new TextArea();
- if (r.nextBoolean()) {
- tf.setCaption("Caption");
- }
- if (r.nextBoolean()) {
- tf.setRequired(true);
- }
- if (r.nextBoolean()) {
- tf.setComponentError(new UserError("Error"));
- }
-
- tf.setRows(2);
- tf.setSizeFull();
-
- layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
- p.addComponent(tf);
-
- }
-
- return p;
- }
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Random;
+
+import com.vaadin.Application;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.terminal.UserError;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2029 extends Application {
+
+ int COMPONENTS;
+ int DIM1, DIM2;
+ Random r = new Random();
+
+ @Override
+ public void init() {
+ COMPONENTS = 5;
+ DIM1 = 504;
+ DIM2 = 100;
+
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ Panel p = createPanel();
+ w.getContent().addComponent(p);
+ // w.getLayout().addComponent(createGLPanel());
+ w.getContent().addComponent(createPanelV());
+ }
+
+ private Panel createPanel() {
+ Panel p = new Panel(DIM1 + "x" + DIM2 + " OrderedLayout");
+ p.setWidth(DIM1 + "px");
+ p.setHeight(DIM2 + "px");
+
+ HorizontalLayout layout = new HorizontalLayout();
+ p.setContent(layout);
+ p.getContent().setSizeFull();
+
+ for (int i = 0; i < COMPONENTS; i++) {
+ TextField tf = new TextField();
+ if (r.nextBoolean()) {
+ tf.setCaption("Caption");
+ }
+ if (r.nextBoolean()) {
+ tf.setRequired(true);
+ }
+ if (r.nextBoolean()) {
+ tf.setComponentError(new UserError("Error"));
+ }
+ tf.setWidth("100%");
+ layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+ p.addComponent(tf);
+
+ }
+
+ return p;
+ }
+
+ @SuppressWarnings("unused")
+ private Panel createGLPanel() {
+ Panel p = new Panel("" + DIM1 + "x" + DIM2 + " GridLayout");
+ p.setWidth("" + DIM1 + "px");
+ p.setHeight("" + DIM2 + "px");
+
+ GridLayout layout = new GridLayout(COMPONENTS, 1);
+ p.setContent(layout);
+ p.getContent().setSizeFull();
+
+ for (int i = 0; i < COMPONENTS; i++) {
+ TextField tf = new TextField();
+ tf.setImmediate(true);
+ tf.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ Component c = ((Component) event.getProperty());
+ c.setCaption("askfdj");
+
+ }
+ });
+ if (r.nextBoolean()) {
+ tf.setCaption("Caption");
+ }
+ if (r.nextBoolean()) {
+ tf.setRequired(true);
+ }
+ if (r.nextBoolean()) {
+ tf.setComponentError(new UserError("Error"));
+ }
+ tf.setWidth("100%");
+ layout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
+ p.addComponent(tf);
+
+ }
+
+ return p;
+ }
+
+ private Panel createPanelV() {
+ Panel p = new Panel("" + DIM1 + "x" + DIM2 + " OrderedLayout");
+ p.setWidth("" + DIM2 + "px");
+ p.setHeight("" + DIM1 + "px");
+
+ VerticalLayout layout = new VerticalLayout();
+ p.setContent(layout);
+ p.getContent().setSizeFull();
+
+ for (int i = 0; i < COMPONENTS; i++) {
+ TextArea tf = new TextArea();
+ if (r.nextBoolean()) {
+ tf.setCaption("Caption");
+ }
+ if (r.nextBoolean()) {
+ tf.setRequired(true);
+ }
+ if (r.nextBoolean()) {
+ tf.setComponentError(new UserError("Error"));
+ }
+
+ tf.setRows(2);
+ tf.setSizeFull();
+
+ layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
+ p.addComponent(tf);
+
+ }
+
+ return p;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java
index 652983c423..782cbd06c2 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java
@@ -1,48 +1,48 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2037 extends com.vaadin.Application {
-
- @Override
- public void init() {
- Window main = new Window();
- setMainWindow(main);
-
- main.addComponent(new Label(
- "Use debug dialog and trac number of registered paintables. It should not grow on subsequant b clicks."));
-
- final Layout lo = new VerticalLayout();
-
- Button b = new Button("b");
-
- main.addComponent(b);
- main.addComponent(lo);
- b.addListener(new Button.ClickListener() {
-
- public void buttonClick(ClickEvent event) {
-
- repopupate(lo);
-
- }
- });
-
- }
-
- int counter = 0;
-
- protected void repopupate(Layout lo) {
- lo.removeAllComponents();
-
- for (int i = 0; i < 20; i++) {
- lo.addComponent(new Label("tc" + (counter++)));
- }
-
- }
-
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2037 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ Window main = new Window();
+ setMainWindow(main);
+
+ main.addComponent(new Label(
+ "Use debug dialog and trac number of registered paintables. It should not grow on subsequant b clicks."));
+
+ final Layout lo = new VerticalLayout();
+
+ Button b = new Button("b");
+
+ main.addComponent(b);
+ main.addComponent(lo);
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+
+ repopupate(lo);
+
+ }
+ });
+
+ }
+
+ int counter = 0;
+
+ protected void repopupate(Layout lo) {
+ lo.removeAllComponents();
+
+ for (int i = 0; i < 20; i++) {
+ lo.addComponent(new Label("tc" + (counter++)));
+ }
+
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java
index f1775da039..35210ebaa4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java
@@ -1,87 +1,87 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Accordion;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2040 extends com.vaadin.Application {
-
- TextField f = new TextField();
-
- @Override
- public void init() {
- Window main = new Window();
- setMainWindow(main);
-
- main.getContent().setSizeFull();
- ((Layout) main.getContent()).setMargin(true);
-
- setTheme("tests-tickets");
-
- Accordion ts;
-
- ts = new Accordion();
- ts.setSizeFull();
- ts.setWidth("300px");
-
- TextArea l = new TextArea("DSFS");
- l.setRows(2);
- l.setStyleName("red");
- l.setSizeFull();
- ts.addTab(l, "100% h component", null);
-
- Label testContent = new Label(
- "TabSheet by default uses caption, icon, errors etc. from Components. ");
-
- testContent.setCaption("Introduction to test");
-
- ts.addTab(testContent);
-
- // main.addComponent(ts);
-
- ts = new Accordion();
- ts.setSizeFull();
- ts.setHeight("200px");
- ts.setWidth("300px");
-
- l = new TextArea("DSFS");
- l.setRows(2);
- l.setStyleName("red");
- l.setSizeFull();
- ts.addTab(l, "200px h component", null);
-
- testContent = new Label(
- "TabSheet by default uses caption, icon, errors etc. from Components. ");
-
- testContent.setCaption("Introduction to test");
-
- ts.addTab(testContent);
-
- main.addComponent(ts);
-
- ts = new Accordion();
- ts.setSizeFull();
- ts.setHeight("50%");
- ts.setWidth("300px");
-
- l = new TextArea("DSFS");
- l.setRows(2);
- l.setStyleName("red");
- l.setSizeFull();
- ts.addTab(l, "50% h component", null);
-
- testContent = new Label(
- "TabSheet by default uses caption, icon, errors etc. from Components. ");
-
- testContent.setCaption("Introduction to test");
-
- ts.addTab(testContent);
-
- // main.addComponent(ts);
-
- }
-
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Accordion;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket2040 extends com.vaadin.Application {
+
+ TextField f = new TextField();
+
+ @Override
+ public void init() {
+ Window main = new Window();
+ setMainWindow(main);
+
+ main.getContent().setSizeFull();
+ ((Layout) main.getContent()).setMargin(true);
+
+ setTheme("tests-tickets");
+
+ Accordion ts;
+
+ ts = new Accordion();
+ ts.setSizeFull();
+ ts.setWidth("300px");
+
+ TextArea l = new TextArea("DSFS");
+ l.setRows(2);
+ l.setStyleName("red");
+ l.setSizeFull();
+ ts.addTab(l, "100% h component", null);
+
+ Label testContent = new Label(
+ "TabSheet by default uses caption, icon, errors etc. from Components. ");
+
+ testContent.setCaption("Introduction to test");
+
+ ts.addTab(testContent);
+
+ // main.addComponent(ts);
+
+ ts = new Accordion();
+ ts.setSizeFull();
+ ts.setHeight("200px");
+ ts.setWidth("300px");
+
+ l = new TextArea("DSFS");
+ l.setRows(2);
+ l.setStyleName("red");
+ l.setSizeFull();
+ ts.addTab(l, "200px h component", null);
+
+ testContent = new Label(
+ "TabSheet by default uses caption, icon, errors etc. from Components. ");
+
+ testContent.setCaption("Introduction to test");
+
+ ts.addTab(testContent);
+
+ main.addComponent(ts);
+
+ ts = new Accordion();
+ ts.setSizeFull();
+ ts.setHeight("50%");
+ ts.setWidth("300px");
+
+ l = new TextArea("DSFS");
+ l.setRows(2);
+ l.setStyleName("red");
+ l.setSizeFull();
+ ts.addTab(l, "50% h component", null);
+
+ testContent = new Label(
+ "TabSheet by default uses caption, icon, errors etc. from Components. ");
+
+ testContent.setCaption("Introduction to test");
+
+ ts.addTab(testContent);
+
+ // main.addComponent(ts);
+
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java
index 2dfe4a1cb5..1714a93f82 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java
@@ -1,38 +1,38 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Window.Notification;
-
-public class Ticket2042 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(1, 2);
- layout.setHeight("2000px");
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- layout.addComponent(new Label("abc"));
- layout.addComponent(new Button("B", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Notification n = new Notification("Test");
- getMainWindow().showNotification(n);
- }
-
- }));
-
- layout.addComponent(new Label("abc"));
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.Window.Notification;
+
+public class Ticket2042 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(1, 2);
+ layout.setHeight("2000px");
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ layout.addComponent(new Label("abc"));
+ layout.addComponent(new Button("B", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Notification n = new Notification("Test");
+ getMainWindow().showNotification(n);
+ }
+
+ }));
+
+ layout.addComponent(new Label("abc"));
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java
index faea096744..ce42699094 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java
@@ -1,28 +1,28 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Window;
-
-public class Ticket2043 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- Link l = new Link("Vaadin home (new 200x200 window, no decor, icon)",
- new ExternalResource("http://www.vaadin.com"), "_blank", 200,
- 200, Link.TARGET_BORDER_NONE);
-
- layout.addComponent(l);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Window;
+
+public class Ticket2043 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ Link l = new Link("Vaadin home (new 200x200 window, no decor, icon)",
+ new ExternalResource("http://www.vaadin.com"), "_blank", 200,
+ 200, Link.TARGET_BORDER_NONE);
+
+ layout.addComponent(l);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java
index 65b5f73b53..92a08eced9 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java
@@ -1,103 +1,103 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.ThemeResource;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Embedded;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2048 extends Application {
-
- private Embedded embedded;
- private Panel p;
- private VerticalLayout orderedLayout;
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- // splitPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
- // getMainWindow().setContent(splitPanel);
-
- // GridLayout layout = new GridLayout(10, 10);
- // w.setContent(layout);
- // gridLayout = new GridLayout(1, 1);
- orderedLayout = new VerticalLayout();
-
- getMainWindow().setContent(orderedLayout);
- // getMainWindow().setContent(new GridLayout(1, 1));
- getMainWindow().setSizeFull();
- getMainWindow().getContent().setSizeFull();
-
- createUI(orderedLayout);
- // createUI(gridLayout);
-
- }
-
- private void createUI(Layout layout) {
- // Button sw = new Button("Switch", new ClickListener() {
- //
- // public void buttonClick(ClickEvent event) {
- // Layout l = getMainWindow().getLayout();
- // if (l == orderedLayout) {
- // getMainWindow().setContent(gridLayout);
- // } else {
- // getMainWindow().setContent(orderedLayout);
- // }
- //
- // }
- // });
- // layout.addComponent(sw);
-
- Layout ol = new GridLayout(1, 2);
- p = new Panel("Panel", ol);
- p.setSizeFull();
- Label l = new Label("Spacer");
- l.setHeight("400px");
- p.addComponent(l);
-
- embedded = new Embedded(null, new ThemeResource(
- "icons/64/folder-add.png"));
- layout.addComponent(embedded);
- Button b = new Button(
- "Replace image with new embedded component (flashes)",
- new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- Embedded newEmbedded = new Embedded(null,
- new ThemeResource("icons/64/folder-add.png"));
- getMainWindow().getContent().replaceComponent(embedded,
- newEmbedded);
- embedded = newEmbedded;
-
- }
-
- });
- p.addComponent(b);
-
- b = new Button("Change image source (is fine)", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- String img = "folder-add";
- if (((ThemeResource) embedded.getSource()).getResourceId()
- .contains("folder-add")) {
- img = "folder-delete";
- }
- embedded.setSource(new ThemeResource("icons/64/" + img + ".png"));
-
- }
-
- });
-
- p.addComponent(b);
- layout.addComponent(p);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.ThemeResource;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2048 extends Application {
+
+ private Embedded embedded;
+ private Panel p;
+ private VerticalLayout orderedLayout;
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ // splitPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+ // getMainWindow().setContent(splitPanel);
+
+ // GridLayout layout = new GridLayout(10, 10);
+ // w.setContent(layout);
+ // gridLayout = new GridLayout(1, 1);
+ orderedLayout = new VerticalLayout();
+
+ getMainWindow().setContent(orderedLayout);
+ // getMainWindow().setContent(new GridLayout(1, 1));
+ getMainWindow().setSizeFull();
+ getMainWindow().getContent().setSizeFull();
+
+ createUI(orderedLayout);
+ // createUI(gridLayout);
+
+ }
+
+ private void createUI(Layout layout) {
+ // Button sw = new Button("Switch", new ClickListener() {
+ //
+ // public void buttonClick(ClickEvent event) {
+ // Layout l = getMainWindow().getLayout();
+ // if (l == orderedLayout) {
+ // getMainWindow().setContent(gridLayout);
+ // } else {
+ // getMainWindow().setContent(orderedLayout);
+ // }
+ //
+ // }
+ // });
+ // layout.addComponent(sw);
+
+ Layout ol = new GridLayout(1, 2);
+ p = new Panel("Panel", ol);
+ p.setSizeFull();
+ Label l = new Label("Spacer");
+ l.setHeight("400px");
+ p.addComponent(l);
+
+ embedded = new Embedded(null, new ThemeResource(
+ "icons/64/folder-add.png"));
+ layout.addComponent(embedded);
+ Button b = new Button(
+ "Replace image with new embedded component (flashes)",
+ new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Embedded newEmbedded = new Embedded(null,
+ new ThemeResource("icons/64/folder-add.png"));
+ getMainWindow().getContent().replaceComponent(embedded,
+ newEmbedded);
+ embedded = newEmbedded;
+
+ }
+
+ });
+ p.addComponent(b);
+
+ b = new Button("Change image source (is fine)", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ String img = "folder-add";
+ if (((ThemeResource) embedded.getSource()).getResourceId()
+ .contains("folder-add")) {
+ img = "folder-delete";
+ }
+ embedded.setSource(new ThemeResource("icons/64/" + img + ".png"));
+
+ }
+
+ });
+
+ p.addComponent(b);
+ layout.addComponent(p);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java
index e901ebc343..29aeef21b1 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java
@@ -1,44 +1,44 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.data.Item;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2051 extends Application {
-
- private static final Object P1 = new Object();
- private static final Object P2 = new Object();
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- Table t = new Table("This is a table");
- t.addContainerProperty(P1, Component.class, null);
- t.addContainerProperty(P2, Component.class, null);
- t.setColumnHeaders(new String[] { "Col1", "Col2" });
-
- Item i = t.addItem("1");
- i.getItemProperty(P1).setValue(new TextField("abc"));
- i.getItemProperty(P2).setValue(new Label("label"));
- Item i2 = t.addItem("2");
- i2.getItemProperty(P1).setValue(new Button("def"));
- i2.getItemProperty(P2).setValue(new DateField());
-
- layout.addComponent(t);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.data.Item;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket2051 extends Application {
+
+ private static final Object P1 = new Object();
+ private static final Object P2 = new Object();
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ Table t = new Table("This is a table");
+ t.addContainerProperty(P1, Component.class, null);
+ t.addContainerProperty(P2, Component.class, null);
+ t.setColumnHeaders(new String[] { "Col1", "Col2" });
+
+ Item i = t.addItem("1");
+ i.getItemProperty(P1).setValue(new TextField("abc"));
+ i.getItemProperty(P2).setValue(new Label("label"));
+ Item i2 = t.addItem("2");
+ i2.getItemProperty(P1).setValue(new Button("def"));
+ i2.getItemProperty(P2).setValue(new DateField());
+
+ layout.addComponent(t);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java
index 63bf5b3ff7..061c71a509 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java
@@ -1,50 +1,50 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2060 extends Application {
-
- private Button button1;
- private Button button2;
- private Button button3;
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- HorizontalLayout buttonLayout = new HorizontalLayout();
- button1 = new Button("Button which is 50px wide");
- button1.setWidth("50px");
- button2 = new Button("Button without width");
- button3 = new Button("Click to repaint buttons", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- button1.requestRepaint();
- button2.requestRepaint();
- button3.requestRepaint();
-
- }
-
- });
-
- buttonLayout.addComponent(button1);
- buttonLayout.addComponent(button2);
- buttonLayout.addComponent(button3);
-
- layout.addComponent(buttonLayout);
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2060 extends Application {
+
+ private Button button1;
+ private Button button2;
+ private Button button3;
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ HorizontalLayout buttonLayout = new HorizontalLayout();
+ button1 = new Button("Button which is 50px wide");
+ button1.setWidth("50px");
+ button2 = new Button("Button without width");
+ button3 = new Button("Click to repaint buttons", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ button1.requestRepaint();
+ button2.requestRepaint();
+ button3.requestRepaint();
+
+ }
+
+ });
+
+ buttonLayout.addComponent(button1);
+ buttonLayout.addComponent(button2);
+ buttonLayout.addComponent(button3);
+
+ layout.addComponent(buttonLayout);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java
index 2dabffe5f4..5b6bbe71de 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java
@@ -1,41 +1,41 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket2062 extends Application {
- private static final Object P1 = new Object();
-
- @Override
- public void init() {
- setMainWindow(new Window("Ticket2062"));
- getMainWindow().setSizeFull();
-
- HorizontalSplitPanel p = new HorizontalSplitPanel();
- p.setSizeFull();
- getMainWindow().setContent(p);
-
- TextField tf1 = new TextField("Tab 1");
- tf1.setValue("Field 1");
- tf1.setSizeFull();
-
- Table t = new Table("Table");
- t.addContainerProperty(P1, String.class, "");
- t.setSizeFull();
-
- TabSheet tabSheet = new TabSheet();
- tabSheet.setWidth("300px");
- tabSheet.setHeight("300px");
-
- tabSheet.addComponent(tf1);
- tabSheet.addComponent(t);
-
- getMainWindow().addComponent(tabSheet);
-
- }
-
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket2062 extends Application {
+ private static final Object P1 = new Object();
+
+ @Override
+ public void init() {
+ setMainWindow(new Window("Ticket2062"));
+ getMainWindow().setSizeFull();
+
+ HorizontalSplitPanel p = new HorizontalSplitPanel();
+ p.setSizeFull();
+ getMainWindow().setContent(p);
+
+ TextField tf1 = new TextField("Tab 1");
+ tf1.setValue("Field 1");
+ tf1.setSizeFull();
+
+ Table t = new Table("Table");
+ t.addContainerProperty(P1, String.class, "");
+ t.setSizeFull();
+
+ TabSheet tabSheet = new TabSheet();
+ tabSheet.setWidth("300px");
+ tabSheet.setHeight("300px");
+
+ tabSheet.addComponent(tf1);
+ tabSheet.addComponent(t);
+
+ getMainWindow().addComponent(tabSheet);
+
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java
index e722c6826c..25ecfabbec 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java
@@ -1,28 +1,28 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Window;
-
-public class Ticket2083 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- Panel p = new Panel(
- "This is a panel with a longer caption than it should have");
- p.setWidth("100px");
- p.getContent().addComponent(new Label("Contents"));
- layout.addComponent(p);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Window;
+
+public class Ticket2083 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ Panel p = new Panel(
+ "This is a panel with a longer caption than it should have");
+ p.setWidth("100px");
+ p.getContent().addComponent(new Label("Contents"));
+ layout.addComponent(p);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java
index 0911cb6830..42486748d2 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java
@@ -1,29 +1,29 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.ui.Embedded;
-import com.vaadin.ui.Window;
-
-public class Ticket2095 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
-
- // uncomment to workaround iorderedlayout bug in current trunk
- // w.setContent(new ExpandLayout());
- w.getContent().setSizeFull();
-
- Embedded em = new Embedded();
- em.setType(Embedded.TYPE_BROWSER);
- em.setSource(new ExternalResource("../statictestfiles/ticket2095.html"));
- em.setDebugId("MYIFRAME");
-
- em.setSizeFull();
-
- w.addComponent(em);
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.Window;
+
+public class Ticket2095 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+
+ // uncomment to workaround iorderedlayout bug in current trunk
+ // w.setContent(new ExpandLayout());
+ w.getContent().setSizeFull();
+
+ Embedded em = new Embedded();
+ em.setType(Embedded.TYPE_BROWSER);
+ em.setSource(new ExternalResource("../statictestfiles/ticket2095.html"));
+ em.setDebugId("MYIFRAME");
+
+ em.setSizeFull();
+
+ w.addComponent(em);
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java
index 829fb30070..4d02862e4b 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java
@@ -1,37 +1,37 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.Window;
-
-public class Ticket2098 extends Application {
-
- private static final String info = "First tab hidden, second should initially be selected";
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- w.addComponent(new Label(info));
- createUI(w);
- }
-
- private void createUI(Window w) {
- TabSheet ts = new TabSheet();
- Label l1 = new Label("111");
- Label l2 = new Label("222");
- Label l3 = new Label("333");
- Label l4 = new Label("444");
-
- ts.addTab(l1, "1", null);
- ts.addTab(l2, "2", null);
- ts.addTab(l3, "3", null);
- ts.addTab(l4, "4", null);
-
- l1.setVisible(false);
-
- w.addComponent(ts);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.Window;
+
+public class Ticket2098 extends Application {
+
+ private static final String info = "First tab hidden, second should initially be selected";
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ w.addComponent(new Label(info));
+ createUI(w);
+ }
+
+ private void createUI(Window w) {
+ TabSheet ts = new TabSheet();
+ Label l1 = new Label("111");
+ Label l2 = new Label("222");
+ Label l3 = new Label("333");
+ Label l4 = new Label("444");
+
+ ts.addTab(l1, "1", null);
+ ts.addTab(l2, "2", null);
+ ts.addTab(l3, "3", null);
+ ts.addTab(l4, "4", null);
+
+ l1.setVisible(false);
+
+ w.addComponent(ts);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java
index 4f79eb7e64..d0021ae75f 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java
@@ -1,77 +1,77 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2099 extends Application {
-
- private Label l1, l2, l3;
- private VerticalLayout ol1, ol2, ol3;
- private Window popup;
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
- // setTheme("tests-tickets");
- GridLayout layout = new GridLayout(10, 10);
- w.setContent(layout);
- createUI(layout);
- }
-
- private void createUI(GridLayout layout) {
- Button b = new Button("Show popup", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- getMainWindow().addWindow(popup);
- // popup.setVisible(true);
- }
-
- });
- popup = createPopup();
- addWindow(popup);
-
- layout.addComponent(b);
- layout.addComponent(new Button("Hide label '222'", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- l2.setVisible(!l2.isVisible());
- }
-
- }));
-
- }
-
- private Window createPopup() {
- Window w = new Window("Popup");
- TabSheet ts = new TabSheet();
- ol1 = new VerticalLayout();
- ol2 = new VerticalLayout();
- ol3 = new VerticalLayout();
- l1 = new Label("111");
- l2 = new Label("222");
- l3 = new Label("333");
-
- ol1.addComponent(l1);
- ol2.addComponent(l2);
- ol3.addComponent(l3);
-
- ts.addTab(ol1, "1", null);
- ts.addTab(ol2, "2", null);
- ts.addTab(ol3, "3", null);
-
- // l1.setVisible(false);
- // ts.setSelectedTab(l3);
-
- w.addComponent(ts);
-
- return w;
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2099 extends Application {
+
+ private Label l1, l2, l3;
+ private VerticalLayout ol1, ol2, ol3;
+ private Window popup;
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+ // setTheme("tests-tickets");
+ GridLayout layout = new GridLayout(10, 10);
+ w.setContent(layout);
+ createUI(layout);
+ }
+
+ private void createUI(GridLayout layout) {
+ Button b = new Button("Show popup", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ getMainWindow().addWindow(popup);
+ // popup.setVisible(true);
+ }
+
+ });
+ popup = createPopup();
+ addWindow(popup);
+
+ layout.addComponent(b);
+ layout.addComponent(new Button("Hide label '222'", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ l2.setVisible(!l2.isVisible());
+ }
+
+ }));
+
+ }
+
+ private Window createPopup() {
+ Window w = new Window("Popup");
+ TabSheet ts = new TabSheet();
+ ol1 = new VerticalLayout();
+ ol2 = new VerticalLayout();
+ ol3 = new VerticalLayout();
+ l1 = new Label("111");
+ l2 = new Label("222");
+ l3 = new Label("333");
+
+ ol1.addComponent(l1);
+ ol2.addComponent(l2);
+ ol3.addComponent(l3);
+
+ ts.addTab(ol1, "1", null);
+ ts.addTab(ol2, "2", null);
+ ts.addTab(ol3, "3", null);
+
+ // l1.setVisible(false);
+ // ts.setSelectedTab(l3);
+
+ w.addComponent(ts);
+
+ return w;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java
index 8c12ca10ce..7d3412bfd8 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java
@@ -1,21 +1,21 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Window;
-
-public class Ticket2101 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
-
- Button b = new Button(
- "Button with a long text which will not fit on 50 pixels");
- b.setWidth("50px");
-
- w.getContent().addComponent(b);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Window;
+
+public class Ticket2101 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+
+ Button b = new Button(
+ "Button with a long text which will not fit on 50 pixels");
+ b.setWidth("50px");
+
+ w.getContent().addComponent(b);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java
index 01ef18f2ef..4de873a7fc 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java
@@ -1,62 +1,62 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Window;
-
-/**
- *
- * Toggling container with an empty one may result duplicate header cell in
- * client.
- *
- */
-public class Ticket2126 extends com.vaadin.Application {
-
- Window main = new Window();
- Table table = new Table();
-
- @Override
- public void init() {
- setMainWindow(main);
-
- final IndexedContainer container1 = new IndexedContainer();
- container1.addContainerProperty("text", Component.class, null);
- final IndexedContainer container2 = new IndexedContainer();
-
- // Case #2 Try to comment the following line for another type of strange
- // behaviour
- container2.addContainerProperty("text", Component.class, null);
-
- for (int i = 0; i < 100; i++) {
- Item item = container1.addItem(i);
- item.getItemProperty("text").setValue(new Label("Test " + i));
- }
-
- table.setContainerDataSource(container1);
-
- // workaround for case #2
- // table.setWidth("300px");
- // table.setHeight("300px");
-
- Button refreshTable = new Button("Switch table container");
- refreshTable.addListener(new Button.ClickListener() {
- boolean full = true;
-
- public void buttonClick(Button.ClickEvent e) {
- if (full) {
- table.setContainerDataSource(container2);
- } else {
- table.setContainerDataSource(container1);
- }
- full = !full;
- }
- });
-
- main.addComponent(table);
- main.addComponent(refreshTable);
- }
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Window;
+
+/**
+ *
+ * Toggling container with an empty one may result duplicate header cell in
+ * client.
+ *
+ */
+public class Ticket2126 extends com.vaadin.Application {
+
+ Window main = new Window();
+ Table table = new Table();
+
+ @Override
+ public void init() {
+ setMainWindow(main);
+
+ final IndexedContainer container1 = new IndexedContainer();
+ container1.addContainerProperty("text", Component.class, null);
+ final IndexedContainer container2 = new IndexedContainer();
+
+ // Case #2 Try to comment the following line for another type of strange
+ // behaviour
+ container2.addContainerProperty("text", Component.class, null);
+
+ for (int i = 0; i < 100; i++) {
+ Item item = container1.addItem(i);
+ item.getItemProperty("text").setValue(new Label("Test " + i));
+ }
+
+ table.setContainerDataSource(container1);
+
+ // workaround for case #2
+ // table.setWidth("300px");
+ // table.setHeight("300px");
+
+ Button refreshTable = new Button("Switch table container");
+ refreshTable.addListener(new Button.ClickListener() {
+ boolean full = true;
+
+ public void buttonClick(Button.ClickEvent e) {
+ if (full) {
+ table.setContainerDataSource(container2);
+ } else {
+ table.setContainerDataSource(container1);
+ }
+ full = !full;
+ }
+ });
+
+ main.addComponent(table);
+ main.addComponent(refreshTable);
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java
index a326a0c381..ff3d9e6ca1 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java
@@ -1,68 +1,68 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.data.Item;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.Table.CellStyleGenerator;
-import com.vaadin.ui.Table.ColumnGenerator;
-import com.vaadin.ui.Window;
-
-public class Ticket2208 extends Application {
-
- private Table t;
-
- @Override
- public void init() {
- Window mainWindow = new Window();
- setMainWindow(mainWindow);
-
- t = new Table("A table");
- t.addContainerProperty("col 1 (red)", String.class, "");
- t.addContainerProperty("col 2", String.class, "");
-
- t.setHeight("150px");
- t.addGeneratedColumn("col 3 (green)", new ColumnGenerator() {
-
- public Component generateCell(Table source, Object itemId,
- Object columnId) {
- Item item = source.getItem(itemId);
- String col1 = (String) item.getItemProperty("col 1 (red)")
- .getValue();
- String col2 = (String) item.getItemProperty("col 2").getValue();
- return new Label(col1 + "-" + col2);
- }
- });
-
- t.addContainerProperty("col 4", String.class, "");
- t.setCellStyleGenerator(new CellStyleGenerator() {
-
- public String getStyle(Object itemId, Object propertyId) {
- if ("col 1 (red)".equals(propertyId)) {
- return "red";
- }
-
- if ("col 3 (green)".equals(propertyId)) {
- return "green";
- }
-
- return null;
- }
- });
-
- t.addItem(new Object[] { "Col 1-1", "Col 2-1", "Col 4-1" },
- new Object());
- t.addItem(new Object[] { "Col 1-2", "Col 2-2", "Col 4-2" },
- new Object());
- t.addItem(new Object[] { "Col 1-3", "Col 2-3", "Col 4-3" },
- new Object());
-
- t.setColumnReorderingAllowed(true);
- t.setColumnCollapsingAllowed(true);
- setTheme("tests-tickets");
- mainWindow.addComponent(t);
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.data.Item;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.CellStyleGenerator;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.Window;
+
+public class Ticket2208 extends Application {
+
+ private Table t;
+
+ @Override
+ public void init() {
+ Window mainWindow = new Window();
+ setMainWindow(mainWindow);
+
+ t = new Table("A table");
+ t.addContainerProperty("col 1 (red)", String.class, "");
+ t.addContainerProperty("col 2", String.class, "");
+
+ t.setHeight("150px");
+ t.addGeneratedColumn("col 3 (green)", new ColumnGenerator() {
+
+ public Component generateCell(Table source, Object itemId,
+ Object columnId) {
+ Item item = source.getItem(itemId);
+ String col1 = (String) item.getItemProperty("col 1 (red)")
+ .getValue();
+ String col2 = (String) item.getItemProperty("col 2").getValue();
+ return new Label(col1 + "-" + col2);
+ }
+ });
+
+ t.addContainerProperty("col 4", String.class, "");
+ t.setCellStyleGenerator(new CellStyleGenerator() {
+
+ public String getStyle(Object itemId, Object propertyId) {
+ if ("col 1 (red)".equals(propertyId)) {
+ return "red";
+ }
+
+ if ("col 3 (green)".equals(propertyId)) {
+ return "green";
+ }
+
+ return null;
+ }
+ });
+
+ t.addItem(new Object[] { "Col 1-1", "Col 2-1", "Col 4-1" },
+ new Object());
+ t.addItem(new Object[] { "Col 1-2", "Col 2-2", "Col 4-2" },
+ new Object());
+ t.addItem(new Object[] { "Col 1-3", "Col 2-3", "Col 4-3" },
+ new Object());
+
+ t.setColumnReorderingAllowed(true);
+ t.setColumnCollapsingAllowed(true);
+ setTheme("tests-tickets");
+ mainWindow.addComponent(t);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java
index 7ee8a07405..c6b30fa52f 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java
@@ -1,42 +1,42 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class Ticket2209 extends Application {
-
- private GridLayout gl;
- private ComboBox combo;
- private Label labelLong;
-
- @Override
- public void init() {
- setMainWindow(new Window());
-
- gl = new GridLayout(1, 2);
- gl.setStyleName("borders");
- getMainWindow().addComponent(gl);
- setTheme("tests-tickets");
- combo = new ComboBox("Combo caption");
- labelLong = new Label(
- "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?");
- gl.addComponent(combo);
- gl.addComponent(labelLong);
-
- Button b = new Button("Add label text", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- labelLong.setValue(labelLong.getValue() + "-12345");
- }
-
- });
- getMainWindow().addComponent(b);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class Ticket2209 extends Application {
+
+ private GridLayout gl;
+ private ComboBox combo;
+ private Label labelLong;
+
+ @Override
+ public void init() {
+ setMainWindow(new Window());
+
+ gl = new GridLayout(1, 2);
+ gl.setStyleName("borders");
+ getMainWindow().addComponent(gl);
+ setTheme("tests-tickets");
+ combo = new ComboBox("Combo caption");
+ labelLong = new Label(
+ "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?");
+ gl.addComponent(combo);
+ gl.addComponent(labelLong);
+
+ Button b = new Button("Add label text", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ labelLong.setValue(labelLong.getValue() + "-12345");
+ }
+
+ });
+ getMainWindow().addComponent(b);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java
index b7b7b8aba1..c7305bd0fb 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java
@@ -1,49 +1,49 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2209OL extends Application {
-
- private VerticalLayout gl;
- private ComboBox combo;
- private Label labelLong;
-
- @Override
- public void init() {
- setMainWindow(new Window());
- getMainWindow().getContent().setWidth("250px");
- gl = new VerticalLayout();
- gl.setStyleName("borders");
- getMainWindow().addComponent(gl);
- setTheme("tests-tickets");
- combo = new ComboBox("Combo caption");
- labelLong = new Label(
- "This should stay on one line or to wrap to multiple lines? At leas it should display all the text?. "
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?");
- gl.addComponent(combo);
- gl.addComponent(labelLong);
-
- Button b = new Button("Add label text", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- labelLong.setValue(labelLong.getValue() + "-12345");
- }
-
- });
- getMainWindow().addComponent(b);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2209OL extends Application {
+
+ private VerticalLayout gl;
+ private ComboBox combo;
+ private Label labelLong;
+
+ @Override
+ public void init() {
+ setMainWindow(new Window());
+ getMainWindow().getContent().setWidth("250px");
+ gl = new VerticalLayout();
+ gl.setStyleName("borders");
+ getMainWindow().addComponent(gl);
+ setTheme("tests-tickets");
+ combo = new ComboBox("Combo caption");
+ labelLong = new Label(
+ "This should stay on one line or to wrap to multiple lines? At leas it should display all the text?. "
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?");
+ gl.addComponent(combo);
+ gl.addComponent(labelLong);
+
+ Button b = new Button("Add label text", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ labelLong.setValue(labelLong.getValue() + "-12345");
+ }
+
+ });
+ getMainWindow().addComponent(b);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java
index 99103e7e42..d7385562cd 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java
@@ -1,55 +1,55 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2209OL2 extends Application {
-
- private VerticalLayout gl;
- private ComboBox combo;
- private Label labelLong;
-
- @Override
- public void init() {
- setMainWindow(new Window());
- getMainWindow().getContent().setWidth("250px");
- gl = new VerticalLayout();
- gl.setSizeUndefined();
- gl.setStyleName("borders");
- getMainWindow().addComponent(gl);
- setTheme("tests-tickets");
- combo = new ComboBox("Combo caption");
- labelLong = new Label(
- "This should stay on one line or to wrap to multiple lines? At leas it should display all the text?. "
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
- + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?");
- gl.addComponent(combo);
- gl.addComponent(labelLong);
-
- Button b = new Button("Add label text", new ClickListener() {
-
- public void buttonClick(ClickEvent event) {
- labelLong.setValue(labelLong.getValue() + "-12345");
- }
-
- });
- getMainWindow().addComponent(b);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2209OL2 extends Application {
+
+ private VerticalLayout gl;
+ private ComboBox combo;
+ private Label labelLong;
+
+ @Override
+ public void init() {
+ setMainWindow(new Window());
+ getMainWindow().getContent().setWidth("250px");
+ gl = new VerticalLayout();
+ gl.setSizeUndefined();
+ gl.setStyleName("borders");
+ getMainWindow().addComponent(gl);
+ setTheme("tests-tickets");
+ combo = new ComboBox("Combo caption");
+ labelLong = new Label(
+ "This should stay on one line or to wrap to multiple lines? At leas it should display all the text?. "
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?"
+ + "A long label, longer than the combo box. Why doesn't it affect the width? And why is the gridlayout so high?");
+ gl.addComponent(combo);
+ gl.addComponent(labelLong);
+
+ Button b = new Button("Add label text", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ labelLong.setValue(labelLong.getValue() + "-12345");
+ }
+
+ });
+ getMainWindow().addComponent(b);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java
index 221f84f86f..62ed69e433 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java
@@ -1,29 +1,29 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.themes.Reindeer;
-
-public class Ticket2215 extends Application {
-
- @Override
- public void init() {
- setMainWindow(new Window());
-
- VerticalLayout ol = new VerticalLayout();
- Panel p = new Panel("Test");
- p.addComponent(new Label("Panel1"));
- p.setHeight("500px");
- p.setWidth("500px");
- p.setStyleName(Reindeer.PANEL_LIGHT);
- ol.addComponent(p);
- ol.addComponent(new Label("NextComponent"));
-
- getMainWindow().addComponent(ol);
-
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
+
+public class Ticket2215 extends Application {
+
+ @Override
+ public void init() {
+ setMainWindow(new Window());
+
+ VerticalLayout ol = new VerticalLayout();
+ Panel p = new Panel("Test");
+ p.addComponent(new Label("Panel1"));
+ p.setHeight("500px");
+ p.setWidth("500px");
+ p.setStyleName(Reindeer.PANEL_LIGHT);
+ ol.addComponent(p);
+ ol.addComponent(new Label("NextComponent"));
+
+ getMainWindow().addComponent(ol);
+
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java
index 6df6717c33..ab4e83f0ba 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java
@@ -1,74 +1,74 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.SpacingHandler;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2232 extends Application {
-
- @Override
- public void init() {
- setMainWindow(new Window());
- setTheme("tests-tickets");
-
- getMainWindow()
- .addComponent(
- new Label(
- "Defining spacing must be possible also with pure CSS"));
-
- Layout gl;
- gl = new VerticalLayout();
- gl.setWidth("100%");
- gl.setHeight("200px");
- gl.setStyleName("t2232");
- fillAndAdd(gl);
-
- gl = new GridLayout();
- gl.setWidth("100%");
- gl.setHeight("200px");
- gl.setStyleName("t2232");
- fillAndAdd(gl);
-
- gl = new VerticalLayout();
- gl.setWidth("100%");
- gl.setHeight("200px");
- ((SpacingHandler) gl).setSpacing(true);
- fillAndAdd(gl);
-
- gl = new GridLayout();
- gl.setWidth("100%");
- gl.setHeight("200px");
- ((SpacingHandler) gl).setSpacing(true);
- fillAndAdd(gl);
-
- gl = new VerticalLayout();
- gl.setWidth("100%");
- gl.setHeight("200px");
- fillAndAdd(gl);
-
- gl = new GridLayout();
- gl.setWidth("100%");
- gl.setHeight("200px");
- fillAndAdd(gl);
-
- }
-
- private void fillAndAdd(Layout gl) {
- for (int i = 0; i < 4; i++) {
- Button b = new Button("B");
- b.setSizeFull();
- gl.addComponent(b);
- }
- String caption = gl.getClass().getSimpleName();
- caption += " style: " + gl.getStyleName() + ", spacingFromServer:"
- + ((SpacingHandler) gl).isSpacing();
- gl.setCaption(caption);
- getMainWindow().addComponent(gl);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Layout.SpacingHandler;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2232 extends Application {
+
+ @Override
+ public void init() {
+ setMainWindow(new Window());
+ setTheme("tests-tickets");
+
+ getMainWindow()
+ .addComponent(
+ new Label(
+ "Defining spacing must be possible also with pure CSS"));
+
+ Layout gl;
+ gl = new VerticalLayout();
+ gl.setWidth("100%");
+ gl.setHeight("200px");
+ gl.setStyleName("t2232");
+ fillAndAdd(gl);
+
+ gl = new GridLayout();
+ gl.setWidth("100%");
+ gl.setHeight("200px");
+ gl.setStyleName("t2232");
+ fillAndAdd(gl);
+
+ gl = new VerticalLayout();
+ gl.setWidth("100%");
+ gl.setHeight("200px");
+ ((SpacingHandler) gl).setSpacing(true);
+ fillAndAdd(gl);
+
+ gl = new GridLayout();
+ gl.setWidth("100%");
+ gl.setHeight("200px");
+ ((SpacingHandler) gl).setSpacing(true);
+ fillAndAdd(gl);
+
+ gl = new VerticalLayout();
+ gl.setWidth("100%");
+ gl.setHeight("200px");
+ fillAndAdd(gl);
+
+ gl = new GridLayout();
+ gl.setWidth("100%");
+ gl.setHeight("200px");
+ fillAndAdd(gl);
+
+ }
+
+ private void fillAndAdd(Layout gl) {
+ for (int i = 0; i < 4; i++) {
+ Button b = new Button("B");
+ b.setSizeFull();
+ gl.addComponent(b);
+ }
+ String caption = gl.getClass().getSimpleName();
+ caption += " style: " + gl.getStyleName() + ", spacingFromServer:"
+ + ((SpacingHandler) gl).isSpacing();
+ gl.setCaption(caption);
+ getMainWindow().addComponent(gl);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java
index 5d4ac308ef..0942877947 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java
@@ -1,32 +1,32 @@
-package com.vaadin.tests.tickets;
-
-import java.net.URL;
-
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class Ticket2287 extends Ticket2292 {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
- URL url = getURL();
- main.addComponent(new Label(
- "Icon is built by servlet with a slow method, so it will show the bug (components not firing requestLayout)."));
-
- Label l = new Label();
- l.setContentMode(Label.CONTENT_XHTML);
- l.setValue("This is a label with as slow image. <img src=\"" + url
- + "/icon.png\" />");
- main.addComponent(l);
-
- l = new Label();
- l.setContentMode(Label.CONTENT_XHTML);
- l.setValue("This is a label with as slow image. <img src=\"" + url
- + "/icon.png\" />");
- main.addComponent(l);
-
- }
+package com.vaadin.tests.tickets;
+
+import java.net.URL;
+
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class Ticket2287 extends Ticket2292 {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+ URL url = getURL();
+ main.addComponent(new Label(
+ "Icon is built by servlet with a slow method, so it will show the bug (components not firing requestLayout)."));
+
+ Label l = new Label();
+ l.setContentMode(Label.CONTENT_XHTML);
+ l.setValue("This is a label with as slow image. <img src=\"" + url
+ + "/icon.png\" />");
+ main.addComponent(l);
+
+ l = new Label();
+ l.setContentMode(Label.CONTENT_XHTML);
+ l.setValue("This is a label with as slow image. <img src=\"" + url
+ + "/icon.png\" />");
+ main.addComponent(l);
+
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java
index 2fd7c3511a..8ddc6519f7 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java
@@ -1,87 +1,87 @@
-package com.vaadin.tests.tickets;
-
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.imageio.ImageIO;
-
-import com.vaadin.terminal.DownloadStream;
-import com.vaadin.terminal.ExternalResource;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Link;
-import com.vaadin.ui.Window;
-
-public class Ticket2292 extends com.vaadin.Application {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
-
- ExternalResource icon = new ExternalResource("./icon.png");
- main.addComponent(new Label(
- "Note, run with trailing slash in url to have a working icon. Icon is built by servlet with a slow method, so it will show the bug (components not firing requestLayout)"));
- Button b = new Button();
- main.addComponent(b);
- b.setIcon(icon);
-
- CheckBox checkBox = new CheckBox();
- main.addComponent(checkBox);
- checkBox.setIcon(icon);
-
- Link l = new Link("l", icon);
- main.addComponent(l);
-
- }
-
- @Override
- public DownloadStream handleURI(URL context, String relativeUri) {
- if (!relativeUri.contains("icon.png")) {
- return null;
- }
-
- // be slow to show bug
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- BufferedImage image = new BufferedImage(200, 200,
- BufferedImage.TYPE_INT_RGB);
- Graphics drawable = image.getGraphics();
- drawable.setColor(Color.lightGray);
- drawable.fillRect(0, 0, 200, 200);
- drawable.setColor(Color.yellow);
- drawable.fillOval(25, 25, 150, 150);
- drawable.setColor(Color.blue);
- drawable.drawRect(0, 0, 199, 199);
-
- // Use the parameter to create dynamic content.
- drawable.setColor(Color.black);
- drawable.drawString("Tex", 75, 100);
-
- try {
- // Write the image to a buffer.
- ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream();
- ImageIO.write(image, "png", imagebuffer);
-
- // Return a stream from the buffer.
- ByteArrayInputStream istream = new ByteArrayInputStream(
- imagebuffer.toByteArray());
- return new DownloadStream(istream, null, null);
- } catch (IOException e) {
- return null;
- }
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.imageio.ImageIO;
+
+import com.vaadin.terminal.DownloadStream;
+import com.vaadin.terminal.ExternalResource;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Link;
+import com.vaadin.ui.Window;
+
+public class Ticket2292 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+
+ ExternalResource icon = new ExternalResource("./icon.png");
+ main.addComponent(new Label(
+ "Note, run with trailing slash in url to have a working icon. Icon is built by servlet with a slow method, so it will show the bug (components not firing requestLayout)"));
+ Button b = new Button();
+ main.addComponent(b);
+ b.setIcon(icon);
+
+ CheckBox checkBox = new CheckBox();
+ main.addComponent(checkBox);
+ checkBox.setIcon(icon);
+
+ Link l = new Link("l", icon);
+ main.addComponent(l);
+
+ }
+
+ @Override
+ public DownloadStream handleURI(URL context, String relativeUri) {
+ if (!relativeUri.contains("icon.png")) {
+ return null;
+ }
+
+ // be slow to show bug
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ BufferedImage image = new BufferedImage(200, 200,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics drawable = image.getGraphics();
+ drawable.setColor(Color.lightGray);
+ drawable.fillRect(0, 0, 200, 200);
+ drawable.setColor(Color.yellow);
+ drawable.fillOval(25, 25, 150, 150);
+ drawable.setColor(Color.blue);
+ drawable.drawRect(0, 0, 199, 199);
+
+ // Use the parameter to create dynamic content.
+ drawable.setColor(Color.black);
+ drawable.drawString("Tex", 75, 100);
+
+ try {
+ // Write the image to a buffer.
+ ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream();
+ ImageIO.write(image, "png", imagebuffer);
+
+ // Return a stream from the buffer.
+ ByteArrayInputStream istream = new ByteArrayInputStream(
+ imagebuffer.toByteArray());
+ return new DownloadStream(istream, null, null);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java
index da257b4ae8..8b425af136 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java
@@ -1,41 +1,41 @@
-package com.vaadin.tests.tickets;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.net.URL;
-
-import com.vaadin.ui.CustomLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class Ticket2297 extends Ticket2292 {
-
- @Override
- public void init() {
- final Window main = new Window(getClass().getName().substring(
- getClass().getName().lastIndexOf(".") + 1));
- setMainWindow(main);
- URL url = getURL();
- main.addComponent(new Label(
- "Icon is built by servlet with a slow method, so it will show the bug (components not firing requestLayout)."));
-
- try {
- CustomLayout cl = new CustomLayout(
- new ByteArrayInputStream(
- ("This is an empty CustomLayout with as slow image. <img src=\""
- + url.toString() + "/icon.png\" />")
- .getBytes()));
- main.addComponent(cl);
-
- cl = new CustomLayout(
- new ByteArrayInputStream(
- ("This is an empty CustomLayout with as slow image. <img src=\""
- + url.toString() + "/icon.png\" />")
- .getBytes()));
- main.addComponent(cl);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+package com.vaadin.tests.tickets;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class Ticket2297 extends Ticket2292 {
+
+ @Override
+ public void init() {
+ final Window main = new Window(getClass().getName().substring(
+ getClass().getName().lastIndexOf(".") + 1));
+ setMainWindow(main);
+ URL url = getURL();
+ main.addComponent(new Label(
+ "Icon is built by servlet with a slow method, so it will show the bug (components not firing requestLayout)."));
+
+ try {
+ CustomLayout cl = new CustomLayout(
+ new ByteArrayInputStream(
+ ("This is an empty CustomLayout with as slow image. <img src=\""
+ + url.toString() + "/icon.png\" />")
+ .getBytes()));
+ main.addComponent(cl);
+
+ cl = new CustomLayout(
+ new ByteArrayInputStream(
+ ("This is an empty CustomLayout with as slow image. <img src=\""
+ + url.toString() + "/icon.png\" />")
+ .getBytes()));
+ main.addComponent(cl);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java
index 21b33d5bb6..3b8864bccc 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java
@@ -1,43 +1,43 @@
-package com.vaadin.tests.tickets;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import com.vaadin.Application;
-import com.vaadin.ui.CustomLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2303 extends Application {
-
- @Override
- public void init() {
- Window w = new Window("main window");
-
- String customlayout = "<div location=\"test\"></div>";
- CustomLayout cl = null;
- try {
- cl = new CustomLayout(new ByteArrayInputStream(
- customlayout.getBytes()));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- cl.setWidth("100%");
- w.setContent(cl);
-
- // VerticalLayout ol = new VerticalLayout();
- // w.setContent(ol);
- VerticalLayout hugeLayout = new VerticalLayout();
- hugeLayout.setMargin(true);
- hugeLayout.setSpacing(true);
- for (int i = 0; i < 30; i++) {
- hugeLayout.addComponent(new Label("huge " + i));
- }
- cl.addComponent(hugeLayout, "test");
- // ol.addComponent(hugeLayout);
- setMainWindow(w);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import com.vaadin.Application;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2303 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window("main window");
+
+ String customlayout = "<div location=\"test\"></div>";
+ CustomLayout cl = null;
+ try {
+ cl = new CustomLayout(new ByteArrayInputStream(
+ customlayout.getBytes()));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ cl.setWidth("100%");
+ w.setContent(cl);
+
+ // VerticalLayout ol = new VerticalLayout();
+ // w.setContent(ol);
+ VerticalLayout hugeLayout = new VerticalLayout();
+ hugeLayout.setMargin(true);
+ hugeLayout.setSpacing(true);
+ for (int i = 0; i < 30; i++) {
+ hugeLayout.addComponent(new Label("huge " + i));
+ }
+ cl.addComponent(hugeLayout, "test");
+ // ol.addComponent(hugeLayout);
+ setMainWindow(w);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java
index e095bb294c..f5ac1dc37f 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java
@@ -1,21 +1,21 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.ui.Form;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2407 extends com.vaadin.Application {
-
- @Override
- public void init() {
- final Window main = new Window("Ticket2407");
- setMainWindow(main);
-
- Form form = new Form(new VerticalLayout());
- TextField text = new TextField("This caption shall be visible");
- text.setRequired(true);
- form.addField("test", text);
- main.addComponent(form);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.ui.Form;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2407 extends com.vaadin.Application {
+
+ @Override
+ public void init() {
+ final Window main = new Window("Ticket2407");
+ setMainWindow(main);
+
+ Form form = new Form(new VerticalLayout());
+ TextField text = new TextField("This caption shall be visible");
+ text.setRequired(true);
+ form.addField("test", text);
+ main.addComponent(form);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java
index 3159be360b..01bd4f0651 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java
@@ -1,29 +1,29 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket2411 extends Application {
-
- @Override
- public void init() {
- Window w = new Window(getClass().getSimpleName());
- setMainWindow(w);
-
- // VerticalLayout l = new VerticalLayout();
- GridLayout l = new GridLayout();
- w.setContent(l);
-
- l.setHeight("504px");
-
- for (int i = 1; i <= 5; i++) {
- Button b = new Button("Button " + i
- + " should be 100px or 101px high");
- b.setHeight("100%");
- l.addComponent(b);
- }
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket2411 extends Application {
+
+ @Override
+ public void init() {
+ Window w = new Window(getClass().getSimpleName());
+ setMainWindow(w);
+
+ // VerticalLayout l = new VerticalLayout();
+ GridLayout l = new GridLayout();
+ w.setContent(l);
+
+ l.setHeight("504px");
+
+ for (int i = 1; i <= 5; i++) {
+ Button b = new Button("Button " + i
+ + " should be 100px or 101px high");
+ b.setHeight("100%");
+ l.addComponent(b);
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
index 81ffcf5a01..c37a9362d6 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
@@ -1,332 +1,332 @@
-package com.vaadin.tests.tickets;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import com.vaadin.Application;
-import com.vaadin.data.Container;
-import com.vaadin.data.Validator;
-import com.vaadin.data.util.BeanItemContainer;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.ListSelect;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.themes.Reindeer;
-
-/**
- * Table layout is very slow in Firefox 3.0.10 when the table contains
- * components.
- *
- * This is adapted from the HbnContainer example application WorkoutLog.
- *
- * Other browsers are much faster.
- */
-public class Ticket2998 extends Application {
- private Table table;
- private VerticalLayout mainLayout;
-
- public class Workout implements Serializable {
- private Long id;
- private Date date = new Date();
- private String title = " -- new workout -- ";
- private float kilometers;
-
- private String trainingType;
-
- private Set<String> secondaryTypes;
-
- public Workout() {
- }
-
- public Long getId() {
- return id;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public float getKilometers() {
- return kilometers;
- }
-
- public void setKilometers(float kilometers) {
- this.kilometers = kilometers;
- }
-
- public String getTrainingType() {
- return trainingType;
- }
-
- public void setTrainingType(String trainingType) {
- this.trainingType = trainingType;
- }
-
- public void setSecondaryTypes(Set<String> secondaryTypes) {
- this.secondaryTypes = secondaryTypes;
- }
-
- public Set<String> getSecondaryTypes() {
- return secondaryTypes;
- }
-
- }
-
- public class WorkoutEditor extends Window {
-
- private DateField date = new DateField("Date");
- private TextField kilomiters = new TextField("Kilometers");
- private TextField title = new TextField("Title/note");
-
- private Ticket2998 workoutLog;
-
- public WorkoutEditor(Ticket2998 app) {
- super("Edit workout");
- workoutLog = app;
- Layout main = new VerticalLayout();
- setContent(main);
- main.setSizeUndefined();
- main.setStyleName(Reindeer.PANEL_LIGHT);
-
- FormLayout form = new FormLayout();
- form.setSizeUndefined();
- date.setResolution(DateField.RESOLUTION_MIN);
- form.addComponent(date);
- form.addComponent(kilomiters);
- form.addComponent(title);
- main.addComponent(form);
-
- }
-
- public void loadRun(Workout run) {
- if (run == null) {
- close();
- } else {
- date.setValue(run.getDate());
- kilomiters.setValue(run.getKilometers());
- title.setValue(run.getTitle());
- if (getParent() == null) {
- workoutLog.getMainWindow().addWindow(this);
- }
- kilomiters.focus();
- }
- }
- }
-
- public class MyFieldFactory extends DefaultFieldFactory {
-
- public MyFieldFactory(Ticket2998 app) {
- }
-
- @Override
- public Field createField(Container container, Object itemId,
- Object propertyId, Component uiContext) {
-
- /*
- * trainingType is manyToOne relation, give it a combobox
- */
- if (propertyId.equals("trainingType")) {
- return getTrainingTypeComboboxFor(itemId);
- }
-
- /*
- * Secondarytypes is manyToMany relation, give it a multiselect list
- */
- if (propertyId.equals("secondaryTypes")) {
- return getSecondaryTypesList(itemId);
- }
-
- final Field f = super.createField(container, itemId, propertyId,
- uiContext);
- if (f != null) {
- if (f instanceof TextField) {
- TextField tf = (TextField) f;
- tf.setWidth("100%");
- }
- if (propertyId.equals("kilometers")) {
- f.setWidth("4em");
- f.addValidator(new Validator() {
- public boolean isValid(Object value) {
- try {
- @SuppressWarnings("unused")
- float f = Float.parseFloat((String) value);
- return true;
- } catch (Exception e) {
- f.getWindow().showNotification(
- "Bad number value");
- f.setValue(0);
- return false;
- }
- }
-
- public void validate(Object value)
- throws InvalidValueException {
- // TODO Auto-generated method stub
-
- }
- });
- }
- if (propertyId.equals("date")) {
- ((DateField) f).setResolution(DateField.RESOLUTION_MIN);
- }
- }
- return f;
-
- }
-
- private Map<Object, ListSelect> workoutIdToList = new HashMap<Object, ListSelect>();
-
- private Field getSecondaryTypesList(Object itemId) {
- ListSelect list = workoutIdToList.get(itemId);
- if (list == null) {
- list = new ListSelect();
- list.setMultiSelect(true);
- list.addItem("Item1");
- list.addItem("Item2");
- list.addItem("Item3");
- list.addItem("Item4");
- list.addItem("Item5");
- // list.setContainerDataSource(trainingTypes);
- list.setRows(4);
- workoutIdToList.put(itemId, list);
- }
- return list;
- }
-
- private Map<Object, ComboBox> workoutIdToCombobox = new HashMap<Object, ComboBox>();
-
- private Field getTrainingTypeComboboxFor(Object itemId) {
- ComboBox cb = workoutIdToCombobox.get(itemId);
- if (cb == null) {
- final ComboBox cb2 = new ComboBox();
- cb2.addItem("value1");
- cb2.addItem("value2");
- cb2.addItem("value3");
- cb2.addItem("value4");
- cb2.setNewItemsAllowed(true);
-
- workoutIdToCombobox.put(itemId, cb2);
- cb = cb2;
- }
- return cb;
- }
- }
-
- @Override
- public void init() {
- buildView();
- setTheme("reindeer");
- }
-
- /**
- * Builds a simple view for application with Table and a row of buttons
- * below it.
- */
- private void buildView() {
-
- final Window w = new Window("Workout Log");
-
- // set theme and some layout stuff
- setMainWindow(w);
- w.getContent().setSizeFull();
- ((Layout) w.getContent()).setMargin(false);
-
- Panel p = new Panel("Workout Log");
- p.setStyleName(Reindeer.PANEL_LIGHT);
- w.addComponent(p);
- mainLayout = new VerticalLayout();
- p.setContent(mainLayout);
-
- populateAndConfigureTable();
-
- mainLayout.addComponent(table);
-
- // make table consume all extra space
- p.setSizeFull();
- mainLayout.setSizeFull();
- mainLayout.setExpandRatio(table, 1);
- table.setSizeFull();
- }
-
- protected void populateAndConfigureTable() {
- table = new Table();
-
- table.setWidth("100%");
- table.setSelectable(true);
- table.setImmediate(true);
- table.setColumnCollapsingAllowed(true);
- table.setColumnWidth("date", 200);
- table.setColumnWidth("kilometers", 100);
- // table.addListener(this);
- table.setTableFieldFactory(new MyFieldFactory(this));
-
- loadWorkouts();
-
- table.setEditable(true);
- }
-
- /**
- * Loads container to Table
- */
- protected void loadWorkouts() {
- final BeanItemContainer<Workout> cont;
- // Use plain HbnContainer
- cont = new BeanItemContainer<Workout>(Workout.class);
- table.setContainerDataSource(cont);
-
- // insert some sample data
- Calendar c = Calendar.getInstance();
- c.set(Calendar.MILLISECOND, 0);
- c.set(Calendar.SECOND, 0);
- c.set(Calendar.MINUTE, 0);
-
- String[] titles = new String[] { "A short easy one", "intervals",
- "very long", "just shaking legs after work",
- "long one with Paul", "test run" };
-
- c.add(Calendar.DATE, -1000);
-
- Random rnd = new Random();
-
- Workout r;
-
- for (int i = 0; i < 1000; i++) {
- r = new Workout();
- c.set(Calendar.HOUR_OF_DAY,
- 12 + (rnd.nextInt(11) - rnd.nextInt(11)));
- r.setDate(c.getTime());
- r.setTitle(titles[rnd.nextInt(titles.length)]);
- r.setKilometers(Math.round(rnd.nextFloat() * 30));
- r.setTrainingType("tt");
- c.add(Calendar.DATE, 1);
- cont.addBean(r);
- }
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import com.vaadin.Application;
+import com.vaadin.data.Container;
+import com.vaadin.data.Validator;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.DefaultFieldFactory;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+import com.vaadin.ui.themes.Reindeer;
+
+/**
+ * Table layout is very slow in Firefox 3.0.10 when the table contains
+ * components.
+ *
+ * This is adapted from the HbnContainer example application WorkoutLog.
+ *
+ * Other browsers are much faster.
+ */
+public class Ticket2998 extends Application {
+ private Table table;
+ private VerticalLayout mainLayout;
+
+ public class Workout implements Serializable {
+ private Long id;
+ private Date date = new Date();
+ private String title = " -- new workout -- ";
+ private float kilometers;
+
+ private String trainingType;
+
+ private Set<String> secondaryTypes;
+
+ public Workout() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public float getKilometers() {
+ return kilometers;
+ }
+
+ public void setKilometers(float kilometers) {
+ this.kilometers = kilometers;
+ }
+
+ public String getTrainingType() {
+ return trainingType;
+ }
+
+ public void setTrainingType(String trainingType) {
+ this.trainingType = trainingType;
+ }
+
+ public void setSecondaryTypes(Set<String> secondaryTypes) {
+ this.secondaryTypes = secondaryTypes;
+ }
+
+ public Set<String> getSecondaryTypes() {
+ return secondaryTypes;
+ }
+
+ }
+
+ public class WorkoutEditor extends Window {
+
+ private DateField date = new DateField("Date");
+ private TextField kilomiters = new TextField("Kilometers");
+ private TextField title = new TextField("Title/note");
+
+ private Ticket2998 workoutLog;
+
+ public WorkoutEditor(Ticket2998 app) {
+ super("Edit workout");
+ workoutLog = app;
+ Layout main = new VerticalLayout();
+ setContent(main);
+ main.setSizeUndefined();
+ main.setStyleName(Reindeer.PANEL_LIGHT);
+
+ FormLayout form = new FormLayout();
+ form.setSizeUndefined();
+ date.setResolution(DateField.RESOLUTION_MIN);
+ form.addComponent(date);
+ form.addComponent(kilomiters);
+ form.addComponent(title);
+ main.addComponent(form);
+
+ }
+
+ public void loadRun(Workout run) {
+ if (run == null) {
+ close();
+ } else {
+ date.setValue(run.getDate());
+ kilomiters.setValue(run.getKilometers());
+ title.setValue(run.getTitle());
+ if (getParent() == null) {
+ workoutLog.getMainWindow().addWindow(this);
+ }
+ kilomiters.focus();
+ }
+ }
+ }
+
+ public class MyFieldFactory extends DefaultFieldFactory {
+
+ public MyFieldFactory(Ticket2998 app) {
+ }
+
+ @Override
+ public Field createField(Container container, Object itemId,
+ Object propertyId, Component uiContext) {
+
+ /*
+ * trainingType is manyToOne relation, give it a combobox
+ */
+ if (propertyId.equals("trainingType")) {
+ return getTrainingTypeComboboxFor(itemId);
+ }
+
+ /*
+ * Secondarytypes is manyToMany relation, give it a multiselect list
+ */
+ if (propertyId.equals("secondaryTypes")) {
+ return getSecondaryTypesList(itemId);
+ }
+
+ final Field f = super.createField(container, itemId, propertyId,
+ uiContext);
+ if (f != null) {
+ if (f instanceof TextField) {
+ TextField tf = (TextField) f;
+ tf.setWidth("100%");
+ }
+ if (propertyId.equals("kilometers")) {
+ f.setWidth("4em");
+ f.addValidator(new Validator() {
+ public boolean isValid(Object value) {
+ try {
+ @SuppressWarnings("unused")
+ float f = Float.parseFloat((String) value);
+ return true;
+ } catch (Exception e) {
+ f.getWindow().showNotification(
+ "Bad number value");
+ f.setValue(0);
+ return false;
+ }
+ }
+
+ public void validate(Object value)
+ throws InvalidValueException {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+ if (propertyId.equals("date")) {
+ ((DateField) f).setResolution(DateField.RESOLUTION_MIN);
+ }
+ }
+ return f;
+
+ }
+
+ private Map<Object, ListSelect> workoutIdToList = new HashMap<Object, ListSelect>();
+
+ private Field getSecondaryTypesList(Object itemId) {
+ ListSelect list = workoutIdToList.get(itemId);
+ if (list == null) {
+ list = new ListSelect();
+ list.setMultiSelect(true);
+ list.addItem("Item1");
+ list.addItem("Item2");
+ list.addItem("Item3");
+ list.addItem("Item4");
+ list.addItem("Item5");
+ // list.setContainerDataSource(trainingTypes);
+ list.setRows(4);
+ workoutIdToList.put(itemId, list);
+ }
+ return list;
+ }
+
+ private Map<Object, ComboBox> workoutIdToCombobox = new HashMap<Object, ComboBox>();
+
+ private Field getTrainingTypeComboboxFor(Object itemId) {
+ ComboBox cb = workoutIdToCombobox.get(itemId);
+ if (cb == null) {
+ final ComboBox cb2 = new ComboBox();
+ cb2.addItem("value1");
+ cb2.addItem("value2");
+ cb2.addItem("value3");
+ cb2.addItem("value4");
+ cb2.setNewItemsAllowed(true);
+
+ workoutIdToCombobox.put(itemId, cb2);
+ cb = cb2;
+ }
+ return cb;
+ }
+ }
+
+ @Override
+ public void init() {
+ buildView();
+ setTheme("reindeer");
+ }
+
+ /**
+ * Builds a simple view for application with Table and a row of buttons
+ * below it.
+ */
+ private void buildView() {
+
+ final Window w = new Window("Workout Log");
+
+ // set theme and some layout stuff
+ setMainWindow(w);
+ w.getContent().setSizeFull();
+ ((Layout) w.getContent()).setMargin(false);
+
+ Panel p = new Panel("Workout Log");
+ p.setStyleName(Reindeer.PANEL_LIGHT);
+ w.addComponent(p);
+ mainLayout = new VerticalLayout();
+ p.setContent(mainLayout);
+
+ populateAndConfigureTable();
+
+ mainLayout.addComponent(table);
+
+ // make table consume all extra space
+ p.setSizeFull();
+ mainLayout.setSizeFull();
+ mainLayout.setExpandRatio(table, 1);
+ table.setSizeFull();
+ }
+
+ protected void populateAndConfigureTable() {
+ table = new Table();
+
+ table.setWidth("100%");
+ table.setSelectable(true);
+ table.setImmediate(true);
+ table.setColumnCollapsingAllowed(true);
+ table.setColumnWidth("date", 200);
+ table.setColumnWidth("kilometers", 100);
+ // table.addListener(this);
+ table.setTableFieldFactory(new MyFieldFactory(this));
+
+ loadWorkouts();
+
+ table.setEditable(true);
+ }
+
+ /**
+ * Loads container to Table
+ */
+ protected void loadWorkouts() {
+ final BeanItemContainer<Workout> cont;
+ // Use plain HbnContainer
+ cont = new BeanItemContainer<Workout>(Workout.class);
+ table.setContainerDataSource(cont);
+
+ // insert some sample data
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.MILLISECOND, 0);
+ c.set(Calendar.SECOND, 0);
+ c.set(Calendar.MINUTE, 0);
+
+ String[] titles = new String[] { "A short easy one", "intervals",
+ "very long", "just shaking legs after work",
+ "long one with Paul", "test run" };
+
+ c.add(Calendar.DATE, -1000);
+
+ Random rnd = new Random();
+
+ Workout r;
+
+ for (int i = 0; i < 1000; i++) {
+ r = new Workout();
+ c.set(Calendar.HOUR_OF_DAY,
+ 12 + (rnd.nextInt(11) - rnd.nextInt(11)));
+ r.setDate(c.getTime());
+ r.setTitle(titles[rnd.nextInt(titles.length)]);
+ r.setKilometers(Math.round(rnd.nextFloat() * 30));
+ r.setTrainingType("tt");
+ c.add(Calendar.DATE, 1);
+ cont.addBean(r);
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java b/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java
index 6afa25efda..f4dc1d59e4 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java
@@ -1,96 +1,96 @@
-package com.vaadin.tests.tickets;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket3146 extends Application {
-
- Table table;
- TextField result;
-
- @Override
- public void init() {
- Window mainWindow = new Window("Test");
-
- table = new Table();
- table.addContainerProperty("Items", String.class, null);
- table.addItem(new String[] { "a" }, "a");
- table.addItem(new String[] { "b" }, "b");
- table.addItem(new String[] { "c" }, "c");
- for (int i = 1; i < 100; ++i) {
- table.addItem(new String[] { "Item " + i }, "Item " + i);
- }
- table.setMultiSelect(true);
- table.setSelectable(true);
- table.setImmediate(true);
- table.setHeight("200px");
- table.setWidth("200px");
- mainWindow.addComponent(table);
-
- Button clearButton = new Button("Clear selection",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- clearSelection();
- }
- });
- mainWindow.addComponent(clearButton);
- Button clearButton2 = new Button("Clear selection 2",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- clearSelection2();
- }
- });
- mainWindow.addComponent(clearButton2);
- Button clearButton3 = new Button("Clear selection 3",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- clearSelection3();
- }
- });
- mainWindow.addComponent(clearButton3);
- Button printButton = new Button("Print selection",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- printSelection();
- }
- });
- mainWindow.addComponent(printButton);
-
- result = new TextField();
- result.setHeight("200px");
- result.setWidth("200px");
- mainWindow.addComponent(result);
-
- setMainWindow(mainWindow);
- }
-
- void clearSelection() {
- table.setValue(null);
- }
-
- void clearSelection2() {
- table.setValue(new HashSet<Object>());
- }
-
- void clearSelection3() {
- table.unselect("a");
- table.unselect("b");
- table.unselect("c");
- }
-
- void printSelection() {
- String selection = "";
- for (Object item : (Collection<?>) table.getValue()) {
- selection = selection + item + ' ';
- }
- result.setValue(selection);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket3146 extends Application {
+
+ Table table;
+ TextField result;
+
+ @Override
+ public void init() {
+ Window mainWindow = new Window("Test");
+
+ table = new Table();
+ table.addContainerProperty("Items", String.class, null);
+ table.addItem(new String[] { "a" }, "a");
+ table.addItem(new String[] { "b" }, "b");
+ table.addItem(new String[] { "c" }, "c");
+ for (int i = 1; i < 100; ++i) {
+ table.addItem(new String[] { "Item " + i }, "Item " + i);
+ }
+ table.setMultiSelect(true);
+ table.setSelectable(true);
+ table.setImmediate(true);
+ table.setHeight("200px");
+ table.setWidth("200px");
+ mainWindow.addComponent(table);
+
+ Button clearButton = new Button("Clear selection",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ clearSelection();
+ }
+ });
+ mainWindow.addComponent(clearButton);
+ Button clearButton2 = new Button("Clear selection 2",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ clearSelection2();
+ }
+ });
+ mainWindow.addComponent(clearButton2);
+ Button clearButton3 = new Button("Clear selection 3",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ clearSelection3();
+ }
+ });
+ mainWindow.addComponent(clearButton3);
+ Button printButton = new Button("Print selection",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ printSelection();
+ }
+ });
+ mainWindow.addComponent(printButton);
+
+ result = new TextField();
+ result.setHeight("200px");
+ result.setWidth("200px");
+ mainWindow.addComponent(result);
+
+ setMainWindow(mainWindow);
+ }
+
+ void clearSelection() {
+ table.setValue(null);
+ }
+
+ void clearSelection2() {
+ table.setValue(new HashSet<Object>());
+ }
+
+ void clearSelection3() {
+ table.unselect("a");
+ table.unselect("b");
+ table.unselect("c");
+ }
+
+ void printSelection() {
+ String selection = "";
+ for (Object item : (Collection<?>) table.getValue()) {
+ selection = selection + item + ' ';
+ }
+ result.setValue(selection);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java b/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java
index bbb9a1ebc2..2f5bade03a 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java
@@ -1,35 +1,35 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.Window;
-
-/**
- * #5053: Last ComboBox item may not be shown if null selection enabled
- */
-public class Ticket5053 extends Application {
-
- @Override
- public void init() {
- Window main = new Window();
- setMainWindow(main);
-
- ComboBox combobox = new ComboBox("My ComboBox");
-
- // Enable null selection
- combobox.setNullSelectionAllowed(true);
- // Add the item that marks 'null' value
- String nullitem = "-- none --";
- combobox.addItem(nullitem);
- // Designate it was the 'null' value marker
- combobox.setNullSelectionItemId(nullitem);
-
- // Add some other items
- for (int i = 0; i < 10; i++) {
- combobox.addItem("Item " + i);
- }
-
- main.addComponent(combobox);
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Window;
+
+/**
+ * #5053: Last ComboBox item may not be shown if null selection enabled
+ */
+public class Ticket5053 extends Application {
+
+ @Override
+ public void init() {
+ Window main = new Window();
+ setMainWindow(main);
+
+ ComboBox combobox = new ComboBox("My ComboBox");
+
+ // Enable null selection
+ combobox.setNullSelectionAllowed(true);
+ // Add the item that marks 'null' value
+ String nullitem = "-- none --";
+ combobox.addItem(nullitem);
+ // Designate it was the 'null' value marker
+ combobox.setNullSelectionItemId(nullitem);
+
+ // Add some other items
+ for (int i = 0; i < 10; i++) {
+ combobox.addItem("Item " + i);
+ }
+
+ main.addComponent(combobox);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java b/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java
index f620cd27be..c5049f67c0 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java
@@ -1,52 +1,52 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.event.ShortcutListener;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-/**
- * Key codes were converted to lower case on the server (overlapping special key
- * codes for function keys etc.) and then back to upper case on the client.
- * Therefore, registering e.g. F8 as a key code resulted in "w" being used as
- * the trigger and F8 being ignored.
- */
-public class Ticket5157 extends Application {
-
- @Override
- public void init() {
- final Window mainWindow = new Window("Forumtests Application");
- setMainWindow(mainWindow);
-
- Panel p = new Panel();
- mainWindow.addComponent(p);
-
- Label l = new Label("Panel with F8 bound");
- p.addComponent(l);
-
- TextField f = new TextField();
- p.addComponent(f);
-
- p.addAction(new ShortcutListener("F8", KeyCode.F8, null) {
-
- @Override
- public void handleAction(Object sender, Object target) {
- mainWindow.showNotification(getCaption());
-
- }
- });
-
- p.addAction(new ShortcutListener("a", KeyCode.A, null) {
-
- @Override
- public void handleAction(Object sender, Object target) {
- mainWindow.showNotification(getCaption());
-
- }
- });
- }
-
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+/**
+ * Key codes were converted to lower case on the server (overlapping special key
+ * codes for function keys etc.) and then back to upper case on the client.
+ * Therefore, registering e.g. F8 as a key code resulted in "w" being used as
+ * the trigger and F8 being ignored.
+ */
+public class Ticket5157 extends Application {
+
+ @Override
+ public void init() {
+ final Window mainWindow = new Window("Forumtests Application");
+ setMainWindow(mainWindow);
+
+ Panel p = new Panel();
+ mainWindow.addComponent(p);
+
+ Label l = new Label("Panel with F8 bound");
+ p.addComponent(l);
+
+ TextField f = new TextField();
+ p.addComponent(f);
+
+ p.addAction(new ShortcutListener("F8", KeyCode.F8, null) {
+
+ @Override
+ public void handleAction(Object sender, Object target) {
+ mainWindow.showNotification(getCaption());
+
+ }
+ });
+
+ p.addAction(new ShortcutListener("a", KeyCode.A, null) {
+
+ @Override
+ public void handleAction(Object sender, Object target) {
+ mainWindow.showNotification(getCaption());
+
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java b/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java
index 4a5d405858..cd2b3a70e6 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java
@@ -1,30 +1,30 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Window;
-
-public class Ticket5952 extends Application {
-
- @Override
- public void init() {
- final Window mainWindow = new Window("Forumtests Application");
- setMainWindow(mainWindow);
-
- String mathml =
- "<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'>"+
- "<mrow>"+
- " <msup>"+
- " <mi>x</mi>"+
- " <mn>2</mn>"+
- " </msup>"+
- " <msup>"+
- " <mi>c</mi>"+
- " <mn>2</mn>"+
- " </msup>"+
- " </mrow>"+
- "</math>";
- Label mathLabel = new Label(mathml, Label.CONTENT_XML);
- mainWindow.addComponent(mathLabel);
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+public class Ticket5952 extends Application {
+
+ @Override
+ public void init() {
+ final Window mainWindow = new Window("Forumtests Application");
+ setMainWindow(mainWindow);
+
+ String mathml =
+ "<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'>"+
+ "<mrow>"+
+ " <msup>"+
+ " <mi>x</mi>"+
+ " <mn>2</mn>"+
+ " </msup>"+
+ " <msup>"+
+ " <mi>c</mi>"+
+ " <mn>2</mn>"+
+ " </msup>"+
+ " </mrow>"+
+ "</math>";
+ Label mathLabel = new Label(mathml, Label.CONTENT_XML);
+ mainWindow.addComponent(mathLabel);
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java b/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java
index 888f1c05ca..bd6a8e2b7c 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java
@@ -1,88 +1,88 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class Ticket6002 extends TestBase {
-
- @Override
- public void setup() {
- Window main = new Window("The Main Window");
- setMainWindow(main);
-
- final VerticalLayout mainLayout = new VerticalLayout();
- main.setContent(mainLayout);
-
- mainLayout.addComponent(new Label(
- "Replace the floating-point values with an integer"));
-
- // ///////////////////////////////////////////////////
- // Better working case
-
- final ObjectProperty<Double> property1 = new ObjectProperty<Double>(
- new Double(42.0));
-
- // A text field that changes its caption
- final TextField tf1 = new TextField(
- "Changing this field modifies only the textfield", property1);
- tf1.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- // This value change event is called twice if the new
- // input value is an integer. The second time is during
- // paint() of AbstractOrderedLayout.
-
- System.out.println("Value 2 is: " + property1.getValue());
-
- tf1.setCaption("With caption " + property1.getValue());
- }
- });
- tf1.setImmediate(true);
- mainLayout.addComponent(tf1);
-
- // ///////////////////////////////////////////////////
- // Totally failing case
-
- final ObjectProperty<Double> property2 = new ObjectProperty<Double>(
- new Double(42.0));
-
- // A text field that adds new components
- final TextField tf2 = new TextField(
- "Changing this field modifies the layout - do it twice",
- property2);
- tf2.addListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- // This value change event is called twice if the new
- // input value is an integer. The second time is during
- // paint() of AbstractOrderedLayout.
-
- System.out.println("Value 1 is: " + property2.getValue());
-
- // When this listener is called the second time in paint(), the
- // add operation causes a ConcurrentModificationException
- mainLayout.addComponent(new Label(
- "Added a component, value is " + property2.getValue()));
- }
- });
- tf2.setImmediate(true);
- mainLayout.addComponent(tf2);
-
- mainLayout.setSpacing(true);
- }
-
- @Override
- protected String getDescription() {
- return "Change the numbers to integer value or add 0 in the decimal representation. "
- + "This causes a secondary call during paint() to reformat the value, which causes ConcurrentModificationException in the second case.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6002;
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class Ticket6002 extends TestBase {
+
+ @Override
+ public void setup() {
+ Window main = new Window("The Main Window");
+ setMainWindow(main);
+
+ final VerticalLayout mainLayout = new VerticalLayout();
+ main.setContent(mainLayout);
+
+ mainLayout.addComponent(new Label(
+ "Replace the floating-point values with an integer"));
+
+ // ///////////////////////////////////////////////////
+ // Better working case
+
+ final ObjectProperty<Double> property1 = new ObjectProperty<Double>(
+ new Double(42.0));
+
+ // A text field that changes its caption
+ final TextField tf1 = new TextField(
+ "Changing this field modifies only the textfield", property1);
+ tf1.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // This value change event is called twice if the new
+ // input value is an integer. The second time is during
+ // paint() of AbstractOrderedLayout.
+
+ System.out.println("Value 2 is: " + property1.getValue());
+
+ tf1.setCaption("With caption " + property1.getValue());
+ }
+ });
+ tf1.setImmediate(true);
+ mainLayout.addComponent(tf1);
+
+ // ///////////////////////////////////////////////////
+ // Totally failing case
+
+ final ObjectProperty<Double> property2 = new ObjectProperty<Double>(
+ new Double(42.0));
+
+ // A text field that adds new components
+ final TextField tf2 = new TextField(
+ "Changing this field modifies the layout - do it twice",
+ property2);
+ tf2.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // This value change event is called twice if the new
+ // input value is an integer. The second time is during
+ // paint() of AbstractOrderedLayout.
+
+ System.out.println("Value 1 is: " + property2.getValue());
+
+ // When this listener is called the second time in paint(), the
+ // add operation causes a ConcurrentModificationException
+ mainLayout.addComponent(new Label(
+ "Added a component, value is " + property2.getValue()));
+ }
+ });
+ tf2.setImmediate(true);
+ mainLayout.addComponent(tf2);
+
+ mainLayout.setSpacing(true);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Change the numbers to integer value or add 0 in the decimal representation. "
+ + "This causes a secondary call during paint() to reformat the value, which causes ConcurrentModificationException in the second case.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6002;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket677.java b/tests/testbench/com/vaadin/tests/tickets/Ticket677.java
index ee7320e59b..f2a1ae1664 100644
--- a/tests/testbench/com/vaadin/tests/tickets/Ticket677.java
+++ b/tests/testbench/com/vaadin/tests/tickets/Ticket677.java
@@ -1,210 +1,210 @@
-package com.vaadin.tests.tickets;
-
-import com.vaadin.Application;
-import com.vaadin.data.Container;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.Window;
-
-public class Ticket677 extends Application {
-
- private static final Label info = new Label(
- "<li> keep debug window open to see variable changes"
- + "<li> disable root panel w/ toggle button"
- + "<li> toggle one of the subpanels"
- + "<li> we attempt to focus the subpanels first textfield"
- + "<li> focusing should fail (try tabbing as well) [worked previousy]"
- + "<li> no variable changes should be sent from disabled fields [changed sent previously]"
- + "<li> try further toggling and tabbing around",
- Label.CONTENT_RAW);
-
- Panel root = new Panel("Enabled");
- Panel one = new Panel("Enabled");
- Panel two = new Panel("Enabled");
- Form form;
- Table table;
-
- @Override
- public void init() {
- Window main = new Window();
- setMainWindow(main);
-
- main.addComponent(info);
-
- HorizontalLayout l = new HorizontalLayout();
- main.addComponent(l);
-
- l.addComponent(new Button("Toggle root panel",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- toggle(root);
- }
- }));
- l.addComponent(new Button("Toggle panel one",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- toggle(one);
- }
- }));
- l.addComponent(new Button("Toggle panel two",
- new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- toggle(two);
- }
- }));
- l.addComponent(new Button("Toggle form", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- toggle(form);
- }
- }));
- l.addComponent(new Button("Toggle table", new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- toggle(table);
- }
- }));
-
- root.setContent(new GridLayout(2, 3));
- main.addComponent(root);
-
- TextField tf = new TextField("Enabled");
- tf.setImmediate(true);
- root.addComponent(tf);
- tf = new TextField("Disabled");
- tf.setImmediate(true);
- tf.setEnabled(false);
- root.addComponent(tf);
-
- root.addComponent(one);
- tf = new TextField("Enabled");
- tf.setImmediate(true);
- one.addComponent(tf);
- tf = new TextField("Disabled");
- tf.setImmediate(true);
- tf.setEnabled(false);
- one.addComponent(tf);
-
- root.addComponent(two);
- tf = new TextField("Enabled");
- tf.setImmediate(true);
- two.addComponent(tf);
- tf = new TextField("Disabled");
- tf.setImmediate(true);
- tf.setEnabled(false);
- two.addComponent(tf);
-
- form = new Form();
- form.setCaption("Enabled");
- form.setFormFieldFactory(new DefaultFieldFactory() {
-
- @Override
- public Field createField(Item item, Object propertyId,
- Component uiContext) {
- Field f = super.createField(item, propertyId, uiContext);
- f.setEnabled(!"disabled".equals(propertyId));
- return f;
- }
-
- });
- form.setItemDataSource(new BeanItem<MyBean>(new MyBean()));
- root.addComponent(form);
-
- table = new Table("Enabled");
- table.setPageLength(7);
- table.addContainerProperty("Text", String.class, null);
- for (int i = 0; i < 150; i++) {
- Item item = table.addItem("Item" + i);
- Property p = item.getItemProperty("Text");
- p.setValue(i % 5 == 0 ? "enabled" : "disabled");
- }
-
- table.setTableFieldFactory(new DefaultFieldFactory() {
-
- @Override
- public Field createField(Container container, Object itemId,
- Object propertyId, Component uiContext) {
- Field f = super.createField(container, itemId, propertyId,
- uiContext);
- Item item = container.getItem(itemId);
- Property p = item.getItemProperty(propertyId);
- if ("disabled".equals(p.getValue())) {
- f.setEnabled(false);
- }
- return f;
- }
-
- });
- table.setEditable(true);
- root.addComponent(table);
-
- }
-
- private void toggle(Component c) {
- boolean enable = "Disabled".equals(c.getCaption());
- c.setEnabled(enable);
- c.setCaption((enable ? "Enabled" : "Disabled"));
- if (c instanceof ComponentContainer) {
- TextField tf = (TextField) ((ComponentContainer) c)
- .getComponentIterator().next();
- tf.focus();
- }
- }
-
- class MyBean {
- boolean on = false;
- int number = 1;
- String rw = "read/write";
- String r = "read";
- String disabled = "disabled";
-
- public boolean isOn() {
- return on;
- }
-
- public void setOn(boolean on) {
- this.on = on;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
-
- public String getRw() {
- return rw;
- }
-
- public void setRw(String rw) {
- this.rw = rw;
- }
-
- public String getDisabled() {
- return disabled;
- }
-
- public void setDisabled(String disabled) {
- this.disabled = disabled;
- }
-
- public String getR() {
- return r;
- }
-
- }
-}
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.DefaultFieldFactory;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class Ticket677 extends Application {
+
+ private static final Label info = new Label(
+ "<li> keep debug window open to see variable changes"
+ + "<li> disable root panel w/ toggle button"
+ + "<li> toggle one of the subpanels"
+ + "<li> we attempt to focus the subpanels first textfield"
+ + "<li> focusing should fail (try tabbing as well) [worked previousy]"
+ + "<li> no variable changes should be sent from disabled fields [changed sent previously]"
+ + "<li> try further toggling and tabbing around",
+ Label.CONTENT_RAW);
+
+ Panel root = new Panel("Enabled");
+ Panel one = new Panel("Enabled");
+ Panel two = new Panel("Enabled");
+ Form form;
+ Table table;
+
+ @Override
+ public void init() {
+ Window main = new Window();
+ setMainWindow(main);
+
+ main.addComponent(info);
+
+ HorizontalLayout l = new HorizontalLayout();
+ main.addComponent(l);
+
+ l.addComponent(new Button("Toggle root panel",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ toggle(root);
+ }
+ }));
+ l.addComponent(new Button("Toggle panel one",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ toggle(one);
+ }
+ }));
+ l.addComponent(new Button("Toggle panel two",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ toggle(two);
+ }
+ }));
+ l.addComponent(new Button("Toggle form", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ toggle(form);
+ }
+ }));
+ l.addComponent(new Button("Toggle table", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ toggle(table);
+ }
+ }));
+
+ root.setContent(new GridLayout(2, 3));
+ main.addComponent(root);
+
+ TextField tf = new TextField("Enabled");
+ tf.setImmediate(true);
+ root.addComponent(tf);
+ tf = new TextField("Disabled");
+ tf.setImmediate(true);
+ tf.setEnabled(false);
+ root.addComponent(tf);
+
+ root.addComponent(one);
+ tf = new TextField("Enabled");
+ tf.setImmediate(true);
+ one.addComponent(tf);
+ tf = new TextField("Disabled");
+ tf.setImmediate(true);
+ tf.setEnabled(false);
+ one.addComponent(tf);
+
+ root.addComponent(two);
+ tf = new TextField("Enabled");
+ tf.setImmediate(true);
+ two.addComponent(tf);
+ tf = new TextField("Disabled");
+ tf.setImmediate(true);
+ tf.setEnabled(false);
+ two.addComponent(tf);
+
+ form = new Form();
+ form.setCaption("Enabled");
+ form.setFormFieldFactory(new DefaultFieldFactory() {
+
+ @Override
+ public Field createField(Item item, Object propertyId,
+ Component uiContext) {
+ Field f = super.createField(item, propertyId, uiContext);
+ f.setEnabled(!"disabled".equals(propertyId));
+ return f;
+ }
+
+ });
+ form.setItemDataSource(new BeanItem<MyBean>(new MyBean()));
+ root.addComponent(form);
+
+ table = new Table("Enabled");
+ table.setPageLength(7);
+ table.addContainerProperty("Text", String.class, null);
+ for (int i = 0; i < 150; i++) {
+ Item item = table.addItem("Item" + i);
+ Property p = item.getItemProperty("Text");
+ p.setValue(i % 5 == 0 ? "enabled" : "disabled");
+ }
+
+ table.setTableFieldFactory(new DefaultFieldFactory() {
+
+ @Override
+ public Field createField(Container container, Object itemId,
+ Object propertyId, Component uiContext) {
+ Field f = super.createField(container, itemId, propertyId,
+ uiContext);
+ Item item = container.getItem(itemId);
+ Property p = item.getItemProperty(propertyId);
+ if ("disabled".equals(p.getValue())) {
+ f.setEnabled(false);
+ }
+ return f;
+ }
+
+ });
+ table.setEditable(true);
+ root.addComponent(table);
+
+ }
+
+ private void toggle(Component c) {
+ boolean enable = "Disabled".equals(c.getCaption());
+ c.setEnabled(enable);
+ c.setCaption((enable ? "Enabled" : "Disabled"));
+ if (c instanceof ComponentContainer) {
+ TextField tf = (TextField) ((ComponentContainer) c)
+ .getComponentIterator().next();
+ tf.focus();
+ }
+ }
+
+ class MyBean {
+ boolean on = false;
+ int number = 1;
+ String rw = "read/write";
+ String r = "read";
+ String disabled = "disabled";
+
+ public boolean isOn() {
+ return on;
+ }
+
+ public void setOn(boolean on) {
+ this.on = on;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public String getRw() {
+ return rw;
+ }
+
+ public void setRw(String rw) {
+ this.rw = rw;
+ }
+
+ public String getDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(String disabled) {
+ this.disabled = disabled;
+ }
+
+ public String getR() {
+ return r;
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/util/Log.java b/tests/testbench/com/vaadin/tests/util/Log.java
index bdb40d56d7..4eef48a789 100644
--- a/tests/testbench/com/vaadin/tests/util/Log.java
+++ b/tests/testbench/com/vaadin/tests/util/Log.java
@@ -1,62 +1,62 @@
-package com.vaadin.tests.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-
-public class Log extends VerticalLayout {
- List<Label> eventLabels = new ArrayList<Label>();
- private boolean numberLogRows = true;
- private int nextLogNr = 1;
-
- public Log(int nr) {
- for (int i = 0; i < nr; i++) {
- Label l = createEventLabel();
- l.setDebugId("Log_row_" + i);
- eventLabels.add(l);
- addComponent(l);
- }
- setDebugId("Log");
- setCaption("Events:");
- }
-
- /**
- * Clears the rows and reset the row number to zero.
- */
- public Log clear() {
- for (Label l : eventLabels) {
- l.setValue("&nbsp;");
- }
- nextLogNr = 0;
- return this;
- }
-
- public Log log(String event) {
- int nr = eventLabels.size();
- for (int i = nr - 1; i > 0; i--) {
- eventLabels.get(i).setValue(eventLabels.get(i - 1).getValue());
- }
- String msg = event;
- if (numberLogRows) {
- msg = nextLogNr + ". " + msg;
- nextLogNr++;
- }
- eventLabels.get(0).setValue(msg);
- System.out.println(event);
- return this;
- }
-
- private Label createEventLabel() {
- Label l = new Label("&nbsp;", Label.CONTENT_XHTML);
- l.setWidth(null);
- return l;
- }
-
- public Log setNumberLogRows(boolean numberLogRows) {
- this.numberLogRows = numberLogRows;
- return this;
- }
-
-}
+package com.vaadin.tests.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class Log extends VerticalLayout {
+ List<Label> eventLabels = new ArrayList<Label>();
+ private boolean numberLogRows = true;
+ private int nextLogNr = 1;
+
+ public Log(int nr) {
+ for (int i = 0; i < nr; i++) {
+ Label l = createEventLabel();
+ l.setDebugId("Log_row_" + i);
+ eventLabels.add(l);
+ addComponent(l);
+ }
+ setDebugId("Log");
+ setCaption("Events:");
+ }
+
+ /**
+ * Clears the rows and reset the row number to zero.
+ */
+ public Log clear() {
+ for (Label l : eventLabels) {
+ l.setValue("&nbsp;");
+ }
+ nextLogNr = 0;
+ return this;
+ }
+
+ public Log log(String event) {
+ int nr = eventLabels.size();
+ for (int i = nr - 1; i > 0; i--) {
+ eventLabels.get(i).setValue(eventLabels.get(i - 1).getValue());
+ }
+ String msg = event;
+ if (numberLogRows) {
+ msg = nextLogNr + ". " + msg;
+ nextLogNr++;
+ }
+ eventLabels.get(0).setValue(msg);
+ System.out.println(event);
+ return this;
+ }
+
+ private Label createEventLabel() {
+ Label l = new Label("&nbsp;", Label.CONTENT_XHTML);
+ l.setWidth(null);
+ return l;
+ }
+
+ public Log setNumberLogRows(boolean numberLogRows) {
+ this.numberLogRows = numberLogRows;
+ return this;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/util/PortableRandom.java b/tests/testbench/com/vaadin/tests/util/PortableRandom.java
index 2e6d7ce9af..b66bdfdcaf 100644
--- a/tests/testbench/com/vaadin/tests/util/PortableRandom.java
+++ b/tests/testbench/com/vaadin/tests/util/PortableRandom.java
@@ -1,52 +1,52 @@
-package com.vaadin.tests.util;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-public class PortableRandom {
- private final static long multiplier = 0x5DEECE66DL;
- private final static long addend = 0xBL;
- private final static long mask = (1L << 48) - 1;
- private AtomicLong seed;
-
- public PortableRandom(long seed) {
- this.seed = new AtomicLong(0L);
- setSeed(seed);
- }
-
- synchronized public void setSeed(long seed) {
- seed = (seed ^ multiplier) & mask;
- this.seed.set(seed);
- }
-
- public int nextInt(int n) {
- if (n <= 0) {
- throw new IllegalArgumentException("n must be positive");
- }
-
- if ((n & -n) == n) {
- return (int) ((n * (long) next(31)) >> 31);
- }
-
- int bits, val;
- do {
- bits = next(31);
- val = bits % n;
- } while (bits - val + (n - 1) < 0);
- return val;
- }
-
- protected int next(int bits) {
- long oldseed, nextseed;
- AtomicLong seed = this.seed;
- do {
- oldseed = seed.get();
- nextseed = (oldseed * multiplier + addend) & mask;
- } while (!seed.compareAndSet(oldseed, nextseed));
- return (int) (nextseed >>> (48 - bits));
- }
-
- public boolean nextBoolean() {
- return next(1) != 0;
- }
-
+package com.vaadin.tests.util;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+public class PortableRandom {
+ private final static long multiplier = 0x5DEECE66DL;
+ private final static long addend = 0xBL;
+ private final static long mask = (1L << 48) - 1;
+ private AtomicLong seed;
+
+ public PortableRandom(long seed) {
+ this.seed = new AtomicLong(0L);
+ setSeed(seed);
+ }
+
+ synchronized public void setSeed(long seed) {
+ seed = (seed ^ multiplier) & mask;
+ this.seed.set(seed);
+ }
+
+ public int nextInt(int n) {
+ if (n <= 0) {
+ throw new IllegalArgumentException("n must be positive");
+ }
+
+ if ((n & -n) == n) {
+ return (int) ((n * (long) next(31)) >> 31);
+ }
+
+ int bits, val;
+ do {
+ bits = next(31);
+ val = bits % n;
+ } while (bits - val + (n - 1) < 0);
+ return val;
+ }
+
+ protected int next(int bits) {
+ long oldseed, nextseed;
+ AtomicLong seed = this.seed;
+ do {
+ oldseed = seed.get();
+ nextseed = (oldseed * multiplier + addend) & mask;
+ } while (!seed.compareAndSet(oldseed, nextseed));
+ return (int) (nextseed >>> (48 - bits));
+ }
+
+ public boolean nextBoolean() {
+ return next(1) != 0;
+ }
+
} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java b/tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java
index b1d6a8f068..af48f92f5c 100644
--- a/tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java
+++ b/tests/testbench/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java
@@ -1,146 +1,146 @@
-package com.vaadin.tests.validation;
-
-import java.util.Date;
-
-import com.vaadin.data.Validator.InvalidValueException;
-import com.vaadin.data.validator.AbstractValidator;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.Field;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.NativeSelect;
-import com.vaadin.ui.OptionGroup;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Select;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.themes.Reindeer;
-
-public class EmptyFieldErrorIndicators extends TestBase {
-
- @Override
- protected void setup() {
- getLayout().setSizeFull();
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.setSizeFull();
- hl.setSpacing(true);
-
- ComponentContainer part1 = createPart(
- "Empty required fields validation", true, false);
- part1.setDebugId("emptyFieldPart");
- hl.addComponent(part1);
-
- ComponentContainer part2 = createPart(
- "Empty required fields with failing validator", true, true);
- part1.setDebugId("validatedFieldPart");
- hl.addComponent(part2);
-
- Panel panel = new Panel();
- panel.setSizeFull();
- panel.setStyleName(Reindeer.PANEL_LIGHT);
- panel.addComponent(hl);
- panel.setScrollable(true);
- addComponent(panel);
- }
-
- private ComponentContainer createPart(String caption, boolean required,
- boolean failValidator) {
- VerticalLayout part = new VerticalLayout();
- part.setMargin(true);
-
- final Form form = createForm(required, failValidator);
- part.addComponent(form);
-
- Button validate = new Button("Validate fields");
- validate.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- try {
- form.validate();
- } catch (InvalidValueException e) {
- }
- }
- });
- part.addComponent(validate);
-
- Panel panel = new Panel(caption, part);
- panel.setHeight("100%");
- return panel;
- }
-
- private Form createForm(final boolean required, final boolean failValidator) {
- // hand-crafted form, not using form field factory
- final Form form = new Form() {
- @Override
- public void addField(Object propertyId, Field field) {
- super.addField(propertyId, field);
- field.setRequired(required);
- field.setRequiredError("Missing required value!");
- if (failValidator && !(field instanceof Button)) {
- field.addValidator(new AbstractValidator("Validation error") {
- public boolean isValid(Object value) {
- return false;
- }
- });
- }
- }
- };
-
- form.addField("Field", new TextField("Text"));
- form.addField("Date", new DateField("Date"));
- // not good for automated testing with screenshots when null
- // form.addField("Inline Date", new InlineDateField("Date"));
- // same as basic DateField
- // form.addField("Popup Date", new PopupDateField("Date"));
- Button setDateButton = new Button("Set date");
- form.addField("Set Date", setDateButton);
- setDateButton.addListener(new ClickListener() {
- public void buttonClick(ClickEvent event) {
- form.getField("Date").setValue(new Date(0));
- }
- });
-
- NativeSelect nativeSelect = new NativeSelect("NativeSelect");
- form.addField("Native Select", nativeSelect);
- nativeSelect.addItem("Value 1");
-
- // in #4103, the Select component was behaving differently from others
- form.addField("Select", new Select("Select"));
-
- Select select2 = new Select("Select 2");
- select2.addItem("Value 1");
- form.addField("Select 2", select2);
-
- OptionGroup optionGroup = new OptionGroup("OptionGroup");
- optionGroup.setMultiSelect(false);
- optionGroup.addItem("Option 1");
- optionGroup.addItem("Option 2");
- form.addField("Option Group 1", optionGroup);
-
- OptionGroup optionGroup2 = new OptionGroup("OptionGroup");
- optionGroup2.setMultiSelect(true);
- optionGroup2.addItem("Option 1");
- optionGroup2.addItem("Option 2");
- form.addField("Option Group 2", optionGroup2);
-
- // TODO could add more different fields
-
- return form;
- }
-
- @Override
- protected String getDescription() {
- return "Fields on a form should not show the error indicator if required and empty";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4013;
- }
-
-}
+package com.vaadin.tests.validation;
+
+import java.util.Date;
+
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.AbstractValidator;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Select;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.Reindeer;
+
+public class EmptyFieldErrorIndicators extends TestBase {
+
+ @Override
+ protected void setup() {
+ getLayout().setSizeFull();
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setSizeFull();
+ hl.setSpacing(true);
+
+ ComponentContainer part1 = createPart(
+ "Empty required fields validation", true, false);
+ part1.setDebugId("emptyFieldPart");
+ hl.addComponent(part1);
+
+ ComponentContainer part2 = createPart(
+ "Empty required fields with failing validator", true, true);
+ part1.setDebugId("validatedFieldPart");
+ hl.addComponent(part2);
+
+ Panel panel = new Panel();
+ panel.setSizeFull();
+ panel.setStyleName(Reindeer.PANEL_LIGHT);
+ panel.addComponent(hl);
+ panel.setScrollable(true);
+ addComponent(panel);
+ }
+
+ private ComponentContainer createPart(String caption, boolean required,
+ boolean failValidator) {
+ VerticalLayout part = new VerticalLayout();
+ part.setMargin(true);
+
+ final Form form = createForm(required, failValidator);
+ part.addComponent(form);
+
+ Button validate = new Button("Validate fields");
+ validate.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ try {
+ form.validate();
+ } catch (InvalidValueException e) {
+ }
+ }
+ });
+ part.addComponent(validate);
+
+ Panel panel = new Panel(caption, part);
+ panel.setHeight("100%");
+ return panel;
+ }
+
+ private Form createForm(final boolean required, final boolean failValidator) {
+ // hand-crafted form, not using form field factory
+ final Form form = new Form() {
+ @Override
+ public void addField(Object propertyId, Field field) {
+ super.addField(propertyId, field);
+ field.setRequired(required);
+ field.setRequiredError("Missing required value!");
+ if (failValidator && !(field instanceof Button)) {
+ field.addValidator(new AbstractValidator("Validation error") {
+ public boolean isValid(Object value) {
+ return false;
+ }
+ });
+ }
+ }
+ };
+
+ form.addField("Field", new TextField("Text"));
+ form.addField("Date", new DateField("Date"));
+ // not good for automated testing with screenshots when null
+ // form.addField("Inline Date", new InlineDateField("Date"));
+ // same as basic DateField
+ // form.addField("Popup Date", new PopupDateField("Date"));
+ Button setDateButton = new Button("Set date");
+ form.addField("Set Date", setDateButton);
+ setDateButton.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ form.getField("Date").setValue(new Date(0));
+ }
+ });
+
+ NativeSelect nativeSelect = new NativeSelect("NativeSelect");
+ form.addField("Native Select", nativeSelect);
+ nativeSelect.addItem("Value 1");
+
+ // in #4103, the Select component was behaving differently from others
+ form.addField("Select", new Select("Select"));
+
+ Select select2 = new Select("Select 2");
+ select2.addItem("Value 1");
+ form.addField("Select 2", select2);
+
+ OptionGroup optionGroup = new OptionGroup("OptionGroup");
+ optionGroup.setMultiSelect(false);
+ optionGroup.addItem("Option 1");
+ optionGroup.addItem("Option 2");
+ form.addField("Option Group 1", optionGroup);
+
+ OptionGroup optionGroup2 = new OptionGroup("OptionGroup");
+ optionGroup2.setMultiSelect(true);
+ optionGroup2.addItem("Option 1");
+ optionGroup2.addItem("Option 2");
+ form.addField("Option Group 2", optionGroup2);
+
+ // TODO could add more different fields
+
+ return form;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Fields on a form should not show the error indicator if required and empty";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 4013;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java
index 396b244758..51c4f5ecc8 100644
--- a/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java
+++ b/tests/testbench/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java
@@ -1,94 +1,94 @@
-package com.vaadin.tests.validation;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.Validator;
-import com.vaadin.data.validator.IntegerValidator;
-import com.vaadin.data.validator.StringLengthValidator;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.TextField;
-
-public class ValidationOfRequiredEmptyFields extends TestBase {
-
- private TextField tf;
- private CheckBox requiredInput;
- private TextField requiredErrorInput;
-
- private Validator integerValidator = new IntegerValidator(
- "Must be an integer");
- private Validator stringLengthValidator = new StringLengthValidator(
- "Must be 5-10 chars", 5, 10, false);
- private CheckBox integerValidatorInput;
- private CheckBox stringLengthValidatorInput;
-
- @Override
- protected void setup() {
- requiredInput = new CheckBox("Field required");
- requiredInput.setImmediate(true);
- requiredInput.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- tf.setRequired((Boolean) requiredInput.getValue());
- }
- });
-
- requiredErrorInput = new TextField("Required error message");
- requiredErrorInput.setImmediate(true);
- requiredErrorInput.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- tf.setRequiredError((String) requiredErrorInput.getValue());
- }
- });
-
- integerValidatorInput = new CheckBox("Integer.parseInt validator");
- integerValidatorInput.setImmediate(true);
- integerValidatorInput.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- if ((Boolean) integerValidatorInput.getValue()) {
- tf.addValidator(integerValidator);
- } else {
- tf.removeValidator(integerValidator);
- }
- }
- });
- stringLengthValidatorInput = new CheckBox(
- "stringLength.parseInt validator");
- stringLengthValidatorInput.setImmediate(true);
- stringLengthValidatorInput.addListener(new ValueChangeListener() {
-
- public void valueChange(ValueChangeEvent event) {
- if ((Boolean) stringLengthValidatorInput.getValue()) {
- tf.addValidator(stringLengthValidator);
- } else {
- tf.removeValidator(stringLengthValidator);
- }
- }
- });
-
- tf = new TextField();
- tf.setImmediate(true);
-
- requiredInput.setValue(false);
- requiredErrorInput.setValue("");
- integerValidatorInput.setValue(false);
- stringLengthValidatorInput.setValue(false);
-
- addComponent(requiredInput);
- addComponent(requiredErrorInput);
- addComponent(integerValidatorInput);
- addComponent(stringLengthValidatorInput);
- addComponent(tf);
- }
-
- @Override
- protected String getDescription() {
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3851;
- }
-
-}
+package com.vaadin.tests.validation;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.data.validator.IntegerValidator;
+import com.vaadin.data.validator.StringLengthValidator;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.TextField;
+
+public class ValidationOfRequiredEmptyFields extends TestBase {
+
+ private TextField tf;
+ private CheckBox requiredInput;
+ private TextField requiredErrorInput;
+
+ private Validator integerValidator = new IntegerValidator(
+ "Must be an integer");
+ private Validator stringLengthValidator = new StringLengthValidator(
+ "Must be 5-10 chars", 5, 10, false);
+ private CheckBox integerValidatorInput;
+ private CheckBox stringLengthValidatorInput;
+
+ @Override
+ protected void setup() {
+ requiredInput = new CheckBox("Field required");
+ requiredInput.setImmediate(true);
+ requiredInput.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ tf.setRequired((Boolean) requiredInput.getValue());
+ }
+ });
+
+ requiredErrorInput = new TextField("Required error message");
+ requiredErrorInput.setImmediate(true);
+ requiredErrorInput.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ tf.setRequiredError((String) requiredErrorInput.getValue());
+ }
+ });
+
+ integerValidatorInput = new CheckBox("Integer.parseInt validator");
+ integerValidatorInput.setImmediate(true);
+ integerValidatorInput.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ if ((Boolean) integerValidatorInput.getValue()) {
+ tf.addValidator(integerValidator);
+ } else {
+ tf.removeValidator(integerValidator);
+ }
+ }
+ });
+ stringLengthValidatorInput = new CheckBox(
+ "stringLength.parseInt validator");
+ stringLengthValidatorInput.setImmediate(true);
+ stringLengthValidatorInput.addListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ if ((Boolean) stringLengthValidatorInput.getValue()) {
+ tf.addValidator(stringLengthValidator);
+ } else {
+ tf.removeValidator(stringLengthValidator);
+ }
+ }
+ });
+
+ tf = new TextField();
+ tf.setImmediate(true);
+
+ requiredInput.setValue(false);
+ requiredErrorInput.setValue("");
+ integerValidatorInput.setValue(false);
+ stringLengthValidatorInput.setValue(false);
+
+ addComponent(requiredInput);
+ addComponent(requiredErrorInput);
+ addComponent(integerValidatorInput);
+ addComponent(stringLengthValidatorInput);
+ addComponent(tf);
+ }
+
+ @Override
+ protected String getDescription() {
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3851;
+ }
+
+}